/*
 * The tool's own chrome.
 *
 * This is an application, not a chart, and the two have different rules. A
 * chart plate is locked to the corpus palette — those hexes are house law and
 * the renderer may not drift from them. The app is free to darken them, and it
 * has to: measured against white, the chart palette's own accents fail WCAG AA
 * as small text (`#9AA3AF` is 2.55:1, white on `#66B2B0` is 2.45:1). So the
 * brand hues below are the corpus ones, and every *text* token is a darkened
 * sibling. Nothing here changes what a chart looks like.
 *
 * Two columns, fixed rail: the rail is the preset library and does not scroll
 * with the stage. Dense by intent — 373 decks have to be scannable — but never
 * below 12px, and every operable control carries a visible focus ring.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  /* Brand — identical to the renderer's palette. Fills only. */
  --navy: #123B79;
  --navy-deep: #0C2A57;
  --mid: #3C71BB;
  --teal: #66B2B0;
  --orange: #F15A24;

  /* Text-safe siblings. Ratios below are against #FFFFFF unless noted. */
  --ink: #10151C;          /* 18.3:1  headings, selected rows */
  --ink-2: #3B4553;        /*  9.7:1  body copy */
  --ink-3: #5B6676;        /*  5.8:1  labels, counts — the lightest text we use */
  --navy-ink: #0E3163;     /* 12.8:1  navy that is readable as text */
  --teal-ink: #1F6E6C;     /*  6.0:1  the teal, dark enough to read */
  --good: #12703F;         /*  6.2:1 */
  --warn: #8A5300;         /*  6.3:1 */
  --bad: #B32B20;          /*  6.4:1 */

  /* Surfaces */
  --surface: #F1F4F8;
  --surface-2: #E8EDF4;
  --card: #FFFFFF;
  --tint: #EDF2FA;         /* selected row wash */
  --rule: #E2E8F0;
  --rule-2: #D3DCE8;

  --rail-w: 356px;
  --radius: 10px;
  --radius-lg: 14px;

  /* One duration per intent, not one per component: a hover is felt, a panel
     arriving is watched. */
  --t-fast: 120ms;
  --t-base: 200ms;
  --ease: cubic-bezier(0.2, 0, 0.15, 1);

  /* The house face, served from assets/fonts, with a system fallback chain
     that is metric-similar enough not to reflow the layout on first paint. */
  --font: 'Satoshi', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --shadow-1: 0 1px 2px rgba(16, 21, 28, 0.06), 0 1px 1px rgba(16, 21, 28, 0.04);
  --shadow-2: 0 4px 16px rgba(16, 21, 28, 0.08), 0 1px 3px rgba(16, 21, 28, 0.05);
}

@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('/fonts/Satoshi-Black.otf') format('opentype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.25; }

/* Numbers that sit in columns must not jitter as they change. */
.tnum, .preset-pages, .rail-count, #count, .deck-meta { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- focus */
/* Never removed, only redrawn. :focus-visible so a mouse click does not
   leave a ring behind, but every keyboard stop is unmissable. */

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  border-radius: 6px;
}
/* On navy fills the navy ring is invisible, so those get a light one. */
.topbar :focus-visible,
.btn:focus-visible,
.chip-on:focus-visible { outline-color: #FFFFFF; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: 0 0 var(--radius) var(--radius);
  background: var(--card); color: var(--navy-ink); font-weight: 500;
  box-shadow: var(--shadow-2);
  transition: top var(--t-fast) var(--ease);
}
.skip:focus { top: 0; }

