/* Film-Sammlung – schlankes eigenes CSS (Bausteine wie bei leicht-vergleich), eigene Akzentfarbe.
   Mobil zuerst, Dark Mode über prefers-color-scheme. */

:root {
  --bg: #f5f6f8; --card: #ffffff; --ink: #1b1d22; --muted: #5d6270; --line: #e1e4ea;
  --accent: #1d4ed8; --accent-ink: #ffffff; --soft: #e8eefc; --warn: #9a4a00; --warn-bg: #fff4e5; --danger: #b42318;
  --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 2px 8px rgb(0 0 0 / .04);
  color-scheme: light dark;
  accent-color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121317; --card: #1c1e24; --ink: #e9eaee; --muted: #a3a7b3; --line: #31343d;
    --accent: #93b4ff; --accent-ink: #0b1a3d; --soft: #1a2747; --warn: #fdba74; --warn-bg: #3a2614; --danger: #fca5a5;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-underline-offset: .15em; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------- Kopf / Navigation ---------- */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { font-weight: 750; color: var(--ink); text-decoration: none; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: 11px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav button.link { padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .95rem; min-height: 0; }
.nav a:hover { background: var(--bg); }
.nav a[aria-current="page"] { background: var(--soft); color: var(--accent); font-weight: 600; }
.nav form { display: inline; }
.nav button.nav-logout { font-weight: 400; color: var(--muted); }
@media (max-width: 599px) {
  .nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .nav a, .nav button.link { white-space: nowrap; }
}

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }
.foot { color: var(--muted); font-size: .82rem; text-align: center; padding: 20px 16px; border-top: 1px solid var(--line); }
.foot p { margin: 0 auto 6px; max-width: 70ch; }
.foot a { color: var(--muted); }

/* ---------- Bausteine ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.narrow { max-width: 28rem; margin: 24px auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.row .grow { flex: 1; width: auto; min-width: 0; }
.cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover, button:hover { filter: brightness(1.06); }
.btn.secondary, button.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover, button.secondary:hover { background: var(--bg); filter: none; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small, .btn.small { padding: 5px 10px; font-size: .85rem; min-height: 34px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; }
button:disabled { opacity: .45; cursor: not-allowed; }

label { font-weight: 600; font-size: .92rem; display: block; margin-bottom: 4px; }
.hint { font-size: .85rem; color: var(--muted); margin: 4px 0 0; font-weight: 400; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; min-height: 42px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input:user-invalid { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 18px; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }

.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--card); }
.flash.ok { border-color: var(--accent); background: var(--soft); }
.flash.error { border-color: var(--danger); color: var(--danger); }
.flash.warn, .flash.info { border-color: var(--warn); background: var(--warn-bg); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); vertical-align: middle; }
.badge.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 12px; }
.tabs a { padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--card); font-size: .92rem; }
.tabs a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---------- Filter ---------- */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.filters-q, .filters-go { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .filters { grid-template-columns: 2fr repeat(4, minmax(0, 1fr)) auto; }
  .filters-q, .filters-go { grid-column: auto; }
}

/* ---------- Cover ---------- */
.cover { border-radius: 6px; border: 1px solid var(--line); background: var(--bg); object-fit: cover; aspect-ratio: 5 / 7; height: auto; flex: none; }
.cover-sm { width: 56px; }
.cover-md { width: 100%; }
.cover-lg { width: min(240px, 100%); }
.cover-none { display: grid; place-items: center; text-align: center; color: var(--muted); font-size: .72rem; padding: 4px; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--bg) 0 8px, var(--card) 8px 16px); }
.cover-md.cover-none { font-size: .85rem; font-weight: 600; color: var(--ink); padding: 10px; overflow-wrap: anywhere; }

