@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

/* =====================================================================
   PatternDB - minimal data-tool design system
   Neutral zinc surfaces | calm-blue accent used sparingly | hairline rules.
   Accent is reserved for selection, key figures, and interaction - never
   for decoration. Data meaning (up/down, hit/miss) keeps its own colors.
   ===================================================================== */

:root {
  /* surfaces - warm editorial paper */
  --bg:          #fbfaf7;   /* page paper */
  --bg-soft:     #f6f4ef;   /* panels, sidebars */
  --bg-sunken:   #f1efe8;   /* table heads, wells, bar tracks */
  --bg-hover:    #f1efe8;   /* row / control hover */

  /* ink */
  --ink-1: #1a1b1e;         /* headlines / primary */
  --ink-2: #2b2d31;         /* body text */
  --ink-3: #83868f;         /* muted / mono labels */
  --ink-4: #a9abb2;         /* faint / placeholders */
  --ink-5: #cfcdc4;         /* hairline-on-content */

  /* rules - warm hairlines */
  --line:        #e7e4da;   /* default hairline border */
  --line-strong: #d8d4c8;   /* inputs, dividers */

  /* accent - editorial royal blue */
  --accent:        #1d4ed8;
  --accent-strong: #1a3fb0;
  --accent-wash:   rgba(29, 78, 216, 0.07);
  --accent-soft:   rgba(29, 78, 216, 0.18);

  /* data semantics (meaningful color - muted to the editorial palette) */
  --up:   #1f8f4e;
  --down: #c83a2f;
  --good: #1f7a44;
  --bad:  #b23423;
  --warn: #b8761f;

  /* type - Hanken Grotesk (display) + IBM Plex Mono (labels/figures) */
  --font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;

  /* shape & motion - editorial = crisp, minimal radius */
  --radius:    4px;
  --radius-lg: 6px;
  --shadow-pop: 0 12px 40px rgba(26, 27, 30, 0.13), 0 2px 8px rgba(26, 27, 30, 0.06);
  --tx: 140ms cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink-1);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

/* thin neutral scrollbars throughout */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-5) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-5);
  border-radius: 6px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ---- shared top navigation (injected by nav.js) ---- */
.topnav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.25rem;
  min-height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  font-size: 0.85rem;
}
.topnav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-1);
  text-decoration: none;
  letter-spacing: -0.01em;
  margin-right: 0.75rem;
}
.topnav .brand:hover { color: var(--ink-1); }
.topnav .brand svg { color: var(--accent); }
.topnav .navlinks { display: flex; gap: 0.15rem; flex-wrap: wrap; }
.topnav a.navlink {
  color: var(--ink-3);
  text-decoration: none;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius);
  font-weight: 500;
  transition: color var(--tx), background var(--tx);
}
.topnav a.navlink:hover { background: var(--bg-hover); color: var(--ink-1); }
.topnav a.navlink.active { color: var(--ink-1); font-weight: 600; border-radius: 0; box-shadow: inset 0 -2px 0 var(--accent); }
.topnav .nav-spacer { flex: 1; }
.topnav .nav-tag { color: var(--ink-3); font-size: 0.75rem; font-family: var(--mono); }

header {
  padding: 1.5rem 1.75rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.8rem; font-weight: 800; letter-spacing: -0.025em; color: var(--ink-1); }
header p  { margin: 0; color: var(--ink-3); font-size: 0.85rem; }
header a  { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
header a:hover { text-decoration: underline; }

footer {
  padding: 0.75rem 2rem;
  color: var(--ink-3);
  font-size: 0.8rem;
  text-align: center;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
footer code, code.k {
  background: var(--bg-hover);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.92em;
}

/* ---- landing ---- */
.landing-wrap { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }
.intro {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
  color: var(--ink-2);
  line-height: 1.6;
}
.intro p { margin: 0; }
.enc-pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--bg-hover);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.02rem 0.34rem;
  letter-spacing: 0.02em;
}
.card-static { cursor: default; }
.card-static:hover { border-color: var(--line); background: var(--bg); }
.landing {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 680px) { .landing { grid-template-columns: 1fr; } }
.card {
  display: block;
  padding: 1.35rem 1.4rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--tx), background var(--tx);
}
.card:hover {
  border-color: var(--accent-soft);
  background: var(--accent-wash);
}
.card h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.card:hover h2 { color: var(--accent-strong); }
.card p  { margin: 0; color: var(--ink-2); font-size: 0.9rem; line-height: 1.55; }
.card p + p { margin-top: 0.45rem; }
.card .meta {
  color: var(--ink-3);
  font-size: 0.74rem;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

/* ---- common app layout ---- */
/* App-shell pages fill the viewport below the sticky nav. Using a flex body
   (rather than pixel-subtracting the nav + optional <header>) keeps the fill
   correct whether or not a page has a header. The calc() is a fallback for
   engines without :has(). */
.app {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 52px);
}
body:has(> .app) { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body:has(> .app) > .app { height: auto; }
.controls {
  padding: 0.7rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
}
.controls label {
  font-size: 0.8rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.controls input, .controls select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink-1);
  font-size: 0.85rem;
  min-width: 160px;
  font-family: inherit;
  transition: border-color var(--tx), box-shadow var(--tx);
}
.controls input::placeholder { color: var(--ink-4); }
.controls input:focus, .controls select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.controls button {
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--tx), border-color var(--tx), color var(--tx);
}
.controls button:hover { background: var(--bg-hover); color: var(--ink-1); }
.controls .hint { color: var(--ink-3); font-size: 0.78rem; margin-left: auto; font-variant-numeric: tabular-nums; }

