/* Motion Visuals Studio: one stylesheet, two themes. LIGHT is the default and is designed as light (warm paper, deep ink,
   amber that stays readable); DARK matches the original dark design. Colours only come from the tokens below.

   Motion rules (from the design-engineering guidelines this UI follows):
   - press feedback on everything pressable: scale(.97) in 160ms with a strong ease-out
   - UI transitions stay under 300ms, name their properties (never `all`), and use custom curves, never ease-in
   - things people see dozens of times a day (navigation, pages) don't animate; rare moments (landing, first run) may
   - hover effects only on devices that really hover; reduced motion keeps fades and drops movement */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F7F5F0;            /* warm paper */
  --bg-soft: #EFECE5;
  --surface: #FFFFFF;
  --surface-2: #FBFAF7;
  --border: #E6E2D9;
  --border-strong: #CFC9BD;
  --input-border: #8C877D;  /* 3.6:1 on white: form controls stay visible (WCAG 1.4.11) */
  --text: #17161A;
  --text-2: #3D3B42;
  --muted: #5F5C66;         /* 6.4:1 on --bg */
  --faint: #6B6873;         /* 5.0:1 on --bg, 4.6:1 on --bg-soft */
  --accent: #F5A524;        /* fills: buttons, selected chips */
  --accent-ink: #1C1205;    /* text on accent */
  --accent-text: #8F4E00;   /* links and accent text: 5.6:1 on white */
  --accent-soft: #FFF4E0;
  --accent-line: #F0CF94;
  --ok: #146C36; --ok-bg: #E6F4EA;
  --info: #1D58B0; --info-bg: #E8F0FC;
  --warn: #7A4F00; --warn-bg: #FFF1D6;
  --bad: #B3261E; --bad-bg: #FDECEA; --bad-line: #F3C2BE;
  --code-bg: #F4F1EA;
  /* surfaces are separated by soft rings and shadows, not hard 1px lines */
  --ring: 0 0 0 1px rgba(23, 22, 26, .07);
  --shadow-sm: var(--ring), 0 1px 2px rgba(23, 22, 26, .04);
  --shadow: var(--ring), 0 1px 2px rgba(23, 22, 26, .04), 0 8px 24px -8px rgba(23, 22, 26, .10);
  --shadow-pop: 0 0 0 1px rgba(23, 22, 26, .08), 0 12px 32px -6px rgba(23, 22, 26, .18);
  --focus: 0 0 0 3px rgba(245, 165, 36, .45);
  --header-bg: rgba(247, 245, 240, .78);
  --main-bg: #FFFFFF;        /* the studio's work area is white in light mode */
  --shell-header-bg: rgba(255, 255, 255, .82);
  /* motion */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --press: 160ms;
  --fast: 150ms;
  --pop: 200ms;
  --rise: 10px;
  /* shape */
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0C;
  --bg-soft: #141416;
  --surface: #151517;
  --surface-2: #111113;
  --border: #26262A;
  --border-strong: #3A3A40;
  --input-border: #6A6A72;
  --text: #F2F2F2;
  --text-2: #D6D6DB;
  --muted: #A9A9B0;
  --faint: #8E8E96;
  --accent: #FFB547;
  --accent-ink: #1A1203;
  --accent-text: #FFC56E;
  --accent-soft: #1C160A;
  --accent-line: #5A4520;
  --ok: #7EE2A0; --ok-bg: #132A1C;
  --info: #9CC3FF; --info-bg: #1B2433;
  --warn: #FFC56E; --warn-bg: #2A2010;
  --bad: #FFB4B4; --bad-bg: #2A1618; --bad-line: #5A2A2E;
  --code-bg: #0E0E10;
  --ring: 0 0 0 1px rgba(255, 255, 255, .07);
  --shadow-sm: var(--ring);
  --shadow: var(--ring), 0 1px 0 rgba(255, 255, 255, .03) inset;
  --shadow-pop: 0 0 0 1px rgba(255, 255, 255, .10), 0 16px 40px -8px rgba(0, 0, 0, .6);
  --focus: 0 0 0 3px rgba(255, 181, 71, .45);
  --header-bg: rgba(11, 11, 12, .72);
  --main-bg: var(--bg);
  --shell-header-bg: rgba(11, 11, 12, .72);
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* scrollbars stay invisible; scrolling still works by wheel, trackpad, touch and keyboard */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-feature-settings: "cv11", "ss01"; }
/* tracking is size-specific: big type tighter, small type slightly open */
h1, h2, h3, .display { font-family: "Space Grotesk", Inter, sans-serif; margin: 0; font-weight: 700; }
h1 { font-size: clamp(28px, 3.2vw, 36px); line-height: 1.1; letter-spacing: -.022em; }
h2 { font-size: 22px; line-height: 1.2; letter-spacing: -.015em; }
h3 { font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: text-decoration-thickness var(--fast) ease; }
@media (hover: hover) and (pointer: fine) { a:hover { text-decoration-thickness: 2px; } }
img { max-width: 100%; }
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
/* the outline follows each element's own shape (pills stay pills) */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 75%, transparent); outline-offset: 2px; }
.input:focus-visible, .select:focus-visible { outline: none; }
.only-sm { display: none !important; }
@media (max-width: 760px) { .only-sm { display: inline-flex !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
a.sr-only:focus { position: fixed; top: 12px; left: 12px; width: auto; height: auto; clip: auto; margin: 0; padding: 10px 14px; z-index: 100; background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--shadow-pop); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; }
.tiny { font-size: 13px; letter-spacing: .005em; }
.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 12px); }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.eyebrow { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
nav[aria-label="Breadcrumb"] a { color: var(--muted); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { nav[aria-label="Breadcrumb"] a:hover { color: var(--text); text-decoration: underline; } }

/* theme switch: ease the brightness change instead of a hard flash (only while switching) */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color 240ms ease, color 240ms ease, border-color 240ms ease, box-shadow 240ms ease, fill 240ms ease, stroke 240ms ease !important;
}

/* ---------------------------------------------------------------- logo */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand svg rect { stroke: var(--text); }
.brand svg path { fill: var(--accent); }

/* ---------------------------------------------------------------- pressables: one motion language */
.btn, .chip, .choice, .tab, .dl, .side-link, .theme-toggle, .flash-close, .linklike {
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--press) var(--ease-out), background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease, box-shadow var(--fast) ease;
}
.btn:active, .chip:active, .choice:active, .tab:active, .dl:active, .theme-toggle:active, .flash-close:active { transform: scale(.97); }
.side-link:active { transform: scale(.98); }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font: 600 15px/1.2 Inter, sans-serif; letter-spacing: -.005em; text-decoration: none; cursor: pointer; white-space: nowrap; user-select: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 1px 2px rgba(120, 70, 0, .18); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 1px 2px rgba(23, 22, 26, .04); }
[data-theme="dark"] .btn-ghost { background: transparent; border-color: var(--border-strong); box-shadow: none; }
.btn-outline-accent { background: transparent; color: var(--accent-text); border-color: var(--accent-line); }
.btn-danger { background: transparent; color: var(--bad); border-color: var(--bad-line); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: color-mix(in srgb, var(--accent) 90%, #fff); }
  [data-theme="dark"] .btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #fff); }
  .btn-ghost:hover { background: var(--bg-soft); border-color: var(--border-strong); }
  .btn-outline-accent:hover { background: var(--accent-soft); }
  .btn-danger:hover { background: var(--bad-bg); }
}
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { opacity: .75; cursor: progress; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-text); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
/* copy buttons keep their width when the label changes; a short success tint */
[data-copy] { min-width: 84px; }
[data-copy].is-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input, .select, textarea.input { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--input-border); border-radius: var(--r-sm); padding: 12px 14px; font: 16px/1.4 Inter, sans-serif; transition: border-color var(--fast) ease, box-shadow var(--fast) ease, background-color var(--fast) ease; }
[data-theme="dark"] .input, [data-theme="dark"] .select { background: #0F0F11; }
@media (hover: hover) and (pointer: fine) { .input:hover, .select:hover { border-color: var(--text-2); } }
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.hint { font-size: 13px; color: var(--faint); }
.error-text { font-size: 14px; color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--text-2); }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.code-input { font-family: "JetBrains Mono", monospace; font-size: 22px; letter-spacing: .14em; text-transform: uppercase; width: 230px; }
input[type=file] { font: 14px Inter, sans-serif; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: 600 14px Inter, sans-serif; padding: 10px 14px; margin-right: 12px; border-radius: var(--r-sm); border: 1px solid var(--input-border); background: var(--surface); color: var(--text); cursor: pointer; transition: background-color var(--fast) ease; }
@media (hover: hover) and (pointer: fine) { input[type=file]::file-selector-button:hover { background: var(--bg-soft); } }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow); }
.card-soft { background: var(--surface-2); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--ring); }
.card-accent { box-shadow: 0 0 0 1px var(--accent-line), 0 1px 2px rgba(23, 22, 26, .04), 0 8px 24px -8px rgba(143, 78, 0, .14); }
[data-theme="dark"] .card-accent { box-shadow: 0 0 0 1px var(--accent-line); }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details:not(.menu) > summary { display: flex; align-items: center; gap: 10px; }
details:not(.menu) > summary::before { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform var(--pop) var(--ease-out); margin-right: 2px; }
details[open]:not(.menu) > summary::before { transform: rotate(45deg); }
/* a summary laid out as "title … meta": the title takes the free space next to the arrow */
details > summary.between > :first-child { flex: 1 1 auto; }
/* opening a disclosure by hand: the content arrives gently (JS marks .just-opened; never on page load) */
details.just-opened:not(.menu) > :not(summary) { animation: rise var(--pop) var(--ease-out) both; }

