/* ComicDB – Stil: dunkles „Comicladen“-Thema, mobil zuerst */
:root {
  --bg: #12131c;
  --panel: #1b1d29;
  --panel2: #242737;
  --line: #33374a;
  --text: #eceef5;
  --muted: #9aa0b6;
  --accent: #ffd23f;
  --accent-ink: #1b1d29;
  --red: #ff5a5f;
  --green: #38c172;
  --orange: #ff9f43;
  --radius: 12px;
  --tabs-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f2ec; --panel: #ffffff; --panel2: #f0eee6; --line: #dcd8cc;
    --text: #1d1e26; --muted: #6b6e7d; --accent: #ffc800; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .2em 0 .4em; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 1em 0 .5em; }
h3 { font-size: 1rem; margin: 1.2em 0 .3em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.err { color: var(--red); }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }

/* Kopf und Navigation */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 900; font-size: 1.25rem; text-decoration: none; color: var(--text); letter-spacing: -.5px; }
.logo span { background: var(--accent); color: var(--accent-ink); padding: 0 5px; border-radius: 4px; margin-left: 2px; transform: rotate(-3deg); display: inline-block; }
.top-search { flex: 1; }
.top-search input { width: 100%; }
.top-link { color: var(--muted); text-decoration: none; font-size: 1.3rem; padding: 0 4px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: .72rem; gap: 2px;
}
.tabs a span { font-size: 1.25rem; line-height: 1; }
.tabs a.active { color: var(--accent); }
.tabs .scan-tab span { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 6px 10px; font-size: .95rem; letter-spacing: -2px; font-weight: 900; }

.view { max-width: 1100px; margin: 0 auto; padding: 14px; }
.narrow { max-width: 520px; margin: 0 auto; padding: 24px 16px; }
.plain { padding-bottom: 0; }
.logo-big { font-size: 2.4rem; font-weight: 900; text-align: center; margin: 30px 0 20px; }

/* Bedienelemente */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; color: var(--text);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-height: 44px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ok { background: var(--green); color: #fff; border-color: var(--green); }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 34px; padding: 5px 10px; font-size: .88rem; }
.btn.big { font-size: 1.1rem; width: 100%; }
.btn.block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .6; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .8rem; padding: 2px; }
.link.danger { color: var(--red); }
.chip { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 99px; padding: 6px 12px; font-weight: 600; cursor: pointer; }
.pill { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: .8rem; white-space: nowrap; }
.pill.wish { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.card.ok { border-color: var(--green); }
.card.bad, .log.bad { border-color: var(--red); color: var(--red); }
.card.warn { border-color: var(--orange); }
.checks { list-style: none; padding: 0; margin: 0; }
.checks .ok { color: var(--green); } .checks .bad { color: var(--red); }

.form label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.form label input, .form label select, .form label textarea { margin-top: 4px; }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 1rem; min-height: 44px; margin-top: 26px; }
.form label.check input { width: 22px; min-height: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.form .btn[type=submit], .form > .btn { margin-top: 16px; }
.form.inline { display: grid; grid-template-columns: 1fr; gap: 8px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 16px 0; padding: 4px 14px 14px; }
legend { padding: 0 6px; color: var(--accent); font-weight: 700; font-size: .9rem; }
.row2, .row3 { display: grid; gap: 0 12px; grid-template-columns: 1fr; align-items: end; }
.with-btn { display: flex; gap: 6px; margin-top: 4px; }
.with-btn input { margin: 0 !important; }
.sticky-save { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 6px); padding-top: 10px; z-index: 5; }
.lookup .row2 .btn { margin-top: 10px; }

@media (min-width: 640px) {
  .row2 { grid-template-columns: 1fr 1fr; }
  .row3 { grid-template-columns: 1fr 1fr 1fr; }
  .form.inline { grid-template-columns: 1fr 1fr auto; }
  .lookup .row2 { grid-template-columns: 1fr auto; }
}

