:root {
  --ink: #10231f;
  --ink-soft: #3d534e;
  --paper: #f4f1ea;
  --paper-2: #ebe6db;
  --card: #fffdf8;
  --line: #d4cec2;
  --mint: #1f8a78;
  --mint-dark: #0f5c50;
  --mint-soft: #d7efe9;
  --gold: #c9a227;
  --gold-soft: #f3e6b8;
  --danger: #b42318;
  --danger-soft: #f8d5d2;
  --warn: #b45309;
  --ok: #157a4b;
  --header: #0f5c50;
  --header-ink: #f4f1ea;
  --radius: 14px;
  --tap: 48px;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
img, svg { max-width: 100%; }

#app { min-height: 100vh; display: flex; flex-direction: column; }
#top {
  background: var(--header);
  color: var(--header-ink);
  min-height: 60px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
#top h1 { font-size: 21px; font-weight: 600; margin: 0; text-align: center; }
.back, .icon-btn {
  background: none; border: 0; color: var(--header-ink); font-weight: 600;
  min-height: var(--tap); padding: 0 8px;
}
.back-spacer { width: 64px; }
.head-actions { display: flex; }
#strip {
  background: var(--paper-2);
  color: var(--ink-soft);
  padding: 8px 14px;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}
#view { flex: 1; padding: 14px 14px 96px; }
#dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  min-height: 64px; z-index: 5;
}
#dock button {
  border: 0; background: transparent; color: var(--ink-soft);
  min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; font-weight: 600;
}
#dock button.on { color: var(--mint-dark); }
.glyph { width: 28px; height: 28px; color: var(--mint); display: inline-flex; }
.glyph svg { width: 28px; height: 28px; }
#dock .glyph { width: 22px; height: 22px; }
#dock .glyph svg { width: 22px; height: 22px; }

.page { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.home .greet { font-size: 36px; line-height: 1.1; margin: 4px 0; font-weight: 600; }
.card, .modules-hint {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: 0 1px 2px rgba(16, 35, 31, .08);
}
.card.inset { margin-top: 8px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 112px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  box-shadow: 0 1px 2px rgba(16, 35, 31, .08);
}
.tile strong { font-size: 16px; font-weight: 650; }
.tile span { color: var(--ink-soft); font-size: 15px; }
.launch, .btn, .btn-primary, .btn-danger, .btn-ghost {
  border-radius: 12px; border: 1px solid transparent; min-height: 52px; padding: 0 14px; font-weight: 600;
}
.launch {
  width: 100%; background: var(--danger); color: white; letter-spacing: .02em; font-size: 13px;
  text-transform: uppercase; border: 0;
}
.btn-primary { background: var(--mint); color: white; width: 100%; }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.field-label { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); margin: 0; }
input, select, textarea {
  width: 100%; background: white; border: 1px solid var(--line); border-radius: 10px;
  min-height: var(--tap); padding: 8px 10px;
}
textarea { min-height: 72px; }
.chip-row, .flag-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.flag-grid { display: grid; grid-template-columns: 1fr 1fr; }
.chip, .person-chip {
  min-height: var(--tap); border-radius: 999px; border: 1px solid var(--line); background: white; padding: 0 12px; font-weight: 600;
}
.chip.on { background: var(--mint); color: white; border-color: var(--mint); }
.person-chip { border-width: 2px; }
.switch {
  width: 56px; height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-2); position: relative; flex: 0 0 auto;
}
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: white; }
.switch.on { background: var(--mint); }
.switch.on span { left: 27px; }
.module-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.module-row.grey { opacity: .55; }
.list-row, .list-row.static {
  width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
}
.tag { display: inline-block; font-size: 13px; font-weight: 700; color: var(--mint-dark); }
.tag-warn { color: var(--warn); }
.muted { color: var(--ink-soft); }
.mono, .clock { font-family: var(--mono); }
.clock { font-size: 28px; }
.banner, .banner-gold, .banner-danger {
  border-radius: 12px; padding: 10px 12px; text-align: left; width: 100%; border: 1px solid var(--line); background: var(--paper-2);
}
.banner-gold { background: var(--gold-soft); border-color: var(--gold); }
.banner-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); font-weight: 700; }
.modules-hint { text-align: left; width: 100%; }
.check { display: flex; gap: 8px; align-items: center; min-height: var(--tap); }
.check input { width: auto; }
.person-head { display: flex; gap: 10px; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; display: inline-block; }
.prose h3 { margin: 12px 0 4px; font-size: 18px; }
.prose p { margin: 0 0 8px; }
.map-scroll { overflow-x: auto; max-width: 100%; }
.body-map { width: 220px; height: 320px; background: white; border-radius: 12px; }
.zone { fill: var(--paper-2); stroke: var(--ink); stroke-width: 1.4; }
.zone.on { fill: var(--danger-soft); stroke: var(--danger); }
.annotate { width: 100%; max-width: 320px; background: white; border: 1px solid var(--line); border-radius: 12px; touch-action: none; }
.prompt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chart { width: 100%; height: 140px; background: white; }
.series { fill: none; stroke: var(--mint); stroke-width: 2.5; }
.aim { stroke: var(--gold); stroke-dasharray: 4 4; }
.train-grid { display: grid; gap: 8px; }
.cell { border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; }
.cell.ok { background: #e5f6ee; }
.cell.bad { background: var(--danger-soft); }
.cell.wait { background: var(--gold-soft); }
.material-pre, #selfcheck { white-space: pre-wrap; font-family: var(--mono); font-size: 14px; }
.print-sheet h1 { font-size: 22px; }
.print-block { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.print-foot { font-size: 12px; color: var(--ink-soft); margin-top: 16px; }

#toast {
  position: fixed; left: 12px; right: 12px; bottom: 78px; background: var(--ink); color: var(--header-ink);
  padding: 12px 14px; border-radius: 12px; opacity: 0; pointer-events: none; z-index: 20;
}
#toast.show { opacity: 1; }
#modal, #sheet, #lock {
  position: fixed; inset: 0; background: rgba(16, 35, 31, .45); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
#modal[hidden], #sheet[hidden], #lock[hidden] { display: none; }
.modal-card, .sheet-card, .lock-card {
  background: var(--card); width: min(560px, 100%); border-radius: 16px 16px 0 0; padding: 16px; max-height: 90vh; overflow: auto;
}
.lock-card { margin: auto; border-radius: 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.rapid { overflow-x: hidden; }

@media (min-width: 800px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  #view { padding-bottom: 96px; }
  .btn-primary, .launch { width: auto; min-width: 220px; }
  .modal-card, .sheet-card { border-radius: 16px; margin-bottom: 8vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  #top, #strip, #dock, #toast, #modal, #sheet, #lock, .no-print { display: none !important; }
  body { background: white; }
  #view { padding: 0; }
  .print-sheet { display: block; }
}

#selfcheck { margin: 12px; }
