:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #6b665e;
  --line: #e4e0d8;
  --accent: #6a3fb5;
  --accent-text: #ffffff;
  --effect: #2f6f5e;
  --flag-bg: #fff1c2;
  --flag-text: #6b4e00;
  --error: #b3261e;
  --logo: #1b3a6b;
  --map-alloc: #d9480f;
  --map-natural: #0b7285;
  --map-reported: #7048e8;
  --pressure-0: #2b8a3e;
  --pressure-1: #94d82d;
  --pressure-2: #fab005;
  --pressure-3: #f76707;
  --pressure-4: #c92a2a;
  --map-gauged: #1c5fbf;
  --map-est: #5aa9e6;
  --map-licence: #e8590c;
  --map-licence-other: #868e96;
  --map-gauge: #1c5fbf;
  --map-marker-edge: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17161a;
    --surface: #211f25;
    --text: #ece9f2;
    --muted: #a39fac;
    --line: #36333c;
    --accent: #b49cf0;
    --accent-text: #17161a;
    --effect: #7cc9b1;
    --flag-bg: #4a3c10;
    --flag-text: #ffe08a;
    --error: #ff8a80;
    --logo: #8fb3ea;
    --map-alloc: #ff8c42;
    --map-natural: #3bc9db;
    --map-reported: #b197fc;
    --pressure-0: #51cf66;
    --pressure-1: #c0eb75;
    --pressure-2: #ffd43b;
    --pressure-3: #ff922b;
    --pressure-4: #ff6b6b;
    --map-gauged: #4d9fff;
    --map-est: #8cc8f5;
    --map-licence: #ff8c42;
    --map-licence-other: #adb5bd;
    --map-gauge: #4d9fff;
    --map-marker-edge: #17161a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17161a; --surface: #211f25; --text: #ece9f2; --muted: #a39fac; --line: #36333c;
  --accent: #b49cf0; --accent-text: #17161a; --effect: #7cc9b1; --flag-bg: #4a3c10; --flag-text: #ffe08a;
  --error: #ff8a80; color-scheme: dark;
  --logo: #8fb3ea; --map-natural: #3bc9db; --map-reported: #b197fc; --pressure-0: #51cf66; --pressure-1: #c0eb75; --pressure-2: #ffd43b;
  --pressure-3: #ff922b; --pressure-4: #ff6b6b; --map-alloc: #ff8c42; --map-gauged: #4d9fff; --map-est: #8cc8f5; --map-licence: #ff8c42; --map-licence-other: #adb5bd;
  --map-gauge: #4d9fff; --map-marker-edge: #17161a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
html { height: 100%; }
body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
/* Content columns stay readable; the scroll container itself spans the full width. */
main { flex: 1 1 auto; min-height: 0; overflow-y: auto; width: 100%;
       padding: 16px max(16px, calc((100% - 760px) / 2)) 64px; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 6px; }
.top { display: flex; gap: 20px; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.top .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.top nav a, .filters a { margin-right: 14px; text-decoration: none; color: var(--muted); }
.top nav a[aria-current], .filters a[aria-current] { color: var(--text); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }
.messages { list-style: none; padding: 0; }
.messages .error { color: var(--error); }

.statement { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.said { margin: 0 0 6px; font-weight: 600; }
.source { font-size: 0.75rem; font-weight: 600; color: var(--effect); border: 1px solid var(--effect); border-radius: 6px; padding: 0 5px; vertical-align: 1px; }
.trend { color: var(--effect); }
.summary { margin: 0 0 6px; color: var(--muted); }
.changes { list-style: none; margin: 0; padding: 0; }
.change { padding: 2px 0 2px calc(var(--depth, 0) * 18px); }
.change a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--line); }
.change .via { color: var(--effect); margin-right: 4px; }
.change.node_created::before { content: "+ "; color: var(--accent); }
.change.question_asked { color: var(--flag-text); }
.change.note { color: var(--muted); font-size: 0.9rem; }

