:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #232733;
  --line: #2c3140;
  --text: #f4f5f7;
  --muted: #9aa1b1;
  --brand: #f97316;
  --brand-soft: #fb923c;
  --gold: #fbbf24;
  --danger: #ef4444;
  --radius: 16px;
  --topbar-h: 108px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding: calc(var(--safe-top) + 10px) 16px 12px;
  background: linear-gradient(180deg, rgba(15,17,21,0.98), rgba(15,17,21,0.92));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { margin: 0 0 10px; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.search-wrap { position: relative; display: flex; align-items: center; }
#searchInput {
  width: 100%; padding: 12px 38px 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; color: var(--text); font-size: 15px; outline: none;
}
#searchInput:focus { border-color: var(--brand); }
.search-clear {
  position: absolute; right: 8px; background: var(--surface-2); border: none;
  color: var(--muted); width: 26px; height: 26px; border-radius: 50%; font-size: 13px;
}

/* ---------- View area ---------- */
.view {
  padding: calc(var(--topbar-h) + var(--safe-top)) 14px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  min-height: 100vh;
}

/* ---------- Feed grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card {
  position: relative; border-radius: 14px; overflow: hidden; background: var(--surface);
  border: 1px solid var(--line); aspect-ratio: 1 / 1;
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.82));
}
.card-dish { font-size: 13px; font-weight: 700; line-height: 1.2; }
.card-place { font-size: 11px; color: #d7dae2; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.card-rating { position: absolute; top: 8px; right: 8px; font-size: 11px; background: rgba(0,0,0,0.55);
  padding: 3px 7px; border-radius: 20px; color: var(--gold); font-weight: 700; }

/* ---------- Section / places ---------- */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  margin: 18px 4px 10px; font-weight: 700; }
.place-group { margin-bottom: 22px; }
.place-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.place-name { font-size: 17px; font-weight: 800; }
.place-sub { font-size: 12px; color: var(--muted); }
.place-count { font-size: 12px; color: var(--brand-soft); font-weight: 700; }
.hscroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll .card { flex: 0 0 130px; aspect-ratio: 1/1; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty .big { font-size: 52px; margin-bottom: 12px; }
.empty h2 { color: var(--text); font-size: 19px; margin: 0 0 6px; }
.empty p { margin: 0 0 20px; line-height: 1.5; }

/* ---------- Map ---------- */
#mapEl { width: 100%; height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - var(--safe-top) - var(--safe-bottom) - 38px);
  border-radius: 14px; border: 1px solid var(--line); }
.leaflet-container { background: var(--surface); font: inherit; }
.pin {
  background: var(--brand); color: #fff; font-weight: 800; font-size: 13px;
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.pin span { transform: rotate(45deg); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(20,23,30,0.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tab {
  background: none; border: none; color: var(--muted); font-size: 10px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; padding: 6px 0;
}
.tab .ic { font-size: 20px; filter: grayscale(0.4) opacity(0.7); }
.tab.is-active { color: var(--brand-soft); }
.tab.is-active .ic { filter: none; }
.fab {
  flex: 0 0 auto; width: 58px; height: 58px; margin-top: -22px; border-radius: 50%;
  background: linear-gradient(145deg, var(--brand), #ea580c); color: #fff; font-size: 30px;
  border: 4px solid var(--bg); box-shadow: 0 6px 18px rgba(249,115,22,0.45); line-height: 1;
}
.fab:active { transform: scale(0.94); }

/* ---------- Sheet ---------- */
.sheet, .viewer { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; }
.sheet-backdrop, .viewer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.sheet-panel {
  position: relative; width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + var(--safe-bottom));
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: 6px auto 14px; }
.sheet-progress { text-align: center; font-size: 12px; color: var(--brand-soft); font-weight: 700; margin: -8px 0 12px; }
.sheet-photo { width: 100%; aspect-ratio: 4/3; border-radius: 14px; overflow: hidden; background: #000; margin-bottom: 16px; }
.sheet-photo img { width: 100%; height: 100%; object-fit: cover; }

.field { display: block; margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea {
  width: 100%; padding: 12px 13px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 11px; color: var(--text); font-size: 15px; outline: none; resize: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); }

.suggestions { margin: -6px 0 14px; display: flex; flex-direction: column; gap: 1px; max-height: 200px; overflow-y: auto; }
.suggestions:empty { display: none; }
.suggestion {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; text-align: left; color: var(--text); font-size: 14px;
}
.suggestion small { color: var(--muted); font-size: 12px; }
.suggestion.loading { color: var(--muted); text-align: center; }

.stars { display: flex; gap: 6px; font-size: 30px; color: var(--line); }
.stars span { transition: color 0.12s, transform 0.1s; }
.stars span.on { color: var(--gold); }
.stars span:active { transform: scale(1.2); }

.sheet-actions { display: flex; gap: 12px; margin-top: 8px; }
.btn { flex: 1; padding: 14px; border-radius: 12px; border: none; font-size: 15px; font-weight: 700; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.4); }
.btn:disabled { opacity: 0.5; }

/* ---------- Viewer ---------- */
.viewer-panel { position: relative; width: 100%; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(20px + var(--safe-bottom)); max-height: 92vh; overflow-y: auto; animation: slideUp 0.25s ease; }
.viewer-panel img { width: 100%; border-radius: 14px; max-height: 60vh; object-fit: contain; background: #000; }
.viewer-close { position: absolute; top: 16px; right: 16px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff; border: none; font-size: 15px; }
.viewer-meta { padding: 14px 4px 4px; }
.viewer-meta h3 { margin: 0 0 4px; font-size: 20px; }
.viewer-meta .sub { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.viewer-meta .stars-static { color: var(--gold); font-size: 18px; letter-spacing: 2px; }
.viewer-meta .notes { margin-top: 10px; color: #d7dae2; font-size: 14px; line-height: 1.5; }
.viewer-actions { margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); padding: 11px 18px; border-radius: 24px; z-index: 80;
  font-size: 14px; border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,0.4); animation: pop 0.2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
