:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1d1b16;
  --muted: #625d52;
  --line: #e2ddd2;
  --accent: #b5470b;
  --accent-text: #ffffff;
  --accent-soft: #fbe9dc;
  --bar: #d9732f;
  --error: #b3261e;
  --focus: #1a5fb4;
  --star: #e0a100;
  --star-empty: #d8d3c8;
  --radius: 14px;
  /* Charts: validated categorical slots 1-3 (scripts/validate_palette.js, light on #ffffff). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --area: rgba(42, 120, 214, 0.1);
  --grid: #ece8df;
  --axis: #c3c2b7;
  --good: #006300;
  --bad: #d03b3b;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161512;
    --card: #211f1b;
    --text: #f1ede4;
    --muted: #b0a999;
    --line: #38342d;
    --accent: #f08a4b;
    --accent-text: #1d1206;
    --accent-soft: #3b2618;
    --bar: #f08a4b;
    --error: #ff8a80;
    --focus: #8ab4ff;
    --star: #f5c542;
    --star-empty: #4a453c;
    /* Dark steps of the same slots, validated on #211f1b. */
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --area: rgba(57, 135, 229, 0.12);
    --grid: #2f2c27;
    --axis: #4a463e;
    --good: #0ca30c;
    --bad: #e66767;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

h1, h2, h3, p { margin: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Header / footer ---------- */

.site-header { padding: 8px 0 16px; }
.site-header h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
.today { color: var(--muted); }

.site-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 16px;
}
.card > * + * { margin-top: 8px; }
.card-body { margin-top: 16px; }
.card-body > * + * { margin-top: 12px; }

.eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.lunch-title { font-size: 1.6rem; line-height: 1.2; }
.vendor { font-size: 1.05rem; color: var(--muted); }
.big-emoji { font-size: 2.5rem; }

/* ---------- Buttons ---------- */

.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }

.link {
  min-height: 44px;
  padding: 8px 4px;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link.small { font-size: 0.9rem; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.center { justify-content: center; margin-top: 12px; }

.error { color: var(--error); font-weight: 500; }
.error:empty { display: none; }

/* ---------- Rating ---------- */

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.question { font-size: 1.15rem; font-weight: 600; padding: 0; margin-bottom: 12px; }

.choices {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.choice-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 6px 2px;
  border: 2px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}
.choice-num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.choice-label { font-size: 0.8rem; color: var(--muted); }
.choice input:checked + .choice-box { border-color: var(--accent); background: var(--accent-soft); }
.choice input:checked + .choice-box .choice-label { color: var(--text); font-weight: 600; }
.choice input:focus-visible + .choice-box { outline: 3px solid var(--focus); outline-offset: 2px; }
.rate-form .actions { margin-top: 16px; }
.rate-form .btn.primary { width: 100%; }

/* Honeypot: off-screen, never visible to people. */
.hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Follow-ups ---------- */

.thanks { font-size: 1.1rem; font-weight: 600; }
.followup { margin-top: 16px; }
.followup-q { display: block; font-weight: 500; margin-bottom: 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.counter { display: block; text-align: right; font-size: 0.8rem; }
.followups-form .actions { margin-top: 20px; }

/* ---------- Results ---------- */

.avg { font-size: 1.25rem; color: var(--muted); }
.avg strong { font-size: 3rem; line-height: 1; color: var(--text); }
.histogram { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 5.5em 1fr 2.5em; gap: 8px; align-items: center; }
.bar-label { font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.bar-track { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar); border-radius: 7px; }
.bar-count { text-align: right; font-variant-numeric: tabular-nums; }
.order-again { font-weight: 600; }
.gate { padding: 12px; border-radius: 10px; background: var(--accent-soft); }

/* ---------- Dashboard ---------- */

.dashboard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}


.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0 16px; }
@media (min-width: 520px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 10px 12px; background: var(--bg); border-radius: 10px; display: flex; flex-direction: column; }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 650; line-height: 1.2; }
.stat-sub { font-size: 0.75rem; color: var(--muted); }

