:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-active: #1e293b;
  --border: #1f2937;
  --text: #e5e7eb;
  --text-soft: #d1d5db;
  --muted: #9ca3af;
  --dim: #6b7280;
  --accent: #6ea8fe;
  --accent-strong: #3b82f6;
  --scroll-thumb: #374151;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Dark thin scrollbars everywhere — table wraps, popovers, modals. */
* {
  scrollbar-color: var(--scroll-thumb) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* Exactly the viewport — never taller. Tables scroll inside their
     pane instead of growing the page. */
  height: 100dvh;
  line-height: 1.5;
  overflow: hidden;
}

/* Header */

/* Compact bar — the workspace owns the screen, so the header is just
   the brand mark + title, the updated stamp, and icon buttons. The
   old footer's attribution/meta copy lives in the ⓘ popover. */
header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  padding: 0.45rem 1rem;
}

header h1 {
  align-items: center;
  display: flex;
  font-size: 1.05rem;
  gap: 0.4rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* The favicon doubles as the brand mark — one file, both uses. */
header h1 svg {
  height: 1.1em;
  width: 1.1em;
}

/* The stamp leads the actions cluster — it hides on phones, and the
   auto margin on the group keeps the buttons right-aligned either
   way. */
.hdr-updated {
  color: var(--dim);
  font-size: 0.8rem;
  margin-right: 0.35rem;
  white-space: nowrap;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* Icon-only header buttons — tooltips/aria-labels carry the names. */
.hdr-btn {
  align-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dim);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 0.95rem;
  justify-content: center;
  padding: 0.25rem 0.6rem;
  text-decoration: none;
}

.hdr-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* Reset carries the accent — the one header action that changes state. */
.hdr-accent {
  color: var(--accent);
}

.hdr-accent:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* The info popover: pick-pop chrome, but anchored to the right edge
   under its ⓘ button and sized to its text lines. Two classes — the
   generic .pick-pop rules live later in this file, and left+right
   both set makes left win, hanging the panel off the viewport. */
.hdr-info .hdr-pop {
  color: var(--text-soft);
  font-size: 0.9rem;
  gap: 0.5rem;
  left: auto;
  line-height: 1.45;
  max-width: min(80vw, 20rem);
  min-width: 0;
  padding: 0.75rem 0.9rem;
  right: 0;
  width: max-content;
}

.hdr-pop a {
  color: var(--accent);
}

/* The popover's Updated copy only exists for phones — wider layouts
   show the stamp inline beside the buttons instead. */
.hdr-pop .pop-updated {
  display: none;
}

/* Layout: main is a column flex so the workspace fills the viewport
   under the header bar — panes scroll internally instead of the page
   scrolling through tables. */

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0.75rem 1rem;
}

/* Workspace: two panes split by a draggable divider */

#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Panes share the space by flex-grow ratio — workspace.js writes
   inline flex values from the divider position, and clears them on
   narrow screens where the stacked split is fixed at even halves.
   Panes are flat against the page background — no card chrome; the
   divider and the controls carry the separation. */
.pane {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0.75rem;
}

/* display:flex above would otherwise beat the UA [hidden] rule and
   keep a "hidden" pane visible while the other is maximized. */
.pane[hidden] {
  display: none;
}

/* The divider doubles as the gap between panes: a faint full-height
   track (::before) under a bordered grip handle (::after) — a raised
   pill with ridge lines so the drag affordance reads at a glance. */
.divider {
  cursor: col-resize;
  flex: 0 0 14px;
  position: relative;
}

.divider::before {
  background: var(--border);
  bottom: 0;
  content: '';
  left: 50%;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 1px;
}

/* Grip ridges are three vertical lines drawn with a repeating
   gradient inside the padded pill. */
.divider::after {
  background:
    repeating-linear-gradient(90deg,
      var(--dim) 0 2px, transparent 2px 6px)
    center / 16px 24px no-repeat,
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  content: '';
  height: 64px;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
}

.divider:hover::after,
.divider:active::after {
  background:
    repeating-linear-gradient(90deg,
      var(--accent-strong) 0 2px, transparent 2px 6px)
    center / 16px 24px no-repeat,
    var(--surface-active);
  border-color: var(--accent-strong);
}

