:root {
  --green: #38b146;
  --green-deep: #1c823c;
  --green-ink: #145f2c;
  --green-soft: #e8f6ea;
  --magenta: #c8228a;
  --magenta-bright: #ea33a6;
  --magenta-soft: #fde8f5;
  --purple: #8d1b8c;
  --ink: #1a2766;
  --text: #222a3d;
  --muted: #5a6479;
  --line: #e7e0d3;
  --paper: #fffaf2;
  --card: #ffffff;
  --warn: #9a5b00;
  --warn-soft: #fff3d6;
  --danger: #b3261e;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(26, 39, 102, .06), 0 4px 16px rgba(26, 39, 102, .06);
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --tabbar-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--body); font-size: 17px; line-height: 1.45; color: var(--text);
  background: var(--paper); min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--green-deep); }
h1, h2, h3 { font-family: var(--display); color: var(--ink); line-height: 1.15; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(255, 250, 242, .92);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 1.05rem; }
.brand strong { font-family: var(--display); color: var(--green-deep); letter-spacing: .02em; }
.net { font-size: .8rem; font-weight: 700; color: var(--warn); background: var(--warn-soft); padding: 4px 10px; border-radius: 99px; }

main { max-width: 720px; margin: 0 auto; padding: 18px 16px 32px; outline: none; }
.splash { text-align: center; padding-top: 18vh; }

/* bottom tab bar */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(26, 39, 102, .05);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 700; min-width: 0;
}
.tabbar svg { width: 25px; height: 25px; fill: currentColor; }
.tabbar a[aria-current="page"] { color: var(--green-deep); }
.tabbar a.live { color: var(--magenta); }
.tabbar a.live svg { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .tabbar a.live svg { animation: none; } }

/* cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.tap { cursor: pointer; transition: transform .08s ease; }
.card.tap:active { transform: scale(.99); }
.card.mine { border-color: var(--green); box-shadow: inset 4px 0 0 var(--green), var(--shadow); }
.card.cancelled { opacity: .65; }
.card.alert { background: var(--magenta-soft); border-color: #f3b6dc; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 10px; }
.section-title h2 { margin: 0; }
.date-head { font-weight: 700; color: var(--ink); margin: 20px 2px 8px; font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; }
.when { font-weight: 700; color: var(--green-ink); }
.title { font-weight: 700; font-size: 1.06rem; color: var(--ink); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty img { width: 90px; opacity: .9; margin-bottom: 8px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #eef0f6; color: var(--ink); white-space: nowrap; }
a.badge.link { text-decoration: none; background: var(--green-soft); color: var(--green-ink); }
.badge.green { background: var(--green-soft); color: var(--green-ink); }
.badge.pink { background: var(--magenta-soft); color: #8a1561; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: #fde7e5; color: var(--danger); }
.slots { display: flex; gap: 4px; align-items: center; }
.slots i { width: 11px; height: 11px; border-radius: 50%; background: #e3e6ee; display: inline-block; }
.slots i.on { background: var(--green); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-size: 1.55rem; color: var(--green-deep); line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); font-weight: 700; }

/* buttons */
.btn {
  appearance: none; border: 0; border-radius: 12px; padding: 12px 18px; min-height: 46px; font: inherit; font-weight: 700;
  background: var(--green-deep); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: filter .1s ease, transform .08s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--green-deep); border: 1.5px solid var(--green-deep); }
.btn.ghost { background: transparent; color: var(--muted); padding: 10px 12px; }
.btn.danger { background: #fff; color: var(--danger); border: 1.5px solid #f0b9b4; }
.btn.pink { background: var(--magenta); }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: .92rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.huge { width: 100%; min-height: 84px; font-size: 1.35rem; border-radius: 20px; box-shadow: 0 8px 24px rgba(28, 130, 60, .28); }
.btn.huge.pink { box-shadow: 0 8px 24px rgba(200, 34, 138, .32); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* segmented control */
.seg { display: flex; background: #efe9dd; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font: inherit; font-weight: 700; font-size: .92rem; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* forms */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 5px; color: var(--ink); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border: 1.5px solid #d9d2c3; border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .seg button:focus-visible { outline: 3px solid rgba(56, 177, 70, .45); outline-offset: 1px; border-color: var(--green-deep); }
textarea { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { flex: 1; min-width: 40px; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span { display: block; text-align: center; padding: 9px 0; border-radius: 10px; border: 1.5px solid #d9d2c3; font-weight: 700; cursor: pointer; background: #fff; }
.days input:checked + span { background: var(--green-deep); color: #fff; border-color: var(--green-deep); }
.days input:focus-visible + span { outline: 3px solid rgba(56, 177, 70, .45); }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid #d9d2c3; border-radius: 12px; margin-bottom: 10px; background: #fff; cursor: pointer; }
.choice > input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--green-deep); flex: none; }
.choice:has(> input:checked) { border-color: var(--green-deep); background: var(--green-soft); }
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.check > input { width: 22px; height: 22px; accent-color: var(--green-deep); }

/* trip screen */
.trip-live { background: linear-gradient(160deg, #10351f, #1a2766 130%); color: #f4f7f2; border-radius: 22px; padding: 22px 18px; margin: 0 -4px 14px; }
.trip-live h1, .trip-live h2 { color: #fff; }
.trip-live .muted { color: #b9c7c0; }
.timer { font-family: var(--display); font-size: 3.2rem; font-variant-numeric: tabular-nums; line-height: 1; margin: 8px 0 4px; }
.live-km { font-size: 1.05rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--magenta-bright); margin-right: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.done-km { font-family: var(--display); font-size: 3.4rem; color: var(--green-deep); line-height: 1; }
.hint { background: var(--green-soft); border-radius: 12px; padding: 12px 14px; font-size: .94rem; color: var(--green-ink); }
.hint.warn { background: var(--warn-soft); color: var(--warn); }

/* table (admin) */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* bottom sheet dialog */
.sheet {
  border: 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 22px 22px 0 0;
  max-height: 92dvh; background: var(--paper); color: var(--text); box-shadow: 0 -10px 40px rgba(0,0,0,.2);
}
.sheet::backdrop { background: rgba(20, 26, 45, .45); }
.sheet-inner { padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: 92dvh; }
.sheet-grip { width: 44px; height: 5px; border-radius: 9px; background: #d6cfc0; margin: 4px auto 14px; }
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 22px; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: calc(100% - 32px);
  font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); }

/* login */
.login { text-align: center; padding-top: 6vh; }
.login img { width: 190px; max-width: 60%; }
.login .btn { margin-top: 18px; }
.ms-logo { width: 20px; height: 20px; }

.install { display: flex; gap: 12px; align-items: center; }
.install img { width: 46px; height: 46px; border-radius: 11px; flex: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* type-ahead suggestions (admin: add a place) */
.suggest { margin-top: 6px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; box-shadow: var(--shadow); }
.suggest button { display: block; width: 100%; text-align: left; font: inherit; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; }
.suggest button:hover, .suggest button:focus-visible { background: var(--green-soft); outline: none; }
.suggest .s-main { display: block; font-weight: 700; color: var(--ink); }
.suggest .s-sub { display: block; font-size: .86rem; color: var(--muted); }
.suggest-empty { padding: 11px 12px; }
.suggest-attr { padding: 6px 12px; font-size: .72rem; color: var(--muted); background: var(--paper); }
.suggest-attr a { color: inherit; }

/* Roster with per-person admin actions */
.roster { list-style: none; padding: 0; margin: 6px 0; }
.roster li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line, rgba(0,0,0,.08)); }
.roster li:last-child { border-bottom: 0; }
.roster .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
