/* brouter developer portal
 *
 * Identity: "signal on ink". A near-black indigo canvas (routing happens in the
 * dark, at the wire level) with one electric-cyan signal colour used only for the
 * live, the actionable, and the money. Display type is Bricolage Grotesque — a
 * grotesque with real character at large sizes — over Inter for interface text.
 * The memorable element is the credit figure: oversized, tabular, the one place
 * colour and scale are spent. Everything else is quiet.
 */

:root {
  /*
   * Tells the browser which way the built-in chrome should lean: scrollbars,
   * form widgets, the caret. app.js (and the inline script in index.html) set
   * `data-theme` on <html>; both values are listed here so the dark default
   * still holds for a browser that never runs the switch.
   */
  color-scheme: dark;

  --ink-900: #0a0e1a;
  --ink-850: #0e1424;
  --ink-800: #131a2e;
  --ink-700: #1b2540;
  --ink-600: #26314f;
  --line: #26314f;
  --line-soft: #1a2238;

  --text: #eaeefb;
  --text-dim: #9aa6c8;
  --text-faint: #67739a;

  --signal: #35e0d8;      /* electric cyan — live, action, credit */
  --signal-deep: #12b8b0;
  --signal-glow: rgba(53, 224, 216, 0.14);
  /* Text that sits on a --signal/--signal-deep fill. On the bright cyan of the
   * dark theme that is near-black ink; the light theme deepens the fill to a
   * mid-teal, where dark ink sinks into the colour, so it flips to white. */
  --on-signal: #04201f;
  /* The fill behind --on-signal text: a solid accent button. Kept separate from
   * --signal (which is also used as text and border colour) so the light theme can
   * darken the fill alone and give white text a proper 4.5:1, without drowning every
   * accent label in navy. */
  --signal-fill: #35e0d8;
  --signal-fill-hover: #12b8b0;
  --violet: #7c6bff;      /* secondary accent for paid/premium */
  --amber: #f5b544;       /* warnings, low balance */
  --rose: #ff6b81;        /* errors, debits */

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px -22px rgba(0, 0, 0, 0.8);

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }

/*
 * The theme button: same footprint as a nav pill so it sits in the rail footer
 * and in the landing header without either row re-flowing around it.
 */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--text-dim);
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--ink-600); }
.theme-toggle:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* The language button carries a word ("Tiếng Việt ▾"), not a glyph, so it sizes
   to its label instead of the square theme toggle it sits beside. */
[data-lang-toggle] {
  width: auto;
  min-width: 2.2rem;
  padding: 0 .55rem;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* Language dropdown — fixed-positioned under its button, above everything. */
.i18n-menu {
  position: fixed;
  z-index: 1200;
  min-width: 9rem;
  padding: 5px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  animation: i18n-menu-in 0.12s ease-out;
}
@keyframes i18n-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.i18n-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-dim);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.i18n-menu-item:hover { color: var(--text); background: var(--ink-700); }
.i18n-menu-item.active { color: var(--signal); }
.i18n-menu-check { color: var(--signal); font-size: 12px; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink-900);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 600px at 82% -10%, rgba(53, 224, 216, 0.06), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(124, 107, 255, 0.05), transparent 55%),
    var(--ink-900);
}

.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }

a, .linklike {
  color: var(--signal);
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}
.linklike:hover { color: var(--text); }

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  font: 500 14px/1 var(--font-body);
  border: 1px solid var(--line);
  background: var(--ink-700);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--ink-600); border-color: var(--ink-600); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.btn-primary {
  background: var(--signal-fill);
  color: var(--on-signal);
  border-color: var(--signal-fill);
  font-weight: 600;
}
.btn-primary:hover { background: var(--signal-fill-hover); border-color: var(--signal-fill-hover); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--ink-800); }

.btn-danger { color: var(--rose); border-color: transparent; background: transparent; }
.btn-danger:hover { background: rgba(255, 107, 129, 0.1); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.42rem 0.7rem; font-size: 13px; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 15px; }

/* ── Landing ─────────────────────────────────────────────────────────── */

/*
 * The landing is themed like every other page — the switch in the header
 * changes the whole thing, not just the bar it sits in.
 *
 * It runs on its own set of variables rather than the app's `--ink-*` scale
 * because a landing has different needs: a translucent glass panel, a hairline
 * that reads over a moving canvas, and a body colour that has to stay legible
 * over both. Defining them here, and redefining them under
 * `[data-theme="light"] .landing` below, means every rule in this section is
 * written once against a name instead of being duplicated per theme.
 *
 * The values are still *chosen* per theme rather than mechanically inverted: a
 * near-black stage is what makes the signal colour and the glass read as depth,
 * and the light version keeps a deeper canvas tint than the signed-in pages so
 * the same composition survives on paper.
 */
.landing {
  --stage-bg: #06080f;
  --stage-bg-2: #0b1020;
  --stage-panel: rgba(18, 24, 42, 0.55);
  --stage-panel-solid: #0e1424;
  --stage-line: rgba(120, 140, 190, 0.16);
  --stage-line-strong: rgba(140, 165, 220, 0.28);
  --stage-text: #eaeefb;
  --stage-dim: #9aa6c8;
  --stage-faint: #67739a;
  --stage-nav: rgba(6, 8, 15, 0.6);
  --stage-nav-solid: rgba(6, 8, 15, 0.86);
  --stage-signal: #35e0d8;
  --stage-violet: #7c6bff;
  --stage-ink: #04201f;
  --stage-wash: rgba(255, 255, 255, 0.03);
  --stage-wash-strong: rgba(255, 255, 255, 0.055);
  --stage-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
  --stage-node: rgba(150, 175, 220, 0.5);
  --stage-amber: #f5b544;
  --stage-rose: #ff6b81;
  color-scheme: dark;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background: var(--stage-bg);
  color: var(--stage-text);
}

/*
 * The light stage.
 *
 * Not a plain inversion: on white, a translucent white panel disappears, so the
 * glass becomes a *solid* pale panel with a visible border, and the shadows
 * that gave depth on black are replaced by a much softer lift. The accent
 * colours deepen the same way they do elsewhere in the light theme, since
 * #35e0d8 as text on white is barely legible.
 */
[data-theme="light"] .landing {
  --stage-bg: #f6f8fd;
  --stage-bg-2: #eef2fa;
  --stage-panel: rgba(255, 255, 255, 0.78);
  --stage-panel-solid: #ffffff;
  --stage-line: rgba(19, 26, 46, 0.1);
  --stage-line-strong: rgba(19, 26, 46, 0.16);
  --stage-text: #131a2e;
  --stage-dim: #59637a;
  --stage-faint: #8b93a7;
  --stage-nav: rgba(246, 248, 253, 0.72);
  --stage-nav-solid: rgba(246, 248, 253, 0.92);
  --stage-signal: #0f9d96;
  --stage-violet: #5b48e0;
  --stage-ink: #ffffff;
  --stage-wash: rgba(19, 26, 46, 0.025);
  --stage-wash-strong: rgba(19, 26, 46, 0.05);
  --stage-shadow: 0 30px 60px -34px rgba(19, 26, 46, 0.35);
  --stage-node: rgba(19, 26, 46, 0.34);
  --stage-amber: #b45309;
  --stage-rose: #d93b52;
  color-scheme: light;
}

/* The animated node field, fixed behind the whole page. */
.landing-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.85;
}

/*
 * Two large soft radials that drift very slowly. This is the page's colour:
 * a cyan pool top-right and a violet one bottom-left, blended over the node
 * field so the canvas never looks like a flat starfield.
 */
.landing-aurora {
  position: fixed;
  inset: -20% -10% -10% -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58vw 44vw at 78% 6%, color-mix(in srgb, var(--stage-signal) 15%, transparent), transparent 62%),
    radial-gradient(52vw 42vw at 12% 78%, color-mix(in srgb, var(--stage-violet) 14%, transparent), transparent 60%),
    radial-gradient(40vw 30vw at 50% 120%, color-mix(in srgb, var(--stage-signal) 7%, transparent), transparent 60%);
  filter: blur(10px);
  animation: aurora 26s ease-in-out infinite alternate;
}
@keyframes aurora {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(2%, -2.5%, 0) scale(1.07); }
}

/* Every band sits above the canvas. */
.landing > section,
.landing > footer,
.landing > header { position: relative; z-index: 1; }

