/* Nepal Flood 2026 — Bhote Koshi & Trishuli.  Sidebar + swipe compare shell. */
:root {
  --bg: #12161c;
  --bg2: #1a2029;
  --bg3: #232b36;
  --fg: #e7ecf3;
  --fg-dim: #9aa6b5;
  --line: #313b48;
  --accent: #5eb0ff;
  --accent2: #ffb64d;
  --pre: #9fd5a9;
  --post: #ffb64d;
  --panel-w: 356px;
  --ctrl-w: 330px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden;
  font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg);
  background: #000; -webkit-text-size-adjust: 100%; }

/* ---------------------------------------------------------------- layout */
/* The sidebar slides out of the way; the stage reflows to full width.  Same
   mechanism on desktop and mobile, differing only in whether the stage is
   pushed across (desktop) or the panel floats over it (mobile). */
#panel { position: absolute; top: 0; left: 0; bottom: 0; width: var(--panel-w); z-index: 10;
  background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(-100%); transition: transform .18s ease; }
body.sidebar-open #panel { transform: none; }
#panel > .pad { padding: 12px 14px 40px; }
#panel h1 { font-size: 15px; margin: 0 0 2px; letter-spacing: -.01em; }
#panel .sub { color: var(--fg-dim); font-size: 11.5px; margin: 0 0 10px; }

#stage { position: absolute; top: 0; right: 0; bottom: 0; left: 0; transition: left .18s ease, right .18s ease; }
body.sidebar-open #stage { left: var(--panel-w); }
body.controls-open #stage { right: var(--ctrl-w); }

/* Right rail: layer controls.  Same slide mechanism, mirrored. */
#controls { position: absolute; top: 0; right: 0; bottom: 0; width: var(--ctrl-w); z-index: 10;
  background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(100%); transition: transform .18s ease; }
body.controls-open #controls { transform: none; }
#controls > .pad { padding: 6px 14px 40px; }
#controls .block:first-child { border-top: none; }
#controlsToggle { position: absolute; top: 50%; right: 0; z-index: 20; width: 24px; height: 58px;
  margin-top: -29px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 6px 0 0 6px; border-right: none; background: var(--bg2); color: var(--fg-dim);
  font-size: 13px; transition: right .18s ease; }
#controlsToggle:hover { color: var(--fg); background: var(--bg3); }
body.controls-open #controlsToggle { right: var(--ctrl-w); }

#sidebarToggle { position: absolute; top: 50%; left: 0; z-index: 20; width: 24px; height: 58px;
  margin-top: -29px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 0 6px 6px 0; border-left: none; background: var(--bg2); color: var(--fg-dim);
  font-size: 13px; transition: left .18s ease; }
#sidebarToggle:hover { color: var(--fg); background: var(--bg3); }
body.sidebar-open #sidebarToggle { left: var(--panel-w); }

#mapPre, #mapPost { position: absolute; inset: 0; }
/* The POST map sits on top.  Its canvas is clipped by the divider, so the div
   itself must not swallow clicks meant for the PRE map underneath. */
#mapPost { pointer-events: none; }
/* The canvas container has no intrinsic size (its canvas is absolutely positioned), so a
   clip-path on it would clip against a 0x0 box and hide the whole map. Size it first. */
#mapPost .maplibregl-canvas-container { position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: auto; clip-path: inset(0 0 0 50%); }
#mapPost .maplibregl-ctrl { pointer-events: auto; }
#mapPost .maplibregl-popup { pointer-events: auto; }
/* One attribution line at a time: whichever side is actually on screen. */
body:not([data-mode="pre"]) #mapPre .maplibregl-ctrl-attrib { display: none; }
body[data-mode="pre"] #mapPost .maplibregl-ctrl-attrib { display: none; }

#divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.55); cursor: ew-resize; z-index: 4; touch-action: none; }
#divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: -14px; right: -14px; }
#divider .knob { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; color: #12161c; font-size: 14px; }
body[data-mode="pre"] #divider, body[data-mode="post"] #divider { display: none; }

