:root {
  --bg: #f8f4ed;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6862;
  --border: #e3e0da;
  --accent: #135633;
  --accent-text: #ffffff;
  --accent-soft: #e4efe7;
  --danger: #b42318;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #1f1f1d;
    --text: #f1efe9;
    --muted: #a39f96;
    --border: #34332f;
    --accent: #5cbf86;
    --accent-text: #0c1f14;
    --accent-soft: #173323;
    --danger: #f97066;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }

h1, h2, p { margin: 0; }

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.bar h1 { font-size: 20px; font-weight: 700; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; padding: 0 8px; }
.btn.small { min-height: 36px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); background: transparent; margin-top: 8px; }
.btn:focus-visible, .star:focus-visible, .seg:focus-visible, .input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

/* List */
.list { padding: 16px; display: grid; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card h2 { font-size: 17px; }
.dist { color: var(--accent); font-weight: 700; font-size: 14px; white-space: nowrap; }
.addr, .meta { color: var(--muted); font-size: 14px; }
.notes { font-size: 15px; white-space: pre-wrap; border-left: 3px solid var(--border); padding-left: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
}
.chip.rate-1, .chip.rate-2 { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.actions { display: flex; gap: 8px; margin-top: 4px; }
.actions .btn { flex: 1; }

.empty {
  text-align: center;
  padding: 48px 16px;
  display: grid;
  gap: 12px;
  justify-items: center;
  color: var(--muted);
}
.empty-title { color: var(--text); font-weight: 700; font-size: 18px; }
.fineprint { color: var(--muted); font-size: 13px; text-align: center; padding: 8px 0 24px; }

/* Form */
.form { padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); display: grid; gap: 16px; }
.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}
.group h2 { font-size: 17px; }
.hint { color: var(--muted); font-size: 14px; }
.hint:empty { display: none; }
.field-label { font-weight: 600; }
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
}
textarea.input { resize: vertical; }

.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.suggestions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.suggestions:empty { display: none; }
.suggestions button {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.s-name { font-weight: 600; }
.s-addr { color: var(--muted); font-size: 14px; }

.picked { display: flex; align-items: center; gap: 8px; }
.picked-text { flex: 1; font-weight: 600; }

.field { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.field[hidden] { display: none; }
.field.sub { border-top: none; padding-top: 0; }
.input.count { width: 96px; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rating-word { color: var(--muted); font-size: 14px; }

.stars { display: flex; gap: 4px; }
.star {
  flex: 1;
  max-width: 56px;
  height: 48px;
  border: none;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
  padding: 0;
  /* Emoji can't be recolored, so unselected ones are greyed and faded. */
  filter: grayscale(1);
  opacity: 0.28;
  transition: opacity 120ms, filter 120ms, transform 120ms;
}
.star.on { filter: none; opacity: 1; }
.star:active { transform: scale(0.9); }
.scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; max-width: 296px; }

.segmented { display: flex; gap: 8px; }
.seg {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.seg.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.error { color: var(--danger); font-weight: 600; }
.error:empty { display: none; }

/* ---------- Status colors ---------- */
:root {
  --open-bg: #e1efe5; --open-text: #0f4a2b; --open-dot: #1d7a45;
  --unknown-bg: #eceae6; --unknown-text: #4a4743; --unknown-dot: #8a867e;
  --varies-bg: #fbebd0; --varies-text: #7a4f08; --varies-dot: #c7841a;
  --closed-bg: #e3e0da; --closed-text: #4a4743;
  --mine-bg: #e6eef9; --mine-text: #1f4e8c;
  --dim-bg: #f1efeb;
  --banner-bg: #fbebd0; --banner-text: #5c3b05;
  --dark: #1c1b19; --dark-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --open-bg: #163626; --open-text: #9fdcb6; --open-dot: #4fb37a;
    --unknown-bg: #2c2b28; --unknown-text: #c9c5bc; --unknown-dot: #8a867e;
    --varies-bg: #3a2c12; --varies-text: #f3c77a; --varies-dot: #e0a33c;
    --closed-bg: #2c2b28; --closed-text: #a39f96;
    --mine-bg: #1b2a40; --mine-text: #a9c6f0;
    --dim-bg: #1a1a18;
    --banner-bg: #3a2c12; --banner-text: #f3d9a4;
    --dark: #f1efe9; --dark-text: #151514;
  }
}

/* ---------- Shell ---------- */
#app.has-tabbar { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; z-index: 3;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding: 4px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 700; color: var(--muted); text-decoration: none;
}
.tab.on { color: var(--accent); }

.bar.slim { justify-content: flex-start; }
.btn.back { gap: 2px; padding-left: 4px; }
.btn.big { min-height: 52px; font-size: 17px; gap: 8px; }
.btn.dark { background: var(--dark); border-color: var(--dark); color: var(--dark-text); }
.btn.outline { border-color: var(--accent); color: var(--accent); gap: 8px; }
.link {
  background: none; border: none; padding: 0; font: inherit; font-weight: 700; color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer; min-height: 32px;
}
.link-out { color: var(--accent); font-weight: 700; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-label {
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 8px;
}

/* ---------- Nearby header ---------- */
.top {
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  display: grid; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.top h1 { font-size: 26px; font-weight: 800; }
.loc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; font-weight: 600; color: var(--muted); }
.loc .link { margin-left: auto; font-size: 14px; }
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px;
  background: var(--banner-bg); color: var(--banner-text); font-size: 14px;
}
.banner svg { flex-shrink: 0; margin-top: 1px; }
.banner .link { color: inherit; font-size: 14px; }
.zip-field { display: grid; gap: 6px; }
.zip-field .input { max-width: 160px; }

.radius { display: flex; background: var(--unknown-bg); border-radius: 12px; padding: 3px; gap: 3px; }
.radius button {
  flex: 1; min-height: 40px; border: none; border-radius: 9px; background: transparent;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--unknown-text); cursor: pointer;
}
.radius button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }

