/* KeyAuth. Fonts are self-hosted (the CSP allows only 'self'). Keep the two token blocks below in sync:
   tests/test_contrast.py reads them and checks every text/background pair.
   Palette: ink-navy neutrals and brass (the colour of keys). --accent is the text-safe brass; --btn-bg is the bright one. */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("../fonts/martian-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #edf0f3;
  --surface: #ffffff;
  --ink: #0e1822;
  --ink-muted: #475763;
  --line: #d9e0e6;
  --field-border: #6b7b86;
  --accent: #8a5a00;
  --info: #1f4fbf;
  --btn-bg: #d4a03a;
  --btn-ink: #0e1822;
  --ok: #1b6b45;
  --warn: #7a5200;
  --bad: #a3263a;
  /* the sidebar and the sign-in stage are dark ink in both themes, with brass for the key */
  --rail-bg: #0f1a23;
  --rail-ink: #e6edf1;
  --rail-muted: #9fb0bb;
  --stage-bg: #0f1a23;
  --stage-ink: #e9edef;
  --stage-muted: #a9b8c2;
  --stage-brass: #e2ae48;
  --nickel: #c9d4da;
  --r: 8px;
  --r-lg: 14px;
  --shadow-1: 0 1px 2px rgb(14 24 34 / 0.05), 0 10px 24px -14px rgb(14 24 34 / 0.2);
  --shadow-2: 0 2px 4px rgb(14 24 34 / 0.06), 0 20px 36px -16px rgb(14 24 34 / 0.32);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a1017;
    --surface: #111a22;
    --ink: #e8edf1;
    --ink-muted: #9fb0bb;
    --line: #1f2c36;
    --field-border: #6c7e8b;
    --accent: #e6b450;
    --info: #8db0ff;
    --btn-bg: #e6b450;
    --btn-ink: #0a1017;
    --ok: #5cc38d;
    --warn: #e0b04c;
    --bad: #ff8a9a;
    --rail-bg: #0d161e;
    --shadow-1: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 28px -16px rgb(0 0 0 / 0.7);
    --shadow-2: 0 1px 0 rgb(255 255 255 / 0.05) inset, 0 22px 40px -18px rgb(0 0 0 / 0.85);
  }
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 "Archivo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--stage-brass) 40%, transparent); }
h1, h2 { font-stretch: 112%; font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 1.65rem; letter-spacing: -0.015em; }
h2 { font-size: 1.1rem; letter-spacing: -0.005em; }
p { margin: 0 0 1rem; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: "Martian Mono", ui-monospace, monospace; font-size: 0.8rem; letter-spacing: 0.02em; }
.muted { color: var(--ink-muted); font-size: 0.9rem; }
.lede { color: var(--ink-muted); margin: 0.5rem 0 1.75rem; max-width: 34ch; }
.aside { margin-top: 1.5rem; color: var(--ink-muted); }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 0.5rem; left: 0.5rem; z-index: 10; background: var(--surface); padding: 0.5rem 0.75rem; border-radius: var(--r); }

/* key drawing (templates call key_svg(); colour comes from currentColor) */
.key { display: block; height: auto; }
.key-mark { width: 2.75rem; flex: none; }

/* motion: short, ease-out, transform and opacity only (see the reduced-motion block at the end) */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes nudge { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }
@keyframes bar-y { from { transform: scaleY(0); } }
@keyframes bar-x { from { transform: scaleX(0); } }
@keyframes grid-pan { to { transform: translate(44px, 22px); } }
@keyframes glow-drift { from { transform: translate(-6%, 4%) scale(0.95); opacity: 0.7; } to { transform: translate(8%, -6%) scale(1.15); opacity: 1; } }
@keyframes glow-breathe { from { transform: translate(0, 0); opacity: 0.45; } to { transform: translate(8%, 5%) scale(1.1); opacity: 1; } }
@keyframes speck { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 0.9; } 85% { opacity: 0.7; } 100% { transform: translateY(-170px); opacity: 0; } }
@keyframes glint { 0%, 60% { transform: translateX(0); } 100% { transform: translateX(300px); } }
@keyframes glint-once { to { transform: translateX(300px); } }
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; animation-timing-function: cubic-bezier(0.23, 1, 0.32, 1); }

