/* Shitportal
   Farben angelehnt an deutsche Verkehrszeichen:
   Signalbraun (touristische Hinweistafeln), Verkehrsgelb (RAL 1023) für Platz 1 und den Schiss des Monats. */

@font-face {
  font-family: "Barlow";
  src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("/fonts/barlow-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-800-normal.woff2") format("woff2");
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  --yellow: #f4c300;
  --brown: #6b3f22;
  --brown-dark: #4a2a15;
  --tan: #c99a5b;
  --sign-black: #000;
  --sign-white: #fff;

  --bg: #e3e5e1;          /* Beton */
  --surface: #f3f4f2;
  --ink: #1f2322;
  --ink-soft: #545b58;
  --line: #c5c9c4;
  --toast-bg: #1f2322;
  --toast-ink: #f3f4f2;

  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sign: "Barlow Condensed", "Arial Narrow", sans-serif;

  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2a2d2c;        /* Asphalt */
    --surface: #343837;
    --ink: #eceeeb;
    --ink-soft: #a9b0ac;
    --line: #4a504d;
    --toast-bg: #eceeeb;
    --toast-ink: #2a2d2c;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

body.booting .app, body.booting .login { visibility: hidden; }

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr); /* breite Inhalte (z. B. Tab-Leisten) dürfen die Seite nicht verbreitern */
}
.app[hidden], .login[hidden] { display: none; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  background: var(--surface); color: var(--ink); padding: 8px 12px; border-radius: 6px;
}
.skip:focus { top: 8px; }

/* ---------- Kopf ---------- */

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--gutter) 10px;
}

.brand {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: .01em;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  padding: 8px 0;
}

.sync {
  font-size: .8125rem;
  color: var(--ink-soft);
  min-height: 1em;
}

main {
  min-height: 0;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b));
}

.view[hidden] { display: none !important; }


/* ---------- Seiten ---------- */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px var(--gutter) 32px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
}

.block { margin-top: 32px; }
.block:first-child { margin-top: 0; }