/* -------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px; padding: 0 20px;
  background: linear-gradient(180deg, #16468C 0%, var(--navy) 62%, var(--navy-deep) 100%);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 9px; color: #fff; min-width: 0; }
/* A neutral glyph rather than a house wordmark — see index.html. */
.brand-glyph { width: 17px; height: 17px; fill: #fff; opacity: 0.85; flex: none; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: 0.1px; white-space: nowrap; }

.topbar-right { display: flex; align-items: center; gap: 9px; min-width: 0; }
.hub-back {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 10px;
  color: #fff; text-decoration: none; font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.hub-back:hover,.hub-back:focus-visible { background: rgba(255,255,255,.14); text-decoration: none; }
.auth-chip {
  max-width: 220px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  color: #fff; background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.auth-chip:hover { background: rgba(255, 255, 255, 0.2); }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: 999px; cursor: default;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #C7D0DC; flex: none; }
.pill-idle .dot { background: #C7D0DC; }
.pill-ok .dot { background: #4ADE80; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.22); }
.pill-warn .dot { background: #FBBF24; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.22); }
.pill-bad .dot { background: #F87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.22); }

/* A hairline of the render's own progress, so a slow deck reads as working
   even when the eye is already down in the rail. */
.progress {
  position: fixed; top: 60px; left: 0; right: 0; height: 2px; z-index: 30;
  background: transparent; overflow: hidden; pointer-events: none;
}
.progress::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--teal), var(--mid), transparent);
  transform: translateX(-100%);
  animation: sweep 1.15s var(--ease) infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }

/* ---------------------------------------------------------- authentication */

.auth-gate {
  min-height: calc(100vh - 60px); padding: 42px 20px;
  display: grid; place-items: center;
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(440px, 100%); padding: 42px 38px; text-align: center;
  border: 1px solid var(--rule); border-radius: 20px;
  background: var(--card); box-shadow: var(--shadow-2);
}
.auth-mark { width: 72px; height: 52px; fill: var(--navy); margin-bottom: 18px; }
.auth-eyebrow {
  margin: 0 0 8px; color: var(--teal-ink); font-size: 11px;
  font-weight: 900; letter-spacing: 1.3px;
}
.auth-card h1 { margin: 0 0 12px; color: var(--navy-ink); font-size: 28px; }
.auth-card > p:not(.auth-eyebrow):not(.auth-error) {
  max-width: 34ch; margin: 0 auto 24px; color: var(--ink-2); line-height: 1.65;
}
.auth-button {
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 10px;
  color: #fff; background: var(--navy); cursor: pointer;
  font: inherit; font-weight: 700;
}
.auth-button:hover { background: var(--navy-deep); }
.auth-error { margin: 16px 0 0; color: var(--bad); font-size: 13px; }

/* ---------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: calc(100vh - 60px); }

/* ----------------------------------------------------------------- rail */

.rail {
  display: flex; flex-direction: column;
  height: calc(100vh - 60px); position: sticky; top: 60px;
  background: var(--card);
  border-right: 1px solid var(--rule);
}

.rail-head {
  display: grid; gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--rule);
}

.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--ink-3); pointer-events: none;
}
#search {
  width: 100%; height: 38px;
  padding: 0 12px 0 33px;
  font: inherit; font-size: 13.5px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 9px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
#search::placeholder { color: var(--ink-3); }
#search:hover { border-color: var(--rule-2); }
#search:focus { background: #fff; border-color: var(--mid); }
/* Chrome's own clear button is a grey blob against this tracking. */
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

/* One toggle, not four. The four readiness states are a fact about our wiring;
   a user has one question, "can I make this now". The note underneath says
   what turning it off will show. */
.ready-row { display: flex; }
.chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 36px; padding: 6px 12px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 9px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip:hover { color: var(--ink); background: #fff; }
.chip b { font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip-on {
  background: var(--navy); color: #fff; border-color: var(--navy);
  box-shadow: var(--shadow-1);
}
.chip-on:hover { background: var(--navy-ink); color: #fff; }
.chip-on b { color: rgba(255, 255, 255, 0.82); }
.ready-note {
  margin: -4px 2px 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-3);
}

/* Category and family sit side by side. Two facets, one row: they are both
   "narrow the rail", and stacking them would push the tags below the fold. */
.sel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.sel-row-one { grid-template-columns: 1fr; }
.sel-wrap { position: relative; min-width: 0; }
.sel-wrap svg {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-3); pointer-events: none;
}
#family-filter, #category-filter, #universe-filter, #slice-filter {
  width: 100%; height: 36px; padding: 0 28px 0 10px;
  font: inherit; font-size: 12.5px; color: var(--ink);
  background: #fff; border: 1px solid var(--rule); border-radius: 9px;
  -webkit-appearance: none; appearance: none; cursor: pointer;
  text-overflow: ellipsis;
  transition: border-color var(--t-fast) var(--ease);
}
#family-filter:hover, #category-filter:hover, #universe-filter:hover, #slice-filter:hover { border-color: var(--rule-2); }
#family-filter:focus, #category-filter:focus, #universe-filter:focus, #slice-filter:focus { border-color: var(--mid); }
/* The first control earns a stronger edge: it is where slice-first browsing starts. */
#slice-filter { border-color: #C9DAF0; background: var(--tint); font-weight: 500; color: var(--navy-ink); }

/* -------------------------------------------------------------- tag cloud */

.tag-block { display: grid; gap: 7px; }
.tag-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  letter-spacing: 0.5px; text-transform: uppercase;
}
#tag-clear {
  font: inherit; font-size: 11px; letter-spacing: 0.4px; cursor: pointer;
  color: var(--navy-ink); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
}
/* Bounded and scrollable. The full tag set is longer than the rail can show,
   and an unbounded cloud would push the preset list off the screen entirely. */
