/* ============================================================
   Restaurantes Portugal — design system
   Warm "Alentejo" palette · Fraunces + Inter · light & dark
   ============================================================ */

:root {
  /* Brand / category colors */
  --c-tradicional: #b06a36;
  --c-petiscos: #c14b34;
  --c-pastelaria: #c25b86;
  --c-fine-dining: #5d7b4a;

  /* Semantic tokens (light) */
  --bg: #f6f1e8;
  --surface: #fffdf9;
  --surface-2: #f1e9da;
  --surface-3: #e9dfcc;
  --text: #2b2620;
  --text-muted: #756c5d;
  --text-faint: #a99d8a;
  --border: #e7dcca;
  --border-strong: #d8cab2;

  --primary: #b5531f;
  --primary-hover: #98441a;
  --primary-ink: #fffaf4;
  --accent: #5d7b4a;

  --star: #e0a52e;
  --danger: #c14b34;
  --success: #5d7b4a;

  --shadow-sm: 0 1px 2px rgba(60, 45, 25, 0.06), 0 1px 3px rgba(60, 45, 25, 0.08);
  --shadow-md: 0 4px 10px rgba(60, 45, 25, 0.08), 0 2px 4px rgba(60, 45, 25, 0.06);
  --shadow-lg: 0 12px 32px rgba(50, 38, 20, 0.16);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  --topbar-h: 60px;
  --tabbar-h: 56px;
  --topbar-total: calc(var(--topbar-h) + env(safe-area-inset-top));
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181511;
    --surface: #221e18;
    --surface-2: #2b261f;
    --surface-3: #353026;
    --text: #f0e9dd;
    --text-muted: #b3a892;
    --text-faint: #837a69;
    --border: #363027;
    --border-strong: #4a4334;

    --primary: #e0824a;
    --primary-hover: #ec9159;
    --primary-ink: #1b1611;
    --accent: #8aa46a;

    --c-tradicional: #cf8a52;
    --c-petiscos: #e0664a;
    --c-pastelaria: #dd7da3;
    --c-fine-dining: #8aa46a;
    --star: #f0bc4f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
button, .btn, .chip, .seg-btn, .tab, .card, .memory-card, .feed-item, .lb-row, a, label { touch-action: manipulation; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
/* App shell: pin to the dynamic viewport and never scroll the document
   (each region scrolls internally). Fixes the dead band below the tab bar in
   the installed iOS PWA, where `100%` and `100dvh` disagree. */
body { height: 100dvh; overflow: hidden; }

/* App-like pressed feedback. */
.btn:active, .card:active, .memory-card:active, .feed-item:active, .lb-rest:active, .seg-btn:active, .tab:active, .chip:active {
  transform: scale(0.97);
}
/* Don't let the chrome be text-selected (keeps inputs/review text selectable). */
.topbar, .tabbar, .detail-tabs, .seg, .visit-row, .card-meta, .lb-row, .feed-line { -webkit-user-select: none; user-select: none; }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; }

button { font-family: inherit; }

.icon {
  width: 1.2em;
  height: 1.2em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--text-muted); }

/* ---------- Topbar ---------- */
.topbar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-total);
  padding: env(safe-area-inset-top) var(--sp-4) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: var(--sp-2); flex: 1; min-width: 0; }