.block h2 {
  margin: 0 0 12px;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Zeitraum */
.range {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.range button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .9375rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 36px;
}
.range button[aria-checked="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* Summe + Anteile */
.sum {
  margin: 0 0 16px;
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 1.375rem;
  line-height: 1.1;
  color: var(--ink-soft);
}
.sum span {
  display: block;
  font-weight: 800;
  font-size: 4.5rem;
  line-height: .9;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.totals { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.totals li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  row-gap: 6px;
}
.totals .t-name { font-weight: 600; }
.totals .t-val { font-variant-numeric: tabular-nums; }
.totals .t-val small { color: var(--ink-soft); font-size: .875rem; margin-left: 6px; }
.totals .t-bar {
  grid-column: 1 / -1;
  height: 12px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}
.totals .t-bar i { display: block; height: 100%; border-radius: 3px; min-width: 2px; }

/* Farben für Diagramme */
.c-furz  { background: var(--tan); }
.c-ultra { background: var(--brown); }

/* Säulendiagramme */
.chart {
  height: 150px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  border-bottom: 1px solid var(--ink);
}
.chart-hours { gap: 2px; }
.chart .col {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
}
.chart .col i { display: block; width: 100%; }
.chart .col i:last-child { border-radius: 2px 2px 0 0; }

.axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: .8125rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.axis-week span { flex: 1 1 0; text-align: center; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: -4px 0 12px;
  padding: 0;
  list-style: none;
  font-size: .875rem;
  color: var(--ink-soft);
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* Fakten */
.facts { margin: 0; display: grid; gap: 0; }
.facts div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.facts div:last-child { border-bottom: 1px solid var(--line); }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Leerer Zustand */
.empty {
  padding: 32px 0;
}
.empty p { margin: 0 0 16px; font-size: 1.125rem; }
.empty-link {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--brown);
  color: var(--sign-white);
  font-weight: 600;
  text-decoration: none;
  box-shadow: inset 0 0 0 2px var(--brown-dark);
}

/* ---------- Regeln ---------- */

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: para;
}
.rules > li {
  counter-increment: para;
  display: grid;
  grid-template-columns: 3rem 1fr;
  column-gap: 8px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.rules > li:last-child { border-bottom: 1px solid var(--line); }
.rules > li::before {
  content: "§\00a0" counter(para);
  grid-row: 1 / span 3;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
}
.rules h2 {
  margin: 0 0 4px;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
}
.rules p { margin: 0; max-width: 34em; }

/* Definition: eigener Abschnitt unter den Regeln */
.definition { margin-top: 56px; }
.definition h2 {
  margin: 0 0 16px;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
}
.definition p { margin: 0; max-width: 34em; font-size: 1.0625rem; }
.definition .guide-title { margin-top: 20px; font-weight: 600; }
.guide { margin: 8px 0 0; display: grid; gap: 0; max-width: 34em; }
.guide div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.guide div:last-child { border-bottom: 1px solid var(--line); }
.guide dt { font-family: var(--font-sign); font-weight: 800; font-size: 1.25rem; line-height: 1.2; }
.guide dd { margin: 0; align-self: center; }

/* ---------- Kopf: Konto und Admin ---------- */

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.top-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  min-width: 40px;
  justify-content: center;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: .9375rem;
}
.top-link span {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-link svg {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.top-link[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.top-gear[hidden] { display: none; }
.top { align-items: center; padding-top: calc(env(safe-area-inset-top, 0px) + 8px); padding-bottom: 6px; }
.sync:empty { display: none; }
.sync { margin-right: 4px; }

/* ---------- Formulare ---------- */

.form { display: grid; gap: 16px; max-width: 420px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .9375rem; }
.field small { color: var(--ink-soft); font-size: .8125rem; }
.field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem; /* verhindert Auto-Zoom auf iOS */
}
.field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
}
.field select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.field input[type="number"] { max-width: 160px; }
.field input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.field input::placeholder { color: var(--ink-soft); opacity: .8; }

.check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 40px; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fbe3dd;
  color: #7a1d0c;
  font-weight: 500;
}
.form-error[hidden] { display: none; }
.hint { margin: 0; color: var(--ink-soft); font-size: .9375rem; }
.hint[hidden] { display: none; }
.form-info {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  font-weight: 500;
}
.form-info[hidden] { display: none; }
.login .btn[hidden] { display: none; }

.top-gear { position: relative; }
.badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #c4300f;
  color: #fff;
  font-size: .6875rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.badge[hidden] { display: none; }

.requests li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 0;
}
.requests .r-actions { display: flex; gap: 8px; }
.block[hidden] { display: none; }

.btn {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.0625rem;
  cursor: pointer;
}
.btn-primary {
  background: var(--brown);
  color: var(--sign-white);
  box-shadow: inset 0 0 0 2px var(--brown-dark);
}
.btn-secondary {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}
.btn-small { min-height: 40px; padding: 0 14px; font-size: .9375rem; }
.btn-danger { background: transparent; color: #a3260f; box-shadow: inset 0 0 0 1.5px #a3260f; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- Anmeldung ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) var(--gutter) calc(var(--safe-b) + 24px);
}
.login-inner { width: 100%; max-width: 420px; margin: 0 auto; }
.login-sign {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-bottom: 32px;
  padding: 22px 16px 16px;
  border-radius: 10px;
  background: var(--brown);
  color: var(--sign-white);
  box-shadow: inset 0 0 0 6px var(--brown), inset 0 0 0 9px var(--sign-white), 0 2px 0 rgba(0, 0, 0, .18);
  text-align: center;
}
.login-sign-name {
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: clamp(2.25rem, 12vw, 3.25rem);
  line-height: 1;
}
.login-sign-sub {
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 1.125rem;
}
.login .btn { width: 100%; }

.force-title {
  margin: 0 0 8px;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 2.25rem;
  line-height: 1.05;
}
.force-text { margin: 0 0 24px; font-size: 1.0625rem; }

/* ---------- Konto ---------- */

.whoami { margin: 0; font-size: 1.0625rem; }
.whoami span { color: var(--ink-soft); }
.whoami-login { margin: 4px 0 0; color: var(--ink-soft); }
.whoami-login[hidden] { display: none; }


/* ---------- Statistik: Personen ---------- */

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.people li {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 5px;
  align-items: baseline;
}
.people .p-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .p-name.none { font-weight: 500; color: var(--ink-soft); }
.people .p-sum { font-variant-numeric: tabular-nums; }
.people .p-bar { grid-column: 1 / -1; display: flex; height: 10px; }
.people .p-bar i { display: block; height: 100%; }
.people .p-bar i:first-child { border-radius: 3px 0 0 3px; }
.people .p-bar i:last-child { border-radius: 0 3px 3px 0; }
.people .p-bar i:only-child { border-radius: 3px; }
.people .me .p-name::after { content: " (du)"; font-weight: 500; color: var(--ink-soft); }

/* ---------- Ranking ---------- */

.rk-month { margin: 0; font-size: 1.0625rem; font-weight: 600; color: var(--ink-soft); }

.podium {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}
.podium[hidden] { display: none; }
.pod { display: flex; flex-direction: column; min-width: 0; text-align: center; }
.pod-pos-1 { order: 2; }
.pod-pos-2 { order: 1; }
.pod-pos-3 { order: 3; }
.pod-name {
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pod-sum {
  margin: 2px 0 8px;
  color: var(--ink-soft);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
.pod-block {
  display: flex;
  padding: 5px;
  border-radius: 10px 10px 3px 3px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .18);
}
.pod-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border: 3px solid;
  border-radius: 6px 6px 2px 2px;
}
.pod-rank { font-family: var(--font-sign); font-weight: 800; font-size: 2.75rem; line-height: 1; }
.pod.me .pod-inner::after {
  content: "du";
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--sign-white);
  font-size: .8125rem;
  font-weight: 700;
  line-height: 1.4;
}
.pod-1.me .pod-inner::after { background: var(--sign-black); color: var(--yellow); }
.pod-2.me .pod-inner::after { color: var(--brown); }
.pod-1 .pod-block { height: 150px; background: var(--yellow); color: var(--sign-black); }
.pod-1 .pod-inner { border-color: var(--sign-black); }
.pod-1 .pod-rank { font-size: 3.5rem; }
.pod-2 .pod-block { height: 112px; background: var(--brown); color: var(--sign-white); }
.pod-3 .pod-block { height: 92px; background: var(--tan); color: var(--sign-black); }
.pod-2 .pod-inner { border-color: var(--sign-white); }
.pod-3 .pod-inner { border-color: var(--sign-black); }
.pod-3.me .pod-inner::after { background: var(--sign-black); color: var(--tan); }
.pod.free .pod-name { color: var(--ink-soft); font-weight: 500; }
.pod.free .pod-block { opacity: .3; box-shadow: none; }

