:root {
  --bg: #0f1115; --panel: #181b22; --line: #262a33; --fg: #eef0f4; --muted: #9aa1ad;
  --acc: #e5a00d; --acc-fg: #111; --bad: #e5484d; --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; padding-bottom: env(safe-area-inset-bottom); }
button, input, a.btn { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

.brand { font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.brand span { color: var(--acc); font-weight: 600; letter-spacing: 0; }
.brand.big { font-size: 32px; }

/* ---- cabecera ---- */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(15,17,21,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top input { flex: 1; min-width: 0; padding: 10px 12px; font-size: 16px; color: var(--fg); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); }
.top input:focus { outline: 2px solid var(--acc); outline-offset: -1px; }
.top form { margin: 0; }
.ghost { background: none; border: 0; color: var(--muted); padding: 8px 4px; cursor: pointer; }

.tabs { display: flex; gap: 6px; padding: 10px 16px 0; }
.tabs button { background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.tabs button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

main { padding: 0 16px 40px; max-width: 1400px; margin: 0 auto; }
h2 { font-size: 18px; margin: 22px 0 10px; }

/* ---- tarjetas ---- */
.row { display: grid; grid-auto-flow: column; grid-auto-columns: 128px; gap: 12px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; padding-bottom: 6px; scrollbar-width: thin; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 16px 12px; }
.card { display: flex; flex-direction: column; gap: 3px; text-align: left; background: none; border: 0; padding: 0; color: inherit;
  cursor: pointer; scroll-snap-align: start; min-width: 0; }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; background: var(--panel); display: block;
  transition: transform .15s ease-out; }
.card img.noimg { visibility: hidden; }
.card:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; border-radius: 8px; }
@media (hover: hover) { .card:hover img { transform: scale(1.03); } }
.card .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .y { font-size: 12px; color: var(--muted); }

/* ---- ficha ---- */
dialog { padding: 0; border: 0; background: transparent; color: inherit; max-width: 560px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(0,0,0,.7); }
.sheet { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; overflow: auto; max-height: calc(100dvh - 24px); }
.close { position: absolute; top: 6px; right: 8px; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 28px; cursor: pointer; }
.head { display: flex; gap: 14px; padding-right: 30px; }
.head img { width: 110px; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; background: var(--bg); flex: none; }
.head h3 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; }
.head p { margin: 2px 0; }
.summary { color: #cfd3da; font-size: 15px; max-height: 9.5em; overflow: auto; }
.chips { display: flex; gap: 8px; margin: 6px 0 4px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 4px 14px; cursor: pointer; }
.chip.on { border-color: var(--acc); color: var(--acc); }

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn { display: block; width: 100%; text-align: center; text-decoration: none; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-weight: 600; cursor: pointer;
  transition: transform .1s ease-out, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }
.hint { margin: -2px 2px 6px; font-size: 13px; color: var(--muted); }
.firetv { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.firetv summary { cursor: pointer; font-weight: 600; }
.firetv ol { padding-left: 20px; color: #cfd3da; font-size: 14px; }

/* ---- reproductor ---- */
#player { max-width: 720px; }
.ptitle { margin: 0 40px 12px 0; font-size: 18px; }
#video { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 8px; display: block; margin-bottom: 10px; }

/* ---- aviso ---- */
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  max-width: min(520px, calc(100% - 32px)); background: #2a2f39; color: var(--fg); padding: 12px 16px; border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,.4); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }

/* ---- login ---- */
body.login { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login-box { max-width: 380px; text-align: center; }
.login-box .btn { margin: 20px 0 12px; }
.alert { background: rgba(229,72,77,.15); border: 1px solid var(--bad); border-radius: var(--radius); padding: 10px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