.pane-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* The view picker never shrinks past readability — shrinking a flex
   item below its content needs an explicit min-width under its
   min-content floor, and 9rem keeps ~16 chars of the label visible.
   The floor also counts in the overflow measurement: if the head can't
   fit controls *and* a readable picker, controls move to the ⋯ pop. */
.pane-head > .chart-pick {
  min-width: 9rem;
}

.pane-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Chart canvases stretch to fill the pane body */
.pane-body .chart-pane {
  flex: 1;
  height: auto;
  min-height: 0;
  position: relative;
}

/* Tables scroll inside the pane; the sticky thead tracks the wrap's
   own scroll container. */
.pane-body > .table-wrap {
  flex: 1;
  margin-bottom: 0;
  min-height: 0;
  overflow: auto;
}

.pane > .pager {
  margin-top: 0.75rem;
}

.seg {
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
}

.seg[hidden] {
  display: none;
}

.seg-btn {
  background: var(--surface);
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface-active);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
  color: var(--text);
}

.seg-btn + .seg-btn {
  border-left: 1px solid var(--border);
}

.seg-btn:first-child {
  border-radius: 7px 0 0 7px;
}

.seg-btn:last-child {
  border-radius: 0 7px 7px 0;
}

.seg-btn:disabled {
  cursor: default;
  opacity: 0.4;
}

.pager {
  margin-left: auto;
}

.pager-select {
  background: var(--surface);
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 0.5rem;
}

.year-pager .pager-select {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--text);
}

.year-pager > button:not([hidden]) + .pager-select {
  border-left: 1px solid var(--border);
}

.year-pager > .pager-select:not(:last-child) {
  border-right: 1px solid var(--border);
}

.year-pager > .pager-select:only-child,
.year-pager > button[hidden] + .pager-select:last-child {
  border-radius: 7px;
}

.year-pager > button[hidden] + .pager-select:not(:last-child) {
  border-top-left-radius: 7px;
  border-bottom-left-radius: 7px;
}

.year-pager > .pager-select:last-child {
  border-top-right-radius: 7px;
  border-bottom-right-radius: 7px;
}

.year-pager .seg-btn {
  padding: 0.4rem 0.65rem;
}

.pager-total {
  align-self: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding-left: 0.4rem;
  padding-right: 0.5rem;
}

/* Tab buttons — used by the detail modals (the workspace's own tabs
   are gone; panes pick views from a dropdown instead). */

.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem 1.1rem;
}

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

.tab.active {
  background: var(--surface-active);
  border-color: var(--accent-strong);
  color: var(--text);
}

/* Pane-head controls */

/* Kind tag beside the view picker: the select's visible value is only
   the subject label, so two same-subject panes of different kinds
   would read identically without it. */
.pane-kind {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Per-view controls (year select, country picker, table search…) sit
   in a row inside the pane head and wrap under each other on narrow
   panes. */
.pane-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* applyScopeFilters hides controls via the hidden attr, but controls
   with their own display rule (e.g. .success-toggle) would defeat it. */
.pane-controls > [hidden] {
  display: none;
}

/* Table pane filter box — --bg reads as inset against the pane's
   --surface. */
.pane-filter {
  align-items: center;
  display: flex;
  gap: 0.6rem;
}

.pane-filter input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.4rem 0.9rem;
  width: min(220px, 32vw);
}

.pane-filter input:focus {
  border-color: var(--accent-strong);
  outline: none;
}

.pane-filter input::placeholder {
  color: var(--dim);
}

