/* ==========================================================================
   Credence — Risk Engine UI
   1. Tokens  2. Base  3. Layout  4. Components  5. Pages  6. Motion  7. Responsive
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --font-serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --container: 1200px;
  --topbar-h: 64px;

  /* Risk band palette (shared by both themes, tuned for contrast on each) */
  --band-vl: #12895f;
  --band-l:  #3fa774;
  --band-m:  #d39a1f;
  --band-h:  #e0702f;
  --band-vh: #d23f47;
}

:root, [data-theme="light"] {
  color-scheme: light;
  --bg:          #f4f3ef;
  --bg-2:        #eceae4;
  --surface:     #ffffff;
  --surface-2:   #faf9f6;
  --surface-3:   #f3f2ee;
  --glass:       rgba(255, 255, 255, .72);
  --line:        rgba(20, 22, 30, .08);
  --line-2:      rgba(20, 22, 30, .14);
  --ink:         #12141c;
  --ink-2:       #4a4e5a;
  --ink-3:       #868994;
  --ink-4:       #b4b6bd;
  --accent:      #3346e0;
  --accent-2:    #4f8bff;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(51, 70, 224, .08);
  --accent-line: rgba(51, 70, 224, .28);
  --good:        #12895f;
  --good-soft:   rgba(18, 137, 95, .10);
  --warn:        #b97a0c;
  --warn-soft:   rgba(211, 154, 31, .14);
  --bad:         #c9363e;
  --bad-soft:    rgba(210, 63, 71, .10);
  --shadow-xs:   0 1px 2px rgba(18, 20, 28, .05);
  --shadow-sm:   0 1px 2px rgba(18, 20, 28, .04), 0 2px 6px -2px rgba(18, 20, 28, .06);
  --shadow-md:   0 1px 2px rgba(18, 20, 28, .04), 0 12px 32px -12px rgba(18, 20, 28, .14);
  --shadow-lg:   0 2px 4px rgba(18, 20, 28, .04), 0 24px 60px -20px rgba(18, 20, 28, .22);
  --grid-line:   rgba(20, 22, 30, .045);
  --glow:        rgba(79, 139, 255, .18);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #0b0c10;
  --bg-2:        #101218;
  --surface:     #13151b;
  --surface-2:   #171a21;
  --surface-3:   #1c1f27;
  --glass:       rgba(19, 21, 27, .7);
  --line:        rgba(255, 255, 255, .07);
  --line-2:      rgba(255, 255, 255, .12);
  --ink:         #eceef3;
  --ink-2:       #a6aab6;
  --ink-3:       #6e7280;
  --ink-4:       #464a55;
  --accent:      #7d8cff;
  --accent-2:    #5fa2ff;
  --accent-ink:  #0b0c10;
  --accent-soft: rgba(125, 140, 255, .12);
  --accent-line: rgba(125, 140, 255, .35);
  --good:        #3fcf94;
  --good-soft:   rgba(63, 207, 148, .12);
  --warn:        #f0b94a;
  --warn-soft:   rgba(240, 185, 74, .12);
  --bad:         #ff6b72;
  --bad-soft:    rgba(255, 107, 114, .12);
  --shadow-xs:   0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px -2px rgba(0, 0, 0, .4);
  --shadow-md:   0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -16px rgba(0, 0, 0, .7);
  --shadow-lg:   0 2px 4px rgba(0, 0, 0, .4), 0 30px 80px -24px rgba(0, 0, 0, .8);
  --grid-line:   rgba(255, 255, 255, .035);
  --glow:        rgba(95, 120, 255, .16);

  --band-vl: #33c48a;
  --band-l:  #7fd3a4;
  --band-m:  #f0b94a;
  --band-h:  #f68a4c;
  --band-vh: #ff6b72;
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  transition: background-color .4s var(--ease-out), color .4s var(--ease-out);
}

img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.icon {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 22px; height: 22px; }