/* forms */
.field { display: grid; gap: 0.35rem; margin-bottom: 1.1rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.hint { color: var(--ink-muted); font-size: 0.85rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--field-border); border-radius: var(--r); padding: 0.6rem 0.75rem; width: 100%;
  transition: border-color 150ms, box-shadow 150ms;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--stage-brass) 22%, transparent);
}
input[type="checkbox"] { width: 1rem; height: 1rem; margin: 0 0.5rem 0 0; vertical-align: -0.15em; accent-color: var(--accent); }
fieldset.field { border: 0; padding: 0; margin: 0 0 1.1rem; }
fieldset legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 0.5rem; }
.check { display: block; font-weight: 400; margin-bottom: 0.5rem; }
.form { max-width: 34rem; }
.form-row { display: flex; flex-wrap: wrap; align-items: end; gap: 0 1rem; max-width: none; }
.form-row .field { flex: 1 1 12rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.field-row .field { flex: 1 1 12rem; }
.field-row + .hint { display: block; margin: -0.5rem 0 1.1rem; }
.btn {
  font: inherit; font-weight: 650; font-size: 0.95rem; line-height: 1.25; cursor: pointer; border-radius: var(--r); padding: 0.6rem 1.1rem;
  background: var(--btn-bg); color: var(--btn-ink); border: 1px solid color-mix(in srgb, var(--btn-bg) 78%, #000);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35), 0 1px 2px rgb(14 24 34 / 0.18);
  transition: background-color 160ms, border-color 160ms, color 160ms, box-shadow 160ms, transform 160ms var(--ease-out);
}
.btn:hover { background: color-mix(in srgb, var(--btn-bg) 88%, #fff); }
.btn:active { transform: scale(0.97); }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--field-border); box-shadow: 0 1px 2px rgb(14 24 34 / 0.06); }
.btn-quiet:hover { background: color-mix(in srgb, var(--ink) 6%, var(--surface)); }
.btn-small { padding: 0.35rem 0.8rem; font-size: 0.875rem; }
a.btn { display: inline-block; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* notices */
.notice { border: 1px solid var(--line); border-left: 3px solid var(--tone); border-radius: var(--r); background: var(--surface); padding: 0.7rem 1rem; margin: 0 0 1.25rem; animation: rise 280ms var(--ease-out) backwards; }
.notice-error { animation: nudge 360ms var(--ease-out); }
.notice p, .notice ul { margin: 0; }
.notice ul { padding-left: 1.1rem; }
.notice-success { --tone: var(--ok); }
.notice-error { --tone: var(--bad); }
.notice-info { --tone: var(--info); }

/* sign-in / sign-up: ink stage on the left, form on the right */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.stage, .app-art { background: var(--stage-bg); isolation: isolate; }
.app-art { background: radial-gradient(60% 55% at 62% 46%, color-mix(in srgb, var(--stage-brass) 13%, transparent), transparent 72%), var(--stage-bg); }
/* a faint drafting grid behind the key, fading out towards the edges. On the stage it is oversized and slowly pans */
.stage::before, .app-art::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgb(255 255 255 / 0.045) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 60% 46%, #000 15%, transparent 72%);
}
.stage::before { inset: -44px; animation: grid-pan 24s ease-in-out infinite alternate; }
/* ambient light: a brass glow drifting behind the key, and a few specks of brass dust rising through it */
.stage::after {
  content: ""; position: absolute; z-index: -1; left: 20%; top: 10%; width: 74%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--stage-brass) 20%, transparent), transparent);
  animation: glow-drift 16s ease-in-out infinite alternate;
}
.specks { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.specks::before, .specks::after { content: ""; position: absolute; left: 0; bottom: 0; width: 4px; height: 4px; border-radius: 50%; background: var(--stage-brass); opacity: 0; }
.specks::before {
  box-shadow: 70px -70px 1px var(--stage-brass), 190px -250px 2px var(--stage-brass), 330px -140px 1px var(--stage-brass), 470px -420px 2px var(--stage-brass),
    590px -190px 1px var(--stage-brass), 120px -520px 2px var(--stage-brass), 410px -640px 1px var(--stage-brass), 650px -560px 2px var(--stage-brass);
  animation: speck 19s ease-in-out infinite;
}
.specks::after {
  width: 3px; height: 3px;
  box-shadow: 40px -330px 1px var(--stage-brass), 250px -90px 2px var(--stage-brass), 370px -480px 1px var(--stage-brass), 520px -300px 2px var(--stage-brass),
    630px -80px 1px var(--stage-brass), 160px -680px 2px var(--stage-brass), 300px -590px 1px var(--stage-brass), 560px -700px 1px var(--stage-brass);
  animation: speck 27s ease-in-out -9s infinite;
}
.stage {
  color: var(--stage-ink);
  padding: 2.5rem; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; overflow: hidden; position: relative;
}
.wordmark {
  display: flex; align-items: center; gap: 0.7rem; color: inherit; text-decoration: none;
  font-stretch: 125%; font-weight: 800; font-size: 1.15rem;
}
.wordmark .key-mark { color: var(--stage-brass); transition: transform 300ms var(--ease-out); transform-origin: 20% 50%; }
.key-hero { width: 128%; max-width: none; margin-left: -9%; color: var(--stage-brass); animation: key-in 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both; filter: drop-shadow(0 18px 28px rgb(0 0 0 / 0.35)); }
/* the sign-in unlock animation (static/js/login.js) docks the key at its tip into this lock; hidden until then */
.key-hero { transform-origin: 0 0; }
.key-hero .glint { animation: glint 9s ease-in-out 1.6s infinite; }
.app-card:hover .glint { animation: glint-once 1.1s var(--ease-out); }
.lock { position: absolute; inset-block: 0; inset-inline-end: 6%; margin-block: auto; width: min(34%, 40vh); height: auto; overflow: visible; color: var(--nickel); opacity: 0; pointer-events: none; filter: drop-shadow(0 18px 28px rgb(0 0 0 / 0.35)); }
.shackle { transform-origin: 114px 92px; }
@keyframes key-in { from { opacity: 0; transform: translateX(-3rem); } to { opacity: 1; transform: none; } }
.tagline { font-stretch: 112%; font-weight: 600; font-size: clamp(1.5rem, 2.6vw, 2.25rem); line-height: 1.15; letter-spacing: -0.015em; max-width: 16ch; margin-bottom: 1rem; animation: rise 500ms 300ms var(--ease-out) backwards; }
.stage-code { color: var(--stage-muted); margin: 0; animation: fade 600ms 500ms backwards; }
.panel { display: flex; align-items: center; padding: 2.5rem; }
.panel-inner { width: 100%; max-width: 25rem; margin: 0 auto; }
.panel-inner > * { animation: rise 420ms var(--ease-out) backwards; }
.panel-inner > :nth-child(1) { animation-delay: 150ms; }
.panel-inner > :nth-child(2) { animation-delay: 200ms; }
.panel-inner > :nth-child(3) { animation-delay: 250ms; }
.panel-inner > :nth-child(4) { animation-delay: 300ms; }
.panel-inner > :nth-child(n+5) { animation-delay: 350ms; }
.panel-inner.swapped > * { animation: none; }   /* after a wrong password, only the notice moves (static/js/login.js) */
.panel-inner.swapped > .notice { animation: nudge 360ms var(--ease-out); }

/* signed-in shell: dark ink rail + content */
.shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail-bg); color: var(--rail-ink); border-right: 1px solid color-mix(in srgb, #fff 8%, var(--rail-bg)); padding: 1.25rem 0.8rem;
  display: flex; flex-direction: column; gap: 1.75rem; position: sticky; top: 0; height: 100vh; view-transition-name: rail;
}
.rail { isolation: isolate; overflow: hidden; }
.rail::before {
  content: ""; position: absolute; z-index: -1; left: -30%; top: -9rem; width: 130%; aspect-ratio: 1; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--stage-brass) 12%, transparent), transparent);
  animation: glow-breathe 12s ease-in-out infinite alternate;
}
.rail :focus-visible { outline-color: var(--stage-brass); }
.rail .wordmark { padding: 0.25rem 0.5rem; }
.rail nav { display: grid; gap: 0.15rem; }
.rail nav a {
  position: relative; display: flex; align-items: center; gap: 0.7rem;
  color: var(--rail-muted); text-decoration: none; padding: 0.5rem 0.7rem; border-radius: var(--r); font-weight: 500;
  transition: background-color 160ms, color 160ms;
}
.rail nav svg { width: 1.15rem; height: 1.15rem; flex: none; transition: color 160ms; }
.rail nav a:hover { color: var(--rail-ink); background: color-mix(in srgb, #fff 6%, transparent); }
.rail nav a[aria-current="page"] { color: var(--rail-ink); background: color-mix(in srgb, #fff 9%, transparent); font-weight: 600; }
.rail nav a[aria-current="page"] svg { color: var(--stage-brass); }
.rail nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 0.55rem; bottom: 0.55rem; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--stage-brass); transform-origin: center; animation: bar-y 320ms var(--ease-out) backwards;
}
.rail-foot { margin-top: auto; padding: 0.9rem 0.5rem 0; border-top: 1px solid color-mix(in srgb, #fff 8%, transparent); }
.rail .btn-quiet { background: transparent; color: var(--rail-ink); border-color: color-mix(in srgb, #fff 24%, transparent); box-shadow: none; }
.rail .btn-quiet:hover { background: color-mix(in srgb, #fff 9%, transparent); }
.who { display: flex; align-items: center; margin: 0 0 0.7rem; font-weight: 600; }
.avatar {
  display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; margin-right: 0.6rem; border-radius: 50%; flex: none;
  background: color-mix(in srgb, var(--stage-brass) 22%, transparent); color: var(--stage-brass); font-size: 0.8rem; font-weight: 700;
}
.main { padding: 2.25rem clamp(1.25rem, 4vw, 3.5rem) 3rem; max-width: 72rem; width: 100%; }
.main > * { animation: rise 300ms var(--ease-out) backwards; }
.main > :nth-child(2) { animation-delay: 40ms; }
.main > :nth-child(3) { animation-delay: 80ms; }
.main > :nth-child(4) { animation-delay: 120ms; }
.main > :nth-child(n+5) { animation-delay: 160ms; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; margin-bottom: 1.5rem; min-height: 2.5rem; }
.page-head h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
.page-head .mono { color: var(--ink-muted); }
.usage { display: flex; align-items: center; gap: 0.75rem; margin: 0; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.cuts { display: flex; gap: 3px; }
.cut { width: 0.5rem; height: 1rem; border-radius: 2px; background: var(--line); }
.cut.on { background: var(--btn-bg); }
.empty { border: 1px dashed var(--field-border); border-radius: var(--r-lg); padding: 2rem; max-width: 40rem; background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty h2 { margin-bottom: 0.5rem; }
.empty p { margin: 0; color: var(--ink-muted); }
.empty p + p { margin-top: 1rem; }

/* the dashboard: one card per application, each with its own key (drawn from the application's id) */
.apps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.15rem; }
.app-card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden; animation: rise 340ms var(--ease-out) backwards;
  transition: transform 240ms var(--ease-out), box-shadow 240ms var(--ease-out), border-color 240ms;
}
.app-card:nth-child(2) { animation-delay: 50ms; }
.app-card:nth-child(3) { animation-delay: 100ms; }
.app-card:nth-child(4) { animation-delay: 150ms; }
.app-card:nth-child(5) { animation-delay: 200ms; }
.app-card:nth-child(n+6) { animation-delay: 250ms; }
.app-art { position: relative; display: grid; align-items: center; height: 7.5rem; overflow: hidden; color: var(--stage-brass); }
.app-art::after {
  content: ""; position: absolute; z-index: -1; right: -12%; top: -55%; width: 70%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--stage-brass) 16%, transparent), transparent);
  animation: glow-breathe 9s ease-in-out infinite alternate;
}
.app-card:nth-child(2) .app-art::after { animation-delay: -3s; }
.app-card:nth-child(3) .app-art::after { animation-delay: -6s; }
.app-card:nth-child(4) .app-art::after { animation-delay: -1.5s; }
.app-key { width: 88%; max-width: none; margin-left: 6%; transition: transform 380ms var(--ease-out); filter: drop-shadow(0 8px 12px rgb(0 0 0 / 0.35)); }
.app-body { display: grid; gap: 0.2rem; padding: 1rem 1.25rem 1.15rem; }
.app-name { font-weight: 700; font-stretch: 106%; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.app-name::after { content: ""; position: absolute; inset: 0; }
.app-name:focus-visible { outline: 0; }
.app-card:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-id { color: var(--ink-muted); }
.app-new { border-style: dashed; border-color: var(--field-border); background: transparent; box-shadow: none; display: grid; place-items: center; min-height: 11.5rem; }
.app-new a { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink-muted); font-weight: 600; text-decoration: none; }
.app-new a::before { content: "+"; display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--btn-bg); color: var(--btn-ink); font-size: 1.15rem; line-height: 1; transition: transform 240ms var(--ease-out); }
.app-new a:focus-visible { outline: 0; }
.app-body .status { margin-top: 0.35rem; font-size: 0.85rem; }
@media (hover: hover) and (pointer: fine) {
  .app-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
  .app-card:hover .app-key { transform: translateX(10px) rotate(-2deg); }
  .app-new:hover a { color: var(--ink); }
  .app-new:hover a::before { transform: rotate(90deg) scale(1.08); }
  .wordmark:hover .key-mark { transform: rotate(-14deg); }
}

/* customer panel: one quiet column */
.pshell { min-height: 100vh; }
.phead { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; padding: 0.9rem clamp(1.25rem, 4vw, 3.5rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.phead nav { display: flex; gap: 1.25rem; }
.phead nav a { color: var(--ink-muted); font-weight: 500; text-decoration: none; padding: 0.35rem 0; border-bottom: 2px solid transparent; transition: color 160ms; }
.phead nav a:hover { color: var(--ink); }
.phead nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.phead-out { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.phead-out .who { margin: 0; }
.pmain { padding: 2.5rem clamp(1.25rem, 4vw, 3.5rem); max-width: 46rem; animation: rise 300ms var(--ease-out) backwards; }
.steps { padding-left: 1.25rem; max-width: 36rem; }
.steps li { margin-bottom: 1rem; }
.pmain h1 { margin-bottom: 1.5rem; }
.pmain.wide { max-width: 72rem; }

/* legal pages and footer links */
.legal-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.875rem; }
.legal-links a { color: var(--ink-muted); }
.legal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; padding: 0.9rem clamp(1.25rem, 4vw, 3.5rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.legal-head nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.legal-head nav a { color: var(--ink-muted); font-weight: 500; text-decoration: none; padding: 0.35rem 0; border-bottom: 2px solid transparent; transition: color 160ms; }
.legal-head nav a:hover { color: var(--ink); }
.legal-head nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.legal-head .lang { margin-left: auto; }
.prose { max-width: 44rem; padding: 2.5rem clamp(1.25rem, 4vw, 3.5rem) 4rem; animation: rise 300ms var(--ease-out) backwards; }
.prose h1 { margin-bottom: 0.5rem; }
.prose h2 { margin: 2rem 0 0.5rem; }
.prose pre, .example pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1rem; font: 0.8rem/1.5 "Martian Mono", ui-monospace, monospace; }
.prose code, .example code { font-family: "Martian Mono", ui-monospace, monospace; font-size: 0.85em; }
.prose pre code, .example pre code { font-size: inherit; }
.example { max-width: 58rem; }
.example h3 { margin: 2rem 0 0.25rem; }
.example .jump { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 0 0 0.5rem; }
.prose.wide { max-width: 58rem; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: 0.4rem; }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 600; color: var(--ink-muted); font-size: 0.8125rem; padding: 0.75rem 1rem; background: color-mix(in srgb, var(--paper) 55%, var(--surface)); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr td { transition: background-color 120ms; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--stage-brass) 9%, var(--surface)); }
.table td.mono { white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.actions .btn { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-muted); font-weight: 500; padding: 0.3rem 0.6rem; }
.actions .btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.actions form[action$="/delete"] .btn:hover { color: var(--bad); }
.inline { display: inline; }
.nowrap { white-space: nowrap; }
.table-roomy th, .table-roomy td { padding-right: 1.75rem; }
.table-roomy td { padding-top: 1.1rem; padding-bottom: 1.1rem; }
.tag-line { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.tag-line .tag { margin-left: 0; }
.tag.tag-warn { border-color: var(--warn); color: var(--warn); }
.actions-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; }
.inline-form input[type="date"] { width: 9.5rem; }
.tag { white-space: nowrap; font-size: 0.75rem; border: 1px solid var(--field-border); border-radius: 5px; padding: 0.05rem 0.4rem; margin-left: 0.35rem; color: var(--ink-muted); }
.status { display: inline-flex; align-items: center; gap: 0.45rem; }
.status::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot) 18%, transparent); }
.status-pending { --dot: var(--warn); }
.status-active { --dot: var(--ok); }
.status-suspended, .status-banned { --dot: var(--bad); }
.status-unused { --dot: var(--info); }
.status-used { --dot: var(--ok); }
.status-paused { --dot: var(--warn); }
.head-side { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }

/* application pages */
.tabs { display: flex; gap: 1.5rem; overflow-x: auto; scrollbar-width: none; box-shadow: inset 0 -1px 0 var(--line); margin: 0 0 1.75rem; }
.tabs a { position: relative; color: var(--ink-muted); font-weight: 500; text-decoration: none; padding: 0.6rem 0; white-space: nowrap; transition: color 160ms; }
.tabs a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform 240ms var(--ease-out), opacity 160ms;
}
.tabs a:hover { color: var(--ink); }
.tabs a:hover::after { transform: scaleX(1); opacity: 0.3; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabs a[aria-current="page"]::after { transform: scaleX(1); opacity: 1; animation: bar-x 320ms var(--ease-out) backwards; }
.section { margin: 2rem 0 0.75rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 0.5rem; box-shadow: var(--shadow-1); }
.stats div { display: grid; background: var(--surface); padding: 1.1rem 1.35rem; }
.stat-n { font-stretch: 112%; font-weight: 700; font-size: 2rem; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.5rem 1.5rem; margin: 0 0 1rem; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; }
.wrap { overflow-wrap: anywhere; }
.lede-wide { max-width: 44rem; margin-bottom: 1.5rem; }
.secret-box { border: 1px solid var(--field-border); border-left: 3px solid var(--accent); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); padding: 1.5rem; max-width: 40rem; }
.secret-box h2 { margin-bottom: 0.75rem; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 1.5rem; margin-bottom: 1.25rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.filters input, .filters select { width: auto; padding: 0.35rem 0.6rem; }
.toolbar-actions, .action-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-form { display: inline-flex; gap: 0.5rem; align-items: center; }
.inline-form input { width: auto; padding: 0.35rem 0.6rem; }
.inline-form input.short { width: 5.5rem; }
textarea.keys { resize: vertical; margin-bottom: 1rem; max-width: 34rem; }
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; }

