:root {
  --radius: 14px;
  --radius-s: 9px;
  --gutter: clamp(16px, 3vw, 32px);
  --topbar: 64px;
}

/* El reproductor es siempre oscuro, sea cual sea el tema de la página. */
:root, .player {
  --bg: #0c0d10;
  --surface: #15171c;
  --surface-2: #1e2127;
  --surface-3: #2a2e36;
  --line: rgb(255 255 255 / 9%);
  --text: #f3f4f6;
  --muted: #a0a6b1;
  --accent: #e8452a;
  --accent-strong: #f25a40;
  --gold: #ffc247;
  --gold-text: #ffc247;
  --ok: #4fd18b;
  --ok-soft: rgb(79 209 139 / 14%);
  --ok-text: #a6edc7;
  --danger: #ff6b6b;
  --danger-soft: rgb(255 107 107 / 13%);
  --danger-text: #ffb3b3;
  --topbar-bg: rgb(12 13 16 / 88%);
  --shadow: rgb(0 0 0 / 55%);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-2: #ececf0;
  --surface-3: #dcdce3;
  --line: rgb(16 18 24 / 11%);
  --text: #16181d;
  --muted: #5a606c;
  --accent: #d93a1e;
  --accent-strong: #bd2f16;
  --gold: #eda80c;
  --gold-text: #8a5d00;
  --ok: #157a48;
  --ok-soft: rgb(21 122 72 / 12%);
  --ok-text: #0f5d36;
  --danger: #c02626;
  --danger-soft: rgb(192 38 38 / 10%);
  --danger-text: #971c1c;
  --topbar-bg: rgb(245 245 247 / 88%);
  --shadow: rgb(16 18 24 / 18%);
  color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-2: #ececf0;
  --surface-3: #dcdce3;
  --line: rgb(16 18 24 / 11%);
  --text: #16181d;
  --muted: #5a606c;
  --accent: #d93a1e;
  --accent-strong: #bd2f16;
  --gold: #eda80c;
  --gold-text: #8a5d00;
  --ok: #157a48;
  --ok-soft: rgb(21 122 72 / 12%);
  --ok-text: #0f5d36;
  --danger: #c02626;
  --danger-soft: rgb(192 38 38 / 10%);
  --danger-text: #971c1c;
  --topbar-bg: rgb(245 245 247 / 88%);
  --shadow: rgb(16 18 24 / 18%);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; letter-spacing: -.015em; }