/* segmented control (encoder switch, view/ticker/horizon toggles) */
.tok-toggle {
  display: inline-flex;
  gap: 1.35rem;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 0.8rem;
  font-family: var(--mono);
}
.tok-toggle button {
  appearance: none;
  padding: 0.2rem 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  color: var(--ink-3);
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color var(--tx), border-color var(--tx);
}
.tok-toggle button:hover { color: var(--ink-1); }
.tok-toggle button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tok-toggle button:disabled { opacity: 0.35; cursor: default; }
.tok-toggle button:disabled:hover { color: var(--ink-3); }

/* ---- data.html (table view) ---- */
.stocks-split {
  display: grid;
  grid-template-columns: 1fr 340px;
  flex: 1;
  min-height: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
@media (max-width: 900px) { .stocks-split { grid-template-columns: 1fr; } }
.stocks-table-wrap {
  overflow: auto;
  min-height: 0;
}
.stocks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.stocks-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.85rem;
  font-weight: 500;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  user-select: none;
  z-index: 1;
}
.stocks-table thead th.num { text-align: right; }
.stocks-table thead th.sortable { cursor: pointer; }
.stocks-table thead th.sortable:hover { background: var(--bg-hover); color: var(--ink-1); }
.stocks-table thead th.sortable.active { color: var(--accent-strong); }
.stocks-table thead th.sortable.desc::after { content: " ↓"; font-size: 0.85em; }
.stocks-table thead th.sortable.asc::after  { content: " ↑"; font-size: 0.85em; }
.stocks-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--tx);
}
.stocks-table tbody tr:hover { background: var(--bg-hover); }
.stocks-table tbody tr.selected { background: var(--accent-wash); }
.stocks-table td {
  padding: 0.5rem 0.85rem;
  vertical-align: top;
}
.stocks-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--ink-2);
}
.stocks-table td.t-ticker {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-1);
}
.stocks-table td.partners {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.stocks-table td.partners .pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  background: var(--bg-hover);
  color: var(--ink-2);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
}
.stocks-table td.partners .pill em {
  color: var(--ink-4);
  font-style: normal;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}
.stocks-table td .muted { color: var(--ink-4); }

.stock-info {
  border-left: 1px solid var(--line);
  padding: 1rem 1.1rem;
  overflow: auto;
  background: var(--bg-soft);
  min-height: 0;
  font-size: 0.85rem;
}
.stock-info h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-family: var(--mono);
  letter-spacing: 0.03em;
  color: var(--ink-1);
}
.stock-info p.sub { margin: 0 0 0.85rem; color: var(--ink-3); font-size: 0.78rem; }
.stock-info .partner-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stock-info .partner-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  padding: 0.2rem 0.25rem;
  border-radius: var(--radius);
  transition: background var(--tx);
}
.stock-info .partner-row:hover { background: var(--bg-hover); }
.stock-info .partner-row .label {
  font-family: var(--mono);
  min-width: 60px;
  color: var(--ink-1);
}
.stock-info .partner-row .bar {
  flex: 1;
  height: 6px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}
.stock-info .partner-row .bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.stock-info .partner-row .w {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--ink-3);
  font-size: 0.76rem;
  min-width: 56px;
  text-align: right;
}

/* ---- sparkline (shape-based vocab) ---- */
.spark {
  vertical-align: middle;
  color: var(--ink-3);
  flex-shrink: 0;
}
.vocab-item .spark { color: var(--ink-2); }
.vocab-item.selected .spark { color: var(--accent); }