.landing-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem clamp(1rem, 5vw, 4rem);
  border-bottom: 1px solid transparent;
  position: sticky; top: 0; z-index: 40;
  background: var(--stage-nav);
  backdrop-filter: blur(14px) saturate(140%);
  transition: border-color 0.3s, background 0.3s;
}
/* The hairline only appears once the page has scrolled under the bar. */
.landing-nav.scrolled { border-bottom-color: var(--stage-line); background: var(--stage-nav-solid); }
.landing-brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }
.landing-links { display: flex; align-items: center; gap: 1.4rem; }
.landing-links a { color: var(--stage-dim); font-size: 14px; transition: color 0.15s; }
.landing-links a:hover { color: var(--stage-text); }
@media (max-width: 900px) {
  .landing-links { gap: 0.6rem; }
  .landing-links a { display: none; }
}

/* ── Hero ────────────────────────────────────────────────────────────── */

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
  padding: clamp(2.5rem, 7vw, 6.5rem) clamp(1rem, 5vw, 4rem) clamp(2rem, 5vw, 4rem);
  max-width: 1240px;
  margin: 0 auto;
  /* Phones the pointer-parallax and the 3D tilt are dropped: see the media
   * query at the end of the landing block. */
}
@media (max-width: 900px) { .landing-hero { grid-template-columns: 1fr; gap: 2.5rem; } }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 12.5px; color: var(--stage-dim);
  border: 1px solid var(--stage-line);
  background: var(--stage-wash);
  border-radius: 999px;
  padding: 0.32rem 0.8rem 0.32rem 0.6rem;
  margin: 0 0 1.4rem;
  backdrop-filter: blur(6px);
}
.hero-eyebrow b { color: var(--stage-signal); font-variant-numeric: tabular-nums; }
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--stage-signal);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--stage-signal) 0.6%, transparent);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--stage-signal) 0.5%, transparent); }
  70% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--stage-signal) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--stage-signal) 0%, transparent); }
}

.landing-hero-copy h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.6rem, 6.2vw, 4.4rem);
  line-height: 1.0; letter-spacing: -0.035em;
  margin: 0 0 1.2rem;
}
/* A static gradient is enough for the accent line; the animated sheen is
 * reserved for the button, where it signals the primary action. */
.grad-text {
  background: linear-gradient(100deg, var(--stage-signal) 0%, var(--stage-violet) 55%, var(--stage-signal) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lead { color: var(--stage-dim); font-size: clamp(1rem, 1.4vw, 1.15rem); max-width: 34rem; margin: 0 0 1.9rem; line-height: 1.65; }
.landing-cta { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; }

/* The one element allowed to glow. */
.btn-glow {
  position: relative;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--stage-signal) 0.4%, transparent), 0 12px 40px -12px color-mix(in srgb, var(--stage-signal) 0.55%, transparent);
  overflow: hidden;
}
.btn-glow::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.5), transparent 80%);
  transform: translateX(-120%);
  animation: sheen 4.5s ease-in-out infinite;
}
@keyframes sheen { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.btn-glow:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--stage-signal) 0.7%, transparent), 0 16px 50px -12px color-mix(in srgb, var(--stage-signal) 0.7%, transparent); }

.hero-points { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; padding: 0; margin: 1.5rem 0 0; }
.hero-points li { position: relative; padding-left: 1.2rem; color: var(--stage-faint); font-size: 13px; }
.hero-points li::before {
  content: ""; position: absolute; left: 0; top: 0.45em;
  width: 5px; height: 9px;
  border-right: 1.6px solid var(--stage-signal); border-bottom: 1.6px solid var(--stage-signal);
  transform: rotate(42deg);
}

/* ── The 3D hero stage ───────────────────────────────────────────────── */

/*
 * The stacked cards sit in their own perspective container and are rotated in
 * three dimensions, each on a different z so the group reads as a physical
 * object rather than three flat panels. `hero-stage` owns the perspective;
 * `hero-stack` is the thing that turns, and its rotation follows the pointer.
 *
 * `transform-style: preserve-3d` on the stack is what lets the children keep
 * their own z-placement instead of being flattened into it.
 */
.hero-stage {
  position: relative;
  perspective: 1400px;
  perspective-origin: 60% 40%;
  min-height: 22rem;
}
.hero-orb {
  position: absolute;
  inset: 8% 4% 8% 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--stage-signal) 0.22%, transparent), transparent 58%);
  filter: blur(28px);
  z-index: 0;
}
.hero-stack {
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(8deg) rotateY(-15deg) rotateZ(1.5deg);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.hero-card {
  border: 1px solid var(--stage-line-strong);
  background: var(--stage-panel);
  backdrop-filter: blur(16px) saturate(150%);
  border-radius: 16px;
  box-shadow: var(--stage-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
/* Each card floats on its own plane. The translateZ values are what make the
 * depth real once the stack is rotated. */
.hero-card-code {
  transform: translateZ(46px);
  padding: 0.9rem 1.1rem 1.1rem;
  animation: float 9s ease-in-out infinite;
}
.hero-card-route {
  transform: translate3d(2.4rem, -1.4rem, 96px);
  padding: 0.95rem 1.1rem;
  margin-top: 1.1rem;
  animation: float 9s ease-in-out infinite 1.2s;
}
.hero-card-meter {
  position: absolute;
  right: -0.6rem;
  bottom: -1.6rem;
  transform: translateZ(140px);
  padding: 0.75rem 0.95rem;
  display: grid;
  gap: 0.15rem;
  animation: float 9s ease-in-out infinite 2.4s;
}
@keyframes float {
  0%, 100% { transform: translate3d(var(--tx, 0), 0, var(--tz, 0)); }
  50% { transform: translate3d(var(--tx, 0), -0.7rem, var(--tz, 0)); }
}
/* The float keyframes animate transform, which would otherwise wipe the tilt —
 * so each card carries its own translation through custom properties. */
.hero-card-code { --tz: 46px; --tx: 0px; }
.hero-card-route { --tz: 96px; --tx: 2.4rem; margin-top: 1.1rem; }
.hero-card-meter { --tz: 140px; }

.hero-card-bar { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.75rem; }
.hero-card-bar span[class^="dot-"] { width: 9px; height: 9px; border-radius: 50%; }
.dot-r { background: var(--stage-rose); } .dot-a { background: var(--stage-amber); } .dot-g { background: var(--stage-signal); }
.hero-card-title { margin-left: 0.5rem; font-size: 11.5px; color: var(--stage-faint); letter-spacing: 0.04em; text-transform: uppercase; }

.hero-card-code pre {
  font-family: var(--font-mono); font-size: 12.4px; line-height: 1.75;
  color: var(--stage-signal); margin: 0; overflow-x: auto; white-space: pre;
}

.route-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.8rem; }
.route-node {
  font-size: 11.5px; color: var(--stage-text);
  border: 1px solid var(--stage-line-strong);
  background: var(--stage-wash-strong);
  border-radius: 7px; padding: 0.25rem 0.55rem;
  white-space: nowrap;
}
.route-node-hub { color: var(--stage-ink); background: var(--stage-signal); border-color: var(--stage-signal); font-weight: 600; }
.route-line { flex: 1; height: 1px; background: var(--stage-line-strong); position: relative; overflow: hidden; }
/* The travelling pulse is the "request in flight" cue. */
.route-line i {
  position: absolute; top: -1px; left: 0;
  width: 34%; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--stage-signal), transparent);
  animation: travel 2.2s linear infinite;
}
@keyframes travel { from { transform: translateX(-120%); } to { transform: translateX(420%); } }

.route-spokes { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; }
.spoke { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 11.5px; color: var(--stage-dim); }
.spoke-dot { width: 6px; height: 6px; border-radius: 50%; }
.spoke-dot.ok { background: var(--stage-signal); }
.spoke-dot.warn { background: var(--stage-amber); }

.meter-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--stage-faint); }
.meter-value { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--stage-signal); font-variant-numeric: tabular-nums; }
.meter-spark .sparkline { height: 22px; gap: 2px; }
/* The stage is dark in both themes, so the sparkline's own tokens have to be
 * restated here — the shared component reads the page palette, which is light
 * when the visitor has chosen light. */
.landing .sparkline .bar { background: color-mix(in srgb, var(--stage-node) 40%, transparent); }
.landing .sparkline .bar.has-value { background: var(--stage-signal); }
.landing .sparkline:hover .bar { background: color-mix(in srgb, var(--stage-node) 60%, transparent); }
.landing .sparkline .bar:hover { background: var(--stage-violet); }

/* ── Stats band ──────────────────────────────────────────────────────── */