.tagcloud {
  display: flex; flex-wrap: wrap; gap: 5px;
  max-height: 104px; overflow-y: auto; overscroll-behavior: contain;
  padding: 2px 1px;
}
.tagcloud::-webkit-scrollbar { width: 8px; }
.tagcloud::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 4px; }
.tagchip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; font: inherit; font-size: 11.5px; cursor: pointer;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 999px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.tagchip:hover { background: #fff; border-color: var(--rule-2); color: var(--ink); }
.tagchip b { font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tag-on, .tag-on:hover {
  background: var(--navy); border-color: var(--navy); color: #fff;
}
.tag-on b { color: rgba(255, 255, 255, 0.75); }
.tag-on:focus-visible { outline-color: #FFFFFF; }

.rail-count {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12px; color: var(--ink-3); letter-spacing: 0.2px;
}
.rail-count b { color: var(--ink); font-weight: 700; }

/* ------------------------------------------------------------ preset list */

.preset-list {
  list-style: none; margin: 0; padding: 6px 8px 28px;
  overflow-y: auto; overscroll-behavior: contain; flex: 1;
}

/* Sticky category headings. The rail scrolls a few hundred rows; without a
   heading that travels with the scroll, "which market am I looking at" is
   unanswerable a screenful down. The negative margin cancels the list's own
   padding so the heading spans the rail and rows cannot scroll past its edges. */
.group-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 0 -8px 2px; padding: 9px 22px 6px;
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  letter-spacing: 0.6px; text-transform: uppercase;
  background: var(--card); border-bottom: 1px solid var(--rule);
}
.group-head b {
  font-weight: 500; font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.preset {
  position: relative; display: block; width: 100%; text-align: left;
  font: inherit; cursor: pointer;
  padding: 10px 12px 10px 14px; margin-bottom: 2px;
  color: inherit; background: none;
  border: 1px solid transparent; border-radius: 9px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
/* The accent bar rather than a border-left, so selecting a row does not shift
   the text 2px sideways. */
.preset::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--mid);
  opacity: 0; transform: scaleY(0.4);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.preset:hover { background: var(--surface); }
.preset:hover::before { opacity: 0.4; transform: scaleY(1); }
.preset-on { background: var(--tint); border-color: #C9DAF0; }
.preset-on::before { opacity: 1; transform: scaleY(1); }
.preset-on .preset-title { color: var(--navy-ink); font-weight: 500; }

.preset-title {
  font-size: 13.5px; font-weight: 400; color: var(--ink);
  line-height: 1.35;
  /* Two lines then ellipsis. 373 titles include some very long ones, and a
     row that wraps to four lines breaks the scan. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.preset-sub { display: flex; align-items: center; gap: 6px; margin-top: 5px; flex-wrap: wrap; }

.preset-flag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase;
}
.preset-flag::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none;
}
.flag-live { color: var(--good); }
.flag-partial { color: var(--teal-ink); }
.flag-needs-input { color: var(--warn); }
.flag-reference { color: var(--ink-3); }

.preset-fam {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  color: var(--navy-ink); background: var(--tint);
  padding: 1px 5px; border-radius: 4px; letter-spacing: 0.2px;
}
/* The overflow marker. Reads "… 36pp" next to the page count rather than a
   bare "+", which parsed as "plus 36 pages". */
.preset-more { background: var(--surface); color: var(--ink-3); padding: 0 5px; }

.preset-pages { font-size: 11.5px; color: var(--ink-3); font-family: var(--mono); }

/* Pinned decks: a second, quieter button on the row. Kept out of the row button
   because a button inside a button is not a thing. */
.preset-row { position: relative; }
.preset-row .preset { padding-right: 42px; }
.preset-pin {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 28px; height: 28px;
  color: var(--ink-3); background: transparent;
  border: 1px solid transparent; border-radius: 7px; cursor: pointer;
  opacity: 0; transition: opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.preset-pin svg { width: 15px; height: 15px; }
.preset-row:hover .preset-pin,
.preset-pin:focus-visible,
.preset-pin-on { opacity: 1; }
.preset-pin:hover { background: #fff; border-color: var(--rule); color: var(--navy-ink); }
.preset-pin-on { color: var(--navy-ink); }
.preset-pin-on svg { fill: currentColor; }
@media (hover: none) { .preset-pin { opacity: 1; } }

.rail-empty { padding: 22px 12px; color: var(--ink-3); font-size: 13px; text-align: center; }

/* The house-style specimen at the foot of the rail. Static by design: it is a
   reference, not a render, so it costs nothing and never waits on a source. */
.rail-style { border-top: 1px solid var(--rule); padding: 10px 16px 14px; }
.rail-style > summary {
  cursor: pointer; font-size: 11px; font-weight: 600; color: var(--ink-3);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.rail-style[open] > summary { margin-bottom: 10px; }
.style-specimen {
  padding: 12px; border: 1px solid var(--rule); border-radius: 10px; background: #fff;
}
.style-title { font-size: 13px; font-weight: 700; color: var(--navy-ink); line-height: 1.25; text-align: center; }
.style-sub { margin-top: 4px; font-size: 10px; color: var(--ink-3); text-align: center; }
.style-bars {
  display: flex; align-items: flex-end; gap: 5px; height: 46px; margin: 10px 0;
  padding: 0 6px; border-bottom: 1px solid var(--ink-3);
}
.style-bars i { flex: 1; background: var(--mid); border-radius: 2px 2px 0 0; }
.style-specimen p { margin: 4px 0 0; font-size: 9.5px; line-height: 1.4; color: var(--ink-3); }
.style-specimen b { color: var(--ink-2); font-weight: 700; }
.style-foot {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 8px; font-size: 9px; color: var(--ink-3);
}
.style-open { margin-top: 10px; font-size: 12px; }

/* ---------------------------------------------------------------- stage */

.stage { padding: 26px 30px 88px; min-width: 0; }

/* ---------------------------------------------------------- empty state */

.empty { max-width: 660px; margin: 7vh auto 0; text-align: center; }
.empty-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 150px; height: 100px; margin-bottom: 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #FFFFFF, #F7F9FC);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-1);
}
.empty-mark svg { width: 104px; height: 69px; }
.empty h1 { font-size: 25px; font-weight: 700; color: var(--navy-ink); margin: 0 0 12px; letter-spacing: -0.4px; }
.empty p { font-size: 14.5px; line-height: 1.65; color: var(--ink-2); margin: 0 auto 10px; max-width: 58ch; }
.empty-hint { font-size: 13.5px; color: var(--ink-3); }

/* Three doors into the library, so the first action does not require reading
   373 titles. Each one is a live preset, not a mock. */
.starters { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.starter {
  display: grid; gap: 3px; text-align: left; cursor: pointer;
  min-width: 172px; padding: 12px 14px;
  font: inherit; color: inherit;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.starter:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: #C9DAF0; }
.starter:active { transform: translateY(0); }
.starter b { font-size: 13px; font-weight: 600; color: var(--navy-ink); }
.starter span { font-size: 11.5px; color: var(--ink-3); }

.linkbtn {
  font: inherit; font-size: 13.5px; color: var(--navy-ink);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px; text-decoration-color: var(--rule-2);
}
.linkbtn:hover { text-decoration-color: var(--navy); }

/* ------------------------------------------------------------- deck head */

.deck-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; flex-wrap: wrap; margin-bottom: 18px;
}
.deck-title { min-width: 0; }
.deck-title h1 {
  font-size: 22px; font-weight: 700; color: var(--navy-ink);
  margin: 0 0 7px; letter-spacing: -0.35px; line-height: 1.22;
}
.deck-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); }
.deck-meta .sep { color: var(--rule-2); }
/* The markets a deck reads, so the rail's axis is visible on the deck too. */
.deck-universe { font-size: 12px; color: var(--teal-ink); }
.fam-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.deck-actions { display: flex; align-items: flex-end; gap: 12px; flex: none; }
.field { display: grid; gap: 5px; }
.field span {
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.field select {
  height: 38px; padding: 0 11px;
  font: inherit; font-size: 13px; color: var(--ink);
  background: #fff; border: 1px solid var(--rule); border-radius: 9px; cursor: pointer;
}
.field select:hover { border-color: var(--rule-2); }

.btnrow { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 15px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  color: #fff; background: var(--navy); border: 1px solid var(--navy);
  border-radius: 9px; box-shadow: var(--shadow-1);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:hover { background: var(--navy-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn-ghost { background: #fff; color: var(--navy-ink); border-color: var(--rule-2); }
.btn-ghost:hover { background: var(--tint); }

/* ----------------------------------------------------------------- params */

.params {
  display: grid; gap: 14px;
  margin: 0 0 18px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
}
.params[hidden] { display: none; }
.params-label {
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  letter-spacing: 0.5px; text-transform: uppercase; margin-right: 2px;
}
.param-group { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.param-group-head {
  flex: 0 0 100%; font-size: 10.5px; font-weight: 700; color: var(--ink-3);
  letter-spacing: 0.8px; text-transform: uppercase;
}
.param-more { padding-top: 2px; }
.param-more-toggle {
  justify-self: start; min-height: 28px; padding: 3px 10px;
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--navy-ink); background: none; border: 1px dashed var(--rule-2); border-radius: 999px;
}
.param-more-toggle:hover { background: var(--tint); border-style: solid; }

/* The collapsed door to the controls. Charts first; this is the second click. */
.adjust { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.adjust-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 13px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--navy-ink); background: var(--card);
  border: 1px solid var(--rule); border-radius: 999px;
}
.adjust-toggle:hover { border-color: var(--mid); background: var(--tint); }
.adjust-toggle svg { width: 15px; height: 15px; }
.adjust-toggle[aria-expanded="true"] { background: var(--tint); border-color: #C9DAF0; }
.adjust-count {
  padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--rule);
  font-size: 11.5px; font-weight: 400; color: var(--ink-3);
}

/* Menus: native <details>, so there is no positioning script and the keyboard
   already works. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15;
  display: none; min-width: 170px; padding: 6px;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: var(--shadow-2);
}
.menu[open] .menu-list { display: grid; gap: 3px; }
.menu-list button {
  width: 100%; text-align: left; padding: 8px 10px;
  font: inherit; font-size: 13px; color: var(--ink-2);
  background: none; border: 0; border-radius: 7px; cursor: pointer;
}
.menu-list button:hover { background: var(--tint); color: var(--navy-ink); }
.export-options .menu-list { min-width: 230px; padding: 12px; gap: 10px; }
.menu-caret { padding: 0 10px; min-width: 34px; justify-content: center; }
.dl-split { display: flex; gap: 6px; }

/* Tags behind a disclosure: the least-used facet should not hold prime space. */
.more-filters { border-top: 1px solid var(--rule); padding-top: 10px; }
.more-filters > summary {
  cursor: pointer; font-size: 11px; font-weight: 600; color: var(--ink-3);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.more-filters[open] > summary { margin-bottom: 8px; }
.more-filters #tag-count { color: var(--navy-ink); }
.param-chip {
  min-height: 30px; padding: 5px 12px;
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule); border-radius: 999px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.param-chip:hover { border-color: var(--mid); color: var(--navy-ink); }
.param-on { background: var(--mid); border-color: var(--mid); color: #fff; }
.param-on:hover { background: var(--navy); color: #fff; }
.param-chips { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* One parameter: its label, its control, and the unit when it has one. */
.param { display: inline-flex; align-items: center; gap: 7px; }

.param-input {
  min-height: 30px; padding: 4px 9px;
  font: inherit; font-size: 12px; color: var(--navy-ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  transition: border-color var(--t-fast) var(--ease);
}
.param-input:hover { border-color: var(--rule-2); }
.param-input:focus-visible { outline: 2px solid var(--mid); outline-offset: 1px; border-color: var(--mid); }
/* Wide enough for the value they hold — "2018-01-01" and a three-digit count —
   rather than for the longest thing anyone might type. */
.param input[type='date'] { width: 138px; }
.param input[type='number'] { width: 78px; }
.param-select { padding-right: 6px; max-width: 190px; }

.param-unit { font-size: 11px; color: var(--ink-3); }

/* What the probe measured. A thin slice is still offered — the chart is real,
   it is just small — so it is marked rather than removed. An empty one is
   removed from the offer, because a filter nothing answers is a chart of
   nothing, and the house does not draw those. */
.param-thin::after {
  content: '·'; margin-left: 4px; color: var(--warn); font-weight: 700;
}
.param-empty, .param-empty:hover {
  opacity: 0.5; cursor: not-allowed;
  color: var(--ink-3); border-color: var(--rule); background: var(--surface-2);
}
.param-chip.param-empty { text-decoration: line-through; }

/* The default a parameter would run with. Faint and unboxed, because it is a
   statement about what happens if you touch nothing, not a value that is set. */
.param-hint {
  font-size: 11px; font-weight: 400; color: var(--ink-3);
  text-transform: none; letter-spacing: 0;
}
.param-hint[hidden] { display: none; }

.param-reset {
  min-height: 30px; padding: 4px 11px; margin-left: auto;
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--ink-3); background: none; border: 1px solid transparent; border-radius: 999px;
}
.param-reset:hover { color: var(--navy-ink); background: var(--tint); }
.param-reset[hidden] { display: none; }

/* ----------------------------------------------------------------- notice */

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  margin: 0 0 18px; padding: 13px 15px;
  border-radius: var(--radius); font-size: 13.5px; line-height: 1.6;
  white-space: pre-wrap;
}
.notice svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.notice-warn { background: #FFF8EA; border: 1px solid #F0DDB4; color: #6B4A08; }
.notice-bad { background: #FEF1F0; border: 1px solid #F3CDCA; color: #7A2119; }
.notice-warn svg { color: var(--warn); }
.notice-bad svg { color: var(--bad); }

/* ---------------------------------------------------------------- routes */
/* A deck whose sources are missing is a route, not an error. */

.route-card {
  padding: 26px 28px; background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.route-kicker {
  margin: 0 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--warn);
}
.route-card h2 { margin: 0 0 8px; font-size: 20px; color: var(--navy-ink); }
.route-lead { margin: 0 0 16px; max-width: 70ch; color: var(--ink-2); line-height: 1.6; }
.route-missing { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.route-missing li {
  display: grid; grid-template-columns: 44px 190px 1fr; gap: 10px; align-items: baseline;
  padding: 10px 12px; background: var(--surface); border-radius: 9px;
  font-size: 12.5px; color: var(--ink-2);
}
.route-fam { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--navy-ink); }
.route-missing b { font-weight: 600; color: var(--ink); }
.route-label {
  margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--ink-3);
}
.route-suggest { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.route-hit {
  display: grid; gap: 4px; text-align: left; padding: 12px;
  font: inherit; cursor: pointer; background: #fff;
  border: 1px solid var(--rule); border-radius: 10px;
}
.route-hit:hover { border-color: var(--mid); background: var(--tint); }
.route-hit span { font-size: 13px; color: var(--ink); line-height: 1.35; }
.route-hit em { font-style: normal; font-size: 11px; color: var(--teal-ink); }
@media (max-width: 600px) {
  .route-missing li { grid-template-columns: 40px 1fr; }
  .route-missing li span:last-child { grid-column: 1 / -1; }
}

/* ----------------------------------------------------------------- charts */

.charts { display: grid; gap: 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--rule); border-radius: var(--radius-lg);
  /* Visible so the per-card download menu can leave the card. The corners are
     rounded on the first and last children instead. */
  overflow: visible; box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(180deg, #FFFFFF, #FCFDFE);
}
.card-id { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.card-fam {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: #fff; background: var(--navy);
  padding: 2px 6px; border-radius: 5px; flex: none; letter-spacing: 0.3px;
}
.card-title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.card-size {
  margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
/* The sentence the API has always sent and the card never showed. */
.card-read {
  margin: 0; padding: 9px 16px 0;
  font-size: 12.5px; line-height: 1.5; color: var(--ink-2);
}
.card-read b {
  margin-right: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--teal-ink);
}

.card-dl { display: flex; gap: 4px; flex: none; }
.dl {
  min-height: 30px; padding: 5px 11px;
  font: inherit; font-size: 11.5px; font-weight: 600; letter-spacing: 0.4px; cursor: pointer;
  color: var(--ink-3); background: #fff;
  border: 1px solid var(--rule); border-radius: 7px;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.dl:hover { color: var(--navy-ink); border-color: var(--mid); background: var(--tint); }

/* The chart sits on white with a hairline inside the card, so a light chart
   plate is still visibly a plate. */
.card-canvas { padding: 10px; background: #fff; }
.card-canvas:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-canvas svg {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--rule); border-radius: 6px;
}
.card-menu > summary { list-style: none; }
.card-menu > summary::-webkit-details-marker { display: none; }
.card-menu .menu-list { top: calc(100% + 4px); }

/* -------------------------------------------------------------- loading */

.loading { display: flex; align-items: center; gap: 11px; padding: 26px 4px; color: var(--ink-3); font-size: 14px; }
.spinner {
  width: 15px; height: 15px; flex: none; border-radius: 50%;
  border: 2px solid var(--rule-2); border-top-color: var(--navy);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeletons hold the layout the charts will occupy, so the stage does not jump
   when they arrive. */
.skeleton {
  height: 210px; border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  background: linear-gradient(100deg, #F4F6F9 30%, #FAFBFC 50%, #F4F6F9 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* --------------------------------------------------------------- motion */

/* Anyone who has asked their system for less motion gets none of the
   decorative kind — the spinner and the progress bar stay, because they are
   the only thing distinguishing "working" from "broken". */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .starter:hover { transform: none; }
  .skeleton { animation: none; background: var(--surface); }
}

/* ------------------------------------------------------------ scrollbars */

.preset-list::-webkit-scrollbar { width: 10px; }
.preset-list::-webkit-scrollbar-thumb {
  background: #D8E0EA; border-radius: 99px; border: 3px solid #fff;
}
.preset-list::-webkit-scrollbar-thumb:hover { background: #C2CDDC; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1080px) {
  :root { --rail-w: 320px; }
  .stage { padding: 22px 22px 72px; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; max-height: 48vh;
    border-right: 0; border-bottom: 1px solid var(--rule);
  }
  .stage { padding: 18px 16px 60px; }
  .empty { margin-top: 4vh; }
  .deck-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .card-canvas { padding: 6px; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-right { gap: 6px; }
  .hub-back { width: 58px; padding: 0 8px; font-size: 0; justify-content: center; }
  .hub-back::after { content: '← Hub'; font-size: 11px; }
  .auth-chip { max-width: 90px; }
  .pill { display: none; }
}
