/* Fadbamserne – mobile first. Light and dark follow the phone's setting. */
:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece0;
  --text: #2a1a0e;
  --muted: #7a6656;
  --line: #e6dccd;
  --accent: #c47a12;
  --accent-ink: #ffffff;
  --up: #2f7d32;
  --down: #c0392b;
  --gold: #d4a017;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(42, 26, 14, 0.08);
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17110c;
    --surface: #231a13;
    --surface-2: #2e231a;
    --text: #f3e9dc;
    --muted: #b5a08b;
    --line: #3a2d22;
    --accent: #f0a53a;
    --accent-ink: #1b120a;
    --up: #6cc070;
    --down: #ff7a6b;
    --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.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.with-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

a { color: var(--accent); }

h1 { font-size: 1.6rem; margin: 0.4rem 0 0.8rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.up { color: var(--up); }
.down { color: var(--down); }
[hidden] { display: none !important; }

/* ---------- frame ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.6rem + env(safe-area-inset-top)) 1rem 0.6rem;
  background: var(--text);
  color: var(--bg);
}
.brand { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 0.9rem; }
.top-actions a, .top-actions .linkish { color: inherit; opacity: 0.85; font-size: 0.9rem; white-space: nowrap; }
.top-actions a.active { opacity: 1; font-weight: 700; }
.top-actions form { margin: 0; }

.page { max-width: 720px; margin: 0 auto; padding: 0.75rem 1rem 2rem; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
}
.tabs a span { font-size: 1.35rem; line-height: 1; }
.tabs a.active { color: var(--accent); font-weight: 600; }

/* ---------- building blocks ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin: 0 0 0.9rem;
  box-shadow: var(--shadow);
}

.btn, button.btn {
  display: inline-block;
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.secondary { background: var(--surface-2); color: var(--text); }

.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { width: auto; min-height: 0; }

.stack { display: grid; gap: 0.8rem; }
.stack label { display: grid; gap: 0.3rem; font-weight: 600; }
.inline { display: inline; margin: 0; }

.error { color: var(--down); font-weight: 600; }
.success-text { color: var(--up); font-weight: 600; }
.empty { padding: 2rem 0; color: var(--muted); text-align: center; }
.back { display: inline-block; margin: 0.2rem 0 0.4rem; text-decoration: none; }

.badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.gold { background: var(--gold); color: #1b120a; }

.points { font-weight: 700; font-variant-numeric: tabular-nums; }
.points.big { font-size: 1.4rem; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 3rem auto; }

/* ---------- beer list ---------- */
.filters {
  position: sticky;
  top: 52px;
  z-index: 5;
  background: var(--bg);
  padding: 0.3rem 0 0.4rem;
}
.filter-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; margin-top: 0.5rem; align-items: center; }
.check { display: flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; white-space: nowrap; }
#count { margin: 0.4rem 0 0; }

.beer-list { list-style: none; margin: 0; padding: 0; }
.beer-list li a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.2rem;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.beer-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.beer-name { font-weight: 600; overflow-wrap: anywhere; }
.beer-brewery { color: var(--muted); font-size: 0.9rem; }
.beer-meta { color: var(--muted); font-size: 0.8rem; margin: 0.1rem 0 0; }
.beer-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.beer-list .points { font-size: 1.1rem; }

/* ---------- beer page ---------- */
.beer-head h1 { margin: 0.1rem 0 0.2rem; }
.beer-head .beer-brewery { margin: 0; font-size: 1rem; }
.stat-row { display: flex; flex-wrap: wrap; gap: 1.2rem; margin: 0.8rem 0 1rem; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.8rem; }

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}
.history li form { grid-column: 2 / -1; }
.history li.current { font-weight: 600; }
.history-date { color: var(--muted); font-size: 0.85rem; }
.history-text { overflow-wrap: anywhere; }

.sparkline { width: 100%; height: auto; max-height: 120px; margin: 0.2rem 0 0.4rem; }
.sparkline path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.sparkline circle { fill: var(--accent); }
.sparkline .mid { stroke: var(--line); stroke-dasharray: 4 4; }

.tasting { padding: 0.5rem 0; border-top: 1px solid var(--line); }
.tasting p { margin: 0.2rem 0; }

.scores { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0; padding: 0; }
.scores li {
  display: flex;
  gap: 0.3rem;
  align-items: baseline;
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.85rem;
}
.scores span { color: var(--muted); font-size: 0.75rem; }

/* ---------- check ---------- */
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin-bottom: 1rem; }
.verdict { padding: 0.9rem 1rem; border-radius: var(--radius); font-weight: 700; margin-bottom: 0.9rem; }
.verdict.bad { background: color-mix(in srgb, var(--down) 18%, var(--surface)); }
.verdict.maybe { background: color-mix(in srgb, var(--gold) 22%, var(--surface)); }
.verdict.good { background: color-mix(in srgb, var(--up) 18%, var(--surface)); }
.hits { list-style: none; margin: 0; padding: 0; }
.hits a { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.hits .same { border-color: var(--down); }

/* ---------- meetings ---------- */
.meeting-list, .meeting-beers, .members { list-style: none; margin: 0; padding: 0; }
.meeting-list a { display: flex; flex-direction: column; gap: 0.15rem; color: inherit; text-decoration: none; }
.meeting-date { font-weight: 700; }
.meeting-winner { font-size: 0.9rem; }
.meeting-beer-head { display: flex; align-items: center; gap: 0.8rem; }
.meeting-beer-head .beer-name { text-decoration: none; }
.placing {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface-2);
  font-weight: 700;
}
.placing.gold { background: var(--gold); color: #1b120a; }
.placing.silver { background: #c0c0c0; color: #1b120a; }
.placing.bronze { background: #cd7f32; color: #1b120a; }

/* ---------- accounts ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.6rem; }
.stat-grid .card { margin: 0; }
.stat-grid .stat-value { font-size: 1.1rem; }

details { border-top: 1px solid var(--line); }
details:first-of-type { border-top: 0; }
details summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  cursor: pointer;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary .name::before { content: "▸ "; color: var(--muted); }
details[open] summary .name::before { content: "▾ "; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0; margin: 0 0 0.6rem; font-size: 0.9rem; }
.facts dt { padding-right: 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.ledger { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-bottom: 0.6rem; }
.ledger th, .ledger td { padding: 0.35rem 0.25rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ledger th { color: var(--muted); font-weight: 600; }
.ledger .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- members ---------- */
.member-head { display: flex; align-items: center; gap: 0.8rem; }
.member-head > span:last-child { display: flex; flex-direction: column; }
.member-nick { font-weight: 700; font-size: 1.1rem; }
.initials {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.contact { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.35rem; overflow-wrap: anywhere; }
.contact a { text-decoration: none; }

/* ---------- admin ---------- */
.steps { padding-left: 1.3rem; }
.success { border-color: var(--up); }
.warnings { color: var(--muted); font-size: 0.9rem; }
.btn.danger { background: var(--down); color: #fff; }
.notice { border-color: var(--accent); }
.notice p { margin: 0; }

.subnav { display: flex; gap: 0.4rem; margin: 0.2rem 0 0.6rem; }
.subnav a {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.subnav a.active { background: var(--accent); color: var(--accent-ink); }

.users { list-style: none; margin: 0; padding: 0; }
.user-head { display: flex; flex-direction: column; gap: 0.3rem; }
.user-email { overflow-wrap: anywhere; }
.user-badges { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.users details { margin-top: 0.5rem; border-top: 1px solid var(--line); }
.stack label.check { display: flex; flex-wrap: wrap; }
.user-action { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
