:root {
  --bg: #f4f6f8; --surface: #ffffff; --ink: #14212b; --muted: #5a6b78; --line: #d8dee4;
  --accent: #0b5c94; --accent-ink: #ffffff; --ok: #1d7a46; --warn: #a15c00; --err: #b3261e;
  --warning: #f99028; --danger: #ff2c0f; --extreme: #92000a; --chip: #eef2f5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1418; --surface: #182027; --ink: #e6edf2; --muted: #9aabb8; --line: #2c3740;
    --accent: #5aa9e6; --accent-ink: #08131c; --ok: #5fc48a; --warn: #f0b45a; --err: #ff8a80; --chip: #222c34;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1418; --surface: #182027; --ink: #e6edf2; --muted: #9aabb8; --line: #2c3740;
  --accent: #5aa9e6; --accent-ink: #08131c; --ok: #5fc48a; --warn: #f0b45a; --err: #ff8a80; --chip: #222c34;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { border-radius: 8px; }
h1 { font-size: 18px; margin: 0; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.intro p { margin: 0 0 12px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.panel { margin-top: 16px; }
.cardHead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.tabs button { border: 1px solid var(--line); background: var(--chip); color: var(--ink); padding: 4px 10px; cursor: pointer; }
.tabs button:first-child { border-radius: 6px 0 0 6px; }
.tabs button:last-child { border-radius: 0 6px 6px 0; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.drop { display: block; border: 2px dashed var(--line); border-radius: 8px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; margin-top: 10px; }
.drop.over { border-color: var(--accent); color: var(--ink); }
.tracePreview { width: 100%; max-width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
label { display: block; font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; margin-top: 2px; }
input:disabled, select:disabled { opacity: 0.75; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.span2 { grid-column: span 2; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td input { padding: 3px 5px; }
td input[type="checkbox"] { width: auto; }
.rows td:nth-child(4) input, .rows td:nth-child(5) input { max-width: 90px; }
.rows td:nth-child(3) input { min-width: 125px; }
.rows, .thr { display: block; overflow-x: auto; }
.lvl { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.kind { font-size: 12px; padding: 1px 6px; border-radius: 10px; background: var(--chip); white-space: nowrap; }
.kind.forecast { color: var(--warn); }
.kind.undated { color: var(--muted); }
button { font: inherit; border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.rowTools { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; flex-wrap: wrap; }
.paste { flex: 1; min-width: 200px; }
.flags { padding-left: 18px; color: var(--warn); font-size: 13px; }
.flags li.err { color: var(--err); }
.confirmRow { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.confirmState.ok { color: var(--ok); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--ok); } .err { color: var(--err); } .warn { color: var(--warn); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--ok); }
.badge.off { color: var(--warn); }
.status { padding: 8px 10px; border-radius: 6px; background: var(--chip); margin: 8px 0; }
.status.err { border-left: 3px solid var(--err); }
.status.ok { border-left: 3px solid var(--ok); }
.status.warn { border-left: 3px solid var(--warn); }
.settings summary { cursor: pointer; font-weight: 600; }
footer { max-width: 1200px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: 12px; }
code { background: var(--chip); padding: 0 4px; border-radius: 4px; }

.lbl { display: block; font-size: 13px; color: var(--muted); }
.dnName { padding: 6px 0; font-weight: 600; }
h2.step { margin: 18px 0 10px; }
.segPick { margin: 0 0 16px; }
.disabledDrop { opacity: 0.5; }
.prof { width: 100%; height: auto; background: var(--surface); }
.prof .grid { stroke: var(--line); stroke-width: 1; }
.prof .ax { fill: var(--muted); font-size: 12px; }
.prof .band { fill: #5aa9e6; opacity: 0.35; }
.prof .med { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.prof .gauge { fill: var(--ink); }
.runBar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }
.runBar label { width: auto; }
#nodeTable table { display: block; overflow-x: auto; }
.rows, .thr, #nodeTable table { max-width: 100%; }
.status, .muted, .flags { overflow-wrap: anywhere; }
.prof .ttl { fill: var(--ink); font-weight: 600; }
.profWrap { position: relative; }
.tip { position: absolute; z-index: 3; width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.15); pointer-events: none; }
.prof .hoverLine { stroke: var(--muted); stroke-dasharray: 3 3; }
.prof .selLine { stroke: var(--ink); stroke-opacity: 0.55; stroke-width: 1.2; stroke-dasharray: 2 3; }
.prof .whisk { stroke: var(--accent); stroke-width: 1.5; }
.prof .bandR { fill: #5aa9e6; opacity: 0.35; }
.prof .medDot { fill: var(--accent); }
.prof .hit { cursor: crosshair; }
.nodePanel { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.nodePanel table { display: block; overflow-x: auto; max-width: 100%; }

/* 0.2: modes, compact cards, reference-style profile */
.modeTabs { margin-bottom: 12px; }
.pickRow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .pickRow { grid-template-columns: 1fr; } }
#cards.cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.card h3 { margin: 0; font-size: 15px; }
.gmeta { margin-top: 2px; }
.rows td:nth-child(1) input[type="date"] { min-width: 140px; }
.rows input[type="number"] { max-width: 110px; }
.thrLine { margin-top: 6px; }
.profHead { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.prof .frame { fill: none; stroke: var(--muted); stroke-width: 1; }
.prof .gline { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1.2; }
.prof .glab { fill: var(--ink); font-size: 12px; }
.prof .gap { fill: var(--chip); opacity: 0.7; }
.prof .obs { fill: #e8892b; stroke: #6b3a07; stroke-width: 1; }
.prof .gauge { fill: var(--ink); }
.prof .lgbox { fill: var(--surface); stroke: var(--line); }
.prof .hoverDot { fill: #ffffff; stroke: #0a2a8a; stroke-width: 2; }
.prof .ttl { fill: var(--ink); font-weight: 600; font-size: 15px; }
.prof .med { stroke: #0a2a8a; stroke-width: 1.8; }
:root[data-theme="dark"] .prof .med { stroke: #8fb8ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .prof .med { stroke: #8fb8ff; } }
details.panel summary { cursor: pointer; font-weight: 600; }
@media (max-width: 700px) { #profile { overflow-x: auto; } #profile svg { min-width: 720px; } }

/* 0.3: top tabs, water-style profile, map, interactive node chart */
:root { --sky1: #eef7ff; --sky2: #ffffff; }
:root[data-theme="dark"] { --sky1: #1c2b38; --sky2: #182027; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sky1: #1c2b38; --sky2: #182027; } }
.top { position: static; }
.appTabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.appTabs button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 14px; background: var(--chip); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.appTabs button .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 12px; }
.appTabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.appTabs button[aria-selected="true"] .n { background: rgba(255,255,255,.25); color: var(--accent-ink); }
.appTabs button:disabled { opacity: .45; }
.view[hidden] { display: none !important; }
.readyBar { position: sticky; bottom: 0; margin-top: 16px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--accent); border-radius: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 -2px 10px rgba(0,0,0,.08); }
.prof .water { fill: url(#gWater); }
.prof .waves { fill: url(#pWave); }
.prof .band { fill: #8fdcff; fill-opacity: 0.55; stroke: #ffffff; stroke-opacity: 0.7; stroke-width: 0.6; }
.prof .lgband { fill: #8fdcff; fill-opacity: 0.9; stroke: #5aa9e6; }
.prof .grid { stroke: var(--line); stroke-opacity: 0.6; }
.prof .naText { fill: var(--muted); font-size: 13px; font-style: italic; }
.prof .naLine { stroke: var(--muted); stroke-dasharray: 2 4; }
.prof .brush { fill: #d0008f; fill-opacity: 0.12; stroke: #d0008f; }
.na { padding: 60px 10px; text-align: center; color: var(--warn); font-size: 18px; border: 1px dashed var(--line); border-radius: 8px; }
.naRow td { color: var(--muted); font-style: italic; }
.zoomBtns { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.zoomBtns button { padding: 4px 10px; }
#map { width: 100%; height: min(70vh, 620px); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #dfe9f2; }
.mapLegend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--muted); }
.mapLegend .ramp { width: 140px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #0b3d91, #22a6c9, #f2e35c); }
.mapLegend .naDot { width: 10px; height: 10px; border-radius: 50%; background: #9aa5ae; display: inline-block; }
.gMark { background: rgba(10, 30, 50, .82); color: #fff; padding: 3px 7px; border-radius: 6px; font-size: 12px; line-height: 1.25; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); pointer-events: none; }
.gMark.val { background: rgba(160, 80, 10, .88); }
.mapPop .maplibregl-popup-content { font-size: 12px; line-height: 1.4; color: #14212b; }
.nsWrap { position: relative; }
.prof.ns .nsHit { cursor: crosshair; }
.dlGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.dlGrid button { margin: 4px 4px 0 0; }

[hidden] { display: none !important; }
/* strict screenshot gauge check */
.gaugeAlert { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0; padding: 12px 14px; border: 2px solid #d32f2f; border-radius: 10px; background: #fdecec; color: #b71c1c; }
.gaugeAlert .triIcon { flex: 0 0 auto; color: #d32f2f; }
.gaugeAlert strong { font-size: 15px; }
.gaugeAlert p { margin: 4px 0; color: #7f1414; }
.gaugeAlert ul { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; color: #7f1414; }
.gaugeAlert .reupload { margin-top: 4px; }
:root[data-theme="dark"] .gaugeAlert { background: #3a1414; color: #ffb4b4; }
:root[data-theme="dark"] .gaugeAlert p, :root[data-theme="dark"] .gaugeAlert ul { color: #ffcdcd; }
:root[data-theme="dark"] .gaugeAlert .triIcon { color: #ff6b6b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gaugeAlert { background: #3a1414; color: #ffb4b4; }
  :root:not([data-theme="light"]) .gaugeAlert p, :root:not([data-theme="light"]) .gaugeAlert ul { color: #ffcdcd; }
  :root:not([data-theme="light"]) .gaugeAlert .triIcon { color: #ff6b6b; }
}

/* 0.4: theme toggle, credit, flowing water, flood levels */
:root { --lv-warning: #f2c200; --lv-danger: #ff7a00; --lv-extreme: #e3122a; }
.topRight { display: flex; align-items: center; gap: 8px; }
.themeBtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.themeBtn:hover { border-color: var(--accent); }
.guideBtn { text-decoration: none; white-space: nowrap; }
.guideBtn .gShort { display: none; }
@media (max-width: 480px) { .guideBtn .gLong { display: none; } .guideBtn .gShort { display: inline; } }
body { padding-bottom: 56px; }
.credit { position: fixed; right: 12px; bottom: 10px; z-index: 20; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; text-decoration: none; box-shadow: 0 2px 10px rgba(0,0,0,.18); max-width: calc(100vw - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credit:hover { border-color: var(--accent); }
.credit .creditUrl { color: var(--accent); margin-left: 6px; text-decoration: underline; }
@media (max-width: 480px) { .credit { font-size: 12px; padding: 5px 10px; } }
.chk { display: inline-flex; align-items: center; gap: 6px; width: auto; color: var(--ink); padding-bottom: 6px; }
.chk input { width: auto; margin: 0; }
.prof .waves2 { fill: url(#pWave2); }
.prof .flow { fill: none; stroke: #e6f6ff; stroke-opacity: 0.55; stroke-width: 1.4; stroke-dasharray: 3 22; stroke-linecap: round; animation: fiFlow 1.6s linear infinite; }
@keyframes fiFlow { to { stroke-dashoffset: -25; } }
.prof.rise .water, .prof.rise .waves, .prof.rise .waves2 { transform-box: fill-box; transform-origin: 50% 100%; animation: fiRise 1.1s cubic-bezier(.2,.8,.2,1) both; }
.prof.rise .band, .prof.rise .med, .prof.rise .flow { animation: fiFade 1.3s ease-out both; }
.prof.rise .flow { animation: fiFade 1.3s ease-out both, fiFlow 1.6s linear 1.3s infinite; }
@keyframes fiRise { from { transform: scaleY(0.03); } }
@keyframes fiFade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .prof .flow { animation: none; display: none; } .prof.rise * { animation: none !important; } }
.prof .lvl { fill: none; stroke-width: 1.7; stroke-dasharray: 7 4; }
.prof .lvTick { stroke-width: 3.2; stroke-linecap: round; }
.prof .lv-warning { stroke: var(--lv-warning); }
.prof .lv-danger { stroke: var(--lv-danger); }
.prof .lv-extreme { stroke: var(--lv-extreme); }
.prof .lvStrip { stroke: none; opacity: 0.9; }
.prof .lvStrip.lv-warning { fill: var(--lv-warning); }
.prof .lvStrip.lv-danger { fill: var(--lv-danger); }
.prof .lvStrip.lv-extreme { fill: var(--lv-extreme); }
.prof .selLab { fill: var(--ink); font-size: 11px; opacity: 0.8; }
.lvTxt { font-weight: 600; padding: 0 4px; border-radius: 3px; color: #1a1300; }
.lvTxt.lv-warning { background: var(--lv-warning); }
.lvTxt.lv-danger { background: var(--lv-danger); }
.lvTxt.lv-extreme { background: var(--lv-extreme); color: #fff; }
.lvAlert { color: var(--lv-danger); font-weight: 600; }

/* 0.5: plot style, bar + box charts, compare */
.prof text { font-family: var(--ff-chart, inherit); }
.prof .tk { font-size: var(--fs-tick, 12px); }
.prof .atl { font-size: var(--fs-axis, 12px); }
.prof .ttl { font-size: var(--fs-title, 15px); }
.prof .bbBg { fill: var(--sky1); opacity: 0.5; }
.prof .bbBar { fill-opacity: 0.28; stroke: none; }
.prof .bbBox { fill: var(--surface); stroke-width: 1.6; }
.prof .bbMed { stroke-width: 2.6; }
.prof .bbWhisk { stroke-width: 1.4; }
.prof .bbCap { stroke-width: 1.6; }
.prof .naText.small { font-size: 10px; }
.chartHost svg { width: 100%; height: auto; display: block; }
.styleBtn::before { content: "⚙ "; }
.stylePanel { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 10px; background: var(--chip); }
.spHead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spHead .sClose { margin-left: auto; border: 0; background: transparent; color: var(--ink); font-size: 20px; cursor: pointer; }
.stylePanel h4 { margin: 12px 0 4px; font-size: 13px; }
.sGrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 8px; margin-top: 8px; }
.cmpAdd { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin: 8px 0; }
.cmpAdd label { flex: 1 1 240px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--chip); font-size: 13px; }
.chip button { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 6px; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.cmpTable table { display: block; overflow-x: auto; max-width: 100%; margin-top: 10px; }
.cmpTable td, .cmpTable th { white-space: nowrap; }
#cmpChart .na, #nsChart .na { padding: 40px 10px; text-align: center; color: var(--muted); }
#ctip { width: 300px; }