/* Liste mit Cover */
.items { list-style: none; margin: 0; padding: 0; }
.card.items { padding-block: 4px; }
.item { border-top: 1px solid var(--line); padding: 12px 0; }
.item:first-child { border-top: 0; }
.item-main { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
a.item-main:hover .item-q { text-decoration: underline; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-q { font-weight: 650; overflow-wrap: anywhere; }
.item-rules { font-size: .85rem; color: var(--muted); }
.item-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }

/* Einfache Liste (Tabelle) */
.table-wrap { padding: 0; overflow-x: auto; }
table.movies { width: 100%; border-collapse: collapse; font-size: .95rem; }
.movies th, .movies td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.movies thead th { border-top: 0; font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.movies tbody th { font-weight: 600; }
.movies td { white-space: nowrap; }
.movies td.col-genre { white-space: normal; color: var(--muted); }
@media (max-width: 599px) { .movies .col-genre { display: none; } }

/* Nur Cover (Raster) */
.cover-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
@media (min-width: 760px) { .cover-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.cover-tile { display: block; position: relative; border-radius: 8px; }
.cover-tile:hover .cover { outline: 2px solid var(--accent); }
.tile-badge { position: absolute; top: 6px; left: 6px; }

/* ---------- Bearbeiten ---------- */
.edit-grid { display: grid; gap: 16px; align-items: start; }
.edit-grid > .card + .card { margin-top: 0; }
@media (min-width: 860px) { .edit-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); } }
.danger-zone { margin-top: 16px; }
.tmdb-pick:empty { display: none; }

/* ---------- Dialog TMDB ---------- */
dialog.dlg { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); padding: 16px; }
dialog.dlg::backdrop { background: rgb(0 0 0 / .6); }
dialog .year { width: 6.5rem; }
.tmdb-results { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.tmdb-hit { width: 100%; justify-content: flex-start; text-align: left; gap: 10px; background: var(--card); color: var(--ink); border-color: var(--line); font-weight: 400; align-items: flex-start; }
.tmdb-hit:hover { background: var(--bg); filter: none; }
.tmdb-ov { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Scannen ---------- */
.scan-view { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: 10px; overflow: hidden; max-width: 560px; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 30% 10%; border: 3px solid rgb(255 255 255 / .9); border-radius: 10px; box-shadow: 0 0 0 999px rgb(0 0 0 / .35); }
/* Foto-Modus: Hochformat wie eine Hülle (passt zum Ausschnitt in movie.js) */
.scan-frame.shot { inset: auto; top: 50%; left: 50%; height: 92%; aspect-ratio: .72; transform: translate(-50%, -50%); }
.scan-start { position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; }
.scan-msg { margin: 10px 0; font-size: .92rem; color: var(--muted); }
.scan-shot { max-width: 560px; margin-bottom: 12px; }
.scan-shot p { margin: 0 0 10px; }
.scan-shot .row button { flex: 1; min-height: 48px; }
.manual { max-width: 560px; margin-top: 8px; }
.scan-list .item { display: grid; gap: 8px; }
.scan-list .scan-title { gap: 6px; }
.scan-note:empty { display: none; }
.scan-list .dupe { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; border: 1px solid var(--warn); }
.scan-list .dupe + .item, .scan-list .item + .dupe { margin-top: 8px; }

/* Originaltitel unter dem deutschen Titel */
.orig { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; }

/* Zuschnitt anpassen */
dialog.dlg-crop { width: min(760px, calc(100vw - 24px)); }
.crop-stage { position: relative; width: fit-content; max-width: 100%; margin: 0 auto 12px; line-height: 0; }
.crop-stage img { display: block; max-width: 100%; max-height: min(68vh, 900px); width: auto; height: auto; }
.crop-svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; overflow: visible; }
.crop-poly { fill: rgb(80 160 255 / .12); stroke: #4da3ff; stroke-linejoin: round; }
.crop-dot { fill: rgb(77 163 255 / .35); stroke: #fff; cursor: grab; }
.crop-dot:focus-visible { outline: none; fill: #ffcc33; }
.crop-dot:active { cursor: grabbing; }

/* Standard-Medium auf der Scan-Seite */
.scan-medium { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; margin-bottom: 12px; }
.scan-medium label { margin: 0; }
.scan-medium select { max-width: 14rem; }
.scan-medium .hint { grid-column: 1 / -1; margin: 0; }

/* Lupen-Knopf (EAN nachschlagen) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 44px; padding-inline: 12px; }
.icon-btn svg { display: block; }

/* Hinweis: vorgemerkte EANs */
.flash.pending { margin-bottom: 12px; }

/* Vorschlag (Zauberstab) */
.suggest-table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .95rem; }
.suggest-table th, .suggest-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.suggest-table thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.suggest-table td:first-child { width: 1%; }
.suggest-table .sg-new { font-weight: 600; }