.filter-row {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }
.chip-btn {
  flex-shrink: 0; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip-btn.on { background: var(--dark); border-color: var(--dark); color: var(--dark-text); }
.divider { flex-shrink: 0; width: 1px; background: var(--border); margin: 6px 2px; }

/* ---------- Cards and badges ---------- */
a.card { color: inherit; text-decoration: none; }
a.card:active { transform: scale(.99); }
.card.dim { background: var(--dim-bg); }
.card.dim h2, .card.dim .dist { color: var(--muted); }
.card-link { color: inherit; text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.badge.open { background: var(--open-bg); color: var(--open-text); } .badge.open .dot { background: var(--open-dot); }
.badge.unknown { background: var(--unknown-bg); color: var(--unknown-text); } .badge.unknown .dot { background: var(--unknown-dot); }
.badge.varies { background: var(--varies-bg); color: var(--varies-text); } .badge.varies .dot { background: var(--varies-dot); }
.badge.closed { background: var(--closed-bg); color: var(--closed-text); }
.badge.mine { background: var(--mine-bg); color: var(--mine-text); }
.type { font-size: 13px; color: var(--muted); }
.type:empty { display: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--dim-bg); color: var(--muted); }

.empty-box {
  display: grid; gap: 10px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px dashed var(--border);
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Welcome ---------- */
.welcome {
  min-height: 100dvh; padding: calc(56px + env(safe-area-inset-top)) 24px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
}
.welcome-top { display: grid; gap: 18px; }
.welcome h1 { font-size: 32px; line-height: 1.15; font-weight: 800; }
.lead { font-size: 17px; color: var(--muted); }
.points {
  margin: 0; padding: 16px 16px 16px 36px; display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted);
}
.points li::marker { color: var(--accent); font-weight: 800; }
.welcome-actions { display: grid; gap: 12px; }

/* ---------- Detail ---------- */
.detail { padding: 8px 16px calc(32px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.detail-head { display: grid; gap: 8px; }
.detail-head h1 { font-size: 26px; font-weight: 800; line-height: 1.2; }
.label { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; text-align: right; }
.kv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.notes-card { background: var(--open-bg); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.notes-card .btn.outline { background: var(--surface); }

/* ---------- Hours form ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 600; }
.switch {
  appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--border);
  position: relative; cursor: pointer; flex-shrink: 0; transition: background 150ms;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform 150ms;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.time { display: grid; gap: 6px; font-size: 14px; font-weight: 700; }
.days { display: grid; gap: 8px; }
.days { gap: 12px; }
.day-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; align-items: center; }
.day-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.day-row .input { min-height: 44px; }
.day-row .input:disabled { opacity: .4; }
.day { font-weight: 700; font-size: 14px; }
.closed-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); min-height: 36px; }
#hours-group .seg { padding: 0 6px; white-space: nowrap; font-size: 15px; }

/* ---------- Bottom sheets ---------- */
body.sheet-open { overflow: hidden; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .45); }
.sheet {
  position: fixed; z-index: 11; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; outline: none;
}
.grabber { justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--border); }
.sheet h2 { font-size: 22px; font-weight: 800; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 8px; }
.steps li {
  counter-increment: step; display: flex; gap: 12px; align-items: center;
  padding: 12px; border-radius: 12px; background: var(--bg);
}
.steps li::before {
  content: counter(step); flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.steps svg { vertical-align: -3px; color: var(--accent); }
.sheet-actions { display: flex; gap: 10px; }
.opt {
  display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; min-height: 64px;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font: inherit; cursor: pointer;
}
.opt:disabled { opacity: .5; cursor: default; }
.opt:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.opt-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--open-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.opt b { display: block; }
.opt .sub { display: block; font-size: 14px; color: var(--muted); }
.success { color: var(--open-text); font-weight: 600; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 44px; padding: 0; }
.fineprint .link { font-size: 13px; min-height: 0; }

/* ---------- Brand ---------- */
.welcome-logo { width: 168px; height: 168px; border-radius: 50%; object-fit: cover; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* ---------- Map view ---------- */
.brand-row h1 { flex: 1; }
.view-toggle { display: flex; background: var(--unknown-bg); border-radius: 10px; padding: 3px; gap: 3px; }
.view-toggle button {
  min-height: 36px; padding: 0 14px; border: none; border-radius: 8px; background: transparent;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--unknown-text); cursor: pointer;
}
.view-toggle button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.map {
  height: max(340px, calc(100dvh - 330px)); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: var(--unknown-bg); z-index: 0;
}
.map-error { padding: 24px; text-align: center; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.legend i.mine { border-width: 3px; }
.pin-popup { font-family: inherit; display: grid; gap: 4px; min-width: 180px; }
.pin-popup p { margin: 0; }
.pin-name { font-weight: 800; font-size: 15px; }
.pin-meta { color: #57534e; font-size: 13px; }
.pin-actions { display: flex; gap: 16px; margin-top: 4px !important; }
.pin-actions a { color: #135633; font-weight: 700; font-size: 14px; }

/* ---------- Sign-in and account ---------- */
.signin-banner {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--open-bg); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
}
.signin-title { font-weight: 800; }
.signin-banner .btn { flex-shrink: 0; white-space: nowrap; }
.signin-form { display: grid; gap: 10px; }
.code-input { font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.toast {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 12px; background: var(--dark); color: var(--dark-text);
  font-weight: 600; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.link:disabled { opacity: .5; }
