:root {
  --bg: #fbf6ee;
  --surface: #ffffff;
  --surface-2: #f3ece0;
  --ink: #16193a;
  --ink-soft: #4a4f6e;
  --line: #16193a;
  --accent: #e8505b;
  --accent-ink: #ffffff;
  --blue: #2f6fdf;
  --good: #1f8a4c;
  --good-bg: #dff3e6;
  --warn: #9a4a00;
  --warn-bg: #ffe8cc;
  --day: var(--accent);
  --radius: 18px;
  --shadow: 0 3px 0 var(--line);
  --tap: 52px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11152a;
    --surface: #1c2142;
    --surface-2: #262c55;
    --ink: #f6f2ea;
    --ink-soft: #c2c5dc;
    --line: #000000;
    --accent: #ff6f78;
    --accent-ink: #11152a;
    --blue: #7aa8ff;
    --good: #6be39a;
    --good-bg: #173a29;
    --warn: #ffc27a;
    --warn-bg: #43301a;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  min-height: 100vh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .6em; }
ul { margin: 0; padding-left: 1.2em; }
li { margin-bottom: .4em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: #1d2a5b;
  color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #0b0e1e; } }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; margin-right: auto; }
.status {
  min-height: 40px;
  border: 2px solid rgba(255,255,255,.5);
  background: transparent;
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font: 600 .9rem var(--font);
  white-space: nowrap;
}
.status.ready { background: #1f8a4c; border-color: #1f8a4c; }
.status.busy { background: #9a6a00; border-color: #9a6a00; }
.status.off { background: #b3261e; border-color: #b3261e; }
.iconbtn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.4rem;
  text-decoration: none;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--ink);
  font-weight: 600;
}
.banner[hidden] { display: none; }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 2px solid var(--line);
}
.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  border-radius: 14px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: .75rem;
  text-decoration: none;
}
.tabs a span { font-size: 1.5rem; line-height: 1.1; }
.tabs a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }

/* ---------- layout ---------- */
main { padding: 16px; max-width: 680px; margin: 0 auto; outline: none; }
.stack > * + * { margin-top: 14px; }

.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.flat { box-shadow: none; }
.card.hero {
  background: var(--day);
  color: #fff;
}
@media (prefers-color-scheme: dark) { .card.hero { color: #11152a; } }
.card.hero .muted { color: inherit; opacity: .85; }

.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }
.kicker { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 800; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 2px solid currentColor;
  font-size: .8rem;
  font-weight: 700;
}
.todo {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  font-size: .9rem;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 700 1rem var(--font);
  text-decoration: none;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { display: flex; width: 100%; }

/* ---------- day switcher ---------- */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seg button {
  min-height: var(--tap);
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 800 1.05rem var(--font);
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg .today-dot::after { content: " ●"; color: var(--accent); }

/* ---------- stops ---------- */
.stop { position: relative; }
.stop.optional { border-style: dashed; }
.stop.done { opacity: .7; }
.stop.next { outline: 4px solid var(--day); outline-offset: 2px; }
.stop-head { display: flex; gap: 12px; align-items: flex-start; }
.stop-emoji {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 1.8rem;
}
.stop-time { font-weight: 800; color: var(--day); font-variant-numeric: tabular-nums; }
.stop h3 { margin: 2px 0 0; }
.stop .desc { margin-top: 10px; }
.kid {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
}
.kid strong { color: var(--day); }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 10px 0; }
dl.facts dt { font-weight: 700; color: var(--ink-soft); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.address { user-select: all; -webkit-user-select: all; }

.checks { list-style: none; padding: 0; margin: 10px 0 0; }
.checks li { margin: 0; }
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 4px 2px;
  font-weight: 600;
  cursor: pointer;
}
.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 30px; height: 30px;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  display: grid;
  place-items: center;
}
.check input:checked { background: var(--good); border-color: var(--good); }
.check input:checked::after { content: "✓"; color: #fff; font-weight: 900; font-size: 1.1rem; }
@media (prefers-color-scheme: dark) { .check input:checked::after { color: #11152a; } }
.check input:checked + span { text-decoration: line-through; color: var(--ink-soft); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

details.more summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
}

textarea, input[type="text"], input[type="tel"], input[type="date"], input[type="time"], input[type="number"] {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: 1rem var(--font);
}
textarea { min-height: 140px; resize: vertical; }
label.field { display: block; font-weight: 700; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 4px; }
.saved { font-size: .85rem; color: var(--good); min-height: 1.2em; }

/* ---------- travel ---------- */
.journey-link { display: flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; }
.journey-link > span:last-child { display: flex; flex-direction: column; }
.jl-title { font-size: 1.1rem; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step.done { opacity: .65; }
.step.next { outline: 4px solid var(--blue); outline-offset: 2px; }
.step h3 { margin-top: 10px; }
.step p { margin-bottom: 0; }
.step-num {
  flex: none;
  width: 52px; height: 52px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font: 900 1.3rem var(--font);
}
.step-num[aria-pressed="true"] { background: var(--good); border-color: var(--good); color: #fff; }
@media (prefers-color-scheme: dark) { .step-num[aria-pressed="true"] { color: #11152a; } }
.hop { padding: 10px 0; border-bottom: 2px dashed var(--surface-2); }
.hop:last-child { border-bottom: 0; }
.hop-route { font-weight: 800; }

/* ---------- today ---------- */
.big-time { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.timers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timer { text-align: center; }
.timer .val { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- hunt ---------- */
.hunt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 130px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 600 .9rem/1.25 var(--font);
  text-align: center;
}
.sticker .e { font-size: 2.4rem; filter: grayscale(1); opacity: .45; transition: transform .2s; }
.sticker[aria-pressed="true"] { border-style: solid; background: var(--good-bg); box-shadow: var(--shadow); }
.sticker[aria-pressed="true"] .e { filter: none; opacity: 1; transform: scale(1.15) rotate(-6deg); }
.progress { height: 18px; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.progress > div { height: 100%; background: var(--good); transition: width .3s; }

/* ---------- cards (lost child / taxi) ---------- */
.showcard {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  background: #fff;
  color: #000;
  font-size: 1.4rem;
  line-height: 1.35;
}
.showcard h2 { font-size: 2rem; }
.showcard .huge { font-size: 2.2rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.showcard .phone { display: block; font-size: 2.2rem; font-weight: 800; color: #000; text-decoration: none; padding: 8px 0; }
.showcard .en { color: #444; font-size: 1.05rem; margin-top: 4px; }
.showcard .close { position: sticky; top: 0; float: right; background: #fff; color: #000; border-color: #000; box-shadow: 0 3px 0 #000; }
.showcard hr { border: 0; border-top: 3px solid #000; margin: 18px 0; }
.showcard.lost { border: 12px solid #e8505b; }
.showcard.taxi { border: 12px solid #f5c400; }

/* ---------- info ---------- */
.sos { display: grid; gap: 10px; }
.sos a {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.sos a.primary { background: #b3261e; color: #fff; }
.sos .num { font-size: 1.8rem; font-weight: 900; min-width: 64px; }
.phrase { padding: 10px 0; border-bottom: 2px dashed var(--surface-2); }
.phrase:last-child { border-bottom: 0; }
.phrase .fr { font-weight: 800; font-size: 1.15rem; }
.phrase .phon { color: var(--accent); font-weight: 700; }

.skyline { display: block; width: 100%; height: auto; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