@media (max-width: 52rem) {
  .split { grid-template-columns: 1fr; min-height: 0; }
  .stage { flex-direction: row; align-items: center; padding: 1.1rem 1.25rem; gap: 1rem; }
  .key-hero { width: 8rem; margin: 0; animation: none; filter: none; }
  .stage-foot, .lock, .specks { display: none; }
  .stage::before, .stage::after, .key-hero .glint { animation: none; }
  .rail::before { display: none; }
  .panel { padding: 1.75rem 1.25rem 2.5rem; }
  .panel-inner { margin: 0; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail {
    position: static; height: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand foot" "nav nav";
    align-items: center; gap: 0.6rem 1rem; border-right: 0; padding: 0.8rem 1.25rem 0;
  }
  .rail .wordmark { grid-area: brand; padding: 0; }
  .rail-foot { grid-area: foot; margin: 0; padding: 0; border-top: 0; display: flex; align-items: center; gap: 0.75rem; }
  .who { margin: 0; }
  .rail nav { grid-area: nav; display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none; margin: 0 -1.25rem; padding: 0 1.25rem; }
  .rail nav a { padding: 0.6rem 0; border-radius: 0; white-space: nowrap; background: none; }
  .rail nav svg { display: none; }
  .rail nav a:hover, .rail nav a[aria-current="page"] { background: none; }
  .rail nav a[aria-current="page"]::before { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 0; animation-name: bar-x; transform-origin: left; }
  .main { padding-top: 1.5rem; }
  .page-head h1 { font-size: 1.6rem; }
}
/* reduced motion: keep the fades, drop the movement */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .main > *, .panel-inner > *, .app-card, .notice, .pmain, .prose, .tagline { animation-name: fade; }
  .notice-error, .panel-inner.swapped > .notice { animation-name: fade; }
  .key-hero, .stage-code { animation: none; }
  .stage::before, .stage::after, .specks::before, .specks::after, .rail::before, .app-art::after, .key-hero .glint, .app-card:hover .glint { animation: none; }
  .specks { display: none; }
  .rail nav a[aria-current="page"]::before, .tabs a[aria-current="page"]::after { animation: none; }
  .btn, .wordmark .key-mark, .app-card, .app-key, .tabs a::after { transition-property: background-color, border-color, color, opacity; }
  .btn:active { transform: none; }
  .app-card:hover, .app-card:hover .app-key, .wordmark:hover .key-mark, .app-new:hover a::before { transform: none; }
}

