/* ==========================================================================
   EmberReady — "Safety Journey" design system.
   Calm, light, Apple-quality: soft off-white surfaces, deep charcoal text,
   cool blue/mint for safety & completion. Ember orange and alert red are
   reserved ONLY for genuine danger/fire information — never decoration.
   Mobile-first: this is the primary layout target, not an afterthought.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-sunken: #f0efe9;
  --border: #e4e2da;

  /* Text */
  --ink: #1c211f;
  --ink-muted: #5b6560;
  --ink-faint: #8a938e;

  /* Safety / calm / completion */
  --blue: #2f7dd1;
  --blue-soft: #e7f0fb;
  --mint: #2fa88f;
  --mint-soft: #e4f5f1;

  /* Danger — reserved */
  --ember: #e2621c;
  --ember-soft: #fdece0;
  --red: #d1352b;
  --red-soft: #fbe6e4;
  --amber: #c78a12;
  --amber-soft: #fbf0dd;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --shadow-soft: 0 2px 6px rgba(28, 33, 31, 0.06), 0 10px 24px rgba(28, 33, 31, 0.06);
  --shadow-raised: 0 6px 16px rgba(28, 33, 31, 0.1), 0 16px 40px rgba(28, 33, 31, 0.1);

  --motion-fast: 140ms;
  --motion-base: 260ms;
  --motion-slow: 520ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --nav-height: 72px;
}

/* High Contrast accessibility mode — boosts contrast, removes soft tints */
body.high-contrast {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-sunken: #eeeeee;
  --border: #000000;
  --ink: #000000;
  --ink-muted: #1a1a1a;
  --ink-faint: #333333;
  --blue: #0047ab;
  --blue-soft: #ffffff;
  --mint: #00695c;
  --mint-soft: #ffffff;
  --ember: #b3410a;
  --ember-soft: #ffffff;
  --red: #a3081a;
  --red-soft: #ffffff;
  --amber: #8a5a00;
  --amber-soft: #ffffff;
  --shadow-soft: none;
  --shadow-raised: none;
}

body.high-contrast .card,
body.high-contrast .journey-chapter,
body.high-contrast button,
body.high-contrast .pill {
  border: 2px solid var(--border) !important;
}

* {
  box-sizing: border-box;
}

html, body {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  line-height: 1.5;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + 12px);
}

h1, h2, h3, h4 {
  color: var(--ink);
  letter-spacing: -0.015em;
  margin: 0 0 8px;
}

p { margin: 0 0 8px; }

a { color: var(--blue); }

.hidden { display: none !important; }

.fine-print {
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* --------------------------------------------------------------------
   Top disclaimer strip — quiet, not alarming, always present
   -------------------------------------------------------------------- */
.disclaimer-strip {
  background: var(--surface-sunken);
  color: var(--ink-muted);
  padding: 10px 130px 10px 20px;
  font-size: 0.82rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.disclaimer-strip strong { color: var(--ink); }

/* --------------------------------------------------------------------
   Screen shell
   -------------------------------------------------------------------- */
.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 20px 8px;
}

/* Clears the fixed top-right settings pill (mounted by shared/effects.js on
   every screen) so it never overlaps a centered title. */
main.screen {
  padding-top: 52px;
}

.screen-header {
  text-align: center;
  margin-bottom: 18px;
}

.screen-header .brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.screen-header h1 {
  font-size: 1.3rem;
  margin: 0;
}

.screen-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.screen-subtitle {
  color: var(--ink-muted);
  font-size: 1rem;
  margin-bottom: 20px;
}

/* --------------------------------------------------------------------
   Cards & pills (used sparingly — one focal element per screen)
   -------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.pill-safe { background: var(--mint-soft); color: var(--mint); }
.pill-prepare { background: var(--amber-soft); color: var(--amber); }
.pill-high { background: var(--ember-soft); color: var(--ember); }
.pill-emergency { background: var(--red-soft); color: var(--red); }
.pill-unknown { background: var(--surface-sunken); color: var(--ink-muted); }

/* --------------------------------------------------------------------
   Buttons — large touch targets, soft press depth, magnetic hover
   -------------------------------------------------------------------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out), background var(--motion-fast);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), var(--shadow-soft);
}

button:hover, .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08), var(--shadow-raised);
}

button:active, .btn:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.08), var(--shadow-soft);
}

button:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.btn-block { display: flex; width: 100%; }

.btn-ember { background: var(--ember); }
.btn-red { background: var(--red); }
.btn-mint { background: var(--mint); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover { box-shadow: var(--shadow-soft); }

.btn-text {
  background: transparent;
  color: var(--blue);
  box-shadow: none;
  padding: 10px 6px;
  font-weight: 600;
}

.btn-text:hover { transform: none; box-shadow: none; text-decoration: underline; }

/* --------------------------------------------------------------------
   Home screen — protection ring + illustrated home
   -------------------------------------------------------------------- */
.home-hero {
  text-align: center;
  padding: 10px 0 18px;
}

.protection-ring {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 0 auto 18px;
}

.protection-ring svg.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.protection-ring .ring-track {
  fill: none;
  stroke: var(--surface-sunken);
  stroke-width: 14;
}

.protection-ring .ring-fill {
  fill: none;
  stroke: var(--ring-color, var(--blue));
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--motion-slow) var(--ease-out), stroke var(--motion-base);
}

