/* Prumo public presentation. Shared identity with the editorial workspace;
   lightweight summaries, local interactive charts only on analytical pages.
   Type scale: the 22px root is deliberately smaller than the installed 28.05px
   reading release after the owner asked for a more compact, app-like surface.
   Functional labels stay at or above 16.5px and touch targets at or above 44px;
   fixed SVG and canvas chart labels keep their reviewed geometry. */

:root {
  --paper: #f6f4f1;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --muted: #524d48;
  --rule: #e2ded9;
  --rule-strong: #c9c3bc;
  --accent: #9b1c2e;
  --accent-hover: #7d1524;
  --accent-soft: #f7e7ea;
  --series-b: #c0392b;
  /* Compatibility name read by the pinned ECharts adapter, also used by SVG B. */
  --red: var(--series-b);
  --amber: #8a5a00;
  --green: #2e7d32;
  /* Bounded country groups: Carmim is the first series, these are the other five. */
  --chart-series-2: #2f5d8a;
  --chart-series-3: var(--amber);
  --chart-series-4: var(--green);
  --chart-series-5: #6b3fa0;
  --chart-series-6: #0b6b6b;
  --serif: "TeX Gyre Schola", ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --wrap: 1240px;
  --motion: 120ms;
  /* Reboot opts into smooth anchor scrolling. Native configuration/form focus
     must settle immediately rather than move controls during the next action. */
  scroll-behavior: auto;
}

* { box-sizing: border-box; }

html { font-size: 22px; }

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

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.08;
  margin: 0;
  overflow-wrap: anywhere;
}
h1 {
  font-size: clamp(1.65rem, 5.2vw, 2.35rem);
}
h2 { font-size: clamp(1.2rem, 3.4vw, 1.55rem); }
h3 { font-size: 1.05rem; }
/* Reboot also defines h4-h6. Evidence headings must stay below section titles. */
h4, h5, h6 { font-family: var(--sans); font-weight: 700; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
h4 { font-size: 1rem; }
h5 { font-size: 0.9rem; }
h6 { font-size: 0.8rem; }

p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
strong { font-weight: 700; }
code { font-family: var(--mono); font-size: 0.82em; word-break: break-all; }
img { max-width: 100%; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 14px 20px; font-weight: 600;
}
.skip-link:focus { left: 10px; top: 10px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* The shared site header, primary navigation, native disclosures, search and action
   roles live in app-shell.css. This file keeps page presentation and component styles. */

/* Hero and section rhythm -------------------------------------------------- */
.hero { padding: 48px 0 32px; max-width: 62rem; }
.hero h1 { max-width: 26ch; text-wrap: balance; }
.eyebrow {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600;
  color: var(--accent); margin-bottom: 12px; text-wrap: balance;
}
.lede { font-size: 1.05rem; color: var(--muted); max-width: 62ch; margin-top: 16px; line-height: 1.45; }
.meta { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0 16px; }
.freshness {
  display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--muted);
  margin: 0; font-variant-numeric: tabular-nums;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }

section { margin: 48px 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px 24px; flex-wrap: wrap; margin-bottom: 18px;
  border-bottom: 1px solid var(--rule); padding-bottom: 10px;
}
.section-note { color: var(--muted); font-size: 0.8rem; margin: 0; }
.note { color: var(--muted); font-size: 0.78rem; }

.page-head { padding: 32px 0 20px; max-width: 62rem; }
.page-head .meta { margin-top: 8px; }
.crumbs { font-size: 0.78rem; color: var(--muted); padding-top: 16px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }

/* Cards ------------------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  gap: 20px;
}
.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 20px;
  display: flex; flex-direction: column; min-width: 0;
  transition: border-color var(--motion) ease;
}
.card:hover { border-color: var(--rule-strong); }
.card:focus-within { border-color: var(--accent); }
.card-label {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0;
  color: var(--ink); margin: 0 0 10px; line-height: 1.3; min-height: 2.6em;
}
/* The authored title is the card's one series link; the only other action is the
   separately named notebook entry, never a second full-width destination button. */
.card-title-link {
  color: inherit; text-decoration: none; text-underline-offset: 3px;
}
.card-title-link:hover { color: var(--accent); text-decoration: underline; }
.cards-overflow {
  margin-top: 16px; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface);
}
.cards-overflow > summary {
  min-height: 44px; padding: 10px 16px; color: var(--accent); font-weight: 600;
  cursor: pointer;
}
.cards-overflow[open] > summary { border-bottom: 1px solid var(--rule); }
.cards-overflow .cards { padding: 16px; margin: 0; }
.card-value {
  font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05;
  font-variant-numeric: tabular-nums lining-nums; margin: 0; min-height: 2em;
  overflow-wrap: anywhere; word-break: normal;
}
/* Display decimals are bounded by the shared formatter. Large integer values can still
   wrap; their functional reading scale must not shrink to fit a card. */
