:root {
  --bg: #f6efe2;
  --surface: #fffaf0;
  --surface-2: #efe5d2;
  --text: #2a2118;
  --muted: #76675a;
  --border: #ddcfb7;
  --accent: #a8541c;
  --accent-text: #fffaf0;
  --star: #c98a12;
  --hit: #2f7a46;
  --hit-bg: #e3f1e5;
  --flop: #b0362b;
  --flop-bg: #f7e1dd;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 16px rgba(60, 40, 20, .06);
  --radius: 14px;
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1712; --surface: #262019; --surface-2: #2f281f; --text: #f1e7d6; --muted: #a8998a;
    --border: #3d3428; --accent: #e08a45; --accent-text: #1c1712; --star: #f0b53a;
    --hit: #7cc892; --hit-bg: #1f3325; --flop: #f08a7d; --flop-bg: #3a2220;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1712; --surface: #262019; --surface-2: #2f281f; --text: #f1e7d6; --muted: #a8998a;
  --border: #3d3428; --accent: #e08a45; --accent-text: #1c1712; --star: #f0b53a;
  --hit: #7cc892; --hit-bg: #1f3325; --flop: #f08a7d; --flop-bg: #3a2220;
  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 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font: 600 1.2rem var(--serif); color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: .95rem; }
.nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
@media (max-width: 560px) {
  .nav { margin-left: 0; width: 100%; }
}

.container { max-width: 860px; margin: 0 auto; padding: 20px 16px 64px; }
.offline { background: var(--flop-bg); color: var(--flop); text-align: center; padding: 6px; font-size: .9rem; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
a.card { display: block; color: inherit; text-decoration: none; transition: transform .12s, border-color .12s; }
a.card:hover { border-color: var(--accent); }
a.card:active { transform: scale(.99); }
.card-title { font: 600 1.1rem var(--serif); margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .9rem; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 8px 0 4px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font: 600 1.5rem var(--serif); }
.stat span { color: var(--muted); font-size: .85rem; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; background: var(--surface-2); color: var(--muted); }
.hit { background: var(--hit-bg); color: var(--hit); }
.flop { background: var(--flop-bg); color: var(--flop); }

.stars-view { color: var(--star); letter-spacing: 1px; white-space: nowrap; }
.stars-view .off { color: var(--border); }

/* Formulare */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="checkbox"] { width: auto; min-height: 0; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 .95rem var(--font); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--flop); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* Sterne-Eingabe */
.stars { display: inline-flex; gap: 2px; }
.stars button {
  background: none; border: 0; padding: 4px 3px; font-size: 1.6rem; line-height: 1; cursor: pointer;
  color: var(--border); min-width: 34px; min-height: 40px;
}
.stars button.on { color: var(--star); }
.stars.compact button { font-size: 1.3rem; min-width: 28px; min-height: 34px; padding: 2px; }

/* Positionen im Formular */
.item {
  background: var(--surface-2); border-radius: 12px; padding: 12px; margin-bottom: 10px;
  display: grid; gap: 8px; grid-template-columns: 1fr 1fr 110px;
}
.item .full { grid-column: 1 / -1; }
.item .item-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item label { margin-bottom: 2px; font-size: .8rem; }
@media (max-width: 560px) {
  .item { grid-template-columns: 1fr 1fr; }
  .item .price { grid-column: 1 / -1; }
}

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; white-space: nowrap; }

.quote { border-left: 3px solid var(--border); padding: 2px 0 2px 12px; margin: 10px 0; }
.quote.hit { border-color: var(--hit); background: none; color: inherit; }
.quote.flop { border-color: var(--flop); background: none; color: inherit; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.error { background: var(--flop-bg); color: var(--flop); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }

.login { max-width: 380px; margin: 10vh auto 0; }
.login .logo { display: block; margin: 0 auto 12px; }
.login h1 { text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .95rem;
  box-shadow: var(--shadow); z-index: 50; max-width: calc(100% - 32px);
}
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  box-shadow: var(--shadow); min-height: 52px; padding: 0 22px; font-size: 1rem;
}

/* Abendplaner */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 500 .95rem var(--font); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.vote-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.vote {
  position: relative; flex: 1; display: block; text-align: left; padding: 10px 14px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; min-height: 48px;
}
.vote:disabled { cursor: default; }
.vote[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.vote.winner { border-color: var(--hit); box-shadow: inset 0 0 0 1px var(--hit); }
.vote .bar { position: absolute; inset: 0 auto 0 0; background: var(--surface-2); transition: width .2s; }
.vote.winner .bar { background: var(--hit-bg); }
.vote > :not(.bar) { position: relative; }
.vote-line { display: flex; justify-content: space-between; gap: 12px; }
.vote .count { font-weight: 600; }
.vote .small { display: block; }
.item.missing { box-shadow: inset 0 0 0 2px var(--flop); }
.item.missing .item-foot label { color: var(--flop); font-weight: 600; }

/* Profilbilder */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; vertical-align: middle;
  border-radius: 50%; object-fit: cover; background: var(--surface-2); color: #fff; font-weight: 600; line-height: 1;
}
.who { display: inline-flex; align-items: center; gap: 8px; }
.voters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.nav a { display: inline-flex; align-items: center; }
.nav a .avatar { margin-right: 6px; }