/* ---- predict.html ---- */
.small-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink-2);
  transition: background var(--tx), border-color var(--tx), color var(--tx);
}
.small-btn:hover { background: var(--bg-hover); color: var(--ink-1); }
.small-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.small-btn.active:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

.predict-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
@media (max-width: 900px) { .predict-split { grid-template-columns: 1fr; } }

.ctx-panel, .pred-panel {
  overflow: auto;
  padding: 1.1rem 1.35rem;
  min-height: 0;
}
.ctx-panel { border-right: 1px solid var(--line); background: var(--bg-soft); }

.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 0.85rem;
}
.section-header h3 { margin: 0; font-size: 0.95rem; font-weight: 600; color: var(--ink-1); }
.section-sub {
  font-size: 0.76rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

.ctx-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 50px;
  padding: 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.85rem;
}
.ctx-empty { color: var(--ink-4); font-size: 0.85rem; font-style: italic; padding: 0.2rem; }
.ctx-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.35rem 0.2rem 0.55rem;
  background: var(--accent-wash);
  color: var(--accent-strong);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.ctx-pill .cid { color: var(--ink-3); font-size: 0.72rem; }
.ctx-pill .ft-tok { font-weight: 600; }
.ctx-pill .ctx-x {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0 0.2rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.ctx-pill .ctx-x:hover { color: var(--accent-strong); }

.add-token {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.add-token input {
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--ink-1);
}
.add-token input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.vocab-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.palette-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--ink-1);
  transition: background var(--tx), border-color var(--tx);
}
.palette-chip:hover { background: var(--bg-hover); border-color: var(--accent-soft); }
.palette-chip.spark-chip .cid { color: var(--ink-3); font-size: 0.68rem; }

.preds {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.pred-row {
  display: grid;
  grid-template-columns: minmax(80px, 120px) 1fr 60px 70px;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.45rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background var(--tx);
}
.pred-row:hover { background: var(--bg-hover); }
.pred-row .p-label {
  font-family: var(--mono);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.pred-row .p-label .cid { color: var(--ink-3); font-size: 0.72rem; }
.pred-row .p-label .ft-tok { font-weight: 600; color: var(--ink-1); }
.pred-row .p-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}
.pred-row .p-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.pred-row .p-pct {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--ink-1);
  text-align: right;
  font-size: 0.82rem;
}
.pred-row .p-count {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--ink-4);
  font-size: 0.76rem;
  text-align: right;
}
.pred-row.chosen {
  background: var(--accent-wash);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ---- synthesis.html ---- */
.small-btn.primary { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.small-btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.small-btn.primary:disabled,
.small-btn:disabled { opacity: 0.5; cursor: default; }

.generate-chart-wrap {
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  height: 320px;
  position: relative;
}
#genChart {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  user-select: none;
}
.chart-hint {
  position: absolute;
  bottom: 6px;
  right: 12px;
  font-size: 0.7rem;
  color: var(--ink-4);
  font-family: var(--mono);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  pointer-events: none;
}
.pred-row.out-of-pool { opacity: 0.45; }
.pred-row.out-of-pool .p-fill { background: var(--ink-4); }
#genPredList { max-height: none; }

.generate-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}
@media (max-width: 900px) { .generate-split { grid-template-columns: 1fr; } }
.gen-preds, .gen-context {
  overflow: auto;
  padding: 1rem 1.1rem;
  min-height: 0;
}
.gen-preds { border-right: 1px solid var(--line); background: var(--bg-soft); }