.card-value--long { font-size: 1.9rem; letter-spacing: -0.02em; }
.card-unit {
  display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted);
  letter-spacing: 0; line-height: 1.25; margin-top: 4px;
}
.card-period { font-size: 0.75rem; color: var(--muted); margin: 6px 0 0; min-height: 1.4em; }
/* A slot that exists in every card, so chips and notes line up across the row. */
.card-tags { margin: 6px 0 0; min-height: 1.5em; }
.card-tags:empty, .calc-line:empty { min-height: 0; }
.card-spark { margin: auto 0 2px; min-height: 56px; padding-top: 10px; }
.spark { width: 100%; max-width: 220px; height: auto; display: block; }
.spark-line { fill: none; stroke: var(--ink); stroke-width: 1.8; }
.spark-end { fill: var(--accent); }
.calc-line { font-size: 0.8rem; margin: 8px 0 0; color: var(--ink); min-height: 2.6em; }
.calc-line .calc-badge { margin-left: 6px; }
.calc-period { color: var(--muted); }
.card-source {
  font-size: 0.75rem; color: var(--muted); margin: 12px 0 8px;
  border-top: 1px solid var(--rule); padding-top: 10px;
}
.card-link { font-size: 0.8rem; }
.card > .btn-link, .card-actions .btn-link { justify-content: flex-start; text-align: left; }
.card-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: auto 0 0; padding-top: 4px; }
.card-actions .card-link { margin: 0; }
.card-create { font-size: 0.8rem; font-weight: 600; }
.card-remove { font-size: 0.8rem; color: var(--muted); text-decoration-color: var(--rule-strong); }
.card-remove:hover { color: var(--accent); }

.badge {
  display: inline-block; border: 1px solid var(--accent); border-radius: 4px; color: var(--accent);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 6px; vertical-align: 1px; white-space: nowrap;
}
.badge-quiet { border-color: var(--rule-strong); color: var(--muted); }

/* Themes ------------------------------------------------------------------ */
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); gap: 16px; }
.theme-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 20px;
  text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 6px;
  min-width: 0; transition: border-color var(--motion) ease;
}
.theme-card:hover { border-color: var(--ink); color: var(--ink); }
.theme-title { font-family: var(--serif); font-size: 1.25rem; font-weight: 700; line-height: 1.15; }
.theme-blurb { color: var(--muted); font-size: 0.9rem; }
.theme-count { font-size: 0.75rem; color: var(--accent); margin-top: auto; padding-top: 8px; font-weight: 600; }

/* Steps and lists ---------------------------------------------------------- */
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px;
         padding-left: 20px; margin: 0 0 18px; }
.steps li { padding-right: 8px; }
.steps li::marker { color: var(--accent); font-family: var(--serif); font-size: 1.1rem; }
.sources-strip { font-size: 0.9rem; color: var(--ink); line-height: 1.55; }
.plain-list { padding-left: 20px; }
.plain-list li { margin-bottom: 6px; }
.cms-text { max-width: 68ch; }
.cms-link-list { margin: 0; padding-left: 20px; }
.cms-link-list li { margin-bottom: 10px; }
.cms-links > p { max-width: 68ch; }
.cms-unavailable { color: var(--muted); }

