/* Locals or Tourists — mobile-first, light/dark via CSS variables.
   Theme: auto (prefers-color-scheme) unless <html data-theme="light|dark">. */

:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #241d17;
  --muted: #75695d;
  --border: #e8dfd2;
  --soft: #f3ebdf;
  --accent: #e4572e;
  --accent-ink: #ffffff;
  --local: #2e7d32;
  --tourist: #b3651e;
  --danger: #b3261e;
  --good-bg: #e6f3e7;
  --good-ink: #1e6b32;
  --warn-bg: #fbe9e5;
  --warn-ink: #a63a24;
  --amber-bg: #fdeacc;
  --amber-ink: #6b4500;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.10);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161210;
    --card: #211b16;
    --ink: #f1e9df;
    --muted: #a3968a;
    --border: #39302a;
    --soft: #2b241e;
    --accent: #ff7849;
    --accent-ink: #24120b;
    --local: #7ed49a;
    --tourist: #eba55f;
    --danger: #ff8c7d;
    --good-bg: #1e3326;
    --good-ink: #97dfab;
    --warn-bg: #3b201b;
    --warn-ink: #ffa494;
    --amber-bg: #3a2d17;
    --amber-ink: #eec78a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}
:root[data-theme="dark"] {
  --bg: #161210;
  --card: #211b16;
  --ink: #f1e9df;
  --muted: #a3968a;
  --border: #39302a;
  --soft: #2b241e;
  --accent: #ff7849;
  --accent-ink: #24120b;
  --local: #7ed49a;
  --tourist: #eba55f;
  --danger: #ff8c7d;
  --good-bg: #1e3326;
  --good-ink: #97dfab;
  --warn-bg: #3b201b;
  --warn-ink: #ffa494;
  --amber-bg: #3a2d17;
  --amber-ink: #eec78a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  transition: background-color 0.2s ease, color 0.2s ease;
}

main { max-width: 860px; margin: 0 auto; padding: 0 16px 64px; }
a { color: var(--accent); }
h2 { margin: 36px 0 14px; font-size: 1.2rem; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 12px; max-width: 860px; margin: 0 auto; padding: 14px 16px;
}
.brand { font-weight: 800; font-size: 1.12rem; text-decoration: none; color: var(--ink); white-space: nowrap; margin-inline-end: auto; }
/* mobile: brand + theme toggle on row one, links on row two */
.nav nav { order: 3; flex-basis: 100%; }
@media (min-width: 700px) {
  .nav nav { order: 0; flex-basis: auto; }
}
.brand-locals { color: var(--local); }
.brand-or { color: var(--muted); font-weight: 600; }
.brand-tourists { color: var(--tourist); }
.nav nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.nav nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; padding: 4px 0; }
.nav nav a:hover { color: var(--accent); }
.nav nav a.signin-link { color: var(--accent); }

.theme-toggle {
  background: var(--soft); border: 1px solid var(--border); border-radius: 50%;
  width: 34px; height: 34px; padding: 0; font-size: 1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--ink);
}
.theme-toggle:hover { border-color: var(--accent); filter: none; }
.theme-icon-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-dark { display: none; }
  :root:not([data-theme="light"]) .theme-icon-light { display: inline; }
}
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 34px 0 18px; }
.hero h1 { font-size: clamp(1.65rem, 6vw, 2.5rem); margin: 0 0 10px; letter-spacing: -0.02em; line-height: 1.18; }
.hero .sub { color: var(--muted); max-width: 620px; margin: 0 auto 24px; }

.analyze-form { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto; }
.search-wrap { position: relative; flex: 1; }
.analyze-form input {
  width: 100%; padding: 14px 16px; font-size: 1rem; color: var(--ink);
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--card);
}
.analyze-form input::placeholder { color: var(--muted); }
.analyze-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  padding: 13px 22px; font-size: 1rem; font-weight: 700; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius);
  transition: transform 0.06s ease;
}
button:hover { filter: brightness(1.06); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.6; cursor: wait; }
button.danger { background: var(--danger); color: #fff; }
button.linkish {
  background: none; color: var(--accent); padding: 0; font-size: inherit; font-weight: 600;
  border-radius: 0;
}
.btn-link {
  display: inline-block; background: var(--accent); color: var(--accent-ink); text-decoration: none;
  font-weight: 700; padding: 11px 20px; border-radius: var(--radius);
}
.alt-action { color: var(--muted); margin-top: 16px; }
.status { color: var(--accent); font-weight: 600; min-height: 1.4em; }
.status.error { color: var(--danger); }
.error-text { color: var(--danger); }
.inline-form { display: inline; }
.inline-form button { vertical-align: baseline; }

@media (min-width: 560px) {
  .analyze-form { flex-direction: row; }
}

/* ---------- autocomplete ---------- */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; text-align: start;
}
.ac-group {
  padding: 8px 14px 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 700;
}
.ac-item {
  display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 10px 14px;
  background: none; border: 0; border-radius: 0; color: var(--ink); text-align: start;
  text-decoration: none; cursor: pointer; font-size: 0.95rem; font-weight: 400;
}
.ac-item:hover { background: var(--soft); filter: none; transform: none; }
.ac-item .ac-main { font-weight: 600; }
.ac-item .ac-sub { color: var(--muted); font-size: 0.82rem; }
.ac-hint { color: var(--accent); font-weight: 600; }

