/* Calibration page — layout and chart styles.
   Shares scenario_results.css for the sidebar-title / nav idiom; everything
   here is page-specific. Light mode only, matching the host applet. */

.calib-page {
  margin: 0;
  background: #f9f9f7;
  color: #0b0b0b;
  font-family: system-ui, sans-serif;
  font-size: 14px;
}

/* Series and scale roles (validated palette — see dataviz notes in LOG):
   modeled = blue, target = orange; diverging ASC wash blue↔red over a
   neutral midpoint; status colors reserved for flags, always icon+label. */
.calib-page {
  --series-modeled: #2a78d6;
  --series-target:  #eb6834;
  --div-pos: #2a78d6;
  --div-neg: #e34948;
  --div-mid: #f0efec;
  --status-warning: #fab219;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --hairline: #e1e0d9;
  --surface: #fcfcfb;
}

.calib-header {
  position: sticky; top: 0; z-index: 10;
  background: white; border-bottom: 1px solid #ddd;
}
.calib-header #panel-title { border-bottom: none; max-width: 1080px; margin: 0 auto; }
.calib-header .applet-nav { max-width: 280px; }

.calib-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px 24px 64px;
}
.calib-main h1 { font-size: 20px; font-weight: 700; margin: 8px 0 4px; }
.calib-main h2 { font-size: 15px; font-weight: 700; color: #0d3266; margin: 28px 0 6px; }
.calib-main h3 { font-size: 13px; font-weight: 600; color: #1a4a8a; margin: 14px 0 4px; }
.calib-intro, .calib-note { font-size: 12.5px; color: var(--ink-secondary); max-width: 72ch; }
.calib-loading { color: var(--ink-muted); font-size: 12px; }
.calib-unavailable { color: var(--ink-muted); font-size: 12px; font-style: italic; }

/* ---- Convergence ---- */
.conv-headline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.conv-pill {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.conv-pill.ok  { background: #e2f2e2; color: #006300; }
.conv-pill.bad { background: #fdf0d5; color: #7a5200; }
.conv-facts { font-size: 12.5px; color: var(--ink-secondary); }
.conv-spark { display: block; }
.conv-spark .spark-line { fill: none; stroke: var(--series-modeled); stroke-width: 2; }
.conv-spark .spark-tol  { stroke: var(--ink-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.conv-spark .spark-dot  { fill: var(--series-modeled); }
.conv-spark .spark-hit  { fill: transparent; cursor: default; }
.conv-spark text { font-size: 10px; fill: var(--ink-muted); }
details.conv-history { margin-top: 8px; font-size: 12px; }
details.conv-history summary { cursor: pointer; color: #1a4a8a; font-weight: 600; }

/* ---- Tables (ASC + iteration history) ---- */
.calib-table {
  border-collapse: collapse; margin-top: 8px; font-size: 12px;
  background: var(--surface);
}
.calib-table th, .calib-table td {
  border: 1px solid var(--hairline); padding: 4px 8px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.calib-table th { background: #f2f5fa; color: #1a4a8a; font-weight: 600; }
.calib-table td.rowhead, .calib-table th.rowhead { text-align: left; font-weight: 600; color: #333; }
.calib-table td.seghead {
  text-align: left; font-weight: 700; color: #0d3266; background: #f7f9fc;
  vertical-align: top;
}
.calib-table td.absent { color: #bbb; text-align: center; }
.calib-table td.anchor { color: var(--ink-muted); }
.asc-cell { position: relative; cursor: default; }
.asc-cell .asc-badges { font-size: 10px; margin-left: 3px; }
.asc-flag-icon { color: #7a5200; }
.asc-bundle-tag {
  font-size: 9.5px; font-weight: 700; color: #555;
  background: #eee; border-radius: 3px; padding: 0 3px; margin-left: 3px;
}
.asc-legend { font-size: 11.5px; color: var(--ink-secondary); margin-top: 6px; max-width: 80ch; }
.asc-legend .asc-bundle-tag { font-size: 9.5px; }

/* ---- Mode-share dumbbells ---- */
.share-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 10px;
}
@media (max-width: 900px) { .share-grid { grid-template-columns: 1fr; } }
.share-panel {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 8px 10px 10px;
}
.share-panel h3 { margin: 0 0 6px; }
.share-row { margin: 6px 0; }
.share-row .row-top { display: flex; align-items: center; gap: 8px; }
.share-row .mode-name { font-size: 11px; font-weight: 600; color: #333; flex: none; white-space: nowrap; }
.share-row .mode-asc { font-weight: 600; color: var(--ink-secondary); font-variant-numeric: tabular-nums; }
.share-row .row-top .share-track { flex: 1; min-width: 40px; }
.share-row .share-nums { display: block; font-size: 10.5px; color: var(--ink-secondary); margin-top: 1px; white-space: nowrap; }
.share-row .thin-badge { color: #7a5200; font-size: 10px; }
.share-track { display: block; }
.share-track .track-base { stroke: var(--hairline); stroke-width: 1; }
.share-track .db-conn { stroke: var(--ink-muted); stroke-width: 2; }
.share-track .db-target { fill: var(--series-target); }
.share-track .db-modeled { fill: var(--series-modeled); }
.chart-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--ink-secondary); margin: 8px 0 0; }
.chart-legend .swatch {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 5px; vertical-align: baseline;
}

/* ---- TLFD bars ---- */
.tlfd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 10px; }
@media (max-width: 900px) { .tlfd-grid { grid-template-columns: 1fr; } }
.tlfd-panel {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 8px 10px 4px;
}
.tlfd-panel h3 { margin: 0 0 4px; }
.tlfd-svg .bar-target { fill: var(--series-target); }
.tlfd-svg .bar-modeled { fill: var(--series-modeled); }
.tlfd-svg .axis-line { stroke: #c3c2b7; stroke-width: 1; }
.tlfd-svg .gridline { stroke: var(--hairline); stroke-width: 1; }
.tlfd-svg text { font-size: 9.5px; fill: var(--ink-muted); }
.tlfd-svg .lane-label { font-size: 8.5px; fill: var(--ink-muted); }
.tlfd-svg .bar-hit { fill: transparent; }
.tlfd-svg .band-excluded { opacity: 0.35; }
.tlfd-svg .band-excluded .bar-target,
.tlfd-svg .band-excluded .bar-modeled { fill: var(--ink-muted); }
.tlfd-svg .argmax-wash { fill: #fdf0d5; }
.tlfd-svg .resid-pos { stroke: var(--div-pos); stroke-width: 4; stroke-linecap: round; }
.tlfd-svg .resid-neg { stroke: var(--div-neg); stroke-width: 4; stroke-linecap: round; }
.tlfd-svg .k-stem { stroke: var(--ink-muted); stroke-width: 1.5; }
.tlfd-svg .k-pos { fill: var(--div-pos); }
.tlfd-svg .k-neg { fill: var(--div-neg); }
.tlfd-svg .k-anchor { fill: var(--surface); stroke: var(--ink-muted); stroke-width: 1.5; }
.tlfd-svg .k-lbl { font-size: 9px; fill: var(--ink-secondary); font-weight: 600; font-variant-numeric: tabular-nums; }
.tlfd-argmax-note { font-size: 10.5px; color: #7a5200; margin-top: 2px; }
.tlfd-svg .zc-tick { stroke: #52514e; stroke-width: 2; }
.chart-legend .swatch-tick { background: none; border-top: 2px solid #52514e; height: 0; width: 12px; border-radius: 0; vertical-align: middle; }
.tlfd-diag-note { font-size: 10.5px; color: var(--ink-secondary); font-weight: 600; margin-top: 2px; cursor: default; }

/* ---- Kink curves ---- */
.kink-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.kink-wrap .kink-svg { max-width: 360px; flex: 1 1 280px; }
.kink-svg .kink-identity { stroke: var(--ink-muted); stroke-width: 1; stroke-dasharray: 4 3; }
.kink-svg .kink-line { fill: none; stroke-width: 2; }
.kink-svg .kink-line.kink-walk, .kink-svg .kink-knee.kink-walk { stroke: var(--series-modeled); }
.kink-svg .kink-knee { fill: var(--surface); stroke-width: 2; }
.kink-svg .kink-line.kink-bicycle, .kink-svg .kink-knee.kink-bicycle { stroke: #1baf7a; }
.kink-svg text.kink-tag { font-size: 9.5px; fill: var(--ink-secondary); font-weight: 600; }
.kink-facts { font-size: 12px; color: var(--ink-secondary); flex: 1 1 260px; }
.kink-facts > div { margin: 4px 0; }
.kink-facts .kink-status { color: var(--ink-muted); font-size: 11px; }
.kink-swatch { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; }
.kink-swatch.kink-walk { background: var(--series-modeled); }
.kink-swatch.kink-bicycle { background: #1baf7a; }

/* ---- Tooltip ---- */
#calib-tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  background: rgba(20, 26, 36, 0.94); color: #fff;
  font-size: 11.5px; line-height: 1.45;
  padding: 6px 9px; border-radius: 5px; max-width: 320px;
}
#calib-tooltip .tt-title { font-weight: 700; }
#calib-tooltip .tt-muted { color: #b9c2d0; }