/* ------------------------------------------------------------ corner tags */
/* Each corner tag is a button plus a checkbox menu: it picks any number of
   imagery scenes for that side and carries the "Pre only" / "Post only" view
   options.  A white outline marks the side shown alone; in swipe mode both are
   plain.  The wrapper carries the position and the per-side colour, which the
   button inherits. */
.tagwrap { position: absolute; top: 10px; z-index: 6; max-width: 44%; }
.tag {
  display: block; max-width: 100%; color: inherit; text-align: left;
  padding: 3px 24px 3px 10px; border-radius: 4px; border: 1px solid transparent;
  font: inherit; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  background: rgba(12,17,22,.82) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238FA0AB' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 8px center;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.tag:hover { border-color: var(--accent); }
.tag:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tag.only { border-color: #e6ecf0; box-shadow: 0 0 0 1px rgba(230,236,240,.35); }
.tagwrap.open .tag { border-color: var(--accent); }
#tagPre { left: 12px; color: var(--pre); }
/* Clear the MapLibre top-right control column (29px buttons + 10px margin). */
#tagPost { right: 52px; color: var(--post); }
body[data-mode="pre"] #tagPost, body[data-mode="post"] #tagPre { opacity: .45; }

/* The scene menu: same checkbox rows as the sidebar overlay lists. */
.tagmenu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 240px; max-width: 78vw;
  max-height: 66vh; overflow-y: auto; z-index: 7;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 5px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); padding: 4px;
  color: var(--fg); font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none;
}
#tagPost .tagmenu { left: auto; right: 0; }
.tagmenu .tm-hd { font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--fg-dim); padding: 6px 4px 2px; }
.tagmenu .tm-empty { padding: 4px; color: var(--fg-dim); }
.tagmenu label.tm-row { display: flex; align-items: center; gap: 7px; padding: 3px 4px;
  cursor: pointer; border-radius: 3px; }
.tagmenu label.tm-row:hover { background: var(--bg); }
.tagmenu label.tm-row > span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagmenu .tm-item { display: block; width: 100%; text-align: left; padding: 3px 4px;
  background: none; border: 0; border-radius: 3px; color: inherit; font: inherit; cursor: pointer; }
.tagmenu .tm-item:hover { background: var(--bg); }
.tagmenu .tm-stackrow { display: flex; align-items: center; gap: 5px; padding: 3px 4px; }
.tagmenu .tm-stackrow > span.t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tagmenu .tm-arrow {
  flex: none; width: 18px; height: 18px; line-height: 16px; padding: 0; text-align: center;
  background: none; border: 1px solid var(--line); border-radius: 3px; color: inherit;
  font: inherit; font-size: 9px; cursor: pointer;
}
.tagmenu .tm-arrow:hover:not(:disabled) { background: var(--bg); border-color: var(--accent); }
.tagmenu .tm-arrow:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tagmenu .tm-arrow:disabled { opacity: .3; cursor: default; }

#readout { position: absolute; bottom: 8px; right: 10px; z-index: 3; font-size: 11.5px;
  background: rgba(18,22,28,.8); color: #cfd8e3; padding: 3px 8px; border-radius: 5px;
  font-variant-numeric: tabular-nums; pointer-events: none; }

/* --------------------------------------------------------------- controls */
.block { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.block > h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-dim);
  margin: 0 0 7px; font-weight: 600; }

button, select { font: inherit; color: var(--fg); background: var(--bg3); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 8px; cursor: pointer; }
button:hover, select:hover { border-color: #48566a; }
select { width: 100%; padding: 5px 7px; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg3);
  border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }

