:root {
  --sea:#D7E3E8; --sea-2:#C8D8DF; --land:#F5F7F4; --land-line:#A9BDC6;
  --ink:#14222A; --ink-soft:#5B707A; --ink-faint:#8CA1AB;
  --panel:#FFFFFF; --panel-line:#D8E2E6; --panel-sub:#EDF2F3;
  --visited:#0E7C6B; --pending:#B06A12; --focus:#0E7C6B; --danger:#B3261E;
  --shadow:0 1px 2px rgba(20,34,42,.06), 0 8px 24px rgba(20,34,42,.07);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Consolas, "Roboto Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sea:#0A1418; --sea-2:#071013; --land:#17272D; --land-line:#31474F;
    --ink:#DEEAEE; --ink-soft:#8CA5AF; --ink-faint:#61797F;
    --panel:#0F1D22; --panel-line:#25383F; --panel-sub:#16272D;
    --visited:#35B7A0; --pending:#E0A44A; --focus:#35B7A0; --danger:#F2B8B5;
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="light"] {
  --sea:#D7E3E8; --sea-2:#C8D8DF; --land:#F5F7F4; --land-line:#A9BDC6;
  --ink:#14222A; --ink-soft:#5B707A; --ink-faint:#8CA1AB;
  --panel:#FFFFFF; --panel-line:#D8E2E6; --panel-sub:#EDF2F3;
  --visited:#0E7C6B; --pending:#B06A12; --focus:#0E7C6B; --danger:#B3261E;
  --shadow:0 1px 2px rgba(20,34,42,.06), 0 8px 24px rgba(20,34,42,.07);
}
:root[data-theme="dark"] {
  --sea:#0A1418; --sea-2:#071013; --land:#17272D; --land-line:#31474F;
  --ink:#DEEAEE; --ink-soft:#8CA5AF; --ink-faint:#61797F;
  --panel:#0F1D22; --panel-line:#25383F; --panel-sub:#16272D;
  --visited:#35B7A0; --pending:#E0A44A; --focus:#35B7A0; --danger:#F2B8B5;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--sea-2); color: var(--ink);
  font-family: var(--sans); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 16px 36px;
        display: flex; flex-direction: column; gap: 16px; }

/* ---------- header ---------- */
header { display: flex; flex-direction: column; gap: 12px; }
.topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .16em;
           text-transform: uppercase; color: var(--ink-faint); }
h1 { font-family: var(--mono); font-size: clamp(19px, 2.4vw, 28px); font-weight: 600;
     letter-spacing: -.01em; margin: 2px 0 0; text-wrap: balance; }
h1 .yr { color: var(--ink-faint); font-weight: 400; }