/* ---- patterns.html ---- */
.transitions-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
}
@media (max-width: 900px) { .transitions-layout { grid-template-columns: 1fr; } }
.vocab-panel {
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.vocab-panel .vocab-search {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
}
.vocab-panel .vocab-search input {
  width: 100%;
  padding: 0.4rem 0.15rem;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink-1);
}
.vocab-panel .vocab-search input::placeholder { color: var(--ink-4); }
.vocab-panel .vocab-search input:focus { outline: none; border-bottom-color: var(--accent); box-shadow: none; }
.vocab-filters {
  padding: 0.55rem 0.85rem 0.6rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.len-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.len-chip {
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink-2);
  border-radius: 5px; padding: 0.12rem 0.45rem; font-size: 0.72rem; cursor: pointer;
  font-family: var(--mono);
  transition: background var(--tx), color var(--tx), border-color var(--tx);
}
.len-chip:hover { background: var(--bg-hover); color: var(--ink-1); }
.len-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mincount { font-size: 0.72rem; color: var(--ink-3); display: flex; align-items: center; gap: 0.4rem; }
.mincount input { width: 70px; padding: 0.18rem 0.4rem; border: 1px solid var(--line-strong); border-radius: 5px; font-family: var(--mono); color: var(--ink-1); }
.vocab-listinfo {
  padding: 0.45rem 0.85rem; font-size: 0.68rem; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
}
.curated-dot { color: var(--accent); margin-right: 0.35rem; font-size: 0.7rem; }
.pglyph { vertical-align: middle; color: var(--ink-2); }
.vocab-item .pg { display: inline-block; margin-right: 0.45rem; color: var(--ink-3); }
.vocab-item.selected .pg { color: var(--accent); }
.cmb-glyph { margin-left: auto; color: var(--ink-3); }
.vs-hdr .cmb-glyph { color: var(--accent); }
.cmb-ribbon { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 0.3rem; }
.cmb-sym {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; border-radius: 5px; color: #fff; font-weight: 700;
  font-family: var(--mono); font-size: 0.85rem;
}
.vocab-list {
  flex: 1;
  overflow: auto;
  padding: 0.4rem 0;
}
.vocab-item {
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.8rem;
  border-left: 2px solid transparent;
  transition: background var(--tx), border-color var(--tx);
}
.vocab-item:hover { background: var(--bg-hover); }
.vocab-item.selected { background: var(--accent-wash); border-left-color: var(--accent); }
.vocab-item .tok {
  font-family: var(--mono);
  color: var(--ink-1);
  word-break: break-all;
  letter-spacing: 0.03em;
  flex: 1;
}
.vocab-item .cnt {
  color: var(--ink-3);
  font-size: 0.72rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.trans-panel {
  overflow: auto;
  padding: 1.5rem 1.75rem;
  background: var(--bg-soft);
}
.context-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}
.context-bar .lbl { color: var(--ink-3); }
.context-bar .tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: var(--accent-wash);
  color: var(--accent-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.context-bar select {
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: inherit;
  color: var(--ink-1);
  background: var(--bg);
}
.empty-state {
  padding: 2.5rem 2rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--ink-3);
  font-size: 0.9rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.1rem 0;
  padding: 0.18rem 0;
}
.bar-row .label {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-1);
  letter-spacing: 0.02em;
  min-width: 160px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.bar-row .label:hover { color: var(--accent-strong); text-decoration: underline; }
.bar-row .bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 999px;
  flex: 1;
  max-width: 360px;
  position: relative;
}
.bar-row .bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.bar-row .pct {
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--ink-2);
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}

.section-title {
  font-size: 1.05rem;
  color: var(--ink-1);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 0.85rem;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}
.section-title .sub {
  color: var(--ink-4);
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  font-family: var(--mono);
}

.stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  font-size: 0.78rem;
  color: var(--ink-3);
}
.stats .chip {
  padding: 0.18rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ---- forecast.html ---- */
.fc-app { display: flex; flex-direction: column; gap: 0.85rem; padding: 1rem 1.75rem 2.5rem; }
.fc-legend { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 0.25rem; }
.fc-legitem {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.25rem 0.65rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); font-size: 0.78rem; color: var(--ink-2); cursor: pointer;
  transition: background var(--tx), border-color var(--tx);
}
.fc-legitem:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.fc-legitem.off { opacity: 0.4; text-decoration: line-through; }
.swatch { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.fc-chart-wrap {
  position: relative; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-lg); height: 420px;
}
#fcChart { width: 100%; height: 100%; display: block; }
.fc-table-wrap { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0.6rem 0.85rem 0.85rem; }
.fc-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.fc-table th {
  text-align: left; color: var(--ink-3); font-weight: 600; padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase;
}
.fc-table th.num, .fc-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.fc-table td { padding: 0.45rem 0.65rem; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.fc-table tbody tr:last-child td { border-bottom: none; }
.fc-table td .swatch { width: 14px; height: 4px; margin-right: 0.5rem; }
.fc-table tr.row-dl { background: rgba(220, 38, 38, 0.04); }
.fc-table td.good { color: var(--good); font-weight: 600; }
.fc-table .badge { font-size: 0.66rem; padding: 0.05rem 0.4rem; border-radius: 999px; font-weight: 600; font-family: var(--mono); }
.fc-table .badge.b-dl { background: var(--accent-wash); color: var(--accent-strong); }
.fc-table .badge.b-naive { background: rgba(22, 163, 74, 0.12); color: var(--good); }
.fc-note { color: var(--ink-3); font-size: 0.76rem; margin: 0.7rem 0 0; line-height: 1.5; }
.fc-note code { background: var(--bg-hover); padding: 0.05rem 0.3rem; border-radius: 4px; font-family: var(--mono); }
/* robustness view */
#viewRobust { display: flex; flex-direction: column; gap: 0.85rem; }
#viewRobust[hidden] { display: none; }   /* ID selector beats [hidden]; restore it */
.rb-summary { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.1rem; }
.rb-bigstat .n { font-size: 2.2rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; font-family: var(--font-sans); letter-spacing: -0.02em; }
.rb-bigstat { display: inline-block; margin-right: 0.5rem; }
.rb-sub { color: var(--ink-3); font-size: 0.8rem; }
.rb-canary { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--ink-2); }
.rb-canary code { background: var(--bg-hover); padding: 0.05rem 0.3rem; border-radius: 4px; font-family: var(--mono); }
.fc-table tr.row-oracle { background: var(--bg-sunken); color: var(--ink-3); }
.fc-table tr.row-naive { background: rgba(113, 113, 122, 0.06); }
.rb-dist-wrap { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.1rem 1.5rem; }
.rb-dist-title { font-size: 0.85rem; color: var(--ink-2); margin-bottom: 0.7rem; font-weight: 600; }
.rb-dist-title .sub { color: var(--ink-3); font-weight: 400; }
.rb-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.18rem 0; }
.rb-name { width: 130px; text-align: right; font-size: 0.76rem; color: var(--ink-2); font-family: var(--mono); flex: none; }
.rb-track { position: relative; flex: 1; height: 16px; background: var(--bg-sunken); border-radius: 4px; }
.rb-dot { position: absolute; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; opacity: 0.55; }
.rb-naive-line { position: absolute; top: 0; bottom: 0; width: 1.5px; background: var(--ink-1); opacity: 0.45; }
.rb-axis { position: relative; height: 1.1rem; margin-left: 140px; color: var(--ink-3); font-size: 0.7rem; font-family: var(--mono); }
.rb-axis span { position: absolute; }
.rb-axis span:first-child { left: 0; }
.rb-byh-wrap { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem 1.1rem; }
.rb-byh-wrap .rb-dist-title { margin-bottom: 0.7rem; }
.rb-wr { color: var(--ink-4); font-weight: 400; font-size: 0.72rem; font-family: var(--mono); }