.seg { display: flex; gap: 0; }
.seg button { flex: 1; border-radius: 0; border-right-width: 0; }
.seg button:first-child { border-radius: 5px 0 0 5px; }
.seg button:last-child { border-radius: 0 5px 5px 0; border-right-width: 1px; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #08121e; font-weight: 600; }

.field { margin: 0 0 8px; }
.field label { display: block; font-size: 11px; color: var(--fg-dim); margin-bottom: 3px; }
.meta { font-size: 11px; color: var(--fg-dim); margin: 3px 0 0; }
.meta b { color: #cfd8e3; font-weight: 600; }
/* One block per selected scene, hairline-separated. */
.meta .metasep { border-top: 1px solid var(--line); margin: 6px 0; }
.meta .scenenote { display: block; margin-top: 2px; color: var(--fg-dim); opacity: .85; }
.side-pre b { color: var(--pre); }
.side-post b { color: var(--post); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { font-size: 11.5px; padding: 3px 8px; }

details { margin: 5px 0; }
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; font-size: 12.5px; list-style: none;
  display: flex; align-items: center; gap: 6px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--fg-dim); font-size: 10px; transition: transform .12s; }
details[open] > summary::before { transform: rotate(90deg); }
summary .n { color: var(--fg-dim); font-weight: 400; font-size: 11px; margin-left: auto; }
.grp { display: flex; gap: 6px; margin: 2px 0 5px 16px; }
.grp button { font-size: 10.5px; padding: 1px 6px; }

label.row { display: flex; align-items: center; gap: 7px; padding: 2px 4px; cursor: pointer;
  border-radius: 4px; white-space: nowrap; }
label.row:hover { background: var(--bg2); }
label.row > span.t { overflow: hidden; text-overflow: ellipsis; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; flex: none; }
.sw.outline { background: transparent !important; border: 2px solid; }
.cnt { color: var(--fg-dim); font-size: 10.5px; margin-left: auto; padding-left: 6px; font-variant-numeric: tabular-nums; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); margin: 0; flex: none; }

.legend { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; align-items: center; font-size: 11.5px; }
.legend .sw { width: 13px; height: 13px; }
.legend .hd { grid-column: 1 / -1; color: var(--fg-dim); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; margin-top: 6px; }

.note { font-size: 11px; color: var(--fg-dim); margin: 7px 0 0; }
.warn { font-size: 11px; color: #ffcf8a; background: rgba(255,182,77,.09); border: 1px solid rgba(255,182,77,.3);
  border-radius: 5px; padding: 6px 8px; margin: 7px 0 0; }
#notes h3 { font-size: 11.5px; margin: 10px 0 3px; color: var(--accent2); }
#notes p, #notes li { font-size: 11.5px; color: #b9c4d2; margin: 3px 0; }
#notes ul { margin: 3px 0; padding-left: 16px; }
#notes a, .note a, .warn a { color: var(--accent); }
#notes dl { margin: 3px 0; }
#notes dt { font-size: 11.5px; color: #dbe4ee; font-weight: 600; margin-top: 6px; }
#notes dd { font-size: 11px; color: #a9b5c4; margin: 1px 0 0 0; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 780px) {
  :root { --panel-w: min(88vw, 340px); }
  #panel { box-shadow: 0 0 24px rgba(0,0,0,.6); }
  :root { --ctrl-w: min(88vw, 340px); }
  #controls { box-shadow: 0 0 24px rgba(0,0,0,.6); }
  body.sidebar-open #stage { left: 0; }          /* the drawers float over the map */
  body.controls-open #stage { right: 0; }
  .tagwrap { max-width: 60%; }
  .tag { font-size: 11px; }
  #tagPost { top: 44px; right: auto; left: 12px; }   /* stack instead of overlapping */
  #tagPost .tagmenu { left: 0; right: auto; }
  #readout { display: none; }
}