/* Tables ------------------------------------------------------------------ */
.data-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; }
.data-table th {
  text-align: left; font-size: 0.75rem; letter-spacing: 0; color: var(--muted);
  font-weight: 700; border-bottom: 2px solid var(--ink); padding: 8px 8px; vertical-align: bottom;
}
.data-table td { padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.data-table a { color: var(--ink); text-decoration-color: var(--rule-strong); }
.data-table a:hover { color: var(--accent); }
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Exact-value evidence sits inside a numeric cell but must wrap and read left to right. */
.original-value { margin-top: 4px; font-size: 0.72rem; color: var(--muted); white-space: normal; text-align: left; }
.original-value summary { cursor: pointer; }
.original-value .num { color: var(--ink); font-variant-numeric: tabular-nums; }
.orig-token { display: block; margin-top: 2px; }
.orig-token code { white-space: normal; }
.data-table .unit { color: var(--muted); font-size: 0.85em; }
.row-meta { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.flag {
  display: inline-block; margin-left: 6px; border: 1px solid #e3d3a8; color: var(--amber);
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 6px; vertical-align: 1px; white-space: nowrap;
}
.attribution { color: var(--muted); font-size: 0.8rem; }
.family { margin: 28px 0; }
.family h2 { font-size: 1.05rem; margin-bottom: 4px; }
.sources-table td { min-width: 8rem; }
.sources-table td:first-child { min-width: 10rem; }

/* Figure and chart --------------------------------------------------------- */
.figure-block {
  background: var(--surface); border-radius: 8px; border-left: 5px solid var(--accent); border-top: 1px solid var(--rule);
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: 22px 24px; margin: 12px 0 28px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); gap: 24px;
}
.figure-meta { margin: 0; border-left: 1px solid var(--rule); padding-left: 20px; font-size: 0.8rem; }
.figure-meta dt {
  font-size: 0.75rem; letter-spacing: 0; color: var(--muted); font-weight: 600;
  margin-top: 10px;
}
.figure-meta dt:first-child { margin-top: 0; }
.figure-meta dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.mini-label {
  display: block; font-size: 0.75rem; letter-spacing: 0; color: var(--muted);
  margin-bottom: 2px; font-weight: 600; text-transform: none;
}
.figure-value {
  font-size: clamp(2rem, 6.6vw, 2.7rem); font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums; line-height: 1.02; margin: 0;
  overflow-wrap: anywhere;
}
.figure-unit { font-size: 0.95rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.figure-period { margin: 8px 0 0; font-size: 0.9rem; }
.figure-source { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted); }

.chart-figure { margin: 10px 0 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--rule); stroke-width: 1.35; }
.chart-zero { stroke: var(--ink); stroke-opacity: .38; stroke-width: 1.7; }
/* SVG text is drawn in user units, so these values must scale with the plot margins in
   app/chart_model.py. At the rendered desktop width they remain above the 1.5x floor. */
.chart-tick { fill: var(--muted); font-family: var(--sans); font-size: 18.15px; font-variant-numeric: tabular-nums; }
.chart-axis-title { fill: var(--ink); font-family: var(--sans); font-size: 19.8px; font-weight: 600; }
.chart-line { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
.chart-point { fill: transparent; }
.chart-last { fill: var(--accent); }
.chart-last-label { fill: var(--accent); font-family: var(--sans); font-size: 19.8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted); font-style: italic; }
.chart-figure figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 10px; max-width: 78ch; }

/* Interactive enhancement. `.chart-wrap` contains only the server SVG and the canvas overlay
   sized to it; the comparison legend is a sibling so the overlay can never cover it. The SVG
   stays in flow and in the accessibility tree; the canvas is overlayed only after the adapter
   has successfully set its option. */
.chart-shell { display: block; }
.chart-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.chart-wrap { position: relative; }
.chart-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; pointer-events: none; touch-action: pan-y;
}
.chart-enhanced .chart { opacity: 0; pointer-events: none; }
.chart-enhanced .chart-canvas { opacity: 1; pointer-events: auto; }
.chart-controls {
  display: flex; align-items: center; gap: 12px; min-height: 48px; margin-top: 4px;
}
.chart-range { flex: 0 1 320px; min-width: 0; accent-color: var(--accent); min-height: 30px; }
.chart-readout {
  font-size: 0.9rem; font-variant-numeric: tabular-nums; color: var(--ink);
}
/* The tooltip is a DOM node (textContent only, never markup). ECharts writes
   `white-space: nowrap` inline for HTML tooltips; wrapping it here is what keeps a long
   value whole instead of letting the box run past the canvas edge. */