/* ---- vocab-stats panel (top of transitions right pane) ---- */
.vocab-stats {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
.vs-hdr {
  font-size: 0.7rem;
  color: var(--ink-3);
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.vs-hdr .vs-tok {
  color: var(--ink-4);
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: none;
  font-family: var(--mono);
}
.vs-body {
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
  flex-wrap: wrap;
}
.vs-metric.vs-big {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.25rem 1.25rem 0.25rem 0;
  border-right: 1px solid var(--line);
  min-width: 120px;
}
.vs-metric .vs-val {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-sans);
  letter-spacing: -0.02em;
  line-height: 1;
}
.vs-metric .vs-lbl {
  font-size: 0.66rem;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.3rem;
}
.vs-len {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.vs-len-title {
  font-size: 0.66rem;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.vs-len-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}
.vs-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.1rem 0.5rem 0.1rem 0.9rem;
  background: none;
  border: none;
  border-left: 1px solid var(--line);
  border-radius: 0;
}
.vs-cell .vs-val-sm {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.vs-cell .vs-lbl-sm {
  font-size: 0.62rem;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}
.vs-context {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--ink-3);
}
.vs-context span { color: var(--ink-1); font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* ---- pattern occurrence cards (patterns.html) ---- */
.occ-scroll {
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.6rem;
}
.occ-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}
.occ-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  cursor: pointer;
  transition: border-color var(--tx), box-shadow var(--tx);
}
.occ-card:hover {
  border-color: var(--accent-soft);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.1);
}
.occ-card .occ-ticker {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.occ-card .occ-badge {
  display: inline-flex;
  align-items: center;
  padding: 0 0.4rem;
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--accent-strong);
  background: var(--accent-wash);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
svg.occ-spark {
  display: block;
  width: 100%;
  height: 60px;
  color: var(--accent);
}

/* ---- modal: interactive per-ticker chart ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: min(1200px, 100%);
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.modal-box.modal-box-wide {
  width: min(1500px, 100%);
}
.modal-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  min-height: 0;
}
.modal-chart-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.modal-tok-pane {
  border-left: 1px solid var(--line);
  background: var(--bg-soft);
  overflow: auto;
  padding: 0.9rem 1rem 1rem;
  min-height: 0;
  font-size: 0.82rem;
}
@media (max-width: 960px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-tok-pane { border-left: none; border-top: 1px solid var(--line); max-height: 40vh; }
}
.modal-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.modal-sub {
  color: var(--ink-3);
  font-size: 0.8rem;
  font-family: var(--mono);
}
.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-3);
  padding: 0 0.2rem;
  border-radius: var(--radius);
  transition: color var(--tx), background var(--tx);
}
.modal-close:hover { color: var(--ink-1); background: var(--bg-hover); }
.modal-chart-wrap {
  flex: 1;
  min-height: 360px;
  position: relative;
  background: var(--bg);
}
#occChart {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  user-select: none;
}
.modal-footer {
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-soft);
}

/* ---- tokenization pane (right side of modal) ---- */
.tok-pane-title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-1);
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.tok-pane-title .sub { color: var(--ink-3); font-size: 0.78rem; font-weight: 400; font-family: var(--mono); }
.tok-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.7rem;
  font-size: 0.74rem;
  color: var(--ink-2);
}
.tok-legend code {
  background: var(--bg-hover);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--mono);
}
.tok-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.tok-summary {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.tok-summary .sumchip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.tok-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.tok-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.32rem 0.45rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}
.tok-row.active { border-color: var(--warn); box-shadow: 0 0 0 1px #fef3c7 inset; }
.tok-row .tok-i { color: var(--ink-4); font-family: var(--mono); font-size: 0.7rem; }
.tok-row .tok-why { color: var(--ink-3); font-family: var(--mono); font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tok-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 0.4rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: #ffffff;
}
.tok-chip.tok-U { background: var(--up); }    /* fud up - green */
.tok-chip.tok-D { background: var(--down); }  /* fud down - red  */
.tok-chip.tok-F { background: var(--ink-4); } /* fud flat - gray */
.tok-chip.tok-a { background: #1e3a8a; }      /* sax: deep blue (lowest)  */
.tok-chip.tok-b { background: #3b82f6; }
.tok-chip.tok-c { background: var(--ink-4); } /* mid bucket - neutral */
.tok-chip.tok-d { background: #f59e0b; }
.tok-chip.tok-e { background: #b91c1c; }      /* sax: deep red (highest)  */

.tok-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  max-height: 110px;
  overflow-y: auto;
}
.tok-ribbon .tok-chip { min-width: 18px; height: 18px; font-size: 0.7rem; padding: 0 0.25rem; cursor: pointer; }
.tok-ribbon .tok-chip.active { outline: 2px solid var(--warn); outline-offset: 1px; }

.tok-shape-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.55rem;
}
.tok-shape-card.active { border-color: var(--warn); box-shadow: 0 0 0 1px #fef3c7 inset; }
.tok-shape-card .tsc-hdr {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--ink-2);
  margin-bottom: 0.3rem;
  font-variant-numeric: tabular-nums;
}
.tok-shape-card .tsc-hdr .cid {
  font-family: var(--mono);
  color: var(--ink-3);
}
.tok-shape-card .tsc-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.7rem;
  color: var(--ink-3);
  margin-top: 0.2rem;
}
.tok-shape-card svg {
  display: block;
  width: 100%;
  height: 36px;
}
.tok-shape-card svg.s-window { color: var(--accent); }
.tok-shape-card svg.s-centroid { color: var(--warn); }

/* ===== Symbolic Forecaster page ===== */
.sf-app { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.5rem 2.5rem; }
.sf-controls { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.sf-field { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--ink-3); }
.sf-field select, .sf-field input[type=range] { font-family: var(--mono); }
.sf-field select { padding: 0.28rem 0.45rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); color: var(--ink-1); }
.sf-field input[type=range] { width: 110px; accent-color: var(--accent); }
.sf-sep { flex: 0 0 1px; align-self: stretch; background: var(--line); margin: 0 0.2rem; }
.small-btn.sf-play { font-weight: 600; }
.small-btn.sf-play.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.sf-score { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }
.sf-stat { flex: 1 1 0; min-width: 120px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0.7rem 0.85rem; }
.sf-stat-n { font-size: 1.9rem; font-weight: 800; color: var(--ink-1); font-variant-numeric: tabular-nums; font-family: var(--font-sans); letter-spacing: -0.02em; line-height: 1.1; }
.sf-stat-n.big { color: var(--accent-strong); }
.sf-stat-n.good { color: var(--good); }
.sf-stat-n.bad { color: var(--bad); }
.sf-stat-l { font-size: 0.72rem; color: var(--ink-3); margin-top: 0.2rem; }

.sf-main { display: grid; grid-template-columns: 1.35fr 1fr; gap: 0.9rem; }
@media (max-width: 880px) { .sf-main { grid-template-columns: 1fr; } }
.sf-chart-card, .sf-decision-card, .sf-ribbon-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0.9rem 1.05rem; }
.sf-card-title { font-size: 0.74rem; font-weight: 600; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 0.6rem; }
.sf-card-title .sub { font-weight: 400; color: var(--ink-4); letter-spacing: 0; text-transform: none; font-family: var(--mono); }
.sf-chart-wrap { height: 240px; }
.sf-chart-wrap canvas { width: 100%; height: 100%; }
.sf-strip { position: relative; height: 12px; margin: 0.35rem 46px 0 46px; }
.sf-tick { position: absolute; top: 0; width: 2px; height: 12px; border-radius: 1px; }
.sf-tick.hit { background: var(--up); } .sf-tick.miss { background: var(--down); }

