:root {
  --bg: #fff;
  --ink: #1c1c1c;
  --muted: #5c5c5c;
  --line: #d5d5d5;
  --soft: #f4f4f4;
  --haar: #8d8d8d;
  --better: #e5f4e5;
  --worse: #fde8e4;
  --row: 3.25rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }
h1 { font-size: 1.05rem; margin: 0; font-weight: 700; }
h2 { font-size: 0.95rem; margin: 0; }
h3 { font-size: 0.85rem; margin: 0.7rem 0 0.25rem; }
button, select, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--soft); border-radius: 4px; padding: 0.28rem 0.6rem; cursor: pointer; }
button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.linkish, .linkish { border: 0; background: none; padding: 0; color: #185a9d; text-decoration: underline; cursor: pointer; }
button.small { font-size: 0.78rem; padding: 0.05rem 0.4rem; }
.note { color: var(--muted); font-size: 0.8rem; }
[hidden] { display: none !important; }

.top { padding: 0.45rem 0.75rem 0.15rem; }
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.7rem; margin-top: 0.2rem; }
.strip select, #window-custom input { padding: 0.2rem 0.35rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
#status { font-size: 0.98rem; }
.ref { color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.55rem; font-size: 0.82rem; }
#window-custom { display: inline-flex; gap: 0.3rem; align-items: center; }
#window-custom input { width: 3.4rem; }
#window-label { font-weight: 650; white-space: nowrap; }

.workspace { display: grid; grid-template-columns: 22rem minmax(0, 1fr); gap: 0.6rem 0.8rem; align-items: start; padding: 0.35rem 0.75rem 4.2rem; }
#matters { position: sticky; top: 0; max-height: 100vh; overflow: auto; padding-bottom: 1rem; }
.stage { min-width: 0; }
.stage-bar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.view-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.view-switch button { border: 0; border-radius: 0; background: transparent; color: var(--ink); }
.view-switch button.on { background: var(--ink); color: #fff; }
.view-switch button + button { border-left: 1px solid var(--line); }
#matter-chip { display: none; align-items: center; gap: 0.35rem; }
#matter-chip.prompt { font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--ink); }
#matter-chip .dots { display: inline-flex; gap: 0.15rem; }
.dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; display: inline-block; flex: none; }

