/* FIRE Simulator.
   Layout: a parameter rail on the left (a bottom sheet on phones), results stacked on the right.
   Palette: cool paper neutrals, one blue accent; green / amber / red only for outcomes. */
:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --ink: #17212b;
  --muted: #5c6a77;
  --faint: #8995a1;
  --line: #d9e0e5;
  --accent: #1f5f9e;
  --accent-soft: #e2edf7;
  --good: #2d7a4c;
  --warn: #b07217;
  --bad: #c03a2b;
  --good-soft: #e3f1e8;
  --warn-soft: #f8eedc;
  --bad-soft: #f8e4e1;
  --shadow: 0 1px 2px rgb(23 33 43 / 6%), 0 4px 16px rgb(23 33 43 / 5%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --rail: 360px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141a;
    --surface: #151d25;
    --surface-2: #1b252f;
    --ink: #e4eaf0;
    --muted: #9aa7b4;
    --faint: #6f7d8a;
    --line: #26323d;
    --accent: #6aa8e4;
    --accent-soft: #17304a;
    --good: #5cbf85;
    --warn: #e2a64a;
    --bad: #ec6a5b;
    --good-soft: #15301f;
    --warn-soft: #33270f;
    --bad-soft: #3a1a16;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e141a;
  --surface: #151d25;
  --surface-2: #1b252f;
  --ink: #e4eaf0;
  --muted: #9aa7b4;
  --faint: #6f7d8a;
  --line: #26323d;
  --accent: #6aa8e4;
  --accent-soft: #17304a;
  --good: #5cbf85;
  --warn: #e2a64a;
  --bad: #ec6a5b;
  --good-soft: #15301f;
  --warn-soft: #33270f;
  --bad-soft: #3a1a16;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---- shell ---- */
.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.rail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rail-head h2 { margin: 0; font-size: 1rem; font-weight: 650; }
.rail-live { font-size: 0.85rem; color: var(--muted); }
.rail-live strong { color: var(--ink); }
.rail-body { padding: 4px 18px 120px; display: flex; flex-direction: column; }

main {
  padding: 24px clamp(16px, 3vw, 36px) 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
header.top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
header.top h1 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; }
header.top .sub { color: var(--muted); font-size: 0.9rem; }
header.top .top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
header.top .title { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; min-width: 0; }

/* ---- form ---- */
details.group { border-bottom: 1px solid var(--line); }
details.group > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 0;
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "+"; color: var(--faint); font-weight: 400; font-size: 1.1rem; }
details.group[open] > summary::after { content: "–"; }
details.group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.fields { display: flex; flex-direction: column; gap: 14px; padding-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .field .label { font-size: 0.85rem; font-weight: 550; display: flex; justify-content: space-between; gap: 8px; }
.field label .val { font-weight: 650; color: var(--accent); }
.hint { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.hint.warn { color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: 14px; }
/* Two fields side by side, their labels, inputs and hints on shared rows (subgrid): a hint under
   one field doesn't push the inputs out of line. */
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 10px; row-gap: 4px; }
.row2 > * { min-width: 0; }
.row2 > .field { grid-row: span 3; display: grid; grid-template-rows: subgrid; }
.row2 > .field > .field-head { align-self: end; }
.input {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input input, .input select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.input .unit { padding: 0 10px; color: var(--faint); font-size: 0.82rem; white-space: nowrap; }
.input.invalid { border-color: var(--bad); }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0; }
.person { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.person-title { font-weight: 650; font-size: 0.9rem; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 2px;
  white-space: nowrap;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button:focus-visible { outline: 2px solid var(--accent); }

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 550;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { border-color: var(--line); color: var(--ink); }
.btn.icon { min-width: 38px; padding: 0 10px; font-size: 1.15rem; line-height: 1; }
.btn:disabled { opacity: 0.55; cursor: default; }

.error {
  display: none;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 0.85rem;
}
.notice {
  display: none;
  margin: 12px 0 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.85rem;
}
.notice.show { display: block; }

/* ---- results ---- */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 20px;
}
.verdict { display: flex; flex-direction: column; gap: 6px; padding-right: 20px; border-right: 1px solid var(--line); }
.verdict .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.verdict .big { font-size: 3.4rem; font-weight: 750; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.verdict .big.good { color: var(--good); }
.verdict .big.warn { color: var(--warn); }
.verdict .big.bad { color: var(--bad); }
.verdict .what { color: var(--muted); font-size: 0.88rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 18px; align-content: start; }
.tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .k { font-size: 0.76rem; color: var(--muted); }
.tile .v { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 0.76rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.compare { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; }
.compare .k { font-size: 0.8rem; color: var(--muted); margin-right: 4px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.82rem;
  background: var(--surface-2);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip:focus-visible { outline: 2px solid var(--accent); }
.chip:disabled { cursor: not-allowed; opacity: 0.6; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 10px;
  position: relative;
  min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; margin-bottom: 6px; }
.card h3 { margin: 0; font-size: 1.02rem; font-weight: 650; }
.card .desc { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; max-width: 70ch; }
.card .tools { display: flex; gap: 8px; align-items: center; }
.card .tools .seg { min-width: 200px; }
.chart { width: 100%; height: 460px; }
.chart.mid { height: 380px; }
.chart.small { height: 280px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.busy::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: slide 1.1s linear infinite;
}
.busy .chart { opacity: 0.55; transition: opacity 0.2s; }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { .busy::before { animation: none; background: var(--accent); opacity: 0.5; } }

.how { color: var(--muted); font-size: 0.88rem; }
.how h4 { color: var(--ink); margin: 14px 0 4px; font-size: 0.92rem; }
.how p, .how ul { margin: 0 0 8px; max-width: 75ch; }
.how summary { cursor: pointer; color: var(--ink); font-weight: 650; }
/* The page's last line: where the code lives, and where to report a problem. */
.site-foot { color: var(--muted); font-size: 0.82rem; text-align: center; line-height: 1.6; }
.site-foot a { color: var(--accent); }
.hidden { display: none !important; }

/* ---- phone ---- */
.fab, .sheet-close { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed;
    inset: auto 0 0 0;
    height: 88vh;
    z-index: 20;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgb(0 0 0 / 18%);
    transform: translateY(102%);
    transition: transform 0.25s ease;
  }
  .rail.open { transform: none; }
  .rail-head { border-radius: 16px 16px 0 0; }
  .sheet-close { display: inline-block; }
  .fab {
    display: block;
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    border: 0;
    border-radius: 999px;
    padding: 13px 20px;
    background: var(--accent);
    color: var(--surface);
    font-weight: 650;
    box-shadow: 0 6px 20px rgb(0 0 0 / 22%);
    cursor: pointer;
  }
  main { padding: 16px 16px 96px; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .verdict { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
  .verdict .big { font-size: 2.8rem; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .chart { height: 360px; }
  .chart.mid { height: 320px; }
  .card .tools .seg { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }

/* ---- help: "?" buttons, the explanation dialog and the guide ---- */
.field-head { display: flex; align-items: center; gap: 6px; }
.field-head label { flex: 1; min-width: 0; }
.hint-row { display: flex; align-items: flex-start; gap: 8px; }
.hint-row .hint { flex: 1; }
.person-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font: 700 0.72rem/1 var(--font);
  cursor: pointer;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}
.help:hover { color: var(--accent); border-color: var(--accent); }
.help:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
h3 .help { margin-left: 4px; position: relative; top: -1px; }
/* A bigger tap target on touch screens, same look. */
@media (pointer: coarse) { .help { width: 26px; height: 26px; font-size: 0.8rem; } }

#help-dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(85vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
  overflow: hidden;
}
#help-dialog[open] { display: flex; flex-direction: column; }
#help-dialog::backdrop { background: rgb(10 16 22 / 45%); }
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.help-head h2 { margin: 0; font-size: 1.1rem; font-weight: 650; }
.help-body { overflow-y: auto; padding: 16px 18px 22px; display: flex; flex-direction: column; gap: 14px; font-size: 0.92rem; }
.help-entry p, .help-entry ul { margin: 0 0 8px; }
.help-entry ul { padding-left: 1.2em; }
.help-entry li { margin: 2px 0; }
.help-entry a { color: var(--accent); }
.help-entry .ex {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.help-entry .ex::before { content: "Example  "; font-weight: 650; color: var(--ink); }
.help-entry code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.guide-link { align-self: flex-start; }

/* The full guide: nearly the whole screen, sections on the left, entries as cards. */
#help-dialog.wide {
  width: min(1280px, calc(100vw - 48px));
  height: min(94vh, 1100px);
  max-height: none;
}
#help-dialog.wide .help-body { padding: 0; }
.guide { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100%; }
.guide-toc {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  min-height: 100%;
}
.toc-link {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
}
.toc-link:hover { color: var(--ink); background: var(--surface-2); }
.toc-link[aria-current="true"] { color: var(--accent); background: var(--accent-soft); }
.toc-link:focus-visible { outline: 2px solid var(--accent); }
.guide-content { padding: 18px 24px 40px; display: flex; flex-direction: column; gap: 26px; min-width: 0; }
.guide-section { scroll-margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.guide-section h3 { margin: 0; font-size: 1.05rem; color: var(--accent); }
.guide-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.guide-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 6px;
  background: var(--surface);
  min-width: 0;
}
.guide-item h4 { margin: 0 0 6px; font-size: 0.95rem; }

@media (max-width: 960px) {
  #help-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 85vh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  #help-dialog.wide { width: 100vw; height: 94vh; }
  .guide { display: block; } /* stacked: the section row, then the content */
  .guide-toc {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    z-index: 1;
    min-height: 0;
  }
  .toc-link { white-space: nowrap; flex: none; }
  .guide-content { padding: 14px 16px 32px; }
  .guide-section { scroll-margin-top: 66px; } /* land below the sticky section row */
  .guide-cards { grid-template-columns: minmax(0, 1fr); }
}

/* ---- scenarios: the picker on top of the parameters, its menu, the name dialog, messages ---- */
.scenario { display: flex; flex-direction: column; gap: 6px; }
.scenario-label { display: flex; align-items: center; gap: 6px; }
.scenario-label label { font-size: 0.75rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.scenario-row { display: flex; gap: 8px; }
.scenario-row > .input { flex: 1; min-width: 0; }
.scenario-row select { font-weight: 600; cursor: pointer; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.scenario-status { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.scenario-status .btn { padding: 5px 11px; }
.scenario-state {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.scenario-state.dirty { color: var(--ink); }
/* Saved plans that no exported file holds yet: a quiet reminder with its own button. */
.backup {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 8px 6px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  font-size: 0.8rem;
  line-height: 1.35;
}
.backup[hidden] { display: none; }
/* A shared plan's seed or number of futures differs from the viewer's: information, not a warning. */
.shared-note { background: var(--accent-soft); }
.backup-text { flex: 1; min-width: 0; }
.scenario-state.error { color: var(--bad); }
/* One mark for "changed, not saved": a dot on the status, the edited fields and their sections. */
.scenario-state.dirty::before,
.field.edited > .field-head::before,
details.group.edited .group-title::after {
  content: "";
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.scenario-state.dirty::before { margin-right: 6px; vertical-align: 1px; }
details.group.edited .group-title::after { margin-left: 8px; vertical-align: 2px; }
.field.edited > .seg { box-shadow: 0 0 0 2px var(--accent-soft); }

.menu-wrap { position: relative; display: flex; }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 16%);
}
.menu[hidden] { display: none; }
.menu button {
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 7px;
  text-align: left;
  font-size: 0.88rem;
  cursor: pointer;
}
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button:disabled { color: var(--faint); cursor: default; }
.menu .danger:not(:disabled) { color: var(--bad); }

.scenario-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.scenario-pill:empty { display: none; }
.scenario-pill:hover { border-color: var(--accent); }
.scenario-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }
.pill-edited { color: var(--accent); font-weight: 550; }
.pill-edited::before { content: "·"; margin-right: 6px; color: var(--faint); }

dialog.panel {
  width: min(440px, calc(100vw - 32px));
  max-height: min(90vh, 900px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog.panel.wide { width: min(680px, calc(100vw - 32px)); }
dialog.panel::backdrop { background: rgb(10 16 22 / 45%); }
dialog.panel form, .panel-body { display: flex; flex-direction: column; gap: 8px; padding: 18px; }
dialog.panel h2 { margin: 0 0 2px; font-size: 1.1rem; font-weight: 650; }
dialog.panel h3 { margin: 10px 0 0; font-size: 0.82rem; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
dialog.panel form > label { font-size: 0.85rem; font-weight: 550; }
#name-input, #share-url, #share-password, #unlock-input { font-size: 16px; } /* 16px: iOS doesn't zoom in on it */
.share-field { display: flex; flex-direction: column; gap: 4px; }
.share-field[hidden] { display: none; }
.share-field > label { font-size: 0.85rem; font-weight: 550; }
.panel-text { margin: 0; color: var(--muted); font-size: 0.85rem; }
.panel-text:empty { display: none; }
.field-error { min-height: 1.2em; color: var(--bad); font-size: 0.8rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 9px 8px 9px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 25%);
  font-size: 0.88rem;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s, transform 0.18s, visibility 0s 0.18s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity 0.18s, transform 0.18s; }
.toast.error { background: var(--bad); }
.toast button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; border-radius: 6px; }
.toast button:focus-visible { outline: 2px solid currentColor; }
.toast-action { padding: 4px 8px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.toast-close { padding: 2px 8px; font-size: 1.25rem; line-height: 1; opacity: 0.75; }
.toast-close:hover { opacity: 1; }
@media (max-width: 960px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.show { transition: none; } }

/* ---- lists in the form: people, accounts, income lines, events ---- */
.item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; }
.item-title { font-weight: 650; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.small { padding: 3px 9px; font-size: 0.8rem; }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.when { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 8px; }
.when > .hidden + * { grid-column: 1 / -1; }
.field.check label { display: flex; align-items: center; gap: 8px; font-weight: 550; justify-content: flex-start; cursor: pointer; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

/* ---- the error box can offer a fix ---- */
.error.show { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#error-fix { color: var(--ink); }

/* ---- the example plan's welcome ---- */
.welcome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 16px 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.welcome h2 { margin: 0 0 4px; font-size: 1.02rem; }
.welcome p { margin: 0; max-width: 70ch; color: var(--ink); font-size: 0.9rem; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- setting up a new plan ---- */
.setup-fields { display: flex; flex-direction: column; gap: 10px; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.setup-person { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 0.7fr) 32px; gap: 8px; align-items: end; }
.setup-field { display: flex; flex-direction: column; gap: 3px; font-size: 0.8rem; font-weight: 550; min-width: 0; }
.setup-field small { color: var(--muted); font-weight: 400; font-size: 0.74rem; }
.setup-field input, .setup-field select {
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 7px 9px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.setup-field input:focus, .setup-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.setup-person .btn { height: 36px; }
.setup-fields > .btn { align-self: flex-start; }
@media (max-width: 600px) {
  .setup-person { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--line); padding-bottom: 10px; }
  .setup-person .btn { grid-column: 1 / -1; justify-self: start; height: auto; }
}
