/* Shell and shared components. Screen-specific rules live in screens-a.css and screens-b.css. */
:root {
  color-scheme: light;
  --bg: #f8f4ec;
  --surface: #ffffff;
  --surface-2: #f1ebdf;
  --ink: #22302b;
  --ink-2: #4d5c55;
  --line: #ddd5c6;
  --line-strong: #8a9690;
  --primary: #24614f;
  --primary-ink: #ffffff;
  --primary-soft: #e0efe9;
  --amber-soft: #fdf1d8;
  --amber-line: #e0b561;
  --amber-ink: #5e4100;
  --safety-soft: #e6eff7;
  --safety-line: #8fb2d1;
  --safety-ink: #1d3c57;
  --radius: 14px;
  --radius-sm: 10px;
  --gutter: 16px;
  --tap: 44px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.5 var(--font);
  overflow-x: hidden;
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); }
ul, ol { margin: 0; padding-left: 1.3em; }
li + li { margin-top: 0.35em; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.icon {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--primary); color: var(--primary-ink); padding: 10px 14px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 8px; }
.noscript { padding: var(--gutter); }

/* Layout */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 60px; padding: max(8px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 8px max(var(--gutter), env(safe-area-inset-left));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; min-height: var(--tap); flex: none; }
.brand-mark { width: 34px; height: 34px; flex: none; color: var(--primary); }
.brand-text { display: grid; line-height: 1.05; }
.brand-name { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.brand-sub { font-size: 1rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.people-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 6px 12px; flex: none;
  background: var(--safety-soft); color: var(--safety-ink); border: 1px solid var(--safety-line);
  border-radius: 999px; font-size: 1rem; font-weight: 650; text-decoration: none; white-space: nowrap;
}
@media (max-width: 440px) {
  .people-btn { width: 128px; padding: 4px 10px; border-radius: var(--radius-sm); line-height: 1.1; white-space: normal; text-align: left; }
}
.people-btn .icon { width: 20px; height: 20px; }

.app-body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.no-nav .app-body { padding-bottom: 32px; }
.no-nav .app-main, .no-nav .app-notes { max-width: 560px; }
.app-main, .app-notes { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 var(--gutter); }
.app-main { padding-top: 18px; outline: none; }
@media (min-width: 900px) { .app-main.is-wide { max-width: 980px; } }
.app-notes:empty { display: none; }
.app-notes { padding-top: 12px; display: grid; gap: 8px; }

.app-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.no-nav .app-nav { display: none; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--ink-2); text-decoration: none; font-size: 1rem; font-weight: 600;
}
.nav-item[aria-current="page"] { color: var(--primary); }
.nav-item[aria-current="page"] .icon { stroke-width: 2.4; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 216px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
  .app.no-nav { grid-template-columns: 1fr; }
  .app-header { grid-column: 1 / -1; padding-left: 24px; padding-right: 24px; }
  .app-nav {
    position: sticky; top: 76px; align-self: start; grid-template-columns: 1fr; gap: 4px;
    padding: 16px 12px; background: transparent; border: 0;
  }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: var(--radius-sm); font-size: 1rem; }
  .nav-item:hover { background: var(--surface-2); }
  .nav-item[aria-current="page"] { background: var(--primary-soft); }
  .app-body { padding-bottom: 40px; }
  .app-main { padding-top: 28px; }
}

/* Page */
.page-head { margin-bottom: 16px; display: grid; gap: 6px; }
.lead { color: var(--ink-2); }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); width: fit-content; margin-left: -6px; padding-right: 8px; font-weight: 600; text-decoration: none; }
.stack { display: grid; gap: 14px; }
.section { display: grid; gap: 10px; margin-top: 22px; }
.help { color: var(--ink-2); font-size: 1rem; }
.muted { color: var(--ink-2); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: grid; gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; max-width: 100%;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--line-strong); }
.btn-quiet { background: transparent; color: var(--primary); }
.btn[disabled] { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); cursor: default; }
.btn[aria-busy="true"] { cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-full { width: 100%; }

/* List rows */
.row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.row-icon { display: inline-flex; color: var(--primary); }
.row-text { display: grid; flex: 1; min-width: 0; }
.row-title { font-weight: 650; }
.row-sub { font-size: 1rem; color: var(--ink-2); }
.row-chevron { display: inline-flex; color: var(--ink-2); }
.row-list { display: grid; gap: 8px; }

/* Notes */
.note { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.note-amber { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber-ink); }
.note-safety { background: var(--safety-soft); border-color: var(--safety-line); color: var(--safety-ink); font-weight: 600; }
.banner { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: var(--radius-sm); background: var(--primary-soft); border: 1px solid var(--primary); }
.banner .btn { flex: none; padding-left: 10px; padding-right: 10px; }
.banner a { flex: 1; min-height: var(--tap); display: flex; align-items: center; color: var(--ink); font-weight: 650; text-decoration: none; }
.banner-note { background: var(--surface-2); border-color: var(--line); }
.banner-text { flex: 1; padding: 6px 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); flex: none; background: none; border: 0; color: inherit; cursor: pointer; border-radius: var(--radius-sm); }

/* Forms */
.field { display: grid; gap: 6px; }
label { font-weight: 600; }
.input, input[type="text"], input[type="tel"], input[type="number"], input[type="time"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 130px; resize: vertical; }

/* Choices */
.choice-list { display: grid; gap: 8px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice-grid .choice { justify-content: center; padding-left: 4px; padding-right: 4px; text-align: center; }
.choice {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 10px 14px;
  background: var(--surface); color: var(--ink); text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; cursor: pointer;
}
.choice[aria-pressed="true"], .choice[aria-checked="true"] { background: var(--primary-soft); border-color: var(--primary); font-weight: 650; box-shadow: inset 0 0 0 1px var(--primary); }

/* Check box row */
.check-row { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check-row input { width: 24px; height: 24px; flex: none; margin: 0; accent-color: var(--primary); }
.field-why { padding: 8px 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 1rem; }
.form-needed { min-height: 1.5em; color: var(--amber-ink); }

/* Two columns on wide screens */
.two-col { display: grid; gap: 0; }
.two-col > .section:first-child { margin-top: 0; }
@media (min-width: 900px) {
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
  .two-col > .section { margin-top: 0; }
  .help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tick rows */
.tick {
  width: 28px; height: 28px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: transparent;
}
[aria-checked="true"] > .tick, .tick.is-on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.tick .icon { width: 18px; height: 18px; stroke-width: 3; }
.tick-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 8px 0; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(30, 40, 36, 0.45); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.sheet { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
@media (min-width: 900px) { .sheet-backdrop { align-items: center; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); z-index: 45;
  transform: translateX(-50%); max-width: calc(100% - 32px); width: max-content;
  padding: 10px 16px; background: var(--ink); color: #fff; border-radius: var(--radius-sm);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.toast.is-on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