.landing-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  max-width: 1240px;
  margin: 0 auto clamp(2rem, 5vw, 4rem);
  padding: 0 clamp(1rem, 5vw, 4rem);
}
@media (max-width: 720px) { .landing-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat-cell {
  display: grid; gap: 0.25rem;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--stage-line);
  background: var(--stage-wash);
  backdrop-filter: blur(8px);
}
.stat-cell:first-child { border-radius: 14px 0 0 14px; }
.stat-cell:last-child { border-radius: 0 14px 14px 0; }
@media (max-width: 720px) {
  .stat-cell:first-child { border-radius: 14px 0 0 0; }
  .stat-cell:last-child { border-radius: 0 0 14px 0; }
  .stat-cell:nth-child(2) { border-radius: 0 14px 0 0; }
  .stat-cell:nth-child(3) { border-radius: 0 0 0 14px; }
}
.stat-cell b {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  letter-spacing: -0.03em; color: var(--stage-text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.stat-cell span { font-size: 12.5px; color: var(--stage-faint); }

/* ── Scroll reveal ───────────────────────────────────────────────────── */

/*
 * Applied by app.js as the element enters the viewport. The initial state is
 * only added when the observer is actually going to run (`.will-reveal`), so a
 * browser without IntersectionObserver or a visitor who prefers reduced motion
 * sees the page immediately rather than staring at invisible sections.
 */
.will-reveal { opacity: 0; transform: translateY(22px); }
.will-reveal.revealed {
  opacity: 1;
  transform: none;
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Stagger the grid children so a row of cards arrives as a sequence rather
 * than a single block. */
.will-reveal .step, .will-reveal .feature, .will-reveal .price-card { transition-delay: 0.06s; }

/* ── Sections ────────────────────────────────────────────────────────── */

.landing-section { padding: clamp(2.5rem, 6vw, 5rem) clamp(1rem, 5vw, 4rem); max-width: 1240px; margin: 0 auto; scroll-margin-top: 5rem; }
.section-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.7rem, 3.6vw, 2.6rem);
  letter-spacing: -0.03em; line-height: 1.1;
  margin: 0 0 0.6rem;
}
.section-sub { color: var(--stage-dim); font-size: clamp(0.95rem, 1.3vw, 1.05rem); margin: 0 0 2.2rem; max-width: 44rem; }

/* ── How it works ────────────────────────────────────────────────────── */

.steps { list-style: none; padding: 0; margin: 0 0 2.6rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; counter-reset: step; }
@media (max-width: 820px) { .steps { grid-template-columns: 1fr; } }
.step {
  position: relative;
  border: 1px solid var(--stage-line);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--stage-wash-strong), var(--stage-wash));
  padding: 1.5rem 1.4rem;
  backdrop-filter: blur(10px);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s;
}
/* A gentle lift on hover — the same 3D idea as the hero, at card scale. */
.step:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--stage-signal) 0.4%, transparent); }
.step-num {
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; margin-bottom: 0.9rem;
  border-radius: 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 0.95rem;
  color: var(--stage-ink); background: var(--stage-signal);
  box-shadow: 0 8px 24px -10px color-mix(in srgb, var(--stage-signal) 0.8%, transparent);
}
.step h3 { font-size: 1.05rem; margin: 0 0 0.45rem; }
.step p { color: var(--stage-dim); font-size: 14px; margin: 0; line-height: 1.6; }

.landing-code-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 820px) { .landing-code-split { grid-template-columns: 1fr; } }
.code-pane {
  border: 1px solid var(--stage-line);
  border-radius: 14px;
  background: var(--stage-wash);
  padding: 1.1rem 1.2rem;
  backdrop-filter: blur(8px);
}
.code-pane-after { border-color: color-mix(in srgb, var(--stage-signal) 0.32%, transparent); background: color-mix(in srgb, var(--stage-signal) 0.05%, transparent); }
.code-pane-label { margin: 0 0 0.7rem; font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--stage-faint); }
.code-pane-after .code-pane-label { color: var(--stage-signal); }
.code-pane pre {
  margin: 0; font-family: var(--font-mono); font-size: 12.4px; line-height: 1.75;
  color: var(--stage-dim); white-space: pre-wrap; word-break: break-word;
}
.code-pane-after pre { color: var(--stage-signal); }

/* ── Provider marquee ────────────────────────────────────────────────── */

.marquee {
  position: relative;
  overflow: hidden;
  /* Fades the strip into the page at both ends rather than cutting it. */
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track { display: flex; gap: 0.7rem; width: max-content; animation: marquee 46s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.provider-chip {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--stage-line);
  background: var(--stage-wash);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 13px; color: var(--stage-dim);
  white-space: nowrap;
}
.provider-chip b { color: var(--stage-text); font-weight: 600; }
.provider-chip .chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--stage-signal); box-shadow: 0 0 8px color-mix(in srgb, var(--stage-signal) 0.7%, transparent); }

/* ── Features ────────────────────────────────────────────────────────── */

.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; }
@media (max-width: 980px) { .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .feature-grid { grid-template-columns: 1fr; } }
.feature {
  border: 1px solid var(--stage-line);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--stage-wash-strong), var(--stage-wash));
  padding: 1.4rem;
  backdrop-filter: blur(10px);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s;
}
.feature:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--stage-signal) 0.4%, transparent); }
.feature-icon {
  display: grid; place-items: center;
  width: 2.3rem; height: 2.3rem; margin-bottom: 0.9rem;
  border-radius: 11px;
  border: 1px solid color-mix(in srgb, var(--stage-signal) 0.3%, transparent);
  background: color-mix(in srgb, var(--stage-signal) 0.1%, transparent);
}
.feature-icon svg { width: 19px; height: 19px; fill: none; stroke: var(--stage-signal); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.feature h3 { font-size: 1.05rem; margin: 0 0 0.45rem; }
.feature p { color: var(--stage-dim); font-size: 14px; margin: 0; line-height: 1.6; }

/* ── Pricing ─────────────────────────────────────────────────────────── */

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 1rem; }
.price-card {
  border: 1px solid var(--stage-line);
  border-radius: 16px;
  background: linear-gradient(160deg, var(--stage-wash-strong), var(--stage-wash));
  padding: 1.3rem;
  backdrop-filter: blur(10px);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s;
}
.price-card:hover { transform: translateY(-5px); border-color: color-mix(in srgb, var(--stage-signal) 0.4%, transparent); }
.price-card h3 { font-size: 1.05rem; margin: 0 0 0.3rem; }
.price-card .price-amount { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; margin-top: 0.9rem; }
.price-card .muted { color: var(--stage-dim); font-size: 13px; }
.pricing-note { color: var(--stage-faint); font-size: 13px; margin: 1.4rem 0 0; max-width: 46rem; }

/* ── FAQ ─────────────────────────────────────────────────────────────── */

.faq-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
@media (max-width: 820px) { .faq-grid { grid-template-columns: 1fr; } }
.faq {
  border: 1px solid var(--stage-line);
  border-radius: 13px;
  background: var(--stage-wash);
  padding: 0.2rem 1.1rem;
  backdrop-filter: blur(8px);
}
.faq summary {
  cursor: pointer;
  padding: 0.95rem 0;
  font-weight: 500; font-size: 14.5px; color: var(--stage-text);
  list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  flex: none;
  font-size: 1.15rem; color: var(--stage-signal);
  transition: transform 0.25s;
}
.faq[open] summary::after { transform: rotate(45deg); }
.faq p { color: var(--stage-dim); font-size: 13.5px; line-height: 1.65; margin: 0 0 1rem; }
.faq code { font-family: var(--font-mono); font-size: 0.9em; color: var(--stage-signal); }
.faq a { color: var(--stage-signal); }

/* ── Closing band ────────────────────────────────────────────────────── */

.landing-cta-band {
  text-align: center;
  padding: clamp(3rem, 7vw, 6rem) clamp(1rem, 5vw, 4rem);
  margin: clamp(1rem, 3vw, 2rem) auto 0;
  max-width: 1240px;
  border-top: 1px solid var(--stage-line);
}
.landing-cta-band h2 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -0.03em;
  margin: 0 0 0.6rem;
}
.landing-cta-band p { color: var(--stage-dim); margin: 0 0 1.8rem; }

/* ── Free allowance band ────────────────────────────────────────────────
 * A single high-contrast card that advertises the free-model token budget the
 * operator set. Shown only when there is one; the section stays hidden (and its
 * padding with it) otherwise. */
.landing-free[hidden] { display: none; }
/* Sits right under the hero, so it uses a tight vertical rhythm rather than the
 * full section padding — a banner, not another chapter. */
