:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --border: #e3e0d8;
  --text: #1d1b17;
  --muted: #6d685e;
  --accent: #e8590c;
  --accent-soft: #fde8db;
  --accent-text: #b8450a;
  --focus: #e8590c55;
  --danger: #c92a2a;
  --shadow: 0 1px 2px rgba(30, 25, 15, .05), 0 4px 16px rgba(30, 25, 15, .04);
  --radius: 14px;

  /* Score-Skala 1 (rot) → 10 (grün) */
  --s1: #d9480f; --s2: #e8590c; --s3: #f08c00; --s4: #f59f00; --s5: #e0b300;
  --s6: #a9c11d; --s7: #74b816; --s8: #40c057; --s9: #2f9e44; --s10: #2b8a3e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1e1c19;
    --surface-2: #272521;
    --border: #36332d;
    --text: #efece6;
    --muted: #a09a8e;
    --accent: #ff7a2e;
    --accent-soft: #3a2316;
    --accent-text: #ffa36d;
    --focus: #ff7a2e66;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ───────── Buttons & Inputs ───────── */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }

/* ───────── Login ───────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 4px 0 0; font-size: 24px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.login-card .btn { margin-top: 4px; padding: 11px; }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 21h4v5H8zM14 14h4v12h-4zM20 7h4v19h-4z' fill='white'/%3E%3C/svg%3E");
  background-size: 100%;
}
.logo.small { width: 28px; height: 28px; border-radius: 8px; }

/* ───────── Topbar ───────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.tabs { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.tab { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.progress { flex: 1; min-width: 150px; max-width: 280px; }
.progress-text { font-size: 13px; color: var(--muted); }
.progress-text strong { color: var(--text); }
.progress-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 3px; }
#progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; padding: 4px 10px; border-radius: 99px; font-size: 13px; }

/* ───────── Layout ───────── */
.container { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar #search { flex: 1 1 280px; }
.toolbar .spacer { flex: 1; }
.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; padding: 0 4px; user-select: none; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.result-info { font-size: 13px; margin: 12px 2px 8px; }
.list { display: flex; flex-direction: column; gap: 12px; }

/* ───────── Themen-Karte ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: 80px;
}
.card.rated { border-left: 4px solid var(--accent); }
.card.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--focus); } 100% { box-shadow: var(--shadow); } }
.card-body { padding: 16px 18px 12px; }
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.nr {
  flex: none; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px;
  background: var(--surface-2); color: var(--muted); border-radius: 8px; padding: 3px 8px; margin-top: 2px;
}
.card h2 { margin: 0; font-size: 17px; line-height: 1.35; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.neu { background: #e6f4ea; color: #2b7a3d; }
.pill.weiter { background: #e7f0fd; color: #2459a8; }
.pill.ort { background: #fff1e0; color: #a65a00; }
@media (prefers-color-scheme: dark) {
  .pill.neu { background: #1b3323; color: #7fd18f; }
  .pill.weiter { background: #1b2840; color: #8ab4f8; }
  .pill.ort { background: #3a2a14; color: #ffc078; }
}

.desc {
  margin: 12px 0 0; white-space: pre-line; overflow-wrap: anywhere;
  color: var(--text); font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.desc.open { display: block; -webkit-line-clamp: unset; }
.more { border: 0; background: none; color: var(--accent-text); font-weight: 600; padding: 4px 0; cursor: pointer; font-size: 14px; }
.foot { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; color: var(--muted); }
.tag::before { content: "#"; opacity: .6; }

/* ───────── Bewertung ───────── */
.vote {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 12px 18px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
}
.vote-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; flex: 1 1 340px; max-width: 460px; }
.score-btn {
  height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; padding: 0;
  transition: transform .08s;
}
.score-btn:hover { border-color: var(--accent); }
.score-btn:active { transform: scale(.94); }
.score-btn.sel { color: #fff; border-color: transparent; }
.team { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.avg { font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 8px; color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avg.none { background: var(--surface); color: var(--muted); border: 1px dashed var(--border); font-weight: 600; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 7px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.me { border-color: var(--accent); }
.locked { font-size: 13px; color: var(--muted); }

/* Farben der Scores */
.s1 { background: var(--s1); } .s2 { background: var(--s2); } .s3 { background: var(--s3); }
.s4 { background: var(--s4); } .s5 { background: var(--s5); } .s6 { background: var(--s6); }
.s7 { background: var(--s7); } .s8 { background: var(--s8); } .s9 { background: var(--s9); }
.s10 { background: var(--s10); }
.chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

/* ───────── Ranking ───────── */
.table-wrap { margin-top: 14px; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ranking { width: 100%; border-collapse: collapse; font-size: 14px; }
.ranking th, .ranking td { padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ranking th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
.ranking th.me { color: var(--accent-text); }
.ranking th.left { text-align: left; }
.small { font-size: 13px; }
.ranking td.title { text-align: left; white-space: normal; min-width: 240px; }
.ranking td.title a { color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; }
.ranking td.title a:hover { color: var(--accent-text); text-decoration: underline; }
.ranking td.title .sub { display: block; font-size: 12px; color: var(--muted); }
.ranking tr:last-child td { border-bottom: 0; }
.ranking tbody tr:hover { background: var(--surface-2); }
.rank { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank.top { color: var(--accent-text); }
.cell-score { display: inline-block; min-width: 28px; padding: 2px 6px; border-radius: 6px; color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.cell-empty { color: var(--border); }
.ranking .avgcell { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.small-note { font-size: 13px; margin-top: 12px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ───────── Toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ───────── Mobil ───────── */
@media (max-width: 640px) {
  .topbar { position: static; }
  .topbar-inner { gap: 10px; }
  .progress { order: 5; max-width: none; flex-basis: 100%; }
  .brand span { display: none; }
  .card-body { padding: 14px 14px 10px; }
  .vote { padding: 12px 14px; }
  .scale { flex-basis: 100%; max-width: none; gap: 3px; }
  .score-btn { height: 40px; }
  .team { margin-left: 0; }
  .toolbar select { flex: 1 1 45%; }
}
