/* Sleep Low - a survey-map look: paper, sepia contour ink, a teal route, rust for a night that climbs too fast. */
:root {
  --bg: #f4eddc; --paper: #fbf7ec; --panel: #fffdf6; --ink: #262420; --soft: #5f574a; --line: #ddd1b8;
  --contour: #a88355; --contour-2: #7a5a32; --zone: #ece0c4; --route: #2f5d62; --route-soft: #d7e6e4;
  --bad: #b23c0b; --bad-soft: #fbe5d9; --tired: #8a5a00; --tired-soft: #fbefcf; --still: #2e6b4c; --still-soft: #dcefe3;
  --accent: #2f5d62; --accent-ink: #ffffff; --focus: #1d6fa3; --shadow: 0 1px 0 rgba(60, 45, 20, .06), 0 6px 18px rgba(60, 45, 20, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111719; --paper: #162024; --panel: #1a2529; --ink: #ece6d8; --soft: #b5ad9c; --line: #2f3d42;
  --contour: #8f7552; --contour-2: #c9a876; --zone: #1f2b2c; --route: #7cc7cb; --route-soft: #1f3a3c;
  --bad: #ff9a5c; --bad-soft: #3a2116; --tired: #f2c14e; --tired-soft: #362c12; --still: #7fd6a4; --still-soft: #163227;
  --accent: #7cc7cb; --accent-ink: #0d1a1c; --focus: #8cc8ff; --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .86rem; } .muted { color: var(--soft); } .mono { font-family: var(--mono); }
code { font-family: var(--mono); font-size: .9em; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 0 .25em; }

/* Header */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.back { color: var(--soft); text-decoration: none; font-size: .9rem; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 1.15rem; }
.logo { width: 28px; height: 28px; }
.lg-c1 { fill: var(--zone); stroke: var(--contour); stroke-width: 1.4; }
.lg-c2 { fill: none; stroke: var(--contour); stroke-width: 1.4; }
.lg-c3 { fill: var(--route); stroke: var(--route); stroke-width: 1; }
.lg-ln { stroke: var(--contour-2); stroke-width: 1.6; fill: none; }
.session { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .88rem; cursor: pointer; text-decoration: none; line-height: 1.3; }
.pill:hover { border-color: var(--contour); }
.pill.solid { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.ghost { cursor: default; background: transparent; }
.pill.tiny { padding: 2px 9px; font-size: .78rem; vertical-align: middle; margin-left: 6px; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
.hero { padding: 18px 4px 10px; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; color: var(--contour-2); font-weight: 700; }
h1 { font-family: var(--serif); font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.08; margin: .2em 0 .3em; font-weight: 600; }
.lede { max-width: 760px; margin: 0 0 14px; color: var(--soft); font-size: 1.04rem; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { border: 1px dashed var(--contour); background: transparent; color: var(--ink); border-radius: 8px; padding: 6px 11px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip:hover { background: var(--panel); }
.chip.on { border-style: solid; background: var(--route-soft); border-color: var(--route); }

.bench { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; margin-top: 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); margin-top: 16px; min-width: 0; }
.bench .panel { margin-top: 0; }
.ph { font-family: var(--serif); font-size: 1.3rem; margin: 0 0 10px; font-weight: 600; }
.ph3 { font-family: var(--serif); font-size: 1.05rem; margin: 16px 0 6px; }
h3 { font-family: var(--serif); font-size: 1.08rem; margin: 18px 0 6px; font-weight: 600; }
.lbl { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input[type="text"], textarea, select { width: 100%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: .95rem; }
textarea { font-family: var(--mono); font-size: .88rem; line-height: 1.5; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two .lbl { min-height: 2.6em; display: flex; align-items: flex-end; }
.drop { border-radius: 10px; }
.drop.over textarea { border-color: var(--route); background: var(--route-soft); }
.dropline { margin: 4px 0 0; }
.filelink { color: var(--accent); text-decoration: underline; cursor: pointer; }
.flags { list-style: none; padding: 0; margin: 8px 0 0; }
.flags li { font-size: .86rem; padding: 5px 9px; border-radius: 6px; margin-top: 4px; }
.flags li.warn { background: var(--tired-soft); color: var(--ink); border-left: 3px solid var(--tired); }

/* The map */
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.map-head .ph { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg-b { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: .86rem; padding: 5px 12px; cursor: pointer; }
.seg-b.on { background: var(--route); color: var(--accent-ink); }
.verdict-tag { display: inline-block; margin: 10px 0 4px; font-weight: 700; font-size: .9rem; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--line); }
.verdict-tag:empty { display: none; }
.v-on_pace { background: var(--still-soft); color: var(--still); border-color: var(--still); }
.v-check_units, .v-add_nights { background: var(--tired-soft); color: var(--tired); border-color: var(--tired); }
.v-rethink { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.topobox { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; overflow: hidden; }
.topobox .empty { padding: 60px 16px; text-align: center; color: var(--soft); margin: 0; }
svg.topo { display: block; width: 100%; height: auto; font-family: var(--sans); }
.topo .zone { fill: var(--zone); }
.topo .contour { fill: none; stroke: var(--contour); stroke-width: .8; opacity: .8; }
.topo .contour.index { stroke-width: 1.5; }
.topo .contour.line3000 { stroke: var(--contour-2); stroke-width: 1.8; stroke-dasharray: 6 4; opacity: 1; }
.topo .clabel { fill: var(--contour-2); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--paper); stroke-width: 3px; }
.topo .clabel.c3000 { font-weight: 800; }
.topo .peak { fill: var(--contour-2); }
.topo .seg { fill: none; stroke: var(--route); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.topo .seg.bad { stroke: var(--bad); stroke-width: 3.8; }
.topo .ghost .seg { stroke: var(--route); stroke-width: 1.6; stroke-dasharray: 3 4; opacity: .55; }
.topo .spur { stroke: var(--route); stroke-width: 1.4; stroke-dasharray: 2 3; fill: none; }
.topo .spur-top { fill: var(--route); }
.topo .pin circle { fill: var(--panel); stroke: var(--route); stroke-width: 2; }
.topo .pin text { fill: var(--ink); font-size: 9.5px; font-weight: 700; pointer-events: none; }
.topo .pin.bad circle { stroke: var(--bad); fill: var(--bad-soft); stroke-width: 2.4; }
.topo .pin.tired circle { stroke: var(--tired); fill: var(--tired-soft); stroke-width: 2.4; }
.topo .pin.still circle { fill: var(--still-soft); stroke: var(--still); }
.topo .pin.added circle { stroke-dasharray: 3 2; }
.topo .pin.start rect { fill: var(--route); }
.topo .pin.flash circle { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { stroke-width: 6; } }
.cap { margin: 8px 0 4px; }
.legend { list-style: none; padding: 0; margin: 6px 0 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--soft); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 18px; height: 10px; border-radius: 3px; display: inline-block; border: 2px solid var(--route); background: var(--panel); }
.k-ok { background: var(--route); border-color: var(--route); height: 4px; }
.k-bad { background: var(--bad); border-color: var(--bad); height: 5px; }
.k-tired { background: var(--tired-soft); border-color: var(--tired); border-radius: 50%; width: 12px; height: 12px; }
.k-still { background: var(--still-soft); border-color: var(--still); border-radius: 50%; width: 12px; height: 12px; }
.k-spur { border: 0; border-top: 2px dashed var(--route); height: 0; background: none; border-radius: 0; }
.k-ghost { border: 0; border-top: 2px dotted var(--route); height: 0; background: none; border-radius: 0; opacity: .7; }

.nights { list-style: none; padding: 0; margin: 4px 0 0; border-top: 1px solid var(--line); }
.night { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto auto; grid-template-areas: "k place alt gain" "k tags tags tags"; gap: 0 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: baseline; }
.night:hover { background: var(--paper); }
.n-k { grid-area: k; font-weight: 700; color: var(--route); }
.n-place { grid-area: place; overflow-wrap: anywhere; }
.n-alt { grid-area: alt; }
.n-gain { grid-area: gain; color: var(--soft); min-width: 5.5em; text-align: right; }
.n-gain.over { color: var(--bad); font-weight: 700; }
.n-tags { grid-area: tags; display: flex; flex-wrap: wrap; gap: 4px; }
.n-tags:empty { display: none; }
.night.bad .n-k { color: var(--bad); }
.night.tired .n-k { color: var(--tired); }
.night.added { background: var(--route-soft); }
.tag { font-size: .74rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; line-height: 1.5; }
.t-arrival, .t-jump, .t-big_jump { color: var(--bad); background: var(--bad-soft); }
.t-no_rest { color: var(--tired); background: var(--tired-soft); }
.t-rest, .t-down, .t-climb_high { color: var(--still); background: var(--still-soft); }
.t-added { color: var(--route); background: var(--panel); }
.reads { list-style: none; padding: 0; margin: 0; }
.reads li { padding: 6px 0; border-bottom: 1px dotted var(--line); font-size: .92rem; }
.reads .lv { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.reads .lv-fix .lv { background: var(--bad-soft); color: var(--bad); }
.reads .lv-info .lv { background: var(--route-soft); color: var(--route); }
.reads li.ok, .reads li.none { color: var(--soft); }

/* Ask + run */
.ask .runrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.meter { flex: 1 1 260px; }
.note { background: var(--paper); border-left: 3px solid var(--contour); padding: 6px 10px; border-radius: 4px; font-size: .9rem; margin: 8px 0 0; }
.gate { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--tired-soft); font-size: .92rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.steps { list-style: none; padding: 0; margin: 0; }
.step { padding: 3px 0; color: var(--soft); }
.step.done { color: var(--still); } .step.active { color: var(--ink); font-weight: 700; }
.step-ic { display: inline-block; width: 1.2em; font-family: var(--mono); }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .82rem; background: var(--paper); padding: 10px; border-radius: 8px; max-height: 420px; overflow: auto; }

/* The report */
.rep-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.rep-head h2 { margin: 0; font-family: var(--serif); font-size: 1.5rem; line-height: 1.2; overflow-wrap: anywhere; }
.rep-k { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--soft); }
.stamp { display: inline-block; padding: 6px 12px; border: 2px solid var(--line); border-radius: 8px; font-weight: 800; letter-spacing: .03em; transform: rotate(-2deg); white-space: nowrap; }
.summary { font-size: 1.02rem; margin: 12px 0 0; }
.changes, .watch, .turn, .recon, #rCaveats { list-style: none; padding: 0; margin: 0; }
.chg { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 8px; background: var(--paper); }
.chg.skipped { opacity: .75; border-style: dashed; }
.chg p { margin: 4px 0 0; font-size: .93rem; }
.chg-h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.astamp { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 4px; background: var(--route-soft); color: var(--route); }
.astamp.a-stop { background: var(--tired-soft); color: var(--tired); }
.warn { color: var(--tired); }
.none { color: var(--soft); font-style: italic; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.watch li { border-left: 3px solid var(--bad); padding: 6px 10px; margin-top: 6px; background: var(--bad-soft); border-radius: 0 8px 8px 0; font-size: .93rem; }
.watch li.none { background: transparent; border-left-color: var(--line); }
.turn li { padding: 6px 0 6px 22px; position: relative; font-size: .93rem; border-bottom: 1px dotted var(--line); }
.turn li::before { content: ""; position: absolute; left: 2px; top: .8em; width: 10px; height: 10px; border: 2px solid var(--route); border-radius: 50%; }
.turn li.none::before { display: none; }
#rAsk { padding-left: 1.3em; margin: 0; } #rAsk li { padding: 3px 0; }
.recon li { padding: 6px 10px; border-radius: 6px; margin-top: 6px; font-size: .9rem; background: var(--paper); border-left: 3px solid var(--line); }
.recon li.ok { border-left-color: var(--still); } .recon li.info { border-left-color: var(--route); }
.recon li.warn { border-left-color: var(--tired); color: var(--ink); background: var(--tired-soft); }
.recon li.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.hlist { list-style: none; padding: 0; margin: 10px 0 0; }
.hrow { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.foot { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; color: var(--soft); font-size: .88rem; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: .9rem; transition: opacity .5s; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #1a0d06; }
.toast a { color: inherit; font-weight: 700; }
.toast.gone { opacity: 0; }

/* Docs pages */
main.doc { max-width: 900px; }
.doc h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
.doc h2 { font-family: var(--serif); margin-top: 1.6em; }
.doc pre { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: .82rem; line-height: 1.45; }
.doc pre code { background: none; border: 0; padding: 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 0; }
.tab { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px 6px 0 0; padding: 4px 10px; font: inherit; font-size: .84rem; cursor: pointer; }
.tab.active { background: var(--route); color: var(--accent-ink); border-color: var(--route); }
.codegroup pre { margin-top: 0; border-top-left-radius: 0; }
.statebox, .tokenbox { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 10px 12px; }
.tokenbox { font-family: var(--mono); font-size: .84rem; overflow-wrap: anywhere; flex: 1; }
.tokenrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }

@media (max-width: 900px) { .bench { grid-template-columns: 1fr; } .cols { grid-template-columns: 1fr; gap: 0; } }
@media (max-width: 480px) {
  .bar { padding: 8px 12px; } .two { grid-template-columns: 1fr; gap: 0; } .two .lbl { min-height: 0; }
  .panel { padding: 14px 12px; } main { padding: 12px 12px 30px; }
  .night { grid-template-columns: 2em minmax(0, 1fr) auto; grid-template-areas: "k place alt" "k gain gain" "k tags tags"; }
  .n-gain { text-align: left; }
}
@media print { .bar, .samples, .askpanel, .exports, .history, .toasts, .seg { display: none !important; } body { background: #fff; } }
