/* The compass block ("section 00") of the single merged page — loaded
   together with method.css, which owns the page shell (body, headers, TOC,
   methodology sections). This file owns everything inside #compass-app plus
   the compass overlays. The two files share the same :root tokens and have
   no overlapping class/id names; only #compass-app-scoped element rules
   belong here — never bare body/h1/canvas rules, they would leak into the
   methodology part. "Graphite" system. Colour budget goes to the
   data (dots, answer scale); the chrome is neutral graphite. Chart surface
   #212121 is a palette-validation input — do not change without
   re-validating the series palettes. */
:root {
  --bg: #101010;
  --surface: #161616;
  --surface-head: #191919;
  --surface-sunken: #131313;
  --chart: #212121;
  --control: #262626;
  --control-active: #3d3d3d;
  --rule-faint: #1f1f1f;
  --rule: #262626;
  --rule-strong: #333333;
  --border-control: #4a4a4a;
  --ink-hi: #f2f1ef;
  --ink: #e7e7e6;
  --ink-2: #b4b3b0;
  --ink-3: #8a8987;
  --ink-4: #6b6a68;
  --accent: #cbbfa8;
  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-text: system-ui, -apple-system, 'Segoe UI', Helvetica, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
  --r-sm: 3px;
  --r: 4px;
}

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

/* The compass block: centers its own children (controls, legend, chart);
   the page body/scroll belongs to method.css */
#compass-app {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.controls {
  display: flex;
  gap: 10px 28px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
#view-controls { margin-bottom: 10px; }

.ctrl-group {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.ctrl-name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
}

/* Buttons + segmented controls: neutral greys, no blue tint (Zapador 2026-07-30) */
.ctrl-btn {
  background: var(--control);
  color: var(--ink-2);
  border: 1px solid var(--border-control);
  border-radius: var(--r);
  padding: 6px 14px; /* modal buttons keep this; the controls row shrinks it */
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ctrl-btn:hover {
  background: var(--control-active);
  color: var(--ink);
}

/* Segmented control: real radio inputs, visually a two-option pill */
.seg {
  display: inline-flex;
  background: var(--control);
  border: 1px solid var(--border-control);
  border-radius: var(--r);
  overflow: hidden;
}
.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.seg label {
  padding: 1px 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg label:not(:first-of-type) { border-left: 1px solid var(--border-control); }
.seg label:hover { color: var(--ink-2); }
.seg input:checked + label {
  background: var(--control-active);
  color: var(--ink);
}
.seg input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* The View switcher keeps the original larger hit targets; every other
   segmented control and the controls-row buttons are ~10px smaller. */
#view-controls .seg label { padding: 5px 13px; }
.controls .ctrl-btn { padding: 1px 9px; }

/* ── Company legend ───────────────────────────────────────────────────── */
/* Two-row grid; buildLegend() sets the column template so every column has
   the same pitch, dictated by the longest company name (dots line up). */
#legend {
  display: grid;
  justify-content: center;
  gap: 4px 0;
  margin: 0 0 10px;
  font-size: 0.72rem;
  color: var(--ink-2);
  letter-spacing: 0.03em;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, color 0.15s;
}
.legend-item:hover { color: var(--ink); }
.legend-item.dim { opacity: 0.35; }
.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  flex-shrink: 0;
}

/* Square plot, sized so the compass section (header, controls, legend,
   chart) roughly fits the viewport on load: 100vh minus the chrome above +
   below, capped by the methodology content column it lives in
   (min(1240px, 100vw - 48px) wrap minus the 212px TOC + 56px gap). */
.chart-wrapper {
  position: relative;
  width: min(calc(min(1240px, 100vw - 48px) - 268px), calc(100vh - 388px));
  height: min(calc(min(1240px, 100vw - 48px) - 268px), calc(100vh - 388px));
}
/* Zoomed in: allow extra width (different x/y scale is fine — ticks stay);
   height keeps the square formula so vertical size is unchanged. The chart
   may grow past the 1240px wrap into the right page margin, up to the
   viewport edge — but must never reach left over the sticky TOC column,
   hence align-self: flex-start (the column's left edge) instead of the
   centered default. */
