:root {
  --ink: #12211b;
  --ink2: #44544c;
  --ink3: #6a7871;
  --line: #e3e7e1;
  --wash: #f4f6f2;
  --brand: #0b3c2c;
  --dmg: #e8261a;
  --rail: 76px;
  --side: 310px;
  --dock: 200px;
  --lift: 0 4px 16px rgba(10, 30, 22, .16);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 400 14px/1.4 "Schibsted Grotesk", system-ui, sans-serif; color: var(--ink); background: #fff; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
:focus-visible { outline: 2px solid var(--dmg); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, p { margin: 0; }

.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr) var(--side); grid-template-rows: minmax(0, 1fr) var(--dock); height: 100dvh; }
.app[data-tab="compare"] { grid-template-rows: minmax(0, 1fr) 0; }
.app[data-tab="compare"] .dock { display: none; }

/* Rail */
.rail { grid-row: 1 / 3; background: var(--brand); display: flex; flex-direction: column; gap: 4px; padding: 0 6px; z-index: 5; }
.logo { display: block; padding: 14px 7px 12px; }
.logo img { width: 100%; height: auto; display: block; }
#tabs { display: flex; flex-direction: column; gap: 4px; }
.tab { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 2px 9px; border-radius: 10px; color: #c6d8cf; font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.15; transition: background .15s, color .15s; }
.tab svg { width: 24px; height: 24px; }
.tab:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.tab[aria-selected="true"] { background: #fff; color: var(--brand); }

/* Map */
.stage { position: relative; grid-column: 2; grid-row: 1; background: #1d2a24; overflow: hidden; }
.app[data-tab="compare"] .stage { grid-row: 1 / 3; }

/* Embed slider mode */
.app.embed-slider {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
  background: #070c08;
}
.app.embed-slider .rail,
.app.embed-slider .side,
.app.embed-slider .dock,
.app.embed-slider .event {
  display: none !important;
}
.app.embed-slider .stage {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  grid-column: unset !important;
  grid-row: unset !important;
}
.app.embed-slider .sidetag.after {
  right: 14px;
}
.app.embed-slider .maplibregl-ctrl-top-right,
.app.embed-slider .maplibregl-ctrl-bottom-right,
.app.embed-slider .coord {
  display: none !important;
}
.map { position: absolute; inset: 0; }
.map.clip { clip-path: inset(0 0 0 var(--split, 50%)); }
.swipe { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.handle { position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, .5); pointer-events: auto; cursor: ew-resize; touch-action: none; }
.grip { position: absolute; top: 50%; left: 50%; width: 42px; height: 42px; margin: -21px; border-radius: 50%; background: #fff; color: var(--brand); display: grid; place-items: center; box-shadow: var(--lift); }
.sidetag { position: absolute; top: 14px; background: rgba(18, 33, 27, .88); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 16px; }
.sidetag b { margin-right: 6px; }
.sidetag.before { left: 14px; }
.sidetag.after { right: 54px; }
.event { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(18, 33, 27, .9); color: #fff; padding: 9px 16px; border-radius: 22px; font-size: 14px; box-shadow: var(--lift); white-space: nowrap; animation: pop .45s cubic-bezier(.16, 1, .3, 1); z-index: 3; }
.event b { color: #ffb4a8; margin-right: 6px; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -8px); } }
.loading { position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 18px; padding: 6px 12px; display: flex; gap: 8px; align-items: center; font-size: 12.5px; box-shadow: var(--lift); z-index: 3; }
.spin { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.coord { position: absolute; left: 10px; bottom: 8px; color: #fff; font-size: 11.5px; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; pointer-events: none; z-index: 2; }
.mlabel { color: #fff; font-weight: 700; font-size: 13px; text-shadow: 0 0 3px #000, 0 1px 2px #000; pointer-events: none; }

/* Patch preview popup */
.maplibregl-popup-content { font: 13px/1.35 "Schibsted Grotesk", sans-serif; padding: 12px 12px 10px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.maplibregl-popup-close-button { font-size: 20px; padding: 2px 8px; }
.pv h3 { font-size: 15px; }
.pv h3 span { color: var(--dmg); margin-left: 6px; }
.pv .where { color: var(--ink2); margin: 2px 0 8px; }
.pvg { display: grid; grid-template-columns: 76px 1fr 1fr; gap: 4px; align-items: center; }
.pvg .h { font-size: 11px; font-weight: 700; color: var(--ink3); text-transform: uppercase; letter-spacing: .05em; }
.pvg .s { font-size: 12px; font-weight: 600; line-height: 1.15; }
.chip { position: relative; aspect-ratio: 1; border-radius: 6px; background-size: 200% 300%; background-color: #3c3c3c; }
.chip i { position: absolute; left: 4px; bottom: 4px; font-style: normal; font-size: 10.5px; color: #fff; background: rgba(0, 0, 0, .6); padding: 1px 5px; border-radius: 4px; }
.pv .facts { margin-top: 8px; font-size: 12px; color: var(--ink2); }

/* Side panel */
.side { grid-column: 3; grid-row: 1 / 3; border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.brand { padding: 16px 18px 13px; border-bottom: 1px solid var(--line); }
.brand h1 { font-size: 18px; }
.brand p { color: var(--ink3); font-size: 13px; }
.side section { padding: 14px 18px 8px; }
.side h2 { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink3); margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); gap: 4px; background: var(--wash); padding: 3px; border-radius: 10px; }
.seg button { padding: 7px 4px; border-radius: 8px; font-weight: 600; font-size: 12.5px; text-align: center; color: var(--ink2); }
.seg button[aria-checked="true"] { background: var(--brand); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.dates { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.dchip { border: 1.5px solid var(--line); border-radius: 8px; padding: 4px 8px 4px 7px; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.dchip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2f9e44; }
.dchip.cloud::before { background: #b5bdb8; }
.dchip.post { border-color: #f3b3ad; }
.dchip:hover { border-color: #9aa69f; }
.dchip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.note { font-size: 12px; color: var(--ink3); margin-top: 7px; }
.ramp { height: 9px; border-radius: 5px; background: linear-gradient(90deg, #8a8a8a, #c9c9c9 50%, #eb1e19); margin: 4px 0 2px; }
.ends { display: flex; justify-content: space-between; color: var(--ink3); font-size: 11.5px; }

.layer { display: grid; grid-template-columns: 26px 1fr auto 36px; align-items: center; gap: 10px; width: 100%; padding: 7px 6px; border-radius: 8px; }
.layer:hover { background: var(--wash); }
.layer .name { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.layer .val { font-size: 12.5px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.layer[aria-checked="false"] .name, .layer[aria-checked="false"] .sw { opacity: .4; }
.switch { width: 34px; height: 20px; border-radius: 10px; background: #cfd6d1; position: relative; transition: background .18s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s; }
.layer[aria-checked="true"] .switch { background: var(--brand); }
.layer[aria-checked="true"] .switch::after { transform: translateX(14px); }
.sw { width: 22px; height: 16px; border-radius: 4px; }
.sw.dmg { background: radial-gradient(circle, #ff3b1f 35%, rgba(255, 140, 0, .6) 70%, rgba(255, 200, 0, .25)); border: 1.5px solid #fff; box-shadow: 0 0 0 1.5px #7a0b05; }
.sw.bld { background: #ffb000; border: 1.5px solid #3a2600; }
.sw.near { background: #ffe066; border: 3px solid #111; border-radius: 50%; width: 16px; margin-left: 3px; }
.sw.river { height: 4px; background: #3d9bf0; border-radius: 2px; }
.sw.road { height: 5px; background: #fff; border: 1.5px solid #333; border-radius: 3px; }
.sw.label { background: none; font-weight: 700; font-size: 13px; text-align: center; line-height: 16px; }
.sw.label::before { content: "Aa"; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { background: var(--wash); border-radius: 8px; padding: 7px 10px; }
.stat b { display: block; font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--ink3); }
.stat.hot b { color: var(--dmg); }
.plist { display: flex; flex-direction: column; gap: 2px; }
.prow { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; padding: 6px; border-radius: 9px; width: 100%; }
.prow:hover, .prow[aria-current="true"] { background: var(--wash); }
.prow .th { width: 52px; height: 52px; border-radius: 7px; background-size: 200% 300%; background-position: 100% 0; }
.prow b { font-size: 13.5px; }
.prow b span { color: var(--dmg); margin-left: 4px; }
.prow small { display: block; font-size: 12px; color: var(--ink3); line-height: 1.3; }

.foot { margin-top: auto; padding: 14px 18px 16px; border-top: 1px solid var(--line); font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; }
.foot a { color: var(--brand); font-weight: 600; }
.foot p { color: var(--ink3); font-size: 11.5px; margin-top: 4px; }

/* Dock */
.dock { grid-column: 2; grid-row: 2; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; padding: 10px 16px 10px; min-width: 0; }
.tl { display: flex; flex-direction: column; min-width: 0; }
.tlhead { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.play { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.play:hover { background: #155440; }
.speed { height: 28px; min-width: 42px; padding: 0 8px; border: 1.5px solid var(--line); border-radius: 14px; font-weight: 700; font-size: 12.5px; text-align: center; font-variant-numeric: tabular-nums; }
.when { margin-left: 6px; display: flex; align-items: baseline; gap: 10px; }
.when b { font-size: 22px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.when span { color: var(--ink3); font-size: 13px; }
.track { flex: 1; min-height: 0; cursor: pointer; touch-action: none; user-select: none; }
.track svg, .chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.track text, .chart text { font-size: 10.5px; fill: var(--ink3); }
.track text.lane { font-size: 11px; fill: var(--ink2); font-weight: 600; }
.track text.mark { fill: var(--dmg); font-weight: 700; }
.info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.kpi { background: var(--wash); border-radius: 8px; padding: 6px 9px; }
.kpi b { display: block; font-size: 19px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11.5px; color: var(--ink3); line-height: 1.2; display: block; }
.kpi.hot b { color: var(--dmg); }
.chart { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chart h3 { font-size: 12px; font-weight: 700; color: var(--ink2); margin-bottom: 2px; }
.chart > div { flex: 1; min-height: 0; }
.chart text.v { fill: var(--ink); font-weight: 600; }
.chart rect.hit { fill: transparent; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 5px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 8px)); }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto 58vh auto auto; height: auto; }
  .rail { grid-row: 1; flex-direction: row; align-items: center; }
  .logo { width: 70px; padding: 8px; }
  #tabs { flex-direction: row; flex: 1; }
  .tab { flex-direction: row; justify-content: center; }
  .stage, .app[data-tab="compare"] .stage { grid-column: 1; grid-row: 2; }
  .dock { grid-column: 1; grid-row: 3; grid-template-columns: 1fr; }
  .track { height: 120px; flex: none; }
  .chart { height: 120px; flex: none; }
  .side { grid-column: 1; grid-row: 4; border-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .event { animation: none; } }
.pvcard { position: absolute; top: 14px; left: 14px; width: 350px; max-height: calc(100% - 28px); overflow-y: auto; background: #fff; border-radius: 12px; padding: 12px 12px 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); z-index: 4; animation: slide .3s cubic-bezier(.16, 1, .3, 1); }
.app[data-tab="compare"] .pvcard { top: 52px; }
.pvx { position: absolute; top: 6px; right: 8px; width: 28px; height: 28px; border-radius: 50%; font-size: 20px; line-height: 1; text-align: center; color: var(--ink2); }
.pvx:hover { background: var(--wash); }
@keyframes slide { from { opacity: 0; transform: translateX(-10px); } }
@media (max-width: 900px) { .pvcard { top: auto; bottom: 10px; left: 10px; right: 10px; width: auto; max-height: 60%; } }