.ranks, .history { list-style: none; margin: 0; padding: 0; }
.ranks li {
  display: grid;
  grid-template-columns: 1.75em minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.ranks li:last-child { border-bottom: 1px solid var(--line); }
.r-rank { font-family: var(--font-sign); font-weight: 800; font-size: 1.25rem; color: var(--ink-soft); }
.r-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-sum { font-variant-numeric: tabular-nums; }
.ranks .me .r-name::after { content: " (du)"; font-weight: 500; color: var(--ink-soft); }

.rk-reset { margin: 20px 0 0; color: var(--ink-soft); font-size: .9375rem; }
.rk-history { margin-top: 40px; }

.history li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: baseline;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.history li:last-child { border-bottom: 1px solid var(--line); }
.h-month { grid-column: 1 / -1; color: var(--ink-soft); font-size: .875rem; font-weight: 600; }
.h-name { font-weight: 700; font-size: 1.0625rem; overflow-wrap: anywhere; }
.h-name::before {
  content: "1";
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  margin-right: 8px;
  border-radius: 4px;
  background: var(--yellow);
  color: var(--sign-black);
  box-shadow: inset 0 0 0 1.5px var(--sign-black);
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: .9375rem;
  vertical-align: 1px;
}
.h-sum { color: var(--ink-soft); font-size: .9375rem; font-variant-numeric: tabular-nums; white-space: nowrap; }


/* ---------- Admin ---------- */

.u-rename { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 10px; padding: 0 0 14px; max-width: 480px; }
.u-rename .field { flex: 1 1 200px; }
.u-rename .btn { margin-top: 27px; }

.credential {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  max-width: 420px;
}
.credential[hidden] { display: none; }
.credential p { margin: 0 0 8px; }
.credential .pw {
  display: inline-block;
  margin-right: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .04em;
  user-select: all;
  -webkit-user-select: all;
}
.credential small { display: block; margin-top: 8px; color: var(--ink-soft); }

.users { list-style: none; margin: 0; padding: 0; }
.users > li { border-top: 1px solid var(--line); }
.users > li:last-child { border-bottom: 1px solid var(--line); }
.users summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
}
.users summary::-webkit-details-marker { display: none; }
.users summary::after {
  content: "";
  width: 10px; height: 10px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(45deg) translateY(-3px);
  grid-row: 1 / span 2;
  grid-column: 2;
}
.users details[open] summary::after { transform: rotate(-135deg) translateY(-3px); }
.u-name { font-weight: 600; font-size: 1.0625rem; }
.u-meta { grid-column: 1; color: var(--ink-soft); font-size: .875rem; }
.u-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  vertical-align: 2px;
  background: var(--ink);
  color: var(--bg);
}
.u-tag.locked { background: #a3260f; color: #fff; }
.u-tag.pending { background: var(--yellow); color: var(--sign-black); }
.u-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 14px; }
.u-actions .credential { flex-basis: 100%; margin-top: 4px; }

