:root {
  --bg: #10161c;
  --panel: #151d25;
  --panel-2: #1c262f;
  --line: #2a3742;
  --text: #e7edf2;
  --dim: #93a3b0;
  --munro: #f4a259;
  --corbett: #6fb3d2;
  --low: #8fbf6a;
  --drive: #c86b8c;
  --accent: #f4a259;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: 100%;
}

/* ---------- panel ---------- */

#panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

#panel-head {
  padding: 16px 16px 0;
  border-bottom: 1px solid var(--line);
}

#panel-head h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.sub {
  margin: 3px 0 12px;
  color: var(--dim);
  font-size: 13px;
}

#tabs {
  display: flex;
  gap: 2px;
}

.tab {
  flex: 1;
  padding: 9px 4px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

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

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

#panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tabpane { display: none; padding: 12px; }
.tabpane.is-active { display: block; }

/* ---------- route cards ---------- */

.card {
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

.card:hover { border-color: #3b4b59; }
.card.is-sel { border-color: var(--accent); background: #232f3a; }

.card.t-munro { border-left-color: var(--munro); }
.card.t-corbett { border-left-color: var(--corbett); }
.card.t-low { border-left-color: var(--low); }

.card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.3;
}

.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 6px;
  color: var(--dim);
  font-size: 12.5px;
}

.card .meta b { color: var(--text); font-weight: 600; }

.card p { margin: 6px 0 0; font-size: 13px; color: #c3ced7; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pill.t-munro { background: rgba(244, 162, 89, 0.16); color: var(--munro); }
.pill.t-corbett { background: rgba(111, 179, 210, 0.16); color: var(--corbett); }
.pill.t-low { background: rgba(143, 191, 106, 0.16); color: var(--low); }

.qual { color: var(--munro); letter-spacing: 1px; }

/* Status badge: a colour bar plus a word. The word carries the meaning, never
   the colour alone — same rule for ground verdicts and fire closures. */
.badge {
  margin-top: 6px;
  padding: 6px 9px;
  border-left: 3px solid var(--bc, var(--line));
  border-radius: 0 5px 5px 0;
  background: color-mix(in srgb, var(--bc, #888) 11%, transparent);
  font-size: 12.5px;
  color: #c9d4dd;
}

.badge b { color: var(--bc); font-weight: 700; }
.badge .soil { color: var(--dim); font-variant-numeric: tabular-nums; }
.badge.big { margin: 0 0 14px; padding: 11px 13px; font-size: 13px; }
.badge.big b { display: block; margin-bottom: 4px; font-size: 14px; }
.badge.big ul { margin: 7px 0; padding-left: 17px; }
.badge.big li { margin: 2px 0; }
.badge a {
  display: inline-block;
  margin-top: 7px;
  color: var(--corbett);
  font-weight: 600;
}
.badge p { margin: 8px 0 0; }

.chip {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 1px solid var(--bc);
  border-radius: 999px;
  color: var(--bc);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: 1px;
}

.card.is-closed { opacity: 0.62; }
.card.is-closed h3 { text-decoration: line-through; text-decoration-thickness: 1px; }

.grp {
  margin: 16px 2px 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.filt { display: flex; gap: 5px; margin-bottom: 10px; }

.filt button {
  flex: 1;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.filt button.is-active { border-color: var(--accent); color: var(--text); }

.dim { color: var(--dim); }

.src { margin-top: 8px; font-size: 11.5px; color: var(--dim); font-style: italic; }

/* inline magnitude bar in the ground table — bar and figure on one line */
.gcell { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

.bar {
  flex: 0 0 34px;
  height: 7px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar i { display: block; height: 100%; border-radius: 2px; }

/* the ground table carries five numeric columns — keep the rain ones tight
   so the area name gets the space it needs */
table.t.ground th, table.t.ground td { padding: 6px 5px; }
table.t.ground td.n, table.t.ground th.n { font-size: 12px; }
table.t.ground td:first-child { font-size: 12.5px; }

/* ---------- plan comparison ---------- */

/* The plan letter alone in column 1 — the full name goes on the trade row below, which
   keeps all seven columns inside 400px of panel with no horizontal scroll at all. */
.cmp-scroll { overflow-x: auto; margin: 0 -2px 4px; -webkit-overflow-scrolling: touch; }

table.cmp { table-layout: fixed; }
table.cmp th, table.cmp td { padding: 5px 2px; vertical-align: middle; }
table.cmp td.pk { white-space: nowrap; font-size: 13.5px; width: 30px; }
table.cmp th.mn, table.cmp td.mn { width: 34px; }
table.cmp td.pk .cond {
  margin-left: 2px;
  padding: 0 3px;
  font-size: 9px;
  vertical-align: 2px;
}
table.cmp tr.cmp-row td { border-bottom: 0; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; font-size: 10.5px; }
th.sortable:hover { color: var(--text); }
th.sortable.is-sort { color: var(--accent); }

/* ◆ measured / ◇ judged marker — present but never competing with the label */
th.sortable .mk { font-size: 8px; opacity: 0.75; vertical-align: 1px; }

/* rank cell: numeral for precision, bar length for the at-a-glance read */
td.rk { padding-bottom: 6px !important; }
td.rk .rv { display: block; font-size: 12.5px; font-variant-numeric: tabular-nums; }

td.rk .rb {
  display: block;
  height: 3px;
  margin-top: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
}

td.rk .rb i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--dim);
}

td.rk.is-best .rv { color: var(--accent); font-weight: 700; }
td.rk.is-best .rb i { background: var(--accent); }

tr.cmp-row { cursor: pointer; }
tr.cmp-row:hover td { background: rgba(255, 255, 255, 0.035); }

tr.cmp-trade { cursor: pointer; }

tr.cmp-trade td {
  padding: 1px 3px 8px !important;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.45;
}

tr.cmp-trade td b { color: #c3ced7; }
tr.cmp-trade:hover td { background: rgba(255, 255, 255, 0.035); }

.cond {
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(250, 178, 25, 0.16);
  color: #fab219;
  font-size: 10px;
  font-weight: 700;
}

/* per-day ground sequence in the "shown working" table */
.seq {
  display: inline-block;
  margin: 1px 2px 1px 0;
  padding: 0 5px;
  border-left: 2px solid var(--bc);
  border-radius: 0 3px 3px 0;
  background: color-mix(in srgb, var(--bc) 12%, transparent);
  font-size: 10.5px;
  white-space: nowrap;
}

.card .expand { display: none; }
.card.is-sel .expand { display: block; }

.card a {
  display: inline-block;
  margin-top: 8px;
  color: var(--corbett);
  font-size: 12.5px;
}

.tt {
  margin-top: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(111, 179, 210, 0.07);
}

.tt h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--corbett); }
.tt table.t { font-size: 12.5px; }
.tt table.t td, .tt table.t th { padding: 3px 6px; }
.tt tr.tt-caveat td { opacity: 0.6; font-style: italic; }
.tt-note { margin: 8px 0 0; font-size: 12px; color: var(--dim); }
.tt a { font-size: 12px; margin-top: 4px; }

.warn {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  background: rgba(244, 162, 89, 0.1);
  border: 1px solid rgba(244, 162, 89, 0.3);
  font-size: 12.5px;
  color: #f0c69b;
}

/* ---------- week / tables ---------- */

.planhead {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.planhead h2 { margin: 0 0 2px; font-size: 15px; }
.planhead p { margin: 8px 0 0; font-size: 13px; color: var(--dim); }
.planhead .tagline { font-size: 12.5px; color: var(--accent); font-weight: 600; }

.planhead .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--dim);
}

.planhead .stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.plan-switch { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.plan-switch button {
  flex: 1 1 30%;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.plan-switch button.is-active { border-color: var(--accent); color: var(--text); }

.day { margin-bottom: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.day h4 { margin: 0 0 2px; font-size: 13px; color: var(--accent); letter-spacing: 0.02em; }
.day .r { font-size: 14px; font-weight: 600; cursor: pointer; }
.day .r:hover { text-decoration: underline; }
.day .r.rest { color: var(--dim); font-weight: 500; font-style: italic; cursor: default; }
.day .r.rest:hover { text-decoration: none; }
.day .legs { margin: 5px 0 0; font-size: 12.5px; color: var(--dim); }
.day p { margin: 6px 0 0; font-size: 13px; color: #c3ced7; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.t th { color: var(--dim); font-weight: 600; font-size: 12px; }
table.t td.n { text-align: right; font-variant-numeric: tabular-nums; }

.note { margin: 10px 2px 16px; font-size: 12.5px; color: var(--dim); }

/* ---------- map ---------- */

#map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0b1116; }

.leaflet-container { font: inherit; background: #0b1116; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
.leaflet-popup-content b { display: block; margin-bottom: 3px; font-size: 13.5px; }
.leaflet-popup-content .s { color: var(--dim); font-size: 12.5px; }
a.leaflet-popup-close-button { color: var(--dim) !important; }

#legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 29, 37, 0.94);
  font-size: 12.5px;
}

#legend .row { display: flex; gap: 10px; align-items: center; }
#legend label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
#legend .lbl { color: var(--dim); font-size: 11.5px; }

#legend button {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#legend button.is-active { border-color: var(--accent); color: var(--accent); }

#rain-days { display: flex; gap: 3px; }
#rain-days button { padding: 3px 7px; }

/* Sequential legend: swatch + range, ink stays in text tokens. */
#grid-legend { display: flex; flex-wrap: wrap; gap: 4px 9px; align-items: center; max-width: 420px; }
#grid-legend .sw { display: flex; gap: 4px; align-items: center; color: var(--dim); font-size: 11px; }
#grid-legend .sw i {
  width: 15px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#grid-legend .cav { color: var(--dim); font-size: 11px; font-style: italic; }

.leaflet-tooltip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
}
.leaflet-tooltip b { display: block; }
.leaflet-tooltip .s { color: var(--dim); font-size: 11px; }
.leaflet-tooltip::before { border-top-color: var(--line); }

#panel-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 500;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 29, 37, 0.94);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.summit-dot {
  border-radius: 50%;
  border: 2px solid #10161c;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.pk-dot {
  border-radius: 4px;
  border: 2px solid #10161c;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.fire-dot {
  border-radius: 50%;
  border: 2px solid #10161c;
  box-shadow: 0 0 0 2px rgba(208, 59, 59, 0.55);
}

.v2 {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(244, 162, 89, 0.18);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 3px;
}

/* ---------- narrow ---------- */

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  #panel {
    position: absolute;
    inset: 0;
    z-index: 900;
    border-right: 0;
  }
  #panel.is-hidden { display: none; }
  #panel-toggle { display: block; }
  #legend { bottom: max(10px, env(safe-area-inset-bottom)); font-size: 12px; gap: 9px; }
}

/* whole-week itinerary markers */
.night {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: #10161c;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.day-key { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 10px; font-size: 11.5px; }
.day-key span { display: flex; gap: 4px; align-items: center; color: var(--dim); }
.day-key i { width: 14px; height: 3px; border-radius: 2px; }

/* a model row that is a duplicate of another, not an independent voice */
table.t tr.dup td { opacity: 0.5; font-style: italic; }
.dupnote { margin: 8px 0 0 !important; color: #f0c69b; font-size: 12px; }
