/* color9 — Tokens (hell + dunkel), Bausteine. Struktur nach basis/CLAUDE.md §10; eigene ruhige Primärfarbe Abendblau. */

:root {
  --brand: #3b4a7a;
  --brand-dark: #2c3860;
  --brand-light: #e4e8f4;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --ink: #1f2937;
  --muted: #6b7280;
  --bg: #f5f6fa;
  --card: #ffffff;
  --line: #e2e5ee;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(31, 41, 55, 0.06), 0 4px 16px rgba(31, 41, 55, 0.06);
}

/* Dunkel: manuell per data-theme, sonst nach Systemeinstellung (data-theme="light" erzwingt hell) */
[data-theme="dark"] {
  --brand: #8fa2e0;
  --brand-dark: #b3c0ee;
  --brand-light: #262d47;
  --ink: #e8eaf2;
  --muted: #9aa1b5;
  --bg: #12141c;
  --card: #1b1e2a;
  --line: #2c3040;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #8fa2e0;
    --brand-dark: #b3c0ee;
    --brand-light: #262d47;
    --ink: #e8eaf2;
    --muted: #9aa1b5;
    --bg: #12141c;
    --card: #1b1e2a;
    --line: #2c3040;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.2; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 6px 0 12px; }
.error { color: var(--red); font-size: 0.9rem; margin: 8px 0 0; }
.banner { background: var(--brand-light); padding: 12px; border-radius: var(--radius-sm); }
.subtle-link { color: var(--muted); font-size: 0.9rem; }

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

label { display: block; margin: 12px 0 4px; font-size: 0.9rem; font-weight: 600; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .lang-switch button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.code-input { text-transform: uppercase; letter-spacing: 0.25em; font-family: ui-monospace, Menlo, monospace; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: 0.55; }
[data-theme="dark"] .btn.primary { color: #12141c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #12141c; } }

/* ---------- Login- und Reset-Seite ---------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 16px);
}
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 24px; padding: 24px; box-shadow: var(--shadow); position: relative; }
@media (min-width: 640px) { .login-card { zoom: 1.2; } }
.login-card h1 { text-align: center; margin: 6px 0 2px; }
.login-card .subtitle { text-align: center; color: var(--muted); margin: 0 0 16px; }
.logo { font-size: 3rem; text-align: center; }
.lang-switch { position: absolute; top: 14px; right: 14px; display: flex; gap: 2px; }
.lang-switch button { border: 0; background: none; color: var(--muted); font-size: 0.8rem; padding: 4px 6px; border-radius: 6px; }
.lang-switch button.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 700; }

/* ---------- App-Hülle (index.html) ---------- */

/* Basis §10: kein eigenes Desktop-Layout, stattdessen hochskalieren. min-height durch den Zoom teilen,
   sonst wäre die Seite zoom-mal höher als der Bildschirm. */
#app {
  --zoom: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: calc(100dvh / var(--zoom));
  display: flex;
  flex-direction: column;
}
@media (min-width: 640px) { #app { --zoom: 1.3; zoom: 1.3; } }
@media (min-width: 900px) { #app { --zoom: 1.5; zoom: 1.5; } }

.view { flex: 1; padding: 12px 16px 24px; }
.view > .loading { text-align: center; color: var(--muted); margin-top: 40px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 16px) 8px calc(env(safe-area-inset-left) + 16px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  min-height: 56px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.active { color: var(--brand-dark); font-weight: 700; }
.tabbar a.active .tab-icon { background: var(--brand-light); }
.tab-icon { font-size: 1.25rem; line-height: 1; padding: 4px 14px; border-radius: 12px; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h1, .card h2 { margin: 0 0 6px; }
.card h1 { font-size: 1.35rem; }
.card h2 { font-size: 1.05rem; }
.placeholder { text-align: center; padding: 40px 16px; }
.small { font-size: 0.85rem; }

.btn.small { min-height: 44px; padding: 4px 12px; font-size: 0.9rem; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-outline { color: var(--red); border-color: var(--red); background: transparent; }

/* Avatar */
.avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; font-size: 1.3rem; line-height: 1; overflow: hidden; color: #1f2937; }
.avatar.sm { width: 36px; height: 36px; font-size: 1.15rem; }
.avatar.xl { width: 84px; height: 84px; font-size: 2.6rem; }

/* Listen */
.list { list-style: none; margin: 8px 0; padding: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 100px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; letter-spacing: 0.2em; font-weight: 700; }

/* Schalter, Segmente, Chips */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 10px 0; font-weight: 400; font-size: 1rem; }
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 48px; min-height: 28px; height: 28px; padding: 0; border-radius: 14px; background: var(--line); border: 0; position: relative; cursor: pointer; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
input.switch:checked { background: var(--brand); }
input.switch:checked::after { transform: translateX(20px); }
input.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type=range] { padding: 0; min-height: 32px; accent-color: var(--brand); }
input[type=range]:disabled { opacity: 0.45; }
input.color-input { padding: 2px; height: 44px; }

.segmented { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.segmented button { flex: 1; min-height: 44px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; color: var(--muted); }
.segmented button.active { background: var(--brand); color: #fff; }
[data-theme="dark"] .segmented button.active { color: #12141c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented button.active { color: #12141c; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { min-width: 40px; height: 40px; padding: 0 8px; font-size: 1.3rem; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.chip.swatch { width: 40px; padding: 0; }

/* Dialoge und Hinweis */
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 20, 0.55); overflow-y: auto; }
.dialog { width: 100%; max-width: 420px; background: var(--card); border-radius: 20px; padding: 20px; box-shadow: var(--shadow); }
.dialog h2 { margin: 0 0 6px; font-size: 1.15rem; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
body.has-dialog { overflow: hidden; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 76px); transform: translateX(-50%); z-index: 60; max-width: 90vw; padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 0.95rem; }
.toast-error { background: var(--red); color: #fff; }

/* Mitgliederwahl und PIN-Feld (Familiengerät) */
.picker { text-align: center; padding-top: 16px; }
.picker h1 { margin: 4px 0; }
.member-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin: 18px 0; }
.member-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; min-height: 44px; background: var(--card); border: 2px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; }
.member-tile:active { background: var(--brand-light); }
.member-tile.locked { opacity: 0.5; }
.member-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.member-sub { font-size: 0.8rem; color: var(--muted); min-height: 1.1em; }
.pin-screen { display: flex; flex-direction: column; align-items: center; }
.pin-box { width: 100%; max-width: 300px; margin: 0 auto; }
.pin-label { color: var(--muted); margin: 8px 0; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 12px 0; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.on { background: var(--brand); }
.pin-error { min-height: 1.4em; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.pin-key { height: 68px; font-size: 1.7rem; font-weight: 600; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; }
.pin-key:active { background: var(--brand-light); }

/* ---------- Malansicht (paint/screen.js) ---------- */
/* Vollflächig über der App-Hülle; Palette unten (hochkant) bzw. rechts (quer). Die Malfläche selbst zeichnet der
   Renderer (Grund durchsichtig → --stage, bei Vorlagen mit bg die Grundfarbe der Vorlage). */

:root { --stage: #e9ebf2; --ring-track: #d9dce6; }
[data-theme="dark"] { --stage: #0f1118; --ring-track: #31364a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --stage: #0f1118; --ring-track: #31364a; } }

body.painting { overflow: hidden; overscroll-behavior: none; }
.paint-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "stage" "panel";
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
@media (orientation: landscape) {
  .paint-screen {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top top" "stage panel";
  }
}

.paint-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 12px) 6px calc(env(safe-area-inset-left) + 6px);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  touch-action: manipulation; /* kein Doppeltipp-Zoom der Seite auf den Knöpfen */
}
.paint-title { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paint-progress { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: right; color: var(--brand-dark); }
.paint-time { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paint-time svg { width: 16px; height: 16px; }
@media (max-width: 420px) { .paint-time svg { display: none; } .paint-time { font-size: 0.8rem; } }
.icon-btn { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--ink); -webkit-tap-highlight-color: transparent; }
.icon-btn:active { background: var(--brand-light); }
.icon-btn svg { width: 26px; height: 26px; }
.sync-hint { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 0.85rem; }
.sync-hint svg { width: 18px; height: 18px; }

.paint-stage { grid-area: stage; position: relative; overflow: hidden; touch-action: none; background: var(--stage); }
.paint-canvas { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
.paint-msg { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 16px; text-align: center; color: var(--muted); }
.paint-fade { position: absolute; left: 0; top: 0; pointer-events: none; transition: opacity 1.2s ease; }
.paint-fade.out { opacity: 0; }

/* Fehltipper: die Zahl blinkt 300 ms dezent auf */
.miss-blink {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  padding: 0 0.45em;
  border-radius: 999px;
  background: rgba(143, 162, 224, 0.45);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.5;
  animation: c9-blink 300ms ease-out forwards;
}
@keyframes c9-blink { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

.paint-panel {
  grid-area: panel;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--card);
  border-top: 1px solid var(--line);
}
@media (orientation: landscape) {
  .paint-panel { width: calc(272px + env(safe-area-inset-right)); padding-left: 0; border-top: 0; border-left: 1px solid var(--line); }
}

.paint-tools { display: flex; justify-content: space-between; gap: 6px; padding: 8px 12px 4px; touch-action: manipulation; }
@media (orientation: portrait) and (min-width: 600px) { .paint-tools { justify-content: center; gap: 16px; } }
.tool {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
@media (orientation: landscape) { .tool { width: 44px; height: 46px; border-radius: 12px; } }
.tool svg { width: 26px; height: 26px; }
.tool:active { background: var(--brand-light); }
.tool[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .tool[aria-pressed="true"] { color: #12141c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool[aria-pressed="true"] { color: #12141c; } }
.tool:disabled { opacity: 0.38; }

.paint-palette {
  display: flex;
  gap: 10px;
  padding: 8px 12px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  touch-action: pan-x; /* nur scrollen, kein Seitenzoom */
}
@media (orientation: landscape) {
  .paint-palette {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 60px);
    grid-auto-rows: 60px;
    justify-content: center;
    align-content: start;
    gap: 12px;
    padding: 10px 12px 14px;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
  }
}
.swatch { position: relative; flex: none; width: 60px; height: 60px; padding: 0; border: 0; border-radius: 50%; background: transparent; -webkit-tap-highlight-color: transparent; }
/* Fortschrittsring: Anteil gefüllter Felder dieser Farbe */
.swatch .ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--brand) calc(var(--p, 0) * 1turn), var(--ring-track) 0); }
.swatch .dot {
  position: absolute;
  inset: 5px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c);
  color: var(--fg);
  box-shadow: 0 0 0 2px var(--card);
  font-size: 1.15rem;
  font-weight: 700;
}
.swatch.selected .ring { inset: -4px; }
.swatch.selected .dot { box-shadow: 0 0 0 2px var(--card), 0 0 0 5px var(--ink); inset: 7px; }
.swatch.done .ring { background: var(--ring-track); }
.swatch.done .dot { filter: grayscale(0.7); opacity: 0.45; }
.swatch .tick { position: absolute; right: -3px; bottom: -3px; display: none; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--green); color: #fff; box-shadow: 0 0 0 2px var(--card); }
.swatch .tick svg { width: 16px; height: 16px; stroke-width: 3; }
.swatch.done .tick { display: grid; }
/* Farbwechsel per Langdruck: der Knopf leuchtet kurz auf */
.swatch.picked .dot { animation: c9-picked 0.45s ease-out; }
@keyframes c9-picked { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .swatch.picked .dot { animation: none; } }

.swatch:focus-visible, .tool:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.swatch:focus-visible { border-radius: 50%; }
.done-bar { touch-action: manipulation; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 14px 12px; }
.done-bar p { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 0; font-size: 1.2rem; font-weight: 700; }
.done-check { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; }
.done-check svg { width: 20px; height: 20px; stroke-width: 3; }
@media (orientation: landscape) { .done-bar { flex-direction: column; align-items: stretch; } .done-bar .btn { width: 100%; } }

/* Abschluss-Dialog und neue Badges */
.complete-backdrop { background: rgba(10, 12, 20, 0.35); }
.complete-dialog { text-align: center; }
.complete-dialog:focus { outline: none; }
.complete-thumb canvas { display: block; max-width: 100%; max-height: 38vh; height: auto; margin: 0 auto 8px; border-radius: 12px; }
.complete-dialog .dialog-actions { justify-content: center; flex-wrap: wrap; }
.complete-badges h3 { margin: 12px 0 6px; font-size: 1rem; }
.badge-list { list-style: none; margin: 0; padding: 0; text-align: left; }
.badge-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.badge-emoji { font-size: 1.8rem; line-height: 1; }
.badge-body { display: flex; flex-direction: column; }
.badge-note {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 16px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  animation: c9-note-in 300ms ease-out;
}
@keyframes c9-note-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Bibliothek, Galerie (Aufgabe 22) ---------- */

.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; }
.view-title { font-size: 1.35rem; margin: 4px 0 12px; }
.lib-empty { text-align: center; padding: 28px 8px; }

/* „Weitermalen“: waagerecht wischbare Reihe */
.lib-continue { margin: 0 0 14px; }
.lib-continue h2 { font-size: 1.05rem; margin: 2px 0 8px; }
.tile-row { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 2px 8px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
.tile-row .tile { flex: 0 0 136px; scroll-snap-align: start; }

/* Themen-Reiter: Pillen in einer Zeile, waagerecht wischbar (rechts weich ausgeblendet als Hinweis, dass es weitergeht).
   scroll-padding hält den angesteuerten Reiter (scrollIntoView) aus dem ausgeblendeten Randstreifen heraus. */
.theme-tabs { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 10px; margin: 0 -2px; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scroll-padding-inline: 12%;
  }
/* Ausblendung nur, wo es weitergeht (Klassen setzt library.js nach Scrollstand): rechts, links oder beidseitig */
.theme-tabs.has-more { -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent); }
.theme-tabs.has-less { -webkit-mask-image: linear-gradient(to left, #000 88%, transparent); mask-image: linear-gradient(to left, #000 88%, transparent); }
.theme-tabs.has-more.has-less { -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); }
.theme-tabs::-webkit-scrollbar { display: none; }
.theme-tabs button { flex: none; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); color: var(--ink); font-weight: 600; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.theme-tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
[data-theme="dark"] .theme-tabs button.active { color: #12141c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-tabs button.active { color: #12141c; } }

.lib-controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chips button { min-height: 44px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 22px; background: transparent; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.filter-chips button.active { background: var(--brand-light); border-color: var(--brand-light); color: var(--brand-dark); }

.gen-box { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 14px; }
.gen-box .hint { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--brand-light); border-top-color: var(--brand); animation: c9-spin 0.9s linear infinite; }
@keyframes c9-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Kacheln: groß, ruhig; das Bild bekommt den meisten Platz */
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } }
.tile { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 2px; margin: 0; padding: 8px 8px 10px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); -webkit-tap-highlight-color: transparent; min-width: 0; }
button.tile:active { transform: scale(0.985); }
.tile-art { display: block; aspect-ratio: 1; border-radius: 12px; background: var(--bg); overflow: hidden; margin-bottom: 6px; }
.tile.glow .tile-art { background: #0d0f1a; }
.tile-art img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 0.25s; }
.tile-art img.ready { opacity: 1; }
.tile-art img.instant { transition: none; }
/* Vorschaubild gescheitert: dezenter Platzhalter, neuer Versuch beim nächsten Sichtbarwerden bzw. bei „online“ */
.tile-art.failed { display: grid; place-items: center; }
.tile-art.failed img { display: none; }
.tile-art.failed::after { content: "🖼️"; font-size: 2rem; opacity: 0.3; filter: grayscale(1); }
.tile.fresh .tile-art img { filter: saturate(0.5); }
.tile-title { font-weight: 700; font-size: 0.95rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mine { color: var(--brand-dark); font-weight: 600; }
.tile-pill { position: absolute; top: 14px; right: 14px; padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; background: rgba(255, 255, 255, 0.92); color: #3b4a7a; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.tile-pill.done { color: #15803d; }
.tile-progress { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 4px 0 2px; }
.tile-progress span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.tile.small { padding: 6px 6px 8px; }
.tile.small .tile-title { font-size: 0.85rem; }

/* Galerie */
.member-switch { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -2px; scrollbar-width: none; }
.member-switch::-webkit-scrollbar { display: none; }
.member-chip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 14px 4px 4px; border: 1px solid var(--line); border-radius: 24px; background: var(--card); color: var(--ink); text-decoration: none; font-weight: 600; }
.member-chip.active { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }
.gallery-tile figcaption { display: flex; flex-direction: column; min-width: 0; }
.gallery-tile .again { margin-top: 8px; width: 100%; }

/* ---------- Badges ---------- */

/* nur Badge-Seite — .badge-list im Abschluss-Dialog (Malansicht) ist eine eigene Liste */
.badges .badge-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.badge-card { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.badge-card:not(.earned) .medal { filter: grayscale(0.7); opacity: 0.75; }
.badge-main { flex: 1; min-width: 0; }
.badge-main h3 { margin: 2px 0; font-size: 1rem; }
.badge-main p { margin: 0; font-size: 0.9rem; }
.badge-meta { margin-top: 4px !important; color: var(--muted); font-size: 0.8rem !important; }
.badge-group { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 16px 0 0; }
.badge-new { display: inline-block; padding: 0 7px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 0.72rem; vertical-align: middle; }
.tier-tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-progress { display: block; height: 6px; margin-top: 8px; border-radius: 3px; background: var(--line); overflow: hidden; }
.badge-progress span { display: block; height: 100%; background: var(--brand); }
.medal { --tier: #c98a52; flex: none; display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; font-size: 1.6rem; border: 4px solid var(--tier); background: color-mix(in srgb, var(--tier) 20%, var(--card)); }
.silver .medal, .medal.silver { --tier: #aab3bf; }
.gold .medal, .medal.gold { --tier: #e8b830; }
.secret-row { display: flex; flex-wrap: wrap; gap: 10px; }
.medal.secret { width: 44px; height: 44px; font-size: 1.2rem; opacity: 0.6; }
.streak-nums { display: flex; gap: 24px; margin: 6px 0; }
.streak-nums > div { display: flex; flex-direction: column; }
.streak-big { font-size: 2.2rem; font-weight: 800; line-height: 1.1; color: var(--brand-dark); }
.streak-big.muted-num { color: var(--muted); }

/* ---------- Bildnachweise (eigene Seite) ---------- */

.credits-page { padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 24px); }
.credits { max-width: 640px; margin: 0 auto; }
.credits h1 { margin: 8px 0 4px; }
.credit-meta { font-size: 0.9rem; }
.credit-list { list-style: none; margin: 8px 0; padding: 0; }
.credit-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.credit-list li:last-child { border-bottom: 0; }
.credit-files summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; min-height: 32px; }
.credit-files ul { columns: 2; font-size: 0.85rem; padding-left: 18px; }
.login-foot { margin: 14px 0 0; }