@media (prefers-color-scheme: dark) {
  .form-error { background: #4a1d14; color: #ffd9cf; }
  .btn-danger { color: #ff9a85; box-shadow: inset 0 0 0 1.5px #ff9a85; }
  .u-tag.locked { background: #ff9a85; color: #2a2d2c; }
}


/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  z-index: 20;
  min-height: 56px;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  border-radius: 10px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  animation: toast-in 180ms ease-out;
}
.toast[hidden] { display: none; }
.toast-text { font-weight: 500; }
.toast-action {
  border: 0;
  background: var(--tan);
  color: var(--sign-black);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 7px;
  cursor: pointer;
  min-height: 40px;
}

@keyframes toast-in {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}


/* ---------- Tab-Leiste ---------- */

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .8125rem;
  font-weight: 500;
}
.tabs svg {
  width: 26px; height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabs a[aria-current="page"] svg { stroke-width: 2.2; }
.tabs a:focus-visible { outline-offset: -4px; }
.tabs .badge { top: 6px; right: calc(50% - 24px); }

.sheet {
  border: 0;
  padding: 0;
  color: var(--ink);
  background: var(--bg);
}
.sheet::backdrop { background: rgba(0, 0, 0, .55); }
.sheet {
  width: min(480px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 32px);
  border-radius: 14px;
  overflow: auto;
}
.sheet .form { padding: 20px var(--gutter) 20px; max-width: none; }
.sheet-title {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 2rem;
  line-height: 1;
}

.ap-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.ap-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ap-bar [hidden] { display: none; }

/* ---------- Admin: Unter-Tabs ---------- */

.subtabs {
  display: flex;
  gap: 2px;
  margin: 0 calc(-1 * var(--gutter)) 20px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.subtabs::-webkit-scrollbar { display: none; }
.subtabs [role="tab"] {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  margin-bottom: -1px;
  padding: 0 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.subtabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.subtabs [role="tab"]:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.subtab-badge {
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #c4300f;
  color: #fff;
  font-size: .6875rem;
  line-height: 18px;
  text-align: center;
}
.subtab-badge[hidden] { display: none; }
.admin-panel[hidden] { display: none; }
.admin-panel > .hint:first-child { margin-bottom: 12px; }
.empty-note { margin: 16px 0; color: var(--ink-soft); font-size: 1.0625rem; }
.empty-note[hidden] { display: none; }

.create-box {
  margin-bottom: 20px;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: var(--surface);
}
.create-box summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.create-box summary::-webkit-details-marker { display: none; }
.create-box summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--brown);
  color: var(--sign-white);
  box-shadow: inset 0 0 0 1.5px var(--brown-dark);
  font-size: 1.25rem;
  line-height: 1;
}
.create-box[open] summary::before { content: "−"; }
.create-box .form { padding: 4px 14px 16px; }
.create-box .credential { margin: 0 14px 16px; }

/* ---------- Regeln bestätigen ---------- */

.rules-sheet { width: min(560px, calc(100vw - 2 * var(--gutter))); overflow: hidden; }
.rules-sheet-inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 32px);
}
.rules-sheet-head { flex: none; padding: 20px var(--gutter) 8px; }
.rules-sheet-head .hint { margin-top: 6px; }
.rules-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--gutter) 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.rules-sheet-body .rules { margin-top: 8px; }
.rules-sheet-body .definition { margin-top: 32px; }
.rules-sheet-body .definition h2 { font-size: 1.75rem; }
.rules-sheet-actions { flex: none; display: grid; gap: 8px; padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom, 0px)); }
.rules-reset { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.rules-reset h3 { margin: 0 0 6px; font-size: 1.0625rem; }
.rules-reset .btn { margin-top: 10px; }
/* ---------- Aufnehmen ---------- */

.view-record {
  min-height: calc(100dvh - var(--tabs-h) - var(--safe-b) - 64px);
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px var(--gutter) 12px;
}
.view-record[hidden] { display: none; }

/* Zähltafel als braune Hinweistafel */
.tally {
  flex: none;
  display: flex;
  padding: 6px;
  border-radius: 12px;
  background: var(--brown);
  color: var(--sign-white);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .18);
}
.tally-inner {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  column-gap: 12px;
  padding: 10px 16px 10px 18px;
  border: 3px solid var(--sign-white);
  border-radius: 7px;
}
.tally-label {
  align-self: center;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: clamp(1.875rem, 9.5vw, 2.5rem);
  line-height: 1;
}
.tally-count {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: clamp(3rem, 16vw, 4.5rem);
  line-height: .85;
  font-variant-numeric: tabular-nums;
}
.tally-today {
  grid-row: 2;
  font-family: var(--font-sign);
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.2;
  opacity: .9;
}
.tally-today b { font-weight: 800; font-variant-numeric: tabular-nums; }
.tally-count.bump { animation: bump 260ms cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* Aufnahmeknopf wie in Messengern: halten, wischen, fixieren */
.recorder {
  --dx: 0px;
  flex: 1 1 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 300px;
  padding: 16px 0;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}
.rec-status {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
  text-align: center;
}
.rec-live {
  display: none;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.25rem;
}
.rec-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #d22f12;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }
.rec-meter {
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.rec-meter i {
  display: block;
  height: 100%;
  background: var(--brown);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 90ms linear;
}
.rec-cancel-hint {
  display: none;
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
  transform: translateX(calc(var(--dx) * .5));
}
.rec-lock {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--ink-soft);
  font-size: .8125rem;
  font-weight: 600;
}
.rec-lock svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  animation: nudge 1.2s ease-in-out infinite;
}
@keyframes nudge { 50% { transform: translateY(-4px); } }