.sf-ctx-row { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.7rem; flex-wrap: wrap; }
.sf-ctx-label { font-size: 0.72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.sf-ctx { display: flex; gap: 0.25rem; }
.sf-chip { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; color: #fff; font-family: var(--mono); font-weight: 600; font-size: 0.85rem; opacity: 0.45; }
.sf-chip.matched { opacity: 1; box-shadow: 0 0 0 2px var(--accent-soft); }
.sf-empty { color: var(--ink-3); font-size: 0.8rem; font-style: italic; }
.sf-arrow { font-family: var(--mono); font-weight: 700; color: var(--ink-2); font-size: 1.05rem; }

.sf-dist { display: flex; flex-direction: column; gap: 0.32rem; }
.sf-bar { display: flex; align-items: center; gap: 0.5rem; position: relative; }
.sf-bar-sym { width: 22px; height: 22px; flex: none; border-radius: 5px; color: #fff; font-family: var(--mono); font-weight: 600; font-size: 0.8rem; display: flex; align-items: center; justify-content: center; }
.sf-bar-track { flex: 1; height: 16px; background: var(--bg-hover); border-radius: 4px; overflow: hidden; }
.sf-bar-fill { display: block; height: 100%; border-radius: 4px; opacity: 0.55; transition: width 0.15s ease; }
.sf-bar-pct { width: 38px; text-align: right; font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3); }
.sf-bar.pick .sf-bar-fill { opacity: 1; }
.sf-bar.pick .sf-bar-pct { color: var(--ink-1); font-weight: 600; }
.sf-bar.actual .sf-bar-track { box-shadow: 0 0 0 2px var(--ink-1); }
.sf-bar-tag { position: absolute; right: 46px; font-size: 0.62rem; color: var(--ink-1); background: var(--bg); padding: 0 3px; }

.sf-verdict { margin-top: 0.7rem; min-height: 1.6rem; display: flex; align-items: center; gap: 0.45rem; }
.sf-verdict b { font-family: var(--mono); font-size: 1.05rem; color: var(--ink-1); }
.sf-vlabel { font-size: 0.74rem; color: var(--ink-3); }
.sf-hit { color: var(--good); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.03em; }
.sf-miss { color: var(--bad); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.03em; }
.sf-pending { color: var(--ink-3); font-style: italic; font-size: 0.8rem; }
.sf-note { font-size: 0.74rem; color: var(--ink-3); margin: 0.6rem 0 0; }

.sf-ribbon-card { margin-top: 0.9rem; }
.sf-ribbon { display: flex; gap: 2px; overflow-x: auto; padding: 2px; }
.sf-cell { flex: none; width: 17px; height: 22px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 0.66rem; color: #fff; }
.sf-cell.hit { background: var(--up); } .sf-cell.miss { background: var(--down); }

/* ===== Encoder Playground (playground.html - scoped under body.pg so the
   card-style .controls etc. don't collide with the app-shell toolbar) ===== */
.pg main { max-width: 1100px; margin: 1.75rem auto; padding: 0 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.pg .controls, .pg .viz, .pg .output, .pg .patterns, .pg .empty {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.1rem 1.35rem;
}
.pg .controls { display: flex; flex-wrap: wrap; gap: 1rem 1.25rem; align-items: flex-end; }
.pg .field { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--ink-3); }
.pg .field span { font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.pg .field input[type="file"], .pg .field select {
  padding: 0.45rem 0.6rem; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--ink-1); font-size: 0.9rem; font-family: inherit; min-width: 220px;
}
.pg .field select:focus, .pg .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.pg button { cursor: pointer; background: var(--accent); color: #fff; border: 1px solid var(--accent); padding: 0.5rem 0.95rem; border-radius: var(--radius); font-size: 0.88rem; font-family: inherit; font-weight: 500; transition: background var(--tx), border-color var(--tx); }
.pg button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.pg button.small { padding: 0.32rem 0.65rem; font-size: 0.8rem; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line-strong); }
.pg button.small:hover { background: var(--bg-hover); color: var(--ink-1); }
.pg .hint { flex-basis: 100%; margin: 0.25rem 0 0; color: var(--ink-3); font-size: 0.82rem; }
.pg .viz { display: flex; flex-direction: column; gap: 0.9rem; }
.pg .chart-wrap { position: relative; height: 320px; }
.pg .mp-chart-wrap { height: 110px; margin-top: 0.25rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.pg .mp-label { font-size: 0.68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.2rem; font-family: var(--mono); }
.pg .heatmap-wrap { margin-top: 0.25rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
/* canvas wrapper is offset by JS (align()) to sit under the chart's plot area */
.pg .heatmap-canvas-wrap { box-sizing: content-box; }
.pg .heatmap-wrap canvas { width: 100%; height: 160px; display: block; image-rendering: pixelated; }
.pg .heatmap-legend { display: flex; align-items: center; gap: 0.5rem; font-size: 0.7rem; color: var(--ink-3); margin-top: 0.4rem; }
.pg .heatmap-legend .ramp { flex: 0 0 120px; height: 10px; border-radius: 2px; background: linear-gradient(to right, #1e3a8a, #3b82f6, #bfdbfe, #f9fafb); border: 1px solid var(--line); }
.pg .tok-params { display: inline-flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }
.pg .tok-params:empty { display: none; }
.pg .tok-params .param-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--ink-3); }
.pg .tok-params .param-field span { font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.pg .tok-params .param-field input { padding: 0.32rem 0.45rem; border: 1px solid var(--line-strong); border-radius: var(--radius); font-family: var(--mono); font-size: 0.85rem; width: 90px; color: var(--ink-1); }
.pg .ribbon-wrap { display: flex; align-items: center; gap: 0.6rem; }
.pg .ribbon-label { font-size: 0.68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--mono); flex-shrink: 0; }
.pg .ribbon { flex: 1; display: flex; height: 28px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--bg-hover); }
.pg .ribbon .seg { flex: 1; min-width: 0; font-size: 10px; color: #fff; text-align: center; line-height: 28px; font-weight: 600; font-family: var(--mono); white-space: nowrap; overflow: hidden; }
.pg .legend { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; font-size: 0.85rem; color: var(--ink-2); }
.pg .legend .item { display: inline-flex; align-items: center; gap: 0.4rem; }
.pg .legend .item strong { font-family: var(--mono); font-weight: 600; }
.pg .legend .swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.08); }
.pg .output-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.pg .output h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.pg .output pre { margin: 0; padding: 0.85rem; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 0.85rem; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.pg .empty { text-align: center; color: var(--ink-3); padding: 2.5rem 1rem; }
.pg .empty p { margin: 0; }
.pg .patterns h2 { margin: 0 0 0.85rem; font-size: 0.95rem; font-weight: 600; }
.pg .pattern-block { margin-top: 1rem; }
.pg .pattern-block:first-of-type { margin-top: 0; }
.pg .pattern-block h3 { margin: 0 0 0.5rem; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); }
.pg .pattern-block h3 .sub { font-weight: 400; color: var(--ink-4); margin-left: 0.4rem; font-size: 0.72rem; letter-spacing: 0; text-transform: none; }
.pg .runs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.pg .run-pill { display: inline-block; padding: 0.2rem 0.55rem; color: #fff; border-radius: 999px; font-size: 0.78rem; font-weight: 600; line-height: 1.2; font-family: var(--mono); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.pg .motifs { display: flex; flex-direction: column; gap: 0.6rem; }
.pg .motif-header { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-family: var(--mono); }
.pg .motif-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pg .motif-chip { display: inline-flex; align-items: center; gap: 0; padding: 0.15rem 0.45rem 0.15rem 0.15rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--mono); font-size: 0.8rem; }
.pg .motif-token { display: inline-block; min-width: 18px; padding: 0.05rem 0.3rem; margin-right: 2px; color: #fff; border-radius: 3px; text-align: center; font-weight: 600; font-size: 0.75rem; }
.pg .motif-token:last-of-type { margin-right: 6px; }
.pg .motif-count { color: var(--ink-3); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.pg .empty-msg { color: var(--ink-4); font-style: italic; font-size: 0.85rem; }
