/* ================================================================
   OPCG Tracker — editorial-financial dashboard aesthetic.
   Adapted from the Cuddlebles Ledger style.
   Palette: warm linen · brown-black ink · aged gold · forest · terracotta.
   Type: Fraunces (display), IBM Plex Sans (body), JetBrains Mono (numerals).
   ================================================================ */

:root {
  --paper: #f2ece0;
  --paper-tint: #ebe3d3;
  --surface: #fbf8f2;
  --surface-raised: #ffffff;
  --ink: #14110e;
  --ink-soft: #2c2723;
  --muted: #6a6358;
  --muted-strong: #4b453d;
  --hairline: #ddd3bf;
  --hairline-soft: #e6ddca;
  --rule: #c9bfa9;

  --gold: #b88a2f;
  --gold-soft: #efe1bd;
  --gold-ink: #6b4a0d;

  --forest: #1d5f4a;
  --forest-soft: #cfe0d7;
  --terracotta: #b64a2a;
  --terracotta-soft: #eed3c7;

  --accent: var(--forest);
  --accent-2: #7c5d2a;
  --growth: var(--forest);
  --decline: var(--terracotta);
  --decline-soft: var(--terracotta-soft);
  --growth-soft: var(--forest-soft);

  --display: "Fraunces", "New York", ui-serif, Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 6px;
  --radius-sm: 3px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 12% -10%, #f7f0df 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #eee4cd 0%, transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv01", "cv11";
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 56px 36px 96px;
}

/* ---------- Masthead ---------- */

.masthead {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding: 48px 0 28px;
  border-bottom: 1px solid var(--rule);
}

.masthead-rule {
  position: absolute;
  inset: 0 0 auto 0;
  height: 28px;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 5px,
    var(--hairline) 5px,
    var(--hairline) 6px
  );
  opacity: 0.55;
  pointer-events: none;
}

.masthead-brand { position: relative; max-width: 64ch; }

.eyebrow {
  margin: 0 0 14px;
  color: var(--gold-ink);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 600;
  font-family: var(--sans);
}

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-size: clamp(2.75rem, 6vw, 4.5rem);
  letter-spacing: -0.035em;
  font-weight: 500;
  line-height: 0.95;
  color: var(--ink);
}

.narrative {
  margin: 20px 0 0;
  font-family: var(--display);
  font-variation-settings: "opsz" 24, "SOFT" 50;
  font-weight: 350;
  font-size: 1.25rem;
  line-height: 1.42;
  color: var(--ink-soft);
  max-width: 62ch;
  letter-spacing: -0.005em;
}

.masthead-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 20px;
}

.masthead-meta {
  display: grid;
  grid-auto-flow: column;
  gap: 36px;
  margin: 0;
  padding: 0 0 4px;
}

.masthead-meta > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 1px solid var(--hairline);
  padding-left: 16px;
}

