/* Medflix Web – schlichtes Layout, hell und dunkel; als einzige Fremdbibliothek hls.js für HLS-Streams. */
:root {
  --bg: #f5f5f7; --surface: #fff; --text: #1d1d1f; --muted: #6e6e73; --line: #d2d2d7;
  --accent: #0a66d8; --red: #d70015; --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1c1e; --surface: #2c2c2e; --text: #f5f5f7; --muted: #98989d; --line: #3a3a3c; --accent: #4c9bff; --red: #ff453a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red); }
.spacer { flex: 1; }
button, .button, input, select {
  font: inherit; color: inherit; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: .4rem .75rem;
}
button, .button { cursor: pointer; display: inline-block; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.card { background: var(--surface); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: 0 1px 3px rgb(0 0 0 / .08); }

/* Kopfzeile */
/* Drei Spalten: links Marke, Mitte Bereiche, rechts Hilfe und Konto */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { justify-self: start; display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.topbar-end { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; }
/* So hoch wie die Bereichs-Schaltflächen: Zeilenhöhe + Innenabstand + Rahmen */
.brand img { display: block; width: calc(1.45rem + .5rem + 4px); height: calc(1.45rem + .5rem + 4px); border-radius: 8px; }
.main-nav { display: flex; gap: .25rem; background: var(--bg); border-radius: 9px; padding: 3px; }
.main-nav a { padding: .25rem .8rem; border-radius: 7px; color: var(--text); border: 2px solid transparent; }
.main-nav a:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); text-decoration: none; }
.main-nav a[aria-current] { background: var(--surface); border-color: var(--accent); font-weight: 600; }
.topbar-end a[aria-current] { font-weight: 600; }
.account-menu { position: relative; }
.account-menu summary { cursor: pointer; list-style: none; }
.account-menu .menu { position: absolute; right: 0; top: 1.8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .5rem; display: grid; gap: .4rem; min-width: 11rem; }
.account-menu .menu button { width: 100%; text-align: left; }

/* Bibliothek: Seitenleiste + Inhalt */
.library { display: grid; grid-template-columns: 16rem 1fr; min-height: calc(100vh - 3.2rem); }
.sidebar { border-right: 1px solid var(--line); padding: .8rem; overflow-y: auto; max-height: calc(100vh - 3.2rem); position: sticky; top: 3.2rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: flex; justify-content: space-between; align-items: baseline; gap: .9rem; padding: .3rem .5rem; border-radius: 6px; color: var(--text); line-height: 1.3; }
.sidebar li a[aria-current] { background: var(--accent); color: #fff; }
.content { padding: 1rem 1.4rem 2rem; min-width: 0; }

/* Anmeldung */
.centered { display: grid; place-items: center; min-height: 100vh; }
.narrow { max-width: 28rem; margin: 2rem auto; }
.login, .narrow .card { display: grid; gap: .8rem; width: min(24rem, 92vw); }
.login label, .narrow label { display: grid; gap: .3rem; }
.narrow label.check { display: flex; gap: .5rem; align-items: center; }
.narrow h2 { margin: .6rem 0 0; }

/* Seiten */
.page { max-width: 72rem; margin: 0 auto; padding: 1rem 1.2rem 3rem; }
.page section { margin-top: 1.5rem; }
.page h2 .small { font-weight: 400; margin-left: .5rem; }
.ok { color: #248a3d; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.prose { white-space: pre-line; max-width: 46rem; }
.prose-page { max-width: 46rem; }
.prose-page .note { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-radius: 8px; padding: .7rem .9rem; }
.help-table { border-collapse: collapse; background: var(--surface); border-radius: 8px; }
.help-table th { text-align: left; font-family: ui-monospace, Menlo, monospace; padding: .3rem .9rem; white-space: nowrap; }
.help-table td { padding: .3rem .9rem; }
.footer { color: var(--muted); font-size: .8rem; text-align: center; padding: 1.5rem; }

/* Suche mit Vorschlägen */
.search { position: relative; display: flex; gap: .5rem; margin: .4rem 0 1rem; }
.search input { flex: 1; }
.suggestions { position: absolute; top: 100%; left: 0; right: 0; z-index: 3; list-style: none; margin: .3rem 0 0; padding: .3rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / .15); }
.suggestions[hidden] { display: none; }
.suggestions li { padding: .4rem .6rem; border-radius: 6px; cursor: pointer; display: grid; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.suggestions .detail { color: var(--muted); font-size: .8rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chips:empty { display: none; }
.chips a { border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem; background: var(--surface); color: var(--text); font-size: .9rem; }
.chips a:hover { border-color: var(--accent); text-decoration: none; }

/* Filme als Kacheln mit Vorschaubild, wie die Filmkarten der App */
.films { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .9rem; }
.film { display: grid; align-content: start; height: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden;
  color: var(--text); border: 1px solid transparent; box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.film-text { display: grid; gap: .15rem; padding: .55rem .8rem .7rem; }
/* Platzhalter in 16:9, bis das Bild da ist oder wenn es keins gibt */
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 25%, var(--surface)), var(--line)); }
.thumb img, .hero-image img, .teaser-image img, .follow-cover img, .detail-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.progress.on-thumb { position: absolute; left: .5rem; right: .5rem; bottom: .45rem; margin: 0; background: rgb(255 255 255 / .35); }
/* Reihen auf der Startseite: waagerecht scrollen */
.shelf { list-style: none; padding: 0 0 .4rem; margin: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(14rem, 16rem);
  gap: .9rem; overflow-x: auto; scroll-snap-type: x proximity; }
.shelf li { scroll-snap-align: start; }
/* Karussell: eine Folge je gefolgter Sendung */
.carousel { position: relative; margin: .5rem 0 1rem; }
.carousel-track { display: flex; gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; }
.carousel-track::-webkit-scrollbar { display: none; }
.hero { position: relative; flex: 0 0 100%; scroll-snap-align: center; border-radius: 18px; overflow: hidden; aspect-ratio: 21 / 9; max-height: 28rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 40%, #000), #111); }
.hero-image { position: absolute; inset: 0; }
.hero-text { position: absolute; left: 1.2rem; bottom: 1.2rem; max-width: min(32rem, 80%); display: grid; gap: .3rem; justify-items: start;
  padding: .9rem 1.1rem; border-radius: 14px; background: rgb(20 20 22 / .62); backdrop-filter: blur(14px); color: #fff; }
.hero-text .film-topic, .hero-text .film-meta { color: rgb(255 255 255 / .75); }
.hero-title { color: #fff; font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.carousel-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 2.6rem; height: 2.6rem; border-radius: 50%; padding: 0;
  font-size: 1.6rem; line-height: 1; background: rgb(20 20 22 / .5); color: #fff; border: 0; opacity: 0; transition: opacity .2s; }
.carousel:hover .carousel-arrow, .carousel-arrow:focus-visible { opacity: 1; }
.carousel-arrow.prev { left: .8rem; } .carousel-arrow.next { right: .8rem; }
.carousel-dots { position: absolute; right: 1.2rem; bottom: 1.2rem; display: flex; gap: .35rem; padding: .45rem .6rem; border-radius: 999px; background: rgb(20 20 22 / .5); }
.carousel-dots button { width: .4rem; height: .4rem; padding: 0; border: 0; border-radius: 999px; background: rgb(255 255 255 / .45); transition: width .2s; }
.carousel-dots button[aria-current] { width: 1.1rem; background: #fff; }
.welcome { display: grid; gap: .4rem; margin: 1rem 0; }
.welcome .chips form { display: inline; }
/* Gefolgt */
.follow-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.follow-list li { display: grid; grid-template-columns: 9rem 1fr auto; gap: 1rem; align-items: center; padding: .6rem; }
.follow-cover { display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 25%, var(--surface)), var(--line)); }
.follow-text { display: grid; gap: .15rem; color: var(--text); }
.follow-actions { display: flex; gap: .4rem; align-items: center; }
.follow-actions form { display: inline; }
button:disabled { opacity: .4; cursor: default; }
/* Editor */
.narrow.wide { max-width: 40rem; }
.narrow.wide .card { width: auto; }
.toggles { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.narrow label.toggle { display: inline-flex; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem; cursor: pointer; background: var(--surface); }
.toggle input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.preview { margin: 0; padding-left: 1.1rem; }
.editor details summary { cursor: pointer; font-weight: 600; }
.delete { margin-top: 1rem; text-align: center; }
.danger { color: var(--red); }
.detail-image { aspect-ratio: 16 / 9; max-width: 56rem; border-radius: 18px; overflow: hidden; margin-bottom: 1rem; background: var(--line); }
.teaser-image { display: block; aspect-ratio: 21 / 9; border-radius: 10px; overflow: hidden; margin-bottom: .6rem; background: var(--line); }
a.film:hover { text-decoration: none; border-color: var(--accent); }
.film-topic { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.film-topic a { color: inherit; }
.film-title { font-weight: 600; }
.film-meta { color: var(--muted); font-size: .82rem; }
.progress { display: block; height: 4px; background: var(--line); border-radius: 2px; margin-top: .3rem; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.progress.wide { display: inline-block; width: 14rem; vertical-align: middle; }
.show-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.teaser { display: grid; gap: .2rem; color: var(--text); margin-bottom: 1rem; padding: .8rem; max-width: 56rem; }
a.teaser:hover { text-decoration: none; outline: 1px solid var(--accent); }
.teaser-title { font-size: 1.4rem; font-weight: 700; }

/* Filmdetails */
.detail h1 { margin-top: .1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.actions form { display: inline; }
.button.disabled { color: var(--muted); cursor: default; }
.button.disabled:hover { border-color: var(--line); }

/* Player */
.player { padding: 0; overflow: hidden; position: relative; }
.player video { width: 100%; display: block; background: #000; aspect-ratio: 16 / 9; }
.player-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .6rem .9rem; }
.qualities a { margin-right: .6rem; font-size: .9rem; }
.qualities a[aria-current] { font-weight: 700; color: var(--text); }
.resume-message { position: absolute; top: .8rem; left: 50%; transform: translateX(-50%); margin: 0; padding: .35rem .8rem;
  border-radius: 999px; background: rgb(0 0 0 / .65); color: #fff; font-size: .9rem; pointer-events: none; }
.resume-message[hidden] { display: none; }

/* Schmale Bildschirme: Seitenleiste über dem Inhalt */
@media (max-width: 760px) {
  .library { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar ul { display: flex; flex-wrap: wrap; gap: .2rem; }
  .topbar { display: flex; flex-wrap: wrap; gap: .6rem; }
  .topbar-end { flex: 1; }
  /* Bereiche in eigener Zeile über die ganze Breite */
  .main-nav { order: 3; width: 100%; }
  .main-nav a { flex: 1; text-align: center; padding: .25rem .4rem; }
  .films { grid-template-columns: 1fr; }
  .hero { aspect-ratio: 4 / 3; }
  .hero-text { left: .6rem; right: .6rem; bottom: .6rem; max-width: none; }
  .hero-title { font-size: 1.15rem; }
  .carousel-dots { display: none; }
  .follow-list li { grid-template-columns: 6rem 1fr; }
  .follow-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Empfehlungen */
.unread { color: var(--red); }
.note-quote { font-style: italic; }
.narrow textarea { font: inherit; color: inherit; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: .5rem .7rem; width: 100%; }
.narrow .card + .card { margin-top: 1rem; }
.device { display: flex; gap: .8rem; align-items: center; justify-content: space-between; }
