:root {
  --bg: #f7f2e8;
  --card: #fffdf8;
  --ink: #2a1d12;
  --muted: #7a6a58;
  --line: #e7dccb;
  --accent: #c8841a;
  --accent-ink: #fff;
  --dark: #3b2414;
  --star-empty: #e2d6c3;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110c;
    --card: #221911;
    --ink: #f3e9da;
    --muted: #b2a08a;
    --line: #3a2c1f;
    --accent: #e3a23a;
    --accent-ink: #1b120a;
    --dark: #0f0a06;
    --star-empty: #4a3a2a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
.hidden { display: none !important; }

.site-header { background: var(--dark); color: #f3e9da; padding: 14px 16px; }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; max-width: 860px; margin: 0 auto; }
.brand-mark { font-size: 2rem; }
.brand small { display: block; opacity: .75; font-size: .85rem; }
main { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar h1 { margin: 0; }

/* forms */
.form { padding: 18px; margin-bottom: 20px; display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .95rem; }
.form input:not([type=radio]), .form textarea {
  font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
.row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.form-msg { color: #c0392b; margin: 0; min-height: 1em; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; }

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

/* leaderboard */
.beer-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.beer-row { display: grid; grid-template-columns: 32px 56px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; text-decoration: none; transition: transform .1s; }
.beer-row:hover { transform: translateY(-1px); border-color: var(--accent); }
.rank { font-size: 1.3rem; font-weight: 800; color: var(--accent); text-align: center; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 1.6rem; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.info { display: grid; min-width: 0; }
.info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info small, .score small, .meta { color: var(--muted); }
.mini-bars { display: flex; gap: 3px; height: 16px; align-items: flex-end; margin-top: 4px; }
.mini-bars span { width: 8px; height: 100%; background: var(--line); border-radius: 2px; display: flex; align-items: flex-end; }
.mini-bars i { width: 100%; background: var(--accent); border-radius: 2px; }
.score { display: grid; justify-items: end; text-align: right; }
.score b { font-size: 1.4rem; }

/* detail */
.back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; }
.beer-head { padding: 20px; display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; margin-bottom: 20px; }
.beer-head p { margin: 0 0 .4rem; }
.big-score { display: grid; justify-items: center; align-content: start; }
.big-score b { font-size: 2.6rem; line-height: 1; }
.breakdown { grid-column: 1 / -1; display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; font-size: .95rem; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* star input */
.ratings { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.rating { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0; }
.rating legend { font-weight: 600; padding: 0 4px; }
.rating legend small { font-weight: 400; color: var(--muted); }
.star-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.star-input input { position: absolute; opacity: 0; pointer-events: none; }
.form .star-input label { font-size: 1.9rem; line-height: 1; color: var(--star-empty); cursor: pointer; padding: 0 2px; font-weight: 400; display: inline; }
.star-input label:hover, .star-input label:hover ~ label,
.star-input input:checked ~ label { color: var(--accent); }
.star-input input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }

.photo-pick .preview { max-width: 180px; max-height: 180px; border-radius: 10px; object-fit: cover; }

/* reviews */
.reviews { display: grid; gap: 12px; }
.review { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 14px; }
.review img { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; display: block; }
.review header { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.review .when { color: var(--muted); font-size: .85rem; }
.review .overall { margin-left: auto; font-weight: 600; }
.review p { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chips { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .82rem; }
.review:not(:has(img)) { grid-template-columns: 1fr; }

.loading, .empty { color: var(--muted); text-align: center; padding: 24px; list-style: none; }

@media (max-width: 560px) {
  .beer-row { grid-template-columns: 24px 44px 1fr auto; gap: 8px; padding: 10px; }
  .thumb { width: 44px; height: 44px; }
  .beer-head { grid-template-columns: 1fr; }
  .big-score { justify-items: start; }
  .bar-row { grid-template-columns: 96px 1fr 32px; }
  .row { grid-template-columns: 1fr; }
  .review { grid-template-columns: 1fr; }
  .review img { width: 100%; height: 220px; }
}