.ring-center-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.risk-percent {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.risk-percent-caption {
  font-size: 0.95rem;
  color: var(--ink-muted);
  font-weight: 600;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.home-status-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.home-area-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.home-explainer {
  color: var(--ink);
  font-size: 1rem;
  max-width: 340px;
  margin: 0 auto 4px;
}

.home-search {
  padding: 10px 0 18px;
}

.recommended-action-card {
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--blue-soft);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.recommended-action-card .ra-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  color: var(--blue);
}

.recommended-action-card .ra-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--blue);
  font-weight: 700;
}

.recommended-action-card .ra-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

/* Spark micro-animation: ember flies up and becomes a blue spark on the ring */
.ember-spark {
  position: fixed;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff9a5c, var(--ember));
  box-shadow: 0 0 10px 2px rgba(226, 98, 28, 0.6);
  pointer-events: none;
  z-index: 2000;
  transition: all 650ms var(--ease-out);
}

.ember-spark.arrived {
  background: radial-gradient(circle, #cfe6ff, var(--blue));
  box-shadow: 0 0 14px 3px rgba(47, 125, 209, 0.8);
}

/* --------------------------------------------------------------------
   Bottom navigation — exactly four destinations
   -------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 900;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

body.high-contrast .bottom-nav {
  background: #ffffff;
  border-top: 2px solid #000;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-faint);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  transition: color var(--motion-fast);
}

.bottom-nav a svg {
  width: 24px;
  height: 24px;
}

.bottom-nav a.active {
  color: var(--blue);
}

.bottom-nav a:active {
  transform: scale(0.94);
}

/* --------------------------------------------------------------------
   Forms & inputs
   -------------------------------------------------------------------- */
label {
  display: block;
  font-weight: 600;
  margin: 14px 0 6px;
}

input[type="text"], input[type="tel"], input[type="email"], select {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

fieldset {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 14px 0;
}

fieldset legend {
  font-weight: 700;
  padding: 0 4px;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  margin: 10px 0;
}

fieldset input[type="radio"], fieldset input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--blue);
}

.error-text {
  color: var(--red);
  font-weight: 600;
  margin-top: 8px;
}

/* Toggle switch (settings) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.toggle-row .toggle-label {
  font-weight: 600;
}

.toggle-row .toggle-sub {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--surface-sunken);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  transition: background var(--motion-fast);
  cursor: pointer;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--motion-fast) var(--ease-out);
}

.switch input:checked + .track {
  background: var(--blue);
  border-color: var(--blue);
}

.switch input:checked + .track .knob {
  transform: translateX(20px);
}

/* --------------------------------------------------------------------
   Simple checklist
   -------------------------------------------------------------------- */
.checklist-heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 18px 0 0;
  color: var(--ink);
}

ul.simple-checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

ul.simple-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
}

ul.simple-checklist li:last-child { border-bottom: none; }

ul.simple-checklist input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin-top: 1px;
  flex: 0 0 auto;
  accent-color: var(--mint);
}