.brand-icon { width: 22px; height: 22px; color: var(--primary); }
.topbar h1 {
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-progress {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
}

.topbar-install { flex-shrink: 0; }
@media (max-width: 480px) {
  /* Collapse to an icon-only button on tight screens (text node hidden). */
  .topbar-install { padding: 0 var(--sp-2); font-size: 0; gap: 0; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .icon { width: 22px; height: 22px; }
.topbar-menu { display: none; margin-left: -8px; }

/* ---------- Layout ---------- */
.layout { display: flex; height: calc(100dvh - var(--topbar-total) - var(--tabbar-h)); }

.sidebar {
  width: 384px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-inner { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.sidebar-close { display: none; }

/* ---------- Search ---------- */
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 14px;
  width: 18px; height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}
#search-input {
  width: 100%;
  height: 46px;
  padding: 0 var(--sp-4) 0 42px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}
#search-input::placeholder { color: var(--text-faint); }
#search-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
  background: var(--surface);
}

/* ---------- Progress ---------- */
.progress-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.progress-head {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.progress-track {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.4s var(--ease);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 38px; font-size: 0.85rem; padding: 0 var(--sp-3); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }

.quick-actions { display: grid; grid-template-columns: 1fr; gap: var(--sp-2); }
.quick-actions .btn { width: 100%; }
.hidden { display: none !important; }

.linklike {
  background: none; border: none; padding: 0;
  color: var(--primary); text-decoration: underline;
  cursor: pointer; font: inherit;
}

/* ---------- Category chips ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  user-select: none;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip[aria-pressed="true"] {
  color: var(--text);
  border-color: currentColor;
  background: var(--surface-2);
}
.chip[aria-pressed="false"] { opacity: 0.55; }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- Panels (details) ---------- */
.panel { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.panel-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  min-height: 48px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
}
.panel-summary::-webkit-details-marker { display: none; }
.panel-summary .icon { width: 18px; height: 18px; color: var(--text-muted); }
.panel-summary .chev { margin-left: auto; transition: transform 0.2s var(--ease); }
.panel[open] > .panel-summary .chev { transform: rotate(180deg); }
.panel-body { padding: 0 var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }

.field-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin-top: var(--sp-2); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.field input, .field select {
  height: 44px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
}
.field input:focus-visible, .field select:focus-visible {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

.check-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.switch-row, .check-list label {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 0.88rem; cursor: pointer; min-height: 32px;
}
input[type="checkbox"], input[type="range"] { accent-color: var(--primary); }
input[type="checkbox"] { width: 18px; height: 18px; }

.hint { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; margin: 0; }

/* Price filter chips (checkbox inside a chip-like label) */
.price-chip {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; user-select: none;
  transition: all 0.15s var(--ease);
}
.price-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.price-chip:has(input:checked) { color: var(--text); border-color: currentColor; background: var(--surface-2); }
.price-chip:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }

/* ---------- Trip planner ---------- */
.planner-actions { display: flex; gap: var(--sp-2); }
.planner-actions .btn { flex: 1; }
.planner-status { font-size: 0.82rem; color: var(--text-muted); margin: 0; min-height: 1em; }
.planner-results { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.planner-results li {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.planner-results li:hover { background: var(--surface-2); }
.planner-results li.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.planner-results .dist { color: var(--text-muted); font-size: 0.78rem; }
.planner-results .route-summary { display: block; margin-top: 3px; color: var(--primary); font-size: 0.78rem; font-weight: 650; }

/* ---------- Restaurant list ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
#list-count { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 600; }
.list-add-btn { min-height: 32px; padding: 0 var(--sp-2); font-size: 0.8rem; }
.restaurant-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.region-heading {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-top: var(--sp-2);
  padding-bottom: var(--sp-1);
}

.card {
  position: relative;
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card.highlighted { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.card.visited { opacity: 0.62; }

.card-accent { width: 4px; border-radius: var(--r-pill); flex-shrink: 0; align-self: stretch; }
.card-main { flex: 1; min-width: 0; }
.card-title-row { display: flex; align-items: baseline; gap: var(--sp-2); }
.card-title { font-weight: 600; font-size: 0.96rem; letter-spacing: -0.01em; }
.card-town { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.card-notes { font-size: 0.84rem; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.card-meta { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); min-height: 18px; }
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--text); }
.rating .icon { width: 14px; height: 14px; color: var(--star); fill: var(--star); stroke: var(--star); }
.rating .count { color: var(--text-faint); font-weight: 400; }
.open-now { font-size: 0.76rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.open-now::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.open-now.open { color: var(--success); }
.open-now.closed { color: var(--danger); }
.badge {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  background: var(--surface-3);
}
.badge.community { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

.card-visit {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-faint);
  transition: all 0.15s var(--ease);
}
.card-visit .icon { width: 16px; height: 16px; }
.card-visit:hover { border-color: var(--success); color: var(--success); }
.card-visit.on { background: var(--success); border-color: var(--success); color: #fff; }
.card-visit:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 30%, transparent); }

.empty { padding: var(--sp-5) var(--sp-3); text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* ---------- Map ---------- */
.map-area { position: relative; flex: 1; }
#map { width: 100%; height: 100%; background: var(--surface-2); }

.map-banner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  background: var(--bg);
}
.map-banner.hidden { display: none; }
.map-banner-card {
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  text-align: center;
  box-shadow: var(--shadow-md);
}
.map-banner-icon { width: 40px; height: 40px; color: var(--primary); margin-bottom: var(--sp-3); }
.map-banner h2 { font-size: 1.4rem; margin-bottom: var(--sp-2); }
.map-banner p { color: var(--text-muted); line-height: 1.55; font-size: 0.92rem; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 0.86em; }

/* ---------- Detail drawer ---------- */
.detail-panel { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.detail-panel[aria-hidden="false"] { pointer-events: auto; }
.detail-scrim {
  position: absolute; inset: 0;
  background: rgba(30, 22, 12, 0.45);
  opacity: 0; transition: opacity 0.2s var(--ease);
}
.detail-panel[aria-hidden="false"] .detail-scrim { opacity: 1; }

.detail-card {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s var(--ease);
}
.detail-panel[aria-hidden="false"] .detail-card { transform: translateX(0); }
.detail-close {
  position: absolute; top: var(--sp-3); right: var(--sp-3); z-index: 2;
  background: rgba(255, 255, 255, 0.9);
  color: #2b2620;
  box-shadow: var(--shadow-sm);
}
.detail-close:hover { background: #fff; }

.detail-hero {
  height: 200px;
  background: var(--surface-3);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero .placeholder-icon { width: 56px; height: 56px; opacity: 0.5; }

.detail-body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.detail-head h2 { font-size: 1.55rem; line-height: 1.15; letter-spacing: -0.01em; }
.detail-sub { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: 6px; color: var(--text-muted); font-size: 0.9rem; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.82rem; }
.cat-chip .dot { width: 9px; height: 9px; border-radius: 50%; }

.detail-stats { display: flex; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-3) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.stat .value { font-size: 0.95rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.stat .value .icon { width: 15px; height: 15px; color: var(--star); fill: var(--star); stroke: var(--star); }

.detail-note {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.9rem;
}
.detail-note strong { font-family: var(--font-display); }

.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.detail-actions .btn-block { grid-column: 1 / -1; }
.cat-edit { display: flex; flex-direction: column; gap: var(--sp-2); }
.cat-suggest {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
}

.gallery { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.gallery img { width: 116px; height: 86px; object-fit: cover; border-radius: var(--r-sm); flex-shrink: 0; }

.detail-section-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 600; font-family: var(--font-body); }

/* ---------- Detail: tabs ---------- */
.detail-tabs {
  display: flex; gap: var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin: 0 calc(var(--sp-5) * -1) var(--sp-1);
  padding: 0 var(--sp-5);
  overflow-x: auto; scrollbar-width: none;
}
.detail-tabs::-webkit-scrollbar { display: none; }
.detail-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 0.86rem; font-weight: 600;
  color: var(--text-muted); white-space: nowrap;
  padding: var(--sp-2) 2px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--text); border-bottom-color: var(--primary); }
.detail-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); border-radius: var(--r-sm); }
.detail-pane { display: flex; flex-direction: column; gap: var(--sp-4); }
.detail-pane[hidden] { display: none; }

/* ---------- Detail: visit history ---------- */
.visit-list { display: flex; flex-direction: column; gap: 4px; margin-top: var(--sp-2); }
.visit-entry {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  font-size: 0.85rem; color: var(--text-muted);
}
.visit-entry > span { display: inline-flex; align-items: center; gap: 6px; }
.visit-entry .icon { width: 15px; height: 15px; }
.visit-del { width: 26px; height: 26px; color: var(--text-faint); }
.visit-del:hover { color: var(--primary); }
.visit-del .icon { width: 15px; height: 15px; }

.hours-list { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--text-muted); }
.hours-list .today { color: var(--text); font-weight: 600; }

.reviews { display: flex; flex-direction: column; gap: var(--sp-3); }
.review { display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.review:last-child { border-bottom: none; }
.review-head { display: flex; align-items: center; gap: var(--sp-2); }
.review-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.8rem; color: var(--text-muted); }
.review-who { display: flex; flex-direction: column; line-height: 1.2; }
.review-who .name { font-weight: 600; font-size: 0.85rem; }
.review-who .when { font-size: 0.74rem; color: var(--text-faint); }
.review-stars { display: inline-flex; gap: 1px; margin-left: auto; }
.review-stars .icon { width: 13px; height: 13px; color: var(--star); fill: var(--star); stroke: var(--star); }
.review-stars .icon.empty { color: var(--border-strong); fill: var(--border-strong); stroke: var(--border-strong); }
.review-text { font-size: 0.86rem; line-height: 1.5; color: var(--text-muted); }
.attribution { font-size: 0.72rem; color: var(--text-faint); }

/* skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm); }
.sk-line { height: 12px; margin: 6px 0; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.modal.hidden { display: none; }
.modal-scrim { position: absolute; inset: 0; background: rgba(30, 22, 12, 0.5); }
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  width: 100%;
  max-width: 460px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: var(--sp-3); right: var(--sp-3); }
.modal-title { font-size: 1.5rem; }
.modal-intro { color: var(--text-muted); font-size: 0.9rem; margin: 6px 0 var(--sp-4); }
#add-restaurant-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.coords-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.advanced { margin-top: var(--sp-2); }
.form-status { font-size: 0.86rem; margin: 0; min-height: 1em; }
.form-status.info { color: var(--text-muted); }
.form-status.success { color: var(--success); font-weight: 600; }
.form-status.error { color: var(--danger); font-weight: 600; }

/* Backdrop behind the mobile sidebar drawer (no-op on desktop). */
.sidebar-scrim { display: none; }

/* ---------- Auth (topbar) ---------- */
.topbar-signin { flex-shrink: 0; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.8rem; color: var(--text-muted);
  flex-shrink: 0;
}
.user-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 3px 4px 3px 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); flex-shrink: 0;
}
.user-chip.hidden, .topbar-signin.hidden { display: none; }
.user-chip-name {
  font-size: 0.85rem; font-weight: 600; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip-out { width: 28px; height: 28px; color: var(--text-faint); }
.user-chip-out:hover { color: var(--danger); }
@media (max-width: 520px) { .user-chip-name { display: none; } }

/* ---------- Card badges (priority / visited-by) ---------- */
.badge { display: inline-flex; align-items: center; gap: 3px; }
.badge .icon { width: 11px; height: 11px; }
.badge.priority { color: var(--primary); background: color-mix(in srgb, var(--primary) 15%, transparent); }
.badge.visited-by { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ---------- Detail: "sugerido por" ---------- */
.added-by { font-size: 0.82rem; color: var(--text-muted); margin-top: var(--sp-2); display: inline-flex; align-items: center; gap: 5px; }
.added-by .icon { width: 14px; height: 14px; color: var(--accent); }
.added-by strong { color: var(--text); }

/* ---------- Detail: personal marks ---------- */
.my-marks { display: flex; flex-direction: column; gap: var(--sp-3); }
.my-marks:empty { display: none; }
.signin-invite {
  display: flex; gap: var(--sp-2); align-items: flex-start;
  font-size: 0.85rem; color: var(--text-muted); line-height: 1.45;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3);
}
.signin-invite .icon { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; margin-top: 1px; }

.priority-toggle.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.priority-toggle .icon { color: currentColor; }

.rate-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.rate-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.stars-input { display: inline-flex; gap: 2px; }
.star-btn {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--border-strong); line-height: 0;
}
.star-btn .icon { width: 24px; height: 24px; }
.star-btn.on { color: var(--star); }
.star-btn.on .icon { fill: var(--star); stroke: var(--star); }
.star-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--star) 30%, transparent); border-radius: var(--r-sm); }

