:root {
  --jade: #0E6B57;
  --jade-ink: #0A4A3D;
  --jade-soft: #E3F1EC;
  --paper: #F6F7F4;
  --surface: #FFFFFF;
  --ink: #1F2421;
  --muted: #5F6A65;
  --line: #E1E5E0;
  --chili: #D9381E;
  --amber: #B07806;
  --great: #0E6B57;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --jade: #3FB896;
    --jade-ink: #8EDCC4;
    --jade-soft: #173A31;
    --paper: #111513;
    --surface: #1A1F1D;
    --ink: #ECEFEC;
    --muted: #9AA49F;
    --line: #2B322F;
    --chili: #FF6A4D;
    --amber: #E3A93A;
    --great: #3FB896;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--jade); }
:focus-visible { outline: 3px solid var(--jade); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }
#views { position: absolute; inset: 0 0 calc(var(--tabs-h) + var(--safe-b)) 0; }
.view { position: absolute; inset: 0; display: none; }
.view.on { display: block; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 52px) 0 32px; }

/* ---------- Page chrome ---------- */
.page { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.page h1 { font-size: 28px; line-height: 1.15; margin: 16px 0 4px; letter-spacing: -0.01em; }
.page h2 { font-size: 17px; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.back { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 8px 0; color: var(--jade); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); z-index: 900;
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--jade); }
.tabs .tab-add { order: 0; }
.tabs .plus {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--jade); color: #fff; font-size: 30px; line-height: 1; font-weight: 500;
  margin-top: -18px; box-shadow: 0 4px 14px rgba(14, 107, 87, .35);
}
@media (prefers-color-scheme: dark) { .tabs .plus { color: #0B201A; } }
.tabs a[data-tab="map"] { order: 1; } .tabs a[data-tab="feed"] { order: 2; }
.tabs a[data-tab="add"] { order: 3; } .tabs a[data-tab="me"] { order: 4; }

/* ---------- Map ---------- */
#map { position: absolute; inset: 0; background: var(--line); }
.leaflet-container { font-family: var(--font); }
.fab-small {
  position: absolute; right: 14px; bottom: 18px; z-index: 500;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--jade); display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.pin { position: relative; width: 40px; height: 40px; }
.pin .face {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px; border: 3px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.pin.ok .face { outline: 3px solid var(--amber); }
.pin .count {
  position: absolute; top: -6px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--chili); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface);
}
.pin.lit .face { transform: scale(1.15); transition: transform .2s; }
.me-dot { width: 22px; height: 22px; border-radius: 50%; background: #2F6FD6; border: 4px solid #fff; box-shadow: 0 0 0 6px rgba(47,111,214,.25); }
.me-dot.sim { background: #7A4CC2; box-shadow: 0 0 0 6px rgba(122,76,194,.25); }

.sheet {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 600;
  max-width: 540px; margin: 0 auto; background: var(--surface); border-radius: 18px;
  padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.sheet h3 { margin: 0 0 2px; font-size: 19px; }
.sheet .row { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Shared bits ---------- */
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.stack { display: inline-flex; }
.stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.stack .avatar:first-child { margin-left: 0; }
.rating { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.rating.great { background: var(--jade-soft); color: var(--great); }
.rating.ok { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.rating.avoid { background: color-mix(in srgb, var(--chili) 14%, transparent); color: var(--chili); }
.meta { color: var(--muted); font-size: 13px; }
.quote { margin: 6px 0 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--jade); border-color: var(--jade); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0B201A; } }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--chili); }

/* ---------- Feed ---------- */
.post { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.post:last-child { border-bottom: 0; }
.post .body { flex: 1; min-width: 0; }
.post .who { font-weight: 700; }
.post .who span { font-weight: 500; color: var(--muted); }
.empty { padding: 32px 0; color: var(--muted); }

/* ---------- Add ---------- */
.steps { display: flex; gap: 6px; margin: 4px 0 18px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--jade); }
.field { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
textarea.field { min-height: 96px; resize: vertical; }
.pick-list { list-style: none; margin: 10px 0 0; padding: 0; }
.pick-list li button {
  width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: none;
}
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chip {
  padding: 18px 8px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 700; text-align: center;
}
.chip small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }
.chip[aria-pressed="true"].great { border-color: var(--great); background: var(--jade-soft); }
.chip[aria-pressed="true"].ok { border-color: var(--amber); }
.chip[aria-pressed="true"].avoid { border-color: var(--chili); }
.label { display: block; font-weight: 700; margin: 18px 0 6px; }
.actions { display: flex; gap: 10px; margin-top: 22px; }

/* ---------- Me ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--jade); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--jade); outline-offset: 2px; }
input[type="range"] { width: 100%; accent-color: var(--jade); }
.time { width: auto; padding: 6px 8px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

/* ---------- Nearby ticket (the one bold moment) ---------- */
.ticket {
  position: absolute; z-index: 1000; left: 12px; right: 12px; top: calc(var(--safe-t) + 12px);
  max-width: 520px; margin: 0 auto; background: var(--jade); color: #fff; border-radius: 18px;
  padding: 16px 16px 14px; box-shadow: 0 14px 40px rgba(10, 74, 61, .45); cursor: pointer;
  animation: drop .45s cubic-bezier(.2, 1.3, .4, 1);
}
@media (prefers-color-scheme: dark) { .ticket { color: #0B201A; } }
.ticket::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 46px;
  border-top: 2px dashed rgba(255,255,255,.35);
}
.ticket .t-head { display: flex; align-items: center; gap: 10px; }
.ticket .t-title { font-size: 17px; font-weight: 800; line-height: 1.25; }
.ticket .t-quote { margin: 8px 0 20px; opacity: .92; }
.ticket .t-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; }
.ticket .t-close { background: rgba(255,255,255,.18); border: 0; border-radius: 10px; padding: 6px 12px; color: inherit; font-weight: 700; }
.ticket .stack .avatar { border-color: var(--jade); }
@keyframes drop { from { transform: translateY(-140%) rotate(-2deg); } to { transform: none; } }

/* ---------- Demo panel ---------- */
.demo-btn {
  position: absolute; z-index: 950; left: 12px; top: calc(var(--safe-t) + 12px);
  padding: 8px 14px; border-radius: 999px; border: 0; background: #7A4CC2; color: #fff; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.demo-panel {
  position: absolute; z-index: 960; left: 12px; right: 12px; top: calc(var(--safe-t) + 58px);
  max-width: 420px; background: var(--surface); border-radius: 18px; padding: 14px;
  box-shadow: 0 10px 34px rgba(0,0,0,.28); border: 2px solid #7A4CC2;
  max-height: calc(100% - var(--tabs-h) - var(--safe-b) - var(--safe-t) - 80px); overflow-y: auto;
}
.demo-panel h3 { margin: 0 0 8px; font-size: 16px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.seg button { padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-weight: 700; }
.seg button[aria-pressed="true"] { background: #7A4CC2; border-color: #7A4CC2; color: #fff; }
.demo-panel .btn { min-height: 40px; width: 100%; margin-top: 6px; }

/* ---------- Welcome ---------- */
.welcome { position: absolute; inset: 0; z-index: 2000; background: var(--paper); overflow-y: auto; padding: calc(var(--safe-t) + 24px) 20px 32px; }
.welcome .inner { max-width: 440px; margin: 0 auto; }
.welcome img { width: 72px; height: 72px; border-radius: 18px; }
.welcome h1 { font-size: 30px; line-height: 1.15; margin: 18px 0 8px; }
.welcome p { color: var(--muted); }
.welcome .btn { margin-top: 10px; }

.toast {
  position: absolute; z-index: 3000; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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