/* Pelis — biblioteca de streaming personal */
:root {
  --bg: #0a0a0c;
  --bg-raise: #16161a;
  --bg-raise-2: #1f1f24;
  --bg-press: #2a2a31;
  --line: rgba(255, 255, 255, .08);
  --fg: #f5f5f7;
  --fg-2: #a1a1aa;
  --fg-3: #8b8b94;
  --accent: #e5484d;
  --accent-soft: rgba(229, 72, 77, .16);
  --ok: #3dd68c;
  --warn: #f5a524;
  --danger: #ff6369;
  --radius: 10px;
  --radius-lg: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --gutter: max(16px, var(--safe-l));
  --topbar-h: 52px;
  --tabbar-h: 56px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
::selection { background: var(--accent); color: #fff; }
input, textarea { caret-color: var(--accent); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 1em; height: 1em; flex: none; }
img { display: block; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.num, time { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

@media (hover: hover) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: #2c2c33; border-radius: 10px; border: 2px solid var(--bg); }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* ---------- barra superior ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) max(8px, var(--safe-r)) 0 max(8px, var(--safe-l));
  display: flex; align-items: center; gap: 4px;
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
  border-bottom: 1px solid transparent;
}
.topbar::before { /* degradado para que el texto se lea sobre la portada */
  content: ""; position: absolute; inset: 0 0 -24px 0; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(10, 10, 12, .72), rgba(10, 10, 12, 0));
  transition: opacity .25s var(--ease);
}
.topbar.solid {
  background: rgba(16, 16, 19, .78);
  -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px);
  border-bottom-color: var(--line);
}
.topbar.solid::before { opacity: 0; }
.brand {
  font: 800 22px/1 var(--display); letter-spacing: -.03em; padding: 6px 8px;
  color: var(--fg);
}
.brand::after { content: "."; color: var(--accent); }
.topbar-title {
  position: absolute; left: 64px; right: 64px; text-align: center;
  font: 600 16px/1 var(--display); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .2s var(--ease); pointer-events: none;
}
.topbar.titled .topbar-title { opacity: 1; }
.topbar.has-back .brand { display: none; }
#add { margin-left: auto; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; font-size: 22px; color: var(--fg);
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.iconbtn:active { background: rgba(255, 255, 255, .12); transform: scale(.94); }
@media (hover: hover) { .iconbtn:hover { background: rgba(255, 255, 255, .08); } }
.iconbtn.sm { width: 32px; height: 32px; font-size: 18px; background: var(--bg-raise-2); color: var(--fg-2); }
.iconbtn.glass { background: rgba(30, 30, 34, .6); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }

/* ---------- barra de pestañas ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(16, 16, 19, .82);
  -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 500; letter-spacing: .01em; color: var(--fg-3);
  transition: color .15s var(--ease);
}
.tabbar a svg { font-size: 24px; }
.tabbar a[aria-current="page"] { color: var(--fg); }
.tabbar a[aria-current="page"] svg { color: var(--accent); }
.tabicon { position: relative; display: inline-flex; }
.badge {
  position: absolute; top: -5px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff;
  font: 700 11px/18px var(--sans); text-align: center; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px #101013;
}

/* ---------- contenedor de vistas ---------- */
main {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 28px);
}
main.padded { padding-top: calc(var(--topbar-h) + var(--safe-t)); }
.view-enter { animation: enter .22s var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

.large-title {
  font: 800 32px/1.1 var(--display); letter-spacing: -.025em;
  margin: 6px var(--gutter) 14px;
}
.section { margin-top: 28px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0 var(--gutter) 10px;
}
.section-head h2 { font: 700 19px/1.2 var(--display); letter-spacing: -.015em; margin: 0; }
.section-head .aside { font-size: 13px; color: var(--fg-2); }

/* ---------- portada destacada ---------- */
.hero {
  position: relative; isolation: isolate;
  height: min(72svh, 640px); min-height: 440px;
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.hero-img {
  position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover;
  animation: settle 1.4s var(--ease) both;
}
@keyframes settle { from { transform: scale(1.06); opacity: .4; } }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(10,10,12,0) 30%, rgba(10,10,12,.55) 62%, var(--bg) 100%),
    linear-gradient(90deg, rgba(10,10,12,.35), rgba(10,10,12,0) 60%);
}
.hero-body { width: 100%; padding: 0 var(--gutter) 6px; }
.hero-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--fg); margin-bottom: 8px;
}
.hero-tag i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.hero h1 {
  font: 800 30px/1.08 var(--display); letter-spacing: -.025em; margin: 0;
  max-width: 18ch; text-wrap: balance; overflow-wrap: anywhere;
  text-shadow: 0 2px 16px rgba(0,0,0,.35);
}
.meta-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  font-size: 13px; color: var(--fg-2); margin-top: 8px;
}
.meta-line .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--fg-3); }
.pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid rgba(255,255,255,.28); color: var(--fg);
}
.pill.new { border-color: transparent; background: var(--accent); color: #fff; }
.pill.seen { border-color: transparent; background: rgba(255,255,255,.12); color: var(--fg-2); }
.hero-progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--fg-2); max-width: 360px; }
.hero-progress .bar { flex: 1; }
.hero-actions { display: flex; gap: 10px; margin-top: 16px; }
.hero-actions .btn { flex: 1; max-width: 200px; }