.landing-free { padding-top: clamp(0.75rem, 2vw, 1.25rem); padding-bottom: clamp(0.75rem, 2vw, 1.25rem); }
.free-allowance {
  display: flex; align-items: center; gap: clamp(1rem, 3vw, 2rem); flex-wrap: wrap;
  padding: clamp(1.4rem, 3vw, 2.2rem) clamp(1.4rem, 3vw, 2.4rem);
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--stage-signal) 34%, var(--stage-line));
  background:
    radial-gradient(120% 180% at 0% 0%, color-mix(in srgb, var(--stage-signal) 12%, transparent), transparent 60%),
    var(--stage-panel-solid);
}
.free-allowance-badge {
  flex: none; display: grid; place-items: center;
  width: 3.4rem; height: 3.4rem; border-radius: 50%;
  background: color-mix(in srgb, var(--stage-signal) 18%, transparent);
  color: var(--stage-signal); font-weight: 800; font-size: 0.85rem; letter-spacing: 0.02em;
  border: 1px solid color-mix(in srgb, var(--stage-signal) 40%, transparent);
}
.free-allowance-body { flex: 1 1 16rem; min-width: 0; }
.free-allowance-title {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
  font-size: clamp(1.25rem, 2.6vw, 1.9rem); margin: 0 0 0.25rem; color: var(--stage-text);
}
.free-allowance-sub { margin: 0; color: var(--stage-dim); font-size: 0.95rem; line-height: 1.5; }
.free-allowance .btn { flex: none; }

/* ── Footer ──────────────────────────────────────────────────────────── */

.landing-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  padding: 1.6rem clamp(1rem, 5vw, 4rem); border-top: 1px solid var(--stage-line);
  color: var(--stage-faint); font-size: 13px;
  max-width: 1240px; margin: 0 auto;
}
.foot-brand { display: flex; align-items: center; gap: 0.55rem; font-family: var(--font-display); font-weight: 700; color: var(--stage-text); }
.landing-foot nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.landing-foot a { color: var(--stage-faint); }
.landing-foot a:hover { color: var(--stage-text); }
/* Legal boilerplate line, full-width under the brand and nav. */
.foot-note { flex-basis: 100%; margin: 0; max-width: 60rem; line-height: 1.65; color: var(--stage-faint); }
.foot-note a { color: var(--stage-dim); text-decoration: underline; text-underline-offset: 2px; }
.foot-note a:hover { color: var(--stage-text); }

/*
 * Motion and depth are dropped on small screens and for anyone who has asked
 * for reduced motion: the tilt, the float, the sheen and the marquee all cost
 * frames, and on a phone the stacked cards overlap at an angle that reads as
 * clutter rather than depth.
 */
@media (max-width: 900px), (prefers-reduced-motion: reduce) {
  .hero-stack { transform: none !important; }
  .hero-card { animation: none !important; }
  .hero-card-code { transform: none; }
  .hero-card-route { transform: none; margin-top: 0.9rem; }
  .hero-card-meter { position: static; transform: none; margin-top: 0.9rem; }
  .hero-orb { display: none; }
  .marquee-track { animation: none; flex-wrap: wrap; width: auto; }
  .btn-glow::after { display: none; }
}

/* ── Auth screen ─────────────────────────────────────────────────────── */

.auth-back { position: absolute; top: 1.4rem; left: 1.4rem; font-size: 13px; color: var(--text-dim); }
.auth-back:hover { color: var(--text); }

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-aside { display: none; } }

.auth-panel {
  padding: clamp(2rem, 6vw, 5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 30rem;
  width: 100%;
  margin: 0 auto;
}

.auth-brand, .rail-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.logo {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  /* White on a deeper teal. The old dark ink (#04201f) on --signal sat too
   * close to the fill to read at logo size, and --signal-deep is too bright in
   * the dark theme for white (2.5:1). This fixed pair holds 6.09:1 in both. */
  background: #0a6e69;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
}

.auth-title {
  font-size: clamp(2rem, 5vw, 2.9rem);
  line-height: 1.02;
  margin-top: 2.2rem;
}
.auth-lead { color: var(--text-dim); margin: 0.6rem 0 1.8rem; }

.social { display: grid; gap: 0.6rem; }
.social:empty { display: none; }
.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink-800);
  color: var(--text);
  font: 500 14px/1 var(--font-body);
  cursor: pointer;
}
.social-btn:hover { background: var(--ink-700); }
.social-btn svg { width: 18px; height: 18px; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-faint);
  font-size: 13px;
  margin: 1.4rem 0;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.divider:empty, .divider[hidden] { display: none; }

.auth-form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.35rem; }
/* `display: grid` above would otherwise beat the HTML `hidden` attribute, so the
 * name field stayed visible on the sign-in view. Make hidden win. */
.field[hidden] { display: none; }
.field > span { font-size: 13px; color: var(--text-dim); }
.field input, .modal input, .modal textarea, .modal select {
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.65rem 0.8rem;
  font: 400 15px var(--font-body);
  width: 100%;
}
.field input:focus, .modal input:focus, .modal textarea:focus, .modal select:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-glow);
}
.auth-error, .modal-error { color: var(--rose); font-size: 13px; min-height: 1rem; }
.auth-switch { margin-top: 1.4rem; color: var(--text-dim); font-size: 14px; }
.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: -0.4rem; font-size: 13px; flex-wrap: wrap;
}
.remember {
  display: inline-flex; align-items: center; gap: 0.45rem;
  color: var(--text-dim); cursor: pointer; user-select: none;
}
.remember input { width: auto; accent-color: var(--signal); cursor: pointer; }
/* Consent to Terms + Privacy on sign-up; matches the remember row, but the
   label wraps and the links carry the accent. */
.auth-consent {
  display: flex; align-items: flex-start; gap: 0.5rem;
  color: var(--text-dim); font-size: 13px; line-height: 1.5;
  cursor: pointer; user-select: none;
}
.auth-consent input { width: auto; margin-top: 0.15rem; accent-color: var(--signal); cursor: pointer; flex: none; }
.auth-consent a { color: var(--signal); text-decoration: underline; }
.auth-forgot { font-size: 13px; }
.auth-referral {
  font-size: 13px; color: var(--signal);
  background: var(--signal-glow); border: 1px solid rgba(53,224,216,0.3);
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem;
}
.ref-share { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ref-share input { flex: 1; min-width: 12rem; font-family: var(--font-mono); font-size: 13px; }
.modal-hint { font-size: 13px; margin-top: 0.4rem; }
.stack { display: grid; gap: 1rem; }
.stack .field { margin: 0; }

.auth-aside {
  background:
    linear-gradient(160deg, var(--ink-800), var(--ink-900));
  border-left: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.auth-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 400px at 70% 30%, var(--signal-glow), transparent 70%);
  pointer-events: none;
}
.aside-inner { max-width: 26rem; position: relative; }
.aside-kicker { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.aside-copy { color: var(--text-dim); margin: 0.8rem 0 1.8rem; font-size: 1.02rem; }
.aside-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--signal);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── App shell ───────────────────────────────────────────────────────── */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}
/*
 * Both shell children must be allowed to shrink below their content's intrinsic
 * width, or a wide child (the scrolling nav row, a wide table) forces the grid
 * track — and the whole page — past the viewport, which is what pushed content
 * off-screen behind a horizontal scrollbar. `minmax(0,…)` on the track plus
 * `min-width:0` here is the standard fix.
 */
.rail, .main { min-width: 0; }

.rail {
  border-right: 1px solid var(--line-soft);
  background: var(--ink-850);
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  /*
   * Pinned to the viewport so the footer (email + sign out) always sits at the
   * bottom of the screen. Without this the rail stretches to the page height,
   * and on a tab whose content scrolls — Usage's long table — `flex:1` on the
   * nav pushed the footer far below the fold, so it looked absent on tall tabs
   * and present on short ones.
   */
  position: sticky;
  top: 0;
  height: 100vh;
}
.rail-brand { padding: 0 0.4rem; }
.rail-nav { display: flex; flex-direction: column; gap: 1.05rem; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-heading {
  margin: 0 0 0.3rem;
  padding: 0 0.7rem;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  padding: 0.52rem 0.7rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: 500 14px var(--font-body);
  cursor: pointer;
  white-space: nowrap;
}
.nav-item:hover { background: var(--ink-800); color: var(--text); }
.nav-item.active { background: var(--ink-700); color: var(--text); box-shadow: inset 2px 0 0 var(--signal); }
/* Stroke-only icons inherit the item's colour, so the active state needs no
 * second rule and the icons stay quiet next to the labels. */
.nav-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.nav-item.active .nav-icon { color: var(--signal); opacity: 1; }

/*
 * Balance + burn in the rail. Shown on every tab because "can I afford this"
 * and "how fast am I spending" are the two questions a metered user has open
 * regardless of what they are doing.
 */
.rail-balance {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--ink-800);
  text-decoration: none;
  color: inherit;
}
.rail-balance:hover { border-color: var(--line); }
.rail-balance-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-faint); }
.rail-balance-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--signal);
}
.rail-spark { margin-top: 0.4rem; }