.masthead-meta dt {
  font-size: 0.64rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.masthead-meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* ---------- Tab bar ---------- */

.tab-bar {
  display: flex;
  gap: 0;
  margin: 32px 0 0;
  border-bottom: 1px solid var(--rule);
  padding: 0;
}

.tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 22px 12px;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- Tab panels ---------- */

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- Sections ---------- */

.sections {
  display: grid;
  gap: 44px;
  margin-top: 56px;
}

.panel {
  display: grid;
  gap: 18px;
  opacity: 0;
  transform: translateY(10px);
  animation: panel-in 0.55s var(--ease) forwards;
}

.panel:nth-child(1) { animation-delay: 60ms; }
.panel:nth-child(2) { animation-delay: 140ms; }
.panel:nth-child(3) { animation-delay: 210ms; }
.panel:nth-child(4) { animation-delay: 280ms; }
.panel:nth-child(5) { animation-delay: 340ms; }
.panel:nth-child(6) { animation-delay: 400ms; }

@keyframes panel-in {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { opacity: 1; transform: none; animation: none; }
}

.panel-header {
  display: grid;
  gap: 4px;
  max-width: 78ch;
}

.panel-header h2 {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: "opsz" 72, "SOFT" 50;
  font-size: 1.65rem;
  font-weight: 500;
  letter-spacing: -0.018em;
  color: var(--ink);
  line-height: 1.1;
}

.panel-subtitle {
  margin: 2px 0 0;
  color: var(--muted-strong);
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: 74ch;
}

/* ---------- Stat strip ---------- */

.stat-strip {
  display: grid;
  grid-template-columns: minmax(280px, 1.6fr) repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(20, 17, 14, 0.03),
    0 24px 40px -32px rgba(20, 17, 14, 0.18);
}

.stat-card {
  padding: 22px 24px;
  border-right: 1px solid var(--hairline-soft);
  border-bottom: 1px solid var(--hairline-soft);
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 8px;
  min-width: 0;
  position: relative;
}

.stat-card:last-child { border-right: none; }

.stat-card.is-hero {
  grid-row: span 2;
  grid-column: 1 / 2;
  padding: 28px 28px 24px;
  background:
    radial-gradient(80% 130% at 10% 0%, #fbf0d0 0%, transparent 55%),
    var(--surface-raised);
  border-right: 1px solid var(--rule);
}

.stat-card.is-hero .stat-label { color: var(--gold-ink); }

.stat-label {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.95rem;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.stat-card.is-hero .stat-value {
  font-family: var(--display);
  font-variation-settings: "opsz" 144, "SOFT" 50;
  font-weight: 400;
  font-size: clamp(3.2rem, 6.5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-top: 2px;
}

.stat-caption,
.stat-secondary {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.stat-secondary span {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.sparkline {
  width: 100%;
  height: 40px;
  display: block;
  margin-top: 8px;
}

.stat-card.is-hero .sparkline { height: 72px; margin-top: 14px; }

.sparkline-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-card.is-hero .sparkline-path { stroke: var(--gold); stroke-width: 2; }
.sparkline-fill { fill: var(--gold-soft); opacity: 0.7; }

/* ---------- Chart panels ---------- */

.chart {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 22px 22px 16px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(20, 17, 14, 0.03),
    0 24px 40px -32px rgba(20, 17, 14, 0.16);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.grid-line { stroke: var(--hairline-soft); stroke-width: 1; }

.series-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-area { opacity: 0.22; }

.axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.end-label {
  fill: var(--ink);
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.reference-line {
  stroke: var(--muted-strong);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.55;
}

.reference-label {
  fill: var(--muted-strong);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline-soft);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ---------- Bar classes ---------- */

.bar { rx: 2; }
.bar-growth  { fill: var(--growth); }
.bar-decline { fill: var(--decline); }
.bar-neutral { fill: var(--accent); opacity: 0.82; }
.bar-primary   { fill: var(--accent); }
.bar-secondary { fill: var(--accent-2); }
.bar-muted     { fill: var(--muted); }
.bar-highlight { fill: var(--gold); }

.delta-positive { color: var(--growth); }
.delta-negative { color: var(--decline); }
.delta-neutral  { color: var(--muted); }

/* ---------- Data table ---------- */

.data-table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
  text-align: right;
  white-space: nowrap;
}

.data-table .col-left {
  text-align: left;
  font-family: var(--sans);
  color: var(--ink);
  min-width: 140px;
  white-space: normal;
}

.data-table thead th {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--hairline);
  background: var(--surface);
  position: sticky;
  top: 0;
}

.data-table td {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.data-table tbody tr:hover { background: var(--paper-tint); }

/* ---------- Placeholder panels ---------- */

.panel-placeholder {
  border: 1px dashed var(--hairline);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  background: var(--surface);
}

.panel-placeholder p {
  margin: 0;
  line-height: 1.6;
}

/* ---------- Mode toggle ---------- */

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px;
  background: var(--paper-tint);
}

.mode-btn {
  appearance: none;
  background: transparent;
  border: none;
  padding: 6px 16px;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.mode-btn:hover { color: var(--ink); }

.mode-btn.is-active {
  background: var(--ink);
  color: #fbf0d0;
}

/* ---------- Tooltip ---------- */

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  min-width: 200px;
  max-width: 300px;
  padding: 12px 14px;
  background: var(--ink);
  color: #fbf0d0;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  box-shadow: 0 16px 36px rgba(20, 17, 14, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tooltip.is-visible { opacity: 1; }

.tooltip .tt-title {
  font-family: var(--display);
  font-variation-settings: "opsz" 18;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  margin-bottom: 8px;
  color: #fff8e1;
}

.tooltip .tt-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.tooltip .tt-row span:first-of-type {
  font-family: var(--sans);
  color: rgba(251, 240, 208, 0.7);
}

.tooltip .tt-row strong { font-weight: 600; }

.tt-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ---------- Footnotes ---------- */

.footnotes {
  margin-top: 72px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 48px;
}

.footnote-block h2 {
  margin: 0 0 16px;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-ink);
  font-weight: 600;
}

#definitions-list,
#box-definitions-list {
  margin: 0;
  display: grid;
  gap: 14px;
}

#definitions-list dt,
#box-definitions-list dt {
  font-family: var(--display);
  font-variation-settings: "opsz" 24;
  font-weight: 500;
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: -0.005em;
}

#definitions-list dd,
#box-definitions-list dd {
  margin: 3px 0 10px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.6;
}

#source-definitions {
  margin: 0;
  display: grid;
  gap: 12px;
}

#source-definitions dt {
  font-family: var(--display);
  font-variation-settings: "opsz" 24;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.95rem;
  letter-spacing: -0.005em;
}

#source-definitions dd {
  margin: 3px 0 8px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.6;
}

