:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --surface-2: #f4ede4;
  --text: #2b2118;
  --muted: #7a6b5d;
  --border: #e8ddd0;
  --accent: #c2410c;
  --accent-contrast: #ffffff;
  --accent-soft: #fde8dc;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --gold: #eab308;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120e;
    --surface: #221b15;
    --surface-2: #2d241c;
    --text: #f3ebe2;
    --muted: #b3a393;
    --border: #3a2f25;
    --accent: #fb8a4c;
    --accent-contrast: #1a0f08;
    --accent-soft: #42261a;
    --ok: #4ade80;
    --ok-soft: #173322;
    --warn: #facc15;
    --warn-soft: #3a3012;
    --danger: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

* { 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, sans-serif;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 48px; }
body.has-savebar main.wrap { padding-bottom: 110px; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 8px 0 8px; }
h2 { font-size: 1.15rem; margin: 32px 0 12px; }
a { color: var(--accent); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); font-style: italic; }

/* ---------- top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.brand { font-weight: 800; letter-spacing: -.01em; }
.brand em { font-style: normal; color: var(--accent); }

/* ---------- blocks */
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.card-link:hover, .card-link:focus-visible { border-color: var(--accent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.narrow { max-width: 320px; margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.flash {
  background: var(--ok-soft); color: var(--ok);
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; font-weight: 600;
}
.notice {
  background: var(--warn-soft); color: var(--text);
  border-radius: var(--radius); padding: 10px 14px;
}

.hero, .report-hero { text-align: center; padding: 32px 0 8px; }
.hero-emoji { font-size: 3rem; line-height: 1; }
.greeting { margin-top: 4px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.link-subtle { color: var(--muted); font-size: .875rem; }

.chip {
  display: inline-block; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 600;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.todo, .chip.host { background: var(--accent-soft); color: var(--accent); }

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; }

.report-cta { display: flex; gap: 14px; align-items: center; margin-top: 16px; border-color: var(--gold); }
.big-emoji { font-size: 2rem; }

/* ---------- forms */
input, select, textarea {
  font: inherit; color: inherit;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; font-weight: 600; color: var(--muted); }
label input, label select { color: var(--text); font-weight: 400; font-size: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 700;
  min-height: 44px; padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .875rem; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input { flex: 2 1 200px; }
.inline-form select { flex: 1 1 160px; width: auto; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-actions form { margin: 0; }

details { margin-top: 10px; }
details > summary { cursor: pointer; color: var(--muted); font-size: .875rem; font-weight: 600; padding: 4px 0; }
details[open] > summary { margin-bottom: 10px; }

.linkrow { display: flex; gap: 6px; margin-top: 10px; }
.link-input { flex: 1; min-width: 0; font-size: .8rem; min-height: 36px; padding: 6px 10px; color: var(--muted); }

.tabs { display: flex; gap: 6px; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 2; }
.tabs a {
  flex: 1; text-align: center; text-decoration: none; font-weight: 700; font-size: .9rem;
  padding: 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
section[id] { scroll-margin-top: 60px; }

.progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.day.status-open { border-left: 4px solid var(--accent); }

/* ---------- voting */
.meal { margin-top: 16px; }
.meal h2 { margin: 0; }
.dish { margin: 2px 0 0; color: var(--muted); font-style: italic; }
.scale { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.scale legend { font-weight: 600; font-size: .95rem; margin-bottom: 8px; padding: 0; }
.chips { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.score-chip { display: block; color: inherit; font-size: 1rem; }
.score-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; pointer-events: none; }
.score-chip span {
  display: flex; align-items: center; justify-content: center;
  height: 42px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 700; font-variant-numeric: tabular-nums;
  cursor: pointer; user-select: none;
  transition: background .12s, transform .12s;
}
.score-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); transform: scale(1.06); }
.score-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.readonly .score-chip span { cursor: default; opacity: .55; }
.readonly .score-chip input:checked + span { opacity: 1; }
@media (max-width: 380px) {
  .chips { gap: 2px; }
  .score-chip span { height: 38px; font-size: .85rem; border-radius: 7px; }
}

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.savebar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#progress.done { color: var(--ok); font-weight: 700; }

/* ---------- report */
.ranking { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.rank { display: flex; gap: 14px; align-items: center; }
.rank-pos { font-size: 1.6rem; min-width: 44px; text-align: center; font-weight: 800; color: var(--muted); }
.rank-1 { border: 2px solid var(--gold); }
.rank-1 .rank-pos, .rank-2 .rank-pos, .rank-3 .rank-pos { font-size: 2.2rem; }
.rank-name { font-weight: 800; font-size: 1.1rem; }
.rank-1 .rank-name { font-size: 1.3rem; }
.rank-facts { display: flex; flex-direction: column; font-size: .875rem; margin-top: 2px; }

.awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.award { text-align: center; }
.award-emoji { font-size: 1.8rem; }
.award-winner { font-weight: 800; margin-top: 2px; }
