/* Cresslet Studio. Tokens first; every color pair below meets WCAG AA (text ≥ 4.5:1, UI boundaries ≥ 3:1). */
@font-face {
  font-family: "Geist";
  src: url("./vendor/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("./vendor/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #111114;
  --surface-2: #18181c;
  --surface-3: #202026;
  --line: #26262d;
  --line-strong: #63636f; /* form control edges: ≥ 3:1 on every surface */
  --text: #ededf0;
  --text-2: #a1a1aa;
  --text-3: #8e8e98;
  --accent: #6d4aff;
  --accent-hover: #5f3df0; /* white on it: 6.2:1 */
  --accent-ink: #ffffff;
  --accent-text: #a996ff;
  --accent-soft: #6d4aff26;
  --success: #4ade94;
  --success-soft: #4ade941f;
  --warn: #f5b84a;
  --warn-soft: #f5b84a1f;
  --danger: #ff7a7a;
  --danger-soft: #ff7a7a1a;
  --focus: #a996ff;
  --seg-db: #38bdf8;
  --seg-files: #f5b84a;
  --grid-line: #ffffff0a;
  --shadow: 0 1px 0 #ffffff08 inset, 0 12px 40px -12px #000c;
  --radius: 10px;
  --radius-sm: 7px;
  --sans: "Geist", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f6;
    --surface-3: #ececf0;
    --line: #e4e4e9;
    --line-strong: #8a8a96;
    --text: #18181b;
    --text-2: #55555f;
    --text-3: #63636e;
    --accent: #5b3df5;
    --accent-hover: #4b2ee0;
    --accent-text: #5232e6;
    --accent-soft: #5b3df51a;
    --success: #0f7a52;
    --success-soft: #0f7a521a;
    --warn: #8f5a00;
    --warn-soft: #f5b84a2e;
    --danger: #c42b2b;
    --danger-soft: #c42b2b14;
    --focus: #5232e6;
    --seg-db: #0369a1;
    --seg-files: #a16207;
    --grid-line: #0000000a;
    --shadow: 0 1px 2px #0000000d, 0 12px 40px -16px #00000040;
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--accent-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Headings and regions take focus only programmatically (after navigation); they aren't controls, so no ring. */
[tabindex="-1"]:focus { outline: none; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.error { color: var(--danger); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  transform: translateY(-160%); transition: transform 150ms ease;
}
.skip-link:focus { transform: none; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px;
  padding: 6px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background-color 120ms, border-color 120ms, color 120ms, transform 120ms;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
.btn.sm { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer; text-decoration: none; transition: background-color 120ms, color 120ms;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.input {
  width: 100%; min-height: 36px; padding: 7px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus-visible { outline-offset: 0; border-color: var(--focus); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.row { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.row.start { justify-content: flex-start; align-items: center; }

/* ------------------------------------------------------------------ app shell */
/* Pages scroll the document (zoom, find-in-page and mobile browsers behave); the workspace fills the viewport. */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.app[data-view="workspace"] { grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; }
.app[data-view="workspace"] .sidebar { display: none; }
.content { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.app[data-view="workspace"] .content { overflow: hidden; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line); padding: 14px 12px 12px;
}
.brand {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px 14px; color: var(--text);
  text-decoration: none; font-weight: 650; font-size: 15px; letter-spacing: -0.01em;
}
.brand-mark { width: 22px; height: 22px; color: var(--accent-text); flex: none; }
.brand-tag {
  margin-left: auto; font-size: 11px; font-weight: 500; color: var(--text-2); letter-spacing: 0;
  border: 1px solid var(--line); border-radius: 999px; padding: 0 7px;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav ul { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 11.5px; font-weight: 500; color: var(--text-3); padding: 10px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 5px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
  transition: background-color 120ms, color 120ms;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent-text); }
.nav a[aria-current="page"] .icon { color: var(--accent-text); }
.nav .trail { margin-left: auto; width: 13px; height: 13px; opacity: 0.7; }
.recent a { font-weight: 400; }
.recent a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.recent .dot { margin: 0 4px; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.account {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 6px 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface-2);
  font-weight: 500; cursor: pointer; text-align: left; transition: background-color 120ms;
}
.account:hover { background: var(--surface-3); }
#account-label { position: relative; } /* clips its visually hidden suffix with the label */
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ------------------------------------------------------------------ pages */
.page { width: 100%; max-width: 1040px; margin: 0 auto; padding: 40px 32px 72px; }
.page.narrow { max-width: 720px; }
.page.wide { max-width: 1200px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head > div { min-width: 0; overflow-wrap: anywhere; }
.page-head h1 { font-size: 26px; margin-bottom: 4px; overflow-wrap: anywhere; }
.page-head h1 a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--line-strong); text-decoration-thickness: 1px; }
.page-head h1 a:hover { color: var(--text); text-decoration-color: currentColor; }
.block { margin-top: 36px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.block-head h2 { font-size: 15px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel > h2 { font-size: 14px; margin-bottom: 14px; }
.panel.split { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.callout { overflow-wrap: anywhere; border-color: var(--accent); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
.callout:focus { outline: none; }
.kv { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.block.first { margin-top: 0; }
.cli-panel h2 { font-size: 14px; margin-bottom: 2px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2);
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 3px 12px 3px 10px; margin-bottom: 18px;
}
.eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.accent-text { color: var(--accent-text); }
.lede { color: var(--text-2); font-size: 16px; line-height: 1.6; max-width: 44rem; margin-top: 16px; }
.cli-box {
  display: flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 4px 4px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg);
}
.cli-box code { background: none; padding: 0; font-size: 13px; overflow-x: auto; white-space: nowrap; }
.cli-prompt { color: var(--text-3); user-select: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; min-height: 132px;
  padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; transition: border-color 150ms, background-color 150ms, transform 150ms;
}
.card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.card:active { transform: translateY(1px); }
.card-icon {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; margin-bottom: 8px;
  background: var(--accent-soft); color: var(--accent-text);
}
.card-icon .icon { width: 18px; height: 18px; }
.card strong { font-size: 14.5px; font-weight: 600; }
.card .desc { color: var(--text-2); font-size: 13px; line-height: 1.5; }
.card .go { position: absolute; top: 18px; right: 18px; color: var(--text-3); transition: translate 150ms, color 150ms; }
.card:hover .go { color: var(--text); translate: 3px 0; }

/* lists + tables */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list > .list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list > .list-row:first-child { border-top: 0; }
.list > .list-row .tok { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.list > .list-row .tok strong { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; overflow-wrap: anywhere; }
.list ~ .panel { margin-top: 16px; }
.list > .list-row .meta { color: var(--text-2); font-size: 12.5px; margin-left: auto; text-align: right; overflow-wrap: anywhere; }
.list > .list-row .tok .meta { margin-left: 0; text-align: left; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 32px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--text-2);
}
.empty-state strong { color: var(--text); font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 500; line-height: 18px; white-space: nowrap;
  color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 0 8px; margin-left: 8px; vertical-align: 1px;
}
/* position: contains the visually hidden header text, which would otherwise widen the page */
.table-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table caption { text-align: left; }
.table th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.table td { padding: 11px 16px; border-top: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; }
.table td a { color: var(--text); text-decoration: none; font-weight: 500; }
.table td a:hover { color: var(--accent-text); text-decoration: underline; }
.table td .sub { display: block; max-width: 20rem; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); font-size: 12.5px; }
.table tr[data-deleted] td:not(:last-child) { color: var(--text-2); }
.table .actions { text-align: right; width: 1%; }
.table .actions > * { margin-left: 4px; vertical-align: middle; }
.table .empty { color: var(--text-2); text-align: center; padding: 28px; }
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell .file-ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); flex: none; }
.ext { display: inline-flex; align-items: center; gap: 4px; }
.ext .icon { width: 12px; height: 12px; }

/* status pills: dot + text, never color alone */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; line-height: 20px;
  padding: 0 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.pill[data-s="running"], .pill[data-s="live"] { color: var(--success); background: var(--success-soft); border-color: transparent; }
.pill[data-s="deleted"] { color: var(--danger); background: var(--danger-soft); border-color: transparent; }

.dot[data-s="running"], .dot[data-s="live"], .pill[data-s="running"] .dot, .pill[data-s="live"] .dot { background: var(--success); }
.dot[data-s="deleted"], .pill[data-s="deleted"] .dot { background: var(--danger); }
.dot[data-s="idle"], .pill[data-s="idle"] .dot { background: var(--text-3); }

/* forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form h3 { font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 500; padding: 0; }
.field > legend { margin-bottom: 8px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; min-height: 28px; min-width: 0; max-width: 100%; cursor: pointer; }
.check > span { min-width: 0; overflow-wrap: anywhere; }
.token-row { display: flex; gap: 8px; margin: 12px 0; }
.token-row .input { flex: 1; min-width: 0; }
.list > .list-row .role-select { width: auto; min-height: 28px; padding: 3px 8px; }
.token-apps { display: flex; flex-wrap: wrap; gap: 2px 18px; margin: 4px 0 0 26px; }
.token-new p { margin: 0; }

/* toast */
.toast {
  position: fixed; z-index: 50; bottom: 20px; right: 20px; display: flex; align-items: flex-start; gap: 8px;
  max-width: min(32rem, calc(100% - 32px)); padding: 10px 8px 10px 16px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  transition: opacity 160ms, translate 160ms;
}
.toast[data-open="false"] { opacity: 0; translate: 0 8px; pointer-events: none; padding: 0; border: 0; box-shadow: none; }
.toast[data-top="true"] { bottom: auto; top: 20px; }
.toast[data-top="hide"] { opacity: 0; pointer-events: none; } /* stays in the accessibility tree */
.toast-body { padding-top: 4px; overflow-wrap: anywhere; }
.toast-body a { color: var(--accent-text); }

/* ------------------------------------------------------------------ workspace */
.topbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar-home { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); }
.topbar-home:hover { background: var(--surface-3); }
.project-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb-sep { color: var(--text-3); }
#project-name {
  min-width: 0; width: 16rem; padding: 5px 8px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; font-weight: 600;
}
#project-name:hover { border-color: var(--line-strong); }
#project-name:focus-visible { border-color: var(--focus); outline-offset: 0; background: var(--bg); }
.status {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status[data-state="busy"] { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.status[data-state="busy"] .status-dot { animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="ready"] { color: var(--success); background: var(--success-soft); border-color: transparent; }
.status[data-state="error"] { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
@keyframes pulse { 50% { opacity: 0.35; } }
.spacer { flex: 1; }
.deploy-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; max-width: 22rem; min-width: 0; }
.deploy-url { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace {
  flex: 1; min-height: 0; display: grid; gap: 1px; background: var(--line); overflow: auto;
  grid-template-columns: 232px minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(220px, 1fr) minmax(140px, 240px);
}
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.files { grid-row: 1 / 3; }
.bottom-pane { grid-column: 2 / 4; }
.pane-head {
  height: 38px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 6px 0 12px;
  border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 12.5px;
}
.pane-title { flex: 1; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.pane-head .crumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tree { overflow: auto; padding: 6px; flex: 1; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree li > button, .tree li > .dir {
  display: flex; align-items: center; gap: 7px; width: 100%; min-height: 28px; padding: 3px 8px;
  padding-left: calc(8px + var(--depth, 0) * 14px); border: 0; border-radius: 6px; background: none;
  font: 13px/1.3 var(--mono); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree li > button { color: var(--text); cursor: pointer; }
.tree li > button:hover { background: var(--surface-3); }
.tree li > button[aria-current="true"] { background: var(--accent-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--accent-text); }
.tree li > .dir { color: var(--text-2); }
.tree .icon { width: 14px; height: 14px; color: var(--text-3); }
.tree li > button[aria-current="true"] .icon { color: var(--accent-text); }
/* How to leave the editor/terminal (Tab is theirs): a status row under each, outside the scroll areas. */
.pane-foot { flex: none; padding: 4px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2); }
.pane-foot kbd { font: 500 11px var(--mono); padding: 0 4px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text); }
.editor { flex: 1; min-height: 0; overflow: hidden; }
/* The editor's ring sits on an overlay: CodeMirror's opaque layers and sticky gutters (z-index 200) cover its box. */
.editor { position: relative; isolation: isolate; } /* its z-indexes stay below the toast and skip link */
.editor:focus-within::after { content: ""; position: absolute; inset: 0; z-index: 201; pointer-events: none; outline: 2px solid var(--focus); outline-offset: -2px; }
.terminal:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; }
.editor .cm-editor.cm-focused { outline: none; }
.editor .cm-editor { height: 100%; }
.editor .cm-editor, .editor .cm-gutters { background: var(--surface) !important; }
.editor .cm-gutters { border-right: 1px solid var(--line) !important; color: var(--text-3) !important; }
.editor .cm-scroller { font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.urlbar {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); color: var(--text-3);
}
.urlbar:focus-within { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
.urlbar .icon { width: 13px; height: 13px; }
#preview-path { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); padding: 2px 0; font-size: 12.5px; }
#preview-path:focus-visible { outline: none; }
/* Transparent: an app that follows light/dark gets the studio's scheme; one that doesn't gets an opaque canvas
   in its own scheme from the browser (so its text never lands on a mismatched background). */
.preview-body { position: relative; flex: 1; min-height: 0; background: var(--surface); }
.preview-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; }
.preview-empty {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  background: var(--surface); color: var(--text-2);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
}
.preview-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 26rem; line-height: 1.6; }
.preview-empty .btn { margin: 0 4px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent-text);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }
.tabs { gap: 2px; padding-left: 6px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; border-radius: 6px;
  border: 0; background: none; color: var(--text-2); font-weight: 500; cursor: pointer;
}
.tab .icon { width: 14px; height: 14px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface-3); box-shadow: inset 0 -2px 0 var(--accent-text); }
.terminal { flex: 1; min-height: 0; padding: 6px 0 0 10px; background: var(--surface); }
.terminal .xterm-viewport { background: var(--surface) !important; }
/* xterm draws dim (SGR 2) text at 50% of its color, under 4.5:1 here: use the muted text color instead
   (colored dim text turns muted too; the studio's own output only dims plain text). */
.terminal .xterm-rows .xterm-dim { color: var(--text-2) !important; }
.deploy-log { flex: 1; margin: 0; padding: 12px 14px; overflow: auto; white-space: pre-wrap; color: var(--text-2); font-size: 12.5px; line-height: 1.6; }

/* ------------------------------------------------------------------ admin */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.stat .label { color: var(--text-2); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--text-2); letter-spacing: 0; }
.stat .sub { color: var(--text-2); font-size: 12.5px; overflow-wrap: anywhere; }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 16px; margin-bottom: 16px; overflow-wrap: anywhere; }
.banner.deleted { border-color: var(--danger); background: linear-gradient(var(--danger-soft), var(--danger-soft)), var(--surface); }
.usage-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.usage-bar span { min-width: 3px; }
.seg-deploys { background: var(--accent-text); }
.seg-database { background: var(--seg-db); }
.seg-files { background: var(--seg-files); }
.table-wrap + p { margin-top: 12px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; color: var(--text-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin: 28px 0 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 12rem; }
.search .icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 34px; background: var(--surface); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 2px; background: var(--surface); gap: 2px; }
.seg button { border: 0; background: none; color: var(--text-2); min-height: 30px; padding: 3px 12px; border-radius: 5px; cursor: pointer; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent-text); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.detail-grid .table td, .detail-grid .table th { padding: 8px 0; }
.detail-grid .table td + td, .detail-grid .table th + th { padding-left: 16px; }
.detail-grid .table tbody tr:hover td { background: none; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.scroll-x { position: relative; overflow-x: auto; }
.mt { margin-top: 22px !important; }


/* ------------------------------------------------------------------ landing (logged out, no projects) */
.app[data-view="landing"] { grid-template-columns: minmax(0, 1fr); }
.app[data-view="landing"] .sidebar { display: none; }
.app[data-view="landing"] .content { overflow-x: clip; } /* full-bleed decoration; clip keeps the nav sticky */
.site-nav {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: 60px;
  padding: 0 max(20px, calc((100% - 1120px) / 2 + 24px));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 15.5px; letter-spacing: -0.01em; margin-right: 18px; }
.site-brand.small { font-size: 13.5px; margin: 0; }
.site-brand.small .brand-mark { width: 18px; height: 18px; }
.site-links { display: flex; gap: 2px; }
.site-links a, .l-foot a { color: var(--text-2); text-decoration: none; font-weight: 500; padding: 6px 10px; border-radius: var(--radius-sm); transition: color 120ms, background-color 120ms; }
.site-links a:hover, .l-foot a:hover { color: var(--text); background: var(--surface-2); }

.landing { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.landing h2 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.12; letter-spacing: -0.03em; font-weight: 650; }
.landing h3 { font-size: 15px; }
.landing code { font-size: 0.88em; }
.kicker { color: var(--accent-text); font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.l-sub { color: var(--text-2); font-size: 16px; line-height: 1.6; max-width: 40rem; margin-top: 12px; }

.l-hero { position: relative; isolation: isolate; text-align: center; padding: 84px 0 0; }
.l-hero::before { /* a quiet blueprint grid, fading out */
  content: ""; position: absolute; z-index: -1; top: 0; left: 50%; translate: -50% 0; width: 100vw; height: 640px;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px; background-position: center -1px;
  mask-image: radial-gradient(ellipse 60% 80% at 50% 0%, #000 30%, transparent 100%);
}
.l-hero::after {
  content: ""; position: absolute; z-index: -1; width: min(900px, 100vw); height: 520px; top: -260px; left: 50%; translate: -50% 0;
  background: radial-gradient(closest-side, var(--accent-soft), transparent); filter: blur(20px);
}
.l-hero h1 { font-size: clamp(38px, 6.6vw, 70px); line-height: 1.02; letter-spacing: -0.045em; font-weight: 680; max-width: 15ch; margin: 0 auto; }
.l-hero h1 .accent-text { display: block; }
.l-hero .lede { margin: 22px auto 0; font-size: clamp(16px, 1.7vw, 18.5px); max-width: 37rem; }
.cta-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 32px; }
.btn.lg { min-height: 44px; padding: 10px 20px; font-size: 15px; border-radius: 9px; }
.btn.lg .icon { width: 17px; height: 17px; }
.cta-row .btn .icon { transition: translate 150ms; }
.cta-row .btn.primary:hover .icon { translate: 2px 0; }
.l-note { margin: 16px auto 0; font-size: 13px; color: var(--text-2); max-width: 36rem; }

/* the studio, drawn */
.mock {
  position: relative; margin: 60px auto 0; max-width: 1040px; text-align: left; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow), 0 40px 120px -30px var(--accent-soft);
}
.mock-bar { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.mock-dots { display: inline-flex; gap: 6px; }
.mock-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line); }
.mock-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin-left: 6px; }
.mock-name .brand-mark { width: 16px; height: 16px; }
.mock-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--success); background: var(--success-soft); border-radius: 999px; padding: 1px 9px; }
.mock-deploy { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; color: var(--accent-ink); background: var(--accent); border-radius: var(--radius-sm); padding: 5px 12px; }
.mock-deploy .icon { width: 14px; height: 14px; }
.mock-body { display: grid; grid-template-columns: 180px minmax(0, 1.25fr) minmax(0, 1fr); min-height: 320px; }
.mock-files { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-right: 1px solid var(--line); font: 12.5px/1.3 var(--mono); color: var(--text); }
.mock-files span { padding: 5px 8px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-files .mock-dir { color: var(--text-2); }
.mock-files .d1 { padding-left: 22px; }
.mock-files .on { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent-text); }
.mock-code { margin: 0; padding: 16px 18px; border-right: 1px solid var(--line); font: 12.5px/1.75 var(--mono); color: var(--text); white-space: pre; overflow: hidden; }
.mock-code .k { color: var(--accent-text); }
.mock-code .s { color: var(--success); }
.mock-code .f { color: var(--seg-db); }
.mock-code .c { color: var(--text-3); }
.mock-preview { display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.mock-url { display: flex; align-items: center; gap: 6px; margin: 8px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; font: 12px var(--mono); color: var(--text-2); white-space: nowrap; overflow: hidden; }
.mock-url .icon { width: 12px; height: 12px; }
.mock-app { display: flex; flex-direction: column; gap: 8px; padding: 18px 22px; }
.mock-app strong { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 4px; }
.mock-input { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--text-3); font-size: 13px; }
.mock-todo { display: flex; align-items: center; gap: 9px; font-size: 13.5px; padding: 4px 0; }
.mock-todo i { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--line-strong); flex: none; }
.mock-todo.done { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--text-3); }
.mock-todo.done i { background: var(--accent); border-color: var(--accent); }
.mock-toast {
  position: absolute; right: 16px; bottom: 16px; display: inline-flex; align-items: center; gap: 8px; max-width: calc(100% - 32px);
  padding: 8px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: mock-pop 500ms 900ms both cubic-bezier(.2, .8, .2, 1);
}
.mock-toast .js-app-host { font-family: var(--mono); font-size: 12.5px; color: var(--accent-text); }
@keyframes mock-pop { from { opacity: 0; translate: 0 10px; } }