.rail-foot { display: grid; gap: 0.5rem; padding: 0 0.4rem; }
.rail-user { font-size: 13px; color: var(--text-faint); line-height: 1.4; word-break: break-all; }
.rail-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.rail-signout { display: inline; }

/*
 * Phone layout: the rail becomes a sticky top bar. Brand + sign-out share the
 * first row, and the nav scrolls horizontally beneath it as pill tabs — so every
 * destination and the sign-out stay reachable without the desktop sidebar, which
 * simply does not fit a narrow screen.
 */
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: sticky;
    top: 0;
    height: auto;
    /*
     * A grid row stretches its item to the row height by default, and the shell
     * is min-height:100vh — so on a short tab the rail row grew and the top bar
     * became a tall empty band. Pin it to its own content instead.
     */
    align-self: start;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0.8rem 0.9rem;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    z-index: 30;
  }
  .rail-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    order: 0;
  }
  /*
   * Move the sign-out (and the theme button) up next to the brand; hide the long
   * email to save space. The brand row is brand + this, so the actions stay one
   * row rather than the rail footer's stacked pair.
   */
  .rail-foot {
    grid-auto-flow: column;
    align-items: center;
    padding: 0;
  }
  .rail-actions { display: flex; align-items: center; gap: 0.9rem; }
  .rail-user { display: none; }
  /*
   * The grouped nav flattens back into one scrolling row of pills: group
   * headings are meaningless in a horizontal strip, and a phone has no room for
   * four stacked sections. The grouping still exists in the DOM, so the rail
   * re-groups on a wider screen without a second markup path.
   */
  .rail-nav {
    flex-direction: row;
    /*
     * Not `flex: 1`: in the column rail that made the nav absorb the rail's
     * extra height on a short page (min-height:100vh stretches the rail), and the
     * pills — align-items:stretch by default — grew into tall ovals. Fixed height,
     * centred, so a pill is only as tall as its text on every tab.
     */
    flex: 0 0 auto;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .rail-nav::-webkit-scrollbar { display: none; }
  .nav-group { flex-direction: row; gap: 0.35rem; }
  .nav-heading { display: none; }
  .nav-item {
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    font-size: 13px;
    gap: 0.4rem;
  }
  .nav-item.active { box-shadow: none; border-color: var(--signal); color: var(--signal); }
  /* The balance is a desktop affordance; on a phone the Wallet tab is one tap
   * away and the bar has no room for it. */
  .rail-balance { display: none; }
}

.main { padding: clamp(1.1rem, 3.5vw, 3rem); overflow-x: hidden; }
.view { display: none; }
.view.active { display: block; animation: rise 0.3s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view.active { animation: none; } }
/*
 * The first paint after a reload restores the tab the user was already on, which
 * is not a tab change: see `switchView` in app.js, which sets this for the
 * duration of that one render so a refresh does not flicker.
 */
.no-view-anim .view.active { animation: none; }

.view-head { margin-bottom: 1.8rem; }
.view-head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.view-head p { color: var(--text-dim); margin: 0.35rem 0 0; }

/* ── Overview: the credit hero ───────────────────────────────────────── */

.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--ink-800), var(--ink-850));
  padding: clamp(1.6rem, 3vw, 2.4rem);
  position: relative;
  overflow: hidden;
  margin-bottom: 1.4rem;
}
.hero::after {
  content: "";
  position: absolute;
  right: -80px; top: -80px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, var(--signal-glow), transparent 70%);
  pointer-events: none;
}
.hero-label { color: var(--text-dim); font-size: 14px; margin: 0 0 0.4rem; }
.hero-amount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 9vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--signal);
}
.hero-amount .cents { color: var(--text); opacity: 0.55; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 1.6rem; margin-top: 1.3rem; color: var(--text-dim); font-size: 14px; }
.hero-meta b { color: var(--text); font-variant-numeric: tabular-nums; }
.hero-status { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px var(--signal-glow); }
.dot.low { background: var(--amber); box-shadow: 0 0 0 3px rgba(245,181,68,0.18); }
.dot.empty { background: var(--rose); box-shadow: 0 0 0 3px rgba(255,107,129,0.18); }

/*
 * Deposit-bonus promo strip: the one place a running promotion is advertised on
 * the pages a user funds from. Tinted with the signal colour rather than a new
 * palette so it reads as "this gateway's offer", and laid out as a single row
 * that collapses on narrow screens.
 */
.promo-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.4rem;
  border: 1px solid color-mix(in srgb, var(--signal) 45%, var(--line));
  border-radius: var(--radius);
  background:
    radial-gradient(120% 180% at 0% 0%, var(--signal-glow), transparent 60%),
    linear-gradient(100deg, color-mix(in srgb, var(--signal) 10%, var(--ink-850)), var(--ink-850));
}
.promo-badge {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 3.1rem;
  padding: 0.35rem 0.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--on-signal);
  background: var(--signal-fill);
  border-radius: var(--radius-sm);
}
.promo-body { flex: 1 1 auto; min-width: 0; }
.promo-title { font-weight: 700; color: var(--text); font-size: 14.5px; }
.promo-text { color: var(--text-dim); font-size: 13.5px; margin-top: 0.15rem; }
.promo-banner .btn { flex: none; }
@media (max-width: 560px) {
  .promo-banner { flex-wrap: wrap; }
  .promo-banner .btn { width: 100%; }
}

.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-850);
  padding: 1.2rem;
}
.stat-label { color: var(--text-faint); font-size: 13px; margin: 0 0 0.5rem; }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-sub { color: var(--text-dim); font-size: 13px; margin-top: 0.3rem; }

/* ── Metrics ─────────────────────────────────────────────────────────── */

/*
 * The one place a headline figure is drawn, used on every tab.
 *
 * A bare total ("12,847 requests") tells a user nothing they can act on. Every
 * metric carries its period, and where a comparison is meaningful, how it moved
 * against the previous period of the same length — so the number answers "is
 * this normal, and which way is it going", not just "what is it".
 */
.metric {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-850);
  padding: 1.1rem 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.metric-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; }
.metric-label { color: var(--text-faint); font-size: 12.5px; }
.metric-period {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}
.metric-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.85rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-top: 0.35rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.metric-foot { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.3rem; flex-wrap: wrap; }
.metric-sub { color: var(--text-dim); font-size: 12.5px; }
/* A delta is only coloured when a direction is genuinely good or bad; volume
 * going up is neither, which is why the caller passes a tone rather than the
 * component assuming green means better. */
.metric-delta { font-size: 12.5px; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 0.2rem; }
.metric-delta.up { color: var(--signal); }
.metric-delta.down { color: var(--rose); }
.metric-delta.flat { color: var(--text-faint); }
.metric-spark { margin-top: auto; padding-top: 0.7rem; }

/* ── Sparkline ───────────────────────────────────────────────────────── */

/*
 * A per-day bar series. Bars rather than a line because traffic here is a count
 * per bucket, and a line implies interpolation between days that does not exist.
 * Each bar keeps a 2px floor when non-zero, so a day with a single request is
 * visible rather than sub-pixel.
 */
.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 30px; }
.sparkline .bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--ink-600);
  transition: background 0.15s;
}
.sparkline .bar.has-value { background: var(--signal-deep); }
.sparkline .bar.is-fail { background: var(--amber); }
.sparkline:hover .bar { background: var(--ink-700); }
.sparkline .bar:hover { background: var(--signal); }
.rail-spark .sparkline { height: 20px; gap: 1.5px; }
/* In the rail the spark is ambient, not a control: keep it muted at rest so a
 * short series does not read as a solid button beside the balance. */
.rail-spark .sparkline .bar { background: var(--line-soft); }
.rail-spark .sparkline .bar.has-value { background: color-mix(in srgb, var(--signal-deep) 45%, var(--ink-700)); }

/* ── Breakdown bars ──────────────────────────────────────────────────── */

/* Ported from the admin dashboard's Combos tab so the two surfaces read as one
 * product, retuned to the portal's tokens. */