/* ---------- botones ---------- */
.btn {
  height: 46px; padding: 0 20px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 650; font-size: 15.5px; letter-spacing: -.005em; white-space: nowrap;
  transition: transform .15s var(--ease), background-color .15s var(--ease), opacity .15s var(--ease);
}
.btn svg { font-size: 19px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.play { background: var(--fg); color: #0a0a0c; }
.btn.play:active { background: #d9d9de; }
.btn.secondary { background: rgba(255,255,255,.14); color: var(--fg); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.btn.secondary:active { background: rgba(255,255,255,.22); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: #cf3d42; }
.btn.danger { background: var(--danger); color: #1a0506; }
.btn.ghost { background: transparent; color: var(--fg-2); }
.btn.block { width: 100%; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn.tinted { background: var(--bg-raise-2); color: var(--fg); }
.btn.tinted:active { background: var(--bg-press); }
@media (hover: hover) {
  .btn.play:hover { background: #e6e6ea; }
  .btn.secondary:hover { background: rgba(255,255,255,.2); }
  .btn.primary:hover { background: #ee5a5f; }
  .btn.tinted:hover { background: var(--bg-press); }
}
.btn.loading { pointer-events: none; }
.btn.loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn.loading svg { display: none; }
@keyframes spin { to { transform: rotate(1turn); } }
.link { color: var(--accent); font-weight: 600; }

/* ---------- filas horizontales ---------- */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(44vw, 240px); gap: 10px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  padding: 0 var(--gutter) 4px; scroll-padding: 0 var(--gutter);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }

.card { display: block; min-width: 0; transition: transform .15s var(--ease); }
.card:active { transform: scale(.97); }
.frame {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-raise-2);
}
.frame img { width: 100%; height: 100%; object-fit: cover; transition: opacity .3s var(--ease); }
.frame img.loading { opacity: 0; }
.frame::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); pointer-events: none; }
.frame .bar { position: absolute; left: 8px; right: 8px; bottom: 8px; }
.frame .pill { position: absolute; top: 8px; left: 8px; }
.frame .dur {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 5px;
  background: rgba(0,0,0,.66); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.frame .bar ~ .dur { display: none; }
.card-title {
  margin-top: 8px; font-size: 14px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.card-sub { margin-top: 2px; font-size: 12.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
@media (hover: hover) {
  .card:hover .frame img { transform: scale(1.03); }
  .frame img { transition: transform .35s var(--ease), opacity .3s var(--ease); }
}

.bar { height: 3px; border-radius: 2px; background: rgba(255,255,255,.22); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar.thick { height: 4px; }

.grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 10px;
  padding: 0 var(--gutter);
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px 16px; }
  .rail { grid-auto-columns: 260px; gap: 14px; }
}

.segmented {
  display: inline-flex; padding: 2px; border-radius: 9px; background: var(--bg-raise-2);
}
.segmented button {
  height: 28px; padding: 0 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--fg-2);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.segmented button[aria-pressed="true"] { background: var(--bg-press); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* aviso de descargas en la portada */
.live {
  margin: 18px var(--gutter) 0; padding: 12px 14px; border-radius: 14px;
  background: var(--bg-raise); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  transition: transform .15s var(--ease), background-color .15s var(--ease);
}
.live:active { transform: scale(.98); background: var(--bg-raise-2); }
.live-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 20px; }
.live b { display: block; font-size: 14px; font-weight: 600; }
.live small { display: block; font-size: 12.5px; color: var(--fg-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live .bar { margin-top: 7px; }
.live .pct { font-size: 13px; font-weight: 600; color: var(--fg-2); font-variant-numeric: tabular-nums; }

/* ---------- ficha ---------- */
.detail-hero { position: relative; aspect-ratio: 16 / 10; max-height: 62svh; width: 100%; overflow: hidden; background: var(--bg-raise); }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,10,12,.5) 0%, rgba(10,10,12,0) 30%, rgba(10,10,12,0) 55%, var(--bg) 100%); }
.detail-body { padding: 0 var(--gutter); margin-top: -36px; position: relative; max-width: 760px; }
.detail-body h1 { font: 800 28px/1.1 var(--display); letter-spacing: -.025em; margin: 0; text-wrap: balance; overflow-wrap: anywhere; }
.detail-actions { display: grid; gap: 10px; margin-top: 18px; }
.detail-actions .btn { width: 100%; }
.resume { margin-top: 14px; }
.resume-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--fg-2); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 22px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px;
  border-radius: 12px; background: var(--bg-raise); font-size: 12.5px; font-weight: 500; color: var(--fg-2);
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.tool svg { font-size: 22px; color: var(--fg); }
.tool:active { transform: scale(.96); background: var(--bg-raise-2); }
.tool.danger svg, .tool.danger { color: var(--danger); }
@media (hover: hover) { .tool:hover { background: var(--bg-raise-2); } }
.facts { margin: 26px 0 0; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.facts dt { color: var(--fg-2); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }

@media (min-width: 900px) {
  .detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 36px; padding: calc(var(--topbar-h) + 24px) 36px 0; max-width: 1280px; margin: 0 auto; }
  .detail-hero { aspect-ratio: 16 / 9; border-radius: var(--radius-lg); max-height: none; }
  .detail-hero::after { display: none; }
  .detail-body { margin-top: 0; padding: 0; }
  .detail-body h1 { font-size: 34px; }
}

/* ---------- buscar ---------- */
.searchbox {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 5;
  padding: 0 var(--gutter) 12px; background: var(--bg);
}
.searchfield {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 12px;
  background: var(--bg-raise-2); color: var(--fg-3);
}
.searchfield svg { font-size: 19px; }
.searchfield input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--fg);
  font: 400 16px var(--sans);
}
.searchfield input::placeholder { color: var(--fg-3); }
.searchfield input::-webkit-search-cancel-button { display: none; }
.posters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; padding: 4px var(--gutter) 0; }
@media (min-width: 700px) { .posters { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; } }
.poster { display: block; min-width: 0; transition: transform .15s var(--ease); }
.poster:active { transform: scale(.96); }
.poster-img { position: relative; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: var(--bg-raise-2); }
.poster-img img { width: 100%; height: 100%; object-fit: cover; }
.poster-img .pill { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); border-color: transparent; }
.poster-title { margin-top: 7px; font-size: 12.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.cat-head { display: grid; grid-template-columns: 104px 1fr; gap: 16px; align-items: end; padding: 8px var(--gutter) 0; }
.cat-head .poster-img { border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.cat-head h1 { font: 800 24px/1.12 var(--display); letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.cat-head p { margin: 6px 0 0; font-size: 13px; color: var(--fg-2); }
.tabs-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 0 var(--gutter); scrollbar-width: none; margin-top: 22px; }
.tabs-scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--bg-raise-2);
  font-size: 14px; font-weight: 600; color: var(--fg-2); transition: background-color .15s var(--ease), color .15s var(--ease);
}
.chip[aria-pressed="true"] { background: var(--fg); color: #0a0a0c; }

.list { margin: 12px var(--gutter) 0; border-radius: 14px; background: var(--bg-raise); overflow: hidden; }
.row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; }
.row + .row { border-top: 1px solid var(--line); }
.row-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--bg-raise-2); display: grid; place-items: center; font-size: 19px; color: var(--fg-2); }
.row-main { min-width: 0; }
.row-main b { display: block; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.row-main small { display: block; font-size: 12.5px; color: var(--fg-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main .bar { margin-top: 8px; }
.row .done { color: var(--ok); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.row .done svg { font-size: 17px; }
.row-thumb { width: 96px; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: var(--bg-raise-2); }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
a.row:active, button.row:active { background: var(--bg-raise-2); }
button.row { width: 100%; text-align: left; }

/* ---------- descargas ---------- */
.state { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.state.run { color: var(--fg); }
.state.err { color: var(--danger); }
.state.ok { color: var(--ok); }
.row-icon.run { background: var(--accent-soft); color: var(--accent); }
.row-icon.ok { background: rgba(61,214,140,.14); color: var(--ok); }
.row-icon.err { background: rgba(255,99,105,.14); color: var(--danger); }
.row-icon.wait, .row-icon.off { color: var(--fg-3); }
.row-end { display: inline-flex; align-items: center; gap: 6px; }
.btn.cancel-confirm { background: rgba(255,99,105,.16); color: var(--danger); }
.btn.cancel-confirm:active { background: rgba(255,99,105,.26); }
.row-error { white-space: normal !important; color: var(--danger) !important; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.foot-actions { display: flex; justify-content: center; margin-top: 16px; }

/* ---------- estados vacíos y esqueletos ---------- */
.empty { text-align: center; padding: 56px var(--gutter) 24px; max-width: 420px; margin: 0 auto; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px; background: var(--bg-raise); display: grid; place-items: center; font-size: 30px; color: var(--fg-2); }
.empty h2 { font: 700 20px/1.25 var(--display); margin: 0; letter-spacing: -.015em; }
.empty p { color: var(--fg-2); margin: 8px 0 20px; font-size: 14.5px; }
.empty.compact { padding-top: 32px; }
.empty.hero-empty { padding-top: calc(var(--topbar-h) + var(--safe-t) + 18vh); }
.skeleton { background: linear-gradient(90deg, var(--bg-raise) 0%, var(--bg-raise-2) 50%, var(--bg-raise) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-hero { height: min(72svh, 640px); min-height: 440px; border-radius: 0; }
.sk-line { height: 12px; margin-top: 8px; border-radius: 6px; }

/* ---------- hojas (dialog) ---------- */
.sheet {
  margin: auto auto 0; padding: 0; border: 0; width: 100%; max-width: 560px;
  background: var(--bg-raise); color: var(--fg);
  border-radius: 20px 20px 0 0; max-height: 92dvh;
  box-shadow: 0 -12px 40px rgba(0,0,0,.5);
}
.sheet[open] { animation: sheet-in .32s var(--ease) both; }
.sheet::backdrop { background: rgba(0,0,0,.55); animation: fade .25s var(--ease) both; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 20px; }
  .sheet[open] { animation: pop .22s var(--ease) both; }
  .grabber { display: none; }
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.sheet-body { padding: 8px 20px calc(20px + var(--safe-b)); display: grid; gap: 16px; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); margin: 0 auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font: 700 20px/1.2 var(--display); letter-spacing: -.015em; margin: 0; }
.sheet-text { margin: -6px 0 4px; color: var(--fg-2); font-size: 14.5px; overflow-wrap: anywhere; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--fg-2); }
.field em { font-style: normal; font-weight: 400; color: var(--fg-3); }
.field small { font-size: 12.5px; color: var(--fg-3); }
.field input, .field textarea {
  width: 100%; border: 1px solid transparent; border-radius: 12px; background: var(--bg-raise-2); color: var(--fg);
  font: 400 16px/1.4 var(--sans); padding: 12px 14px;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.field textarea { resize: vertical; min-height: 88px; }
.field input::placeholder, .field textarea::placeholder { color: var(--fg-3); }
.field input:focus, .field textarea:focus { border-color: var(--accent); background: var(--bg-press); }
.field input:focus-visible, .field textarea:focus-visible, .searchfield input:focus-visible { outline: none; }
.searchfield { transition: box-shadow .15s var(--ease); }
.searchfield:focus-within { box-shadow: inset 0 0 0 1px var(--accent); color: var(--fg-2); }
.field .invalid { border-color: var(--danger); }
.form-error { margin: -6px 0 0; color: var(--danger); font-size: 13.5px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- reproductor ---------- */
.player { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; place-items: center; }
.player video { width: 100%; height: 100%; max-height: 100dvh; background: #000; }
.player-bar {
  position: absolute; inset: 0 0 auto 0; padding: calc(var(--safe-t) + 8px) max(12px, var(--safe-r)) 24px max(12px, var(--safe-l));
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,0)); pointer-events: none;
  transition: opacity .3s var(--ease);
}
.player-bar > * { pointer-events: auto; }
.player-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.player.idle .player-bar { opacity: 0; }

/* ---------- avisos ---------- */
.toast {
  position: fixed; left: 50%; z-index: 60; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 14px;
  background: #2b2b31; color: var(--fg); font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); display: flex; align-items: center; gap: 10px;
  transition: opacity .2s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast svg { font-size: 18px; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger); }
.toast a, .toast button { color: var(--accent); font-weight: 650; margin-left: 4px; }

.offline {
  position: fixed; z-index: 40; left: var(--gutter); right: var(--gutter); top: calc(var(--topbar-h) + var(--safe-t) + 8px);
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: #2a1c1d; color: #ffd9da; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.offline svg { font-size: 20px; color: var(--danger); }
.offline span { flex: 1; }

@media (min-width: 700px) {
  :root { --gutter: 32px; }
  .hero { height: min(78vh, 720px); }
  .hero h1 { font-size: 44px; }
  .hero-body { padding-bottom: 12px; max-width: 760px; }
  .large-title { font-size: 36px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
}

/* ---------- inicio de sesión ---------- */
.login-page main { padding: 0; min-height: 100dvh; }
.login {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) var(--gutter) calc(24px + var(--safe-b));
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand img { border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.login-brand .brand { font-size: 30px; padding: 0; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 16px; padding: 22px 20px; border-radius: 20px; background: var(--bg-raise); }
.login-card h1 { font: 700 22px/1.2 var(--display); letter-spacing: -.015em; margin: 0 0 2px; }
.login-note { max-width: 320px; text-align: center; color: var(--fg-3); font-size: 12.5px; margin: 18px 0 0; }
.account { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--fg-2); }

/* pantallas anchas: las secciones pasan a la barra superior */
@media (min-width: 900px) {
  .tabbar {
    top: var(--safe-t); bottom: auto; left: 50%; right: auto; transform: translateX(-50%);
    height: var(--topbar-h); padding: 0; z-index: 31;
    grid-template-columns: repeat(3, auto); gap: 4px; align-items: center;
    background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tabbar a {
    flex-direction: row; gap: 8px; height: 36px; padding: 0 14px; border-radius: 18px;
    font-size: 14px; font-weight: 600; color: var(--fg-2);
    transition: background-color .15s var(--ease), color .15s var(--ease);
  }
  .tabbar a svg { font-size: 18px; }
  .tabbar a:hover { color: var(--fg); background: rgba(255,255,255,.08); }
  .tabbar a[aria-current="page"] { background: rgba(255,255,255,.12); }
  .tabbar a[aria-current="page"] svg { color: var(--fg); }
  .badge { top: -7px; right: -9px; }
  main { padding-bottom: 48px; }
  .toast { bottom: 28px; }
  .topbar-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