.l-section { padding-top: 112px; }
.l-section > h2, .l-section > .kicker, .l-section > .l-sub { text-align: center; margin-left: auto; margin-right: auto; }
.l-section > h2 { max-width: 30ch; }
.steps code { white-space: nowrap; }
#landing-templates-title { scroll-margin-top: 100px; }

.steps { list-style: none; margin: 44px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: none; }
.steps li { position: relative; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.step-n {
  display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 18px; border-radius: 50%;
  font: 600 13px var(--mono); color: var(--accent-text); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent-text) 35%, transparent);
}
.steps h3, .features h3 { margin-bottom: 6px; }
.steps p, .features p { color: var(--text-2); line-height: 1.6; }

.features {
  list-style: none; margin: 44px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
.features li { padding: 28px 26px; background: var(--surface); transition: background-color 150ms; }
.features li:hover { background: var(--surface-2); }
.feature-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 18px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); }
.feature-icon .icon { width: 19px; height: 19px; }

.l-templates { margin-top: 36px; grid-template-columns: repeat(auto-fit, minmax(260px, 340px)); justify-content: center; }
.l-templates .card { min-height: 150px; padding: 22px; }

.l-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 56px; align-items: center; }
.l-split .l-sub { margin-left: 0; }
.checks { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checks li { display: flex; align-items: flex-start; gap: 10px; }
.checks .icon { color: var(--success); margin-top: 3px; }
.term { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow); min-width: 0; }
.term-bar { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--line); }
.term-title { flex: 1; font-size: 12.5px; color: var(--text-2); }
.term-body { margin: 0; padding: 18px 20px 20px; overflow-x: auto; font: 13px/1.9 var(--mono); }
.term-body code { background: none; padding: 0; font-size: inherit; }
.term-body .p { color: var(--text-3); user-select: none; }
.term-body .ok { color: var(--success); }
.term-body .js-app-url { color: var(--accent-text); }