ul.simple-checklist input[type="checkbox"]:checked {
  animation: check-pop var(--motion-base) var(--ease-out);
}

@keyframes check-pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

ul.simple-checklist label {
  margin: 0;
  font-weight: 400;
  line-height: 1.4;
}

.reason-tag {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-top: 2px;
}

/* --------------------------------------------------------------------
   Risk summary (simple version — used inside "Know Your Risk")
   -------------------------------------------------------------------- */
.risk-summary {
  text-align: center;
}

.risk-summary .rs-score {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  margin: 6px 0 2px;
}

.risk-summary .rs-location {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.risk-summary .rs-explainer {
  font-size: 1rem;
  color: var(--ink);
  margin: 10px 0;
}

.risk-summary .rs-precision {
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
  margin-top: 10px;
  text-align: left;
}

.rs-components {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
  text-align: left;
}

.rs-component {
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.rs-component .rc-label {
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.rs-component .rc-value {
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 2px;
}

details.rs-details {
  margin-top: 14px;
  text-align: left;
}

details.rs-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--blue);
  padding: 8px 0;
}

.rs-factor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 8px;
}

.rs-factor-table th, .rs-factor-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.rs-factor-table th { color: var(--ink-muted); font-weight: 600; }

.rs-unavailable { opacity: 0.55; }

.safety-line {
  background: var(--red-soft);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 14px;
}

.ai-explain-block {
  margin: 14px 0;
}

.ai-explain-block .btn {
  padding: 10px 18px;
  font-size: 0.95rem;
}

.rs-ai-explanation {
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------------
   Safety Journey — vertical story pathway
   -------------------------------------------------------------------- */
.journey-path {
  position: relative;
  padding-left: 34px;
}

.journey-path::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--border);
  border-radius: 3px;
}

.journey-path .journey-path-fill {
  position: absolute;
  left: 14px;
  top: 10px;
  width: 3px;
  background: linear-gradient(180deg, var(--mint), var(--blue));
  border-radius: 3px;
  transition: height var(--motion-slow) var(--ease-out);
}

.journey-chapter {
  position: relative;
  margin-bottom: 22px;
}

.journey-chapter .chapter-node {
  position: absolute;
  left: -34px;
  top: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--ember);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--ember);
  transition: all var(--motion-base) var(--ease-out);
  z-index: 1;
}

.journey-chapter.complete .chapter-node {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.journey-chapter .chapter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  transition: border-color var(--motion-base);
}

.journey-chapter.complete .chapter-card {
  border-color: var(--blue-soft);
}

.journey-chapter .chapter-scene {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  background: var(--ember-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
  transition: background var(--motion-base);
}

.journey-chapter.complete .chapter-scene {
  background: var(--blue-soft);
}

.journey-chapter .chapter-scene svg {
  width: 88px;
  height: 88px;
  color: var(--ember);
  transition: color var(--motion-base);
}

.journey-chapter.complete .chapter-scene svg {
  color: var(--blue);
}

.journey-chapter .chapter-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.journey-chapter .chapter-sentence {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.journey-chapter .chapter-body {
  margin-top: 6px;
}

.journey-chapter .chapter-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.journey-chapter.complete .chapter-status { color: var(--blue); }

/* --------------------------------------------------------------------
   Map screen
   -------------------------------------------------------------------- */
body.map-screen {
  padding-bottom: var(--nav-height);
}

.map-screen-frame {
  position: fixed;
  inset: 0 0 var(--nav-height) 0;
}

.map-screen-frame .leaflet-map {
  width: 100%;
  height: 100%;
}

.map-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 800;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0));
  display: flex;
  gap: 8px;
}

.map-top-bar input {
  flex: 1;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.filter-row {
  display: flex;
  gap: 6px;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  align-self: flex-start;
}

.filter-btn {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
}

.filter-btn:hover {
  transform: none;
  box-shadow: none;
}

.filter-btn.active {
  background: var(--blue);
  color: #fff;
}

.eq-status-line {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}

.locate-me-btn {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height) + 20px);
  z-index: 800;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  padding: 0;
  background: var(--surface);
  color: var(--blue);
  box-shadow: var(--shadow-raised);
}