.chart-wrapper.zoomed {
  align-self: flex-start;
  width: min(1640px, calc(100vw - 24px - max(24px, (100vw - 1240px) / 2) - 268px));
}
/* Below 1100px method.css collapses the TOC sidebar into the top jump bar —
   the full wrap width is available again */
@media (max-width: 1100px) {
  .chart-wrapper {
    width: min(calc(100vw - 48px), calc(100vh - 388px));
    height: min(calc(100vw - 48px), calc(100vh - 388px));
  }
  .chart-wrapper.zoomed { width: calc(100vw - 48px); }
}

#hint {
  font-size: 0.7rem;
  color: var(--ink-4);
  letter-spacing: 0.03em;
  text-align: center;
  margin-bottom: 10px;
}

#compass-app canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  cursor: default;
}

.footnote {
  max-width: 620px;
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--ink-3);
  line-height: 1.6;
  text-align: center;
}
.footnote a {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(231, 231, 230, 0.3);
}
.footnote a:hover { text-decoration-color: var(--accent); }

/* ── Tooltip ──────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  display: none;
  background: #0d0d0d;
  border: 1px solid #3a3a3a;
  border-radius: var(--r);
  padding: 10px 14px;
  pointer-events: none;
  z-index: 100;
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}
#tooltip .tt-note {
  font-style: italic;
  max-width: 200px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #3a3a3a;
}
#tooltip .tt-block + .tt-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #2a2a2a;
}
#tooltip .tt-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-hi);
  margin-bottom: 6px;
  line-height: 1.3;
}
#tooltip .tt-row {
  font-size: 0.78rem;
  color: var(--ink-3);
  margin-top: 2px;
}
#tooltip .tt-val {
  color: var(--ink);
  font-weight: 600;
}

/* ── "Add yourself" modal ─────────────────────────────────────────────── */
#you-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#you-overlay.open { display: flex; }
#you-panel {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  padding: 22px 26px 24px;
  width: min(420px, 92vw);
  box-shadow: 0 16px 48px rgba(0,0,0,0.8);
}
#you-panel h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--ink-hi);
  margin-bottom: 6px;
}
.you-note {
  font-size: 0.75rem;
  color: var(--ink-3);
  line-height: 1.5;
  margin-bottom: 16px;
}
.you-note a {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(231, 231, 230, 0.3);
}
.you-note a:hover { text-decoration-color: var(--accent); }
#you-form label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-2);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
#you-form input[type="text"],
#you-form input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  background: var(--surface-sunken);
  border: 1px solid #3a3a3a;
  border-radius: var(--r);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 0.85rem;
}
#you-form input:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
#you-form .you-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  cursor: pointer;
}
#you-form .you-check input { accent-color: var(--accent); }
/* the display:flex above would otherwise defeat the hidden attribute */
#you-form .you-check[hidden] { display: none; }
.you-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ── Detail overlay ───────────────────────────────────────────────────── */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#overlay.open { display: flex; }

#overlay-panel {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  width: min(760px, 92vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.8);
  overflow: hidden;
}

#overlay-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid #2a2a2a;
  background: #1a1a1a;
  flex-shrink: 0;
  gap: 12px;
}

#overlay-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--ink-hi);
  line-height: 1.25;
}

#overlay-scores {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-4);
  margin-top: 5px;
  letter-spacing: 0.02em;
}
#overlay-scores span {
  color: var(--ink-2);
  font-weight: 600;
}

#overlay-close {
  background: var(--control);
  border: 1px solid #3a3a3a;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
#overlay-close:hover { background: var(--control-active); color: var(--ink); }

#overlay-body {
  overflow-y: auto;
  padding: 18px 22px 24px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