.breakdown {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-850);
  padding: 1.1rem 1.2rem;
  min-width: 0;
}
.breakdown h4 {
  margin: 0 0 0.9rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.breakdown-row + .breakdown-row { margin-top: 0.7rem; }
.breakdown-head { display: flex; justify-content: space-between; gap: 0.7rem; font-size: 12.5px; margin-bottom: 0.3rem; }
.breakdown-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-num { flex: none; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.breakdown-bar { height: 5px; border-radius: 3px; background: var(--ink-700); overflow: hidden; display: flex; }
.breakdown-bar i { display: block; height: 100%; background: var(--signal-deep); }
.breakdown-bar i.fail { background: var(--rose); }
.breakdown-empty { color: var(--text-faint); font-size: 12px; }

/* ── Loading + error states ──────────────────────────────────────────── */

/* A skeleton says "content is coming and here is its shape"; "Loading…" says
 * only that something is happening. */
.skeleton { border-radius: var(--radius); background: var(--ink-850); border: 1px solid var(--line-soft); overflow: hidden; position: relative; }
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.035), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }
.skeleton-line { height: 0.8rem; border-radius: 4px; background: var(--ink-700); }
.view-skeleton { display: grid; gap: 1rem; }
.view-skeleton .skeleton { height: 6.5rem; }
.view-skeleton .skeleton.tall { height: 16rem; }

.error-state {
  border: 1px solid rgba(255, 107, 129, 0.28);
  background: rgba(255, 107, 129, 0.06);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  color: var(--text-dim);
  font-size: 14px;
}
.error-state h3 { color: var(--text); font-size: 1rem; margin-bottom: 0.35rem; }
.error-state .btn { margin-top: 0.8rem; }

/* An empty state should say what to do next, not just that there is nothing. */
.empty-state .btn { margin-top: 0.9rem; }

/* ── Toolbar controls ────────────────────────────────────────────────── */

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: 500 13px var(--font-body);
  padding: 0.44rem 0.8rem;
  cursor: pointer;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: var(--ink-800); color: var(--text); }
.seg button.active { background: var(--signal-fill); color: var(--on-signal); font-weight: 600; }

.control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 12.5px;
  color: var(--text-faint);
}
.control select,
.control input[type="date"] {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: 400 13px var(--font-body);
  padding: 0.4rem 0.55rem;
}
.control select:focus-visible,
.control input:focus-visible { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-glow); }

/* ── Pagination ──────────────────────────────────────────────────────── */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 0.9rem; }
.pager-info { color: var(--text-faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager-btns { display: flex; gap: 0.4rem; }

/* ── Usage filters ───────────────────────────────────────────────────── */

.usage-filters { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
/* Pushes the export button to the far end of the row, so it reads as an action
 * on the whole filtered set rather than another filter. */
.usage-filters-spacer { flex: 1 1 auto; }
@media (max-width: 620px) {
  .usage-filters { gap: 0.6rem; }
  .usage-filters .seg { flex: 1 1 100%; }
  .usage-filters .seg button { flex: 1; text-align: center; }
  .usage-filters .control { flex: 1 1 calc(50% - 0.3rem); }
  .usage-filters .control select,
  .usage-filters .control input { flex: 1; min-width: 0; }
  .usage-filters-spacer { display: none; }
  .usage-filters > .btn { width: 100%; }
}

/* ── Definition rows (receipts, key detail) ──────────────────────────── */

.defs { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1.2rem; font-size: 13.5px; }
.defs dt { color: var(--text-faint); }
.defs dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ── Notices ─────────────────────────────────────────────────────────── */

.notice {
  border: 1px solid rgba(245, 181, 68, 0.35);
  background: rgba(245, 181, 68, 0.07);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 13.5px;
  margin-top: 1rem;
}
[data-theme="light"] .notice {
  border-color: rgba(217, 119, 6, 0.32);
  background: rgba(217, 119, 6, 0.07);
  color: #92400e;
}

.hero-actions { display: inline-flex; gap: 0.5rem; }

.topup-presets { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.topup-presets .btn { min-width: 4.2rem; }
/* The chosen credit amount stays visibly chosen while the provider list
   underneath it changes to match. */
.topup-presets .pack-btn.active {
  border-color: var(--signal);
  background: var(--signal-glow);
  color: var(--signal);
  font-weight: 600;
}

/* Payment methods inside the Add funds dialog. A disabled row (a Waffo pack
   that has no product yet, an amount under the provider's minimum) stays
   readable rather than greyed to invisibility, because its reason is the point. */
.pay-method {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.pay-method + .pay-method { margin-top: 0.4rem; }
.pay-method:has(input:checked) { border-color: var(--signal); background: var(--signal-glow); }
.pay-method.disabled { cursor: not-allowed; opacity: 0.6; }
/* `.modal input` sizes text fields to the full width; a radio must not be. */
.modal .pay-method input {
  width: auto;
  flex: none;
  margin: 0;
  padding: 0;
  box-shadow: none;
  accent-color: var(--signal);
}
.pay-method .muted { margin-left: auto; font-size: 12.5px; color: var(--text-dim); }
.pay-alt { margin: 0.25rem 0 0; font-size: 13px; color: var(--text-dim); }
.pay-alt-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--signal);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-850);
  padding: 1.4rem;
  margin-top: 1.4rem;
}
.panel-title { font-size: 1.05rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.quickstart pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--ink-900);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  color: var(--text-dim);
  margin: 0;
}
.quickstart .tok { color: var(--signal); }

/* ── Cards / lists ───────────────────────────────────────────────────── */

.cards { display: grid; gap: 1rem; }
.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--ink-850);
  padding: 1.2rem 1.3rem;
}
.card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.card h3 { font-size: 1.05rem; }
.card .muted { color: var(--text-dim); font-size: 13.5px; }
/*
 * On a phone the key card's title and its Models/Rotate/Delete buttons stop
 * competing for one row: the row wraps, and the button group drops to its own
 * full-width line where each button can breathe instead of being squeezed.
 */
@media (max-width: 560px) {
  .card-row { flex-wrap: wrap; }
  .card-row > div:last-child { width: 100%; }
  .card-row .btn-sm { flex: 1; }
}

.mono { font-family: var(--font-mono); font-size: 13px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 12px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.pill.free { color: var(--signal); border-color: rgba(53,224,216,0.35); }
.pill.paid { color: var(--violet); border-color: rgba(124,107,255,0.4); }
.pill.off { color: var(--text-faint); }

.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 12px; padding: 0.25rem 0.6rem; border-radius: 999px;
  background: var(--ink-700); color: var(--text-dim); margin: 0.15rem 0.15rem 0 0;
}
.chip-all { background: transparent; border: 1px dashed var(--line); color: var(--text-faint); }
.chip-warn { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }

/* Two short fields side by side (expiry + spend cap) inside a modal. */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 460px) { .field-row { grid-template-columns: 1fr; } }

/* A key's active limits, shown as small chips under its 30-day figures. */
.key-limits { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.15rem; }