.chart-tooltip {
  white-space: normal !important;
  max-width: calc(100% - 32px);
}
.chart-hint { font-size: 0.78rem; color: var(--muted); margin: 0; }
.chart-empty + .chart-controls { min-height: 0; }
.windows { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.85rem; }
.windows .btn { min-height: 44px; padding: 8px 12px; font-size: 0.85rem; }
.windows .btn[aria-current="true"] {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 700;
}

.table-details { margin: 6px 0 0; }
.table-details summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; padding: 6px 0; }
.download { margin-top: 12px; font-size: 0.85rem; }

/* Filters ----------------------------------------------------------------- */
.filters {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: end;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 16px; margin: 16px 0 24px;
}
.filters label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.75rem; letter-spacing: 0; color: var(--muted); font-weight: 600;
}
.filters select, .filters input { min-width: 180px; }

/* Provenance --------------------------------------------------------------- */
.provenance { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 20px; }
.provenance-list {
  display: grid; grid-template-columns: minmax(10rem, max-content) 1fr;
  gap: 8px 20px; margin: 0;
}
.provenance-list dt {
  font-size: 0.75rem; letter-spacing: 0; color: var(--muted); font-weight: 600;
  padding-top: 3px;
}
.provenance-list dd { margin: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.formula { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 20px; }
.caveat {
  border-left: 4px solid #d9b45a; background: #fbf6e8; padding: 10px 12px;
  color: #5a4a00; font-size: 0.85rem; margin: 10px 0;
}
.derived-list { list-style: none; padding: 0; margin: 0; }
.derived-list li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.derived-list .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--muted); font-size: 0.8rem; }
.withheld-list { list-style: none; padding: 0; }
.withheld-list li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.withheld-note { display: block; color: var(--muted); font-size: 0.78rem; }

/* Pager, empty states, errors ---------------------------------------------- */
.app-pagination { margin: 24px 0 0; }
.empty-state { color: var(--muted); background: var(--surface); border: 1px dashed var(--rule-strong);
               padding: 20px; border-radius: 8px; }
.error-page { padding-top: 64px; }
.preview-banner { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px; padding: 14px 16px; margin: 16px 0; }

.detail-actions { margin: 16px 0 18px; }