#caveats-list,
#box-caveats-list {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.6;
}

#caveats-list li,
#box-caveats-list li { margin-bottom: 10px; }

/* ---------- Card combobox ---------- */

.card-combo { position: relative; }

.card-combo-trigger {
  display: flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: text;
  transition: border-color 0.15s;
}

.card-combo.is-open .card-combo-trigger {
  border-color: var(--ink-soft);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.card-combo-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink);
  outline: none;
  min-width: 0;
  cursor: pointer;
}

.card-combo-input::placeholder { color: var(--muted); }

.card-combo-arrow {
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.75rem;
  pointer-events: none;
  transition: transform 0.18s;
  flex-shrink: 0;
}

.card-combo.is-open .card-combo-arrow { transform: rotate(180deg); }

.card-combo-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--ink-soft);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 12px 32px rgba(20, 17, 14, 0.16);
  max-height: 340px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-combo-list {
  overflow-y: auto;
  flex: 1;
}

.card-combo-item {
  display: grid;
  grid-template-columns: 20px 92px 1fr 40px;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 0.83rem;
  user-select: none;
  transition: background 0.07s;
}

.card-combo-item:last-child { border-bottom: none; }
.card-combo-item:hover { background: var(--paper-tint); }
.card-combo-item.is-checked { background: var(--gold-soft); }
.card-combo-item.is-checked:hover { background: #e6d29e; }

.card-combo-check {
  font-size: 0.82rem;
  color: var(--forest);
  font-weight: 700;
  text-align: center;
}

.card-combo-num {
  font-family: var(--mono);
  font-size: 0.77rem;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-combo-name {
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-combo-rarity {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
}

.card-combo-footer {
  padding: 6px 14px;
  background: var(--paper-tint);
  border-top: 1px solid var(--hairline-soft);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

/* Selected chips + clear button */

.card-selection-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.card-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 8px 4px 11px;
  font-size: 0.77rem;
  font-family: var(--sans);
  white-space: nowrap;
  color: #fbf0d0;
  line-height: 1.3;
}

.card-chip-remove {
  background: transparent;
  border: none;
  color: rgba(251, 240, 208, 0.65);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.1s;
}

.card-chip-remove:hover { color: #fbf0d0; }

.card-clear-all {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s;
}

.card-clear-all:hover { color: var(--ink); border-color: var(--ink); }

/* Chart note */

.card-chart-note {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .masthead { grid-template-columns: 1fr; align-items: start; gap: 24px; }
  .masthead-right { align-items: flex-start; }
  .masthead-meta { gap: 20px; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat-card.is-hero { grid-row: auto; grid-column: 1 / -1; border-right: none; }
}

@media (max-width: 760px) {
  .page { padding: 36px 20px 72px; }
  .tab-btn { padding: 10px 14px 12px; font-size: 0.78rem; }
  .masthead-meta { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .masthead-meta > div { border-left: none; padding-left: 0; border-top: 1px solid var(--hairline); padding-top: 10px; }
  .narrative { font-size: 1.1rem; }
  .stat-strip { grid-template-columns: 1fr; }
  .stat-card { border-right: none; }
  .panel-subtitle { font-size: 0.86rem; }
  .chart { padding: 16px 14px 12px; }
}

/* ---------- Coverage table (footer) ---------- */

.footnote-note {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 0.75rem;
}

.coverage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: var(--mono);
}

.coverage-table th {
  text-align: left;
  padding: 4px 10px 4px 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  white-space: nowrap;
}

.coverage-table td {
  padding: 4px 10px 4px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-2);
  white-space: nowrap;
}

.coverage-table td:nth-child(5),
.coverage-table td:nth-child(6),
.coverage-table td:nth-child(7) {
  text-align: center;
  color: var(--ink-1);
}

.footnotes .footnote-block:last-child {
  grid-column: 1 / -1;
}

/* ── Card tab: single-column footnote ───────────────────────────────────── */

.card-footnotes {
  grid-template-columns: 1fr;
}

.card-fn-wide {
  grid-column: 1 / -1;
}

/* Subheadings inside footnote sections */
.fn-subhead {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted-strong);
  letter-spacing: 0.04em;
  text-transform: none;
}

/* Scrollable table wrapper — prevents wide tables from breaking layout */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Priority chain chips */
.priority-chains {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0.5rem 0;
}

.pchain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 3px;
}

.pchain-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-ink);
  min-width: 2.4rem;
  margin-right: 4px;
}

