:root {
  --bg: #0f1216;
  --panel: #171c23;
  --panel-2: #1f2630;
  --line: #2a3340;
  --text: #e8edf2;
  --muted: #8b97a6;
  --accent: #ffb454;
  --accent-2: #ff7a59;
  --good: #4ade80;
  --d0: #3a4351;
  --d1: #d9822b;
  --d2: #ffb454;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(90deg, #1a212b, #141a21);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; display: block; }
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: 0.5px; }
.tag { margin: 0; font-size: 11px; color: var(--muted); }
.stats { margin-left: auto; display: flex; gap: 18px; }
.stat { text-align: center; }
.stat b { display: block; font-size: 18px; color: var(--accent); }
.stat span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.auth-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  font-weight: 600; padding: 9px 14px; border-radius: 8px; cursor: pointer;
}
.auth-btn:hover { border-color: var(--accent); }
.topbar-link { color: var(--muted); font-size: 12px; text-decoration: none; white-space: nowrap; }
.topbar-link:hover { color: var(--accent); }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 8px 14px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 9px 14px; border-radius: 8px 8px 0 0; cursor: pointer; font-size: 14px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel); border: 1px solid var(--line); border-bottom-color: var(--panel); }

main { flex: 1; overflow: hidden; position: relative; }
.view { display: none; height: 100%; overflow: auto; }
.view.active { display: block; }

/* Explore layout */
.explore-grid { display: grid; grid-template-columns: 1fr 380px; height: 100%; }
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; }
.map-legend {
  position: absolute; bottom: 12px; left: 12px; z-index: 5;
  background: rgba(20,26,33,0.9); padding: 8px 12px; border-radius: 8px;
  display: flex; gap: 14px; font-size: 12px; border: 1px solid var(--line);
}
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; margin-right: 3px; }
.dot.d0 { background: var(--d0); }
.dot.d1 { background: var(--d1); }
.dot.d2 { background: var(--d2); }