.crit { padding: 0.45rem 0.35rem; border-bottom: 1px solid #eee; border-radius: 6px; }
.crit.weigh { background: #f4f8fb; }
.crit.off { opacity: 0.72; }
.crit.must .sw-top { font-weight: 650; }
.sw-top { display: flex; align-items: center; gap: 0.4rem; font-weight: 650; margin-bottom: 0.25rem; }
.stops { position: relative; }
.stop-words { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stop-words span { text-align: center; font-size: 0.68rem; line-height: 1.15; padding: 0.32rem 0.12rem; cursor: pointer; color: var(--muted); }
.stop-words span + span { border-left: 1px solid #eee; }
.stop-words span.on { background: var(--ink); color: #fff; font-weight: 650; }
.sw-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.thr { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.thr input[type=range] { flex: 1; min-width: 0; }
.thr output { color: var(--ink); font-weight: 700; min-width: 1.6rem; }
.thr output.tier { min-width: 10.5rem; }
.keeps { white-space: nowrap; }
.extra { margin-top: 0.6rem; }
.extra-label { margin: 0.45rem 0 0.2rem; font-weight: 650; font-size: 0.82rem; }
.country-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 0.4rem; max-height: 12rem; overflow: auto; }
.check { display: flex; gap: 0.35rem; align-items: flex-start; font-size: 0.82rem; margin: 0.15rem 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.sheet-done { display: none; }
details:not([open]) > :not(summary) { display: none !important; }
details summary { cursor: pointer; font-weight: 650; padding: 0.45rem 0; }
details ul { margin: 0.2rem 0 0.6rem; padding-left: 1.1rem; }
details li { margin: 0.12rem 0; }

.skeleton { display: grid; gap: 0.45rem; padding-top: 0.2rem; }
.skeleton div { height: var(--row); border-radius: 6px; background: linear-gradient(90deg, #eee, #f7f7f7, #eee); background-size: 200% 100%; animation: sheen 1.1s ease-in-out infinite; }
.skeleton div:nth-child(2) { width: 92%; }
.skeleton div:nth-child(3) { width: 84%; }
@keyframes sheen { 50% { background-position: 100% 0; } }

.rank-row {
  display: grid;
  grid-template-columns: 1.8rem 1.6rem minmax(6.2rem, 32%) minmax(0, 1fr) 1.8rem 0.9rem;
  column-gap: 0.3rem;
  align-items: center;
  height: var(--row);
  border-bottom: 1px solid #f0f0f0;
}
.rank-row.open { height: auto; align-items: start; padding: 0.15rem 0 0.4rem; }
.rank-row.open .star, .rank-row.open .rk, .rank-row.open .who, .rank-row.open .track, .rank-row.open .sc, .rank-row.open .q { margin-top: 0.45rem; }
.pin-row { position: sticky; top: 0; z-index: 2; background: #f3f3f3; border-bottom: 1px solid #ddd; }
.star, .star.slot { width: 1.8rem; height: var(--row); border: 0; background: transparent; color: #c4c4c4; font-size: 1rem; padding: 0; line-height: var(--row); }
.star.on { color: #b45309; }
.star.slot { display: inline-block; }
.rk { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; }
.who { min-width: 0; display: flex; flex-direction: column; }
.who b, .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who b { font-weight: 650; }
.who span { color: var(--muted); font-size: 0.75rem; }
.track { position: relative; display: flex; height: 0.72rem; background: #f3f3f3; border-radius: 2px; overflow: visible; }
.bit { display: block; height: 100%; }
.bit.miss { background: repeating-linear-gradient(-45deg, transparent, transparent 2px, #b9b9b9 2px, #b9b9b9 3px); box-shadow: inset 0 0 0 1px #c4c4c4; }
.haar { position: absolute; top: -0.55rem; bottom: -0.55rem; width: 2px; margin-left: -1px; background: var(--haar); pointer-events: none; }
.sc { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.q { font-style: normal; color: #8a4b00; font-weight: 700; text-align: center; }
.q.off { visibility: hidden; }
.more { grid-column: 1 / -1; padding: 0.15rem 0 0.2rem 2.2rem; }
.vs { margin: 0.1rem 0 0.35rem; font-weight: 650; }
.mini { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 2.4rem; gap: 0.15rem 0.4rem; align-items: center; margin: 0.2rem 0; }
.mini-name { display: flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; }
.mini-track { position: relative; height: 0.45rem; background: #f3f3f3; display: flex; }
.mini-track .tick { position: absolute; top: -0.2rem; bottom: -0.2rem; width: 2px; background: var(--haar); }
.mini-num { font-variant-numeric: tabular-nums; font-size: 0.82rem; text-align: right; }
.mini-raw { grid-column: 1 / -1; color: var(--muted); font-size: 0.75rem; }
.method { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.75rem; }
.wx-raw, table.compare td .note { display: block; font-size: 0.68rem; font-weight: 400; line-height: 1.25; color: var(--muted); white-space: normal; }
.show-all { margin: 0.45rem 0; }
.band { margin: 0.55rem 0 0.15rem; font-size: 0.82rem; letter-spacing: 0.01em; }
.band .note { font-weight: 500; margin-left: 0.25rem; }
.ranks.settle { animation: settle 160ms ease; }
.ranks.plain .rk, .ranks.plain .track, .ranks.plain .sc, .ranks.plain .q { display: none; }
.ranks.plain .rank-row { grid-template-columns: 1.8rem minmax(0, 1fr); }
.way-out { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.45rem 0 0.55rem; }
.way-out button { font-weight: 650; }
@keyframes settle { from { opacity: 0.35; } to { opacity: 1; } }
.why h3 { display: flex; align-items: center; gap: 0.4rem; }
.empty { margin: 0.5rem 0; }

#plot { display: block; width: 100%; background: #fff; }
.axis-pick { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 0.3rem; }
.axis-pick select { max-width: 100%; }
.axis-title { font-size: 11px; fill: var(--muted); }
#plot .city { fill: #3a3a3a; }
#plot .city.star { fill: #b45309; stroke: #7a3406; stroke-width: 1.5; }
#plot .city.haarlem { fill: #fff; stroke: #333; stroke-width: 2; }
#plot .cross { stroke: #8d8d8d; stroke-dasharray: 3 3; }
#plot .cut { stroke-dasharray: 5 4; }
#plot .lab { font-size: 11px; fill: #222; }
.compare-table-wrap { overflow-x: auto; }
table.compare { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.88rem; }
table.compare th, table.compare td { border-bottom: 1px solid #eee; padding: 0.35rem 0.45rem; text-align: right; vertical-align: bottom; }
table.compare tbody th { text-align: left; font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: #fff; z-index: 1; }
table.compare thead th { font-weight: 700; }
table.compare thead th span { display: block; font-weight: 400; color: var(--muted); font-size: 0.75rem; }
table.compare .haarlem-col { background: #f3f3f3; color: #555; text-align: right; }
table.compare td.better, .cmp-line.better { background: var(--better); }
table.compare td.worse, .cmp-line.worse { background: var(--worse); }
table.compare td.na { color: var(--muted); }
.compare-cards { display: none !important; }
body.has-tray .workspace { padding-bottom: 6.5rem; }
.cmp-card { scroll-snap-align: start; min-width: 100%; padding: 0.2rem 0.1rem 0.8rem; }
.cmp-card h3 { margin: 0; font-size: 1.15rem; }
.cmp-line { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.6rem; padding: 0.35rem 0.4rem; border-bottom: 1px solid #f2f2f2; }
.cmp-line .note { grid-column: 1 / -1; }
.cmp-ref { display: none; }

#tray { position: fixed; left: 50%; bottom: 0.6rem; transform: translateX(-50%); z-index: 5; background: var(--ink); color: #fff; border-color: var(--ink); border-radius: 999px; padding: 0.45rem 0.9rem; font-weight: 700; box-shadow: 0 4px 16px rgba(0,0,0,.18); }

@media (max-width: 800px) {
  .workspace { display: block; padding-bottom: 4.5rem; }
  #matters { display: none; position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 8; max-height: 78vh; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0,0,0,.14); padding: 0.55rem 0.75rem 1rem; }
  #matters.open { display: block; }
  #matter-chip { display: inline-flex; }
  .sheet-done { display: inline-block; }
  .compare-table-wrap { display: block; overflow-x: auto; }
  table.compare { width: max-content; min-width: 0; }
  table.compare thead th, table.compare td { width: 4.6rem; min-width: 4.6rem; max-width: 4.6rem; }
  table.compare td.phrase { width: auto; min-width: 7.2rem; max-width: 9rem; white-space: normal; }
  table.compare tbody th { width: 6.6rem; min-width: 6.6rem; max-width: 7.4rem; white-space: normal; }
  table.compare thead th:first-child { width: 6.6rem; min-width: 6.6rem; }
  .rank-row { grid-template-columns: 1.6rem 1.3rem minmax(5.4rem, 38%) minmax(0, 1fr) 1.6rem 0.8rem; }
  .ranks.plain .rank-row { grid-template-columns: 1.6rem minmax(0, 1fr); }
  .stop-words span { font-size: 0.62rem; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton div { animation: none; }
  .rank-row, .bit, .ranks.settle { transition: none !important; animation: none !important; }
}