/* ---------- tone helpers ---------- */
.tone-good { --tone-bg: var(--good-bg); --tone-ink: var(--good-ink); }
.tone-warn { --tone-bg: var(--warn-bg); --tone-ink: var(--warn-ink); }
.tone-neutral { --tone-bg: var(--soft); --tone-ink: var(--muted); }

/* ---------- verdict banner (place page) ---------- */
.verdict-banner {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 10px;
  background: var(--tone-bg); color: var(--tone-ink);
  border-radius: var(--radius); padding: 14px 18px;
}
.verdict-emoji { font-size: 1.7rem; line-height: 1; }
.verdict-label { font-size: clamp(1.15rem, 4.5vw, 1.45rem); font-weight: 800; letter-spacing: -0.01em; }

/* ---------- score duel (the main event) ---------- */
.duel { margin: 18px 0 8px; }
.duel-headline {
  text-align: center; margin: 0 0 14px; color: var(--tone-ink);
  font-size: clamp(1.05rem, 4vw, 1.3rem); font-weight: 800; letter-spacing: -0.01em;
}
.duel-headline.tone-neutral { color: var(--ink); }
.duel-cards { display: flex; align-items: stretch; gap: 10px; }
.duel-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 18px 10px 14px; min-width: 0;
}
.duel-card.local.win { border-color: var(--local); box-shadow: 0 0 0 2px color-mix(in srgb, var(--local) 35%, transparent); }
.duel-card.tourist.win { border-color: var(--tourist); box-shadow: 0 0 0 2px color-mix(in srgb, var(--tourist) 35%, transparent); }
.duel-title { font-weight: 700; font-size: 0.86rem; }
.duel-value { font-size: clamp(2.4rem, 11vw, 3.2rem); font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
.duel-star { font-size: 0.5em; vertical-align: 0.5em; margin-inline-start: 2px; }
.duel-card.local .duel-value { color: var(--local); }
.duel-card.tourist .duel-value { color: var(--tourist); }
.duel-sub { color: var(--muted); font-size: 0.8rem; line-height: 1.3; }
.duel-vs {
  align-self: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--soft); color: var(--muted); font-weight: 800; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; text-transform: uppercase;
}

/* ---------- crowd split ---------- */
.crowd {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin: 14px 0 10px;
}
.crowd-title { margin: 0 0 10px; font-size: 0.95rem; }
.crowd-bar {
  display: flex; gap: 3px; height: 16px; border-radius: 999px; overflow: hidden;
}
.crowd-locals { background: var(--local); border-radius: 999px 0 0 999px; }
.crowd-tourists { background: var(--tourist); border-radius: 0 999px 999px 0; }
[dir="rtl"] .crowd-locals { border-radius: 0 999px 999px 0; }
[dir="rtl"] .crowd-tourists { border-radius: 999px 0 0 999px; }
.crowd-legend { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 0.9rem; flex-wrap: wrap; }
.crowd-side.local { color: var(--local); font-weight: 600; }
.crowd-side.tourist { color: var(--tourist); font-weight: 600; }
.crowd-summary { margin: 10px 0 0; color: var(--muted); font-size: 0.92rem; }

.check-meta { margin-top: 4px; }
.fine { color: var(--muted); font-size: 0.85rem; }

/* ---------- shared mini components ---------- */
.mini-duel { display: inline-flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.92rem; flex-wrap: wrap; }
.mini-duel .local { color: var(--local); }
.mini-duel .tourist { color: var(--tourist); }

.mini-bar {
  display: block; height: 5px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--tourist) 45%, var(--card)); margin-top: 2px;
}
.mini-bar .locals { display: block; height: 100%; background: var(--local); border-radius: 999px 0 0 999px; }
[dir="rtl"] .mini-bar .locals { border-radius: 0 999px 999px 0; }

.verdict-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--tone-bg); color: var(--tone-ink); font-size: 0.78rem; font-weight: 700;
  white-space: nowrap;
}

.card-emoji {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.35rem;
  background: var(--tone-bg, var(--soft));
}

/* ---------- cards (home recent / favorites) ---------- */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
}
.card {
  display: flex; gap: 12px; align-items: center; padding: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--accent); }
.card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.card-body strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body small { color: var(--muted); }

/* ---------- chips + flags ---------- */
.chip {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 700; vertical-align: middle; margin-inline-start: 6px;
}
.chip.warn { background: var(--amber-bg); color: var(--amber-ink); }
.cuisine-flag {
  background: var(--amber-bg); color: var(--amber-ink); border-radius: var(--radius);
  padding: 9px 14px; font-weight: 600; display: inline-block;
}

