:root {
  --bg: #fbf3e4;
  --card: #ffffff;
  --ink: #2b1d14;
  --muted: #7d6a58;
  --line: #eadcc4;
  --lava: #b4471f;
  --lava-dark: #933716;
  --lava-tint: #fae6dc;
  --lagoon: #0f6e66;
  --lagoon-tint: #dff2ee;
  --gold: #c9850f;
  --gold-ink: #7a4d05;
  --gold-tint: #fbeed3;
  --danger: #b3261e;
  --radius: 16px;
  --shadow: 0 4px 14px rgba(60, 35, 15, .08);
  --tabbar-h: 70px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hidden { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.logo-wide { display: block; width: 100%; max-width: 440px; height: auto; margin: 0 auto; }
.passport-head { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.logo-badge { width: 150px; height: auto; }

h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 15px; background: none; border: 0; padding: 4px 0; cursor: pointer; }
.back svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Cards + lists */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bar-row { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.bar-thumb { width: 48px; height: 48px; border-radius: 12px; background: var(--lava-tint); display: flex; align-items: center; justify-content: center; font-size: 24px; flex: none; }
.bar-main { flex: 1; min-width: 0; }
.bar-name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-meta { color: var(--muted); font-size: 13px; }
.visited-tag { color: var(--lagoon); font-size: 12px; font-weight: 600; }
.score { font-size: 22px; font-weight: 700; color: var(--gold-ink); min-width: 42px; text-align: right; }
.score small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

.banner { background: var(--gold-tint); color: var(--gold-ink); border-radius: 12px; padding: 10px 12px; font-size: 13px; }

/* Inputs */
input[type="text"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lagoon); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--lava); }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 99px; padding: 7px 13px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--lagoon); border-color: var(--lagoon); color: #fff; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--lagoon-tint); color: var(--lagoon); font-weight: 600; }
.pill.gold { background: var(--gold-tint); color: var(--gold-ink); }