#overlay-body::-webkit-scrollbar       { width: 6px; }
#overlay-body::-webkit-scrollbar-track { background: transparent; }
#overlay-body::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }

.prop-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0 12px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule-faint);
}
.prop-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* Proposition numbers site-wide follow the upgraded .pv-num treatment:
   ~30% larger, bold, brighter grey (TODO 12, merged item 20). */
.prop-num {
  font-size: 0.91rem;
  font-weight: 700;
  color: var(--ink-3);
  padding-top: 0;
  text-align: right;
  letter-spacing: 0.04em;
}

.prop-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: #cfcecb;
  margin-bottom: 6px;
  line-height: 1.45;
}

/* Answer pills: the methodology page's graphite scale (Zapador 2026-08-01) —
   cool graphite = disagree, warm graphite = agree; strength adds the glyph
   −− − + ++ plus a stronger bg/border. The charts (consensus bars, Likert
   bars, grid cells) keep the red/blue diverging scale via POS_COLORS in
   app.js — that is the data palette; these pills are chrome. */
.prop-position {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  border: 1px solid;
  padding: 2px 8px;
  margin-bottom: 6px;
  white-space: nowrap;
}
.prop-position::before { min-width: 14px; text-align: center; flex: none; }
.pos-0 { border-color: #4b5a66; background: #28323b; color: #cfdde9; }
.pos-0::before { content: "−−"; letter-spacing: 0; }
.pos-1 { border-color: #3b464e; background: #20272c; color: #9aacb7; }
.pos-1::before { content: "−"; }
.pos-2 { border-color: #4c4234; background: #2a251d; color: #b29f7f; }
.pos-2::before { content: "+"; }
.pos-3 { border-color: #5e5138; background: #3a3122; color: #ebd5a7; }
.pos-3::before { content: "++"; letter-spacing: 0; }

.prop-reasoning {
  font-size: 1.0rem;
  color: var(--ink-3);
  line-height: 1.5;
  font-style: italic;
}

/* ── Prompt overlay content ───────────────────────────────────────────── */
.prompt-para {
  font-size: 0.9rem;
  color: #cfcecb;
  line-height: 1.55;
  margin-bottom: 14px;
}
.prompt-para.pre { white-space: pre-line; }
.prompt-options {
  margin: 0 0 14px 24px;
  font-size: 0.9rem;
  color: #cfcecb;
  line-height: 1.7;
}
.prompt-prop { margin-bottom: 0; padding-bottom: 12px; border-bottom: none; }
/* ════ Ported additions: views (Propositions, Grid, Rankings), overlay
   summary/compare, consensus bars — originally developed on /test ═════ */


.hidden { display: none !important; }


/* Like the zoomed chart: may run past the 1240px wrap into the right page
   margin but never left over the TOC column — so left-aligned, not centered */
.alt-view {
  align-self: flex-start;
  width: min(1200px, calc(100vw - 24px - max(24px, (100vw - 1240px) / 2) - 268px));
  margin-bottom: 8px;
}
@media (max-width: 1100px) {
  .alt-view { width: min(1200px, calc(100vw - 48px)); }
}
/* centered block, left-aligned text — matches the compass' centered chrome */
.view-intro {
  font-size: 0.78rem;
  color: var(--ink-3);
  line-height: 1.5;
  margin: 0 auto 18px;
  max-width: 760px;
}

/* ── Overlay: summary strip ───────────────────────────────────────────── */
#overlay-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#compareWrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* the display rules above would defeat the hidden attribute */
#compareWrap[hidden], #overlay-summary[hidden] { display: none; }
#compareSel {
  background: var(--control);
  border: 1px solid var(--border-control);
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 0.78rem;
  padding: 4px 6px;
  max-width: 190px;
}

#overlay-summary {
  padding: 10px 22px 12px;
  border-bottom: 1px solid #242424;
  background: #141414;
  flex-shrink: 0;
}
.sum-line {
  font-size: 0.78rem;
  color: var(--ink-3);
  line-height: 1.6;
}
.sum-line + .sum-line { margin-top: 2px; }
.sum-val { color: var(--ink); font-weight: 600; }
.sum-link {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(231, 231, 230, 0.3);
  cursor: pointer;
}
.sum-link:hover { text-decoration-color: var(--accent); }

/* ── Overlay: badge row with consensus bar + unusual chip ─────────────── */
.prop-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 6px;
}
.prop-meta .prop-position { margin-bottom: 0; }

.cons-bar {
  display: inline-flex;
  width: 140px;
  height: 10px;
  gap: 2px;
  border-radius: 2px;
  flex-shrink: 0;
}
.cons-seg {
  min-width: 3px;
  border-radius: 2px;
}
.cons-seg.own {
  outline: 1.5px solid var(--ink-hi);
  outline-offset: 1px;
}

.unusual-chip {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f0b429;
  border: 1px solid #6b5416;
  background: #211b0e;
  border-radius: 4px;
  padding: 2px 8px;
}

.prop-item.flash { animation: prop-flash 1.6s ease-out; }
@keyframes prop-flash {
  0%   { background: #2f2f2f; }
  100% { background: transparent; }
}

/* ── Overlay: compare mode ────────────────────────────────────────────── */
.cmp-section {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 4px 0 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.prop-item + .cmp-section { margin-top: 24px; }
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 4px;
}
.cmp-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.cmp-cell .prop-reasoning { font-size: 0.85rem; margin-top: 4px; }
@media (max-width: 620px) {
  .cmp-grid { grid-template-columns: 1fr; }
}

/* ── Propositions view ────────────────────────────────────────────────── */
.pv-section {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 26px 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.pv-section:first-child { margin-top: 0; }

.pv-row {
  border-bottom: 1px solid var(--rule-faint);
  padding: 9px 0;
}
.pv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.pv-head:hover .pv-text { color: var(--ink); }
/* view-local controls sit centered, like the compass controls row */
.pv-ctrl {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.pv-num {
  flex: 0 0 32px;
  text-align: right;
  font-size: 0.91rem;
  font-weight: 700;
  color: var(--ink-3);
}
.pv-text {
  flex: 1 1 auto;
  font-size: 0.85rem;
  color: #cfcecb;
  line-height: 1.4;
}
.pv-pct {
  flex: 0 0 34px;
  font-size: 0.7rem;
  color: var(--ink-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pv-pct:last-child { text-align: left; }
.pv-bar {
  flex: 0 0 240px;
  height: 12px;
  display: flex;
  background: #191919;
  border-radius: 2px;
  overflow: hidden;
}
.pv-arm {
  width: 50%;
  display: flex;
  gap: 2px;
}
.pv-arm-l { justify-content: flex-end; border-right: 1px solid #4a4a4a; }
.pv-arm-l > span:first-child { border-radius: 2px 0 0 2px; }
.pv-arm-r > span:last-child  { border-radius: 0 2px 2px 0; }

.pv-detail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 14px 0 8px 44px;
}
/* display:grid above would defeat the hidden attribute (collapse) */
.pv-detail[hidden] { display: none; }
.pv-col-head {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 7px;
}
.pv-model {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.7;
}
.pv-model:hover { color: var(--ink); }
/* company grouping: one row per company, dots in the answer columns its
   models occupy, joined by a line in the company color */
.pv-companies { padding: 14px 0 10px 44px; }
.pv-cmp-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0 12px;
  align-items: center;
  min-height: 26px;
}
.pv-cmp-headrow { min-height: 20px; margin-bottom: 2px; }
.pv-cmp-name {
  font-size: 0.74rem;
  color: var(--ink-2);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pv-cmp-track {
  position: relative;
  height: 26px;
}
.pv-cmp-headrow .pv-cmp-track { height: 20px; }
.pv-sep {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(255,255,255,0.05);
}
.pv-sep-mid { border-left-color: rgba(255,255,255,0.16); }
.pv-cmp-collabel {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pv-cmp-line {
  position: absolute;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  border-radius: 2px;
  opacity: 0.45;
}
.pv-cmp-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  font-size: 0.62rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
@media (max-width: 720px) {
  .pv-head { flex-wrap: wrap; }
  .pv-text { flex-basis: calc(100% - 44px); }
  .pv-bar { flex: 1 1 auto; margin-left: 44px; }
  .pv-detail { grid-template-columns: repeat(2, 1fr); padding-left: 0; }
  .pv-companies { padding-left: 0; }
  .pv-cmp-row { grid-template-columns: 84px 1fr; }
  .pv-cmp-collabel { font-size: 0.54rem; }
}

/* ── Grid view ────────────────────────────────────────────────────────── */
:root { --gv-cell: 14px; }
.gv-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 10px;
}
/* color legend on its own centered row under the sort controls */
.gv-key-row {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}
.gv-key {
  font-size: 0.7rem;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.gv-key-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-left: 7px;
}
.gv-key-ring {
  background: transparent;
  border: 2px solid var(--ink-hi);
}
.gv-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3a transparent;
}
.gv-grid {
  display: grid;
  gap: 2px;
  width: max-content;
}
/* Column numbers follow the upgraded .pv-num treatment — proportionally
   larger, bold, brighter grey (TODO 12, merged item 20). */
.gv-colhead {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  text-align: center;
  align-self: end;
  padding-bottom: 2px;
}
.gv-name {
  position: sticky;
  left: 0;
  background: var(--bg);
  z-index: 2;
  font-size: 0.7rem;
  color: var(--ink-2);
  white-space: nowrap;
  padding-right: 10px;
  line-height: var(--gv-cell);
  cursor: pointer;
}
.gv-name:hover { color: var(--ink); }
.gv-corner { cursor: default; }
.gv-human { color: #FF6600; font-weight: 600; }
/* company separator rows when sorting by company; the label sticks to the
   left edge so it stays readable while the grid scrolls horizontally */
.gv-company {
  grid-column: 1 / -1;
  margin-top: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.gv-company span {
  display: inline-block;
  position: sticky;
  left: 0;
}

.gv-cell {
  width: var(--gv-cell);
  height: var(--gv-cell);
  border-radius: 2px;
  cursor: pointer;
}
.gv-cell.unusual {
  border: 2px solid var(--ink-hi);
}

/* ── Rankings view ────────────────────────────────────────────────────── */
.rank-wrap {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  justify-content: center;
}
.rank-panel {
  flex: 1 1 460px;
  max-width: 570px;
  min-width: 0;
}
.rank-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 2px;
}
.rank-sub {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin: 0 0 8px 210px;
}
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1px 0;
  cursor: pointer;
  border-radius: 4px;
}
.rank-row:hover { background: #1a1a1a; }
.rank-name {
  flex: 0 0 200px;
  text-align: right;
  font-size: 0.72rem;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-human .rank-name { color: #FF6600; font-weight: 600; }
.rank-track {
  position: relative;
  flex: 1 1 auto;
  height: 16px;
  border-left: 1px solid #2f2f2f;
  border-right: 1px solid #2f2f2f;
}
.rank-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.rank-zero {
  position: absolute;
  top: 0; bottom: 0;
  border-left: 1px dashed rgba(255,255,255,0.18);
}
.rank-dot {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,0.3);
}
.rank-human .rank-dot {
  outline: 2px solid #FF6600;
  outline-offset: 1px;
}
.rank-val {
  flex: 0 0 42px;
  font-size: 0.7rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) {
  .rank-name { flex-basis: 130px; }
  .rank-sub { margin-left: 140px; }
}

/* ════ Mobile ═══════════════════════════════════════════════════════════
   Everything below is scoped to coarse-pointer devices or ≤640px viewports,
   so the desktop rendering above stays untouched. The touch-behavior halves
   of this (tap targets on canvas, legend tap semantics, hint text, compact
   canvas typography) live in app.js behind the same IS_TOUCH gate. */

/* ── Phone notice ─────────────────────────────────────────────────────── */
/* Hidden unless app.js adds .open, which it only does on small touch
   screens — so these rules are inert on desktop. */
#phone-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#phone-overlay.open { display: flex; }
#phone-panel {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  padding: 22px 24px 24px;
  width: min(400px, 100%);
  box-shadow: 0 16px 48px rgba(0,0,0,0.8);
  text-align: center;
}
#phone-panel h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--ink-hi);
  margin-bottom: 10px;
}
.phone-note {
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.6;
  margin-bottom: 18px;
  text-align: left;
}
#phone-dismiss { padding: 10px 18px; }

@media (pointer: coarse) {
  /* taps act instantly (no double-tap-zoom pause) on interactive surfaces */
  #compass-app canvas, .seg label, .ctrl-btn, .legend-item, .pv-head, .rank-row,
  .gv-cell, .gv-name {
    touch-action: manipulation;
  }
  /* finger-sized targets for the small segmented controls and buttons */
  .seg label { padding: 6px 10px; }
  .controls .ctrl-btn { padding: 6px 10px; }
}

@media (max-width: 640px) {
  .controls { gap: 8px 14px; margin-bottom: 10px; }
  #view-controls { margin-bottom: 8px; }
  #view-controls .seg label { padding: 7px 8px; font-size: 0.72rem; }
  .ctrl-name { font-size: 0.7rem; }

  /* the JS-measured fixed-pitch legend grid overflows narrow screens —
     let the items wrap instead (the inline grid-template is inert here) */
  #legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 14px;
    padding: 0 4px;
  }

  #hint { margin-bottom: 8px; padding: 0 8px; }

  /* full-bleed square plot; the desktop 100vh coupling no longer applies
     (method.css gives the mobile body 20px side padding — overhang it a
     little, centered, for the full-bleed feel) */
  .chart-wrapper,
  .chart-wrapper.zoomed {
    align-self: center;
    width: calc(100vw - 24px);
    height: calc(100vw - 24px);
  }

  #tooltip { max-width: 210px; }

  .footnote { font-size: 0.72rem; margin-top: 12px; }

  /* detail overlay goes full screen */
  #overlay-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
  }
  #overlay-header { padding: 12px 14px 10px; gap: 10px; }
  #overlay-title { font-size: 1.05rem; }
  #overlay-tools { flex-direction: column; align-items: flex-end; gap: 8px; }
  #overlay-close { order: -1; } /* keep ✕ in the top-right corner */
  #compareWrap .ctrl-name { font-size: 0.62rem; }
  #compareSel { max-width: 150px; }
  #overlay-summary { padding: 8px 14px 10px; }
  #overlay-body { padding: 14px 14px 20px; }
  .prop-item {
    grid-template-columns: 22px 1fr;
    gap: 0 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
  }
  .cons-bar { width: 110px; }
  .prop-reasoning { font-size: 0.92rem; }

  /* alternative views */
  .view-intro { font-size: 0.74rem; }
  .pv-pct { flex-basis: 30px; }
  .rank-wrap { gap: 24px; }
  .rank-name { flex-basis: 108px; font-size: 0.68rem; }
  .rank-sub { margin-left: 118px; }
  .rank-val { flex-basis: 38px; font-size: 0.66rem; }
  .gv-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
}

/* Landscape phones: the viewport is short, not narrow — the desktop
   100vh-based square would collapse, so size the plot by height instead.
   Coarse-pointer-gated so short desktop windows keep today's behavior. */
@media (pointer: coarse) and (max-height: 520px) {
  .chart-wrapper,
  .chart-wrapper.zoomed {
    width: calc(100vh - 120px);
    height: calc(100vh - 120px);
  }
}