.mono { font-family: var(--font-mono); font-feature-settings: "zero", "tnum"; letter-spacing: -.01em; }
.serif { font-family: var(--font-serif); font-weight: 400; letter-spacing: -.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.c-good { color: var(--good); }
.c-warn { color: var(--warn); }
.c-bad  { color: var(--bad); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 8px 14px; border-radius: 10px;
  background: var(--ink); color: var(--bg);
  transform: translateY(-150%);
  transition: transform .2s var(--ease-out);
}
.skip-link:focus { transform: none; }

/* 3. Layout ---------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.backdrop__glow {
  position: absolute; left: 50%; top: -340px;
  width: 1400px; height: 760px;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side at 35% 55%, var(--glow), transparent 70%),
    radial-gradient(closest-side at 70% 45%, rgba(255, 170, 120, .10), transparent 70%);
  filter: blur(20px);
}
.backdrop__grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, #000 30%, transparent 75%);
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color .3s, border-color .3s, backdrop-filter .3s;
}
.topbar.is-scrolled {
  background: var(--glass);
  border-bottom-color: var(--line);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}
.topbar__inner { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.brand__mark { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 4px 14px -4px var(--accent-line); transition: transform .5s var(--ease-spring); }
.brand:hover .brand__mark { transform: rotate(-8deg) scale(1.05); }
.brand__name { font-weight: 600; font-size: 16px; letter-spacing: -.02em; }
.brand__tag {
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  padding: 2px 7px; border: 1px solid var(--line-2); border-radius: 99px;
  letter-spacing: .01em;
}

.nav {
  position: relative;
  display: flex; align-items: center; gap: 2px;
  margin-inline: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--shadow-xs);
}
.nav__indicator {
  position: absolute; top: 4px; left: 0;
  height: calc(100% - 8px); width: 0;
  background: var(--ink);
  border-radius: 99px;
  transition: transform .5s var(--ease-out), width .5s var(--ease-out), opacity .2s;
  opacity: 0;
}
.nav.is-ready .nav__indicator { opacity: 1; }
.nav__hover {
  position: absolute; top: 4px; left: 0;
  height: calc(100% - 8px); width: 0;
  background: var(--surface-3);
  border-radius: 99px;
  opacity: 0;
  transition: transform .35s var(--ease-out), width .35s var(--ease-out), opacity .25s;
}
.nav__link {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  font-size: 14px; font-weight: 500;
  color: var(--ink-2);
  border-radius: 99px;
  transition: color .3s var(--ease-out);
  white-space: nowrap;
}
.nav__link .icon { width: 16px; height: 16px; }
.nav__link:hover { color: var(--ink); }
.nav__link.is-active { color: var(--bg); }
.nav:not(.is-ready) .nav__link.is-active { background: var(--ink); }
.nav__count {
  min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center;
  font: 500 11px/1 var(--font-mono);
  border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
.nav__link.is-active .nav__count { background: rgba(255,255,255,.18); color: inherit; }

.topbar__actions { display: flex; align-items: center; gap: 8px; flex: none; }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px;
  font-size: 13px; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface);
}
.status__dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); }
.status[data-state="online"] .status__dot { background: var(--good); }
.status[data-state="online"] .status__dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  background: var(--good); opacity: .35;
  animation: ping 2.4s var(--ease-out) infinite;
}
.status[data-state="offline"] .status__dot { background: var(--bad); }
.status__latency { color: var(--ink-3); font-size: 12px; }
.status__latency:empty { display: none; }

.icon-btn {
  display: inline-grid; grid-auto-flow: column; place-items: center; gap: 6px;
  height: 34px; min-width: 34px; padding: 0 9px;
  border-radius: 99px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: color .2s, border-color .2s, background-color .2s, transform .2s var(--ease-out);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn:active { transform: scale(.95); }
.icon-btn__text { font-size: 12px; font-weight: 500; }

.theme-toggle { position: relative; width: 34px; padding: 0; overflow: hidden; }
.theme-toggle .icon { position: absolute; transition: transform .6s var(--ease-spring), opacity .3s; }
.theme-toggle .icon--moon { transform: translateY(24px) rotate(-90deg); opacity: 0; }
[data-theme="dark"] .theme-toggle .icon--sun { transform: translateY(-24px) rotate(90deg); opacity: 0; }
[data-theme="dark"] .theme-toggle .icon--moon { transform: none; opacity: 1; }

/* Dropdown menu */
.menu { position: relative; }
.menu__list {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 180px; padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
  pointer-events: none;
  transition: opacity .18s, transform .25s var(--ease-out);
  z-index: 50;
}
.menu.is-open .menu__list { opacity: 1; transform: none; pointer-events: auto; }
.menu__list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 8px;
  font-size: 14px; color: var(--ink-2); text-align: left;
}
.menu__list button .mono { font-size: 11px; color: var(--ink-3); }
.menu__list button:hover { background: var(--surface-3); color: var(--ink); }
.menu__list button[aria-checked="true"] { color: var(--ink); font-weight: 500; }
.menu__list button[aria-checked="true"] .mono { color: var(--accent); }

.main { flex: 1; padding-bottom: 72px; }

.footer { border-top: 1px solid var(--line); padding: 22px 0; font-size: 13px; }
.footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer__left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.footer__left .brand__name { font-size: 14px; }
.footer__muted { color: var(--ink-3); }
.footer__links { display: flex; gap: 18px; }
.footer__links a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); transition: color .2s; }
.footer__links a:hover { color: var(--ink); }
.footer__links .icon { width: 15px; height: 15px; }

.tabbar { display: none; }