.note-input {
  width: 100%; resize: vertical; font: inherit; font-size: 0.9rem;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); color: var(--text);
}
.note-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }

.visit-history { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.history-summary { font-size: 0.8rem; }

/* ---------- Detail: friends (group view) ---------- */
.amigos { display: flex; flex-direction: column; gap: var(--sp-2); }
.amigos:empty { display: none; }
.amigos-avg { display: inline-flex; align-items: center; gap: 6px; font-size: 0.95rem; }
.amigos-avg .icon { width: 16px; height: 16px; color: var(--star); fill: var(--star); stroke: var(--star); }
.amigos-row { display: flex; align-items: center; gap: var(--sp-2); }
.amigos-label { font-size: 0.82rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.amigos-label .icon { width: 13px; height: 13px; color: var(--primary); }
.amigos-avatars { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.amigos-notes { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-1); }
.amigos-note { display: flex; gap: var(--sp-2); align-items: flex-start; }
.amigos-note > div { flex: 1; }
.amigos-note .who { font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.amigos-note .who .icon { width: 12px; height: 12px; color: var(--star); fill: var(--star); stroke: var(--star); }
.amigos-note p { font-size: 0.88rem; color: var(--text); margin: 2px 0 0; line-height: 1.45; }

/* ---------- Detail: comments ---------- */
.comments { display: flex; flex-direction: column; gap: var(--sp-3); }
.comments-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.comment { display: flex; gap: var(--sp-2); align-items: flex-start; }
.comment-body { flex: 1; }
.comment-who { display: flex; align-items: baseline; gap: var(--sp-2); }
.comment-who .name { font-size: 0.85rem; font-weight: 600; }
.comment-who .when { font-size: 0.72rem; color: var(--text-faint); }
.comment-body p { font-size: 0.9rem; color: var(--text); margin: 2px 0 0; line-height: 1.45; }
.comment-form { display: flex; flex-direction: column; gap: var(--sp-2); }
.comment-form .btn { align-self: flex-end; }

/* ---------- Detail: user photos (Cloud Storage) ---------- */
.photos { display: flex; flex-direction: column; gap: var(--sp-2); }
.photos:empty { display: none; }
/* Distinguish the user's own photos from everyone else's. */
.photos[data-my-photos] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
}
.photos-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.photos-head .btn .icon { width: 15px; height: 15px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.photo-tile {
  display: block; aspect-ratio: 1 / 1; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  appearance: none; padding: 0; cursor: pointer; width: 100%;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile:hover img { opacity: 0.92; }
.gallery-img { cursor: pointer; }
.photo-empty { grid-column: 1 / -1; font-size: 0.85rem; margin: 0; }
.photo-status { font-size: 0.8rem; margin: 0; min-height: 1em; }

/* ---------- App-level screens (bottom tab bar views) ---------- */
.screen-data {
  position: fixed;
  top: var(--topbar-total); left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 30;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex; flex-direction: column;
}
.screen-data[hidden] { display: none; }
.screen-head {
  position: sticky; top: 0; z-index: 1;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.screen-head h2 { font-family: var(--font-display); font-size: 1.3rem; }
.screen-sub { color: var(--text-muted); font-size: 0.85rem; }
.screen-list { padding: var(--sp-3) var(--sp-4) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.screen-empty { padding: var(--sp-6) var(--sp-2); text-align: center; }

/* Segmented control (Críticas: mine / all) */
/* Segmented control — each option reads as a distinct chip. */
.seg { display: inline-flex; gap: var(--sp-2); background: none; padding: 0; flex-wrap: wrap; }
.seg-btn {
  appearance: none; cursor: pointer;
  font-family: var(--font-body); font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  padding: 6px var(--sp-3); border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border);
}
.seg-btn:hover { border-color: var(--border-strong); }
.seg-btn.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* Stars (read-only) */
.stars-display { display: inline-flex; gap: 1px; flex-shrink: 0; }
.stars-display .icon { width: 14px; height: 14px; color: var(--star); fill: var(--star); stroke: var(--star); }
.stars-display .icon.empty { color: var(--border-strong); fill: var(--border-strong); stroke: var(--border-strong); }

/* Memory card (diary entry) */
.memory-card {
  appearance: none; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: flex; flex-direction: column; gap: 5px;
  transition: border-color 0.15s var(--ease), transform 0.05s var(--ease);
}
.memory-card:hover { border-color: var(--border-strong); }
.memory-card:active { transform: scale(0.99); }
.memory-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.memory-name { font-weight: 600; font-size: 1rem; }
.memory-loc { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 0.85rem; }
.memory-note { font-size: 0.88rem; line-height: 1.45; color: var(--text); margin: 2px 0 0; }
.memory-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; }
.memory-meta .icon { width: 14px; height: 14px; }

/* Critique row */
.critique { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); cursor: pointer; }
.critique:hover { border-color: var(--border-strong); }
.critique-rest { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9rem; margin-bottom: var(--sp-2); }
.critique-rest .icon { width: 15px; height: 15px; color: var(--primary); }

/* Friends activity feed */
.feed-item {
  appearance: none; text-align: left; cursor: pointer; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3); display: flex; gap: var(--sp-3); align-items: flex-start;
}
.feed-item:hover { border-color: var(--border-strong); }
.feed-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.feed-line { font-size: 0.9rem; line-height: 1.4; display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.feed-line .icon { width: 14px; height: 14px; align-self: center; color: var(--text-muted); }
.feed-note { font-size: 0.86rem; color: var(--text-muted); margin: 0; }
.feed-when { font-size: 0.74rem; color: var(--text-faint); }

/* Friends' uploaded photos get prominence in the activity feed. */
.feed-upload { background: var(--surface-2); border-color: var(--border-strong); }
.feed-photos { display: flex; gap: var(--sp-2); margin-top: 6px; flex-wrap: wrap; }
.feed-photo {
  width: 84px; height: 84px; object-fit: cover; display: block;
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface);
}

/* Sign-in prompt modal */
.signin-modal-actions { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-2); }
.signin-modal-actions .icon { width: 18px; height: 18px; }

/* ---------- Visit + priority chip (detail actions) ---------- */
.visit-row { grid-column: 1 / -1; display: flex; gap: var(--sp-2); }
.visit-row [data-visit-toggle] { flex: 1; }
.chip-toggle {
  flex-shrink: 0; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
}
.chip-toggle .icon { width: 16px; height: 16px; }
.chip-toggle.on { background: color-mix(in srgb, var(--primary) 14%, transparent); border-color: var(--primary); color: var(--primary); }

/* ---------- Experience journey ---------- */
.exp-step { display: flex; flex-direction: column; gap: 6px; }
.exp-hint { font-size: 0.78rem; }

/* Leaderboard unit label */
.lb-unit { font-size: 0.72rem; font-weight: 600; color: var(--text-faint); }

/* ---------- Success modal ---------- */
.success-card { text-align: center; }
.success-icon { display: flex; justify-content: center; margin-bottom: var(--sp-2); }
.success-icon .icon { width: 44px; height: 44px; color: var(--success); }
.success-card .btn { margin-top: var(--sp-2); }

/* ---------- Profile modal ---------- */
.profile-card { text-align: center; }
.profile-photo {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--border);
  margin: var(--sp-2) auto var(--sp-3); display: block;
}
.profile-card .photo-status { text-align: center; }
#user-chip-img { cursor: pointer; }

