:root {
  --bg: #f5f4f8;
  --surface: #ffffff;
  --surface-2: #ecebf2;
  --text: #1c1b22;
  --muted: #66647a;
  --line: #e0dee9;
  --accent: #4f46b8;
  --accent-ink: #ffffff;
  --accent-soft: #e6e4f8;
  --red: #c2372b;
  --red-soft: #fbe7e4;
  --orange: #b8630f;
  --orange-soft: #fcefdf;
  --green: #2f8552;
  --green-soft: #e0f1e6;
  --kino: #b03a7a;
  --kino-soft: #f8e3ef;
  --grey: #a3a1b0;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131218;
    --surface: #1d1c24;
    --surface-2: #27262f;
    --text: #ecebf2;
    --muted: #a3a1b4;
    --line: #34323f;
    --accent: #a59cff;
    --accent-ink: #15122e;
    --accent-soft: #2a2747;
    --red: #f07366;
    --red-soft: #3a211e;
    --orange: #f0a252;
    --orange-soft: #3a2b1a;
    --green: #6cc38f;
    --green-soft: #1d3326;
    --kino: #f08cc4;
    --kino-soft: #3a1f30;
    --grey: #6f6d7c;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
    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.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.sync { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); }
.sync.live .dot { background: var(--green); }
.sync.off .dot { background: var(--orange); }
.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; fill: currentColor;
}
.icon-btn:active { background: var(--surface-2); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 44px; min-width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 10;
}
.menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-radius: 8px;
}
.menu button:hover, .menu button:active { background: var(--surface-2); }
.menu-info { font-size: 13px; color: var(--muted); padding: 8px 12px 6px; word-break: break-all; }
.menu-info:empty { display: none; }

.banner {
  max-width: 608px; margin: 0 auto 8px; padding: 10px 12px; border-radius: 10px;
  background: var(--orange-soft); color: var(--text); font-size: 14px;
}
@media (max-width: 640px) { .banner { margin: 0 16px 8px; } }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 0; }