/* Page header */
.page-head { padding: 44px 0 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-head__eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.page-head__title { font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -.035em; font-weight: 600; }
.page-head__title .serif { font-style: italic; font-weight: 400; letter-spacing: -.02em; color: var(--ink-2); }
.page-head__sub { margin-top: 10px; color: var(--ink-2); max-width: 60ch; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.section { margin-top: 28px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section__title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.section__sub { font-size: 14px; color: var(--ink-3); }

/* 4. Components ------------------------------------------------------------ */

/* Buttons */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-2);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  font-size: 14px; font-weight: 500; letter-spacing: -.005em;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: 12px;
  white-space: nowrap;
  transition: transform .2s var(--ease-out), box-shadow .25s, background-color .2s, border-color .2s, color .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { border-color: var(--ink-4); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }

.btn--primary {
  --btn-bg: var(--ink);
  --btn-fg: var(--bg);
  --btn-bd: transparent;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 6px 18px -8px rgba(18, 20, 28, .5);
}
.btn--primary:hover { box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 10px 26px -10px rgba(18, 20, 28, .6); border-color: transparent; }
.btn--accent {
  --btn-bg: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  --btn-fg: #fff;
  --btn-bd: transparent;
  background: var(--btn-bg);
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 22px -8px var(--accent-line);
}
[data-theme="dark"] .btn--accent { --btn-fg: #0b0c10; }
.btn--accent:hover { box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 12px 30px -10px var(--accent); border-color: transparent; }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }
.btn--ghost:hover { --btn-bg: var(--surface-3); --btn-fg: var(--ink); border-color: transparent; }
.btn--danger { --btn-fg: var(--bad); }
.btn--danger:hover { --btn-bg: var(--bad-soft); border-color: transparent; }
.btn--lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 14px; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn--block { width: 100%; }
.btn .arrow { transition: transform .3s var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }

.kbd {
  display: inline-flex; align-items: center; gap: 2px;
  height: 20px; padding: 0 6px;
  font: 500 11px/1 var(--font-mono);
  border-radius: 6px;
  border: 1px solid currentColor;
  opacity: .55;
}

/* Cards */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card--pad { padding: 22px; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.card__title { font-size: 15px; font-weight: 600; letter-spacing: -.015em; display: flex; align-items: center; gap: 10px; }
.card__title .icon-chip { margin-right: 2px; }
.card__sub { font-size: 13px; color: var(--ink-3); }
.card__body { padding: 18px 22px 22px; }

.icon-chip {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--line);
}
.icon-chip .icon { width: 16px; height: 16px; }

/* Badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  font-size: 12px; font-weight: 500; letter-spacing: .005em;
  border-radius: 99px;
  white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge--plain::before { display: none; }
.badge--good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge--bad  { background: var(--bad-soft);  color: var(--bad);  border-color: transparent; }
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge--lg { height: 30px; padding: 0 12px; font-size: 13px; }

.band-dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; flex: none; }

/* Form controls */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field__label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.field__hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.field__error { font-size: 12px; color: var(--bad); min-height: 0; }

.input, .select {
  width: 100%;
  height: 42px; padding: 0 12px;
  font-size: 15px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 11px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--ink-4); }
.input:hover, .select:hover { border-color: var(--ink-4); }
.input:focus, .select:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.input--mono { font-family: var(--font-mono); font-size: 14px; font-feature-settings: "tnum"; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 44px; }
.input-wrap__suffix {
  position: absolute; right: 12px;
  font-size: 12px; color: var(--ink-3);
  pointer-events: none;
}

.select {
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868994' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.select option { background: var(--surface); color: var(--ink); }

/* Segmented control */
.segmented {
  position: relative;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 11px;
  height: 42px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 500; color: var(--ink-3);
  border-radius: 8px;
  cursor: pointer;
  transition: color .2s;
  white-space: nowrap;
  padding: 0 8px;
}
.segmented label:hover { color: var(--ink); }
.segmented input:checked + label { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  position: relative; width: 34px; height: 20px; border-radius: 99px;
  background: var(--ink-4);
  transition: background-color .25s;
  flex: none;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .35s var(--ease-spring);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Range slider */
.range { --pct: 50%; --range-color: var(--accent); position: relative; height: 28px; display: flex; align-items: center; }
.range input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 99px;
  background: linear-gradient(90deg, var(--range-color) var(--pct), var(--surface-3) var(--pct));
  box-shadow: inset 0 0 0 1px var(--line);
  outline: none; cursor: pointer;
  transition: opacity .2s;
}
.range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 2px 6px rgba(18,20,28,.25), 0 0 0 0 var(--accent-soft);
  transition: box-shadow .2s, transform .2s var(--ease-spring);
}
.range input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 1px solid rgba(0,0,0,.08);
  box-shadow: 0 2px 6px rgba(18,20,28,.25);
}
.range input[type="range"]:hover::-webkit-slider-thumb { box-shadow: 0 2px 6px rgba(18,20,28,.25), 0 0 0 6px var(--accent-soft); }
.range input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.range input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent); }
.range input[type="range"]:disabled { opacity: .35; cursor: not-allowed; }

