:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --dim: #8a92a2;
  --accent: #e0b04a;
  --accent-soft: rgba(224, 176, 74, 0.15);
  --ok: #5fbf8a;
  --danger: #e06a6a;
  --radius: 12px;
  --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: 0.6rem; }
h3 { font-size: 0.85rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem; }
p { margin: 0 0 0.6rem; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 12px) 16px 24px;
  min-height: 70vh;
}
.dim { color: var(--dim); }
.small { font-size: 0.82rem; }
.warn { color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.row > .input, .row > .search-input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.plain { list-style: none; padding: 0; margin: 0; }
section { margin: 0 0 22px; }

/* ---------- Kopf, Werkzeugleiste ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.count { color: var(--dim); font-weight: 500; font-size: 1rem; }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.search-input, .input, .select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  min-height: 40px;
  outline: none;
  width: 100%;
}
.search-input:focus, .input:focus, .select:focus { border-color: var(--accent); }
.search-input.big { font-size: 1.05rem; min-height: 46px; }
.select { width: auto; appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.select.small { min-height: 32px; padding: 4px 28px 4px 8px; font-size: 0.82rem; }
input[type="date"].input { color-scheme: dark; }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.segmented.wide { display: flex; }
.segmented.wide .seg { flex: 1; }
.seg { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; color: var(--dim); cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.status .seg[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: transparent; color: var(--dim); border-radius: 999px; padding: 5px 12px; font-size: 0.85rem; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.removable { display: inline-flex; align-items: center; gap: 4px; color: var(--text); cursor: default; }
.chip.removable button { border: 0; background: none; color: var(--dim); padding: 0 2px; cursor: pointer; font-size: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; min-height: 40px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--accent-soft); border-color: rgba(224, 176, 74, 0.45); color: var(--accent); font-weight: 600; }
.btn.danger { background: rgba(224, 106, 106, 0.14); border-color: rgba(224, 106, 106, 0.45); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.ghost.danger { border-color: rgba(224, 106, 106, 0.35); }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }
.link { border: 0; background: none; color: var(--accent); padding: 4px 0; cursor: pointer; }
.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--accent); font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn.small { width: 32px; height: 32px; font-size: 1rem; color: var(--dim); }
.pill { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--dim); margin: 4px 4px 0 0; }
.pill.ok { background: rgba(95, 191, 138, 0.15); color: var(--ok); }

/* ---------- Karten ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.card { color: inherit; text-decoration: none; display: flex; flex-direction: column; min-width: 0; }
.card-poster { position: relative; }
.poster { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius); background: var(--surface); }
.poster-empty { display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; color: var(--dim); font-size: 0.85rem; border: 1px solid var(--border); }
.badge { position: absolute; top: 6px; right: 6px; background: rgba(14, 16, 20, 0.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 8px; padding: 2px 7px; font-size: 0.75rem; font-weight: 600; }
.badge.own { color: var(--accent); }
.card-body { padding: 7px 2px 0; }
.card-title { font-weight: 600; font-size: 0.92rem; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { color: var(--dim); font-size: 0.78rem; margin-top: 2px; }
.card-providers { display: flex; gap: 5px; align-items: center; margin-top: 6px; min-height: 24px; flex-wrap: wrap; }
.card-providers .logo { width: 24px; height: 24px; }
.more, .paid { font-size: 0.72rem; color: var(--dim); }
.logo { width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); flex: none; }
.logo.mine { box-shadow: 0 0 0 2px var(--accent); }
.logo.dim { opacity: 0.45; }

/* ---------- Suche ---------- */
.results { display: flex; flex-direction: column; gap: 4px; }
.result { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.result-main { display: flex; gap: 12px; flex: 1; min-width: 0; color: inherit; text-decoration: none; align-items: center; }
.result-main .poster { width: 54px; flex: none; border-radius: 8px; }
.result-main .poster-empty { font-size: 0.6rem; padding: 2px; }
.result-title { font-weight: 600; }

/* ---------- Detail ---------- */
.detail { position: relative; }
.backdrop {
  position: absolute; left: -16px; right: -16px; top: calc(-12px - var(--safe-top)); height: 260px;
  background-size: cover; background-position: center top; opacity: 0.22;
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent); mask-image: linear-gradient(to bottom, #000 30%, transparent);
  pointer-events: none;
}
.detail-head { position: relative; display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding-top: 44px; margin-bottom: 18px; }
@media (min-width: 700px) { .detail-head { grid-template-columns: 200px 1fr; gap: 24px; } }
.back { position: absolute; top: 0; left: -6px; border: 0; background: rgba(14, 16, 20, 0.6); color: var(--text); font-size: 1.8rem; line-height: 1;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.detail-title h1 { font-size: 1.35rem; }
.facts { color: var(--dim); font-size: 0.88rem; margin-top: 6px; }
.genres { margin-top: 4px; }
.ratings { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rating-box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; display: flex; flex-direction: column; align-items: center; min-width: 54px; }
.rating-box .label { font-size: 0.66rem; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.rating-box strong { font-size: 1.05rem; }
.rating-box.imdb strong { color: #e8c547; }
.rating-box.own strong { color: var(--accent); }
.overview { color: #c9cdd5; }

.views { list-style: none; padding: 0; margin: 0 0 10px; }
.views li { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
.rating-picker { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rate { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; height: 40px; cursor: pointer; font-weight: 600; color: var(--dim); padding: 0; }
.rate.on { background: var(--accent-soft); border-color: rgba(224, 176, 74, 0.5); color: var(--accent); }
.rate[aria-checked="true"] { background: rgba(224, 176, 74, 0.3); color: var(--text); }

.provider-group { margin-bottom: 12px; }
.provider-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.provider-list li { display: flex; align-items: center; gap: 10px; }
.provider-list .logo { width: 34px; height: 34px; }
.danger-zone { margin-top: 30px; }

/* ---------- Einstellungen ---------- */
.provider-pick { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; max-height: 420px; overflow-y: auto; }
.provider-pick label { display: flex; align-items: center; gap: 10px; padding: 6px 2px; cursor: pointer; }
.provider-pick input, .check input, .import-check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.check { display: flex; gap: 10px; align-items: center; }

/* ---------- Import ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.85rem; color: var(--dim); }
.field .select { width: 100%; }
.sample { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-size: 0.88rem; }
.sample li { padding: 2px 0; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.summary p:last-child { margin: 0; }
.conflict-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.import-list { list-style: none; padding: 0; margin: 0; }
.import-row { border-bottom: 1px solid var(--border); padding: 8px 0; }
.import-row.off { opacity: 0.5; }
.import-check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.import-check .poster { width: 40px; border-radius: 6px; flex: none; }
.import-check .poster-empty { font-size: 0.5rem; padding: 1px; }
.import-info { min-width: 0; }
.import-actions { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.review-list { display: flex; flex-direction: column; gap: 12px; }
.review-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.candidates { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.candidate { flex: none; width: 92px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; text-align: left; scroll-snap-align: start; }
.candidate .poster { border-radius: 6px; }
.candidate .poster-empty { font-size: 0.6rem; }
.cand-title { font-size: 0.78rem; font-weight: 600; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sticky-action { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px); padding-top: 8px; }
.sticky-action .btn { background: #2b2618; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }

/* ---------- Leer, Laden, Toast, Dialog ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--dim); grid-column: 1 / -1; }
.empty h3 { color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1.05rem; }
.empty .row { margin-top: 12px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--dim); padding: 16px 0; }
.spin { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); transform: translate(-50%, 12px);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; opacity: 0;
  transition: opacity 0.2s, transform 0.2s; z-index: 50; width: max-content; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog.sheet {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; width: min(420px, calc(100vw - 32px));
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog.sheet .stack .btn { white-space: normal; }
.sync {
  position: fixed; top: calc(var(--safe-top) + 6px); left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; font-size: 0.75rem; color: var(--dim);
}

/* ---------- Footer, Tab-Leiste ---------- */
.attribution { max-width: 1100px; margin: 0 auto; padding: 16px 16px 24px; font-size: 0.72rem; color: var(--dim); border-top: 1px solid var(--border); }
.attribution p { margin: 0 0 4px; }
.attribution a { color: var(--dim); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: rgba(14, 16, 20, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--dim); text-decoration: none; font-size: 0.68rem; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent); }