.hbtns { display: flex; gap: 8px; align-items: center; }
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 3px;
  padding: 7px 11px; cursor: pointer; color: var(--ink-soft);
}
.btn:hover { background: var(--panel-sub); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.go { background: var(--visited); border-color: var(--visited); color: #fff; }
.btn.go:hover { filter: brightness(1.08); background: var(--visited); color: #fff; }

.stats { display: flex; flex-wrap: wrap; gap: 9px; }
.stat { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 3px;
        padding: 8px 13px; display: flex; flex-direction: column; gap: 1px; min-width: 100px; }
.stat b { font-family: var(--mono); font-size: 18px; font-weight: 600;
          font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
             text-transform: uppercase; color: var(--ink-faint); }
.stat.done b { color: var(--visited); }
.stat.todo b { color: var(--pending); }

/* ---------- target progress ---------- */
.progress { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px;
            align-items: center; background: var(--panel); border: 1px solid var(--panel-line);
            border-radius: 3px; padding: 12px 14px; }
@media (max-width: 620px) { .progress { grid-template-columns: minmax(0,1fr); } }
.pmain { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ptop { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.plabel { font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
          text-transform: uppercase; color: var(--ink-faint); }
.pval { font-family: var(--mono); font-size: 12px; color: var(--ink-faint);
        font-variant-numeric: tabular-nums; white-space: nowrap; }
.pval b { font-size: 15px; color: var(--visited); font-weight: 600; }
.track { height: 9px; background: var(--panel-sub); border: 1px solid var(--panel-line);
         border-radius: 5px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--visited); border-radius: 5px 0 0 5px;
        transition: width .45s ease; }
.fill.over { background: var(--pending); }
.pfoot { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); }

.tgt { display: flex; flex-direction: column; gap: 4px; }
.tgt label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
             text-transform: uppercase; color: var(--ink-faint); }
.trow { display: flex; gap: 6px; }
.trow input { width: 110px; padding: 6px 8px; font-size: 12.5px; background: var(--panel-sub);
              border: 1px solid var(--panel-line); border-radius: 3px;
              font-variant-numeric: tabular-nums; }
.trow input:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
#tmsg { font-family: var(--mono); font-size: 10px; min-height: 13px; }
#tmsg.ok { color: var(--visited); }
#tmsg.err { color: var(--danger); }

/* ---------- layout ---------- */
.grid { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .grid { grid-template-columns: minmax(0,1fr); } }

/* ---------- map ---------- */
.mapcard { position: relative; background: var(--sea); border: 1px solid var(--panel-line);
           border-radius: 4px; overflow: hidden; box-shadow: var(--shadow); }
svg#map { display: block; width: 100%; height: auto; touch-action: none; cursor: grab; }
svg#map.drag { cursor: grabbing; }
.land { fill: var(--land); stroke: var(--land-line); stroke-width: .7; stroke-linejoin: round; }
.dot { stroke: var(--land); stroke-width: 1.1; cursor: pointer; transition: opacity .14s ease; }
.dot.v { fill: var(--visited); }
.dot.p { fill: var(--pending); }
.dot.dim { opacity: .13; pointer-events: none; }
.dot:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ring { fill: none; stroke: var(--ink); stroke-width: 1.6; pointer-events: none; opacity: 0; }
.ring.on { opacity: .85; }
.sel { fill: none; stroke: var(--focus); stroke-width: 2.2; pointer-events: none; opacity: 0; }
.sel.on { opacity: 1; }

.legend, .zoomer { position: absolute; background: var(--panel);
                   border: 1px solid var(--panel-line); border-radius: 3px; box-shadow: var(--shadow); }
.legend { left: 12px; bottom: 12px; padding: 10px 12px; display: flex; flex-direction: column;
          gap: 7px; font-family: var(--mono); font-size: 11px; }
.legend .row { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.legend .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend .sw.v { background: var(--visited); }
.legend .sw.p { background: var(--pending); }
.legend .note { border-top: 1px solid var(--panel-line); padding-top: 7px;
                color: var(--ink-faint); display: flex; align-items: center; gap: 8px; }
.legend .sizes { display: flex; align-items: center; gap: 3px; }
.legend .sizes i { background: var(--ink-faint); border-radius: 50%; display: block; }

.zoomer { right: 12px; top: 12px; display: flex; flex-direction: column; }
.zoomer button { width: 30px; height: 30px; background: none; border: 0; cursor: pointer;
                 color: var(--ink-soft); font-family: var(--mono); font-size: 14px; line-height: 1; }
.zoomer button + button { border-top: 1px solid var(--panel-line); }
.zoomer button:hover { background: var(--panel-sub); color: var(--ink); }
.zoomer button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

#tip { position: fixed; z-index: 20; pointer-events: none; opacity: 0;
       transform: translate(-50%, calc(-100% - 11px)); background: var(--panel);
       border: 1px solid var(--panel-line); border-radius: 3px; box-shadow: var(--shadow);
       padding: 9px 11px; max-width: 262px; transition: opacity .1s ease; }
#tip.on { opacity: 1; }
#tip .nm { font-size: 13px; font-weight: 600; line-height: 1.3; }
#tip .ad { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; line-height: 1.4; }
#tip .mt { font-family: var(--mono); font-size: 10.5px; margin-top: 7px; padding-top: 7px;
           border-top: 1px solid var(--panel-line); display: flex; justify-content: space-between;
           gap: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .07em; }
#tip .mt b { color: var(--ink); font-variant-numeric: tabular-nums; }
#tip .st.v { color: var(--visited); }
#tip .st.p { color: var(--pending); }

/* ---------- sidebar ---------- */
aside { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 4px;
        box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.ctl { padding: 11px; display: flex; flex-direction: column; gap: 9px;
       border-bottom: 1px solid var(--panel-line); }
#q { width: 100%; font-size: 13px; padding: 7px 9px; background: var(--panel-sub);
     border: 1px solid var(--panel-line); border-radius: 3px; }
#q::placeholder { color: var(--ink-faint); }
#q:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.toggle { display: flex; align-items: center; gap: 8px; font-family: var(--mono);
          font-size: 11px; color: var(--ink-soft); cursor: pointer; letter-spacing: .04em; }