.mic {
  position: relative;
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brown);
  color: var(--sign-white);
  box-shadow: inset 0 0 0 6px var(--brown), inset 0 0 0 9px var(--sign-white), 0 3px 0 rgba(0, 0, 0, .2);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 120ms ease-out, background 120ms;
}
.mic svg {
  width: 64px; height: 64px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  pointer-events: none;
}
.mic:disabled { opacity: .6; cursor: default; }
.rec-locked-actions { display: none; gap: 10px; }
.rec-hint { text-align: center; padding: 0 16px; }

.recorder[data-state="starting"] .mic { transform: scale(.96); }
.recorder[data-state="recording"] .mic,
.recorder[data-state="locked"] .mic {
  background: #c4300f;
  box-shadow: inset 0 0 0 6px #c4300f, inset 0 0 0 9px var(--sign-white), 0 0 0 10px rgba(196, 48, 15, .18);
  animation: pulse 1.4s ease-in-out infinite;
}
.recorder[data-state="recording"] .mic { transform: translateX(var(--dx)) scale(1.08); transition: none; }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 6px #c4300f, inset 0 0 0 9px var(--sign-white), 0 0 0 22px rgba(196, 48, 15, .1); } }
.recorder[data-state="recording"] .rec-live,
.recorder[data-state="locked"] .rec-live { display: flex; }
.recorder[data-state="recording"] .rec-cancel-hint { display: block; }
.recorder[data-state="recording"] .rec-lock { display: flex; }
.recorder[data-state="locked"] .rec-locked-actions { display: flex; }
.recorder[data-state="locked"] .rec-hint,
.recorder[data-state="recording"] .rec-hint { visibility: hidden; }
.recorder[data-state="sending"] .rec-status { color: var(--ink-soft); }