h2 { font-size: 1.15rem; line-height: 1.3; letter-spacing: -.01em; }
a { color: inherit; }
img, svg, video { display: block; }
code { padding: .1em .35em; border-radius: 5px; background: var(--surface-2); font-size: .88em; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ------------------------------ Controles base ------------------------------ */

input:not([type="checkbox"], [type="range"]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-2);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { border-color: var(--line); background: var(--surface-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { border-color: var(--danger); background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

.alert { margin: 14px 0; padding: 10px 14px; border-radius: var(--radius-s); font-size: .95rem; }
.alert-error { background: var(--danger-soft); color: var(--danger-text); }
.alert-ok { background: var(--ok-soft); color: var(--ok-text); }

/* ------------------------------ Barra superior ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 3vw, 32px);
  height: var(--topbar);
  padding: 0 var(--gutter);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.logo { display: inline-flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.logo svg { width: 32px; height: 32px; flex: none; }

.search { position: relative; width: 100%; max-width: 620px; margin: 0 auto; }
.search svg { position: absolute; top: 50%; left: 14px; width: 18px; height: 18px; translate: 0 -50%; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input { min-height: 42px; padding-left: 42px; border-radius: 999px; }

.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; border-radius: 50%; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-3); font-weight: 700; }
.usermenu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: 0 18px 48px var(--shadow);
}
.usermenu-panel p { padding: 8px 12px; font-weight: 600; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.usermenu-panel a, .usermenu-panel button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 7px;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--surface-3); }

/* ------------------------------ Catálogo ------------------------------ */

.page { padding: 20px var(--gutter) 56px; max-width: 1760px; margin: 0 auto; }
.page.narrow { max-width: 560px; }
.page > h1 { margin-bottom: 16px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin-bottom: 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips-small { margin-top: -10px; }
.chip {
  flex: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .94rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s;
}
.chip:hover { background: var(--surface-3); }
.chip.is-active { background: var(--text); color: var(--bg); }
.chips-small .chip { padding: 5px 13px; font-size: .86rem; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.sort label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.sort select { width: auto; min-height: 38px; padding: 5px 10px; color: var(--text); }

.results-count { margin-bottom: 12px; color: var(--muted); font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 28px 20px; }
.load-more { display: flex; width: fit-content; margin: 32px auto 0; }
.load-more[aria-busy="true"] { opacity: .6; pointer-events: none; }

.row { margin-bottom: 32px; }
.row h2 { margin-bottom: 12px; }
.row-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 300px);
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.row-scroll .card { scroll-snap-align: start; }

.card { display: block; min-width: 0; text-decoration: none; }
.thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(140deg, hsl(var(--hue, 220) 45% 26%), hsl(calc(var(--hue, 220) + 50) 40% 12%));
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: scale .3s ease; }
.card:hover .thumb img { scale: 1.04; }
.thumb-letter { font-size: 3rem; font-weight: 700; color: rgb(255 255 255 / 42%); }
.thumb-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 30%);
  opacity: 0;
  transition: opacity .15s;
}
.thumb-play svg { width: 46px; height: 46px; fill: #fff; filter: drop-shadow(0 2px 8px rgb(0 0 0 / 60%)); }
.card:hover .thumb-play, .card:focus-visible .thumb-play { opacity: 1; }
.thumb-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgb(0 0 0 / 78%);
  font-size: .78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.thumb-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgb(255 255 255 / 25%); }
.thumb-progress i { display: block; height: 100%; background: var(--accent); }

.card-body { padding: 10px 2px 0; }
.card-body h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.card-sub, .card-meta { color: var(--muted); font-size: .87rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card-meta { display: flex; gap: 10px; }
.star-note { display: inline-flex; align-items: center; gap: 3px; color: var(--gold-text); font-weight: 600; }
.star-note svg { width: 14px; height: 14px; fill: var(--gold); }

.empty { padding: 56px 16px; text-align: center; }
.empty h2 { margin-bottom: 6px; font-size: 1.3rem; }
.empty p { color: var(--muted); max-width: 52ch; margin: 0 auto; }

/* ------------------------------ Página de vídeo ------------------------------ */

.stage { background: #000; }
.player {
  --player-max: calc(100svh - var(--topbar) - 88px);
  position: relative;
  width: min(100%, calc(var(--player-max) * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  overflow: hidden;
  background: #000;
  color: #fff;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.player:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; }
.player video { width: 100%; height: 100%; object-fit: contain; }
.player-surface { position: absolute; inset: 0; }

.player-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin: -26px;
  border: 4px solid rgb(255 255 255 / 22%);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.is-loading .player-spinner { opacity: 1; animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

.player-bigplay {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  translate: -50% -50%;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 8px 28px rgb(0 0 0 / 45%);
}
.player-bigplay svg { width: 36px; height: 36px; fill: #fff; }
.is-playing .player-bigplay, .is-loading .player-bigplay { display: none; }

.player-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(0 0 0 / 82%);
  text-align: center;
  z-index: 4;
}

.player-toast {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 7px 14px;
  border-radius: 10px;
  background: rgb(0 0 0 / 74%);
  font-size: .9rem;
}
.player-toast button { padding: 2px 0; border: 0; background: none; color: #ff8a73; font-weight: 600; cursor: pointer; }

.player-next {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: rgb(0 0 0 / 80%);
  text-align: center;
}
.player-next div { display: flex; gap: 10px; margin-top: 8px; }

.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 36px 14px 6px;
  background: linear-gradient(transparent, rgb(0 0 0 / 82%));
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.show-controls .player-controls, .player:not(.is-playing) .player-controls { opacity: 1; pointer-events: auto; }
.player.is-playing:not(.show-controls) { cursor: none; }

.seek { position: relative; padding: 9px 0; cursor: pointer; touch-action: none; }
.seek-track { position: relative; height: 4px; border-radius: 4px; background: rgb(255 255 255 / 28%); transition: height .12s; }
.seek:hover .seek-track { height: 6px; }
.seek-buffer, .seek-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.seek-buffer { background: rgb(255 255 255 / 34%); }
.seek-fill { background: var(--accent); }
.seek-fill::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  translate: 0 -50%;
  border-radius: 50%;
  background: var(--accent);
}
.seek-tip {
  position: absolute;
  bottom: 24px;
  translate: -50% 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgb(0 0 0 / 88%);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.controls-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ctl {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.ctl:hover { background: rgb(255 255 255 / 14%); }
.ctl svg { width: 24px; height: 24px; fill: #fff; }
.ctl-text { width: auto; min-width: 48px; padding: 0 6px; font-size: .9rem; font-weight: 600; }
.ctl-text.is-on { box-shadow: inset 0 -3px 0 var(--accent); }
.i-pause, .i-muted { display: none; }
.is-playing .i-play { display: none; }
.is-playing .i-pause { display: block; }
.is-muted .i-vol { display: none; }
.is-muted .i-muted { display: block; }

.volume { display: flex; align-items: center; }
.volume input { width: 80px; accent-color: #fff; }
.time { margin-left: 8px; font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.controls-gap { flex: 1; }

.watch-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 32px; padding-top: 22px; }
.watch-layout:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
.watch-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; color: var(--muted); font-size: .94rem; }
.watch-meta a { color: var(--text); font-weight: 600; text-decoration: none; }
.watch-meta a:hover { text-decoration: underline; }
.watch-description { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); white-space: pre-line; overflow-wrap: anywhere; }

.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 16px; }
.rating-stars { display: flex; }
.rating-stars button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }
.rating-stars svg { width: 28px; height: 28px; fill: var(--surface-3); transition: fill .1s, scale .1s; }
.rating-stars button:hover svg { scale: 1.1; }
.rating-stars .is-on svg { fill: var(--gold); }
.rating-summary { color: var(--muted); font-size: .94rem; }

.related h2 { margin-bottom: 12px; }
.related-list { display: grid; gap: 14px; }
.related .card { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 12px; }
.related .thumb { border-radius: 10px; }
.related .thumb-letter { font-size: 1.8rem; }
.related .card-body { padding: 0; }
.related .card-body h3 { font-size: .94rem; }
.related .card-sub, .related .card-meta { font-size: .8rem; }

.player-watermark {
  position: absolute;
  z-index: 1;
  color: rgb(255 255 255 / 22%);
  font-size: clamp(.75rem, 1.6vw, 1rem);
  font-weight: 600;
  text-shadow: 0 1px 2px rgb(0 0 0 / 35%);
  pointer-events: none;
}
.player video::cue { background: rgb(0 0 0 / 72%); font-family: inherit; }
/* Los subtítulos suben cuando aparecen los controles para no quedar debajo. */
.player video::-webkit-media-text-track-container { transition: transform .2s; }
.show-controls video::-webkit-media-text-track-container, .player:not(.is-playing) video::-webkit-media-text-track-container { transform: translateY(-84px); }

.favorite { gap: 8px; margin-top: 14px; }
.favorite svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.favorite.is-on svg { fill: var(--accent); stroke: var(--accent); }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.list-item { display: grid; gap: 6px; align-content: start; min-width: 0; }
.link-button { padding: 4px 2px; border: 0; background: none; color: var(--muted); font-size: .86rem; text-decoration: underline; cursor: pointer; }
.link-button:hover { color: var(--text); }

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface-2); }
.theme-switch button { min-height: 36px; padding: 4px 6px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: .85rem; font-weight: 500; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.usermenu-panel .theme-switch { margin: 6px 4px 8px; background: var(--surface-3); }
.usermenu-panel .theme-switch button { display: block; width: auto; text-align: center; }
.usermenu-panel .theme-switch button:hover { background: none; color: var(--text); }
.usermenu-panel .theme-switch button[aria-pressed="true"]:hover { background: var(--surface); }
.account-first { margin-top: 16px; }
.account-first .theme-switch { margin-top: 10px; max-width: 320px; }
.account-action { margin-top: 10px; }

/* ------------------------------ Acceso ------------------------------ */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 24px 16px;
  background:
    radial-gradient(60rem 36rem at 15% -10%, rgb(255 84 54 / 17%), transparent 65%),
    radial-gradient(50rem 32rem at 100% 110%, rgb(255 194 71 / 8%), transparent 65%),
    var(--bg);
}
.login-box { width: 100%; max-width: 400px; padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.login-box .logo { margin-bottom: 24px; }
.login-sub { margin: 4px 0 18px; color: var(--muted); }
.login-box form { display: grid; gap: 14px; }
.login-box label, .stack label, .form-grid label { display: grid; gap: 5px; font-size: .92rem; color: var(--muted); }
.login-box input, .stack input, .stack select, .stack textarea, .form-grid input { color: var(--text); }
.login-box .btn { width: 100%; margin-top: 6px; }

/* ------------------------------ Paneles ------------------------------ */

.panel { margin-bottom: 20px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel h2 { margin-bottom: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; justify-items: start; }
.stack label { width: 100%; }
.error-page { text-align: center; padding-top: 72px; }
.error-page .btn { margin-top: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: .9rem; }
.stat span { display: block; color: var(--text); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.badge { display: inline-block; margin-right: 6px; padding: 1px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: .8rem; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--danger-soft); color: var(--danger); }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 20px; }
.ranking { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.ranking li { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); counter-increment: rank; }
.ranking li:first-child { border-top: 0; }
.ranking li::before { content: counter(rank); width: 1.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.ranking a { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-decoration: none; }
.ranking a:hover { text-decoration: underline; }
.ranking span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; }
th { border-top: 0; color: var(--muted); font-weight: 500; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel .toolbar, .category-row .toolbar { margin-bottom: 0; }
.toolbar input { min-width: 0; flex: 1; }

.edit-list { display: grid; gap: 8px; margin-top: 14px; }
.edit-item { border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.edit-item summary { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 16px; padding: 12px 16px; cursor: pointer; }
.edit-item[open] summary { border-bottom: 1px solid var(--line); }
.edit-item form { padding: 14px 16px; }
.edit-title { font-weight: 600; overflow-wrap: anywhere; }

.category-list { display: grid; gap: 10px; }
.category-row { display: flex; gap: 10px; align-items: center; }
.category-row .toolbar { flex: 1; min-width: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: end; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid .check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.form-grid .check input { width: 20px; height: 20px; accent-color: var(--accent); }

.access-box { grid-column: 1 / -1; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); min-width: 0; }
.access-box legend { padding: 0 6px; color: var(--muted); font-size: .92rem; }
.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 14px; margin-top: 6px; }
.form-grid .access-box .check { display: flex; align-items: center; gap: 8px; min-height: 40px; color: var(--text); font-size: .95rem; }
.access-box .check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.access-box.is-all .access-grid { opacity: .45; }
.access-box details { margin-top: 8px; color: var(--muted); font-size: .9rem; }
.access-box details summary { padding: 4px 0; cursor: pointer; }
.access-box details label { margin-top: 6px; }
.edit-item .inline-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 16px 14px; }
.edit-item .inline-actions form { padding: 0; }

.pager { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }

/* ------------------------------ Adaptación a móvil ------------------------------ */

@media (max-width: 1080px) {
  .watch-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

@media (max-width: 680px) {
  :root { --topbar: 58px; }
  .logo span { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .stage { position: sticky; top: var(--topbar); z-index: 10; }
  .player { --player-max: 100vw; }
  .player-controls { padding: 28px 6px 2px; }
  .volume input { display: none; }
  .time { margin-left: 2px; font-size: .8rem; }
  .ctl { width: 40px; height: 40px; }
  .ctl[data-skip] { display: none; }
  .ctl-text { min-width: 42px; }
  .player-bigplay { width: 62px; height: 62px; }
  .related .card { grid-template-columns: 140px minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .category-row { flex-wrap: wrap; }
  .login-box { padding: 24px; }
}

/* En horizontal el vídeo ocupa toda la altura disponible. */
@media (orientation: landscape) and (max-height: 520px) {
  .watch-page .topbar { position: static; }
  .player { --player-max: 100svh; }
}

@media (hover: none) {
  .thumb-play { display: none; }
}

/* ------------------------------ Transición de miniatura a reproductor ------------------------------ */

@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: .28s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { transition: none !important; }
  .is-loading .player-spinner { animation-duration: 2s; }
}

/* ---------------------------- Audio, calidad y TV ---------------------------- */
.player-settings { position: relative; }
.player-settings[hidden] { display: none; }
.player-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 5;
  width: 230px;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--radius-s);
  background: rgb(18 18 22 / 95%);
  color: #fff;
}
.player-menu p { padding: 8px 10px 4px; font-size: .8rem; color: rgb(255 255 255 / 65%); }
.player-menu button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.player-menu button:hover { background: rgb(255 255 255 / 12%); }
.player-menu button[aria-pressed="true"] { box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }

/* ---------------------------- Miniaturas de la barra ---------------------------- */
.seek-tip { display: grid; justify-items: center; gap: 4px; }
.seek-tip[hidden] { display: none; }
.seek-preview { display: block; border-radius: 4px; background-repeat: no-repeat; }
.seek-preview[hidden] { display: none; }

/* ---------------------------- Series ---------------------------- */
.series-head { display: flex; gap: 24px; align-items: flex-start; margin-bottom: 28px; }
.series-poster { width: 180px; flex: none; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius); }
.series-kicker { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.series-overview { max-width: 70ch; margin: 12px 0 16px; }
.series-head .btn { margin-top: 12px; }
button.chip { font: inherit; cursor: pointer; }
.episode-list { display: grid; gap: 14px; margin-top: 16px; }
.episode-list[hidden] { display: none; }
.episode { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; text-decoration: none; padding: 8px; border-radius: var(--radius-s); }
.episode:hover { background: var(--surface-2); }
.episode-body h3 { margin-bottom: 4px; }
.episode-text { margin-top: 6px; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------------------------- PIN y subida ---------------------------- */
.pin-box { margin-top: 8vh; }
.pin-box input.pin-input { letter-spacing: .4em; font-size: 1.3rem; text-align: center; }
.settings-action { margin-top: 12px; }
.dropzone { position: relative; display: grid; place-items: center; width: 100%; min-height: 150px; padding: 24px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.is-over, .dropzone:hover { border-color: var(--accent); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-list { display: grid; gap: 10px; margin-top: 16px; list-style: none; padding: 0; }
.upload-list li { display: grid; grid-template-columns: minmax(0, 1fr) 160px minmax(90px, 200px); gap: 12px; align-items: center; overflow-wrap: anywhere; }
.upload-list progress { width: 100%; accent-color: var(--accent); }
.upload-list small { color: var(--muted); }

@media (max-width: 680px) {
  .series-head { flex-direction: column; }
  .series-poster { width: 130px; }
  .episode { grid-template-columns: 130px 1fr; gap: 10px; padding: 4px; }
  .episode-text { -webkit-line-clamp: 2; }
  .upload-list li { grid-template-columns: 1fr; gap: 4px; }
  .category-row, .category-row .toolbar { flex-wrap: wrap; }
}