.toggle input { accent-color: var(--visited); cursor: pointer; }

#areaSel { width: 100%; font-size: 12.5px; padding: 7px 8px; background: var(--panel-sub);
           border: 1px solid var(--panel-line); border-radius: 3px; cursor: pointer; }
#areaSel:focus { outline: 2px solid var(--focus); outline-offset: -1px; }

.rhead { display: grid; grid-template-columns: 1fr 50px 50px; gap: 8px; padding: 7px 12px;
         font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
         color: var(--ink-faint); border-bottom: 1px solid var(--panel-line);
         background: var(--panel-sub); position: sticky; top: 0; z-index: 1; }
.rhead .sm { text-align: right; }
.roster { overflow-y: auto; max-height: 470px; }

.prow { width: 100%; display: grid; grid-template-columns: 1fr 50px 50px; align-items: center;
        gap: 8px; padding: 7px 12px; background: none; border: 0;
        border-bottom: 1px solid var(--panel-sub); cursor: pointer; text-align: left; }
.prow:hover { background: var(--panel-sub); }
.prow:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.prow .pn { display: flex; align-items: center; gap: 8px; min-width: 0; }
.prow .bar { width: 3px; height: 24px; border-radius: 1px; flex: none; background: var(--pending); }
.prow .bar.all { background: var(--visited); }
.prow .pt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.prow em { font-style: normal; font-size: 12px; overflow: hidden;
           text-overflow: ellipsis; white-space: nowrap; }
.prow small { font-size: 10px; color: var(--ink-faint); overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; }
.prow .sm { font-family: var(--mono); font-size: 11px; text-align: right;
            font-variant-numeric: tabular-nums; color: var(--ink-faint); }
.prow .c26.has { color: var(--visited); font-weight: 600; }

/* ---------- edit drawer ---------- */
#edit { position: fixed; z-index: 40; right: 0; top: 0; bottom: 0; width: min(370px, 100%);
        background: var(--panel); border-left: 1px solid var(--panel-line);
        box-shadow: -8px 0 32px rgba(0,0,0,.16); padding: 18px;
        display: flex; flex-direction: column; gap: 14px;
        transform: translateX(100%); transition: transform .2s ease; overflow-y: auto; }
#edit.on { transform: none; }
#edit .ehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
#edit h2 { margin: 0; font-size: 17px; line-height: 1.25; }
#edit .esub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; line-height: 1.45; }
#edit .x { background: none; border: 0; cursor: pointer; color: var(--ink-faint);
           font-size: 20px; line-height: 1; padding: 2px 4px; }
#edit .x:hover { color: var(--ink); }
.hist { display: flex; gap: 8px; font-family: var(--mono); font-size: 11px;
        background: var(--panel-sub); border: 1px solid var(--panel-line);
        border-radius: 3px; padding: 9px 10px; justify-content: space-between; }
.hist div { display: flex; flex-direction: column; gap: 2px; }
.hist span { color: var(--ink-faint); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; }
.hist b { font-variant-numeric: tabular-nums; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
               text-transform: uppercase; color: var(--ink-faint); }
.field input, .field textarea { width: 100%; padding: 8px 9px; font-size: 13px;
  background: var(--panel-sub); border: 1px solid var(--panel-line); border-radius: 3px; }
.field textarea { resize: vertical; min-height: 62px; font-family: var(--sans); }
.field input:focus, .field textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.vtog { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer;
        padding: 9px 10px; border: 1px solid var(--panel-line); border-radius: 3px;
        background: var(--panel-sub); }
.vtog input { accent-color: var(--visited); width: 15px; height: 15px; cursor: pointer; }
.erow { display: flex; gap: 8px; margin-top: 2px; }
.erow .btn { flex: 1; text-align: center; padding: 9px; }
#emsg { font-family: var(--mono); font-size: 11px; min-height: 15px; }
#emsg.ok { color: var(--visited); }
#emsg.err { color: var(--danger); }
#scrim { position: fixed; inset: 0; z-index: 30; background: rgba(10,20,24,.34);
         opacity: 0; pointer-events: none; transition: opacity .2s ease; }
#scrim.on { opacity: 1; pointer-events: auto; }

footer { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); line-height: 1.6; }
#banner { font-family: var(--mono); font-size: 11px; padding: 8px 11px; border-radius: 3px;
          background: var(--panel); border: 1px solid var(--pending); color: var(--pending); }
#banner[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