/* Progress bar */
.bar { position: relative; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.bar__fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 1.1s var(--ease-out);
}

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  width: max-content; max-width: 260px;
  padding: 7px 10px;
  font-size: 12px; font-weight: 400; line-height: 1.4; text-align: left;
  letter-spacing: 0; text-transform: none;
  color: var(--bg); background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .2s var(--ease-out);
  z-index: 30;
  white-space: normal;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.tip-icon { display: inline-grid; place-items: center; color: var(--ink-4); cursor: help; }
.tip-icon .icon { width: 14px; height: 14px; }
.tip-icon:hover { color: var(--ink-2); }

/* Toasts */
.toasts {
  position: fixed; z-index: 90;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: 380px;
  padding: 12px 14px 12px 12px;
  font-size: 14px;
  color: var(--bg);
  background: var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .45s var(--ease-spring) both;
}
.toast.is-leaving { animation: toast-out .3s var(--ease-out) forwards; }
.toast__icon { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; flex: none; background: rgba(255,255,255,.12); }
[data-theme="dark"] .toast__icon { background: rgba(0,0,0,.08); }
.toast__icon .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.toast--good .toast__icon { color: var(--band-l); }
.toast--bad .toast__icon { color: var(--band-vh); }

/* Modal & drawer */
.overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10, 11, 15, .38);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease-out);
}
.overlay.is-open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; z-index: 80; left: 50%; top: 50%;
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -46%) scale(.97);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .4s var(--ease-spring);
}
.modal.is-open { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.modal__icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--bad-soft); color: var(--bad); margin-bottom: 16px; }
.modal__title { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.modal__text { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.modal__actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 10px; }

.drawer {
  position: fixed; z-index: 80; top: 10px; right: 10px; bottom: 10px;
  width: min(480px, calc(100vw - 20px));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateX(calc(100% + 24px));
  transition: transform .55s var(--ease-out);
  overflow: hidden;
}
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer__body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer__foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* Skeleton */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-3);
  border-radius: 8px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: shimmer 1.6s infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); }

/* Table */
.table-wrap { overflow-x: auto; }
.table { font-size: 14px; }
.table th {
  position: sticky; top: 0;
  padding: 12px 16px;
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  text-align: left; white-space: nowrap;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.table th.num, .table td.num { text-align: right; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--surface-2); }
.table tbody tr.is-clickable:hover .row-chevron { transform: translateX(3px); color: var(--ink); }
.row-chevron { color: var(--ink-4); transition: transform .25s var(--ease-out), color .2s; }

/* Empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 56px 24px;
  color: var(--ink-3);
}
.empty__art { width: 120px; height: 90px; margin-bottom: 18px; color: var(--ink-4); }
.empty__title { font-size: 16px; font-weight: 600; color: var(--ink); }
.empty__text { margin-top: 4px; max-width: 42ch; font-size: 14px; }
.empty .btn { margin-top: 18px; }

/* 5. Pages ------------------------------------------------------------------ */