/* ---------------------------------------------------------------- chips, choices, pills */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface); color: var(--text-2); border: 1px solid var(--border-strong); border-radius: 999px; padding: 9px 15px; font: 500 15px/1.2 Inter, sans-serif; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .chip:hover { border-color: var(--accent-line); color: var(--text); } }
.chip.on, .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip-add { border-style: dashed; color: var(--accent-text); border-color: var(--accent-line); background: transparent; }
.choice { text-align: left; display: flex; flex-direction: column; gap: 4px; background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong); border-radius: var(--r-md); padding: 16px 18px; font: inherit; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .choice:hover { border-color: var(--accent-line); } }
.choice.on, .choice[aria-pressed="true"], .choice[aria-current="true"], .choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice .sub { color: var(--muted); font-size: 14px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--bg-soft); color: var(--text-2); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-line); }

/* ---------------------------------------------------------------- flash messages */
.flash { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--r-md); padding: 14px 16px 14px 18px; background: var(--surface); box-shadow: var(--ring);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out); }
/* arrive from just above (where the eye already is); leave faster than they came */
@starting-style { .flash[data-flash] { opacity: 0; transform: translateY(-6px); } }
.flash.leaving { opacity: 0; transform: translateY(-4px); transition-duration: 140ms; }
.flash > .flash-text { flex: 1 1 auto; min-width: 0; }
.flash-ok { background: var(--ok-bg); color: var(--ok); box-shadow: none; }
.flash-bad { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-line); }
.flash-info { background: var(--info-bg); color: var(--info); box-shadow: none; }
.flash-warn { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--accent-line); }
.flash-close { background: none; border: 0; color: inherit; font-size: 22px; line-height: 1; padding: 0 2px; cursor: pointer; opacity: .65; min-width: 28px; min-height: 28px; border-radius: 8px; }
@media (hover: hover) and (pointer: fine) { .flash-close:hover { opacity: 1; } }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--faint); font-size: 12px; letter-spacing: .07em; text-transform: uppercase; font-weight: 600; padding: 12px 16px; white-space: nowrap; background: var(--surface-2); }
td { padding: 14px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background-color var(--fast) ease; }
@media (hover: hover) and (pointer: fine) { tbody tr:hover { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); } }
td.actions { text-align: right; white-space: nowrap; }
td.actions .row { justify-content: flex-end; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
/* phones: rows become small cards, so actions (Download, Revoke) stay on screen */
@media (max-width: 640px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody { display: block; }
  .table-stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 14px 16px; border-top: 1px solid var(--border); }
  .table-stack tbody tr:first-child { border-top: 0; }
  .table-stack td { display: block; padding: 0; border: 0; font-size: 14px; }
  .table-stack td:first-child { flex-basis: 100%; font-size: 15px; }
  .table-stack td.actions { margin-left: auto; text-align: right; }
}