.l-cta {
  position: relative; isolation: isolate; overflow: hidden; margin-top: 112px; padding: 64px 32px; text-align: center;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
}
.l-cta::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(ellipse 60% 90% at 50% 100%, var(--accent-soft), transparent 70%);
}
.l-cta .l-sub { margin: 12px auto 0; }
.l-cta .cta-row { margin-top: 28px; }
.l-foot { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; margin-top: 56px; padding: 22px 0 32px; border-top: 1px solid var(--line); font-size: 13px; }
.l-foot a { padding: 4px 8px; }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .brand { padding: 4px 6px; }
  .brand-tag { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; gap: 0 8px; }
  .nav-label, #recent-wrap { display: none; }
  .nav ul { flex-direction: row; flex-wrap: wrap; margin: 0; }
  .sidebar-foot { border: 0; padding: 0; margin: 0; order: 4; }
  .account { width: auto; max-width: 14rem; }
  .page { padding: 24px 16px 56px; }
  .landing { padding: 0 16px; }
  .site-nav { padding: 0 16px; }
  .site-links { display: none; }
  .l-hero { padding-top: 56px; }
  .mock-body { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .mock-files { display: none; }
  .l-section { padding-top: 80px; }
  .steps, .features { grid-template-columns: minmax(0, 1fr); }
  .l-split { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .l-cta { margin-top: 80px; padding: 44px 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: 180px minmax(280px, 1fr) minmax(280px, 1fr) 220px; overflow: auto; }
  .files { grid-row: auto; }
  .bottom-pane { grid-column: auto; }
  .topbar { flex-wrap: wrap; height: auto; min-height: 52px; padding: 8px 12px; }
  #project-name { width: 9rem; }
  .deploy-link { min-width: 0; flex: 0 1 auto; }
  .list > .list-row { flex-wrap: wrap; }
  .list > .list-row .meta { margin-left: 0; text-align: left; }
}
@media (min-width: 640px) and (max-width: 900px) {
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .cli-box { width: 100%; }
  .site-start { display: none; }
  .mock-bar .mock-status { display: none; }
  .mock-body { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .mock-code { display: none; }
  .mock-toast { position: static; margin: 0 12px 12px; }
  .l-templates { grid-template-columns: minmax(0, 1fr); }
  .cta-row .btn { flex: 1 1 100%; }
  .cli-box code { font-size: 12px; white-space: normal; overflow-wrap: anywhere; flex: 1; }
}

/* ------------------------------------------------------------------ preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  :root { --line: var(--line-strong); --text-2: var(--text); --text-3: var(--text); }
}
@media (forced-colors: active) {
  .btn, .icon-btn, .card, .tab, .seg button, .account, .pill, .status, .nav a, .tree li > button { border: 1px solid ButtonText; }
  .nav a[aria-current="page"], .tab[aria-selected="true"], .seg button[aria-pressed="true"], .tree li > button[aria-current="true"] {
    forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight;
  }
  .dot, .status-dot, .eyebrow-dot { forced-color-adjust: none; background: CanvasText; }
  .mock, .term, .steps li, .features, .l-cta, .site-nav { border: 1px solid CanvasText; }
  .usage-bar span { forced-color-adjust: none; border: 1px solid CanvasText; }
  .brand-mark { color: CanvasText; }
  .nav a[aria-current="page"] .icon, .tree li > button[aria-current="true"] .icon { color: inherit; }
  :focus-visible, .editor:focus-within::after, .terminal:focus-within { outline-color: Highlight; }
}
