/* app.css — the whole stylesheet, because the CSP that serves this page
   allows style-src 'self' and nothing else. An inline style attribute or a
   style element renders perfectly under a local http.server (which sends no
   CSP at all) and is silently refused in production. CSSOM writes from JS
   (el.style.width = …) are not covered by style-src and keep working, so
   anything genuinely dynamic — a bar's width, a legend swatch's colour — is
   set that way. */

:root {
  --bg: #0d1117;
  --panel: #141b24;
  --edge: #22303f;
  --ink: #dde6f0;
  --dim: #8fa3b8;
  --accent: #4fc3f7;
  --accent-ink: #06121b;
  --warn: #ffb74d;
  --bad: #ef5350;
  --ok: #66bb6a;
}

* { box-sizing: border-box; }

/* `hidden` is only a default of display:none, so any class that sets display
   beats it and the "hidden" element keeps rendering. .row is flex and .chips
   is flex here, both of which are toggled. Said once, globally. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* The hosted back-bar is spliced in immediately after <body> by the site
   build. An app wrapper of `position: fixed; inset: 0` covers it completely
   and there is no way to scroll to it. So: body is the flex column, the bar
   takes its natural height at the top, and .wrap takes whatever is left. That
   fills the viewport when the file is opened standalone and yields exactly the
   bar's height when it is hosted. */
body { display: flex; flex-direction: column; }
body > .hosted-bar { flex: 0 0 auto; max-height: 20vh; overflow: auto; }
.topbar, .help { flex: none; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--edge);
  background: var(--panel);
}
.brand { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.brand img { flex: none; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--accent); color: var(--accent-ink);
  padding: 2px 7px; border-radius: 3px; vertical-align: 3px; font-weight: 700;
}

.help {
  padding: 16px 20px; border-bottom: 1px solid var(--edge);
  background: #101720; color: var(--dim); font-size: 14px;
}
.help p { margin: 0 0 10px; max-width: 78ch; }
.help p:last-child { margin-bottom: 0; }
.help strong, .help b { color: var(--ink); }
.help code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: var(--accent);
}

.wrap { display: flex; flex: 1; min-height: 0; position: relative; }

.panel {
  width: 350px; flex: none; overflow-y: auto; min-height: 0;
  border-right: 1px solid var(--edge); background: var(--panel);
  padding: 4px 0 24px;
}
.step { padding: 16px 18px; border-bottom: 1px solid var(--edge); }
.step:last-child { border-bottom: 0; }
.step h2 {
  margin: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--dim); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.n {
  display: inline-grid; place-items: center; width: 19px; height: 19px;
  border-radius: 50%; background: var(--edge); color: var(--ink);
  font-size: 11px; font-weight: 700; flex: none;
}

.row { display: flex; gap: 8px; align-items: center; }
.row.two { gap: 10px; margin-top: 8px; }
.row.two label { flex: 1; font-size: 12px; color: var(--dim); }
.row.two input, .row.two select { width: 100%; margin-top: 3px; }
.row.wrapping { flex-wrap: wrap; }
.row + .row { margin-top: 8px; }

input[type=text], input[type=date], input[type=number], select {
  background: #0b1017; border: 1px solid var(--edge); color: var(--ink);
  border-radius: 6px; padding: 7px 9px; font: inherit; font-size: 13.5px;
  min-width: 0;
}
input[type=text] { flex: 1; }
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=range] { flex: 1; accent-color: var(--accent); }

