:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --ink: #1f1a14;
  --ink-2: #5d544a;
  --ink-3: #8f857a;
  --line: #e6ddd0;
  --accent: #c2410c;
  --accent-2: #9a3412;
  --accent-soft: #fde8dc;
  --good: #15803d;
  --good-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --google: #4b5563;
  --star: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 26, 20, .06), 0 4px 16px rgba(31, 26, 20, .05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 15px; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: .875rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 12px 24px; background: rgba(250, 247, 242, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; font-family: var(--sans); font-size: .8rem; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--ink); color: #fff; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- controls ---------- */
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 10px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-weight: 400; color: var(--ink-3); font-size: .8rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.error { color: var(--bad); font-size: .875rem; min-height: 1.2em; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 8px 0 22px; flex-wrap: wrap; }
.hero p { max-width: 640px; margin: 0; }
.filters { display: grid; grid-template-columns: 1fr 200px 220px; gap: 10px; margin-bottom: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.rcard { display: flex; flex-direction: column; gap: 10px; color: inherit; transition: transform .12s, box-shadow .12s; }
.rcard:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(31, 26, 20, .1); text-decoration: none; }
.rcard-top { display: flex; justify-content: space-between; gap: 12px; }
.rcard h3 { margin: 0; }
.score-big { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1; text-align: right; }
.score-big small { display: block; font-family: var(--sans); font-size: .7rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.compare { display: flex; gap: 14px; font-size: .85rem; color: var(--ink-2); }
.compare b { color: var(--ink); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.v-google-inflated { background: var(--bad-soft); color: var(--bad); }
.v-google-underrated { background: var(--good-soft); color: var(--good); }
.v-consistent, .v-community-only { background: var(--info-soft); color: var(--info); }
.v-google-only, .v-thin, .v-none { background: var(--warn-soft); color: var(--warn); }

/* stars */
.stars { position: relative; display: inline-block; font-size: 1rem; letter-spacing: 2px; color: #e5dccf; line-height: 1; }
.stars::before { content: "★★★★★"; }
.stars span { position: absolute; inset: 0 auto 0 0; overflow: hidden; color: var(--star); white-space: nowrap; }
.stars span::before { content: "★★★★★"; }
.stars.lg { font-size: 1.3rem; }

/* share bar */
.share { height: 10px; border-radius: 999px; background: #d1d5db; overflow: hidden; display: flex; }
.share .c { background: linear-gradient(90deg, var(--accent), #ea580c); }
.share-legend { display: flex; justify-content: space-between; font-size: .78rem; color: var(--ink-2); margin-top: 4px; }

/* ---------- restaurant page ---------- */
.back { display: inline-block; margin-bottom: 10px; font-size: .9rem; }
.r-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.score-panel { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 0; padding: 0; overflow: hidden; margin-bottom: 14px; }
.score-panel > div { padding: 18px 20px; }
.score-panel > div + div { border-left: 1px solid var(--line); }
.metric-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: 6px; }
.metric { font-family: var(--serif); font-size: 2.3rem; font-weight: 700; line-height: 1; }
.metric.huge { font-size: 3.2rem; color: var(--accent-2); }
.metric-sub { font-size: .85rem; color: var(--ink-2); margin-top: 6px; }
.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; }
.verdict strong { display: block; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }

.review { margin-bottom: 14px; }
.review-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.author { display: flex; gap: 10px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: .9rem; }
.author-name { font-weight: 700; color: var(--ink); }
.weight { font-size: .78rem; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 4px 8px; text-align: right; }
.weight b { font-size: .95rem; color: var(--ink); }
.review h4 { margin: 10px 0 4px; font-size: 1rem; }
.review-body { white-space: pre-wrap; color: var(--ink-2); margin: 0 0 8px; }
.votes { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 8px; }
.vote.on.accurate { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.vote.on.inaccurate { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.vote.on.helpful { background: var(--info-soft); border-color: var(--info); color: var(--info); }

/* tier badge */
.tier { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 999px; font-size: .75rem; font-weight: 700; color: #fff; white-space: nowrap; }
.tier::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .85); }
.tier.provisional { background: var(--surface-2) !important; color: var(--ink-2); }
.tier.provisional::before { background: var(--ink-3); }

/* google analysis */
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > div { height: 100%; border-radius: 999px; }
.flag { display: flex; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: .86rem; margin-bottom: 6px; }
.flag-ok { background: var(--good-soft); color: #14532d; }
.flag-info { background: var(--info-soft); color: #1e3a8a; }
.flag-warn { background: var(--warn-soft); color: #78350f; }
.flag-bad { background: var(--bad-soft); color: #7f1d1d; }
.gsample { border-top: 1px solid var(--line); padding: 10px 0; font-size: .86rem; }
.gsample:first-child { border-top: 0; }
.gsample .row { gap: 8px; }
.gsample p { margin: 4px 0 0; color: var(--ink-2); }
.tag { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 6px; background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.source { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }

/* ---------- leaderboard ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; width: 48px; }
.pos.p1 { color: #b8860b; } .pos.p2 { color: #8f9aa5; } .pos.p3 { color: #b0793f; }
.tr-num { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }

/* ---------- profile ---------- */
.ladder-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 26px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; }
.spark { width: 100%; height: 48px; display: block; margin-top: 8px; }
.events { list-style: none; padding: 0; margin: 8px 0 0; font-size: .8rem; max-height: 160px; overflow: auto; }
.events li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.up { color: var(--good); font-weight: 700; } .down { color: var(--bad); font-weight: 700; }

/* ---------- how ---------- */
.prose { max-width: 820px; }
.prose h2 { margin-top: 1.6em; }
.prose code, .formula { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.formula { display: block; padding: 10px 14px; margin: 8px 0 14px; white-space: pre-wrap; }
.tier-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(31, 26, 20, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { width: 100%; max-width: 420px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: all .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.notice { background: var(--warn-soft); color: #78350f; border-radius: 10px; padding: 10px 14px; font-size: .88rem; margin-bottom: 14px; }
.rating-input { display: flex; align-items: center; gap: 12px; }
.rating-input input[type=range] { padding: 0; accent-color: var(--accent); }
.rating-input output { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; min-width: 2.5em; }
.place-result { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 900px) {
  .two-col, .score-panel { grid-template-columns: 1fr; }
  .score-panel > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .filters { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