/* A key's own numbers, so its cost is attributable from the list. */
.key-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
}
@media (max-width: 560px) { .key-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.key-stat { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.key-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.key-stat b { font-size: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.key-stat-note { color: var(--text-faint); font-size: 11.5px; margin: 0.5rem 0 0; }

/* Combo health status, mirroring the admin Combos tab. */
.catalog-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; margin-top: 0.9rem; flex-wrap: wrap;
}
/* Price by direction, on its own line and separated, so the two rates are not
 * read as one range. */
.price-row {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  margin-top: 0.8rem; padding-top: 0.75rem; border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--text-dim);
}
.price-row b { color: var(--text); font-variant-numeric: tabular-nums; }
/* A rate the operator did not set, so it is the billing default rather than a
 * published choice. Dotted-underlined so the asterisk has something to point at. */
.price-default { text-decoration: underline dotted 1px; text-underline-offset: 3px; cursor: help; }
.price-footnote { color: var(--text-faint); font-size: 11.5px; margin: 0.45rem 0 0; }

/* A free model's note: no charge today, but it draws from one shared budget. */
.free-note { color: var(--signal-deep); font-size: 11.5px; margin: 0.45rem 0 0; }

/* Budget banner above the Models grid. */
.free-budget {
  background: color-mix(in srgb, var(--signal) 7%, var(--ink-850));
  border: 1px solid color-mix(in srgb, var(--signal) 28%, var(--line));
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.1rem;
}
.free-budget.spent {
  background: color-mix(in srgb, var(--rose) 8%, var(--ink-850));
  border-color: color-mix(in srgb, var(--rose) 32%, var(--line));
}
.free-budget-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.free-budget-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.free-budget-count { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.free-budget.spent .free-budget-count { color: var(--rose); }
.free-budget-bar { height: 6px; border-radius: 999px; background: var(--ink-700); overflow: hidden; margin: 0.6rem 0 0.5rem; }
.free-budget-bar i { display: block; height: 100%; border-radius: 999px; background: var(--signal-deep); transition: width 0.3s; }
.free-budget.spent .free-budget-bar i { background: var(--rose); }
.free-budget-hint { margin: 0; font-size: 12px; color: var(--text-faint); }

/* A token total with its billed split underneath, so a cached call reads as
 * cheap rather than as an unexplained smaller number. */
.tok-total { display: block; font-variant-numeric: tabular-nums; }
.tok-split {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/*
 * The model id, as a labelled, copyable value.
 *
 * Routing resolves against this string rather than the display title, so it has
 * to be reachable — but as a bare line under the heading it read as an internal
 * field that had leaked into the page. Framing it as "Model id" makes the same
 * string read as documentation instead.
 */
.model-call { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.7rem; font-size: 12.5px; }
.model-call-label { color: var(--text-faint); flex: 0 0 auto; }
.model-call-id {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--ink-900);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
  color: var(--text-dim);
  font: inherit;
  min-width: 0;
}
.model-call-id code {
  font-family: var(--font-mono); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-call-id svg {
  flex: 0 0 auto; width: 12px; height: 12px;
  fill: none; stroke: currentColor; stroke-width: 1.3;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.7;
}
.model-call-id:hover { border-color: var(--line); color: var(--text); }
.model-call-id:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.model-call-id:hover svg { opacity: 1; }
.status {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 12px; color: var(--text-dim);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.status-ok { color: var(--signal); }
.status-ok .status-dot { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-glow); }
.status-warn { color: var(--amber); }
.status-warn .status-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(245,181,68,0.18); }
.status-err { color: var(--rose); }
.status-err .status-dot { background: var(--rose); box-shadow: 0 0 0 3px rgba(255,107,129,0.18); }
.status-idle { color: var(--text-faint); }

.field-note { font-size: 12px; margin-top: 0.5rem; }

/* Recent-activity strip, mirroring the admin Combos tab. */
.activity { margin-top: 0.9rem; }
.activity-head {
  display: flex; gap: 1.2rem; align-items: baseline;
  margin-bottom: 0.4rem; font-size: 11.5px; color: var(--text-dim);
}
.activity-head b { color: var(--text); font-weight: 600; margin-left: 0.25rem; font-variant-numeric: tabular-nums; }
.activity-head b.spark-ok { color: var(--signal); }
.activity-head b.spark-warn { color: var(--amber); }
.activity-head b.spark-err { color: var(--rose); }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 18px; }
.spark .tick {
  flex: 1 1 0; min-width: 3px; max-width: 10px; height: 100%;
  border-radius: 2px; background: var(--ink-600);
}
.spark .tick-ok { background: var(--signal-deep); }
.spark .tick-warn { background: var(--amber); }
.spark .tick-err { background: var(--rose); }

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--text-faint); font-weight: 500; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line-soft); }
.tbl td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line-soft); color: var(--text-dim); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .pos { color: var(--signal); }
.tbl .neg { color: var(--rose); }
/*
 * A wide table (Usage, Wallet, transactions) scrolls sideways within its own
 * panel on a narrow screen rather than forcing the whole page wide. `.panel`
 * clips, and the table keeps a sensible minimum so its columns don't crush.
 */
.panel { overflow-x: auto; }
@media (max-width: 560px) {
  .tbl { min-width: 30rem; }
}

.empty-state { text-align: center; color: var(--text-dim); padding: 2.5rem 1rem; }
.empty-state h3 { color: var(--text); margin-bottom: 0.4rem; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }

/* ── Modal ───────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3, 6, 14, 0.72);
  display: grid; place-items: center; z-index: 60; padding: 1.2rem;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 30rem;
  padding: 1.6rem;
}
.modal h3 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.modal .modal-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 1.2rem; }
.modal .field { margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; }

/* A status modal (error/notice) leads with a badge and centres its text, so a
   bare message reads as a deliberate state, not a stray dialog. */
.modal-status { text-align: center; }
.modal-status .modal-sub { margin-bottom: 0.4rem; }
.modal-status .modal-actions { justify-content: center; }
.modal-badge {
  width: 3rem; height: 3rem; margin: 0.2rem auto 1rem;
  display: grid; place-items: center; border-radius: 50%;
}
.modal-badge-danger {
  color: var(--rose);
  background: color-mix(in srgb, var(--rose) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--rose) 38%, transparent);
}
.modal-badge-accent {
  color: var(--signal);
  background: color-mix(in srgb, var(--signal) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--signal) 38%, transparent);
}
.checklist { display: grid; gap: 0.5rem; max-height: 15rem; overflow-y: auto; }
.checkitem { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); cursor: pointer; }
.checkitem:hover { background: var(--ink-700); }
.checkitem input { width: auto; }
.reveal {
  font-family: var(--font-mono); font-size: 13px; word-break: break-all;
  background: var(--ink-900); border: 1px dashed var(--signal-deep);
  border-radius: var(--radius-sm); padding: 0.8rem; color: var(--signal);
}

/* ── Toasts ──────────────────────────────────────────────────────────── */

.toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; display: grid; gap: 0.5rem; z-index: 80; }
.toast {
  background: var(--ink-700); border: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  padding: 0.8rem 1rem; border-radius: var(--radius-sm);
  font-size: 14px; box-shadow: var(--shadow); max-width: 22rem;
  animation: slidein 0.2s ease;
}
.toast.error { border-left-color: var(--rose); }
@keyframes slidein { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ── Static doc pages (docs / terms / privacy) ────────────────────────── */

.doc-page { max-width: 52rem; margin: 0 auto; padding: 1.4rem clamp(1rem, 5vw, 2rem) 4rem; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.4rem 0 1.4rem; border-bottom: 1px solid var(--line-soft); margin-bottom: 2rem; }
.doc-actions { display: flex; align-items: center; gap: 1rem; }
.doc-brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.doc-body h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -0.02em; margin: 0 0 1rem; }
.doc-body h2 { font-family: var(--font-display); font-size: 1.25rem; margin: 2rem 0 0.6rem; }
.doc-body h3 { font-size: 1rem; margin: 1.4rem 0 0.5rem; color: var(--text); }
.doc-body p, .doc-body li { color: var(--text-dim); line-height: 1.7; }
.doc-body ul { padding-left: 1.2rem; }
.doc-body code { font-family: var(--font-mono); font-size: 0.9em; background: var(--ink-800); border: 1px solid var(--line-soft); border-radius: 5px; padding: 0.1rem 0.35rem; color: var(--signal); }
.doc-code {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.65; color: var(--text-dim);
  background: var(--ink-900); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 1rem; overflow-x: auto; white-space: pre; margin: 0.6rem 0;
}
.doc-foot { margin-top: 3rem; padding-top: 1.4rem; border-top: 1px solid var(--line-soft); color: var(--text-faint); font-size: 13px; }
.doc-foot a { color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }
.doc-foot a:hover { color: var(--text); }
.doc-body ol { padding-left: 1.3rem; }
.doc-body ol li, .doc-body ul li { margin: 0.35rem 0; }
.doc-body strong { color: var(--text); font-weight: 600; }
.doc-body a { color: var(--signal); text-decoration: underline; text-underline-offset: 2px; }
.doc-body a:hover { color: var(--text); }
.doc-body hr { border: 0; border-top: 1px solid var(--line-soft); margin: 2.2rem 0; }

/* The "personal project, not a company" banner that heads both legal pages. */
.doc-banner {
  display: flex; gap: 0.8rem; align-items: flex-start;
  border: 1px solid var(--line-soft);
  background: var(--ink-800);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin: 0 0 2rem;
}
.doc-banner .doc-banner-icon { flex: 0 0 auto; color: var(--signal); margin-top: 0.1rem; }
.doc-banner p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.65; }
.doc-banner strong { color: var(--text); }

/* Shared "at a glance" facts under the title, e.g. last-updated + contact. */
.doc-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.6rem;
  margin: 0 0 2rem; padding: 0; list-style: none;
  color: var(--text-faint); font-size: 13px;
}
.doc-meta b { color: var(--text-dim); font-weight: 600; }