/* Suche + Filter */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 12px; fill: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input, .search input:focus {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 11px 0; outline: none; min-height: 0;
}
.search.big input { font-size: 17px; padding: 13px 0; }
.filterrow { display: flex; gap: 8px; }
.filterrow .search { flex: 1; min-width: 0; }
.filterrow select {
  width: auto; max-width: 44%; min-height: 0; padding: 0 28px 0 10px;
  background-color: var(--surface); border-radius: 12px; font-size: 15px;
}
.filterrow select.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px;
  margin: 0 -16px; scrollbar-width: none; align-items: center;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; white-space: nowrap;
}
.chip .c { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[aria-pressed="true"] .c { color: inherit; opacity: .7; }
.dienst-chips { padding-top: 0; padding-bottom: 0; }
.chip-sep { flex: none; width: 1px; height: 22px; background: var(--line); }

/* Liste */
.group h3, h3.sec {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 18px 4px 8px; font-weight: 600;
}
h3.sec { margin: 10px 0 0; }
.group h3 .c { font-weight: 400; margin-left: 4px; }
.group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.karte {
  position: relative; display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.karte .main {
  flex: 1; min-width: 0; border: 0; background: transparent; text-align: left;
  padding: 8px; display: flex; gap: 12px; align-items: flex-start;
}
.karte .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-top: 2px; }
.karte .name { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.karte .meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.karte .st { font-size: 13px; font-weight: 600; }
.karte .seen {
  flex: none; width: 52px; border: 0; border-left: 1px solid var(--line); background: transparent;
  display: grid; place-items: center; color: var(--muted);
}
.karte .seen span {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--grey);
  display: grid; place-items: center; font-size: 15px; font-weight: 700; color: transparent;
}
.karte .seen[aria-pressed="true"] span { background: var(--green); border-color: var(--green); color: #fff; }
.glocke { width: 14px; height: 14px; fill: var(--muted); flex: none; }

/* Poster */
.poster {
  flex: none; width: 58px; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  background: linear-gradient(150deg, var(--accent-soft), var(--surface-2));
  display: grid; place-items: center; position: relative;
  color: var(--accent); font-weight: 700; font-size: 18px; letter-spacing: .02em;
}
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster.klein { width: 44px; border-radius: 6px; font-size: 14px; }
.poster.gross { width: 108px; border-radius: 12px; font-size: 30px; box-shadow: var(--shadow); }

/* Anbieter-Logos */
.logos { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; overflow: hidden; flex: none;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff;
  background: var(--grey); position: relative;
}
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo.gross { width: 40px; height: 40px; border-radius: 10px; font-size: 13px; }
.logos .mehr { font-size: 12px; color: var(--muted); margin-left: 2px; }
.logos .art { font-size: 12px; color: var(--muted); margin-right: 2px; }

/* Status-Farben */
.st.abo { color: var(--green); }
.st.leihen { color: var(--orange); }
.st.kino, .st.bald { color: var(--kino); }
.st.nichts, .st.offen { color: var(--muted); font-weight: 500; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.neu { background: var(--accent-soft); color: var(--accent); }

.empty, .loading { text-align: center; color: var(--muted); padding: 48px 24px; margin: 0; }
.quelle { text-align: center; font-size: 12px; color: var(--muted); padding: 20px 16px 0; }
.quelle a { color: inherit; }

/* Plus-Knopf */
.fab {
  position: fixed; z-index: 4; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 6px;
  padding: 14px 20px 14px 16px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); fill: currentColor;
  font-weight: 600; box-shadow: 0 6px 20px rgb(0 0 0 / .2);
}

/* Dialoge */
dialog {
  border: 0; padding: 0; background: var(--surface); color: var(--text);
  width: 100%; max-width: 520px; max-height: 92dvh; border-radius: 20px;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
@media (max-width: 600px) {
  dialog {
    margin: auto 0 0; max-width: none; border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
dialog.small { max-width: 420px; }
dialog.full { width: 100%; max-width: 640px; height: 100dvh; max-height: 100dvh; margin: 0 auto; border-radius: 0; }
@media (min-width: 700px) { dialog.full { height: auto; min-height: 60dvh; max-height: 92dvh; margin: auto; border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.pad { padding: 16px; display: grid; gap: 12px; }
.pad h2 { margin: 0; font-size: 20px; }
.pad p { margin: 0; }
.suche-pad { padding-top: calc(12px + env(safe-area-inset-top)); align-content: start; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  font-size: 16px; min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button.primary, button.secondary, button.danger {
  border-radius: 12px; padding: 12px 18px; font-weight: 600; border: 1px solid transparent;
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button.secondary { background: var(--surface-2); border-color: var(--line); }
button.danger { background: transparent; color: var(--red); border-color: var(--line); }
button.wide { width: 100%; }
button:disabled { opacity: .55; }
.stack { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
.callout { background: var(--orange-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.push-status { font-weight: 600; }
.arten { display: grid; gap: 8px; }

/* Suchtreffer */
.treffer { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.treffer button {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  border: 0; background: var(--bg); border-radius: 12px; padding: 8px;
}
.treffer button:active { background: var(--surface-2); }
.treffer .txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.treffer .name { font-weight: 600; line-height: 1.25; }
.treffer .meta { font-size: 13px; color: var(--muted); }
.treffer .ov { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.treffer .drauf { color: var(--green); font-weight: 600; font-size: 13px; }

/* Detail */
.dt { position: relative; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.dt-bild {
  aspect-ratio: 16 / 9; max-height: 260px; width: 100%; position: relative; overflow: hidden;
  background: linear-gradient(150deg, var(--accent), var(--kino));
}
.dt-bild img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dt-bild::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgb(0 0 0 / .25), transparent 40%, transparent 60%, var(--surface)); }
.dt-top { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; gap: 8px; z-index: 1; }
.icon-btn.round { background: rgb(0 0 0 / .45); color: #fff; fill: #fff; }
.dt-body { padding: 0 16px 16px; display: grid; gap: 14px; margin-top: -64px; position: relative; }
.dt-kopf { display: flex; gap: 14px; align-items: flex-end; }
.dt-kopf-text { flex: 1; min-width: 0; display: grid; gap: 4px; padding-bottom: 2px; }
.dt-kopf h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.dt-meta { margin: 0; font-size: 14px; color: var(--muted); }
.dt-status { margin: 0; font-size: 14px; font-weight: 600; }
.dt-status.st.abo { color: var(--green); }
.dt-aktionen { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 9px 14px; font-size: 15px; font-weight: 600; fill: currentColor;
}
.toggle svg { width: 18px; height: 18px; }
.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.toggle.gesehen[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.toggle.gross { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.anbieter-block { display: grid; gap: 8px; }
.anbieter-block h3 { margin: 4px 0 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.anbieter-block h3 .hint { font-weight: 400; font-size: 13px; color: var(--muted); }
.anbieter-liste { display: flex; flex-wrap: wrap; gap: 8px; }
.anbieter {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; font-size: 14px;
}
.anbieter.mein { border-color: var(--accent); }
.anbieter .logo { width: 32px; height: 32px; }
.kein-anbieter { background: var(--bg); border-radius: 12px; padding: 12px; font-size: 14px; color: var(--muted); margin: 0; }
.kino-box { background: var(--kino-soft); border-radius: 12px; padding: 12px; font-size: 14px; margin: 0; }
.kino-box b { color: var(--kino); }
.dt-geprueft { margin: -4px 0 0; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dt-geprueft button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; font-size: 13px; }
.dt-text { margin: 0; font-size: 15px; line-height: 1.5; }
.verlauf { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.verlauf li { display: flex; justify-content: space-between; gap: 10px; }
.verlauf li span:last-child { color: var(--muted); white-space: nowrap; }
.who-info { font-size: 13px; color: var(--muted); margin: 0; }
.dt-quelle { font-size: 12px; color: var(--muted); margin: 0; text-align: center; }

/* Neu */
.ereignis {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 12px 8px 8px;
}
.ereignis .txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ereignis .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ereignis .was { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ereignis .was .logo { width: 22px; height: 22px; border-radius: 6px; font-size: 9px; }
.ereignis.weg .was { color: var(--muted); }
.ereignis.weg { opacity: .8; }
.ereignis .neu-punkt { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }

/* Dienste-Auswahl */
.dienste { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.dienst {
  display: grid; justify-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg); font-size: 12px; line-height: 1.2; text-align: center;
  position: relative;
}
.dienst span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.dienst small { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: -2px; }
.dienst[aria-pressed="true"] small { color: var(--accent); }
.dienst[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.dienst[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 4px; right: 6px; font-size: 12px; color: var(--accent); font-weight: 700;
}

/* Anmeldung */
.login { padding: 32px 16px; display: grid; place-items: center; }
.login .card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow); padding: 28px 20px; display: grid; gap: 14px; text-align: center;
}
.login .card img { justify-self: center; }
.login h2, .login p { margin: 0; }
.login label { text-align: left; }
.error { color: var(--red); font-size: 14px; }

/* Untere Reiter */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  position: relative; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 9px; font-size: 12px; fill: currentColor;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700;
}

/* Hinweis unten */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(146px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  background: var(--text); color: var(--bg);
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); width: max-content; font-size: 15px;
}
.toast button { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; padding: 0; }
@media (prefers-color-scheme: dark) { .toast button { color: var(--accent-ink); } }