.questions .question { background: var(--flag-bg); color: var(--flag-text); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.questions .question p { margin: 0 0 8px; }
.answer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.answer input[type=text] { flex: 1 1 200px; }
.inline { display: inline-flex; gap: 6px; align-items: center; font-size: 0.9rem; }

.ask { margin-top: 24px; }
.ask label { display: block; font-size: 1.3rem; font-weight: 600; margin-bottom: 8px; }
.row { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
textarea, input[type=text], input[type=date], input[type=email], input[type=password] { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input[type=date] { width: auto; padding: 4px 6px; }
button { font: inherit; border: 0; border-radius: 8px; padding: 7px 14px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
button.secondary { background: transparent; color: inherit; border: 1px solid currentColor; }
button:disabled { opacity: 0.6; cursor: progress; }

.node { border-bottom: 1px solid var(--line); padding: 8px 0 12px; }
.node h2 { margin: 6px 0; }
.node h2 a { color: var(--text); text-decoration: none; }
.kind { font-size: 0.75rem; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 4px 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 4px 0; }
.plain li.ended { color: var(--muted); text-decoration: line-through; }
.links li { color: var(--effect); }
.flag { background: var(--flag-bg); color: var(--flag-text); border-radius: 999px; padding: 0 8px; font-size: 0.8rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 4px 8px 4px 0; vertical-align: top; }
@media (max-width: 520px) { table { display: block; overflow-x: auto; } }

.query { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.query .asked { margin: 0 0 6px; font-weight: 600; }
.query .reply p { margin: 0 0 8px; }
.query .reply p:last-child { margin-bottom: 0; }
.query details { margin-top: 6px; }
.reading { padding: 8px 14px; }
.reading summary { cursor: pointer; color: var(--muted); }
.reading details p { margin: 6px 0 0; }

/* accounts */
.top { align-items: center; }
.top .who { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.top .who form { margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
main.narrow { padding-inline: max(16px, calc((100% - 440px) / 2)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 12px 0; }
.card label { display: block; font-size: 0.9rem; color: var(--muted); margin: 10px 0 4px; }
.card label:first-of-type { margin-top: 0; }
.card .row { margin-top: 14px; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.messages li { margin: 6px 0; }
.messages .success { color: var(--effect); }

/* landing: the hero (branding to come) */
main.landing { padding: 0; }
.hero { position: relative; overflow: hidden; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
        background: var(--surface); border-bottom: 1px solid var(--line); }
.hero-body { text-align: center; max-width: 520px; }
.hero-note { color: var(--muted); }
.cta { display: inline-block; background: var(--accent); color: var(--accent-text); text-decoration: none; font-weight: 600;
       font-size: 1.1rem; border-radius: 10px; padding: 12px 28px; }
.cta:hover, .cta:focus-visible { filter: brightness(1.08); }

/* the superuser's console: side nav and client area */
.console { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.sidenav { border-right: 1px solid var(--line); background: var(--surface); padding: 14px 0; overflow-y: auto; min-height: 0; }
.sidenav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; color: var(--muted);
             text-decoration: none; }
.sidenav a[aria-current] { color: var(--text); font-weight: 600; background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.sidenav a:hover { color: var(--text); }
.console .client { min-height: 0; overflow-y: auto; padding: 16px max(24px, calc(100% - 980px)) 64px 24px; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; font-size: 0.75rem; font-weight: 600;
         padding: 0 7px; min-width: 20px; text-align: center; }
table.users td form { margin: 0; }
table.users button { padding: 4px 12px; }
@media (max-width: 720px) {
  .console { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidenav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .sidenav a { padding: 10px 14px; white-space: nowrap; gap: 6px; }
  .sidenav a[aria-current] { box-shadow: inset 0 -3px 0 var(--accent); }
  .console .client { padding: 16px; }
}

/* side nav for everyone logged in */
.sidenav-heading { margin: 14px 16px 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.below-hero { padding: 24px 16px 40px; text-align: center; }

/* the water map */
main.map { padding: 0; overflow: hidden; }
.console main.client.map { padding: 0; overflow: hidden; }
.map-wrap { position: relative; height: 100%; }
#map { position: absolute; inset: 0; }
.map-empty { padding: 16px 24px; }
.map-panel { position: absolute; top: 12px; left: 12px; width: 290px; max-height: calc(100% - 24px); overflow: auto;
             background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
             padding: 12px 14px; box-shadow: 0 2px 10px rgb(0 0 0 / 0.12); font-size: 0.92rem; }
.map-panel h1 { font-size: 1rem; margin: 0 0 8px; }
.map-panel fieldset { border: 0; padding: 0; margin: 0 0 10px; }
.map-panel legend { font-size: 0.8rem; color: var(--muted); margin-bottom: 2px; }
.map-panel label { display: flex; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
.swatch { display: inline-block; width: 22px; height: 5px; border-radius: 3px; }
.swatch.alloc { background: var(--map-alloc); } .swatch.gauged { background: var(--map-gauged); } .swatch.est { background: var(--map-est); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--map-marker-edge); }
.dot.licence { background: var(--map-licence); } .dot.gauge { background: var(--map-gauge); }
.widths { display: flex; align-items: flex-end; gap: 10px; font-size: 0.75rem; color: var(--muted); margin: 4px 0 8px; }
.widths span { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.widths i { display: block; width: 26px; background: var(--muted); border-radius: 3px; }
.map-panel details p { margin: 6px 0; }
dialog#licence-dialog { max-width: 520px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 12px;
                        background: var(--surface); color: var(--text); padding: 16px 18px; }
dialog#licence-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
dialog#licence-dialog h2 { margin: 0 0 10px; }
.dialog-close { float: right; margin: 0 0 0 8px; }
.dialog-close button { padding: 3px 10px; }
.maplibregl-popup-content { background: var(--surface); color: var(--text); font: 0.88rem/1.4 system-ui, sans-serif; }
@media (max-width: 720px) {
  .map-panel { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 45%; }
}

/* logo: line art after Belenois calypso (templates/logo.svg, drawn in currentColor) */
.top .brand { display: inline-flex; align-items: center; gap: 8px; }
.logo { display: inline-flex; color: var(--logo); }
.logo svg { width: 34px; height: auto; }
.sources ul { padding-left: 16px; margin: 6px 0; }
.sources li { margin: 4px 0; }

/* the hero's logo: three overlapping copies in its upper left */
.logo-stack { position: absolute; top: clamp(16px, 4vw, 40px); left: clamp(16px, 4vw, 40px);
              width: clamp(120px, 20vw, 240px); aspect-ratio: 120 / 104; color: var(--logo); pointer-events: none; }
.logo-stack .layer { position: absolute; inset: 0; }
.logo-stack svg { display: block; width: 100%; height: auto; }
.logo-stack .silhouette { fill: var(--surface); }
.logo-stack .layer-2 { transform: translateX(20%); filter: saturate(0.75); }
.logo-stack .layer-3 { transform: translateX(40%); filter: saturate(0.5); }
.swatch.natural { background: var(--map-natural); }
.pressure-scale { display: flex; gap: 2px; margin: 4px 0 2px 26px; font-size: 0.72rem; }
.pressure-scale span { flex: 1; text-align: center; color: #111; border-radius: 3px; padding: 1px 0; }
.inline-check { display: flex !important; gap: 8px; align-items: flex-start; color: var(--text) !important; margin: 10px 0 4px !important; }
.inline-check input { width: auto; margin-top: 4px; }
fieldset.choices { border: 0; padding: 0; margin: 0 0 6px; }
fieldset.choices legend { font-size: 0.9rem; color: var(--muted); margin-bottom: 2px; }
td.actions { display: flex; gap: 6px; }
td.actions form { margin: 0; }
tr.ended td { color: var(--muted); text-decoration: line-through; }
.card select, .card input[type=number] { width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.swatch.reported { background: var(--map-reported); }