/* ---------- Letzte Aufnahme ---------- */

.undo-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 6px 6px 6px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.undo-text {
  flex: 1;
  margin: 0;
  font-size: .9375rem;
  line-height: 1.3;
  color: var(--ink-soft);
}
.undo-text b { color: var(--ink); font-weight: 600; }
.undo-play:empty { display: none; }
.undo-btn {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.undo-btn.confirm { background: var(--ink); color: var(--bg); }
.undo-btn[hidden] { display: none; }

/* ---------- Abspielen ---------- */

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.play {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brown);
  color: var(--sign-white);
  cursor: pointer;
  touch-action: manipulation;
}
.play svg { width: 22px; height: 22px; fill: currentColor; }
.play .i-pause { display: none; }
.player.playing .play .i-play { display: none; }
.player.playing .play .i-pause { display: inline; }
.wave {
  --p: 0%;
  position: relative;
  flex: 1 1 auto;
  min-width: 60px;
  height: 36px;
}
.wave .bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}
.wave .bars i {
  flex: 1 1 0;
  min-width: 1px;
  border-radius: 2px;
  background: var(--line);
}
.wave .bars.fill { clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.wave .bars.fill i { background: var(--brown); }
.dur {
  flex: none;
  min-width: 3.4em;
  text-align: right;
  font-size: .875rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.player-mini .play { width: 40px; height: 40px; }
.player-big .play { width: 64px; height: 64px; }
.player-big .play svg { width: 30px; height: 30px; }
.player-big .wave { height: 64px; cursor: pointer; }
.player-big .wave .bars { gap: 3px; }

@media (prefers-color-scheme: dark) {
  .play, .wave .bars.fill i { background: var(--tan); color: var(--sign-black); }
  .play svg { fill: var(--sign-black); }
}

/* ---------- Swipe ---------- */

.deck {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: min(380px, calc(100dvh - var(--tabs-h) - var(--safe-b) - 300px));
  min-height: 280px;
  margin: 4px auto 0;
}
.deck[hidden] { display: none; }
.card {
  position: absolute;
  inset: 0;
  display: flex;
  border-radius: 14px;
  overflow: hidden;
  background: var(--brown);
  color: var(--sign-white);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 200ms ease-out;
  will-change: transform;
}
.card:not(.is-top) { transform: scale(.95) translateY(10px); filter: brightness(.8); }
.card.is-top { cursor: grab; }
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  margin: 8px;
  padding: 20px 18px;
  border: 3px solid var(--sign-white);
  border-radius: 9px;
}
.card-who {
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.card-when { opacity: .85; font-weight: 500; margin-bottom: 18px; }
.card .play { background: var(--sign-white); color: var(--brown); }
.card .play svg { fill: var(--brown); }
.card .wave .bars i { background: rgba(255, 255, 255, .3); }
.card .wave .bars.fill i { background: var(--sign-white); }
.card .dur { color: rgba(255, 255, 255, .85); }
.stamp {
  position: absolute;
  top: 22px;
  padding: 4px 12px;
  border-radius: 8px;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 2.25rem;
  line-height: 1;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}
.stamp-furz {
  right: 18px;
  transform: rotate(12deg);
  background: var(--tan);
  color: var(--sign-black);
  box-shadow: inset 0 0 0 3px var(--sign-black);
}
.stamp-ultra {
  left: 18px;
  transform: rotate(-12deg);
  background: var(--yellow);
  color: var(--sign-black);
  box-shadow: inset 0 0 0 3px var(--sign-black);
}
.deck-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 440px;
  margin: 16px auto 0;
}
.deck-actions[hidden] { display: none; }
.vote {
  min-height: 56px;
  border: 0;
  border-radius: 10px;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 1.375rem;
  cursor: pointer;
  touch-action: manipulation;
}
.vote-furz { background: var(--tan); color: var(--sign-black); box-shadow: inset 0 0 0 2px var(--sign-black), 0 2px 0 rgba(0, 0, 0, .18); }
.vote-ultra { background: var(--brown); color: var(--sign-white); box-shadow: inset 0 0 0 2px var(--sign-white), 0 2px 0 rgba(0, 0, 0, .18); }
.vote:active { transform: translateY(1px); }
.deck-hint { max-width: 440px; margin: 12px auto 0; text-align: center; font-size: .875rem; }
#sw-play[hidden], #sw-area[hidden] { display: none; }
.area-note { margin-bottom: 12px; }
.more-btn { display: block; margin: 16px auto 0; }
.more-btn[hidden] { display: none; }

/* ---------- Listen ---------- */

.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.rec-item:last-child { border-bottom: 1px solid var(--line); }
.rec-item > .player { flex: 0 1 46%; }
.rec-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.rec-who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: .8125rem; }
.rec-when { color: var(--ink-soft); margin-right: 2px; }
.chip {
  padding: 0 6px;
  border-radius: 4px;
  font-weight: 700;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}
