:root {
  --bg: #fcfcfb; --ink: #1d1d1b; --muted: #6b6a65; --line: #e4e2dc; --chip: #f1efea;
  --accent: #e0582a; --accent-ink: #ffffff; --brand: #2f4a2f;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1f1f1d; --ink: #f1f0ec; --muted: #a8a69f; --line: #3a3936; --chip: #2b2b28; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; background: var(--chip); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); padding: 4px 0; }
button.wide { width: 100%; margin: 6px 0; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.end { justify-content: flex-end; }
.row .muted { flex: 1; }

#map { position: absolute; inset: 0; }

.chips { position: absolute; top: 10px; left: 10px; right: 110px; display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; z-index: 2; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; text-align: left; background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.18); border: 1px solid transparent;
  padding: 6px 10px; line-height: 1.2; }
.chip small { display: block; color: var(--muted); font-size: 11px; }
.chip.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 1px 4px rgba(0,0,0,.18); }
.pill { position: absolute; top: 160px; right: 10px; z-index: 2; background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.25);
  padding: 6px 10px; font-size: 13px; }
.fab { position: absolute; right: 14px; bottom: calc(76px + var(--safe-b)); z-index: 3; background: var(--accent); color: #fff;
  border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.sheet:not(.min) ~ .fab, body:has(.sheet:not(.min)) .fab { bottom: calc(46vh + 14px); }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; background: var(--bg); border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 12px rgba(0,0,0,.2); max-height: 46vh; overflow-y: auto; padding: 0 16px calc(12px + var(--safe-b)); }
.sheet.min { max-height: calc(64px + var(--safe-b)); overflow: hidden; }
.grab { display: block; width: 100%; height: 18px; border: 0; border-radius: 0; background: var(--bg); padding: 0;
  position: sticky; top: 0; z-index: 2; }
.sheet.min .tab { visibility: hidden; }
.grab::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 7px auto; }
.tabs { display: flex; gap: 6px; position: sticky; top: 18px; background: var(--bg); padding-bottom: 8px; z-index: 1; }
.tabs button { flex: 1; padding: 7px 0; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab { display: none; }
.tab.on { display: block; }
h3 { font-size: 14px; margin: 14px 0 6px; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: thin; }
.day { flex: none; min-width: 64px; padding: 6px 8px; font-size: 12px; text-align: center; line-height: 1.25; }
.day b { display: block; font-size: 14px; margin-top: 2px;
  background: linear-gradient(to top, rgba(224,88,42,.25) var(--v), transparent var(--v)); border-radius: 4px; }
.day.fc { border-style: dashed; }
.day.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.charttitle { color: var(--muted); font-size: 12px; margin: 4px 0; }
.chartbox { position: relative; }
#chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
#chart text { font-size: 9px; fill: var(--muted); }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 6px; font-size: 12px; white-space: nowrap; }
.best { margin: 0; padding-left: 22px; }
.best li { padding: 5px 0; cursor: pointer; }
.best li small { display: block; color: var(--muted); font-size: 12px; }
.best li.none { list-style: none; margin-left: -22px; cursor: default; color: var(--muted); }

.list { list-style: none; margin: 8px 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.list li > div { flex: 1; min-width: 0; }
.list small { display: block; color: var(--muted); font-size: 12px; }
.list progress { width: 100%; height: 6px; margin-top: 4px; accent-color: var(--accent); }
.list .x { background: none; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #a32e10; flex: none; }
.dot.empty { background: #8a8984; }

dialog { border: 0; border-radius: 16px; padding: 16px; width: min(440px, calc(100vw - 32px)); background: var(--bg); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-top: 0; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.kinds button { padding: 6px 10px; font-size: 14px; }
.kinds button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.kinds button.empty.on { background: #6b6a65; border-color: #6b6a65; }
textarea { width: 100%; font: inherit; color: inherit; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }

.maplibregl-ctrl-top-right { top: 52px; }

@media (min-width: 900px) {
  .sheet, .sheet.min { left: auto; right: 12px; bottom: 12px; width: 380px; max-height: calc(100vh - 80px); border-radius: 16px; overflow-y: auto; }
  .sheet.min { max-height: calc(100vh - 80px); }
  .fab, body:has(.sheet:not(.min)) .fab { right: 404px; bottom: 24px; }
  .chips { right: 420px; }
}
