:root {
  --sat: env(safe-area-inset-top);
  --bg: #0b1118;
  --ink: #e8eef5;
  --muted: #8a9bb0;
  --line: rgba(160, 190, 220, 0.14);
  --card: rgba(13, 20, 29, 0.72);
  --water: #4fd1e8;
  --deep: #2b6fd6;
  --warn-1: #5bbf6a; --warn-2: #f2c94c; --warn-3: #f2994a; --warn-4: #eb5757;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--sans); overflow: hidden; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  background: radial-gradient(120% 90% at 50% 0%, #1a2a3b 0%, #0e1721 55%, #0b1118 100%); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--water); outline-offset: 2px; border-radius: 6px; }

.card { position: fixed; background: var(--card); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); }

.brand { position: fixed; top: calc(22px + env(safe-area-inset-top)); left: 26px; pointer-events: none; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.6); }
.brand h1 { margin: 0; font: 400 64px/0.9 var(--serif); letter-spacing: -0.5px; }
.brand .sub { margin: 8px 0 0; color: var(--muted); font-size: 13px; letter-spacing: 0.2px; }
.key { margin: 10px 0 0; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.key i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.key i:first-child { margin-left: 0; }
.k-river { background: #1a52a0; } .k-flood { background: linear-gradient(135deg, #59dcf2, #2269e0); } .k-bld { background: #ff7a45; }
.sub .stale { color: var(--warn-2); }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--water);
  box-shadow: 0 0 0 0 rgba(79, 209, 232, 0.6); animation: pulse 2s infinite; vertical-align: 1px; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(79, 209, 232, 0); } 100% { box-shadow: 0 0 0 0 rgba(79, 209, 232, 0); } }