/* ---------------------------------------------------------------- popups */
.maplibregl-popup-content { font: 12px/1.35 system-ui, sans-serif; max-height: 340px; overflow: auto;
  background: #fff; color: #111; border-radius: 6px; }
table.popup { border-collapse: collapse; }
table.popup th { text-align: left; color: #666; font-weight: 500; padding-right: 8px; vertical-align: top; }
table.popup td { word-break: break-word; }
.maplibregl-ctrl-scale { background: rgba(18,22,28,.75); color: #e7ecf3; border-color: #e7ecf3; }

/* ------------------------------------------------- search, panels, legend */
.search { position: relative; margin: 2px 0 8px; }
.search input { width: 100%; padding: 6px 9px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg3); color: var(--fg); font: inherit; }
.search input::placeholder { color: #6f7c8c; }
.results { max-height: 260px; overflow-y: auto; margin-top: 4px; }
.results:empty { display: none; }
.res { padding: 5px 8px; border-radius: 5px; cursor: pointer; border: 1px solid transparent; }
.res:hover, .res.on { background: var(--bg2); border-color: var(--line); }
.res b { font-weight: 600; }
.res .ne, .pop-h .ne { color: var(--fg-dim); font-weight: 400; }
.res .sub, .brow .sub { display: block; font-size: 10.5px; color: var(--fg-dim); }

.chip { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; margin-right: 5px; }
.chip.lg { width: auto; height: auto; padding: 1px 7px; border-radius: 999px; color: #0b0f14;
  font-size: 11px; font-weight: 600; margin: 4px 0 0; }
summary .n .chip { margin-left: 6px; }

.brow { display: flex; align-items: flex-start; gap: 2px; padding: 4px 6px; border-radius: 5px; cursor: pointer; }
.brow:hover { background: var(--bg2); }
.brow .chip { margin-top: 3px; }
.brow .t { min-width: 0; }
.lazy { max-height: 300px; overflow-y: auto; }

table.dmg { width: 100%; border-collapse: collapse; font-size: 11.5px; font-variant-numeric: tabular-nums; }
table.dmg th { text-align: right; color: var(--fg-dim); font-weight: 500; padding: 2px 4px; border-bottom: 1px solid var(--line); }
table.dmg th:first-child, table.dmg td:first-child { text-align: left; }
table.dmg td { text-align: right; padding: 2px 4px; border-bottom: 1px solid rgba(49,59,72,.5); }
.inview { font-size: 11.5px; color: #cfd8e3; margin: 7px 0 0; }

.roadlg .hd { color: var(--fg-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; margin-top: 8px; }
.roadlg .r { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 1px 0; }
.roadlg .rl { display: inline-block; width: 34px; flex: none; border-radius: 1px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.55); }
.roadlg .w1 { height: 1px; } .roadlg .w2 { height: 2px; }
.roadlg .w3 { height: 3px; } .roadlg .w4 { height: 4px; }
.roadlg .heavy { box-shadow: 0 0 0 2px rgba(0,0,0,.8); }
.roadlg .dash { background: repeating-linear-gradient(90deg, #fff 0 6px, transparent 6px 9px); }
.roadlg .dot { background: repeating-linear-gradient(90deg, #fff 0 1.5px, transparent 1.5px 4.5px); }
.roadlg .hw { background: #fbbf24; }
.roadlg .red { background: #ef4444; }
.roadlg .ems-destroyed { background: #ef4444; } .roadlg .ems-damaged { background: #f97316; }
.roadlg .ems-possible.dash { background: repeating-linear-gradient(90deg, #f59e0b 0 6px, transparent 6px 9px); }

.roadlg .r .note { font-size: 10.5px; color: var(--fg-dim); margin-left: 42px; }   /* align with text after the 34px swatch */
.roadlg .ct { background: #a9b45c; opacity: .75; height: 1px; box-shadow: none; }
.roadlg .ct.idx { background: #d3d47a; height: 2px; }

#toast { position: absolute; left: 50%; bottom: 24px; transform: translate(-50%, 8px); z-index: 40;
  background: rgba(18,22,28,.95); color: var(--fg); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 14px; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.pop-h { font-size: 13.5px; font-weight: 600; color: #111; margin-bottom: 1px; }
.pop-m { font-size: 11.5px; color: #555; }
.pop-all { margin-top: 6px; }
.pop-all > summary { cursor: pointer; font-size: 11.5px; color: #555; font-weight: 500; }
.pop-all table { margin-top: 4px; }

/* HOT category list: extent / source switches sit inside the group */
details .field.hotseg { margin: 3px 0 5px 16px; }
details .field.hotseg .seg button { font-size: 11px; padding: 3px 6px; }
label.row[hidden] { display: none !important; }

/* ------------------------------------------------------- damage editor */
/* Floating controls for the in-progress polygon; sits over the stage so it is
   reachable whichever side of the divider the ring is being drawn on. */
#drawBar { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px;
  background: rgba(18,22,28,.94); border: 1px solid var(--line); box-shadow: 0 2px 12px rgba(0,0,0,.5); }
#drawBar[hidden] { display: none; }
#drawBar .dn { font-size: 11.5px; color: var(--fg-dim); font-variant-numeric: tabular-nums; padding: 0 4px; }
#drawBar button { font-size: 11.5px; padding: 3px 9px; }
#drawBar button:disabled { opacity: .45; cursor: default; }

.dmgform { border: 1px solid var(--line); border-radius: 6px; background: var(--bg2);
  padding: 7px 8px 8px; margin: 7px 0; }
.dmgform[hidden] { display: none; }
.dmgform .dmg-h { font-size: 12.5px; font-weight: 600; }
.dmgform .meta { margin: 1px 0 6px; word-break: break-all; }
.dmgform .seg button { font-size: 11px; padding: 3px 4px; }
.dmgform textarea { width: 100%; margin-top: 6px; padding: 5px 7px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--bg3); color: var(--fg); font: inherit; resize: vertical; }
.dmgform textarea::placeholder { color: #6f7c8c; }
.dmgform .chips { margin-top: 6px; }

.dmg-counts { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 3px; }
.dmg-counts .chip.lg { margin: 0; }
.dmg-list { margin-top: 2px; }
.dmg-list .brow { align-items: center; }
.dmg-list .brow .t { flex: 1; }
.dmg-list .acts { display: flex; gap: 4px; margin-left: auto; padding-left: 6px; }
button.mini { font-size: 10.5px; padding: 1px 6px; line-height: 1.4; }
#dmgEd code { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: #cfd8e3; }
.dmg-list .brow.on { background: var(--bg3); box-shadow: inset 2px 0 0 var(--accent); }

/* --------------------------------------------------------- image align */
/* Owner tool for hand-fitting an ungeoreferenced photo; same rail and same
   details/field furniture as the damage editor above. */
.imgal .ia-row { display: flex; gap: 5px; }
.imgal .ia-row input[type=text] { flex: 1; min-width: 0; }
.imgal .ia-row button { flex: none; }
.imgal input[type=text] { font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--fg); background: var(--bg3); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 7px; width: 100%; }
.imgal input[type=range] { width: 100%; accent-color: var(--accent); margin: 2px 0 0; }
.imgal .ia-n { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.imgal .ia-btns { margin-top: 5px; }
.imgal .ia-btns button { font-variant-numeric: tabular-nums; }
.imgal textarea { width: 100%; margin-top: 8px; padding: 5px 7px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--bg3); color: var(--fg);
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
#imgAl code { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: #cfd8e3; }

/* Master transparency for the damage / ground-report overlay group. */
.field.ovop { margin: 2px 0 6px 16px; }
.field.ovop label { display: flex; align-items: center; gap: 6px; }
.field.ovop .ovop-n { margin-left: auto; font-variant-numeric: tabular-nums; }
.field.ovop input[type=range] { width: 100%; accent-color: var(--accent); margin: 1px 0 0; }