.locate-me-btn svg { width: 26px; height: 26px; }

.reset-view-btn {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height) + 20px + 54px + 12px);
  z-index: 800;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  padding: 0;
  background: var(--surface);
  color: var(--ink-muted);
  box-shadow: var(--shadow-raised);
}

.reset-view-btn svg { width: 24px; height: 24px; }

.map-info-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--nav-height);
  z-index: 850;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0));
  max-height: 55vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--motion-base) var(--ease-out);
}

.map-info-sheet.open {
  transform: translateY(0);
}

.map-legend-strip {
  position: fixed;
  left: 16px;
  bottom: calc(var(--nav-height) + 20px);
  z-index: 800;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: var(--shadow-soft);
  font-size: 0.75rem;
}

.map-legend-strip .legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0;
}

.map-legend-strip .legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.map-legend-strip .legend-vintage {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--ink-faint);
  font-size: 0.68rem;
}

.leaflet-tile-pane {
  filter: saturate(0.85) brightness(1.02);
}

/* Clears the global settings gear (top:12/right:12 on every screen) */
.map-screen .leaflet-top.leaflet-right {
  margin-top: 56px;
}

/* --------------------------------------------------------------------
   Modal / popup — tap a summary row, see the full detail
   -------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 33, 31, 0.45);
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 620px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal-panel {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-raised);
  overflow-y: auto;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom, 0));
  animation: modal-in var(--motion-base) var(--ease-out);
}

@media (min-width: 620px) {
  .modal-panel {
    border-radius: var(--radius-lg);
    margin-bottom: 40px;
    max-height: 80vh;
  }
}

@keyframes modal-in {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

body.reduce-motion .modal-panel { animation: none; }
body.modal-open { overflow: hidden; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  box-shadow: none;
  font-size: 1.6rem;
  line-height: 1;
  padding: 2px 8px;
  color: var(--ink-muted);
  flex: 0 0 auto;
}

.modal-close:hover {
  transform: none;
  box-shadow: none;
  color: var(--ink);
}

/* Compact clickable summary row — tap for the full detail in a modal */
.tap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow: none;
  color: var(--ink);
}

.tap-row:hover {
  transform: none;
  box-shadow: var(--shadow-soft);
}

.tap-row .tap-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tap-row .tap-row-title {
  font-weight: 700;
  font-size: 1rem;
}

.tap-row .tap-row-sub {
  font-size: 0.85rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tap-row .tap-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.tap-row .tap-row-chevron {
  color: var(--ink-faint);
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.tap-row .tap-row-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  white-space: nowrap;
}

.tap-row .tap-row-badge.badge-attn {
  background: var(--ember-soft);
  color: var(--ember);
}

.tap-row .tap-row-badge.badge-done {
  background: var(--mint-soft);
  color: var(--mint);
}

/* Accordion sub-sections inside a modal (e.g. checklist categories) */
details.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  overflow: hidden;
}

details.accordion summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  background: var(--surface-sunken);
}

details.accordion summary::-webkit-details-marker { display: none; }

details.accordion .accordion-count {
  font-weight: 600;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

details.accordion .simple-checklist {
  padding: 4px 14px 6px;
}

/* --------------------------------------------------------------------
   Autocomplete dropdown
   -------------------------------------------------------------------- */
.autocomplete-dropdown {
  position: absolute;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 6px;
  box-shadow: var(--shadow-raised);
}

.autocomplete-dropdown li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.autocomplete-dropdown li:hover, .autocomplete-dropdown li.active {
  background: var(--blue-soft);
  color: var(--blue);
}

/* --------------------------------------------------------------------
   Reduce Motion
   -------------------------------------------------------------------- */
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0ms !important;
  transition-duration: 0.001ms !important;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

.settings-fab {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--surface);
  color: var(--ink-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0;
  box-shadow: var(--shadow-soft);
}

/* --------------------------------------------------------------------
   Small helpers
   -------------------------------------------------------------------- */
.icon-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-spacer { height: 20px; }

@media (min-width: 620px) {
  .screen { padding-top: 28px; }
}