/* Subtle danger button (e.g. remove a restaurant you added). */
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* ---------- Dishes (chips) ---------- */
.dish-edit { display: flex; flex-direction: column; gap: 6px; }
.dish-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dish-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.76rem; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 3px 10px;
}
.dish-chip.removable { padding-right: 4px; }
.dish-chip .dish-x { display: inline-flex; padding: 0; background: none; border: none; cursor: pointer; color: var(--text-faint); }
.dish-chip .dish-x .icon { width: 13px; height: 13px; }
.dish-chip .dish-x:hover { color: var(--danger); }
.dish-input { width: 100%; }
.amigos-dishes { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Screen subtabs ---------- */
.screen-head-col { flex-direction: column; align-items: stretch; gap: var(--sp-2); }
.screen-head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.subtabs { align-self: flex-start; }
/* These set display:flex, so override the [hidden] attribute explicitly. */
.screen-list[hidden], .seg[hidden] { display: none; }

/* ---------- Leaderboards ---------- */
.lb-row {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3);
}
.lb-rest { appearance: none; text-align: left; cursor: pointer; width: 100%; }
.lb-rest:hover { border-color: var(--border-strong); }
.lb-rank {
  font-weight: 700; min-width: 28px; text-align: center; font-size: 1rem;
  color: var(--text-faint); flex-shrink: 0;
}
.lb-rank-1 { color: #d4a017; }
.lb-rank-2 { color: #9aa3ad; }
.lb-rank-3 { color: #b87333; }
.lb-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.lb-name { font-weight: 600; font-size: 0.95rem; }
.lb-stats { font-size: 0.78rem; display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lb-stats .icon { width: 13px; height: 13px; color: var(--star); fill: var(--star); stroke: var(--star); }
.lb-score { font-weight: 700; color: var(--primary); font-size: 1rem; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.lb-score .icon { width: 14px; height: 14px; color: var(--star); fill: var(--star); stroke: var(--star); }
.lb-period { margin-bottom: var(--sp-1); align-self: flex-start; }

/* ---------- Guided tour (spotlight) ---------- */
.tour { position: fixed; inset: 0; z-index: 200; }
.tour.hidden { display: none; }
.tour-dim { position: absolute; inset: 0; }
.tour-highlight {
  position: fixed; border-radius: var(--r-md);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  outline: 2px solid var(--primary); pointer-events: none;
  transition: top 0.2s var(--ease), left 0.2s var(--ease), width 0.2s var(--ease), height 0.2s var(--ease);
}
.tour-balloon {
  position: fixed; z-index: 1; width: min(320px, calc(100vw - 24px));
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: var(--sp-4); padding-top: var(--sp-5);
}
.tour-balloon.tour-centered { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.tour-x { position: absolute; top: var(--sp-2); right: var(--sp-2); }
.tour-title { font-family: var(--font-display); font-size: 1.2rem; }
.tour-text { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; margin: 6px 0 var(--sp-3); }
.tour-dots { display: flex; gap: 6px; margin-bottom: var(--sp-3); }
.tour-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.tour-dot.on { background: var(--primary); }
.tour-nav { display: flex; justify-content: space-between; gap: var(--sp-2); }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; appearance: none; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-muted); font-family: var(--font-body); font-size: 0.66rem; font-weight: 600;
  transition: color 0.15s var(--ease), transform 0.08s var(--ease);
}
.tab .icon { width: 22px; height: 22px; }
.tab.active { color: var(--primary); }
.tab:active { transform: scale(0.92); }

/* Desktop: tab bar becomes a floating pill; data screens get a readable width */
@media (min-width: 861px) {
  .tabbar {
    left: 50%; right: auto; transform: translateX(-50%);
    width: min(560px, 90%);
    height: var(--tabbar-h); padding-bottom: 0;
    margin-bottom: var(--sp-4);
    border: 1px solid var(--border); border-radius: var(--r-pill);
    box-shadow: var(--shadow-lg);
  }
  .screen-list { max-width: 760px; margin: 0 auto; width: 100%; }
  .screen-head { max-width: 760px; margin: 0 auto; width: 100%; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .topbar-menu { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--topbar-total); left: 0; bottom: 0;
    width: 90%; max-width: 384px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close {
    display: inline-flex;
    align-self: flex-end;
    margin: calc(-1 * var(--sp-2)) calc(-1 * var(--sp-2)) calc(-1 * var(--sp-3)) 0;
    color: var(--text-muted);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    top: var(--topbar-total); left: 0; right: 0; bottom: 0;
    z-index: 45;
    background: rgba(30, 22, 12, 0.45);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s var(--ease);
  }
  .sidebar-scrim.show { opacity: 1; pointer-events: auto; }

  .detail-card {
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 88dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transform: translateY(100%);
    padding-bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h));
  }
  .detail-panel[aria-hidden="false"] .detail-card { transform: translateY(0); }
  /* While the user drags the sheet, follow the finger without easing. */
  .detail-card.dragging { transition: none; }

  /* Larger, grabbable drag handle on the bottom sheet. */
  .detail-card { padding-top: 14px; }
  .detail-card::before {
    content: "";
    position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 5px; border-radius: var(--r-pill);
    background: var(--border-strong);
    z-index: 3;
  }
}

@media (max-width: 420px) {
  .topbar h1 { font-size: 1.05rem; }
}

/* ---------- Pull-to-refresh indicator ---------- */
.ptr {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden; color: var(--text-muted);
  pointer-events: none; z-index: 2;
}
.ptr.settle { transition: height 0.2s var(--ease); }
.ptr .ptr-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
}
.ptr.spin .ptr-spinner { animation: ptr-rot 0.7s linear infinite; }
@keyframes ptr-rot { to { transform: rotate(360deg); } }
/* (.screen-data is already position:fixed, which is the containing block for .ptr) */

/* ---------- Photo viewer (lightbox) ---------- */
#photo-viewer .modal-scrim { background: rgba(0, 0, 0, 0.88); }
.viewer-card {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
  max-width: min(96vw, 760px);
  padding-bottom: env(safe-area-inset-bottom);
}
.viewer-img {
  max-width: 96vw; max-height: 74dvh; object-fit: contain;
  border-radius: var(--r-md); background: #000;
}
.viewer-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }
.viewer-actions .icon { width: 17px; height: 17px; }
.viewer-close {
  position: fixed; z-index: 2;
  top: calc(env(safe-area-inset-top) + 8px); right: 12px;
  background: rgba(0, 0, 0, 0.45); color: #fff;
}

/* ---------- iOS "Add to Home Screen" hint ---------- */
.ios-a2hs {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--topbar-total) + var(--sp-2)); bottom: auto;
  z-index: 70; width: min(440px, calc(100vw - 24px));
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: var(--sp-3); font-size: 0.85rem; color: var(--text);
}
.ios-a2hs.hidden { display: none; }
.ios-a2hs .icon { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.ios-a2hs .a2hs-x { margin-left: auto; flex-shrink: 0; }

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