:root {
  --bg: #0b0d0e;
  --surface: #111416;
  --surface-raised: #171a1d;
  --line: #2a2e32;
  --line-soft: #202427;
  --text: #eef1f2;
  --muted: #9aa1a6;
  --faint: #686f74;
  --green: #3ecf8e;
  --green-bright: #54e1a2;
  --green-ink: #052e20;
  --amber: #f5b942;
  --red: #f87171;
  --shadow: 0 24px 80px rgb(0 0 0 / 42%);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 75% -10%, rgb(62 207 142 / 8%), transparent 30rem),
    linear-gradient(var(--bg), #0a0c0d);
  font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgb(11 13 14 / 86%);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: .95rem;
  font-weight: 650;
  letter-spacing: -.01em;
  text-decoration: none;
}

.brand-mark { width: 25px; height: 25px; color: var(--green); filter: drop-shadow(0 6px 12px rgb(62 207 142 / 20%)); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 5px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

.connection-badge span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgb(104 111 116 / 12%); }
.connection-badge.online span { background: var(--green); box-shadow: 0 0 0 4px rgb(62 207 142 / 12%); }
.connection-badge.online { color: #b7c2bd; }

.workspace { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 58px 0 100px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: .72rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.05; font-weight: 650; }
h2 { font-size: 1.35rem; line-height: 1.2; font-weight: 650; }
.intro { max-width: 620px; margin: 12px 0 0; color: var(--muted); }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 650;
  text-decoration: none;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-primary { color: var(--green-ink); background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-bright); border-color: var(--green-bright); }
.button-secondary { color: #d4d9dc; background: var(--surface); border-color: var(--line); }
.button-secondary:hover { background: var(--surface-raised); border-color: #3a4045; }
.button-icon { width: 40px; padding: 0; }

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 520px;
  margin-bottom: 32px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgb(17 20 22 / 70%);
}

.summary div { display: flex; align-items: baseline; gap: 9px; padding: 13px 16px; border-right: 1px solid var(--line-soft); }
.summary div:last-child { border-right: 0; }
.summary span { font-size: 1.05rem; font-weight: 700; }
.summary small { color: var(--faint); font-size: .75rem; }

.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.project-card, .new-card, .empty-state, .skeleton-card {
  min-height: 230px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: linear-gradient(145deg, rgb(23 26 29 / 82%), rgb(15 18 20 / 92%));
}

.project-card { display: flex; flex-direction: column; padding: 20px; transition: border-color .18s ease, transform .18s ease; }
.project-card:hover { border-color: #39413f; transform: translateY(-2px); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.project-icon { display: grid; width: 39px; height: 39px; place-items: center; border: 1px solid rgb(62 207 142 / 22%); border-radius: 8px; color: var(--green); background: rgb(62 207 142 / 8%); }
.project-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.status { display: inline-flex; align-items: center; gap: 7px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: capitalize; }
.status::before { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); content: ""; }
.status.running { color: #8be7bb; border-color: rgb(62 207 142 / 22%); background: rgb(62 207 142 / 7%); }
.status.running::before { background: var(--green); }
.status.creating, .status.starting { color: #ffd480; border-color: rgb(245 185 66 / 24%); background: rgb(245 185 66 / 7%); }
.status.creating::before, .status.starting::before { background: var(--amber); animation: pulse 1.2s infinite; }
.project-name { margin: 17px 0 2px; overflow: hidden; font-size: 1rem; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.project-ref { color: var(--faint); font: .74rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.endpoint { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 17px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgb(6 8 9 / 44%); color: var(--muted); font: .73rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; }
.endpoint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { padding: 0; border: 0; color: var(--faint); background: transparent; cursor: pointer; }
.copy-button:hover { color: var(--text); }
.copy-button svg { display: block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 18px; }
.card-actions .button { min-height: 36px; padding: 0 11px; font-size: .78rem; }
.card-actions .open-studio { flex: 1; }
.action-icon { width: 36px; padding: 0 !important; }

.new-card { display: grid; place-items: center; padding: 20px; border-style: dashed; color: var(--muted); background: transparent; cursor: pointer; text-align: center; transition: color .18s ease, border-color .18s ease, background .18s ease; }
.new-card:hover { color: var(--green); border-color: rgb(62 207 142 / 55%); background: rgb(62 207 142 / 4%); }
.new-card strong { display: block; margin-top: 12px; color: inherit; font-size: .92rem; }
.new-card span { display: grid; width: 42px; height: 42px; margin: 0 auto; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 1.35rem; }
.empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; padding: 32px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 1rem; }
.empty-state .button { margin-top: 18px; }
.skeleton-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.skeleton-card span { height: 15px; border-radius: 5px; background: linear-gradient(90deg, #171a1d, #24282b, #171a1d); background-size: 220% 100%; animation: shimmer 1.35s infinite; }
.skeleton-card span:first-child { width: 40px; height: 40px; }
.skeleton-card span:nth-child(2) { width: 48%; margin-top: 8px; }
.skeleton-card span:last-child { width: 100%; height: 36px; margin-top: 20px; }

.dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: 1px solid #30363a;
  border-radius: 12px;
  color: var(--text);
  background: #121517;
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(0 0 0 / 70%); backdrop-filter: blur(4px); }
.dialog form { padding: 25px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-copy { margin: 15px 0 22px; color: var(--muted); font-size: .88rem; }
.close-button { width: 32px; height: 32px; padding: 0 0 3px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.35rem; }
.close-button:hover { color: var(--text); background: var(--surface-raised); }
.dialog label { display: block; margin: 15px 0 7px; color: #dfe3e5; font-size: .82rem; font-weight: 650; }
.dialog input { width: 100%; height: 43px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: var(--text); background: #0b0d0e; }
.dialog input:focus { border-color: rgb(62 207 142 / 72%); box-shadow: 0 0 0 3px rgb(62 207 142 / 9%); }
.field-hint { margin: 7px 0 0; color: var(--faint); font-size: .75rem; }
.project-spec { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.project-spec div { padding: 11px 12px; border: 1px solid var(--line-soft); border-radius: 7px; background: #0e1112; }
.project-spec span, .project-spec strong { display: block; }
.project-spec span { color: var(--faint); font-size: .7rem; }
.project-spec strong { margin-top: 3px; font-size: .78rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.form-error { min-height: 1.2em; margin: 13px 0 -8px; color: var(--red); font-size: .78rem; }
.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 30; display: grid; width: min(370px, calc(100% - 44px)); gap: 10px; }
.toast { padding: 13px 15px; border: 1px solid #344039; border-left: 3px solid var(--green); border-radius: 8px; color: #e6ebe8; background: #161a1b; box-shadow: 0 15px 45px rgb(0 0 0 / 35%); font-size: .84rem; animation: toast-in .2s ease-out; }
.toast.error { border-color: #4a3032; border-left-color: var(--red); }

@keyframes shimmer { to { background-position: -220% 0; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 880px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 610px) {
  .topbar { padding: 0 16px; }
  .connection-badge { display: none; }
  .workspace { width: min(100% - 30px, 1120px); padding-top: 38px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .summary { grid-template-columns: 1fr; max-width: none; }
  .summary div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .summary div:last-child { border-bottom: 0; }
  .project-grid { grid-template-columns: 1fr; }
  .dialog form { padding: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
