/* Driving Tracker — mobile-first, large touch targets, usable one-handed. */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #38bdf8;
  --go: #16a34a;
  --go-press: #15803d;
  --stop: #dc2626;
  --stop-press: #b91c1c;
  --night: #818cf8;
  --day: #fbbf24;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 16px;
  --tap: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc; --surface: #ffffff; --surface-2: #f1f5f9;
    --text: #0f172a; --muted: #64748b; --line: #e2e8f0; --accent: #0284c7;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 32px);
}
.boot { text-align: center; color: var(--muted); padding: 80px 0; }

h1, h2, h3 { margin: 0 0 4px; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------------------------------------------------------------- header */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; min-height: 44px; }
.topbar h1 { flex: 1; font-size: 22px; }
.back {
  appearance: none; border: 0; background: var(--surface); color: var(--text);
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px; cursor: pointer;
  display: grid; place-items: center; flex: none;
}
.back:active { background: var(--surface-2); }
.icon-btn {
  appearance: none; border: 0; background: var(--surface); color: var(--text);
  min-width: 44px; height: 44px; border-radius: 12px; font-size: 18px; cursor: pointer;
  display: grid; place-items: center; flex: none; padding: 0 12px;
}

/* ----------------------------------------------------------- kid picker */
.picker { display: grid; gap: 14px; }
.kid {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; color: var(--text); font: inherit; position: relative; overflow: hidden;
}
.kid:active { transform: scale(.99); }
.kid .kid-name { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kid .kid-stats { color: var(--muted); font-size: 14px; margin-top: 2px; }
.kid .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.kid.running { border-color: var(--go); }
.kid .live {
  display: inline-flex; align-items: center; gap: 6px; color: var(--go);
  font-weight: 700; font-size: 14px; margin-top: 6px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--go); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* -------------------------------------------------------- big go button */
.drive-btn {
  appearance: none; border: 0; cursor: pointer; width: 100%;
  min-height: 200px; border-radius: 28px; color: #fff;
  font-size: 34px; font-weight: 800; letter-spacing: -.02em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
  transition: transform .08s ease, background .15s ease;
}
.drive-btn small { font-size: 15px; font-weight: 500; opacity: .9; letter-spacing: 0; }
.drive-btn.go { background: var(--go); }
.drive-btn.go:active { background: var(--go-press); transform: scale(.98); }
.drive-btn.stop { background: var(--stop); }
.drive-btn.stop:active { background: var(--stop-press); transform: scale(.98); }
.drive-btn:disabled { opacity: .6; cursor: default; }
.timer { font-variant-numeric: tabular-nums; font-size: 56px; font-weight: 800; letter-spacing: -.03em; }

/* -------------------------------------------------------------- progress */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.bar-row { margin-bottom: 14px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 6px; }
.bar-label b { font-size: 17px; font-variant-numeric: tabular-nums; }
.bar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
.bar.total > span { background: var(--accent); }
.bar.night > span { background: var(--night); }
.bar.done > span { background: var(--ok); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 650;
}
.badge.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.badge.pending { background: rgba(148,163,184,.15); color: var(--muted); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warn); }

/* ----------------------------------------------------------------- lists */
.session {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 14px 4px; color: var(--text); font: inherit; cursor: pointer;
}
.session:last-child { border-bottom: 0; }
.session:active { background: var(--surface-2); }
.session .when { flex: 1; min-width: 0; }
.session .when b { font-size: 15px; }
.session .meta { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.session .dur { text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.session .dur b { font-size: 16px; }
.chip {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 6px; margin-left: 4px; vertical-align: 1px;
}
.chip.night { background: rgba(129,140,248,.2); color: var(--night); }
.chip.day { background: rgba(251,191,36,.18); color: var(--day); }
.chip.manual { background: rgba(148,163,184,.2); color: var(--muted); }

/* ---------------------------------------------------------------- forms */
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; min-height: 48px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  appearance: none; cursor: pointer; font: inherit; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  border: 2px solid transparent; border-radius: 999px; padding: 11px 16px; min-height: 46px;
}
.tag[aria-pressed="true"] { border-color: var(--accent); background: rgba(56,189,248,.15); color: var(--accent); font-weight: 650; }

.btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 650; font-size: 16px;
  border: 0; border-radius: 14px; padding: 0 18px; min-height: var(--tap);
  background: var(--accent); color: #04222f; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { filter: brightness(.92); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--stop); color: #fff; }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: grid; gap: 10px; }

/* --------------------------------------------------------------- import */
.preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 12px; }
.preview-row { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.preview-row:last-child { border-bottom: 0; }
.preview-row.bad { background: rgba(220,38,38,.1); }
.preview-row .warn { color: var(--warn); font-size: 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 20px); z-index: 50;
  background: #020617; color: #f8fafc; border: 1px solid var(--line);
  padding: 13px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 90vw; text-align: center;
}
.toast.error { background: var(--stop); border-color: var(--stop); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.spacer { height: 14px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