/* A short table of contents so a long legal page is navigable. */
.doc-toc {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 1rem 1.2rem; margin: 0 0 2.4rem; background: var(--ink-850);
}
.doc-toc p { margin: 0 0 0.6rem; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.doc-toc ol { margin: 0; padding-left: 1.1rem; columns: 2; column-gap: 2rem; }
.doc-toc li { margin: 0.2rem 0; }
.doc-toc a { color: var(--text-dim); text-decoration: none; }
.doc-toc a:hover { color: var(--signal); }
@media (max-width: 560px) { .doc-toc ol { columns: 1; } }

/* Contact block: the one place a visitor can actually reach a human. */
.doc-contact {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem; margin: 1.2rem 0 0; background: var(--ink-850);
}
.doc-contact p { margin: 0 0 0.35rem; }
.doc-contact .doc-contact-mail { font-family: var(--font-mono); font-size: 14px; }

/* ── Modal variants ──────────────────────────────────────────────────── */

.modal-wide { max-width: 46rem; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
@media (max-width: 620px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat-row .stat { padding: 0.9rem; }
.stat-row .stat-value { font-size: 1.35rem; }
.table-wrap { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }

/* ── Playground ──────────────────────────────────────────────────────── */

/*
 * The model picker is the only control, so it is one wide row rather than a
 * grid of half-empty form fields: a label, a select that looks like the page
 * rather than like a default OS widget, and the access chip that tells you what
 * a send will cost before you send it.
 */
.pg-panel { padding: 1.1rem 1.1rem 1.2rem; }

.pg-toolbar {
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  padding-bottom: 0.9rem; border-bottom: 1px solid var(--line-soft);
}
.pg-model { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.pg-model-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); flex: 0 0 auto;
}
.pg-model select {
  /*
   * `appearance: none` plus a background chevron: the native arrow cannot be
   * coloured, and a white dropdown on this page is the thing that made the old
   * control look pasted in. The chevron is a data URI so there is no extra file.
   */
  appearance: none; -webkit-appearance: none;
  flex: 1; min-width: 0; max-width: 32rem;
  font: 600 15px var(--font-display); letter-spacing: -0.01em;
  color: var(--text);
  background-color: var(--ink-900);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2335e0d8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 11px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.62rem 2.2rem 0.62rem 0.85rem;
  cursor: pointer;
  text-overflow: ellipsis;
}
.pg-model select:hover { border-color: var(--ink-600); }
.pg-model select:focus-visible { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-glow); }
/* The popup list is drawn by the OS — on a dark page it needs the dark palette,
 * or the options render as black text on the UA's own white. */
.pg-model select option { background: var(--ink-800); color: var(--text); }

.pg-hint { color: var(--text-faint); font-size: 12.5px; margin: 0.7rem 0 0; min-height: 1.1rem; }

.pg-thread {
  min-height: 16rem; max-height: 32rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 1rem; margin: 0.9rem 0 0.9rem;
  background: var(--ink-900); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.pg-msg { max-width: 80%; padding: 0.7rem 0.95rem; border-radius: 12px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.pg-user { align-self: flex-end; background: var(--signal-fill); color: var(--on-signal); border-bottom-right-radius: 4px; }
.pg-bot { align-self: flex-start; background: var(--ink-700); border: 1px solid var(--line-soft); border-bottom-left-radius: 4px; }
.pg-error { align-self: flex-start; background: rgba(255, 107, 129, 0.12); border: 1px solid rgba(255, 107, 129, 0.3); color: var(--rose); }
.pg-meta { align-self: flex-start; color: var(--text-faint); font-size: 12px; margin-top: -0.3rem; }

.pg-compose { display: flex; gap: 0.6rem; align-items: flex-end; }
.pg-compose textarea {
  flex: 1; min-width: 0; resize: vertical; min-height: 2.6rem;
  font: 400 14px/1.6 var(--font-body); color: var(--text);
  background: var(--ink-900); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}
.pg-compose textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-glow); }
@media (max-width: 480px) { .pg-compose { flex-direction: column; align-items: stretch; } .pg-compose .btn { width: 100%; } }

/* ── Light theme ─────────────────────────────────────────────────────── */

/*
 * The same portal, printed on paper.
 *
 * Only the palette moves: everything above is written against these variables,
 * so a light page is the same layout in different ink. app.js — and the inline
 * script in index.html, which runs before the first paint — put the choice on
 * <html data-theme>, following the machine's own setting when the preference is
 * "system".
 *
 * Dark stays the attribute-less default, so a browser that never runs the
 * switch sees exactly what it always saw.
 *
 * The two canvas colours are the one place the relationship inverts rather than
 * just lightens: on ink, --ink-900 is the recessed surface (the playground
 * thread, a code block) and --ink-850 the raised card. On paper the *page* is
 * the lightest thing, so the fields that were recessed become white and the
 * cards sit on a slightly grey page — which is why --ink-850 is lighter than
 * --ink-900 here and not the other way round.
 */
[data-theme="light"] {
  color-scheme: light;

  --ink-900: #ffffff;
  --ink-850: #f7f8fc;
  --ink-800: #ffffff;
  --ink-700: #eceef6;
  --ink-600: #dfe3ef;
  --line: #dde2ee;
  --line-soft: #e8ecf5;

  --text: #131a2e;
  --text-dim: #59637a;
  --text-faint: #7b859e;

  /* The signal colour survives on white, but only deepened: #35e0d8 as text on
   * paper is barely legible, and as a fill under #04201f text it is worse. */
  --signal: #0f9d96;
  --signal-deep: #0b857f;
  --signal-glow: rgba(15, 157, 150, 0.16);
  --on-signal: #ffffff;
  /* White text needs a darker fill than #0f9d96 to clear 4.5:1; this is the same
   * deepened teal the brand mark uses with white. */
  --signal-fill: #0b7a74;
  --signal-fill-hover: #096660;
  --violet: #5b48e0;
  --amber: #b45309;
  --rose: #d93b52;

  --shadow: 0 18px 40px -26px rgba(19, 26, 46, 0.35);
}

body { background:
    radial-gradient(1100px 600px at 82% -10%, rgba(15, 157, 150, 0.07), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(91, 72, 224, 0.05), transparent 55%),
    var(--ink-900);
}

/* Sticky chrome is translucent over the canvas, so it needs the light wash. */

/* On white, a shadow is a smudge — hold the modal down with the overlay
 * instead, and let toasts keep a much softer lift. */
[data-theme="light"] .modal-overlay,
[data-theme="light"] .modal-backdrop { background: rgba(19, 26, 46, 0.42); }
[data-theme="light"] .toast { box-shadow: 0 8px 24px rgba(19, 26, 46, 0.12); }
[data-theme="light"] .modal { box-shadow: 0 24px 60px rgba(19, 26, 46, 0.18); }

/*
 * Tints tuned for a dark page turn to mud on white: a pale wash of red reads as
 * a warning against #0a0e1a and as a stain against #ffffff. Each state gets its
 * own density, and the text colours it needs to stay readable.
 */
[data-theme="light"] .auth-error,
[data-theme="light"] .modal-error { color: #b91c1c; }

[data-theme="light"] .pg-error {
  background: rgba(217, 59, 82, 0.07);
  border-color: rgba(217, 59, 82, 0.28);
  color: #b91c1c;
}

[data-theme="light"] .auth-referral {
  border-color: rgba(15, 157, 150, 0.4);
  color: #0b6f6a;
}

/* The code blocks keep the "terminal" idea but inverted: a pale slate panel
 * with the deepened signal for the tokens. */
[data-theme="light"] .quickstart pre,
[data-theme="light"] .landing-code,
[data-theme="light"] .doc-code,
[data-theme="light"] .aside-code { background: #f2f4fa; }

[data-theme="light"] .reveal { background: #f2f4fa; color: #0b6f6a; border-color: var(--signal); }

/* The active nav pill is one of the few dark-filled surfaces by intent: keep it
 * legible on paper by holding the text at full ink rather than dimming it. */
[data-theme="light"] .nav-item.active { color: var(--text); }

[data-theme="light"] .hero { background: linear-gradient(150deg, #ffffff, #f5f7fc); }
[data-theme="light"] .auth-aside { background: linear-gradient(160deg, #f5f7fc, #ffffff); }
[data-theme="light"] .auth-aside::after { background: radial-gradient(600px 400px at 70% 30%, rgba(15, 157, 150, 0.09), transparent 70%); }

/* The shimmer is a white wash, which is invisible on a light card — invert it. */
[data-theme="light"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(19, 26, 46, 0.045), transparent);
}

[data-theme="light"] .error-state {
  background: rgba(217, 59, 82, 0.06);
  border-color: rgba(217, 59, 82, 0.26);
  color: #b91c1c;
}
[data-theme="light"] .error-state h3 { color: #7f1d1d; }

[data-theme="light"] .sparkline:hover .bar { background: var(--ink-600); }

/* The id chip sits on the card, so on paper it reads as inset rather than as
 * another card. */
[data-theme="light"] .model-call-id { background: #f2f4fa; }