button {
  background: var(--edge); border: 1px solid transparent; color: var(--ink);
  border-radius: 6px; padding: 7px 12px; font: inherit; font-size: 13.5px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #2c3d50; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary {
  width: 100%; background: var(--accent); color: var(--accent-ink); font-weight: 650;
  padding: 10px;
}
button.primary:hover:not(:disabled) { background: #6fd0fa; }
button.ghost { background: transparent; border-color: var(--edge); }
button.wide { width: 100%; margin-top: 10px; }
button.half { flex: 1; }
button.on { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.link {
  background: none; border: 0; padding: 0; color: var(--accent);
  font-size: inherit; text-decoration: underline; cursor: pointer;
}
button.link:hover { background: none; }

.hint { margin: 8px 0 0; font-size: 12.5px; color: var(--dim); }
.aoi {
  margin: 8px 0 0; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent); word-break: break-all;
}
.err {
  margin: 10px 0 0; font-size: 13px; color: var(--bad);
  background: #2a1416; border: 1px solid #58252a; border-radius: 6px; padding: 9px 11px;
}
.warnbox {
  margin: 10px 0 0; font-size: 12.5px; color: var(--warn);
  background: #241c0e; border: 1px solid #4a3a19; border-radius: 6px; padding: 9px 11px;
}

.prog { margin-top: 12px; }
.bar { height: 4px; background: var(--edge); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.prog p { margin: 7px 0 0; font-size: 12.5px; color: var(--dim); }
.prog .mono { font-variant-numeric: tabular-nums; }

.toggles { margin-top: 10px; gap: 14px; font-size: 13px; color: var(--dim); }
.toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

.out { margin-top: 12px; font-size: 13px; }
.out dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 10px; }
.out dt { color: var(--dim); }
.out dd { margin: 0; font-variant-numeric: tabular-nums; }
.out .note { color: var(--dim); font-size: 12.5px; margin: 0 0 8px; }
.out .lede {
  margin: 0 0 8px; font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.out .lede .dim { font-weight: 400; color: var(--dim); font-size: 13px; }

/* Scene list. Each row is a <button> so it is reachable from the keyboard;
   the default button chrome is unwound rather than fought. */
.scenes { max-height: 230px; overflow-y: auto; margin-top: 10px; }
.pick {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 7px 8px; border: 0; border-top: 1px solid var(--edge);
  border-radius: 0; width: 100%; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
.pick:hover:not(:disabled) { background: #1b2532; }
.pick.sel { background: #16303e; color: var(--ink); }
.pick b { font-weight: 600; font-variant-numeric: tabular-nums; }
.pick span { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.chip {
  font-size: 11px; color: var(--dim); background: #101720;
  border: 1px solid var(--edge); border-radius: 999px; padding: 3px 9px;
  font-variant-numeric: tabular-nums;
}
.chip b { color: var(--ink); font-weight: 600; }
.chip.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

#hist { width: 100%; height: 110px; display: block; margin-top: 4px; }
.histaxis {
  display: flex; justify-content: space-between; font-size: 11px;
  color: var(--dim); font-variant-numeric: tabular-nums; margin: 2px 0 0;
}

.strip { display: flex; height: 10px; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.strip div { flex: 1; }

/* Saved fields and scout stops share the row shape. */
.list { margin-top: 10px; }
.frow {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 0; border-top: 1px solid var(--edge);
}
.frow .grow { flex: 1; min-width: 0; }
.frow .grow b { font-weight: 600; }
.frow .grow span { display: block; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.frow button { padding: 4px 9px; font-size: 12px; }

.stop {
  display: flex; align-items: baseline; gap: 9px; width: 100%;
  padding: 7px 4px; border: 0; border-top: 1px solid var(--edge); border-radius: 0;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.stop:hover { background: #1b2532; }
.stop .num {
  flex: none; display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #0d1117;
}
.stop .grow { flex: 1; min-width: 0; }
.stop .grow b { font-weight: 600; }
.stop .grow span { display: block; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }

.iconkey { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--dim); }
.iconkey span { display: flex; align-items: center; gap: 6px; }
.iconkey i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

.credit { font-size: 0.72rem; color: var(--dim); line-height: 1.5; padding: 16px 18px 0; margin: 0; }

.mapwrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0b1017; }
.leaflet-container { background: #0b1017; font: inherit; }

/* Leaflet's own pin, restyled. A div marker rather than an image keeps the
   numbering legible at the size a numbered stop has to be read at. */
.pin {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #0d1117; color: #0d1117;
  font: 700 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.legend {
  position: absolute; left: 12px; bottom: 24px; z-index: 500;
  background: rgba(13, 17, 23, 0.9); border: 1px solid var(--edge);
  border-radius: 7px; padding: 9px 11px; font-size: 11.5px; color: var(--dim);
  backdrop-filter: blur(4px); max-width: 260px;
}
.legend .ramp { display: flex; height: 9px; border-radius: 2px; overflow: hidden; margin: 5px 0 4px; }
.legend .ramp div { flex: 1; }
.legend .ends { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.legend b { color: var(--ink); font-weight: 600; }

.mapbar {
  position: absolute; left: 52px; top: 12px; z-index: 600;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
}
.mapbar-row { display: flex; align-items: center; gap: 6px; }
.mapbar button {
  width: auto; font: inherit; font-size: 12px; padding: 5px 10px;
  border-radius: 6px; border: 1px solid var(--edge);
  background: rgba(13, 17, 23, 0.9); color: var(--ink); cursor: pointer;
}
.mapbar button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nums, .adv { margin-top: 10px; }
.nums summary, .adv summary {
  cursor: pointer; color: var(--dim); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.adv.step { border-bottom: 1px solid var(--edge); padding: 16px 18px; }
.adv.step summary { color: var(--ink); font-size: 13px; text-transform: none; letter-spacing: 0; }

.opacity {
  position: absolute; right: 12px; bottom: 24px; z-index: 500;
  display: flex; align-items: center; gap: 8px; width: 210px;
  background: rgba(13, 17, 23, 0.9); border: 1px solid var(--edge);
  border-radius: 7px; padding: 7px 11px; font-size: 11.5px; color: var(--dim);
}

.drawhint {
  position: absolute; inset: 0; z-index: 450; display: grid; place-items: center;
  pointer-events: none;
}
.drawhint span {
  background: rgba(13, 17, 23, 0.88); border: 1px solid var(--edge);
  padding: 9px 15px; border-radius: 999px; font-size: 13px; color: var(--dim);
}

/* The undo toast. No confirm() dialog anywhere in this page: a modal asks you
   to predict whether you want the thing before it is gone, and an undo lets
   you look at the result and change your mind. */
.toast {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 900; display: flex; align-items: center; gap: 12px;
  background: #16202c; border: 1px solid var(--edge); border-radius: 8px;
  padding: 9px 12px; font-size: 13px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

@media (max-width: 900px) {
  /* `flex: none` on BOTH children, not just the map: the base rule is
     `flex: 1; min-height: 0`, which in a column resolves to flex-basis 0 with
     no floor, so .wrap gets sized to leftover space while its children need
     far more and simply overflow it. Stacked panels size from content and let
     the document scroll. */
  .wrap { flex: none; flex-direction: column; height: auto; min-height: 0; }
  .panel { width: auto; border-right: 0; border-bottom: 1px solid var(--edge); }
  .mapwrap { flex: none; height: 62vh; min-height: 360px; position: relative; }
  .opacity { width: 160px; }
}