.pchain-item {
  padding: 2px 9px;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted-strong);
  white-space: nowrap;
}

.pchain-top {
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 35%, var(--hairline));
  color: var(--ink);
  font-weight: 500;
}

.pchain-dim  { opacity: 0.65; }
.pchain-dimmer { opacity: 0.38; }

.pchain-arrow {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 1px;
}

/* Timeline blocks */
.timeline-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0.6rem 0;
}

.tblock {
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--hairline);
}

.tblock-now {
  border-color: color-mix(in srgb, var(--gold) 40%, var(--hairline));
  background: color-mix(in srgb, var(--gold) 6%, var(--surface));
}

.tblock-range {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold-ink);
  margin-bottom: 5px;
}

.tblock-body {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ── card footnote: retired source, reason list, stat strip, severe row ── */
.fn-retired dt { opacity: 0.6; }
.fn-retired dd { opacity: 0.6; }

.fn-reasons {
  margin: 0.35rem 0 0.6rem;
  padding-left: 1.1rem;
  line-height: 1.65;
}
.fn-reasons li { margin-bottom: 0.3rem; }

.fn-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 0.6rem;
}
.fn-stats > div {
  flex: 1 1 150px;
  border: 1px solid var(--rule, #ddd6c9);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  background: rgba(0, 0, 0, 0.015);
}
.fn-stat-v {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
}
.fn-stat-k {
  display: block;
  font-size: 0.72rem;
  color: #6a6358;
  margin-top: 0.2rem;
  line-height: 1.35;
}

#bidask-table td { font-size: 0.78rem; }
#bidask-table .row-severe { background: rgba(190, 60, 40, 0.07); }
#bidask-table a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ── Q&A toggle list (footnote) ──────────────────────────────────────────
   Price-source explanation as collapsed questions: a shareholder opens the
   two they care about instead of reading a wall of methodology. */
.fn-qa {
  margin: 0.75rem 0 0;
  border-top: 1px solid var(--rule, #e5ded2);
}

.fn-qa details {
  border-bottom: 1px solid var(--rule, #e5ded2);
}

.fn-qa summary {
  list-style: none;
  cursor: pointer;
  padding: 0.7rem 1.6rem 0.7rem 0;
  position: relative;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted-strong, #4a4337);
  transition: color 0.12s ease;
}

.fn-qa summary::-webkit-details-marker { display: none; }

.fn-qa summary:hover { color: var(--ink, #241f18); }

.fn-qa summary::after {
  content: "+";
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1;
  color: var(--muted, #8b8273);
}

.fn-qa details[open] > summary::after { content: "\2212"; }

.fn-qa details[open] > summary { color: var(--ink, #241f18); }

.fn-qa .qa-body {
  padding: 0 1.6rem 0.95rem 0;
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--muted-strong, #4a4337);
}

.fn-qa .qa-body > *:first-child { margin-top: 0; }
.fn-qa .qa-body > *:last-child { margin-bottom: 0; }
.fn-qa .qa-body p { margin: 0 0 0.6rem; }
.fn-qa .qa-body ul { margin: 0 0 0.6rem; padding-left: 1.1rem; }
.fn-qa .qa-body li { margin-bottom: 0.3rem; }
.fn-qa .qa-body table { font-size: 0.76rem; }

@media (prefers-reduced-motion: no-preference) {
  .fn-qa details[open] > .qa-body { animation: qa-in 0.16s ease-out; }
  @keyframes qa-in { from { opacity: 0; transform: translateY(-2px); } }
}

/* ── Box tab: timing verdict + set picker ───────────────────────────────── */
.timing-verdict {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid #2f6f8f;
  background: rgba(47, 111, 143, 0.05);
  border-radius: 0 4px 4px 0;
}

.timing-verdict .tv-lead {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink, #241f18);
}

.timing-verdict .tv-sub {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted-strong, #4a4337);
}

.mode-select {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.3rem 1.8rem 0.3rem 0.55rem;
  border: 1px solid var(--rule, #e5ded2);
  border-radius: 4px;
  background: #fff;
  color: var(--ink, #241f18);
  cursor: pointer;
}

.mode-select:focus-visible { outline: 2px solid #2f6f8f; outline-offset: 1px; }

/* ── Panel explainer: prose between a panel header and its chart ──────────
   Needs its own rule: the Q&A body styling is scoped to .fn-qa, so reusing
   that class out here left the paragraphs on browser-default 1em margins. */
.panel-explainer {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  line-height: 1.68;
  color: var(--muted-strong, #4a4337);
  max-width: 62rem;
}

.panel-explainer p { margin: 0 0 0.45rem; }
.panel-explainer p:last-child { margin-bottom: 0; }
.panel-explainer ul { margin: 0 0 0.45rem; padding-left: 1.15rem; }
.panel-explainer li { margin-bottom: 0.18rem; }


/* ── 持倉：市價來源標記 ───────────────────────────────────────────────── */
.mark-src {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  vertical-align: 1px;
}
.mark-tw { background: #e4ede2; color: #3f6b46; }
.mark-jp { background: #ece6dc; color: #7a6a52; }
.mark-missing { color: #9e8a72; font-style: italic; }
.row-unmarked td { background: #faf7f1; }
.th-sub {
  display: block;
  font-weight: 400;
  font-size: 0.72em;
  color: #6a6358;
  margin-top: 0.1rem;
}