.map-fallback { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; font-size: 14px; }
.list-panel { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.controls { padding: 12px; border-bottom: 1px solid var(--line); }
#search, #noteInput, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 9px 11px; border-radius: 8px; font-size: 14px;
}
.filters { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 11px; border-radius: 20px; cursor: pointer; font-size: 13px;
}
.chip.active { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
.add-drink-btn { margin-top: 10px; width: 100%; background: var(--panel-2); color: var(--text); border: 1px dashed var(--line); padding: 9px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.add-drink-btn:hover { border-color: var(--accent); color: var(--accent); }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row > * { flex: 1; min-width: 0; }
#addName, #addType, #addRegion, #addStyle, #addAbv {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 9px 11px; border-radius: 8px; font-size: 14px;
}
#addName { margin-top: 4px; }
.drink .name .mine { font-size: 10px; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }

.drink-list { overflow: auto; padding: 8px; flex: 1; }
.country-group { margin-bottom: 6px; }
.country-head {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
  position: sticky; top: 0; background: var(--panel); z-index: 1;
}
.country-head .bar { flex: 1; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.country-head .bar i { display: block; height: 100%; background: var(--accent); }

.drink {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.drink:hover { background: var(--panel-2); border-color: var(--line); }
.drink.done { background: rgba(255,180,84,0.08); }
.drink .check {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line);
  display: grid; place-items: center; flex: none; font-size: 14px; color: #1a1205;
}
.drink.done .check { background: var(--accent); border-color: var(--accent); }
.drink .info { flex: 1; min-width: 0; }
.drink .name { font-size: 14px; font-weight: 600; }
.drink .sub { font-size: 11.5px; color: var(--muted); }
.drink .type-emoji { font-size: 18px; }

/* Passport */
.passport-head { padding: 18px 24px 4px; }
.passport-head h2 { margin: 0 0 4px; }
.passport-head p { margin: 0; color: var(--muted); font-size: 14px; }
.passport-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.share-btn { margin: 0; flex: none; }
@media (max-width: 560px) { .passport-head-row { flex-direction: column; align-items: stretch; } .share-btn { width: 100%; } }
.passport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 24px 16px; }
.passport-grid .card { margin: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.flavor-bars { display: flex; flex-direction: column; gap: 12px; }
.fbar label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.fbar .track { height: 10px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.fbar .track i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

.rec-list, .checkin-list { display: flex; flex-direction: column; gap: 8px; }
.rec {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--panel-2); border-radius: 8px; cursor: pointer;
}
.rec:hover { outline: 1px solid var(--accent); }
.rec .why { font-size: 11px; color: var(--muted); }
.checkin { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.muted { color: var(--muted); font-size: 13px; }

/* Nearby + buttons */
.primary-btn {
  background: var(--accent); color: #1a1205; border: none; font-weight: 700;
  padding: 11px 18px; border-radius: 10px; cursor: pointer; font-size: 15px; margin: 0 24px;
}
.ghost-btn { background: none; border: 1px solid var(--line); color: var(--muted); padding: 11px 18px; border-radius: 10px; cursor: pointer; }
#nearbyStatus { margin: 12px 24px; }
#nearbyList, #feedList { padding: 8px 24px 40px; }

/* Feed */
/* Privacy / doc page */
.doc { max-width: 760px; margin: 0 auto; padding: 28px 24px 60px; overflow: auto; height: calc(100% - 0px); line-height: 1.6; }
.doc h2 { font-size: 18px; margin: 26px 0 8px; }
.doc h3 { margin: 0 0 8px; }
.doc p { color: var(--text); }
.doc ul { color: var(--text); padding-left: 20px; }
.doc li { margin: 6px 0; }
.doc a { color: var(--accent); }

/* Account nudge modal */
.acct-card { text-align: center; }
.acct-card .logo { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 4px; }
.acct-card h3 { margin: 6px 0 8px; }
.acct-card .modal-actions { flex-direction: column; }
.acct-card .modal-actions .primary-btn, .acct-card .modal-actions .ghost-btn { margin: 0; width: 100%; }
#acctEmail { width: 100%; margin: 6px 0 10px; text-align: center; }
.consent { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 12.5px; color: var(--muted); margin: 2px 0 14px; line-height: 1.4; cursor: pointer; }
.consent input { margin-top: 2px; flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.consent a { color: var(--accent); }
#acctStatus { margin-top: 12px; }

/* Add-to-home-screen banner */
.a2hs {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 150; display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 16px; box-shadow: 0 10px 34px rgba(0,0,0,0.45);
  width: min(520px, calc(100vw - 28px));
}
.a2hs-icon { font-size: 24px; flex: none; }
.a2hs-text { flex: 1; font-size: 13.5px; line-height: 1.4; }
.a2hs-text b { color: var(--accent); }
.a2hs-actions { display: flex; gap: 8px; flex: none; }
.a2hs-actions .primary-btn, .a2hs-actions .ghost-btn { margin: 0; padding: 8px 14px; font-size: 14px; }
@media (max-width: 520px) {
  .a2hs { flex-wrap: wrap; }
  .a2hs-text { flex: 1 1 100%; order: -1; }
}

/* Age gate */
.agegate { position: fixed; inset: 0; background: rgba(8,11,15,0.92); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 200; padding: 20px; }
.agegate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; max-width: 420px; text-align: center; }
.agegate-card .logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 4px; }
.agegate-card h2 { margin: 8px 0 6px; }
.agegate-card p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.agegate-actions { display: flex; gap: 10px; justify-content: center; margin: 18px 0 6px; }
.agegate-actions .primary-btn, .agegate-actions .ghost-btn { margin: 0; }
.agegate-denied { color: var(--accent); font-weight: 600; }
.agegate-foot { font-size: 11.5px; margin-top: 12px; }
.agegate-foot a, .agegate-card a { color: var(--accent); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: grid; place-items: center; z-index: 50; }
.modal.hidden, .toast.hidden, .hidden { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(420px, 92vw); position: relative; }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.star-rate { display: flex; gap: 8px; justify-content: center; margin: 14px 0 4px; }
.star { background: none; border: none; font-size: 32px; line-height: 1; cursor: pointer; color: var(--line); padding: 0; transition: color .12s, transform .08s; }
.star:hover { transform: scale(1.1); }
.star.on { color: var(--accent); }
.star-hint { text-align: center; font-size: 11.5px; }
.ci-stars { color: var(--accent); font-size: 12px; letter-spacing: 1px; margin-left: auto; flex: none; }
.sliders { display: flex; flex-direction: column; gap: 14px; margin: 16px 0; }
.sliders label { font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.sliders label span { float: right; color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .primary-btn { margin: 0; flex: 1; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #1a1205; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}

@media (max-width: 820px) {
  .explore-grid { grid-template-columns: 1fr; }
  .map-wrap { height: 45vh; position: relative; }
  .passport-grid { grid-template-columns: 1fr; }
  .stats { display: none; }
}