.filter-row { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg); border-radius: 10px; }
.seg {
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.seg[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
#panel-trends { transition: opacity 0.15s; }
#panel-trends.is-refreshing { opacity: 0.5; pointer-events: none; }

/* ---------- Charts ---------- */

.chart-card { padding: 16px 0; border-top: 1px solid var(--line); }
.chart-title { font-size: 1rem; }
.chart-sub { font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.viz { position: relative; }
.viz-svg { display: block; max-width: 100%; overflow: visible; touch-action: pan-y; }
.viz-svg:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }
.viz-grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-axis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-label { fill: var(--text); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.viz-bar { fill: var(--series-1); transition: opacity 0.1s; }
.viz-bar.is-dim { opacity: 0.45; }
.viz-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { fill: var(--area); }
.viz-dot { fill: var(--series-1); stroke: var(--card); stroke-width: 2; }
.viz-dot-hot { stroke-width: 3; }
.viz-cross { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-tip {
  position: absolute;
  z-index: 2;
  min-width: 140px;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  font-size: 0.85rem;
  pointer-events: none;
}
.viz-tip-title { color: var(--muted); font-size: 0.8rem; margin-bottom: 2px; }
.viz-tip-row strong { font-size: 0.95rem; }
.viz-tip-row span { color: var(--muted); }
.viz-tip-key { display: inline-block; width: 12px; height: 2px; margin-right: 6px; vertical-align: middle; }

.viz-hbars { display: grid; gap: 8px; }
.viz-hbar { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; align-items: center; }
.viz-hbar-label { font-size: 0.875rem; color: var(--muted); white-space: nowrap; }
.viz-hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.viz-hbar-fill { height: 14px; min-width: 2px; background: var(--series-1); border-radius: 0 4px 4px 0; }
.viz-hbar-value { font-size: 0.85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

.viz-stacks { display: grid; gap: 16px; }
.viz-stack-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 6px; }
.viz-stack { display: flex; gap: 2px; height: 26px; border-radius: 4px; overflow: hidden; }
.viz-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2px;
  flex-basis: 0;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.viz-seg.on-dark { color: #ffffff; }
.viz-seg.on-light { color: #0b0b0b; }
.series-1 { background: var(--series-1); }
.series-2 { background: var(--series-2); }
.series-3 { background: var(--series-3); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { width: 10px; height: 10px; border-radius: 2px; }
.viz-table { margin-top: 8px; font-size: 0.875rem; }
.viz-table summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }

/* ---------- Voting page extras ---------- */

.streak { padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--accent-soft); font-weight: 600; }
.streak-note { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); }

.upcoming h2 { font-size: 1.1rem; }
.upcoming-list { list-style: none; margin: 8px 0 0; padding: 0; }
.upcoming-week {
  margin-top: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.upcoming-week:first-child { margin-top: 0; }
.upcoming-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.upcoming-item:last-child { border-bottom: 0; }
.upcoming-date { flex: none; width: 7.5em; color: var(--muted); font-variant-numeric: tabular-nums; }
.upcoming-menu { font-weight: 600; }
.upcoming-menu.muted { font-weight: 400; }

.dash-link { margin: 0 0 8px; }
.dash-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-btn:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }
.dash-btn-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 1.35rem;
}
.dash-btn-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-btn-title { font-weight: 700; font-size: 1.05rem; }
.dash-btn-sub { font-size: 0.875rem; color: var(--muted); }
.dash-btn-chev { flex: none; font-size: 1.6rem; line-height: 1; color: var(--muted); transition: transform 0.15s; }
.dash-btn[aria-expanded="true"] { border-color: var(--accent); }
.dash-btn[aria-expanded="true"] .dash-btn-chev { transform: rotate(90deg); }
.feedback-link { text-align: center; margin-top: 12px; }
.feedback { text-align: left; margin-top: 12px; }
.feedback h2 { font-size: 1.1rem; }

.privacy { max-width: 60ch; margin: 0 auto; text-align: left; }
.privacy details { margin-top: 6px; }
.privacy summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; }
.privacy ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.privacy li + li { margin-top: 6px; }
.privacy code { font-size: 0.8em; word-break: break-all; }
.next-lunch { text-align: center; font-size: 0.9rem; }
.window { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 0.875rem; }
.pill-status { padding: 2px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-weight: 600; }
.pill-status.open { background: var(--accent-soft); color: var(--text); }
.turnout { color: var(--muted); }
.card.earlier { border-style: dashed; }
.meter { height: 10px; margin: 8px 0; border-radius: 5px; background: var(--card); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.gate .small { margin-top: 4px; }
.small-btn { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 0 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
[role="tab"] {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
[role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
[role="tabpanel"] > * + * { margin-top: 12px; }

.empty { padding: 24px 8px; text-align: center; color: var(--muted); }

.fav-list { list-style: none; margin: 0; padding: 0; }
.fav { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.fav:first-child { border-top: 0; }
.rank {
  flex: none;
  width: 2em;
  height: 2em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  font-weight: 700;
}
.fav-main { min-width: 0; }
.fav-vendor { font-weight: 600; }
.fav-score { display: flex; align-items: center; gap: 8px; }

.stars { position: relative; display: inline-block; font-size: 1.05rem; line-height: 1; letter-spacing: 1px; }
.stars::before { content: "★★★★★"; color: var(--star-empty); }
.stars-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; white-space: nowrap; }
.stars-fill::before { content: "★★★★★"; color: var(--star); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.muted td, table.muted td { color: var(--muted); }
.unranked h3 { font-size: 0.95rem; margin: 20px 0 4px; }

/* ---------- Admin ---------- */

.header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.form-grid { display: grid; gap: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.wrap.wide { max-width: 960px; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.who img { border-radius: 50%; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.hint { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.hint:empty { display: none; }
.hint.warn { color: var(--bad); font-weight: 600; }
.block { display: block; }
.admin-table td { min-width: 0; }
.admin-table .pill-status { display: inline-block; font-size: 0.8rem; margin-bottom: 2px; }
.window-edit label { margin-bottom: 4px; }
select, input[type="datetime-local"],
input[type="date"], input[type="text"], input[type="email"], input[list] {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
td input[type="date"], td input[type="text"], td input[list], td input[type="datetime-local"] { min-width: 9em; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.row-actions .btn { min-height: 36px; padding: 6px 10px; font-size: 0.875rem; }
.tag { display: inline-block; padding: 0 6px; border-radius: 6px; background: var(--bg); font-size: 0.75rem; }
.today-row td { background: var(--accent-soft); }
.ok { color: var(--muted); font-weight: 500; }
.ok:empty { display: none; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }

@media (min-width: 640px) {
  .wrap { padding-top: 32px; }
  .card { padding: 24px; }
}

/* ---------- Admin feedback ---------- */

.feedback-item { padding: 12px 0; border-top: 1px solid var(--line); }
.feedback-item:first-child { border-top: 0; }
.feedback-meta { color: var(--muted); }
.feedback-meta .tag { margin-left: 6px; }
.feedback-text { margin: 4px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
