:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --border: #262d38;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3fb950;
  --accent-2: #2ea043;
  --danger: #f85149;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

body { display: flex; flex-direction: column; height: 100vh; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.back {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.back:hover { background: var(--accent-2); border-color: var(--accent-2); }

.search { flex: 1 1 auto; }
.search input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }

#group {
  max-width: 280px;
  padding: 9px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}

/* ---------- main / views ---------- */
.main { flex: 1; display: flex; min-height: 0; }

.sidebar {
  flex: 0 0 250px;
  width: 250px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.sidebar-head {
  padding: 12px 14px 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.cat-filter {
  margin: 0 10px 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.cat-filter:focus { border-color: var(--accent); }
.cat-list { flex: 1; overflow-y: auto; padding-bottom: 10px; }
.cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat:hover { background: var(--panel-2); }
.cat.active { background: var(--panel-2); border-left-color: var(--accent); color: #fff; }
.cat .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cat .cat-count { color: var(--muted); font-size: 11px; flex: 0 0 auto; }

.content { flex: 1; overflow-y: auto; position: relative; min-width: 0; }
.view { min-height: 100%; }
.hidden { display: none !important; }

/* ---------- home tiles ---------- */
.tiles {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  min-height: calc(100vh - 140px);
  padding: 24px;
}
.tile {
  width: 240px;
  height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--text);
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.tile:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.tile-icon { font-size: 84px; line-height: 1; }
.tile-name { font-size: 26px; font-weight: 700; }
.tile-count { color: var(--muted); font-size: 14px; }

/* ---------- grid (movies / series) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}
@media (max-width: 1500px) { .grid { grid-template-columns: repeat(7, minmax(0,1fr)); } }
@media (max-width: 1280px) { .grid { grid-template-columns: repeat(6, minmax(0,1fr)); } }
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(5, minmax(0,1fr)); } }
@media (max-width: 820px)  { .grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 600px)  { .grid { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 420px)  { .grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.card { cursor: pointer; min-width: 0; }
.card .poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #05070a;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card .poster .ph { font-size: 40px; opacity: .35; }
.card .poster img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.card .poster .badge-ep {
  position: absolute;
  right: 6px; bottom: 6px;
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
}
.card:hover .poster { border-color: var(--accent); }
.card .ctitle {
  margin-top: 6px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .csub { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- live list ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.row:hover { background: var(--panel-2); }
.row.playing { background: rgba(63,185,80,.12); box-shadow: inset 3px 0 0 var(--accent); }
.logo { width: 42px; height: 30px; flex: 0 0 42px; object-fit: contain; background: #000; border-radius: 4px; }
.logo-fallback {
  width: 42px; height: 30px; flex: 0 0 42px;
  display: flex; align-items: center; justify-content: center;
  background: #000; border-radius: 4px; color: var(--muted); font-size: 16px;
}
.info { min-width: 0; flex: 1; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-btn {
  flex: 0 0 auto; border: 0; background: var(--panel-2); color: var(--accent);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 13px;
}
.row:hover .play-btn { background: var(--accent-2); color: #fff; }

/* ---------- serie detail ---------- */
.serie-head {
  display: flex;
  gap: 20px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.serie-head img, .serie-head .ph {
  width: 150px; flex: 0 0 150px;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 10px;
  background: #05070a;
  border: 1px solid var(--border);
}
.serie-head .ph { display: flex; align-items: center; justify-content: center; font-size: 48px; opacity: .5; }
.serie-head .sh-info { flex: 1; min-width: 0; }
.serie-head h2 { margin: 0 0 6px; font-size: 24px; }
.serie-head .sh-meta { color: var(--muted); }

.season-title {
  padding: 14px 16px 6px;
  font-weight: 600;
  color: var(--accent);
  position: sticky;
  top: 0;
  background: var(--bg);
}
.ep {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.ep:hover { background: var(--panel-2); }
.ep.playing { background: rgba(63,185,80,.12); box-shadow: inset 3px 0 0 var(--accent); }
.ep-num {
  flex: 0 0 72px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.ep-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- misc ---------- */
.sentinel { height: 60px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.sentinel.loading::after { content: "Cargando..."; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

.nowplaying {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel);
  border-top: 1px solid var(--border); font-size: 13px;
}
.np-label { color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.np-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--danger);
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
}
.stop:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