/* ---------- place page ---------- */
.breadcrumb { color: var(--muted); font-size: 0.9rem; }
.breadcrumb a { color: var(--muted); }
.place h1 { margin: 6px 0 4px; font-size: clamp(1.5rem, 6vw, 2.1rem); letter-spacing: -0.02em; }
.address, .google-meta { color: var(--muted); margin: 2px 0; }
.maps-link { margin-top: 18px; }
.maps-link a { color: var(--accent); }

.score-panel {
  display: flex; gap: 20px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin: 24px 0 14px;
}
.score-text h2 { margin: 0 0 8px; }
.score-text p { margin: 0 0 6px; }
.error-panel h2 { color: var(--danger); }

/* ---------- city ranking ---------- */
.rank-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--ink);
}
.rank-item:hover { border-color: var(--accent); }
.rank-n {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; margin-top: 2px;
  background: var(--soft); color: var(--muted); font-weight: 800; font-size: 0.9rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.rank-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.rank-head strong { font-size: 1.02rem; }
.rank-body > small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-scores { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- account ---------- */
.account-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar { width: 42px; height: 42px; border-radius: 50%; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px;
}
.check-main { display: flex; flex-direction: column; min-width: 0; }
.check-main a { color: var(--ink); text-decoration: none; }
.check-main a:hover { color: var(--accent); }
.check-result { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- filters ---------- */
.filter-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.filter-row label { font-weight: 600; color: var(--muted); }
select, .filter-row select {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); font-size: 0.95rem; color: var(--ink);
}

/* ---------- nearby ---------- */
.nearby-controls { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toggle-label, .radius-label, .cuisine-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.toggle-label input { width: 18px; height: 18px; accent-color: var(--accent); }
.nearby-list { display: flex; flex-direction: column; gap: 10px; }
.nearby-item {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.nearby-item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nearby-item .info small { color: var(--muted); display: block; }
.nearby-item button { padding: 9px 14px; font-size: 0.9rem; }

/* ---------- city list ---------- */
.city-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 22px; }
.city-list a { color: var(--accent); font-weight: 700; }

/* ---------- prose ---------- */
.prose h1 { margin-top: 30px; }
.prose h2 { margin-top: 28px; }
.prose li { margin-bottom: 8px; }

/* ---------- auth ---------- */
.auth-hero { max-width: 460px; margin: 0 auto; }
.auth-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; text-align: start; display: flex; flex-direction: column; gap: 14px;
}
.auth-card form { display: flex; flex-direction: column; gap: 9px; }
.auth-card label { font-weight: 600; font-size: 0.9rem; }
.auth-card input {
  padding: 12px 14px; font-size: 1rem; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
}
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 2px 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.g_id_signin { display: flex; justify-content: center; }

/* ---------- tables (admin + generic) ---------- */
.rank-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.rank-table th, .rank-table td { text-align: start; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.rank-table th { background: var(--soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.rank-table small { display: block; }
.muted { color: var(--muted); }
.stars { font-variant-numeric: tabular-nums; font-weight: 700; }
.local-stars { color: var(--local); }
.tourist-stars { color: var(--tourist); }

/* legacy share badge (admin views) */
.score-badge {
  --h: calc(120 - var(--score) * 1.2);
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: hsl(var(--h) 65% 42%); color: #fff; font-weight: 800;
}
.score-badge.empty { background: var(--border); color: var(--muted); }

/* ---------- jobs widget ---------- */
#jobs-widget {
  position: fixed; inset-inline: 12px; bottom: 12px; z-index: 50;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
}
@media (min-width: 560px) {
  #jobs-widget { inset-inline-start: auto; inset-inline-end: 18px; bottom: 18px; width: 300px; }
}
#jobs-widget h4 { margin: 0 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
#jobs-widget ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#jobs-widget .job { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
#jobs-widget .job a { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
#jobs-widget .job a:hover { color: var(--accent); }
#jobs-widget .job-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
#jobs-widget .job small { color: var(--muted); }
#jobs-widget .job.failed { cursor: pointer; }
.mini-spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}

/* ---------- admin ---------- */
.admin-main { max-width: 1080px; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.stat {
  display: flex; flex-direction: column; align-items: center; min-width: 110px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; color: var(--muted); font-size: 0.82rem;
}
.stat-n { font-size: 1.5rem; font-weight: 800; color: var(--ink); }
.admin-note { background: var(--amber-bg); color: var(--amber-ink); border-radius: var(--radius); padding: 12px 16px; }
.batch-form { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.batch-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.batch-form input { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--ink); }
.batch-form .toggle-label { flex-direction: row; align-items: center; }
code.mini { font-size: 0.78rem; word-break: break-all; }

/* ---------- misc ---------- */
.spinner {
  width: 42px; height: 42px; flex-shrink: 0;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer { max-width: 860px; margin: 0 auto; padding: 26px 16px 40px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }
.lang-row { display: flex; align-items: center; gap: 8px; }