/* ---------------------------------------------------------------- small action menus (popover from its trigger) */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu .menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; background: var(--surface); border-radius: var(--r-md); padding: 8px; box-shadow: var(--shadow-pop);
  transform-origin: top right; transition: opacity var(--fast) var(--ease-out), transform var(--fast) var(--ease-out); }
@starting-style { details.menu[open] .menu-pop { opacity: 0; transform: scale(.97) translateY(-2px); } }
@media (max-width: 640px) { details.menu .menu-pop { right: auto; left: 0; transform-origin: top left; } }

/* ---------------------------------------------------------------- public header/footer (translucent layer) */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--header-bg); -webkit-backdrop-filter: blur(16px) saturate(170%); backdrop-filter: blur(16px) saturate(170%); box-shadow: 0 1px 0 color-mix(in srgb, var(--border) 70%, transparent); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-top: 12px; padding-bottom: 12px; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; font-size: 15px; }
.site-nav a { color: var(--text-2); text-decoration: none; transition: color var(--fast) ease; }
@media (hover: hover) and (pointer: fine) { .site-nav a:hover { color: var(--text); } }
.site-nav a.btn-primary, .site-nav a.btn-primary:hover { color: var(--accent-ink); }
.site-nav a.btn-ghost { color: var(--text); }
.site-footer { border-top: 1px solid var(--border); color: var(--faint); font-size: 14px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding-top: 26px; padding-bottom: 26px; }
.site-footer a { color: var(--muted); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .theme-toggle:hover { background: var(--bg-soft); } }
[data-theme="dark"] .theme-toggle { background: transparent; border-color: var(--border-strong); }
.theme-toggle svg { width: 20px; height: 20px; }
[data-theme="light"] .theme-toggle .moon, :root:not([data-theme]) .theme-toggle .moon { display: block; }
[data-theme="light"] .theme-toggle .sun, :root:not([data-theme]) .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }

/* ---------------------------------------------------------------- app shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; background: var(--main-bg); }
body:has(.shell) { background: var(--main-bg); }
.sidebar { flex: 1 1 240px; max-width: 260px; min-width: 220px; background: var(--surface-2); box-shadow: 1px 0 0 var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 4px 10px 18px; }
.side-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 8px 12px 6px; font-weight: 600; }
.side-link { display: flex; align-items: center; gap: 11px; color: var(--text-2); text-decoration: none; padding: 9px 12px; border-radius: var(--r-sm); font-size: 15px; font-weight: 500; }
.side-link .ico { width: 18px; height: 18px; flex: none; color: var(--faint); transition: color var(--fast) ease; }
@media (hover: hover) and (pointer: fine) { .side-link:hover { background: var(--bg-soft); color: var(--text); } .side-link:hover .ico { color: var(--text-2); } }
.side-link.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.side-link.on .ico { color: var(--accent-text); }
[data-theme="dark"] .side-link.on { background: #1D1D20; }
.side-link.admin { color: var(--accent-text); }
.side-link.admin .ico { color: var(--accent-text); }
.side-sep { height: 1px; background: var(--border); margin: 12px 6px; }
.side-foot { margin-top: auto; padding: 16px 12px 4px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.main { flex: 999 1 640px; min-width: 0; padding: 32px clamp(18px, 3.4vw, 48px) 64px; display: flex; flex-direction: column; gap: 24px; }
/* a calm reading width on large screens */
.main > * { width: 100%; max-width: 1180px; }
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.ws-switch { width: 100%; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 760px) {
  /* phones: a compact translucent top bar (brand + theme/log out), then one scrolling row of pages */
  .shell { align-content: flex-start; }
  .sidebar { position: sticky; top: 0; z-index: 25; height: auto; overflow: visible; max-width: none; min-width: 0; flex-basis: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 8px; padding: 10px 16px 6px; box-shadow: 0 1px 0 var(--border);
    background: var(--shell-header-bg); -webkit-backdrop-filter: blur(16px) saturate(170%); backdrop-filter: blur(16px) saturate(170%); }
  .sidebar .brand { padding: 0; flex: 1 1 auto; }
  .sidebar > .side-label { order: 3; flex-basis: 100%; padding: 2px 0 0; }
  .sidebar > form.stack { order: 3; flex-basis: 100%; padding: 0 !important; }
  .side-nav { order: 4; flex-basis: 100%; flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav .side-link { white-space: nowrap; flex: none; padding: 8px 12px; font-size: 14px; min-height: 44px; }
  .side-nav .side-link .ico { display: none; }
  .side-nav .side-sep { width: 1px; height: auto; margin: 8px 2px; flex: none; }
  .side-foot { order: 2; margin: 0; padding: 0; }
  .side-foot .side-who { display: none; }
  .side-foot .row { margin-top: 0 !important; }
  .side-foot .theme-toggle { width: 40px; height: 40px; }
  .main { padding-top: 22px; }
  .site-nav { gap: 14px; }
  .site-nav a.nav-anchor { display: none; }
  .site-nav a.nav-login { padding: 12px 4px; }
  .btn-sm, .tab, .dl { min-height: 44px; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- layout helpers for pages */
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .primary { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.split > .aside { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border-radius: var(--r-md); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .v { font-family: "Space Grotesk", sans-serif; font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 15px; }
dl.facts dt { color: var(--faint); }
dl.facts dd { margin: 0; font-weight: 600; }
pre.block { margin: 0; background: var(--code-bg); border-radius: 12px; padding: 14px 16px; overflow-x: auto; font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-all; box-shadow: inset 0 0 0 1px var(--border); }
.progress { height: 6px; border-radius: 6px; background: var(--bg-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.progress.done > span { background: var(--ok); }
.progress.warn { background: repeating-linear-gradient(45deg, var(--warn-bg) 0 6px, transparent 6px 12px); }
.progress.warn > span { background: var(--warn); }
.chapter { background: var(--surface); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm); }
.chapter .thumb { aspect-ratio: 9 / 16; width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; background: #000; }
.chapter .thumb.wide { aspect-ratio: 16 / 9; }
.preview { aspect-ratio: 9 / 16; background: #000; border-radius: 22px; overflow: hidden; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 18px 40px -16px rgba(0, 0, 0, .45); }
.preview.wide { aspect-ratio: 16 / 9; }
.preview video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.dl { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border-radius: 12px; padding: 13px 16px; color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm); }
@media (hover: hover) and (pointer: fine) { .dl:hover { box-shadow: 0 0 0 1px var(--accent-line), 0 4px 14px -6px rgba(143, 78, 0, .2); } }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab { display: inline-flex; align-items: center; text-decoration: none; background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 8px 15px; font: 600 14px/1.2 Inter, sans-serif; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--text); border-color: var(--border-strong); } }
.tab[aria-selected="true"], .tab[aria-current="page"] { background: var(--surface); color: var(--text); border-color: transparent; box-shadow: var(--shadow-sm); }
.kit-item { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.kit-item p { white-space: pre-line; color: var(--text-2); }

/* live indicator on the project page (a calm pulse, not a fast blink) */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; animation: live 1.8s ease-in-out infinite; }
@keyframes live { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* status timeline (project page) */
.timeline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; list-style: none; margin: 0; padding: 0; }
.timeline li { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); }
.timeline li + li::before { content: ""; width: 20px; height: 2px; border-radius: 2px; background: var(--border-strong); margin-right: 1px; }
.timeline li.done + li::before { background: var(--ok); }
.timeline .tl-dot { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 2px solid var(--border-strong); color: var(--faint); background: var(--surface); }
.timeline li.done { color: var(--text-2); }
.timeline li.done .tl-dot { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.timeline li.now { color: var(--text); font-weight: 600; }
.timeline li.now .tl-dot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.timeline li.bad .tl-dot { border-color: var(--bad); background: var(--bad-bg); color: var(--bad); }

/* onboarding checklist (first run: the one place the app allows a little delight) */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border-radius: var(--r-md); padding: 16px; box-shadow: var(--ring); animation: rise 320ms var(--ease-out) both; }
.checklist li:nth-child(2) { animation-delay: 60ms; }
.checklist li:nth-child(3) { animation-delay: 120ms; }
.checklist .tl-dot { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid var(--accent-line); color: var(--accent-text); background: var(--accent-soft); }
.checklist li.done .tl-dot { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.checklist li.done strong { color: var(--muted); }

@keyframes rise { from { opacity: 0; transform: translateY(var(--rise)); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- landing */
.hero { padding: 76px 0 52px; display: flex; flex-wrap: wrap; gap: 56px; align-items: center; }
.hero h1 { font-size: clamp(40px, 6vw, 68px); line-height: 1.02; letter-spacing: -.035em; }
.hero .lead { font-size: 19px; color: var(--muted); max-width: 560px; line-height: 1.6; }
/* marketing page: one staggered entrance for the hero (seen rarely, explains the product) */
.hero > .stack > * { animation: rise 560ms var(--ease-out) both; }
.hero > .stack > :nth-child(2) { animation-delay: 60ms; }
.hero > .stack > :nth-child(3) { animation-delay: 120ms; }
.hero > .stack > :nth-child(4) { animation-delay: 180ms; }
.hero > .stack > :nth-child(5) { animation-delay: 240ms; }
.hero .phone { animation: rise 700ms var(--ease-out) 120ms both; }
.badge { align-self: flex-start; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); padding: 7px 12px; border-radius: 999px; font-weight: 600; }
.phone { width: 300px; height: 560px; border-radius: 38px; background: #000; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 18px; box-shadow: 0 0 0 8px var(--text), 0 30px 60px -20px rgba(23, 22, 26, .45); }
[data-theme="dark"] .phone { box-shadow: 0 0 0 1px var(--border-strong), 0 30px 80px -20px rgba(0, 0, 0, .8); }
/* the phone's render bar fills once, as an explanation of "rendering on the server" */
.phone .render-fill { transform-origin: left center; animation: fill 1800ms var(--ease-out) 500ms both; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.section { padding: 56px 0; }
.section h2.big { font-size: clamp(30px, 4vw, 42px); letter-spacing: -.025em; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.step-n { font-family: "Space Grotesk", sans-serif; color: var(--accent-text); font-weight: 700; }
.band { background: var(--surface); border-radius: 26px; padding: 40px; box-shadow: var(--shadow); }
.bullets { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; color: var(--text-2); }
.bullets li { display: flex; gap: 12px; }
.bullets li::before { content: "•"; color: var(--accent-text); font-weight: 700; }
/* sections reveal once as they scroll into view (landing only; JS adds .in) */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }
.js .reveal.in { opacity: 1; transform: none; }
.js .reveal .steps > *, .js .reveal.grid-stagger > * { opacity: 0; transform: translateY(10px); transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out); }
.js .reveal.in .steps > *, .js .reveal.in.grid-stagger > * { opacity: 1; transform: none; }
.reveal.in .steps > :nth-child(2) { transition-delay: 60ms; }
.reveal.in .steps > :nth-child(3) { transition-delay: 120ms; }
.reveal.in .steps > :nth-child(4) { transition-delay: 180ms; }
.auth-wrap { max-width: 1040px; margin: 0 auto; padding: 48px 24px 80px; display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.auth-wrap > .card, .auth-wrap > .card-soft { flex: 1 1 400px; min-width: 0; display: flex; flex-direction: column; gap: 18px; padding: 32px; }
.narrow { max-width: 520px; margin: 0 auto; padding: 56px 24px; }
.narrow > .card { animation: rise 360ms var(--ease-out) both; }

/* ---------------------------------------------------------------- accessibility preferences */
/* reduced motion: keep the fades that explain changes, drop every movement */
@media (prefers-reduced-motion: reduce) {
  :root { --rise: 0px; }
  .btn:active, .chip:active, .choice:active, .tab:active, .dl:active, .theme-toggle:active, .flash-close:active, .side-link:active { transform: none; }
  .reveal, .reveal .steps > *, .reveal.grid-stagger > * { transform: none; }
  .phone .render-fill { animation: none; }
  .live-dot { animation: none; }
  .flash, .flash.leaving, details.menu .menu-pop { transform: none !important; }
  details:not(.menu) > summary::before { transition: none; }
  * { scroll-behavior: auto !important; }
}
/* reduced transparency: solid chrome instead of glass */
@media (prefers-reduced-transparency: reduce) {
  .site-header { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--bg) !important; }
  .sidebar { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--surface-2) !important; }
}
/* more contrast: real borders on every surface */
@media (prefers-contrast: more) {
  .card, .card-soft, .table-wrap, .kpi, .dl, .chapter, .flash, .band { box-shadow: none; border: 1px solid var(--border-strong); }
  .input, .select { border-color: var(--text-2); }
  .faint, .hint, th, .eyebrow { color: var(--muted); }
}