/* Buttons */
.btn { font: inherit; font-size: 16px; font-weight: 650; border-radius: 14px; padding: 13px 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-align: center; text-decoration: none; display: block; width: 100%; }
.btn-primary { background: var(--lava); border-color: var(--lava); color: #fff; }
.btn-primary:active { background: var(--lava-dark); }
.btn-danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn-small { display: inline-block; width: auto; padding: 7px 12px; font-size: 14px; }
.link { color: var(--lagoon); text-decoration: none; font-weight: 600; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* Bar page */
.hero-img { height: 140px; border-radius: var(--radius); background: var(--lava-tint); display: flex; align-items: center; justify-content: center; font-size: 56px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { text-align: center; }
.stat .big { font-size: 26px; font-weight: 700; color: var(--gold-ink); }
.sub-scores { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; font-size: 14px; }
.meter { height: 8px; background: var(--gold-tint); border-radius: 99px; overflow: hidden; }
.meter > div { height: 100%; background: var(--gold); border-radius: 99px; }
.drink-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.drink-row:last-child { border-bottom: 0; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Stars */
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
/* Read-only partial stars: gold row clipped to the value over a pale row. */
.stars-show { position: relative; display: inline-block; letter-spacing: 0; line-height: 1; vertical-align: -0.05em; }
.stars-show .stars-bg { color: #e3d6bf; }
.stars-show .stars-fg { position: absolute; left: 0; top: 0; overflow: hidden; white-space: nowrap; color: var(--gold); }

/* Quarter-star input: tap or drag across the track; number shows the exact value. */
.star-input { display: inline-flex; align-items: center; gap: 8px; outline: none; border-radius: 8px; }
.star-input:focus-visible { outline: 2px solid var(--lagoon); outline-offset: 3px; }
.star-track { position: relative; display: inline-flex; font-size: 32px; line-height: 1; color: #e3d6bf; cursor: pointer;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; padding: 4px 0; }
.star-track > span:not(.star-fill), .star-fill > span { display: inline-block; width: 1.1em; flex: 0 0 1.1em; text-align: center; }
.star-fill { position: absolute; left: 0; top: 4px; overflow: hidden; white-space: nowrap; color: var(--gold); pointer-events: none; display: inline-flex; }
.star-num { min-width: 2.6em; font-size: 15px; font-weight: 700; color: var(--gold-ink); font-variant-numeric: tabular-nums; }
.star-input.sm .star-track { font-size: 26px; }
.star-input.sm .star-num { font-size: 14px; }
.rate-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.clear-x { font-size: 12px; color: var(--muted); background: none; border: 0; cursor: pointer; }

/* Check-in drink entries */
.entry { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.entry-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.add-drink { display: grid; grid-template-columns: 1fr; gap: 8px; }
.error { color: var(--danger); font-size: 13px; }

/* Passport */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 8px; text-align: center; }
.kpi .n { font-size: 24px; font-weight: 700; }
.kpi .l { font-size: 12px; color: var(--muted); }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--lava); }

/* Map */
.map { height: calc(100dvh - var(--tabbar-h) - 140px - env(safe-area-inset-bottom)); min-height: 320px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.leaflet-popup-content { font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.leaflet-popup-content a { color: var(--lagoon); font-weight: 600; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; justify-content: space-around; background: rgba(251, 243, 228, .96); border-top: 1px solid var(--line); padding: 6px 0 max(6px, calc(env(safe-area-inset-bottom) - 14px)); backdrop-filter: blur(8px); }
/* iPhones with a home indicator report a 34px bottom inset; using all of it on top of our own
   padding left a big empty band under the labels. Keep ~20px, enough to clear the swipe bar. */
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; min-width: 64px; padding: 4px 0; }
/* Nav icons (art-source/nav-icons): the plain icon is drawn in the tab's text color via a
 * mask, so it follows --muted; the active tab shows the full-color version instead. */
.tabbar .nav-ic, .tabbar .nav-ic-on { width: 36px; height: 36px; display: block; }
.tabbar .nav-ic { background-color: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.tabbar .nav-bars { -webkit-mask-image: url(icons/nav/bars.svg); mask-image: url(icons/nav/bars.svg); }
.tabbar .nav-map { -webkit-mask-image: url(icons/nav/map.svg); mask-image: url(icons/nav/map.svg); }
.tabbar .nav-passport { -webkit-mask-image: url(icons/nav/passport.svg); mask-image: url(icons/nav/passport.svg); }
.tabbar .nav-account { -webkit-mask-image: url(icons/nav/account.svg); mask-image: url(icons/nav/account.svg); }
.tabbar .nav-ic-on, .tabbar a.on .nav-ic { display: none; }
.tabbar a.on .nav-ic-on { display: block; }
.tabbar a.on { color: var(--lava); }

/* Sign-in */
input[type="email"], input[type="password"] {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
}
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn:disabled { opacity: .6; cursor: default; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  max-width: min(520px, calc(100% - 32px)); background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Profiles + friends */
.stack { display: flex; flex-direction: column; gap: 12px; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--lava-tint); flex: none; display: block; }
.profile-card, .person-row { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.person-row { padding: 10px 12px; }
.row-actions { display: flex; gap: 6px; flex: none; }
.review-head .person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.avatar-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.avatar-choice { width: 64px; height: 64px; border-radius: 50%; padding: 3px; border: 2px solid transparent; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.avatar-choice.on { border-color: var(--lava); }
.avatar-choice.upload { flex-direction: column; gap: 0; border: 2px dashed var(--line); color: var(--muted); font-size: 22px; line-height: 1; }
.avatar-choice.upload .small { font-size: 11px; }
.friend-drinks { margin-top: 6px; }
.friend-drinks .drink-row { padding: 6px 0; font-size: 14px; }
.passport-head .avatar { margin-bottom: 4px; }

/* Signed out / profile setup: no tab bar until you're in. */
body.gated .tabbar { display: none; }
body.gated .app { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* Full-screen tiki panel: waits ("busy") and results like an expired invite */
.tiki-panel { min-height: calc(100dvh - var(--tabbar-h) - 140px - env(safe-area-inset-bottom)); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 12px 8px 24px; }
body.gated .tiki-panel { min-height: calc(100dvh - 100px); }
.tiki-panel h1 { font-size: 26px; line-height: 1.2; margin: 6px 0 0; }
.tiki-panel p { font-size: 17px; line-height: 1.45; color: var(--muted); margin: 0; max-width: 32ch; }
.tiki-panel-art { width: 148px; height: 148px; border-radius: 50%; padding: 8px; background: var(--card);
  box-shadow: 0 0 0 4px var(--gold-tint), 0 10px 28px rgba(180, 71, 31, .22); }
.tiki-panel-art img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.tiki-panel-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; margin-top: 8px; }

/* Busy: the tiki bobs, its glow pulses, and three torch flames flicker in turn. */
.tiki-panel.busy .tiki-panel-art { animation: tiki-bob 1.6s ease-in-out infinite, tiki-glow 1.6s ease-in-out infinite; }
@keyframes tiki-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-10px) rotate(3deg); } }
@keyframes tiki-glow {
  0%, 100% { box-shadow: 0 0 0 4px var(--gold-tint), 0 10px 28px rgba(180, 71, 31, .20); }
  50% { box-shadow: 0 0 0 8px var(--gold-tint), 0 18px 36px rgba(201, 133, 15, .35); }
}
.torch-dots { display: flex; gap: 10px; margin-top: 4px; }
.torch-dots span { width: 12px; height: 12px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: var(--lava); opacity: .25;
  animation: torch 1.2s ease-in-out infinite; }
.torch-dots span:nth-child(2) { animation-delay: .2s; }
.torch-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes torch { 0%, 100% { opacity: .25; transform: scale(.8); background: var(--lava); } 40% { opacity: 1; transform: scale(1.15); background: var(--gold); } }
@media (prefers-reduced-motion: reduce) {
  .tiki-panel.busy .tiki-panel-art, .torch-dots span { animation: none; }
  .torch-dots span { opacity: .7; }
}
.timing-note { text-align: center; font-size: 11px; margin: -6px 0 0; opacity: .8; }

/* Activity feed (top of Bars + #/activity) */
.activity { display: flex; flex-direction: column; gap: 10px; }
.activity.full { gap: 12px; }
.act-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.act-head h2 { margin: 0; }
.act-head:empty { display: none; }
.act-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.activity:not(.full) .act-list li + li { border-top: 1px solid var(--line); }
.activity.full .act-list { gap: 10px; }
.activity.full .act-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.act-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; text-decoration: none; color: inherit; }
.act-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.act-line { font-size: 15px; line-height: 1.35; }
.act-meta { font-size: 13px; color: var(--muted); }
.act-meta .stars { font-size: 13px; }
.act-drinks { font-size: 13px; color: var(--ink); }
.act-drinks .stars { font-size: 11px; letter-spacing: 0; }
.act-text { font-size: 14px; color: var(--muted); font-style: italic; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.activity.full .act-text { -webkit-line-clamp: 6; }
.act-empty { text-align: center; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.act-empty p { margin: 0; color: var(--muted); font-size: 14px; }
.act-loading .torch-dots { margin: 0; }

/* Check-in photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--lava-tint); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo-tile.uploading { display: flex; align-items: center; justify-content: center; }
.photo-add { border: 2px dashed var(--line); background: var(--card); color: var(--muted); font-size: 24px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: inherit; }
.photo-add > span:first-child { font-size: 26px; line-height: 1; }
.photo-del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: rgba(43, 29, 20, .7); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.photo-strip { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; }
.photo-thumb { position: relative; flex: none; width: 72px; height: 72px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--lava-tint); cursor: zoom-in; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-more { position: absolute; inset: 0; background: rgba(43, 29, 20, .55); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.bar-thumb.photo { object-fit: cover; padding: 0; }
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(15, 10, 6, .94); display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button { position: absolute; border: 0; background: rgba(255, 255, 255, .15); color: #fff; border-radius: 50%; width: 44px; height: 44px; font-size: 28px; line-height: 1; cursor: pointer; }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; }
.visit-date { margin: -6px 0 0; }