.pane-filter-count {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.pane-hint {
  color: var(--dim);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Tables */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 2rem;
}

.table-wrap thead th {
  background: var(--surface);
  position: sticky;
  top: 0;
}

.table-wrap tbody tr {
  cursor: pointer;
}

.table-wrap td[data-net] {
  white-space: nowrap;
}

.table-note {
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 0.8rem;
  padding: 0.6rem 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

th.sortable {
  cursor: pointer;
  white-space: nowrap;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable[data-dir="desc"]::after {
  content: ' ▼';
}

th.sortable[data-dir="asc"]::after {
  content: ' ▲';
}

tbody tr:hover {
  background: var(--surface);
}

/* Focused table rows are keyboard-openable (Enter/Space) */
tbody tr[data-set]:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.status {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
  background: var(--border);
  color: var(--muted);
}

.status-success, .status-payload-deployed { background: #14532d; color: #4ade80; }
.status-failure { background: #450a0a; color: #f87171; }
.status-partial-failure { background: #431407; color: #fb923c; }

/* Modal */

/* <dialog> UA styles are neutralized into a transparent full-viewport
   frame — the dim lives on ::backdrop, the card handles its own look.
   The top layer makes a z-index unnecessary. */
.modal {
  background: transparent;
  border: none;
  color: inherit;
  height: 100%;
  margin: 0;
  max-height: none;
  max-width: none;
  padding: 1rem;
  width: 100%;
}

/* display:flex only while open — a closed dialog must be display:none
   (the UA default), or it would block the page. */
.modal[open] {
  align-items: center;
  display: flex;
  justify-content: center;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 85vh;
  max-width: 640px;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
  width: 100%;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  position: absolute;
  right: 1rem;
  top: 0.9rem;
}

.modal-close:hover {
  color: var(--text);
}

.chart-pick {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
}

/* Pane export/maximize chips: bordered buttons so they read as
   controls. The export chip's auto margin pushes it and the maximize
   chip to the pane head's right edge. */
.pane-export,
.pane-focus {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.9rem;
  justify-content: center;
  line-height: 1;
  padding: 0.4rem 0.6rem;
}

.pane-export {
  margin-left: auto;
}

/* Maximize is the pane's main layout control — slightly larger than
   the export chip, and order-pinned to the head's right edge so it
   stays the rightmost chip whenever it isn't overflowed into the ⋯
   pop (the overflow restore already re-seats it tail-first). */
.pane-focus {
  font-size: 1.05rem;
  order: 10;
  padding: 0.35rem 0.7rem;
}

.pane-export:hover,
.pane-focus:hover {
  border-color: var(--accent-strong);
  color: var(--text);
}

/* A donut in a narrow pane is too tight for its figure+table row
   layout — stack it. workspace.js's ResizeObserver sets .narrow from
   the pane's real width, so this covers split panes, dragged splits,
   and phones alike. The figure gets a fixed share so the table still
   has room to scroll. */
.pane.narrow .donut-pane {
  flex-direction: column;
  gap: 0.5rem;
}

.pane.narrow .donut-figure {
  flex: 0 0 45%;
}

/* The ⋯ overflow button + popover — hidden until a control doesn't
   fit the head (retestOverflow in workspace.js moves them right-to-left
   into the pop). The wrapper hides via the hidden attr. */

/* The overflow popover: pick-pop chrome anchored to the button's right
   edge, column-stacking whatever controls didn't fit. Two classes to
   outrank the later .pick-pop rules — left+right both set would anchor
   it left, hanging it off the viewport. */
.pane-filters .overflow-pop {
  left: auto;
  /* The pick-pop height cap (min(480px, 75vh)) ignores how far down
     the screen the pop actually sits — vertical segs and overflowed
     buttons make it tall enough to run off the bottom of short
     landscape windows. Re-cap it to the viewport minus the header +
     pane-head allowance; overflow-y: auto scrolls the excess. */
  max-height: min(480px, calc(100dvh - 8rem));
  max-width: min(80vw, 22rem);
  min-width: 0;
  right: 0;
  width: max-content;
}

/* Inside the ⋯ pop the search box claims the full width: the row
   wraps, input+match-count share the first line, and the 'select a
   row' hint drops to its own. */
.pane-filters .overflow-pop .pane-filter {
  flex-wrap: wrap;
}

.pane-filters .overflow-pop .pane-filter input {
  flex: 1;
  min-width: 0;
  width: auto;
}

.pane-filters .overflow-pop .pane-hint {
  flex: 0 0 100%;
}

/* Segs can't share a phone-width panel horizontally — inside the ⋯
   pop they flip to a vertical list. The buttons become full-width
   rows, the left-border separators become top separators, and the
   corner radii move from the end buttons to the top/bottom ones. */
.pane-filters .overflow-pop .seg {
  flex-direction: column;
  width: 100%;
}

.pane-filters .overflow-pop .seg-btn {
  text-align: left;
  width: 100%;
}

.pane-filters .overflow-pop .seg-btn + .seg-btn {
  border-left: none;
  border-top: 1px solid var(--border);
}

.pane-filters .overflow-pop .seg-btn:first-child {
  border-radius: 7px 7px 0 0;
}

.pane-filters .overflow-pop .seg-btn:last-child {
  border-radius: 0 0 7px 7px;
}

/* Icon buttons that overflow into the ⋯ pop become full-width labeled
   rows — the ::after shows their aria-label, which setFocus/mountPane
   already keep current ('Maximize' ↔ 'Back to split view', etc.). */
.pane-filters .overflow-pop > .pane-export,
.pane-filters .overflow-pop > .pane-focus {
  gap: 0.5rem;
  justify-content: flex-start;
  margin-left: 0;
  padding: 0.4rem 0.6rem;
  width: 100%;
}

.pane-filters .overflow-pop > .pane-export::after,
.pane-filters .overflow-pop > .pane-focus::after {
  content: attr(aria-label);
  font-size: 0.8rem;
}

/* Checkbox pickers (country, rocket, entity): button summarizes the
   live selection and opens a checkbox popover below the pane head. */

.pick-filter {
  position: relative;
}

.pick-filter .chart-pick {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Accent outline while a selection is actually filtering the chart. */
.pick-filter.has-sel .chart-pick {
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}

.pick-pop {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 0.3rem;
  left: 0;
  /* The 75vh cap keeps the long pickers (rockets run 100+) inside
     short landscape windows. */
  max-height: min(480px, 75vh);
  min-width: 210px;
  overflow-y: auto;
  padding: 0.6rem 0.75rem;
  position: absolute;
  top: calc(100% + 4px);
  z-index: 5;
}

.pick-pop[hidden] {
  display: none;
}

.pick-pop-head {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.pick-reset {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
}

.pick-reset:hover {
  color: var(--text);
}

/* Popover filter box — --bg reads as inset against the popover's
   --surface. */
.pop-search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
}

.pop-search:focus {
  border-color: var(--accent-strong);
  outline: none;
}

.pop-search::placeholder {
  color: var(--dim);
}

.pick-row {
  align-items: center;
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  gap: 0.45rem;
  white-space: nowrap;
}

/* display:flex above would defeat the hidden attribute the popover
   filter box sets on non-matching rows. */
.pick-row[hidden] {
  display: none;
}

.pick-negate {
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 0.2rem;
  padding-bottom: 0.4rem;
}

/* Donut pane: figure on the left, scrollable percentage table beside
   it (the legend is off — the table is the legend). */

.donut-pane {
  align-items: stretch;
  display: flex;
  gap: 1rem;
}

.donut-figure {
  flex: 1 1 55%;
  min-height: 0;
  min-width: 0;
}

.donut-table-wrap {
  flex: 1 1 45%;
  min-height: 0;
  min-width: 160px;
  overflow-y: auto;
}

.donut-table {
  font-size: 0.85rem;
}

.donut-table th,
.donut-table td {
  padding: 0.3rem 0.5rem;
}

/* Count and share columns read better right-aligned */
.donut-table th:nth-child(2),
.donut-table td:nth-child(2),
.donut-table th:nth-child(3),
.donut-table td:nth-child(3) {
  text-align: right;
}

.donut-table tfoot td {
  color: var(--muted);
  font-weight: 600;
}

.donut-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Empty-state hint overlaid on the trend chart when no entity is
   selected — the pane would otherwise look like a broken empty plot. */
.chart-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
  pointer-events: none;
}

.chart-hint[hidden] {
  display: none;
}

/* 'Successes only' checkbox in the slot filters row */
.success-toggle {
  align-items: center;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.9rem;
  gap: 0.4rem;
  white-space: nowrap;
}

/* Keep long titles from running under the close button */
#modal-name,
#rocket-modal-name {
  padding-right: 2.5rem;
}

.modal-tabs {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  padding-bottom: 0.75rem;
}

.modal-pane h3 {
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
}

.modal-pane h3:first-child {
  margin-top: 0;
}

.modal-image {
  border-radius: 8px;
  margin: 0.75rem 0;
  max-height: 280px;
  object-fit: cover;
  width: 100%;
}

.modal-details {
  display: grid;
  font-size: 0.9rem;
  gap: 0.35rem 1rem;
  grid-template-columns: max-content 1fr;
  margin: 0.75rem 0;
}

.modal-details dt {
  color: var(--muted);
}

.modal-details dd {
  margin: 0;
}

#modal-desc {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.live-badge {
  color: #f87171;
  font-size: 0.85rem;
}

/* Modal entity sections */

.entity-desc {
  color: var(--text-soft);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  white-space: pre-line;
}

.entity-links {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.entity-links a,
.link-list a,
.update a {
  color: var(--accent);
}

.entity-list,
.link-list {
  font-size: 0.9rem;
  list-style: disc;
  padding-left: 1.25rem;
}

.link-list li,
.entity-list li {
  margin-bottom: 0.25rem;
}

/* Modal updates feed */

.update {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0;
}

.update:last-child {
  border-bottom: none;
}

.update p {
  font-size: 0.9rem;
  margin: 0.15rem 0;
}

.update-meta {
  color: var(--dim);
  font-size: 0.75rem;
}

.update-avatar {
  border-radius: 50%;
  height: 20px;
  margin-right: 0.4rem;
  vertical-align: middle;
  width: 20px;
}

.patch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.patch {
  border-radius: 8px;
  height: 72px;
}

.muted {
  color: var(--dim);
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  header {
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
  }

  header h1 {
    font-size: 0.95rem;
  }

  /* The stamp moves into the ⓘ popover at phone widths — inline copy
     hides, popover copy appears. */
  .hdr-updated {
    display: none;
  }

  .hdr-pop .pop-updated {
    display: block;
  }

  .hdr-btn {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
  }

  main {
    padding: 0.5rem 0.75rem;
  }

  /* Stacked split: fixed even halves, no divider drag. workspace.js
     clears the inline flex styles the desktop drag writes. */
  #workspace {
    flex-direction: column;
  }

  .divider {
    display: none;
  }

  /* The divider supplies the pane gap on desktop; the stacked layout
     needs its own. */
  .pane:last-child {
    margin-top: 0.5rem;
  }

  .pane {
    padding: 0.5rem;
  }

  /* Compact pane head on a phone: the picker claims the row's free
     space (down to its readable min-width floor, not below).
     > only: the country button is also a .chart-pick but must not
     grow */
  .pane-head > .chart-pick {
    flex: 1;
  }

  .pane-head {
    gap: 0.35rem;
    margin-bottom: 0.5rem;
  }

  .pane > .pager {
    margin-top: 0.5rem;
  }

  th, td {
    padding: 0.5rem;
  }

  /* All modals go truly full screen on small screens — no margins or
     rounded corners. dvh tracks the real viewport height as mobile
     browser chrome collapses and expands; min-height keeps even short
     detail modals edge-to-edge. */
  .modal {
    padding: 0;
  }

  .modal-card {
    border: none;
    border-radius: 0;
    max-height: 100dvh;
    min-height: 100dvh;
    padding: 1rem;
  }

  /* (Donut stacking is handled by .pane.narrow — real pane width, not
     the viewport breakpoint.) */

  /* Picker popovers stay inside the viewport */
  .pick-pop {
    max-width: 80vw;
  }

  /* Roomier touch targets on the picker rows */
  .pick-row {
    padding: 0.15rem 0;
  }

  .modal-tabs {
    flex-wrap: wrap;
  }

  .modal-image {
    max-height: 220px;
  }

  .modal-details {
    grid-template-columns: 1fr;
  }

  .modal-details dd {
    margin-bottom: 0.4rem;
  }
}