.side { position: fixed; top: 22px; right: 22px; width: 300px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 250px); overflow-y: auto; scrollbar-width: none; border-radius: 16px; }
.side::-webkit-scrollbar { display: none; }
.side .card { flex: none; }
.side .card { position: relative; }
.now { padding: 18px 20px 16px; }
.now .when { color: var(--muted); font-size: 12px; letter-spacing: 0.4px; text-transform: uppercase; }
.now .q { font: 400 58px/1 var(--serif); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.now .q small { font: 500 14px var(--sans); color: var(--muted); margin-left: 6px; }
.tier { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: rgba(79, 209, 232, 0.14); color: var(--water); }
.tier.t2 { background: rgba(242, 201, 76, 0.16); color: var(--warn-2); }
.tier.t3 { background: rgba(242, 153, 74, 0.18); color: var(--warn-3); }
.tier.t4 { background: rgba(235, 87, 87, 0.2); color: #ff8a8a; }
.vol { margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.vol:empty { display: none; }
.facts { margin: 14px 0 0; display: grid; gap: 8px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.mpeak { display: none; margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.mpeak b { color: var(--ink); }
.warning { margin-top: 12px; padding: 9px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.35;
  border-left: 3px solid var(--warn-3); background: rgba(242, 153, 74, 0.1); }
.warning b { display: block; font-size: 13px; margin-bottom: 2px; }

.odds { padding: 16px 20px 14px; }
.odds h2 { margin: 0; font: 600 13px var(--sans); }
.odds .hint { margin: 2px 0 10px; color: var(--muted); font-size: 12px; }
.odds ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.odds li { display: grid; grid-template-columns: 62px 1fr 46px; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.odds .bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.odds .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--water), var(--deep)); transition: width 0.4s; }
.odds li.hot .bar i { background: linear-gradient(90deg, var(--warn-3), var(--warn-4)); }
.odds .pct { text-align: right; font-weight: 600; white-space: nowrap; }
.odds .peak { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.odds .peak b { color: var(--ink); }

.modes { position: fixed; left: 26px; bottom: 236px; display: flex; padding: 4px; gap: 2px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.modes button, .scen button { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 13px; }
.modes button.on, .scen button.on { background: rgba(255, 255, 255, 0.1); color: var(--ink); }

.timeline { left: 22px; right: 22px; bottom: 40px; height: 182px; padding: 10px 14px 6px; }
.tl-head { display: flex; align-items: center; gap: 14px; height: 32px; }
#play { width: 32px; height: 32px; border-radius: 50%; background: var(--water); color: #06202a; font-size: 12px; font-weight: 700; flex: none; }
.scen { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.legend { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 8px; border-radius: 2px; margin-left: 10px; }
.l-obs { background: var(--ink); height: 2px !important; }
.l-fc { background: rgba(79, 209, 232, 0.25); }
.l-band { background: rgba(79, 209, 232, 0.5); }
#chart { width: 100%; height: 136px; display: block; cursor: ew-resize; touch-action: none; user-select: none; }
#chart text { fill: var(--muted); font: 11px var(--sans); }
#chart .rp text { font-size: 10.5px; }

.credits a { color: #c9d5e2; pointer-events: auto; }
.credits { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 26px 10px; background: linear-gradient(transparent, rgba(11,17,24,0.9) 60%); color: rgba(138, 155, 176, 0.7); font-size: 10.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.brand, .side, .timeline, .modes, .credits { z-index: 2; }
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; font: 500 12px var(--sans); color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 12px rgba(0, 0, 0, 0.8); letter-spacing: 0.2px; padding-bottom: 6px; }
.lbl::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 1px; height: 5px; background: rgba(255, 255, 255, 0.7); }
.lbl.big { font: 400 22px var(--serif); letter-spacing: 0.4px; }
.lbl.river { font: italic 400 17px var(--serif); color: #9fe6f2; }
.lbl.river::after { display: none; }

@media (max-width: 760px) {
  .brand h1 { font-size: 42px; }
  .brand { top: 0; left: 0; right: 0; padding: calc(14px + env(safe-area-inset-top)) 16px 18px; background: linear-gradient(rgba(11,17,24,0.95) 78%, transparent); }
  .warning span { display: none; }
  .warning b { margin: 0; }
  .side { top: auto; bottom: 214px; left: 12px; right: 12px; width: auto; max-height: none; }
  .now { padding: 12px 16px; }
  .now .q { font-size: 40px; display: inline-block; margin-right: 10px; }
  .now .tier { vertical-align: 10px; }
  .now .facts { grid-template-columns: repeat(3, 1fr); }
  .facts div { flex-direction: column; gap: 2px; }
  .facts dd { text-align: left; }
  .odds { display: none; }
  .mpeak { display: block; }
  .modes { top: calc(16px + env(safe-area-inset-top)); right: 12px; left: auto; bottom: auto; }
  .timeline { left: 8px; right: 8px; bottom: 28px; }
  .legend { display: none; }
  .credits { padding: 10px 12px 6px; }
}

.pin { position: fixed; left: 0; top: 0; z-index: 6; width: 250px; padding: 12px 14px 10px; border-radius: 14px;
  background: rgba(13, 20, 29, 0.9); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45); font-size: 13px; }
.pin::after { content: ""; position: absolute; left: var(--ax, 50%); bottom: -14px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: var(--water); box-shadow: 0 0 0 4px rgba(79, 209, 232, 0.25), 0 0 18px var(--water); }
.pin::before { content: ""; position: absolute; left: var(--ax, 50%); bottom: -8px; width: 1px; height: 8px; background: var(--water); }
.pin.below::after { bottom: auto; top: -20px; }
.pin.free::after, .pin.free::before { display: none; }
.pin.below::before { bottom: auto; top: -8px; }
.pin p { margin: 6px 0 0; color: #c9d5e2; }
.pin p.wet b { color: #ffb08a; }
.pin p.est { color: var(--muted); font-size: 11.5px; }
.pin-h { font: 400 22px var(--serif); }
.pin .x { position: absolute; top: 6px; right: 8px; width: 24px; height: 24px; color: var(--muted); font-size: 18px; line-height: 1; }

#loading { position: fixed; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: radial-gradient(120% 90% at 50% 0%, #1a2a3b 0%, #0e1721 55%, #0b1118 100%); transition: opacity 0.8s; }
#loading.done { opacity: 0; pointer-events: none; }
.ld-mark { font: 400 56px var(--serif); }
.ld-bar { width: 160px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.ld-bar i { display: block; width: 40%; height: 100%; background: var(--water); animation: ld 1.2s ease-in-out infinite; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
#loading p { margin: 0; color: var(--muted); font-size: 13px; }
#hint { position: fixed; left: 50%; bottom: 236px; transform: translateX(-50%); z-index: 2; padding: 8px 16px; border-radius: 999px;
  background: rgba(13, 20, 29, 0.78); border: 1px solid var(--line); color: var(--ink); font-size: 13px; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: opacity 0.6s; pointer-events: none; }
#hint.gone { opacity: 0; }
@media (max-width: 760px) { #hint { display: none; } }

/* collapse: tuck the data away to study the map */
.collapse { margin-left: auto; min-height: 36px; padding: 6px 14px; border-radius: 10px; color: var(--ink); background: rgba(255, 255, 255, 0.06); font-weight: 600; font-size: 13px; flex: none; touch-action: manipulation; }
.legend + .collapse { margin-left: 4px; }
.collapse:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.side, .timeline, .modes { transition: transform 0.35s cubic-bezier(.2,.8,.2,1), opacity 0.25s; }
body.collapsed .timeline, body.collapsed .side { transform: translateY(calc(100% + 60px)); opacity: 0; pointer-events: none; }
body.collapsed .side { transform: translateX(calc(100% + 40px)); }
body.collapsed #hint, body.collapsed .credits { opacity: 0; pointer-events: none; }
body.collapsed .modes { transform: translateY(170px); }
.mini { position: fixed; z-index: 3; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-radius: 999px; white-space: nowrap;
  background: rgba(13, 20, 29, 0.82); border: 1px solid var(--line); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45); animation: mini-in 0.35s cubic-bezier(.2,.8,.2,1); }
.mini[hidden] { display: none; }
@keyframes mini-in { from { transform: translate(-50%, 30px); opacity: 0; } }
.mini-q { color: var(--muted); font-size: 13px; }
.mini-q b { font: 400 26px/1 var(--serif); color: var(--ink); margin-right: 2px; }
.mini .tier { font-size: 12px; padding: 2px 9px; }
.mini-when { color: var(--muted); font-size: 12.5px; }
.mini-open { padding: 7px 12px; border-radius: 999px; background: var(--water); color: #06202a; font-weight: 600; font-size: 13px; }
@media (max-width: 760px) {
  .collapse { margin-left: auto; min-height: 44px; padding: 8px 16px; }
  .mini { min-height: 56px; touch-action: manipulation; }
  body.collapsed .side { transform: translateY(calc(100% + 260px)); }
  body.collapsed .modes { transform: none; }
  .mini { left: 10px; right: 10px; transform: none; justify-content: space-between; animation-name: mini-in-m; }
  @keyframes mini-in-m { from { transform: translateY(30px); opacity: 0; } }
  .mini-when { display: none; }
  .timeline { bottom: calc(28px + env(safe-area-inset-bottom)); }
  .side { bottom: calc(214px + env(safe-area-inset-bottom)); }
}

/* address search */
.search { position: fixed; z-index: 4; top: calc(150px + env(safe-area-inset-top)); left: 26px; width: 320px; }
.search input { width: 100%; padding: 10px 14px 10px 38px; border-radius: 12px; border: 1px solid var(--line); outline: none;
  background: rgba(13, 20, 29, 0.78); color: var(--ink); font: 14px var(--sans); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.search input::placeholder { color: #6f8196; }
.search input:focus { border-color: rgba(79, 209, 232, 0.6); box-shadow: 0 0 0 3px rgba(79, 209, 232, 0.15); }
.search-btn { position: absolute; z-index: 1; left: 4px; top: 4px; width: 32px; height: 32px; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
#hits { list-style: none; margin: 6px 0 0; padding: 0; border-radius: 12px; overflow: hidden; background: rgba(13, 20, 29, 0.94);
  border: 1px solid var(--line); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45); }
#hits:empty { display: none; }
#hits li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; cursor: pointer; border-top: 1px solid rgba(160, 190, 220, 0.07); }
#hits li:first-child { border-top: 0; }
#hits li span { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
#hits li[aria-selected="true"], #hits li:hover { background: rgba(79, 209, 232, 0.12); }
#hits li.off { opacity: 0.45; cursor: default; }
.pin-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.pin .share { margin-top: 10px; padding: 6px 12px; border-radius: 999px; background: rgba(79, 209, 232, 0.14); color: var(--water); font-weight: 600; font-size: 12.5px; }
.pin .share:hover { background: rgba(79, 209, 232, 0.24); }
@media (max-width: 760px) {
  .search { top: calc(66px + env(safe-area-inset-top)); left: auto; right: 12px; width: 40px; }
  .search input { display: none; }
  .search-btn { position: static; width: 40px; height: 40px; border-radius: 12px; pointer-events: auto; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .search.open { left: 12px; width: auto; }
  .search.open .search-btn { position: absolute; left: 4px; top: 4px; width: 32px; height: 32px; background: none; border: 0; }
  .search.open input { display: block; font-size: 16px; }
  .pin { width: min(270px, calc(100vw - 24px)); }
}

.pin .watch { display: block; margin-top: 10px; padding: 7px 12px; border-radius: 999px; background: var(--water); color: #06202a; font-weight: 600; font-size: 12.5px; }
.pin .watch:disabled { opacity: 0.7; }
.pin .watch + .share { margin-left: 0; }
.pin p.bell { color: #c9d5e2; font-size: 12.5px; }
.pin p.bell.on { color: var(--water); }
.pin .unwatch { color: var(--muted); text-decoration: underline; font-size: 12.5px; padding: 0; }

/* «Meld hva du ser»: report dots and the popup form */
#dots { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.dot { position: absolute; left: 0; top: 0; width: 14px; height: 14px; padding: 0; border-radius: 50%; pointer-events: auto;
  background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.5); }
.dot::after { content: ""; position: absolute; inset: -10px; }   /* bigger touch target */
.pin .seen { color: var(--muted); font-size: 12px; }
.report-row { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.pin .report { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); font-size: 12.5px; font-weight: 500; }
.pin .ask { width: 100%; margin: 0 0 2px; color: #c9d5e2; font-size: 12.5px; }
.pin .ask.ok { color: var(--water); }
.pin .lvl { padding: 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); color: var(--ink); font-size: 12.5px; min-height: 32px; }
.pin .lvl:hover { background: rgba(79, 209, 232, 0.2); }
.pin .share { display: inline-block; }

.spot { position: fixed; left: 0; top: 0; z-index: 5; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; pointer-events: none;
  background: var(--water); border: 2px solid #fff; box-shadow: 0 0 0 5px rgba(79, 209, 232, 0.25), 0 0 18px var(--water); }
.spot[hidden] { display: none; }
@media (max-width: 760px) {
  .pin { left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; max-height: 52vh; overflow-y: auto;
    transform: none !important; background: #0d141d; border-radius: 18px; padding: 14px 16px 12px; }
  body.sheet .mini { visibility: hidden; }
  .pin::after, .pin::before { display: none; }
}
