:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #15233b;
  --muted: #5b6b82;
  --line: #e1e6ee;
  --primary: #0b4fa8;
  --primary-soft: #e6effa;
  --red: #c8102e;
  --red-soft: #fce8eb;
  --amber: #8a5a00;
  --amber-soft: #fdf1d8;
  --green: #18713d;
  --green-soft: #e2f4e8;
  --primary-solid: #0b4fa8;
  --input-bg: #ffffff;
  --input-line: #b9c3d2;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #000000;
  --card: #121821;
  --text: #eef2f8;
  --muted: #a3b1c4;
  --line: #2a3442;
  --primary: #8ab8ff;
  --primary-soft: #1c2c44;
  --red: #c8102e;
  --red-soft: #3d1219;
  --amber: #f4c97a;
  --amber-soft: #33270f;
  --green: #84d9a3;
  --green-soft: #12301f;
  --input-bg: #0b0f15;
  --input-line: #465365;
}
:root[data-theme=dark] .badge.eat,
:root[data-theme=dark] .badge.expired,
:root[data-theme=dark] .btn.danger { color: #ff9dab; }
.switch { display: flex; align-items: center; gap: 12px; padding: 12px 0; text-align: left; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; position: relative; width: 52px; height: 30px; border-radius: 15px; background: var(--input-line); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked + .track { background: var(--primary-solid); }
.switch input:checked + .track::after { left: 25px; }
.switch input:focus-visible + .track { outline: 3px solid #f0a500; outline-offset: 2px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar[hidden] { display: none; }
.topbar .inner { display: flex; align-items: center; justify-content: space-between; max-width: 720px; margin: 0 auto; padding: 8px 16px; }
.topbar .brand { width: 44px; height: 44px; padding: 4px; border: 0; background: none; cursor: pointer; }
.topbar .brand img { display: block; width: 100%; height: 100%; border-radius: 9px; }
.topbar .profile {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 4px 0 12px;
  border: 0; border-radius: 22px;
  background: none; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.topbar .profile[aria-current=page] { background: var(--primary-soft); }
.topbar .avatar {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-solid); color: #fff;
  font-weight: 700;
}
.topbar .inner { gap: 8px; }
.topbar .brand { margin-right: auto; }
.help-btn {
  flex: none; width: 36px; height: 36px; margin: 4px;
  border: 2px solid var(--primary); border-radius: 50%;
  background: none; color: var(--primary);
  font: inherit; font-weight: 700; cursor: pointer;
}
.bell { position: relative; border-color: transparent; font-size: 18px; margin: 4px 0; }
.bell-count {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px;
}
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 180px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.menu-panel button {
  display: block; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 0; border-radius: 8px; background: none; color: var(--text);
  font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.menu-panel button:hover { background: var(--primary-soft); }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
h3 { font-size: 16px; margin: 16px 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--primary); }
ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  display: block;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
  color: inherit;
  text-align: left;
  text-decoration: none;
  font: inherit;
}
button.card { cursor: pointer; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.tile-icon {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--primary-soft);
  font-size: 22px;
}
.chev { color: var(--muted); font-size: 22px; }
.title { font-weight: 650; }

.hero-alert {
  background: var(--red); color: #fff; border: 0;
}
.hero-alert .tile-icon { background: rgba(255,255,255,.2); }
.hero-alert .chev, .hero-alert .muted { color: #fff; }

.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--primary); }

.btn {
  display: inline-block;
  min-height: 48px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--primary-solid);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn.full { width: 100%; margin-bottom: 8px; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid #f0a500; outline-offset: 2px; }

label.field { display: block; margin-bottom: 14px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--input-line);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}
.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg button {
  flex: 1;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.seg button[aria-pressed=true] { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }

.stepper { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stepper:last-child { border-bottom: 0; }
.stepper .ctl { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 44px; height: 44px;
  border: 0; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 22px; font-weight: 700; cursor: pointer;
}
.stepper output { min-width: 24px; text-align: center; font-weight: 700; }

.check { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--primary); }
.check.done .name { text-decoration: line-through; color: var(--muted); }
.qty { flex: none; font-weight: 700; color: var(--primary); text-align: right; max-width: 40%; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.soon { background: var(--amber-soft); color: var(--amber); }
.badge.eat, .badge.expired { background: var(--red-soft); color: var(--red); }

.notice { padding: 12px 14px; border-radius: 12px; background: var(--primary-soft); margin-bottom: 12px; font-size: 14px; }
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.back { background: none; border: 0; padding: 8px 0; margin-bottom: 8px; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }

#reader { border-radius: 12px; overflow: hidden; background: #000; min-height: 220px; }
.scan-box { position: relative; }
.scan-frame {
  position: absolute; top: 50%; left: 50%;
  width: min(284px, calc(100% - 16px)); height: 134px;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .85);
  border-radius: 10px;
  pointer-events: none;
}
.scan-box.ok .scan-frame { border: 5px solid #2ecc71; box-shadow: 0 0 0 4px rgba(46, 204, 113, .35); }

.emergency { position: fixed; inset: 0; background: #0f1a2b; color: #f3f6fb; overflow: auto; z-index: 10; padding: calc(env(safe-area-inset-top) + 20px) 16px 40px; }
.emergency .inner { max-width: 720px; margin: 0 auto; }
.emergency .check { border-color: #2c3b52; }
.emergency .check.done .name { color: #93a3ba; }
.priority { margin-bottom: 12px; padding: 4px 12px; border-left: 6px solid; border-radius: 10px; background: #1d2c43; }
.priority h2 { margin: 8px 0 2px; font-size: 15px; }
.priority.now { border-color: #ff5a6e; }
.priority.now h2 { color: #ff9dab; }
.priority.soon { border-color: #f4b73f; }
.priority.soon h2 { color: #f4c97a; }
.priority.later { border-color: #5aa2ff; }
.priority.later h2 { color: #8ab8ff; }
.priority .check:last-child { border-bottom: 0; }
.emergency a.call { display: flex; justify-content: space-between; padding: 14px 16px; margin-bottom: 8px; border-radius: 12px; background: #1d2c43; color: #fff; text-decoration: none; }
.emergency .btn { background: #fff; color: #0f1a2b; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav[hidden] { display: none; }
.nav button {
  flex: 1; max-width: 180px;
  min-height: 60px;
  border: 0; background: none;
  color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.nav span { display: block; font-size: 21px; line-height: 1.2; }
.nav button[aria-current=page] { color: var(--primary); }

.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 116px);
  min-height: calc(100dvh - 116px);
  text-align: center;
}
.intro .art { display: block; width: 100%; max-width: 300px; height: auto; margin: 8px auto 16px; }
.intro .lead { max-width: 420px; }
.intro .bullets { margin: 8px 0 12px; padding-left: 20px; text-align: left; }
.intro .bullets li { margin-bottom: 6px; }
.intro .points { list-style: none; margin: 8px 0 16px; padding: 0; max-width: 420px; }
.intro .points li { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; text-align: left; }
.intro .points svg { flex: none; width: 52px; height: 52px; }
.intro .points strong { display: block; }
.intro .actions { width: 100%; max-width: 420px; margin-top: auto; padding-top: 12px; }
.intro .disclaimer { margin: 8px 0 0; }
.intro .back { align-self: flex-start; }
.phone-demo {
  position: relative; overflow: hidden; flex: none;
  width: 150px; height: 250px; margin: 4px auto 16px;
  border: 6px solid #15233b; border-radius: 26px;
  background: linear-gradient(#cfe0f5, #e6effa);
}
.phone-apps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 18px 10px; }
.phone-apps i { aspect-ratio: 1; border-radius: 6px; background: #fff; opacity: .75; }
.phone-icon { width: 100%; aspect-ratio: 1; border-radius: 6px; animation: phone-icon 7s infinite; }
.phone-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 36px; display: grid; place-items: center; background: #fff; }
.phone-share {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  color: #0b4fa8; font-size: 15px; animation: phone-tap 7s infinite;
}
.phone-sheet {
  position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 10px 8px;
  border-radius: 10px; background: #fff; color: #15233b;
  font-size: 10px; font-weight: 600; text-align: left;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25); transform: translateY(130%);
  animation: phone-sheet 7s infinite;
}
.phone-sheet b { float: right; color: #0b4fa8; }
@keyframes phone-tap {
  0%, 10%, 26%, 100% { background: transparent; transform: scale(1); }
  16%, 20% { background: #0b4fa8; color: #fff; transform: scale(1.2); }
}
@keyframes phone-sheet {
  0%, 22% { transform: translateY(130%); background: #fff; }
  30%, 44% { transform: translateY(0); background: #fff; }
  48% { transform: translateY(0); background: #cfe0f5; }
  56%, 100% { transform: translateY(130%); background: #fff; }
}
@keyframes phone-icon {
  0%, 58% { transform: scale(0); opacity: 0; }
  68% { transform: scale(1.35); opacity: 1; }
  74%, 96% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .phone-icon, .phone-share, .phone-sheet { animation: none; }
}
.intro .steps { width: 100%; max-width: 420px; margin: 8px 0; padding-left: 24px; text-align: left; }
.intro .steps li { margin-bottom: 10px; }

.map-box { width: 100%; height: 55vh; min-height: 300px; border-radius: 12px; overflow: hidden; background: var(--line); }
.map-box .maplibregl-popup-content { color: #15233b; }
.shelter .distance { flex: none; text-align: right; }

.tile-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile-pair .card { display: flex; flex-direction: column; gap: 6px; }
.emergency .btn + .btn { margin-top: 0; }

.status-help { color: var(--red); font-weight: 700; }
:root[data-theme=dark] .status-help { color: #ff9dab; }

dialog.confirm {
  width: calc(100% - 32px);
  max-width: 440px;
  padding: 20px;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
}
dialog.confirm::backdrop { background: rgba(15, 26, 43, .6); }
dialog.confirm h2 { margin-top: 0; }
.emergency-banner { padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--red); color: #fff; font-weight: 700; }

.disclaimer { margin-top: 24px; font-size: 13px; color: var(--muted); text-align: center; }
@media print {
  .nav, .topbar, .back, .btn, .seg { display: none !important; }
}