/* Notebook ---------------------------------------------------------------- */
.notebook-search .filters { margin-top: 0; }
.notebook-search .filters label { flex: 1 1 320px; }
.notebook-batch { margin: 10px 0 0; }
.notebook-batch-bar {
  position: sticky; top: 0; z-index: 5; background: var(--paper);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  margin: 0 0 10px; padding: 10px 0; border-block: 1px solid var(--rule);
}
.notebook-batch-bar .selection-instruction { flex: 1 1 22rem; margin: 0; }
.notebook-batch-bar .selection-live {
  margin: 0; font-weight: 600; font-variant-numeric: tabular-nums;
}
.notebook-batch-bar .btn { width: auto; flex: 0 0 auto; }
.notebook-result-select {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; cursor: pointer;
}
.notebook-result-row.is-selected { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.notebook-batch-table .selection-cell { width: 1%; white-space: nowrap; }
.notebook-links { margin-top: 48px; }

/* Footer ------------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 56px; padding: 24px 0 32px; }
.footer-row { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.site-footer p { margin: 0; font-size: 0.78rem; color: var(--muted); max-width: 56ch; }
/* Links wrap between whole labels; a link itself never breaks mid-word. */
.footer-links { white-space: normal; }
.footer-links a { white-space: nowrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

/* Small screens ------------------------------------------------------------ */
@media (max-width: 1200px) {
  /* The metadata column keeps a 22rem maximum, so the value column would fall below its
     reviewed two-line width between 1101px and 1139px. Stack before that happens rather
     than shrink the value or its exact published token. */
  .figure-block { grid-template-columns: 1fr; gap: 20px; }
  .figure-meta { border-left: 0; border-top: 1px solid var(--rule); padding-left: 0; padding-top: 16px; }
}

@media (max-width: 1100px) {
  .cards, .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 1280px) {
  /* Exact values and large reading type need a local table scroller before tablet width. */
  .data-table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 900px) {
  /* Inline-only: .wrap also carries the masthead, whose block padding must survive
     this breakpoint. The shared app bar owns its own narrow composition. */
  .wrap { padding-inline: 20px; }
  .hero { padding: 40px 0 24px; }
  .figure-block { padding: 20px; }
  .figure-meta { padding-left: 0; }
}

@media (max-width: 760px) {
  .cards, .themes { grid-template-columns: 1fr; }
  .hero { padding: 32px 0 20px; }
  .hero h1 { max-width: 26ch; }
  section { margin: 40px 0; }
  .provenance-list { grid-template-columns: 1fr; gap: 3px 0; }
  .provenance-list dd { margin-bottom: 12px; }
  .footer-row { gap: 16px; }
  .footer-links { line-height: 1.9; }
  .data-table th, .data-table td { padding: 8px 6px; }
  .notebook-batch-bar { align-items: stretch; }
  .notebook-batch-bar .btn { width: 100%; }
  .sources-table td { min-width: 0; }
  .sources-table td:first-child { min-width: 0; }
  /* No JavaScript: the server SVG keeps a readable fixed label scale and the wrapper scrolls.
     Once the canvas adapter has painted, the same chart fits the viewport for full-width
     pointer and touch selection; the canvas labels are real CSS pixels, not scaled user units. */
  .chart-wrap { min-width: 660px; min-height: 264px; }
  .chart-enhanced .chart-wrap { min-width: 0; }
}

@media (max-width: 480px) {
  .wrap { padding-inline: 16px; }
  .filters { padding: 14px; }
  .filters label { flex: 1 1 100%; }
  .filters select, .filters input { min-width: 0; width: 100%; }
  .filters .btn { width: 100%; }
  .figure-block { padding: 16px; }
  .card { padding: 16px; }
  .notebook-chart-pair { grid-template-columns: 1fr; }
  .chart-controls { flex-wrap: wrap; gap: 8px 12px; }
  .chart-range, .chart-readout { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* --- two-series comparisons --------------------------------------------------------------- */
.compare-claim {
  font-family: var(--serif); font-size: 1rem; max-width: 62ch;
  margin: 0 0 24px; padding-left: 16px; border-left: 4px solid var(--rule-strong);
}
.compare-list { list-style: none; margin: 0; padding: 0; }
.compare-item { border-top: 1px solid var(--rule); padding: 20px 0; }
.compare-item:first-child { border-top: 0; }
.compare-link,
.country-link {
  font-family: var(--serif); font-size: 1.25rem; color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}
.compare-link:hover, .compare-link:focus,
.country-link:hover, .country-link:focus { border-bottom-color: var(--ink); }
.compare-mechanism { margin: 8px 0 4px; max-width: 62ch; color: var(--muted); }
/* A is solid ink and B is dashed brass in the SVG, canvas adapter and legend. */
.chart-line-a { stroke: var(--ink); }
.chart-line-b { stroke: var(--red); stroke-dasharray: 6 3; }
.chart-last-a { fill: var(--ink); }
.chart-last-b { fill: var(--red); }
/* Country groups: Portugal is Carmim; each other country keeps a distinct colour and dash. */
.chart-line-g0 { stroke: var(--accent); }
.chart-line-g1 { stroke: var(--chart-series-2); stroke-dasharray: 6 3; }
.chart-line-g2 { stroke: var(--chart-series-3); stroke-dasharray: 2 3; }
.chart-line-g3 { stroke: var(--chart-series-4); stroke-dasharray: 8 3 2 3; }
.chart-line-g4 { stroke: var(--chart-series-5); stroke-dasharray: 12 4; }
.chart-line-g5 { stroke: var(--chart-series-6); stroke-dasharray: 1 4; }
.chart-last-g0 { fill: var(--accent); }
.chart-last-g1 { fill: var(--chart-series-2); }
.chart-last-g2 { fill: var(--chart-series-3); }
.chart-last-g3 { fill: var(--chart-series-4); }
.chart-last-g4 { fill: var(--chart-series-5); }
.chart-last-g5 { fill: var(--chart-series-6); }
.chart-axis-label { fill: var(--muted); font-family: var(--sans); font-size: 18.15px; }
.legend {
  list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 12px 0 0;
  padding: 0; font-size: 0.85rem;
}
.legend li { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.legend-swatch { display: inline-block; width: 24px; height: 4px; flex: none; }
.swatch-a { background: var(--ink); }
.swatch-b { background: repeating-linear-gradient(90deg, var(--red) 0 6px, transparent 6px 10px); }
.swatch-g0 { background: var(--accent); }
.swatch-g1 { background: repeating-linear-gradient(90deg, var(--chart-series-2) 0 6px, transparent 6px 10px); }
.swatch-g2 { background: repeating-linear-gradient(90deg, var(--chart-series-3) 0 2px, transparent 2px 5px); }
.swatch-g3 {
  background: repeating-linear-gradient(90deg, var(--chart-series-4) 0 8px, transparent 8px 11px,
                                        var(--chart-series-4) 11px 13px, transparent 13px 16px);
}
.swatch-g4 { background: repeating-linear-gradient(90deg, var(--chart-series-5) 0 12px, transparent 12px 16px); }
.swatch-g5 { background: repeating-linear-gradient(90deg, var(--chart-series-6) 0 1px, transparent 1px 5px); }
.legend-value { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.legend-axis { color: var(--accent); font-size: 1em; font-weight: 600; letter-spacing: 0; }
.compare-provenance { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }

/* Multiseries notebook: the reader sees which group each side belongs to, in words. */
.notebook-axis-groups { margin: 10px 0 0; }
.notebook-axis-groups ul {
  list-style: none; display: grid; gap: 2px; margin: 4px 0 0; padding: 0;
}
.notebook-axis-groups li { font-size: 0.8rem; line-height: 1.35; }

/* Curated Portugal comparisons: three reviewed Caderno configurations. */
.portugal-comparisons { margin-top: 56px; }

/* Country groups: one shared scale, five short labels, a complete table. */
.country-comparisons { margin-top: 56px; }
.country-summary { margin: 0 0 36px; }
.country-summary-list {
  list-style: none; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  gap: 12px 26px; margin: 0; padding: 0;
}
.country-summary-list li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px;
  border-top: 1px solid var(--rule); padding-top: 12px;
}
.country-name { font-weight: 600; }
.country-value { font-variant-numeric: tabular-nums; }
.country-table-scroll { overflow-x: auto; }
.country-table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.table-caption {
  caption-side: top; text-align: left; color: var(--muted); font-size: 0.75rem;
  padding: 0 0 8px;
}
.country-provenance { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }

@media (max-width: 820px) {
  .compare-provenance { grid-template-columns: 1fr; }
  .country-provenance { grid-template-columns: 1fr; }
  /* The wrapper is the one labelled horizontal scroller; the page itself never overflows. */
  .country-table { display: table; width: 46rem; overflow: visible; white-space: normal; }
}

/* Analytical workspace rules live in workspace.css. */

/* Native daily window selection on analytical detail pages. */
.detail-workspace .chart-day-form {
  display: flex; flex-wrap: wrap; align-items: end; gap: 8px 16px; margin: 8px 0;
}
.chart-day-form label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.chart-day-form .form-select, .chart-day-form .btn {
  max-width: 100%;
}
.detail-workspace .analytical-caveats { margin: 16px 0; }
.analytical-options { margin: 12px 0; }
.analytical-options > summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; padding: 6px 0; }
.analytical-options-body { display: grid; gap: 12px; padding: 12px 0; }
@media print { .analytical-options { display: none; } }
/* Calculated labels must wrap instead of imposing a min-content grid wider than a phone. */
.notebook-workspace .figure-block > * { min-width: 0; }
.notebook-workspace .figure-block .badge { max-width: 100%; white-space: normal; }
@media print { .chart-day-form { display: none !important; } }

/* Published analytical documents share the wide plot, without composition controls. */
.authored-workspace .crumbs { margin-bottom: 8px; }
.authored-series-links {
  display: flex; flex-wrap: wrap; gap: 4px 16px;
  list-style: none; margin: 8px 0 10px; padding: 0; font-size: 0.75rem;
}
.authored-series-links li { min-width: 0; overflow-wrap: anywhere; }
.authored-chart .legend-axis { grid-column: 2; }
.authored-reading { margin: 12px 0; }
.authored-reading > summary { font-size: 0.8rem; font-weight: 600; }
.authored-note { white-space: pre-line; max-width: 78ch; }
@media print {
  .authored-reading::details-content { content-visibility: visible !important; display: block !important; }
  .authored-reading > *:not(summary) { display: block !important; }
  .authored-reading > summary { display: none; }
}