/* --- Overview: hero --- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 560px;
  padding-block: 36px 12px;
}
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  height: 30px; padding: 0 12px 0 4px;
  font-size: 13px; color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  box-shadow: var(--shadow-xs);
}
.hero__eyebrow .badge { height: 22px; font-size: 11px; }
.hero__title {
  margin-top: 22px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: .98;
  letter-spacing: -.045em;
  font-weight: 600;
}
.hero__title .serif {
  display: inline-block;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -.03em;
  padding-right: .06em;
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 60%, #e98a5a 110%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero__lead { margin-top: 20px; font-size: 18px; line-height: 1.55; color: var(--ink-2); max-width: 50ch; }
.hero__cta { margin-top: 30px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero__meta { margin-top: 34px; display: flex; gap: 28px; flex-wrap: wrap; }
.hero__meta-item { display: flex; flex-direction: column; gap: 2px; }
.hero__meta-value { font-size: 26px; letter-spacing: -.02em; }
.hero__meta-label { font-size: 13px; color: var(--ink-3); }

.hero__stage { position: relative; height: 560px; }
.hero__canvas { position: absolute; inset: -40px -60px -40px -40px; }
.hero__canvas canvas { width: 100% !important; height: 100% !important; opacity: 0; transition: opacity 1.2s var(--ease-out); }
.hero__canvas.is-ready canvas { opacity: 1; }

/* CSS fallback card (shown until/unless WebGL renders) */
.hero__fallback {
  position: absolute; left: 50%; top: 50%;
  width: 340px; aspect-ratio: 1.586;
  transform: translate(-50%, -50%) rotateX(14deg) rotateY(-18deg) rotateZ(4deg);
  border-radius: 22px;
  background: radial-gradient(120% 120% at 0% 0%, #2c3a9e 0%, #151a33 45%, #0c0e17 100%);
  box-shadow: var(--shadow-lg);
  transition: opacity .8s;
}
.hero__canvas.is-ready + .hero__fallback { opacity: 0; }

.float-card {
  position: absolute; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  animation: float 7s var(--ease-in-out) infinite;
  will-change: transform;
}
.float-card__label { font-size: 12px; color: var(--ink-3); }
.float-card__value { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.float-card--a { left: 0; top: 70px; }
.float-card--b { right: 0; bottom: 92px; animation-delay: -3.5s; }
.float-card--c { left: 34px; bottom: 30px; animation-delay: -1.8s; animation-duration: 8s; }
.float-card .icon-chip { width: 34px; height: 34px; border-radius: 10px; }
.icon-chip--good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.icon-chip--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.mini-gauge { width: 38px; height: 38px; }

/* --- Overview: KPI strip --- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.kpi { position: relative; padding: 20px 22px; background: var(--surface); transition: background-color .25s; }
.kpi:hover { background: var(--surface-2); }
.kpi__label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.kpi__value { margin-top: 8px; font-size: 40px; line-height: 1; letter-spacing: -.02em; }
.kpi__foot { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); }
.kpi__bench { position: relative; margin-top: 12px; height: 4px; border-radius: 99px; background: var(--surface-3); }
.kpi__bench-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 1.4s var(--ease-out); }
.kpi__bench-mark { position: absolute; top: -4px; width: 2px; height: 12px; border-radius: 2px; background: var(--ink-3); }

/* --- Overview: grid --- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
.grid-2--even { grid-template-columns: 1fr 1fr; }

/* Distribution chart */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis text { font: 400 11px var(--font-mono); fill: var(--ink-3); }
.chart .axis line, .chart .gridline { stroke: var(--line); }
.chart .bar-rect { transition: opacity .2s; transform-box: fill-box; transform-origin: bottom; }
.chart.is-hovering .bar-rect { opacity: .35; }
.chart.is-hovering .bar-rect.is-hover { opacity: 1; }
.chart .dr-line { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart .dr-dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.chart .cut-line { stroke: var(--ink-4); stroke-dasharray: 3 4; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 150px; padding: 10px 12px;
  font-size: 12px;
  background: var(--ink); color: var(--bg);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(4px);
  transition: opacity .15s, transform .2s var(--ease-out);
}
.chart-tip.is-on { opacity: 1; transform: none; }
.chart-tip__title { font-weight: 600; margin-bottom: 6px; font-family: var(--font-mono); }
.chart-tip__row { display: flex; justify-content: space-between; gap: 16px; opacity: .85; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__line { width: 16px; height: 2px; background: var(--ink); border-radius: 2px; }

/* Band ladder */
.bands { display: flex; flex-direction: column; }
.band-row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.band-row:last-child { border-bottom: 0; }
.band-row__swatch { width: 12px; height: 32px; border-radius: 4px; }
.band-row__name { font-weight: 500; font-size: 14px; }
.band-row__meta { font-size: 12px; color: var(--ink-3); }
.band-row__stat { text-align: right; }
.band-row__dr { font-size: 15px; font-weight: 500; }
.band-row__share { font-size: 12px; color: var(--ink-3); }

/* Session / recent list */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.stat__label { font-size: 12px; color: var(--ink-3); }
.stat__value { margin-top: 4px; font-size: 28px; letter-spacing: -.02em; line-height: 1.1; }

.recent { display: flex; flex-direction: column; margin-top: 14px; }
.recent__item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 8px; margin: 0 -8px;
  border-radius: 12px;
  transition: background-color .15s;
}
.recent__item:hover { background: var(--surface-2); }
.recent__score {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  font: 500 15px var(--font-mono);
  color: var(--band-color, var(--ink));
  background: color-mix(in srgb, var(--band-color, var(--ink)) 12%, transparent);
}
.recent__title { font-size: 14px; font-weight: 500; }
.recent__meta { font-size: 12px; color: var(--ink-3); }

/* CTA banner */
.cta-banner {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 28px;
  padding: 32px;
  border-radius: var(--radius-xl);
  color: #fff;
  background:
    radial-gradient(80% 140% at 100% 0%, rgba(79,139,255,.55), transparent 60%),
    radial-gradient(60% 120% at 0% 100%, rgba(233,138,90,.35), transparent 60%),
    #11131c;
  box-shadow: var(--shadow-lg);
}
.cta-banner::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(90deg, transparent, #000);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
}
.cta-banner > * { position: relative; }
.cta-banner__title { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.03em; font-weight: 600; line-height: 1.15; }
.cta-banner__title .serif { font-style: italic; font-weight: 400; color: #c9d6ff; }
.cta-banner__text { margin-top: 6px; color: rgba(255,255,255,.7); font-size: 15px; }
.cta-banner .btn { --btn-bg: #fff; --btn-fg: #11131c; --btn-bd: transparent; }

/* --- Scorer --- */
.scorer { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
.scorer__form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.scorer__aside { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 16px; }

.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 10px 10px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.toolbar__group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar__label { font-size: 13px; color: var(--ink-3); margin-right: 2px; }
.preset {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px;
  font-size: 13px; font-weight: 500;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  transition: border-color .2s, color .2s, background-color .2s, transform .2s var(--ease-out);
}
.preset:hover { color: var(--ink); border-color: var(--ink-4); }
.preset:active { transform: scale(.96); }
.preset.is-active { color: var(--ink); border-color: var(--ink); background: var(--surface-2); }

.form-card { overflow: hidden; }
.form-card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.form-card__title { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.form-card__sub { font-size: 13px; color: var(--ink-3); }
.form-card__step { margin-left: auto; font: 500 12px var(--font-mono); color: var(--ink-4); }
.form-card__body { padding: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.form-card__body--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-card__body .span-2 { grid-column: span 2; }
.form-card__body .span-all { grid-column: 1 / -1; }

.collapsible__toggle {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  text-align: left;
}
.collapsible__toggle .chev { margin-left: auto; color: var(--ink-3); transition: transform .35s var(--ease-out); }
.collapsible.is-open .collapsible__toggle .chev { transform: rotate(180deg); }
.collapsible.is-open .collapsible__toggle { border-bottom: 1px solid var(--line); }
.collapsible__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--ease-out); }
.collapsible.is-open .collapsible__panel { grid-template-rows: 1fr; }
.collapsible__inner { overflow: hidden; }

.bureau-score {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: opacity .2s;
}
.bureau-score.is-off { opacity: .55; }
.bureau-score__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bureau-score__name { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.bureau-score__value { font: 500 22px var(--font-mono); letter-spacing: -.02em; }
.bureau-score__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.bureau-score__foot .switch { font-size: 12px; gap: 7px; }
.bureau-score__foot .switch__track { width: 28px; height: 16px; }
.bureau-score__foot .switch__track::after { width: 12px; height: 12px; }
.bureau-score__foot .switch input:checked + .switch__track::after { transform: translateX(12px); }

.ratios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; grid-column: 1 / -1; }
.ratio {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: border-color .3s, background-color .3s;
}
.ratio__label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.ratio__value { margin-top: 2px; font: 500 18px var(--font-mono); letter-spacing: -.02em; }
.ratio[data-level="good"] .ratio__value { color: var(--good); }
.ratio[data-level="warn"] { border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }
.ratio[data-level="warn"] .ratio__value { color: var(--warn); }
.ratio[data-level="bad"] { border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--bad-soft); }
.ratio[data-level="bad"] .ratio__value { color: var(--bad); }

.json-editor {
  width: 100%; min-height: 420px;
  padding: 16px;
  font: 13px/1.65 var(--font-mono);
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  outline: none; resize: vertical;
  tab-size: 2;
}
.json-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.submit-bar {
  position: sticky; bottom: 16px; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 12px 12px 18px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
}
.coverage { display: flex; align-items: center; gap: 12px; min-width: 0; }
.coverage__ring { width: 40px; height: 40px; flex: none; transform: rotate(-90deg); }
.coverage__ring circle { fill: none; stroke-width: 4; }
.coverage__ring .track { stroke: var(--surface-3); }
.coverage__ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease-out); }
.coverage__title { font-size: 14px; font-weight: 500; }
.coverage__sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.submit-bar .btn { margin-left: auto; }

/* Decision card with 3D flip */
.flip { perspective: 1600px; }
.flip__inner {
  position: relative;
  display: grid;
  transform-style: preserve-3d;
  transition: transform 1s var(--ease-out);
}
.flip.is-flipped .flip__inner { transform: rotateY(180deg); }
.flip__face {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip__face--back { transform: rotateY(180deg); }

.decision { overflow: hidden; }
.decision__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.decision__ref { font: 500 12px var(--font-mono); color: var(--ink-3); }
.decision__gauge { position: relative; padding: 4px 18px 0; }
.decision__gauge svg { width: 100%; height: auto; overflow: visible; }
.gauge-track { fill: none; stroke: var(--surface-3); }
.gauge-seg { fill: none; stroke-linecap: butt; opacity: .28; transition: opacity .6s; }
.gauge-seg.is-active { opacity: 1; }
.gauge-progress { fill: none; stroke-linecap: round; }
.gauge-tick text { font: 400 10px var(--font-mono); fill: var(--ink-3); }
.gauge-needle { transition: transform 1.4s var(--ease-out); transform-origin: 160px 160px; }
.gauge-center {
  position: absolute; left: 0; right: 0; bottom: 6px;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
}
.gauge-center__score { font-family: var(--font-serif); font-size: 76px; line-height: .9; letter-spacing: -.03em; }
.gauge-center__label { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.decision__verdict { text-align: center; padding: 10px 18px 18px; }
.decision__action { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 99px; font-weight: 600; font-size: 14px; letter-spacing: -.005em; }
.decision__action .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.decision__interp { margin-top: 10px; font-size: 14px; color: var(--ink-2); }

.decision__metrics { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.decision__metric { padding: 14px 18px; }
.decision__metric + .decision__metric { border-left: 1px solid var(--line); }
.decision__metric-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.decision__metric-value { margin-top: 2px; font: 500 20px var(--font-mono); letter-spacing: -.02em; }
.decision__metric .bar { margin-top: 8px; height: 4px; }

.decision__section { padding: 16px 18px; border-top: 1px solid var(--line); }
.decision__section-title { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.decision__section-title .muted { font-weight: 400; font-size: 12px; }

.agree { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-top: 10px; }
.agree .icon { width: 14px; height: 14px; }

.factors { display: flex; flex-direction: column; gap: 2px; }
.factor {
  display: grid; grid-template-columns: minmax(0, 1fr) 120px 48px; gap: 10px; align-items: center;
  padding: 6px 0;
  font-size: 13px;
  animation: rise .5s var(--ease-out) both;
}
.factor__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.factor__value { font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.factor__bar { position: relative; height: 8px; }
.factor__bar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-2); }
.factor__fill { position: absolute; top: 0; height: 100%; border-radius: 3px; width: 0; transition: width .9s var(--ease-out); }
.factor__fill--pos { left: 50%; background: var(--good); }
.factor__fill--neg { right: 50%; background: var(--bad); }
.factor__pts { text-align: right; font: 500 12px var(--font-mono); }
.factors__more { margin-top: 8px; }

.pending-face { display: flex; flex-direction: column; min-height: 100%; }
.pending-face__art { position: relative; padding: 20px 18px 0; }
.pending-face__text { padding: 8px 24px 24px; text-align: center; }
.pending-face__title { font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.pending-face__sub { margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.pending-face__steps { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 18px; display: flex; flex-direction: column; gap: 9px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-3); transition: color .3s; }
.step__dot {
  position: relative; width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--ink-4);
  display: grid; place-items: center;
  transition: border-color .3s, background-color .3s;
}
.step__dot .icon { width: 11px; height: 11px; stroke-width: 3; color: #fff; opacity: 0; transform: scale(.4); transition: opacity .25s, transform .4s var(--ease-spring); }
.step.is-active { color: var(--ink); }
.step.is-active .step__dot { border-color: var(--accent); border-top-color: transparent; animation: spin .7s linear infinite; }
.step.is-done { color: var(--ink-2); }
.step.is-done .step__dot { background: var(--good); border-color: var(--good); }
.step.is-done .step__dot .icon { opacity: 1; transform: none; }
.step__time { margin-left: auto; font: 400 11px var(--font-mono); color: var(--ink-4); }

.result-actions { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.result-actions .btn { flex: 1; }

.note { display: flex; gap: 10px; padding: 12px 14px; font-size: 13px; color: var(--ink-2); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.note .icon { color: var(--ink-3); width: 16px; height: 16px; margin-top: 2px; }

/* --- History --- */
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.summary-strip .stat { background: var(--surface); box-shadow: var(--shadow-xs); }
.filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .segmented { height: 36px; }
.filters .segmented label { font-size: 13px; padding: 0 12px; }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search .input { height: 36px; padding-left: 34px; width: 240px; font-size: 14px; }
.score-cell { display: flex; align-items: center; gap: 10px; }
.score-cell__bar { width: 56px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.score-cell__fill { height: 100%; border-radius: inherit; }
.id-cell { font: 500 13px var(--font-mono); }
.time-cell { color: var(--ink-3); font-size: 13px; }

.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd { font-family: var(--font-mono); text-align: right; }

/* --- Model page --- */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; counter-reset: step; }
.pipe {
  position: relative;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: transform .4s var(--ease-out), box-shadow .4s, border-color .3s;
}
.pipe:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.pipe::after {
  content: ""; position: absolute; right: -9px; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
  transform: translateY(-50%);
}
.pipe:last-child::after { display: none; }
.pipe__num { font: 500 11px var(--font-mono); color: var(--ink-4); }
.pipe__num::before { counter-increment: step; content: "0" counter(step); }
.pipe__title { margin-top: 18px; font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.pipe__text { margin-top: 4px; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.pipe .icon-chip { position: absolute; right: 14px; top: 14px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-xs); }
.metric__head { display: flex; align-items: center; justify-content: space-between; }
.metric__name { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.metric__value { margin-top: 8px; font-family: var(--font-serif); font-size: 44px; line-height: 1; letter-spacing: -.02em; }
.metric__bench { margin-top: 14px; font-size: 12px; color: var(--ink-3); display: flex; justify-content: space-between; }

.compare { width: 100%; font-size: 14px; }
.compare th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 0 0 10px; }
.compare td { padding: 12px 0; border-top: 1px solid var(--line); }
.compare .num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.compare th + th, .compare td + td { padding-left: 16px; }
.compare th { white-space: nowrap; }
.compare tr.is-selected td:first-child { font-weight: 600; }

.iv-list { display: flex; flex-direction: column; }
.iv-row {
  display: grid; grid-template-columns: 28px minmax(0, 1.2fr) minmax(0, 1fr) 56px; gap: 12px; align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.iv-row:last-child { border-bottom: 0; }
.iv-row__rank { font: 400 12px var(--font-mono); color: var(--ink-4); }
.iv-row__name { min-width: 0; }
.iv-row__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-row__code { font: 400 11px var(--font-mono); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-row__bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.iv-row__fill { height: 100%; border-radius: inherit; width: 0; transition: width 1s var(--ease-out); }
.iv-row__val { text-align: right; font: 500 13px var(--font-mono); }
.group-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-3); }

.formula {
  padding: 16px 18px;
  font: 13px/1.8 var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  color: var(--ink-2);
}
.formula b { color: var(--ink); font-weight: 500; }

/* Tilt (3D hover) */
.tilt { transform-style: preserve-3d; transition: transform .6s var(--ease-out); will-change: transform; }
.tilt__glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 0%), rgba(255,255,255,.35), transparent 45%);
  opacity: 0; transition: opacity .4s;
  mix-blend-mode: soft-light;
}
.tilt:hover .tilt__glare { opacity: 1; }

/* 6. Motion ---------------------------------------------------------------- */
@keyframes ping { 0% { transform: scale(.6); opacity: .5; } 80%, 100% { transform: scale(2.4); opacity: 0; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 var(--accent-line); } 100% { box-shadow: 0 0 0 14px transparent; } }

[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .9s var(--ease-out), transform .9s var(--ease-out); transition-delay: var(--d, 0ms); }
[data-reveal].is-in { opacity: 1; transform: none; }

/* Heading entrance: lines slide up from a mask */
.line { display: block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.12em; }
.line > span { display: inline-block; transform: translateY(110%); animation: word-up 1.1s var(--ease-out) forwards; animation-delay: var(--d, 0ms); }
@keyframes word-up { to { transform: none; } }

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .22s var(--ease-out) both; }
::view-transition-new(root) { animation: vt-in .38s var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(6px); } }
.topbar { view-transition-name: topbar; }
.nav__indicator { view-transition-name: nav-indicator; }

/* 7. Responsive ------------------------------------------------------------ */
@media (max-width: 1100px) {
  .scorer { grid-template-columns: minmax(0, 1fr) 360px; }
  .factor { grid-template-columns: minmax(0, 1fr) 90px 44px; }
  .status__label { display: none; }
  .pipeline { grid-template-columns: repeat(3, 1fr); }
  .pipe:nth-child(3)::after { display: none; }
}

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-top: 24px; }
  .hero__stage { height: 420px; order: -1; margin-top: -10px; }
  .hero__canvas { inset: -20px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2--even { grid-template-columns: 1fr; }
  .scorer { grid-template-columns: 1fr; }
  .scorer__aside { position: static; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .nav__link span:not(.nav__count) { display: none; }
  .nav__link { padding: 0 12px; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  .container { padding-inline: 16px; }
  .nav, .status, .brand__tag { display: none; }
  .topbar__actions { margin-left: auto; }
  .main { padding-bottom: 110px; }
  .footer { padding-bottom: 96px; }

  .tabbar {
    position: fixed; z-index: 45;
    left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
  }
  .tabbar__link {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 4px;
    font-size: 11px; font-weight: 500; color: var(--ink-3);
    border-radius: 14px;
    transition: color .2s, background-color .2s;
  }
  .tabbar__link.is-active { color: var(--ink); background: var(--surface-3); }
  .tabbar__link .icon { width: 20px; height: 20px; }

  .toasts { left: 16px; right: 16px; bottom: 96px; align-items: stretch; }
  .toast { max-width: none; }

  .page-head { padding: 28px 0 20px; }
  .hero__title { font-size: 44px; }
  .hero__lead { font-size: 16px; }
  .hero__stage { height: 340px; }
  .float-card--a { top: 16px; }
  .float-card--b { bottom: 40px; }
  .float-card--c { display: none; }
  .hero__meta { gap: 20px; }
  .kpi { padding: 16px; }
  .kpi__value { font-size: 32px; }
  .form-card__body, .form-card__body--3 { grid-template-columns: 1fr; }
  .form-card__body .span-2 { grid-column: auto; }
  .ratios { grid-template-columns: 1fr; }
  .submit-bar { bottom: 92px; gap: 10px; padding: 10px 10px 10px 12px; }
  .submit-bar .btn { height: 44px; padding: 0 16px; }
  .submit-bar .kbd { display: none; }
  .coverage { gap: 10px; }
  .coverage__ring { width: 34px; height: 34px; }
  .coverage__title { font-size: 13px; line-height: 1.3; }
  .coverage__sub { display: none; }
  .stat-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat__value { font-size: 22px; }
  .pipeline { grid-template-columns: 1fr; }
  .pipe::after { display: none; }
  .search .input { width: 100%; }
  .search { flex: 1; }
  .filters .segmented { width: 100%; overflow-x: auto; }
  .cta-banner { padding: 24px; }
  .iv-row { grid-template-columns: 22px minmax(0, 1fr) 70px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
  .line > span { transform: none; }
}