/* landing page (signed-out "/"): a dark hero in the stage colours, then quiet sections on the page background */
.land-wrap { width: 100%; max-width: 68rem; margin: 0 auto; padding-inline: 1.5rem; }
.land-hero { background: radial-gradient(50% 70% at 78% 45%, color-mix(in srgb, var(--stage-brass) 14%, transparent), transparent 72%), var(--stage-bg); color: var(--stage-ink); padding-block: 2rem 4rem; }
.land-hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 3rem; align-items: center; }
.land-hero h1 { font-size: clamp(2rem, 4.4vw, 3.25rem); letter-spacing: -0.02em; max-width: 14ch; margin: 4rem 0 1rem; }
.land-lede { color: var(--stage-muted); font-size: 1.1rem; max-width: 34rem; }
.land-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin: 1.75rem 0 1rem; }
.land-ghost { background: transparent; color: var(--stage-ink); border-color: var(--stage-muted); box-shadow: none; }
.land-ghost:hover { background: rgb(255 255 255 / 0.08); }
.land-link { color: var(--stage-ink); }
.land-note { color: var(--stage-muted); font-size: 0.9rem; margin: 0; }
.land-art { color: var(--stage-brass); text-align: center; }
.land-art .mono { color: var(--stage-muted); margin: 1rem 0 0; }
.land-key { width: 100%; max-width: 26rem; margin-inline: auto; filter: drop-shadow(0 18px 28px rgb(0 0 0 / 0.35)); }
.land-key .glint { animation: glint 9s ease-in-out 1.6s infinite; }
.land-section { padding-block: 3.5rem; }
.land-section > h2, .land-band h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }
.land-cards, .land-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.land-cards { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.land-cards li, .land-steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 1.25rem; }
.land-cards h3, .land-steps h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.land-cards p, .land-steps p { color: var(--ink-muted); margin: 0; }
.land-band { background: var(--surface); border-block: 1px solid var(--line); }
.land-band .land-section { padding-block: 3rem; }
.land-steps { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); counter-reset: step; }
.land-steps li { counter-increment: step; background: var(--paper); box-shadow: none; }
.land-steps h3::before { content: counter(step) ". "; color: var(--accent); }
.land-text { max-width: 44rem; }
@media (max-width: 52rem) {
  .land-hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .land-hero h1 { margin-top: 2rem; }
  .land-art { order: -1; text-align: left; }
  .land-key { max-width: 14rem; margin: 0; }
  .land-art .mono { display: none; }
}
@media (prefers-reduced-motion: reduce) { .land-key .glint { animation: none; } }
