/* Hörbox-Zentrale – „Spieleschachtel“: Spielkarten, Spielfiguren, Kartonfarben nach Rolle.
   Blau = Rahmen und Hauptaktion, Grün = läuft/auf der Box, Gelb = neu/wartet, Rot = Fehler/Löschen. */

@font-face {
  font-family: "Rubik";
  src: url("/static/fonts/rubik-latin-wght.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --table: #e8ecf3;
  --card: #ffffff;
  --card-2: #f3f5f9;
  --ink: #17213a;
  --ink-2: #4f5a74;
  --rule: #cdd5e2;
  --rule-strong: #17213a;

  --blue: #2456a6;
  --blue-deep: #1a3f7d;
  --blue-soft: #dfe8f8;
  --on-blue: #ffffff;
  --link: #2456a6;
  --green: #2f8f5b;
  --green-ink: #1d6a41;
  --green-soft: #ddf1e5;
  --yellow: #f4c430;
  --yellow-ink: #5c4500;
  --yellow-soft: #fff1c2;
  --red: #d63a2f;
  --red-ink: #b02a20;
  --red-soft: #fbe3e0;

  --radius: 16px;
  --radius-card: 14px;
  --radius-ctl: 12px;
  --lift: 0 1px 0 rgba(23, 33, 58, .06), 0 6px 14px -8px rgba(23, 33, 58, .28);
  --lift-hover: 0 1px 0 rgba(23, 33, 58, .06), 0 12px 22px -10px rgba(23, 33, 58, .35);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --tabbar-h: 64px;
  color-scheme: light;
}

/* Spieltisch bei Nacht */
@media (prefers-color-scheme: dark) {
  :root {
    --table: #0e1524;
    --card: #172137;
    --card-2: #1d2942;
    --ink: #eef2fa;
    --ink-2: #a6b1c8;
    --rule: #2c3a59;
    --rule-strong: #8fa0c4;

    --blue: #3a6cd0;
    --blue-deep: #12204a;
    --blue-soft: #1f2f55;
    --link: #8fb2f5;
    --green: #4cbf80;
    --green-ink: #7dd9a5;
    --green-soft: #173a2a;
    --yellow: #f4c430;
    --yellow-ink: #ffe08a;
    --yellow-soft: #3a3115;
    --red: #f0675c;
    --red-ink: #ff958c;
    --red-soft: #3d1f1f;
    --lift: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 18px -10px rgba(0, 0, 0, .7);
    --lift-hover: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 26px -12px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--table);
  color: var(--ink);
  font: 400 16px/1.5 "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--yellow); color: #17213a; }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1.5px; }
code { font: .88em ui-monospace, "SF Mono", Menlo, monospace; }
h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 700; margin: 0 0 .5rem; letter-spacing: -.015em; text-wrap: balance; }
h2 { font-size: 1.2rem; line-height: 1.25; font-weight: 700; margin: 0 0 .75rem; letter-spacing: -.005em; text-wrap: balance; }
h3 { font-size: 1rem; font-weight: 700; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.lead { font-size: 1.02rem; color: var(--ink-2); margin: 0 0 1.25rem; max-width: 62ch; }
.hint { color: var(--ink-2); font-size: .92rem; margin: -.25rem 0 .9rem; max-width: 62ch; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.text-accent { color: var(--yellow-ink); font-weight: 600; }
.text-err { color: var(--red-ink); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Symbole: 24er-Raster, 2er-Strich */
.i {
  width: 20px; height: 20px; flex: none; vertical-align: -4px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.i .fill, .i use { }
svg .fill { fill: currentColor; stroke: none; }

/* ---------- Rahmen: Kopfleiste und Tab-Leiste ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, calc((100vw - 1120px) / 2)) 10px;
  background: var(--blue); color: var(--on-blue);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: dark) { .topbar { background: var(--blue-deep); } }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-mark { width: 32px; height: 32px; padding: 4px; border-radius: 10px; background: var(--yellow); fill: var(--blue); flex: none; }
@media (prefers-color-scheme: dark) { .brand-mark { fill: var(--blue-deep); } }
.topnav { display: flex; gap: 2px; }
.topnav a {
  color: rgba(255, 255, 255, .86); text-decoration: none; font-weight: 600; padding: 8px 14px;
  border-radius: 10px; display: inline-flex; align-items: center; gap: 6px; transition: background .2s var(--ease);
}
.topnav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topnav a[aria-current="page"] { background: var(--card); color: var(--ink); }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.usermenu form { margin: 0; }
.usermenu-name { display: inline-flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; font-weight: 600; padding: 8px 10px; border-radius: 10px; }
.usermenu-name:hover, .usermenu-name[aria-current="page"] { background: rgba(255, 255, 255, .14); }
.topbar-button {
  font: inherit; font-weight: 600; color: #fff; background: transparent; cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, .45); border-radius: 10px; padding: 6px 12px;
}
.topbar-button:hover { background: rgba(255, 255, 255, .12); }

.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--yellow); color: #3b2c00; font-size: .78rem; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1;
}

.tabbar { display: none; }

.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 72px; }

@media (max-width: 899px) {
  .topnav, .usermenu { display: none; }
  .topbar { justify-content: center; padding-bottom: 8px; }
  .brand { font-size: 1.1rem; }
  .brand-mark { width: 28px; height: 28px; padding: 3px; border-radius: 9px; }
  .page { padding: 18px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--rule);
    box-shadow: 0 -8px 20px -14px rgba(0, 0, 0, .35);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border-radius: 12px; color: var(--ink-2); text-decoration: none;
    font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  }
  .tabbar .i { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--blue); }
  @media (prefers-color-scheme: dark) { .tabbar a[aria-current="page"] { color: var(--link); } }
  .tabbar a[aria-current="page"]::before {
    content: ""; position: absolute; top: 4px; width: 44px; height: 30px; border-radius: 10px;
    background: var(--blue-soft); z-index: -1;
  }
  .tabbar a { isolation: isolate; }
  .tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 20px; height: 20px; font-size: .7rem; }
  .tabbar .tab-new { color: var(--link); }
  .tab-new-mark {
    display: grid; place-items: center; width: 48px; height: 48px; margin-top: -22px; border-radius: 16px;
    background: var(--blue); color: #fff; border: 3px solid var(--card);
    box-shadow: 0 2px 4px rgba(0, 0, 0, .15), 0 8px 16px -6px rgba(0, 0, 0, .35);
  }
  .tabbar .tab-new-mark .i { width: 26px; height: 26px; stroke-width: 2.4; }
}

/* ---------- Abschnitte ---------- */

.block { margin-bottom: 36px; }
section { margin-bottom: 28px; }
.block-head, .section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.block-head h2, .section-head h1, .section-head h2 { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.link-more { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; text-decoration: none; padding: 8px 0 8px 8px; min-height: 44px; }
.link-more .i { width: 18px; height: 18px; }
.link-more:hover { text-decoration: underline; }
.crumbs { margin: 0 0 6px; }
.crumbs a { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; text-decoration: none; min-height: 40px; }
.crumbs a:hover { text-decoration: underline; }

.panel {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.panel > h2:first-child, .panel > .section-head:first-child { margin-top: 0; }
.panel-card { border: 2px solid var(--rule-strong); box-shadow: var(--lift); }
.panel-accent { border: 2px solid var(--yellow); background: linear-gradient(var(--yellow-soft), var(--card) 120px); }
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 32px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s var(--ease); margin: 0 4px;
}
details.panel[open] > summary::before { transform: rotate(45deg); }
details.panel[open] > summary { margin-bottom: 14px; }
details.panel > summary h2 { margin: 0; }
details.panel > summary .muted { margin-left: auto; text-align: right; }
.panel h3.sub { margin-top: 24px; }
.more-settings { margin: 4px 0 18px; border-top: 1px solid var(--rule); padding-top: 12px; }
.more-settings > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--link); list-style: none; }
.more-settings > summary::-webkit-details-marker { display: none; }
.more-settings > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -4px; transition: transform .2s var(--ease); }
.more-settings[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.more-settings[open] > summary { margin-bottom: 12px; }

.empty {
  padding: 28px 20px; text-align: center; color: var(--ink-2);
  border: 2px dashed var(--rule); border-radius: var(--radius); background: color-mix(in srgb, var(--card) 50%, transparent);
}
.empty p { margin: 0 auto 14px; max-width: 46ch; }
.empty p:last-child { margin-bottom: 0; }
.empty strong { color: var(--ink); }

.flash {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-ctl);
  margin: 0 0 18px; font-weight: 600; line-height: 1.4;
}
.flash .i { margin-top: 1px; }
.flash-ok { background: var(--green-soft); color: var(--green-ink); }
.flash-err { background: var(--red-soft); color: var(--red-ink); }

/* Marken und Chips */
.chip, .pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 8px;
  font-size: .8rem; font-weight: 600; line-height: 1.35; white-space: nowrap;
  background: var(--card-2); color: var(--ink-2); border: 1px solid var(--rule);
}
.chip .i, .pill .i { width: 14px; height: 14px; vertical-align: -2px; stroke-width: 2.4; }
.chip-ok, .pill-ok { background: var(--green-soft); color: var(--green-ink); border-color: transparent; }
.chip-wait, .pill-wait { background: var(--yellow-soft); color: var(--yellow-ink); border-color: transparent; }
.chip-err, .pill-err { background: var(--red-soft); color: var(--red-ink); border-color: transparent; }
.chip-bt { background: var(--blue-soft); color: var(--link); border-color: transparent; }
.pill-accent { background: var(--yellow); color: #3b2c00; border-color: transparent; }
@media (prefers-color-scheme: dark) { .chip-bt { color: var(--link); } }

/* Eckzeichen einer Spielkarte (H1) */
.tag {
  display: inline-grid; place-items: center; min-width: 30px; padding: 2px 7px; margin-right: 4px;
  border-radius: 7px; background: var(--ink); color: var(--card); font-weight: 700; font-size: .8rem;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.tag-big { font-size: .95rem; min-width: 38px; padding: 4px 9px; }
.tag-none { white-space: nowrap; background: transparent; color: var(--ink-2); border: 1.5px dashed var(--rule); font-weight: 600; font-size: .75rem; }
/* Familienfarben: jede Familie behält ihre Farbe auf Plakette und Eckzeichen */
.fam-0 { background: #0f6470; color: #fff; }
.fam-1 { background: #7b3f8f; color: #fff; }
.fam-2 { background: #8a5a12; color: #fff; }
.fam-3 { background: #a3306e; color: #fff; }
.fam-4 { background: #3f4a8a; color: #fff; }
.fam-5 { background: #5b6b1f; color: #fff; }

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

label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
label > span, .field-label, fieldset legend { font-size: .875rem; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--rule); border-radius: var(--radius-ctl); padding: 10px 12px; min-width: 0; min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f5a74' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
input::placeholder { color: color-mix(in srgb, var(--ink-2) 80%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--blue) 45%, var(--rule)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
@media (prefers-color-scheme: dark) { input:focus, select:focus, textarea:focus { border-color: var(--link); } }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 8px;
}
input[type="range"] { padding: 0; min-height: 32px; accent-color: var(--blue); border: 0; background: none; box-shadow: none; }
input[type="checkbox"] { accent-color: var(--blue); width: 22px; height: 22px; min-height: 0; margin: 0; }
input[type="file"] { min-height: 0; }
.input-number { width: 84px; }
.form-inline { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.form-inline label { margin-bottom: 0; }
.form-compact { margin: 0; }
.grow { flex: 1 1 220px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.two > * { min-width: 0; }
.two input, .two select { width: 100%; }
fieldset { min-width: 0; }
fieldset.checks { border: 0; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 8px; }
fieldset.checks legend { margin-bottom: 8px; padding: 0; }
.checks-column { flex-direction: column; }
.check {
  flex-direction: row; align-items: center; gap: 10px; margin: 0; font-weight: 500; min-height: 44px;
  padding: 8px 12px; border: 1.5px solid var(--rule); border-radius: var(--radius-ctl); background: var(--card); cursor: pointer;
}
.check:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.checks-column .check { width: 100%; }
.check-long { align-items: flex-start; margin-bottom: 14px; }
.check-long input { margin-top: 3px; flex: none; }
.check-long strong { font-weight: 700; }
.check.small { padding: 4px 8px; min-height: 36px; border: 0; background: none; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
output { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }

/* Tasten */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2;
  min-height: 46px; padding: 10px 18px; border-radius: var(--radius-ctl); border: 1.5px solid transparent;
  background: var(--blue); color: var(--on-blue); white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .14), 0 3px 8px -3px rgba(0, 0, 0, .22);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background .15s;
}
.button:hover { background: color-mix(in srgb, var(--blue) 86%, #000); }
.button:active { transform: translateY(1px); box-shadow: none; }
.button:disabled, .button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.button .i { width: 18px; height: 18px; }
.button-ghost { background: var(--card); color: var(--ink); border-color: var(--rule); box-shadow: none; }
.button-ghost:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--ink) 30%, var(--rule)); }
.button-small { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
.button-danger { background: var(--card); color: var(--red-ink); border-color: color-mix(in srgb, var(--red) 45%, var(--rule)); box-shadow: none; }
.button-danger:hover { background: var(--red-soft); }
.button-go { background: var(--green-ink); color: #fff; }
.button-go:hover { background: color-mix(in srgb, var(--green-ink) 86%, #000); }
@media (prefers-color-scheme: dark) { .button-go { background: var(--green); color: #0b2417; } }
.button-wide { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.icon {
  width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--card);
  color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.icon .i { width: 18px; height: 18px; }
.icon:hover { background: var(--card-2); }
.icon:disabled { opacity: .3; cursor: default; }
.icon-danger:hover { color: var(--red-ink); border-color: var(--red); background: var(--red-soft); }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.link-button {
  background: none; border: 0; padding: 0 0 0 6px; color: var(--link); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: .18em;
}
.danger-zone { margin-top: 36px; padding-top: 20px; border-top: 1px dashed var(--rule); }
.sync-note { color: var(--yellow-ink); font-weight: 600; }

/* ---------- Spielfigur (Box) ---------- */

.figures { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.figure {
  --tone: var(--ink-2); --tone-soft: var(--card-2);
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: start;
  padding: 18px; border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none;
  border: 2px solid var(--rule-strong); box-shadow: var(--lift);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
a.figure:hover { transform: translateY(-2px); box-shadow: var(--lift-hover); }
a.figure:active { transform: translateY(0); }
.figure-ok { --tone: var(--green); --tone-soft: var(--green-soft); }
.figure-bt { --tone: var(--blue); --tone-soft: var(--blue-soft); }
.figure-wait { --tone: var(--yellow); --tone-soft: var(--yellow-soft); }
.figure-err { --tone: var(--red); --tone-soft: var(--red-soft); }
.figure-pawn {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--tone-soft); color: var(--tone);
}
.figure-pawn .i { width: 34px; height: 34px; fill: currentColor; stroke: currentColor; stroke-width: 1.2; }
@media (prefers-color-scheme: dark) { .figure-bt .figure-pawn { color: var(--link); } }
.figure-body { display: grid; gap: 4px; min-width: 0; }
.figure-name { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.figure-state { font-weight: 600; color: var(--ink); }
.figure-meta { display: grid; gap: 4px; margin-top: 6px; color: var(--ink-2); font-size: .9rem; }
.figure-meta > span { display: block; }
.figure-meta .i { margin-right: 6px; }
.figure-meta .i { width: 16px; height: 16px; vertical-align: -3px; }
.figure-meta strong { color: var(--ink); font-weight: 600; white-space: nowrap; }
.figure-meta .figure-online, .figure-meta .figure-online strong { color: var(--green-ink); }
.figure-go { align-self: center; color: var(--ink-2); }
.figure-go .i { width: 22px; height: 22px; }
.figure-wait .figure-pawn { animation: hop 1.6s var(--ease) infinite; }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* Wartungsweg aus Spielfeldern */
.trail { margin-top: 10px; display: grid; gap: 8px; }
.trail-fields { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.trail-fields li { height: 14px; border-radius: 4px; background: var(--card-2); border: 1.5px solid var(--rule); }
.trail-fields li.done { background: var(--green); border-color: var(--green); }
.trail-fields li.here { background: var(--yellow); border-color: var(--yellow); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .45; } }
.trail-text { margin: 0; display: grid; gap: 2px; font-size: .9rem; color: var(--ink-2); }
.trail-text strong { color: var(--ink); }
.trail-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-progress { display: grid; gap: 6px; }

/* ---------- Spielkarten (Hörspiele) ---------- */

.cover {
  display: grid; place-items: center; width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 9px; background: var(--blue-soft); color: var(--blue);
}
.cover-empty { font-size: 2.4rem; font-weight: 800; }
@media (prefers-color-scheme: dark) { .cover-empty { color: var(--link); } }
.cover-large { width: 200px; border-radius: 12px; }
.cover-tiny { width: 44px; border-radius: 8px; font-size: 1.05rem; }

.pcard {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 7px 7px 10px;
  background: var(--card); border: 2px solid var(--rule-strong); border-radius: var(--radius-card);
  color: var(--ink); text-decoration: none; box-shadow: var(--lift); height: 100%;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
a.pcard:hover { transform: translateY(-3px) rotate(-.6deg); box-shadow: var(--lift-hover); }
.pcard .cover { margin-bottom: 5px; }
.pcard-index {
  position: absolute; top: 2px; left: 2px; min-width: 34px; padding: 3px 7px; text-align: center;
  background: var(--ink); color: var(--card); font-weight: 700; font-size: .85rem;
  border-radius: 10px 4px 10px 4px; border: 2px solid var(--card);
}
.pcard-title { font-weight: 600; line-height: 1.25; padding: 0 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-meta { font-size: .8rem; color: var(--ink-2); padding: 0 3px; }
.pcard-flags { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 3px 0; }
.pcard-add { border-style: dashed; border-color: var(--rule); box-shadow: none; align-items: center; justify-content: center; text-align: center; min-height: 180px; color: var(--link); }
.pcard-add-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--blue-soft); margin-bottom: 6px; }
.pcard-add-mark .i { width: 26px; height: 26px; }

/* Kartenfächer: auf dem Handy waagerecht wischen, sonst Raster in festem Maßstab */
.hand { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 640px) {
  .hand {
    grid-auto-flow: column; grid-auto-columns: 42%; grid-template-columns: none; overflow-x: auto;
    scroll-snap-type: x mandatory; padding: 4px 16px 14px; margin: 0 -16px; scrollbar-width: none;
  }
  .hand::-webkit-scrollbar { display: none; }
  .hand > li { scroll-snap-align: start; scroll-margin-left: 16px; }
}
.grid { display: grid; gap: 14px; }
.grid-albums { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 400px) { .grid-albums { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* Verdeckte neue Karten */
.deck { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 160px)); gap: 12px; }
.card-back {
  position: relative; display: grid; align-content: end; gap: 2px; aspect-ratio: 5 / 6; padding: 12px;
  border-radius: var(--radius-card); border: 2px solid var(--rule-strong); overflow: hidden;
  background: var(--yellow); color: #3b2c00; text-decoration: none; box-shadow: var(--lift);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.card-back:hover { transform: translateY(-3px) rotate(1deg); box-shadow: var(--lift-hover); }
.card-back-face {
  position: absolute; inset: 8px; border-radius: 9px; border: 2px solid rgba(59, 44, 0, .35);
  background:
    radial-gradient(circle at 50% 50%, rgba(59, 44, 0, .22) 2.2px, transparent 2.6px) 0 0 / 16px 16px;
  -webkit-mask: linear-gradient(#000 45%, transparent 68%); mask: linear-gradient(#000 45%, transparent 68%);
}
.card-back > span:not(.card-back-face) { position: relative; }
.card-back-label {
  justify-self: start; background: #3b2c00; color: var(--yellow); font-weight: 700; font-size: .8rem;
  padding: 2px 8px; border-radius: 6px; margin-bottom: auto; align-self: start;
}
.card-back { grid-template-rows: 1fr auto auto; }
.card-back-main { font-weight: 700; font-size: 1rem; line-height: 1.2; }
.card-back-where { font-size: .78rem; font-weight: 500; }

/* Neues Hörspiel: aufklappbar */
.panel-new > summary::before { display: none; }
.panel-new > summary { gap: 12px; min-height: 44px; }
.panel-new > summary h2 { color: var(--link); }
.small-mark { width: 36px; height: 36px; margin: 0; }
.small-mark .i { width: 20px; height: 20px; }
.panel-new[open] > summary .small-mark { background: var(--ink-2); }

/* ---------- Seite eines Hörspiels ---------- */

.album-head { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 24px; }
.album-cover { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.album-cover .pcard { padding: 7px; }
.album-cover .pcard .cover { margin: 0; }
.cover-form { margin: 0; }
.album-meta { margin: 0; }
.title-input { font-size: 1.35rem; font-weight: 700; }
@media (max-width: 640px) {
  .album-head { grid-template-columns: 112px minmax(0, 1fr); gap: 14px; }
  .album-head .album-meta { grid-column: 1 / -1; }
  .cover-large { width: 100%; }
  .album-cover .button { font-size: .85rem; min-height: 38px; padding: 6px 8px; }
}
.album-summary { align-self: center; }
.album-summary h1 { font-size: 1.5rem; margin: 0 0 4px; }
@media (min-width: 641px) { .album-summary { display: none; } }

.dropzone {
  position: relative; display: grid; place-items: center; gap: 6px; text-align: center;
  border: 2px dashed color-mix(in srgb, var(--blue) 45%, var(--rule)); border-radius: var(--radius);
  padding: 26px 18px; background: var(--blue-soft); margin-bottom: 16px;
  transition: border-color .15s, background .15s, transform .2s var(--ease);
}
.dropzone.is-over { border-color: var(--blue); transform: scale(1.01); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone label { margin: 0; cursor: pointer; align-items: center; gap: 4px; }
.dropzone label strong { font-size: 1.05rem; color: var(--ink); }
.dropzone-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--blue); color: #fff; margin-bottom: 4px; }
.dropzone-mark .i { width: 26px; height: 26px; }
.upload-progress { display: grid; gap: 8px; width: min(100%, 420px); margin-top: 8px; }
progress { appearance: none; width: 100%; height: 12px; border: 0; border-radius: 6px; background: var(--card); overflow: hidden; accent-color: var(--blue); }
progress::-webkit-progress-bar { background: var(--card); border-radius: 6px; }
progress::-webkit-progress-value { background: var(--blue); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 6px; }

.tracks { list-style: none; margin: 0; padding: 0; counter-reset: track; }
.track {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--rule);
}
.track:first-child { border-top: 0; }
.track-pos {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--card-2); color: var(--ink-2); font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums;
}
.track-title { display: flex; flex-direction: column; gap: 0; margin: 0; min-width: 0; }
.track-title input { border-color: transparent; background: transparent; padding: 4px 8px; min-height: 38px; font-weight: 600; }
.track-title input:hover, .track-title input:focus { border-color: var(--rule); background: var(--card); }
.track-title .small { padding-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-info { color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.track-actions { display: flex; gap: 4px; }
.track-actions form { margin: 0; }
.track-processing .track-info { color: var(--yellow-ink); font-weight: 600; }
.track-error .track-pos { background: var(--red-soft); color: var(--red-ink); }
.spinner {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .track { grid-template-columns: 34px minmax(0, 1fr); row-gap: 4px; }
  .track-info, .track-actions { grid-column: 2; padding-left: 8px; }
  .track-actions .icon { width: 44px; height: 40px; }
}

/* ---------- Listen und Tabellen ---------- */

.plain { list-style: none; margin: 0; padding: 0; }
.plain > li { padding: 12px 0; border-top: 1px solid var(--rule); position: relative; }
.plain > li:first-child { border-top: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row form { margin: 0 0 0 auto; }
.inline-right { position: absolute; right: 0; top: 12px; }
.plain > li .form-inline { padding-right: 110px; }
.log li { font-size: .88rem; word-break: break-word; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--rule); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--ink-2); font-weight: 600; border-top: 0; background: var(--card-2); }
.table tbody tr:hover td { background: color-mix(in srgb, var(--card-2) 60%, transparent); }
.cell-cover { width: 60px; }
.cell-actions { width: 52px; }
.table form { margin: 0; }
.table-flat { margin-bottom: 16px; }
.row-group td { background: var(--card-2); font-size: .8rem; font-weight: 700; color: var(--ink-2); padding-top: 8px; padding-bottom: 8px; }
.row-done td { opacity: .6; }
.row-done td:last-child, .row-done td:nth-child(3) { opacity: 1; }
.row-highlight td { background: var(--yellow-soft); }
.row-pending td { color: var(--ink-2); }
.row-pending .cell-cover img, .row-pending .cell-cover span { opacity: .5; filter: grayscale(1); }

.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.split > * { min-width: 0; }
.stack > * { margin-bottom: 20px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0 0 12px; }
.facts dt { color: var(--ink-2); font-size: .9rem; }
.facts dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.code {
  background: var(--card-2); border: 1px solid var(--rule); border-radius: var(--radius-ctl); padding: 14px;
  overflow-x: auto; font: .85rem/1.5 ui-monospace, "SF Mono", Menlo, monospace;
}

@media (max-width: 760px) {
  .split, .two { grid-template-columns: minmax(0, 1fr); }
  .plain > li .form-inline { padding-right: 0; }
  .inline-right { position: static; margin-top: 8px; }
  .hide-mobile { display: none; }
  .table { display: block; overflow-x: auto; }
  .panel { padding: 16px; }
  h1 { font-size: 1.55rem; }
}

/* ---------- Ordner und Familien (Seitenleiste) ---------- */

.split-sidebar { grid-template-columns: 250px minmax(0, 1fr); }
.folder-nav { display: flex; flex-direction: column; gap: 2px; }
.folder-nav h2 { margin-bottom: 8px; font-size: 1rem; }
.folder-nav a {
  display: flex; justify-content: space-between; gap: 8px; align-items: center; min-height: 44px;
  padding: 8px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; color: var(--ink);
}
.folder-nav a:hover { background: var(--card-2); }
.folder-nav a[aria-current="page"] { background: var(--blue-soft); }
.folder-new { margin-top: 10px; flex-wrap: nowrap; }
.folder-new input { flex: 1; width: 100%; }
.folder-heading { margin: 26px 0 12px; font-size: 1rem; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.folder-heading .i { width: 18px; height: 18px; }
.folder-heading:first-of-type { margin-top: 4px; }

/* Ordner als Wischleiste auf dem Handy */
.filter-strip { display: none; }
@media (max-width: 760px) {
  .split-sidebar { grid-template-columns: minmax(0, 1fr); }
  .split-sidebar > aside { display: none; }
  .filter-strip {
    display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px 6px; scrollbar-width: none;
  }
  .filter-strip::-webkit-scrollbar { display: none; }
  .filter-strip a {
    flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
    border-radius: 20px; border: 1.5px solid var(--rule); background: var(--card); color: var(--ink);
    text-decoration: none; font-weight: 600; font-size: .9rem; white-space: nowrap;
  }
  .filter-strip a[aria-current="page"] { background: var(--ink); color: var(--card); border-color: var(--ink); }
  .filter-strip .count { font-variant-numeric: tabular-nums; opacity: .7; font-weight: 500; }
}

/* ---------- Karten zuordnen ---------- */

.newcards { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.newcard { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 18px; align-items: start; scroll-margin-top: 90px; }
.newcard:target .flip-front { outline: 3px solid var(--yellow); outline-offset: 3px; }
.flip { perspective: 900px; aspect-ratio: 5 / 6; }
.flip-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s var(--ease); }
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-front.card-back:hover { transform: none; }
.flip-back {
  transform: rotateY(180deg); display: flex; flex-direction: column; gap: 4px; padding: 7px;
  background: var(--card); border: 2px solid var(--rule-strong); border-radius: var(--radius-card); box-shadow: var(--lift);
}
.flip-back .cover { flex: 1; aspect-ratio: auto; min-height: 0; }
.flip-back-title { font-weight: 600; font-size: .8rem; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.flip .card-back { padding: 10px; }
.flip .card-back-main { font-size: .85rem; }
.flip .card-back-where { font-size: .72rem; }
.card-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; margin: 0; }
.card-form label { margin-bottom: 12px; }
.card-form .span-2, .card-form .grow { grid-column: 1 / -1; }
.card-form .actions { grid-column: 1 / -1; }
.card-form-id { grid-column: 1 / -1; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 10px; }
.label-number input { width: 100%; }
.discard { margin: 0; }
@media (max-width: 640px) {
  .newcard { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .newcard .flip { width: 112px; }
  .newcard-head { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; align-items: center; }
  .newcard-head-text strong { overflow-wrap: anywhere; }
  .card-form-id { display: none; }
}
@media (min-width: 641px) { .newcard-head { display: contents; } .newcard-head-text { display: none; } }

.cardlist { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); }
.cardrow {
  display: grid; grid-template-columns: 52px 48px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 14px; border-top: 1px solid var(--rule);
}
.cardrow:first-child { border-top: 0; }
.cardrow-pending .cover, .cardrow-pending .tag { opacity: .55; }
.cardrow-pending .cover { filter: grayscale(1); }
.cardrow-main { display: grid; gap: 8px; min-width: 0; }
.cardrow-selects { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 8px; }
.cardrow-selects select { width: 100%; min-height: 42px; padding-top: 7px; padding-bottom: 7px; }
.cardrow-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cardrow .uid { color: var(--ink-2); font-size: .78rem; }
@media (max-width: 640px) {
  .cardrow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "tag del" "main main"; row-gap: 10px; }
  .cardrow > .cell-cover-slot { display: none; }
  .cardrow-tag { grid-area: tag; align-self: center; }
  .cardrow-del { grid-area: del; }
  .cardrow-main { grid-area: main; }
  .cardrow-selects { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Box-Seite: Fernbedienung ---------- */

.remote { display: grid; gap: 12px; margin-bottom: 10px; }
.remote .button, .remote-stop .button { min-height: 52px; }
.remote-stop { margin: 0; }
.remote-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: end; }
.remote-row label { margin: 0; }
.remote-note {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-ctl);
  background: var(--blue-soft); color: var(--ink); font-size: .92rem; margin: 0 0 14px;
}
.remote-note .i { color: var(--link); margin-top: 2px; }
@media (max-width: 640px) {
  .remote-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .remote-row label { grid-column: 1 / -1; }
}
.box-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.box-layout > * { min-width: 0; }
@media (max-width: 860px) { .box-layout { grid-template-columns: minmax(0, 1fr); } }
.box-hero { margin-bottom: 20px; }
.box-hero .figure { box-shadow: var(--lift); }
.onbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.onbox li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "cover title state" "cover meta state";
            column-gap: 12px; align-items: center; }
.onbox .cover { grid-area: cover; }
.onbox-title { grid-area: title; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.onbox-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.onbox-state { grid-area: state; }
.onbox-pending .cover { opacity: .55; filter: grayscale(1); }
@media (max-width: 480px) {
  .onbox li { grid-template-columns: 44px minmax(0, 1fr); grid-template-areas: "cover title" "cover meta" "cover state"; row-gap: 4px; }
}
.how {
  margin: 0; padding: 0; list-style: none; display: grid; gap: 10px;
}
.how li { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; font-size: .92rem; }
.how .i { width: 22px; height: 22px; color: var(--ink-2); margin-top: 1px; }
.how strong { color: var(--ink); }

/* ---------- Mehr ---------- */

.menu { list-style: none; margin: 0 0 20px; padding: 0; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.menu li + li { border-top: 1px solid var(--rule); }
.menu a, .menu button {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%;
  min-height: 60px; padding: 10px 16px; color: var(--ink); text-decoration: none; font: inherit; font-weight: 600;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--card-2); }
.menu small { display: block; font-weight: 400; color: var(--ink-2); font-size: .85rem; }
.menu-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--blue-soft); color: var(--link); }
.menu-mark-red { background: var(--red-soft); color: var(--red-ink); }
.menu .chev { color: var(--ink-2); }
.menu form { margin: 0; }

/* ---------- Druckdialog ---------- */

.print-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: start; }
.print-side { display: flex; flex-direction: column; gap: 10px; }
.sheet-picker {
  display: grid; gap: 3px; padding: 10px; background: #fff; border: 1px solid var(--rule);
  border-radius: 6px; aspect-ratio: 210 / 297; align-content: start; box-shadow: var(--lift);
}
.sheet-picker button {
  border: 1px dashed #c3cad8; background: #fff; border-radius: 3px; padding: 0; cursor: pointer;
  font: 600 10px/1 "Rubik", system-ui; color: #6d7790; min-height: 0;
}
.sheet-picker button.used { background: repeating-linear-gradient(45deg, #e6eaf1, #e6eaf1 3px, #fff 3px, #fff 6px); color: transparent; }
.sheet-picker button.fill { background: #fff1c2; border-style: solid; border-color: #f4c430; color: #5c4500; }
.sheet-picker button.first { background: #2456a6; color: #fff; border-color: #2456a6; }
@media (max-width: 760px) { .print-layout { grid-template-columns: minmax(0, 1fr); } .print-side { max-width: 260px; } }

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

.auth-page {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--blue);
}
@media (prefers-color-scheme: dark) { .auth-page { background: var(--blue-deep); } }
.auth-card { width: min(100%, 400px); border: 2px solid var(--rule-strong); box-shadow: 0 20px 40px -20px rgba(0, 0, 0, .5); }
.auth-page .auth-card .brand { color: var(--ink); margin-bottom: 18px; }
.auth-card input { width: 100%; }
.auth-card .button { width: 100%; }
.page .auth-card { border-width: 1px; box-shadow: none; }

/* ---------- Diverses aus Verwaltungsseiten ---------- */

.view-toggle { display: inline-flex; gap: 0; padding: 3px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--rule); }
.view-toggle .button { box-shadow: none; border: 0; background: transparent; color: var(--ink-2); min-height: 36px; }
.view-toggle [aria-pressed="true"], .view-toggle [aria-current="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.view-toggle a.button { text-decoration: none; }
.section-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.input-prefix { width: 76px; text-transform: uppercase; }
.family-switch { align-items: center; }
.family-switch p { margin: 0; }
.inline-form { display: inline; margin: 0; }
.two-narrow { grid-template-columns: minmax(0, 1fr) 64px; gap: 10px; }

/* USB-Einrichtung */
.usb-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.log-panel { position: sticky; top: 84px; }
.serial-log { height: 560px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: .8rem; margin: 0; }
.serial-log .hb { color: var(--link); }
.serial-log .out { color: var(--ink-2); }
.serial-log .err { color: var(--red-ink); }
.scanlist { max-height: 200px; overflow: auto; }
.scanlist li { padding: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
@media (max-width: 900px) { .usb-grid { grid-template-columns: minmax(0, 1fr); } .log-panel { position: static; } .serial-log { height: 320px; } }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 86px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  color: var(--link); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; padding: 8px;
}

/* Diagnose */
.diag-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.diag-status div { display: grid; gap: 2px; min-width: 0; }
.diag-status .label { color: var(--ink-2); font-size: .8rem; }
.diag-status strong { font-variant-numeric: tabular-nums; }
.ok-text { color: var(--green-ink); }
.err-text { color: var(--red-ink); }
.diag-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 20px; }
@media (max-width: 860px) { .diag-grid { grid-template-columns: minmax(0, 1fr); } }
.selftest-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.selftest-list { display: grid; gap: 8px; margin: 14px 0; max-height: 420px; overflow-y: auto; }
.selftest-list li { font-size: .92rem; line-height: 1.4; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.log-head h2 { margin: 0; }
.log-viewer .actions { align-items: center; margin-top: 12px; }
.logbox {
  list-style: none; margin: 12px 0 0; padding: 10px 12px; height: 60vh; min-height: 280px; overflow: auto;
  background: var(--card-2); border: 1px solid var(--rule); border-radius: var(--radius-ctl);
  font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums;
}
.logbox li { display: grid; grid-template-columns: 7.5ch 5.5ch minmax(0, 1fr); gap: 10px; white-space: pre-wrap; word-break: break-word; }
.logbox .ts, .logbox .lv { color: var(--ink-2); }
.logbox .ts { text-align: right; }
.logbox .lv-warn .lv, .logbox .lv-warn { color: var(--yellow-ink); }
.logbox .lv-error .lv, .logbox .lv-error { color: var(--red-ink); font-weight: 600; }
.logbox .lv-debug { opacity: .75; }
.logbox.only-warn li:not(.lv-warn):not(.lv-error) { display: none; }
.diag-col { display: grid; gap: 20px; min-width: 0; }
.diag-col .panel { margin: 0; }
.card-watch { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-top: 20px; }
@media (max-width: 640px) { .card-watch { grid-template-columns: auto minmax(0, 1fr); } .card-stats { grid-column: 1 / -1; } }
.card-lamp { width: 44px; height: 44px; border-radius: 50%; background: var(--rule); transition: background .2s, box-shadow .2s; }
.card-watch[data-state="present"] .card-lamp { background: var(--green); box-shadow: 0 0 0 6px var(--green-soft); }
.card-watch[data-state="present"] #d-card-title { color: var(--green-ink); }
.card-text { display: grid; gap: 2px; min-width: 0; }
.card-text strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; word-break: break-all; }
.card-stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.mode-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 0; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; min-height: 40px; }
.switch:disabled { opacity: .5; cursor: not-allowed; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--rule); position: relative; transition: background .15s; flex: none; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch[aria-checked="true"] .track { background: var(--green); }
.switch[aria-checked="true"] .knob { transform: translateX(18px); }
.input-watch { margin-top: 20px; }
.input-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.input-chips li { padding: 9px 13px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--card-2); font-weight: 600; transition: background .2s, color .2s, border-color .2s; }
.input-chips li.seen { border-color: var(--green); color: var(--green-ink); }
.input-chips li.seen::before { content: "✓ "; }
.input-chips li.flash { background: var(--green); color: #fff; border-color: var(--green); }

/* Browser-Flächen */
* { scrollbar-color: color-mix(in srgb, var(--ink-2) 45%, transparent) transparent; }
input, textarea { caret-color: var(--blue); }

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

/* Übernahme-Code (Sticker unter der Box) */
.claim-sticker { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin: 8px 0 16px; }
.claim-qr svg { width: 168px; height: 168px; display: block; background: #fff; border-radius: 8px; }
.claim-code { font-size: 1.6rem; font-weight: 800; letter-spacing: .06em; margin: 0 0 4px; }
@media print {
  .topbar, .tabbar, .crumbs, .claim > p, .claim .actions, h1 { display: none !important; }
  .claim { border: 0; background: none; padding: 0; }
}