/* Liste */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stats { margin-top: -6px; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.filters select { font-size: .9rem; padding: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.comic-card { text-decoration: none; color: var(--text); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .12s; }
.comic-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.cover { position: relative; aspect-ratio: 2 / 3; background: var(--panel2); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nocover { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 900; color: var(--line); text-transform: uppercase; background: var(--panel2); min-height: 120px; border-radius: 6px; }
.nocover.big { aspect-ratio: 2 / 3; font-size: 1rem; color: var(--muted); }
.nocover.sm { width: 56px; height: 80px; min-height: 0; font-size: 1rem; }
.badge-num, .badge-qty, .badge-prio { position: absolute; font-weight: 800; font-size: .8rem; border-radius: 6px; padding: 2px 7px; }
.badge-num { left: 6px; bottom: 6px; background: var(--accent); color: var(--accent-ink); }
.badge-qty { right: 6px; top: 6px; background: #000c; color: #fff; }
.badge-prio { right: 6px; top: 6px; background: #000c; color: var(--accent); }
.meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta strong { font-size: .92rem; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meta .sub { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 10px; }

/* Detail */
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; color: var(--muted); }
.detail { display: grid; gap: 20px; }
@media (min-width: 760px) { .detail { grid-template-columns: 320px 1fr; } }
.detail-cover > a img { width: 100%; border-radius: var(--radius); display: block; box-shadow: 0 10px 30px #0006; }
.detail-info h1 .num { color: var(--accent); }
.detail-info h2.sub { font-weight: 500; color: var(--muted); margin-top: 0; }
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; border: 2px solid transparent; }
.gallery .is-cover img { border-color: var(--accent); }
.gallery figcaption { display: flex; flex-direction: column; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; align-items: center; }
.qty { display: inline-flex; align-items: center; gap: 6px; }
.qty span { min-width: 34px; text-align: center; font-weight: 700; }
.facts { width: 100%; border-collapse: collapse; margin-top: 8px; }
.facts th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 12px 6px 0; vertical-align: top; width: 38%; font-size: .9rem; }
.facts td { padding: 6px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.desc { white-space: pre-wrap; }

/* Recherche-Kandidaten */
.cands { display: grid; gap: 8px; margin-top: 10px; }
.cand { display: flex; gap: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.cand img { width: 56px; height: 80px; object-fit: cover; border-radius: 4px; flex: none; }
.cand > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.cand .src { color: var(--accent); }
.cand .btn { align-self: flex-start; margin-top: 6px; }
.cover-pick { display: flex; gap: 14px; align-items: center; margin: 10px 0; }
.cover-pick #coverPreview { width: 90px; flex: none; }
.cover-pick #coverPreview img { width: 90px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px; display: block; }
.cover-pick .nocover { aspect-ratio: 2/3; min-height: 0; font-size: .8rem; color: var(--muted); }

/* Scanner */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel2); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg button { font: inherit; font-weight: 600; border: 0; border-radius: 9px; padding: 10px; background: none; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.reader { width: 100%; max-width: 560px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 220px; }
.reader.mini { margin-top: 10px; }
.reader video { border-radius: var(--radius); }
.reader-off { color: #ccc; text-align: center; padding: 50px 20px; font-size: 1rem; }
.manual { display: flex; gap: 8px; max-width: 560px; margin: 12px auto; }
.found { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.found a { font-weight: 700; flex: 1; }

/* Lagerorte */
.loc { display: flex; align-items: center; gap: 10px; }
.loc-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.loc-main a { text-decoration: none; color: var(--text); }

/* Update */
.upd { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.log { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; white-space: pre-wrap; font-size: .85rem; }

/* Hinweis-Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; max-width: 92vw;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 24px #0007; font-weight: 600;
}
.toast.ok { border-color: var(--green); }
.toast.bad { border-color: var(--red); color: var(--red); }

/* ---- 1.1.0: Scanner mit Zielrahmen, Zusatzcode, Presse-EAN ---- */
.reader { position: relative; }
.reader video { width: 100%; display: block; max-height: 60vh; object-fit: cover; }
.aim { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.aim i { width: 86%; height: 38%; border: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 999px #0007; }
.aim span { position: absolute; bottom: 10px; color: #fff; font-size: .8rem; background: #0009; padding: 2px 10px; border-radius: 99px; }
.torch { position: absolute; top: 10px; right: 10px; background: #000a; border: 1px solid #fff5; color: #fff; border-radius: 99px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; }
.torch.on { background: var(--accent); }
input.addon { width: 92px; flex: none; text-align: center; letter-spacing: 1px; }
.manual input.addon { width: 92px; }
.addon-pill { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 0 6px; font-weight: 700; font-size: .85em; }
.scan-code { margin: 4px 0; font-family: ui-monospace, Menlo, monospace; }
.press-hit .press-name { color: var(--text); font-size: 1.3rem; margin: 8px 0 0; }
.press-hit .num { color: var(--accent); }
.quick { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.quick label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); width: 90px; }
.quick input { font-size: 1.2rem; font-weight: 700; text-align: center; margin-top: 4px; }
.press-learn { font-size: .9rem !important; margin-top: 12px !important; }
.press-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.press-tools input { flex: 1; min-width: 180px; }
.press-row { display: flex; align-items: center; gap: 10px; }
.press-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.press-row .pill { text-decoration: none; color: var(--text); }
.mono { font-family: ui-monospace, Menlo, monospace; color: var(--accent); }

/* ---- 1.2.0: Mandanten, Familie, Serien, Icons ---- */
.ro .needs-edit { display: none !important; }
.top svg, .tabs svg { width: 22px; height: 22px; fill: currentColor; }
.top-link svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.tabs a svg { margin-bottom: 2px; }
.tabs a[data-tab="locations"] svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tabs .scan-tab svg { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 4px 8px; width: 40px; height: 30px; box-sizing: border-box; }
.lib-switch { width: auto; max-width: 34vw; min-height: 36px; padding: 4px 8px; font-size: .85rem; font-weight: 600; }
.small-seg { max-width: 420px; margin: 6px 0 4px; }
.small-seg button { padding: 7px; font-size: .9rem; }
.filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.series-head .chip { margin-bottom: 6px; }
.series-head p { margin: 4px 0; }
.missing { color: var(--orange); }
.badge-miss { position: absolute; right: 6px; top: 6px; background: var(--orange); color: #1b1d29; font-weight: 800; font-size: .72rem; border-radius: 6px; padding: 2px 6px; }
.series-card .cover::after { content: ""; position: absolute; inset: 0 -4px -4px 0; border-right: 4px solid var(--line); border-bottom: 4px solid var(--line); border-radius: 4px; pointer-events: none; }
.members { display: flex; flex-direction: column; }
.member { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.member:last-child { border-bottom: 0; }
.member-main { flex: 1; display: flex; flex-direction: column; min-width: 140px; }
.member select { width: auto; min-height: 36px; padding: 4px 8px; font-size: .88rem; }
.lib-admin { border-top: 1px solid var(--line); padding: 8px 0; }
.lib-admin summary { cursor: pointer; padding: 4px 0; }
[hidden] { display: none !important; }

/* ---- 1.3.0: fehlende Bände auswählen ---- */
.miss-pick { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.miss-pick summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 4px 0; }
.miss-pick label { display: block; color: var(--muted); margin-top: 10px; }
.miss-pick label input, .miss-pick label select { margin-top: 4px; }
.num-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.num-chip { min-width: 44px; min-height: 40px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.num-chip.wished { border-color: var(--accent); color: var(--accent); }
.num-chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ok-text { color: var(--green); }

/* ---- 1.4.0: Serie komplett ---- */
.complete-banner { background: var(--green); color: #fff; font-weight: 700; border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.badge-done { position: absolute; right: 6px; top: 6px; background: var(--green); color: #fff; font-weight: 800; font-size: .72rem; border-radius: 6px; padding: 2px 6px; }
.meta-form { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
.meta-form label { display: block; color: var(--muted); margin-top: 10px; }
.meta-form label input[type=number], .meta-form label input:not([type]) { margin-top: 4px; }
.meta-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.meta-form label.check input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); }
.meta-form .btn { margin-top: 10px; }
.seg.three { grid-template-columns: 1fr 1fr 1fr; }

/* ---- 1.5.0: Zusatzbausteine ---- */
.switch { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.switch input { width: 22px; height: 22px; min-height: 22px; accent-color: var(--accent); }

/* ---- 1.7.0: Cover-Suche ---- */
.img-more { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.img-more .btn { flex: 1; }

/* ---- 1.7.1: Bilder löschen / ersetzen ---- */
.cover-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cover-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.btn.xs { min-height: 30px; padding: 3px 8px; font-size: .78rem; border-radius: 8px; }
.gallery figcaption { gap: 4px; margin-top: 4px; }
.cand-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.cand-actions .btn { margin-top: 0; }
.cand img { width: 72px; height: 104px; }