.chip-furz { background: var(--tan); color: var(--sign-black); }
.chip-ultra { background: var(--brown); color: var(--sign-white); }
.chip-heart { background: #ff4d6d; color: #fff; }
.rec-check { display: none; flex: none; width: 22px; height: 22px; accent-color: #c4300f; }
.rec-list.selecting .rec-check { display: block; }

@media (max-width: 400px) {
  .rec-item > .player .wave { display: none; }
  .rec-item > .player { flex: none; }
}

/* ---------- Detailansicht ---------- */

.detail { width: min(520px, calc(100vw - 2 * var(--gutter))); }
.detail-inner { display: grid; gap: 12px; padding: 20px var(--gutter); }
.detail-inner p { margin: 0; }
.detail-votes { color: var(--ink-soft); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.detail-heart { margin-right: auto; }

/* ---------- Herzen ---------- */

.heart-btn {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 52px;
  height: 52px;
  padding: 0 12px;
  border: 0;
  border-radius: 26px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}
.heart-btn svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.heart-btn.on { color: #ff4d6d; }
.heart-btn.on svg { fill: currentColor; animation: heart-pop 240ms ease-out; }
.heart-count:empty { display: none; }
@keyframes heart-pop { 50% { transform: scale(1.3); } }
.detail-heart .heart-btn {
  position: static;
  height: 40px;
  min-width: 40px;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}
.detail-heart .heart-btn.on { color: #e0294d; }
.detail-heart .heart-btn svg { width: 22px; height: 22px; }

/* ---------- Schiss des Monats ---------- */

.sdm { margin-bottom: 32px; }
.sdm-title {
  margin: 0 0 12px;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
}
.sdm-current { display: grid; gap: 14px; }
.sdm-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 3px var(--yellow);
}
.sdm-card.big {
  margin: 7px;
  padding: 16px;
  box-shadow: 0 0 0 4px var(--yellow), 0 0 0 7px var(--sign-black);
}
.sdm-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.sdm-hearts { color: #e0294d; font-weight: 800; white-space: nowrap; }
.sdm-by { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdm-card:not(.big) { grid-template-columns: auto minmax(0, 1fr); align-items: center; padding: 8px; }
.sdm-card:not(.big) .sdm-meta { flex-direction: column; gap: 0; font-size: .875rem; }
.rk-sub {
  margin: 0;
  font-family: var(--font-sign);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
}
.sdm-history { list-style: none; margin: 0; padding: 0; }
.sdm-history li { padding: 12px 0; border-top: 1px solid var(--line); }
.sdm-history li:last-child { border-bottom: 1px solid var(--line); }
.sdm-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 6px; }

/* ---------- Admin ---------- */

.threshold { display: grid; justify-items: start; gap: 10px; margin-top: 16px; }
#setting-usage { margin-top: 12px; }
.r-info { display: grid; }
.admin-panel > .check + .hint { margin: 0 0 4px 32px; font-size: .875rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
