/* Layout: sticky top bar, filter strip, responsive card grid of book covers; sheets (dialogs) for detail and capture. */
:root {
  --bg: #f5f7f5;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --line: #d9e0db;
  --fg: #18231f;
  --muted: #5b6b64;
  --accent: #1f5e4e;          /* Wandtafel-Grün */
  --accent-fg: #ffffff;
  --accent-soft: #dcebe5;
  --phys: #8a5a12;            /* Bibliothek */
  --phys-soft: #f6ead3;
  --digi: #1d5a9b;            /* SharePoint */
  --digi-soft: #dde9f7;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(20,40,30,.06), 0 4px 14px rgba(20,40,30,.06);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111715; --surface: #18201d; --surface-2: #1f2925; --line: #2d3a35;
    --fg: #e6eeea; --muted: #9db0a8; --accent: #6cc3a8; --accent-fg: #0d1a15; --accent-soft: #1d3a31;
    --phys: #e6b467; --phys-soft: #3a2d17; --digi: #8dbcf0; --digi-soft: #1a2c42; --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111715; --surface: #18201d; --surface-2: #1f2925; --line: #2d3a35;
  --fg: #e6eeea; --muted: #9db0a8; --accent: #6cc3a8; --accent-fg: #0d1a15; --accent-soft: #1d3a31;
  --phys: #e6b467; --phys-soft: #3a2d17; --digi: #8dbcf0; --digi-soft: #1a2c42; --danger: #ff8a80;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 650; line-height: 1.15; text-wrap: balance; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 260px; }
.brand > div { min-width: 0; }
.brand h1 { font-size: 1.35rem; }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 6px; flex: none;
  background:
    linear-gradient(90deg, var(--accent) 0 22%, transparent 22% 30%, var(--phys) 30% 50%, transparent 50% 58%, var(--digi) 58% 78%, transparent 78% 84%, var(--accent) 84%);
  opacity: .9;
}
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.proto-banner {
  max-width: 1200px; margin: 12px auto 0; font-size: .92rem; color: var(--muted);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.proto-banner strong { color: var(--fg); }

.wrap {
  max-width: 1200px; margin: 0 auto; padding-block: 12px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; border: 1px solid transparent; padding: 9px 14px; cursor: pointer;
  font-weight: 600; font-size: .95rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--fg); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
.btn-sm { padding: 6px 10px; font-size: .88rem; }
.danger { color: var(--danger); }
.icon-btn { border: 0; background: transparent; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input, .cap input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* Filters */
.filters { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 8px 0 18px; }
.search input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-size: 1rem;
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg-btn {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.seg-btn.is-active, .seg-btn:has(input:checked) { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.seg-form input { accent-color: var(--accent); }
.selects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.selects select, .field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); min-width: 0;
}
@media (min-width: 860px) {
  .filters { grid-template-columns: minmax(0, 1.4fr) auto minmax(0, 1.6fr); align-items: center; }
}
@media (max-width: 520px) {
  .topbar-inner { flex-wrap: nowrap; }
  .brand { flex: 1 1 auto; }
  .brand h1 { font-size: 1.15rem; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-sub { font-size: .8rem; }
  .top-actions .btn { padding: 8px 10px; font-size: .88rem; }
  #btnAdd { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30; padding: 13px 18px; font-size: 1rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
  .selects { grid-template-columns: 1fr 1fr; }
  .selects select:last-child { grid-column: 1 / -1; }
}

/* Grid of items */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px 16px; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; } }
.item { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-width: 0; border-radius: var(--r); }
.item:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.cover {
  aspect-ratio: 3 / 4; width: 100%; max-width: 100%; border-radius: 6px; overflow: hidden; position: relative;
  background: var(--surface-2); box-shadow: var(--shadow); border: 1px solid var(--line);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-gen {
  position: absolute; inset: 0; padding: 12px 12px 12px 18px; display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
}
.cover-gen::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: rgba(0,0,0,.18); }
.cover-gen .cg-fach { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; opacity: .85; font-weight: 600; }
.cover-gen .cg-title { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.12; font-weight: 650; overflow-wrap: anywhere; }
.cover-gen .cg-verlag { font-size: .78rem; opacity: .85; }
.item-where { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 4px; }
.item-loc { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item-meta { display: grid; gap: 2px; min-width: 0; }
.item-title { font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-sub { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  line-height: 1.2; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.badge-phys { background: var(--phys-soft); color: var(--phys); }
.badge-digi { background: var(--digi-soft); color: var(--digi); }
.badge-digi::before { border-radius: 50%; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.admin-tools { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.admin-tools h2 { font-size: 1.1rem; margin-bottom: 10px; }
.admin-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Sheets */
dialog.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--fg); border-radius: 14px;
  width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog.sheet-sm { width: min(440px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10,20,15,.45); }
@media (max-width: 600px) {
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
  dialog.sheet-sm { height: auto; margin: auto auto 0; border-radius: 14px 14px 0 0; }
}
.sheet-body { padding: 18px max(18px, env(safe-area-inset-right, 0px)) 18px max(18px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h2 { font-size: 1.35rem; }
.sheet-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding-block: 12px; border-top: 1px solid var(--line); margin-top: 4px; }
.spacer { flex: 1; }
.series { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: 0; font-weight: 600; }

/* Capture */
.capture { background: var(--surface-2); border-radius: 12px; padding: 14px; display: grid; gap: 12px; }
.capture-label { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.capture-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 600px) { .capture-grid { grid-template-columns: 1fr; } }
.cap {
  position: relative; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 0;
}
.cap:hover { border-color: var(--accent); }
.cap strong { display: block; font-size: .95rem; }
.cap small { color: var(--muted); font-size: .82rem; }
.cap-ico { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); flex: none; position: relative; }
.cap-ico::after { content: ""; position: absolute; inset: 9px; background: var(--accent); -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ico-barcode { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1 2h1v12H1zM3 2h2v12H3zM6 2h1v12H6zM8 2h1v12H8zM10 2h2v12h-2zM13 2h1v12h-1zM15 2h1v12h-1z'/%3E%3C/svg%3E"); }
.ico-camera { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 2l-1 2H1v10h14V4h-3l-1-2zm3 4a3 3 0 110 6 3 3 0 010-6z'/%3E%3C/svg%3E"); }
.ico-pdf { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 1h7l4 4v10H3zm6 1v4h4zM5 9h6v1H5zm0 2h6v1H5z'/%3E%3C/svg%3E"); }

.scanner { display: grid; gap: 8px; }
#reader { width: 100%; max-width: 480px; border-radius: 10px; overflow: hidden; background: #000; }
#reader video { width: 100% !important; }
.scanner-row { display: flex; gap: 8px; flex-wrap: wrap; }
.scanner-row input { flex: 1; min-width: 140px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.status { font-size: .92rem; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.status.ok { border-color: var(--accent); }
.status.warn { border-color: var(--phys); }
.status .spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .status .spinner { animation: none; } }

.ocr { display: grid; gap: 8px; }
.ocr-help { margin: 0; font-size: .9rem; color: var(--muted); }
.ocr-lines { display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.ocr-line { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 6px; }
.ocr-line-text { overflow-wrap: anywhere; }
.ocr-line-text.big { font-weight: 700; }
.ocr-line-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.ocr-line-btns button { font-size: .8rem; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-weight: 600; }
.ocr-line-btns button:hover { border-color: var(--accent); }

/* Form */
.form { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 18px; }
@media (max-width: 600px) { .form { grid-template-columns: 1fr; } .form-cover { flex-direction: row; align-items: flex-end; } .cover-preview { width: 110px; } }
.form-cover { display: flex; flex-direction: column; gap: 8px; }
.cover-preview { width: 100%; aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; position: relative; background: var(--surface-2); border: 1px solid var(--line); }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.form-fields { display: grid; gap: 12px; min-width: 0; }
.form .sheet-actions { grid-column: 1 / -1; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
.field { display: grid; gap: 4px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 4px; }
.field textarea { resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .88rem; }
.chip input:checked + span { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Detail */
.detail { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; }
@media (max-width: 600px) { .detail { grid-template-columns: 1fr; } .detail .cover { width: 150px; } }
.detail h2 { font-size: 1.5rem; }
.detail-sub { color: var(--muted); margin: 4px 0 0; }
.where { border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; }
.where-phys { background: var(--phys-soft); }
.where-digi { background: var(--digi-soft); }
.where-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.where-phys .where-label { color: var(--phys); }
.where-digi .where-label { color: var(--digi); }
.where a { color: var(--digi); font-weight: 600; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.detail-main { display: grid; gap: 14px; align-content: start; min-width: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 100;
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

/* Handy: kompaktes Formular, Toast über dem Erfassen-Knopf */
@media (max-width: 600px) {
  .form-cover { flex-direction: row; align-items: flex-end; }
  .form-cover .cover-preview { width: 96px; flex: none; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}

/* Erfassen: Zusatzoptionen */
.capture-more { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .9rem; color: var(--muted); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cap-main { border-color: var(--accent-soft); }

/* Zuschneiden */
dialog.crop-dlg { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; background: #0e1311; color: #f2f5f3; }
.crop-wrap { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(12px, env(safe-area-inset-left, 0px)); }
.crop-head { display: grid; gap: 2px; padding-block: 12px 8px; }
.crop-hint { font-size: .9rem; opacity: .8; }
.crop-stage { position: relative; min-height: 0; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
#cropImg { max-width: 100%; max-height: 100%; object-fit: contain; display: block; pointer-events: none; }
.crop-svg { position: absolute; overflow: visible; pointer-events: none; }
.crop-svg polygon { fill: rgba(108,195,168,.18); stroke: #6cc3a8; stroke-width: 2.5; }
.crop-handle {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  background: rgba(108,195,168,.35); border: 3px solid #fff; box-shadow: 0 0 0 2px #1f5e4e, 0 2px 8px rgba(0,0,0,.5); touch-action: none; cursor: grab; z-index: 2;
}
.crop-handle::after { content: ""; position: absolute; inset: -14px; } /* grössere Tippfläche */
.crop-loading { position: absolute; inset: auto 0 16px; margin: auto; width: max-content; max-width: 90%; background: rgba(0,0,0,.7); padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.crop-loading .spinner, .crop-dlg .spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 8px; }
.crop-actions { display: flex; gap: 8px; justify-content: flex-end; padding-block: 12px; flex-wrap: wrap; }
.crop-actions .btn-ghost { background: transparent; color: #f2f5f3; border-color: rgba(255,255,255,.3); }
.crop-actions .btn-primary { background: #6cc3a8; color: #0d1a15; }

/* Titelbild in der Übersicht: echtes Foto ganz zeigen */
.cover.has-photo { background: var(--surface-2); }
.cover.has-photo img { object-fit: contain; }

/* Eigenes Foto liegt über dem automatisch erzeugten Titelbild */
.cover img { position: absolute; inset: 0; z-index: 1; }
.cover.has-photo img { background: var(--surface-2); }

/* Handy: Erfassen-Knopf links unten (rechts unten blendet Netlify ein Abzeichen ein) */
@media (max-width: 520px) {
  #btnAdd { right: auto; left: max(16px, env(safe-area-inset-left, 0px)); }
}

/* Doppelt erfasst: unübersehbarer Hinweis, Formular gesperrt */
:root { --dup: #b3261e; --dup-soft: #fbe9e7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --dup: #ff8a80; --dup-soft: #3a1f1c; } }
:root[data-theme="dark"] { --dup: #ff8a80; --dup-soft: #3a1f1c; }
.dup-box { background: var(--dup-soft); border: 2px solid var(--dup); border-radius: 12px; padding: 16px; display: grid; gap: 14px; }
.dup-head { display: flex; gap: 12px; align-items: flex-start; }
.dup-head > div { display: grid; gap: 2px; }
.dup-icon { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--dup); color: var(--dup-soft); display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; }
.dup-title { font-family: var(--font-display); font-size: 1.4rem; color: var(--dup); line-height: 1.1; }
.dup-item { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: center; background: var(--surface); border-radius: 10px; padding: 10px; }
.dup-item .cover { width: 72px; }
.dup-item .cover-gen .cg-title { font-size: .7rem; }
.dup-item .cover-gen .cg-fach, .dup-item .cover-gen .cg-verlag { display: none; }
.dup-meta { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.dup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dup-force summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.dup-force[open] { display: grid; gap: 8px; }
.dup-force[open] summary { margin-bottom: 4px; }
.dup-check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: .92rem; }
.dup-force .btn:disabled { opacity: .45; cursor: not-allowed; }
#editForm.is-blocked { opacity: .35; pointer-events: none; }

/* ---------- Stapel ---------- */
.stack-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 4px 0 16px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; font-weight: 600;
}
.stack-banner-ico { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); flex: none;
  -webkit-mask: var(--m-stack) center / 70% no-repeat; mask: var(--m-stack) center / 70% no-repeat; }
.stack-banner-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
:root { --m-stack: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 3h12v2H2zM3 7h10v2H3zM4 11h8v2H4z'/%3E%3C/svg%3E"); }
.cap-stack { width: 100%; border: 2px solid var(--accent); background: var(--surface); font: inherit; color: inherit; }
.ico-stack { --m: var(--m-stack); }
.review-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-right: auto; }
.review-bar strong { font-variant-numeric: tabular-nums; margin-right: 4px; }
#btnStack { white-space: nowrap; }
@media (max-width: 520px) { #btnStack { padding: 8px 10px; font-size: .88rem; } }

/* Live-Scan (immer dunkel, wie eine Kamera-App) */
dialog.live-dlg { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; background: #0b0f0d; color: #f1f5f3; }
.live-wrap { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(12px, env(safe-area-inset-left, 0px)); }
.live-dlg.single .live-wrap { grid-template-rows: auto minmax(0, 1fr) auto; }
.live-dlg.single .live-list, .live-dlg.single #liveDone, .live-dlg.single .live-count { display: none; }
.live-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-block: 10px; }
.live-top > div { display: grid; }
.live-count { font-size: .85rem; opacity: .8; font-variant-numeric: tabular-nums; }
.live-top-actions { display: flex; gap: 8px; }
.live-btn { border: 1px solid rgba(255,255,255,.3); background: transparent; color: #f1f5f3; border-radius: 8px; padding: 8px 12px; font-weight: 600; cursor: pointer; }
.live-btn.is-on { background: #f5d76e; color: #1b1b1b; border-color: #f5d76e; }
.live-stage { position: relative; min-height: 180px; border-radius: 12px; overflow: hidden; background: #000; }
.live-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.live-guide { position: absolute; left: 5%; right: 5%; top: 30%; height: 40%; border: 3px solid rgba(255,255,255,.85); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }
.live-guide::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff5a4f; box-shadow: 0 0 8px #ff5a4f; }
.live-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.live-flash.ok { background: rgba(108,195,168,.55); }
.live-flash.warn { background: rgba(255,138,128,.55); }
.live-flash.on { animation: flash .5s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live-flash.on { animation: none; } }
.live-msg { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: max-content; max-width: 92%; text-align: center;
  background: rgba(0,0,0,.72); padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.live-msg.ok { background: #1f7a5c; }
.live-msg.warn { background: #a3271d; border-radius: 12px; }
.live-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 30dvh; overflow: auto; }
.live-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: rgba(255,255,255,.07); border-radius: 8px; padding: 6px 8px; }
.live-item img, .live-noimg { width: 36px; height: 48px; object-fit: cover; border-radius: 3px; background: rgba(255,255,255,.12); }
.live-item-text { display: grid; min-width: 0; }
.live-item-text strong, .live-item-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-item-text small { opacity: .75; }
.live-item.nicht-gefunden small { color: #ffb4ab; opacity: 1; }
.live-del { border: 0; background: transparent; color: #f1f5f3; font-size: 1.5rem; line-height: 1; padding: 4px 8px; cursor: pointer; opacity: .7; }
.live-dlg .spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; margin-right: 6px; vertical-align: -1px; }
.live-bottom { display: flex; gap: 8px; padding-block: 10px; flex-wrap: wrap; }
.live-bottom input { flex: 1; min-width: 120px; padding: 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #f1f5f3; }
.live-bottom .btn-primary { background: #6cc3a8; color: #0d1a15; flex: 1 1 100%; padding: 13px; font-size: 1.02rem; }
/* Beim Durchgehen des Stapels nur das Nötige zeigen */
.capture.in-review #capStack, .capture.in-review .capture-more, .capture.in-review .capture-label,
.capture.in-review .capture-grid > label:not(.cap-main), .capture.in-review .capture-grid > label:has(#capBarcode) { display: none; }
.capture.in-review .capture-grid { grid-template-columns: 1fr; }

/* Schnellwahl Unterstufe / Mittelstufe */
.chip-group { border: 1px dashed var(--accent); background: transparent; color: var(--accent); border-radius: 999px; padding: 5px 11px; font-weight: 700; font-size: .85rem; cursor: pointer; }
.chip-group:first-of-type { margin-left: 6px; }
.chip-group:hover { background: var(--accent-soft); }

/* =========================================================
   Designs (hell + dunkel je nach Gerät). Auswahl in js/config.js -> design
   ========================================================= */
.brand-tag { margin: 2px 0 0; font-size: .92rem; color: var(--muted); }
:root[data-design] { --header-bg: var(--surface); --header-fg: var(--fg); --header-muted: var(--muted); --header-btn: var(--surface); --card-r: 6px; }
.topbar { background: var(--header-bg); color: var(--header-fg); }

/* A – Hell & ruhig (Wandtafel-Grün) */
:root[data-design="a"] {
  --bg: #f6f8f7; --surface: #ffffff; --surface-2: #edf2ef; --line: #d7e0db;
  --fg: #18231f; --muted: #56675f; --accent: #1f5e4e; --accent-fg: #ffffff; --accent-soft: #dcebe5;
  --phys: #8a5a12; --phys-soft: #f6ead3; --digi: #1d5a9b; --digi-soft: #e1ecf8; --danger: #b3261e;
  --font-display: "Fraunces", Georgia, serif; --font-body: "Source Sans 3", system-ui, sans-serif;
}

/* B – Freundlich & warm (Sonnengelb, runde Schrift) */
:root[data-design="b"] {
  --bg: #fbfaf6; --surface: #ffffff; --surface-2: #f3f0e6; --line: #e6e0cf;
  --fg: #1e2a4a; --muted: #5b6480; --accent: #2b4a9b; --accent-fg: #ffffff; --accent-soft: #e2e8f7;
  --phys: #b24a12; --phys-soft: #fde6d6; --digi: #2b4a9b; --digi-soft: #e2e8f7; --danger: #b3261e;
  --font-display: "Nunito", system-ui, sans-serif; --font-body: "Nunito", system-ui, sans-serif;
  --header-bg: #ffd65c; --header-fg: #1e2a4a; --header-muted: #3d4666; --header-btn: rgba(255,255,255,.75); --card-r: 12px;
}
:root[data-design="b"] h1, :root[data-design="b"] h2, :root[data-design="b"] .cg-title, :root[data-design="b"] .dup-title { font-weight: 800; letter-spacing: -.01em; }
:root[data-design="b"] .topbar { border-bottom: 0; }
:root[data-design="b"] .brand-tag, :root[data-design="b"] .brand-sub { color: var(--header-muted); }
:root[data-design="b"] .brand-mark { background: var(--header-fg); border-radius: 50%; opacity: 1;
  -webkit-mask: radial-gradient(circle, #000 60%, transparent 61%); mask: radial-gradient(circle, #000 60%, transparent 61%); }
:root[data-design="b"] .btn { border-radius: 999px; }
:root[data-design="b"] .topbar .btn-ghost { background: var(--header-btn); border-color: rgba(127,127,127,.3); color: var(--header-fg); }
:root[data-design="b"] .search input, :root[data-design="b"] .selects select { border-radius: 999px; }
:root[data-design="b"] .cover { border-radius: var(--card-r); }

/* C – Klar & modern (Schulblau) */
:root[data-design="c"] {
  --bg: #f2f5f9; --surface: #ffffff; --surface-2: #e8eef6; --line: #d5dee9;
  --fg: #142133; --muted: #56657a; --accent: #1d5fb0; --accent-fg: #ffffff; --accent-soft: #dde9f8;
  --phys: #0f7a5c; --phys-soft: #daf2e9; --digi: #6a3fb0; --digi-soft: #ece4f8; --danger: #b3261e;
  --font-display: "Figtree", system-ui, sans-serif; --font-body: "Figtree", system-ui, sans-serif;
  --card-r: 8px;
}
:root[data-design="c"] .topbar { border-bottom: 3px solid var(--accent); }
:root[data-design="c"] h1, :root[data-design="c"] h2 { font-weight: 700; letter-spacing: -.02em; }
:root[data-design="c"] .brand h1 { color: var(--accent); }
:root[data-design="c"] .brand-mark { background: var(--accent); border-radius: 8px; opacity: 1;
  -webkit-mask: none; mask: none; box-shadow: inset 0 -10px 0 rgba(255,255,255,.25); }
:root[data-design="c"] .cover-gen .cg-title { font-weight: 700; }
:root[data-design="c"] .cover { border-radius: var(--card-r); }

/* Dunkle Varianten der Designs (folgen der Einstellung des Geräts) */
@media (prefers-color-scheme: dark) { :root[data-design="a"]:not([data-theme="light"]) { --bg: #111715; --surface: #18201d; --surface-2: #1f2925; --line: #2d3a35; --fg: #e6eeea; --muted: #9db0a8; --accent: #6cc3a8; --accent-fg: #0d1a15; --accent-soft: #1d3a31; --phys: #e6b467; --phys-soft: #3a2d17; --digi: #8dbcf0; --digi-soft: #1a2c42; --danger: #ff8a80; color-scheme: dark; } }
:root[data-design="a"][data-theme="dark"] { --bg: #111715; --surface: #18201d; --surface-2: #1f2925; --line: #2d3a35; --fg: #e6eeea; --muted: #9db0a8; --accent: #6cc3a8; --accent-fg: #0d1a15; --accent-soft: #1d3a31; --phys: #e6b467; --phys-soft: #3a2d17; --digi: #8dbcf0; --digi-soft: #1a2c42; --danger: #ff8a80; color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root[data-design="b"]:not([data-theme="light"]) { --bg: #14182a; --surface: #1c2238; --surface-2: #252c46; --line: #333b58; --fg: #eef1fa; --muted: #a9b1cc; --accent: #9db3f5; --accent-fg: #121729; --accent-soft: #27325a; --phys: #ffab7a; --phys-soft: #43291b; --digi: #9db3f5; --digi-soft: #27325a; --danger: #ff8a80; --header-bg: #3b3313; --header-fg: #ffe08a; --header-muted: #d9c88f; --header-btn: rgba(255,255,255,.08); color-scheme: dark; } }
:root[data-design="b"][data-theme="dark"] { --bg: #14182a; --surface: #1c2238; --surface-2: #252c46; --line: #333b58; --fg: #eef1fa; --muted: #a9b1cc; --accent: #9db3f5; --accent-fg: #121729; --accent-soft: #27325a; --phys: #ffab7a; --phys-soft: #43291b; --digi: #9db3f5; --digi-soft: #27325a; --danger: #ff8a80; --header-bg: #3b3313; --header-fg: #ffe08a; --header-muted: #d9c88f; --header-btn: rgba(255,255,255,.08); color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root[data-design="c"]:not([data-theme="light"]) { --bg: #0f141b; --surface: #161d27; --surface-2: #1e2733; --line: #2b3644; --fg: #e7edf5; --muted: #9aa9bc; --accent: #6aa7f0; --accent-fg: #0b1420; --accent-soft: #1b2e47; --phys: #4fd1a5; --phys-soft: #12352b; --digi: #b79af0; --digi-soft: #2b2142; --danger: #ff8a80; color-scheme: dark; } }
:root[data-design="c"][data-theme="dark"] { --bg: #0f141b; --surface: #161d27; --surface-2: #1e2733; --line: #2b3644; --fg: #e7edf5; --muted: #9aa9bc; --accent: #6aa7f0; --accent-fg: #0b1420; --accent-soft: #1b2e47; --phys: #4fd1a5; --phys-soft: #12352b; --digi: #b79af0; --digi-soft: #2b2142; --danger: #ff8a80; color-scheme: dark; }

/* ---------- PDFs / Ordner einlesen ---------- */
:root { --m-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1 3h5l1.5 2H15v8H1z'/%3E%3C/svg%3E"); }
.ico-folder { --m: var(--m-folder); }
.capture-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) { .capture-grid { grid-template-columns: 1fr; } }
.pdf-tabs { width: max-content; max-width: 100%; }
.pdf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pdf-row { display: grid; grid-template-columns: auto 44px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); opacity: .65; }
.pdf-row.on { opacity: 1; border-color: var(--accent); }
.pdf-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.pdf-row img, .pdf-noimg { width: 44px; height: 58px; object-fit: cover; border-radius: 3px; background: var(--surface-2); display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--muted); }
.pdf-text { display: grid; gap: 3px; min-width: 0; }
.pdf-text strong { overflow-wrap: anywhere; }
.pdf-path { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.pdf-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.pdf-tag { font-size: .74rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pdf-tag.ok { background: var(--accent-soft); color: var(--accent); }
.pdf-tag.warn { background: var(--phys-soft); color: var(--phys); }
.pdf-empty { color: var(--muted); padding: 16px 4px; }
.drop-hint { position: fixed; inset: 0; z-index: 200; display: none; place-items: center; background: color-mix(in srgb, var(--accent) 22%, transparent); border: 4px dashed var(--accent); pointer-events: none; }
.drop-hint span { background: var(--surface); color: var(--fg); padding: 14px 20px; border-radius: 12px; font-weight: 800; font-size: 1.2rem; box-shadow: var(--shadow); }
body.drop-on .drop-hint { display: grid; }

.login-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-size: .9rem; }
