:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b0f;
  color: #f7f8fa;
  --bg: #090b0f;
  --panel: #11151b;
  --panel-raised: #171c24;
  --panel-hover: #1d2430;
  --border: #2b323d;
  --border-soft: #222832;
  --muted: #9da6b3;
  --text: #f7f8fa;
  --blue: #5b8cff;
  --blue-soft: #5b8cff22;
  --green: #2bc875;
  --red: #ef5350;
  --amber: #f2b84b;
  --nav-width: 184px;
  --topbar-height: 74px;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 75% -20%, #18243d 0, transparent 34%),
    var(--bg);
}

button, input, select { font: inherit; }

button, input, select, summary {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
}

button, summary { cursor: pointer; }

button {
  padding: 0 17px;
  color: var(--text);
  background: var(--panel-raised);
  font-weight: 750;
}

button:hover:not(:disabled) { border-color: #465163; background: var(--panel-hover); }
button:disabled { cursor: default; opacity: .45; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #8baaff;
  outline-offset: 3px;
}

input, select {
  min-width: 0;
  padding: 0 12px;
  color: var(--text);
  background: #151a22;
}

label { color: #c2c8d1; font-size: 13px; font-weight: 750; }
h1, h2, h3, p { margin-top: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100svh;
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
}

.app-nav {
  position: relative;
  z-index: 20;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-soft);
  background: #0e1117ee;
  backdrop-filter: blur(18px);
}

.nav-brand {
  min-height: var(--topbar-height);
  padding: 14px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #4777e7, #765bd3);
  font-size: 13px;
  font-weight: 900;
}

.nav-brand strong, .nav-brand span, .nav-user strong, .nav-user span { display: block; }
.nav-brand strong { font-size: 14px; }
.nav-brand div > span { margin-top: 2px; color: var(--muted); font-size: 11px; }

.nav-items {
  display: grid;
  gap: 6px;
  padding: 16px 10px;
}

.nav-item {
  width: 100%;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-color: transparent;
  color: #bdc4ce;
  background: transparent;
  text-align: left;
}

.nav-item:hover:not(:disabled) { border-color: transparent; background: #ffffff0a; }
.nav-item[aria-current="page"] { color: #fff; background: var(--blue-soft); }
.nav-item[aria-current="page"] .nav-icon { color: #9cb5ff; }
.nav-icon { width: 22px; color: #8994a4; font-size: 17px; text-align: center; }

.nav-user {
  margin-top: auto;
  padding: 18px 16px;
  border-top: 1px solid var(--border-soft);
}

.nav-user strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; }
.nav-user span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.app-content {
  min-width: 0;
  height: 100svh;
  display: grid;
  grid-template-rows: var(--topbar-height) auto minmax(0, 1fr);
}

.topbar {
  padding: 0 clamp(18px, 3vw, 38px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border-soft);
  background: #0e1117c7;
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 { margin-bottom: 0; font-size: 22px; line-height: 1.05; }
h2 { margin-bottom: 6px; font-size: clamp(24px, 3vw, 34px); }
h3 { margin-bottom: 5px; font-size: 17px; }

.topbar-statuses { display: flex; align-items: center; gap: 10px; }
.logout-form { margin: 0; }
.logout-form .text-button { min-height: 36px; padding: 0 12px; }

.vlc-link { display: flex; flex-wrap: wrap; gap: 9px; }
.vlc-link input { min-width: 0; flex: 1 1 260px; padding: 0 12px; color: var(--muted); }

.status, .recording-indicator {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.status {
  padding: 0 12px;
  border: 1px solid var(--border);
  color: #c6ccd5;
  background: #151a21;
  font-size: 12px;
}

.status-dot, .recording-dot, .live-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #737d8b;
}

.status[data-state="live"] .status-dot, .live-dot { background: var(--green); box-shadow: 0 0 0 4px #2bc8751f; }
.status[data-state="loading"] .status-dot { background: var(--amber); }
.status[data-state="error"] .status-dot { background: var(--red); }

.recording-indicator {
  padding: 0 12px;
  border-color: #ef535066;
  color: #ffcecd;
  background: #ef535018;
  font-size: 12px;
}

.recording-indicator:hover:not(:disabled) { border-color: var(--red); background: #ef535026; }
.recording-dot { background: var(--red); animation: recording-pulse 1.4s ease-in-out infinite; }

@keyframes recording-pulse { 50% { opacity: .35; } }

.app-alert {
  margin: 10px clamp(18px, 3vw, 38px) 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #ef535066;
  border-radius: 9px;
  color: #ffd8d7;
  background: #351719;
  font-size: 13px;
}

.app-alert > span { flex: 1; }
.text-button { min-height: 32px; padding: 0 8px; border: 0; color: #fff; background: transparent; text-decoration: underline; }
.icon-button { width: 34px; min-height: 34px; padding: 0; font-size: 20px; }

main {
  min-height: 0;
  overflow: auto;
  padding: clamp(14px, 2.5vw, 30px) clamp(14px, 3vw, 38px) 34px;
}

.app-view { width: min(1180px, 100%); margin: 0 auto; }

.app-view.live-view { width: min(1560px, 100%); min-height: 100%; }

.live-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.live-stage { min-width: 0; }

.player-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #303844;
  border-radius: 12px;
  background: #030405;
  box-shadow: 0 18px 60px #0008;
}

video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }

/* Zapping curtain: covers the video while the channel changes for everyone, then
   shrinks into an on-screen banner once the new channel is actually on screen. */
.zap-curtain {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  align-content: end;
  padding: 18px;
  background: linear-gradient(180deg, #05060799 0%, #050607e6 70%);
  backdrop-filter: blur(6px);
  transition: background 0.4s ease, backdrop-filter 0.4s ease, opacity 0.5s ease;
  pointer-events: none;
}

.zap-curtain.is-arrived {
  background: linear-gradient(180deg, transparent 55%, #050607cc 100%);
  backdrop-filter: none;
}

.zap-curtain.is-leaving {
  opacity: 0;
}

.zap-card {
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: min(560px, 100%);
  padding: 12px 16px;
  border: 1px solid #2b323d;
  border-left: 4px solid #f2b84b;
  border-radius: 12px;
  background: #0b0e13e0;
  color: #e8ebef;
}

.zap-logo {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: #1d2430;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 800;
  color: #9da6b3;
}

.zap-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.zap-copy {
  min-width: 0;
}

.zap-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 1.25rem;
}

.zap-number {
  color: #f2b84b;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.zap-head strong,
.zap-programme {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.zap-programme {
  color: #c9d0da;
}

.zap-state {
  margin-top: 2px;
  color: #8a94a3;
  font-size: 0.85rem;
}

.zap-bar {
  height: 3px;
  margin-top: 10px;
  max-width: min(560px, 100%);
  border-radius: 2px;
  background: #2b323d;
  overflow: hidden;
}

.zap-bar i {
  display: block;
  width: 35%;
  height: 100%;
  background: #f2b84b;
  animation: zap-sweep 1.1s ease-in-out infinite;
}

.zap-curtain.is-arrived .zap-bar {
  visibility: hidden;
}

@keyframes zap-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(300%); }
}

@media (prefers-reduced-motion: reduce) {
  .zap-curtain { transition: none; }
  .zap-bar i { animation: none; width: 100%; opacity: 0.6; }
}

.unmute-button {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  padding: 12px 18px;
  border: 2px solid #f2b84b;
  border-radius: 999px;
  background: #0b0e13e6;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.unmute-button:focus-visible {
  outline: 3px solid #f2b84b;
  outline-offset: 2px;
}

.player-message {
  position: absolute;
  inset: 0;
  padding: 24px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: #dce1e8;
  text-align: center;
  background: radial-gradient(circle, #151a21cc, #050607e8);
}

.player-message strong { font-size: 23px; }
.player-message span { color: var(--muted); }
.compact { min-height: 38px; padding: 0 14px; }

.timeshift-controls {
  min-height: 62px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeshift-actions { display: flex; gap: 8px; }
.timeshift-controls button { min-height: 40px; padding: 0 14px; font-size: 12px; }
.live-action { display: flex; align-items: center; gap: 8px; background: #11231b; border-color: #2bc87555; }
.timeshift-summary { min-width: 120px; text-align: right; }
.timeshift-summary strong, .timeshift-summary span { display: block; }
.timeshift-summary strong { font-size: 13px; }
.timeshift-summary span { margin-top: 2px; color: var(--muted); font-size: 11px; }

.now-playing {
  min-height: 70px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 10px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: #11151bc7;
}

.channel-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.channel-number { min-width: 52px; color: #9cb5ff; font-size: 24px; font-weight: 900; }
.channel-identity { grid-column: 1; grid-row: 1; min-width: 0; }
.now-copy { min-width: 0; flex: 1 1 auto; }
.now-copy > span { overflow-wrap: anywhere; }
.now-copy > strong, .now-copy > span { display: block; }
.now-copy > strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.now-copy > span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.live-badge {
  padding: 1px 6px;
  border-radius: 4px;
  color: #7fe0aa;
  background: #2bc87533;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
  vertical-align: middle;
}

.now-programme { grid-column: 1; grid-row: 2; min-width: 0; display: grid; gap: 4px; }
.now-programme-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.now-programme-line strong { font-size: 14px; }
.now-programme-line span, .now-next { color: var(--muted); font-size: 12px; }

.live-progress { height: 3px; overflow: hidden; border-radius: 2px; background: var(--border); }
.live-progress i { display: block; width: 0; height: 100%; background: var(--blue); }

.live-quick-actions { grid-column: 1; grid-row: 3; display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-start; gap: 9px; }
.mode-control { display: grid; gap: 4px; }
.mode-control select { width: 142px; min-height: 40px; }
.mode-readonly { padding: 8px 11px; border-radius: 999px; color: #d8dee8; background: #ffffff0a; font-size: 12px; }
.record-action { min-height: 40px; border-color: #ef535066; background: #ef5350; color: white; }
.record-action.is-recording { background: #38191b; animation: recording-button-pulse 1.6s ease-in-out infinite; }
@keyframes recording-button-pulse { 50% { box-shadow: 0 0 0 5px #ef53501f; } }

.view-header {
  min-height: 78px;
  margin-bottom: 18px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.view-header h2 { margin-bottom: 4px; }
.view-header p { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.live-channels {
  position: sticky;
  top: 0;
  height: calc(100svh - var(--topbar-height) - 70px);
  min-height: 360px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chip-scroller { position: relative; flex: none; min-width: 0; }
.live-chips { position: relative; padding-bottom: 2px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; scroll-padding-inline: 32px; }
.live-chips::-webkit-scrollbar { display: none; }
.chip-scroller.can-prev .live-chips { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 44px); mask-image: linear-gradient(90deg, transparent 0, #000 44px); }
.chip-scroller.can-next .live-chips { -webkit-mask-image: linear-gradient(270deg, transparent 0, #000 44px); mask-image: linear-gradient(270deg, transparent 0, #000 44px); }
.chip-scroller.can-prev.can-next .live-chips { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 44px, #000 calc(100% - 44px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 44px, #000 calc(100% - 44px), transparent 100%); }
.chip-arrow {
  position: absolute;
  top: 0;
  z-index: 2;
  width: 32px;
  height: 36px;
  min-height: 0;
  padding: 0;
  display: none;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}
.chip-arrow-prev { left: 0; }
.chip-arrow-next { right: 0; }
.chip-scroller.can-prev .chip-arrow-prev, .chip-scroller.can-next .chip-arrow-next { display: grid; }

.live-chip {
  max-width: 200px;
  min-height: 36px;
  flex: none;
  padding: 0 13px;
  overflow: hidden;
  border-radius: 999px;
  color: #c9d0da;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-chip[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); color: #fff; }

.live-search { flex: none; }
.live-search input { width: 100%; padding: 0 12px; color: var(--text); background: var(--panel); }
.live-count { flex: none; margin: 0; color: var(--muted); font-size: 12px; }

.live-list {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0 2px 2px 0;
  list-style: none;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 4px;
  scrollbar-width: thin;
}

.live-list:focus-visible { outline-offset: -2px; }

.live-row {
  position: relative;
  border: 1px solid transparent;
  border-radius: 9px;
}

.live-row-main {
  width: 100%;
  min-height: 58px;
  padding: 7px 44px 7px 8px;
  display: grid;
  grid-template-columns: 46px 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  text-align: left;
}

.live-row-num { color: #a9bdff; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.live-row-text { min-width: 0; display: grid; gap: 2px; }
.live-row-name { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.live-row-now, .live-row-next { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.live-row-now { color: #d3d9e2; }
.live-row-text .live-progress { margin: 2px 0; }

.live-fav {
  position: absolute;
  top: 8px;
  right: 6px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
}

.live-fav.is-on { color: var(--amber); }
.live-fav.is-static { min-height: 36px; border: 0; pointer-events: none; }

.live-row:hover { background: var(--panel); }
.live-row.is-playing { border-color: #2bc87544; background: #2bc87514; }
.live-row.is-selected { border-color: var(--amber); background: #f2b84b12; }
.live-row.is-selected.is-playing { background: #2bc87514; }

.live-row-detail { padding: 0 12px 10px 66px; display: grid; justify-items: start; gap: 6px; }
.live-row-desc { margin: 0; color: #c1c9d5; font-size: 12px; line-height: 1.4; }
.live-row-hint { margin: 0; color: var(--amber); font-size: 12px; font-weight: 700; }

.live-watch { border-color: #2bc87566; background: #11231b; }
.live-more { padding: 6px 0; display: grid; }

.number-toast {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 20px;
  z-index: 45;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 14px;
  border: 1px solid var(--amber);
  border-radius: 10px;
  background: #171c24f5;
  box-shadow: 0 18px 45px #0009;
  font-weight: 700;
}

.channel-sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: #000a; }

.sheet-panel {
  position: absolute;
  inset: auto 0 0;
  max-height: 80svh;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  background: var(--panel);
}

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head strong, .sheet-head span { display: block; }
.sheet-head strong { font-size: 18px; }
.sheet-head span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.sheet-line, .sheet-desc, .sheet-note { margin: 0; font-size: 14px; }
.sheet-line b { margin-right: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.sheet-desc { color: #c1c9d5; font-size: 13px; line-height: 1.45; }
.sheet-note { color: var(--amber); font-weight: 700; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions > button { flex: 1; }

.channel-logo {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  color: #a9bdff;
  background: var(--panel-raised);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}

.channel-logo img { width: 100%; height: 100%; object-fit: contain; }
.channel-identity .channel-logo { display: grid; margin-top: 0; color: #a9bdff; font-size: 13px; }

.show-more { grid-column: 1 / -1; }

.recording-list { display: grid; gap: 20px; }
.recording-day { display: grid; gap: 9px; }
.recording-day h3 { margin: 0; color: #cbd1da; font-size: 13px; }

.recording-card {
  width: 100%;
  min-height: 74px;
  padding: 13px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 14px;
  color: #f3f5f8;
  background: var(--panel);
  text-align: left;
}

.recording-card strong, .recording-card span { display: block; }
.recording-card strong { font-size: 15px; }
.recording-card span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.recording-card .recording-play { grid-column: 2; grid-row: 1; color: #a9bdff; font-size: 12px; }
.recording-card.is-active { border-color: #ef535088; background: #ef53500d; }
.recording-card.is-active .recording-play { color: #ffaaa8; }

.settings-card, .advanced-settings {
  margin-bottom: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--panel);
}

.settings-card { padding: 18px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.section-heading > span { color: #a9bdff; font-size: 12px; }
.compact-heading { margin-bottom: 10px; }

.mode-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.mode-card { min-height: 78px; padding: 12px; display: grid; gap: 5px; align-content: center; text-align: left; }
.mode-card strong, .mode-card span { display: block; }
.mode-card strong { font-size: 14px; }
.mode-card span { color: var(--muted); font-size: 11px; font-weight: 500; }
.mode-card.is-active { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }

.iptv-add-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; gap: 12px; }
.iptv-field { min-width: 0; display: grid; gap: 6px; }
.iptv-field input { width: 100%; }
.iptv-add-form > button { align-self: end; }
.iptv-message { margin: 12px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.iptv-message[data-kind="ok"] { color: #8fe0b0; }
.iptv-message[data-kind="error"] { color: #ffaaa8; }
.iptv-playlist-list { margin-top: 16px; display: grid; gap: 10px; }
.iptv-playlist { padding: 13px 14px; display: grid; gap: 8px; border: 1px solid var(--border-soft); border-radius: 10px; background: #0c1015; }
.iptv-playlist-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.iptv-playlist-head strong { min-width: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.iptv-state { flex: none; padding: 3px 9px; border-radius: 999px; color: #d8dee8; background: #ffffff0a; font-size: 11px; }
.iptv-state[data-state="ok"] { color: #8fe0b0; background: #2bc87518; }
.iptv-state[data-state="pending"] { color: var(--amber); background: #f2b84b18; }
.iptv-state[data-state="error"] { color: #ffaaa8; background: #ef53500c; }
.iptv-meta, .iptv-error { margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.iptv-meta { color: var(--muted); }
.iptv-error { color: #ffaaa8; }
.iptv-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.settings-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.danger-outline { border-color: #ef535066; color: #ffaaa8; background: #ef53500c; }

.advanced-settings { overflow: hidden; }
.advanced-settings summary { min-height: 68px; padding: 12px 18px; display: flex; align-items: center; border: 0; border-radius: 0; list-style: none; }
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 22px; }
.advanced-settings[open] summary::after { content: "−"; }
.advanced-settings summary strong, .advanced-settings summary small { display: block; }
.advanced-settings summary small { margin-top: 3px; color: var(--muted); }
.advanced-content { padding: 0 18px 18px; border-top: 1px solid var(--border-soft); }

.advanced-form-grid { padding-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.manual-frequency, .scan-timeout { display: grid; gap: 8px; }
.manual-frequency div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.scan-timeout div { display: grid; grid-template-columns: 100px auto; align-items: center; gap: 9px; }
.scan-timeout span { color: var(--muted); font-size: 12px; }

.scan-panel, .diagnostics { margin-top: 18px; }
.scan-visual { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: #0c1015; }
.scan-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.scan-meta strong { font-size: 20px; }
.scan-meta span { color: var(--muted); font-size: 12px; }

.spectrum { position: relative; height: 66px; overflow: hidden; border: 1px solid #343c48; border-radius: 8px; background: linear-gradient(180deg, #080b0f, #151a21); }
.spectrum-track { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #ffffff0d 0 1px, transparent 1px 22px); }
.spectrum-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #5b8cff55, #2bc87530); transition: width .35s ease; }
.spectrum-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--amber); box-shadow: 0 0 14px #f2b84b99; transform: translateX(-1px); transition: left .35s ease; }
.spectrum-markers { position: absolute; inset: 0; }
.spectrum-marker { position: absolute; top: 10px; bottom: 10px; width: 4px; border-radius: 999px; background: var(--green); transform: translateX(-2px); }
.spectrum-axis { margin-top: 7px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

.diagnostics dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.diagnostics dl > div { padding: 12px; border: 1px solid var(--border-soft); border-radius: 8px; background: #0c1015; }
.diagnostics dt { color: var(--muted); font-size: 11px; }
.diagnostics dd { margin: 4px 0 0; overflow-wrap: anywhere; font-size: 12px; }

.empty-list { margin: 0; padding: 24px; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); text-align: center; }

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  width: min(380px, calc(100vw - 40px));
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.toast {
  padding: 13px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  border: 1px solid #42516a;
  border-radius: 10px;
  color: #f5f7fa;
  background: #182131f2;
  box-shadow: 0 18px 45px #0009;
  pointer-events: auto;
  animation: toast-in .2s ease-out;
}

.toast strong, .toast span { display: block; }
.toast strong { font-size: 13px; }
.toast span { margin-top: 3px; color: #c1c9d5; font-size: 11px; }
.toast button { grid-column: 2; grid-row: 1 / 3; min-height: 36px; padding: 0 10px; color: #bdd0ff; background: transparent; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1000px) {
  .mode-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 899px) {
  :root { --mobile-nav-height: 68px; --topbar-height: 64px; }

  .app-shell { height: 100svh; display: block; }
  .app-content { height: calc(100svh - var(--mobile-nav-height)); }

  .app-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    height: var(--mobile-nav-height);
    display: block;
    border-top: 1px solid var(--border);
    border-right: 0;
  }

  .nav-brand, .nav-user { display: none; }
  .nav-items { height: 100%; padding: 5px 8px; display: flex; justify-content: space-around; gap: 4px; }
  .nav-item { min-width: 0; height: 100%; padding: 4px 10px; flex: 1; flex-direction: column; justify-content: center; gap: 3px; text-align: center; font-size: 10px; }
  .nav-icon { width: auto; font-size: 16px; }

  .topbar { padding: 0 14px; }
  .topbar .eyebrow { display: none; }
  h1 { font-size: 19px; }
  .status { min-height: 34px; padding: 0 9px; }
  .recording-indicator { min-height: 34px; padding: 0 9px; }

  main { padding: 12px 10px 24px; }
  .live-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .live-channels { position: static; height: auto; min-height: 0; }
  .live-list { overflow: visible; }
  .live-row-detail { display: none; }
  .number-toast { top: calc(var(--topbar-height) + 8px); right: 10px; }
  .player-shell { border-radius: 8px; }

  .timeshift-controls { align-items: flex-start; }
  .timeshift-actions { min-width: 0; }
  .timeshift-controls button { padding: 0 10px; }
  .timeshift-summary { min-width: 92px; }

  .now-programme { grid-row: 2; }
  .live-quick-actions { width: 100%; justify-content: stretch; }
  .mode-control { flex: 1; }
  .mode-control select { width: 100%; }
  .record-action { flex: 1; }

  .view-header { min-height: 60px; align-items: flex-start; }
  .view-header h2 { font-size: 26px; }
  .settings-actions > button { flex: 1 1 calc(50% - 9px); }
  .toast-region { right: 10px; bottom: calc(var(--mobile-nav-height) + 10px); width: calc(100vw - 20px); }
}

@media (max-width: 560px) {
  .topbar-statuses { gap: 5px; }
  .status span:last-child { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  .recording-indicator { font-size: 10px; }

  .timeshift-controls { flex-direction: column; gap: 2px; }
  .timeshift-actions { width: 100%; }
  .timeshift-actions button { flex: 1; }
  .timeshift-summary { width: 100%; display: flex; align-items: baseline; justify-content: space-between; text-align: left; }
  .iptv-actions > button { flex: 1 1 calc(50% - 8px); padding: 0 10px; }
  .mode-grid { grid-template-columns: 1fr; }
  .advanced-form-grid { grid-template-columns: 1fr; }
  .diagnostics dl { grid-template-columns: 1fr; }
  .recording-card { grid-template-columns: 1fr; }
  .recording-card .recording-play { grid-column: 1; grid-row: auto; }
}

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

.login-body { overflow: auto; }
.login-shell { min-height: 100%; padding: 24px 16px; display: grid; place-items: center; }
.login-card {
  width: min(100%, 380px);
  padding: 28px 24px;
  display: grid;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}
.login-brand { padding: 0; }
.login-card h1 { margin: 4px 0 0; font-size: 24px; }
.login-field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-field input { width: 100%; padding: 0 12px; color: var(--text); background: var(--panel-raised); }
.login-submit { width: 100%; border-color: var(--blue); background: var(--blue); font-weight: 600; }
.login-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #ef535066;
  border-radius: 10px;
  color: #ffaaa8;
  background: #ef53500c;
  font-size: 14px;
}
.login-hint { margin: 0; color: var(--muted); font-size: 12px; }

/* ---- Guía (cuadrícula) ------------------------------------------------ */

.app-view.guide-view { width: min(1560px, 100%); --chan-w: 192px; --guide-head-h: 34px; --guide-row-h: 54px; }

.guide-toolbar { margin-bottom: 10px; display: grid; gap: 8px; }
.guide-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.guide-nav { display: flex; align-items: center; gap: 8px; }
.guide-range { color: var(--muted); font-size: 12px; white-space: nowrap; }
.guide-days { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.guide-message { margin: 0 0 10px; padding: 10px 14px; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: 13px; }

.guide-grid {
  height: calc(100svh - var(--topbar-height) - 170px);
  min-height: 320px;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--panel);
}

.guide-inner { position: relative; width: 100%; min-width: calc(var(--chan-w) + var(--tl-min, 560px)); }

.guide-head, .guide-row { display: grid; grid-template-columns: var(--chan-w) minmax(var(--tl-min, 560px), 1fr); }

.guide-head {
  position: sticky;
  top: 0;
  z-index: 4;
  height: var(--guide-head-h);
  border-bottom: 1px solid var(--border);
  background: var(--panel-raised);
}

.guide-corner, .guide-chan {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--panel-raised);
  border-right: 1px solid var(--border-soft);
}

.guide-corner { display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-size: 12px; font-weight: 750; }
.guide-times { display: flex; }
.guide-times span { flex: 1; min-width: 0; padding: 0 6px; display: flex; align-items: center; border-left: 1px solid var(--border-soft); color: #c1c9d5; font-size: 12px; white-space: nowrap; overflow: hidden; }

.guide-row { height: var(--guide-row-h); border-bottom: 1px solid var(--border-soft); }
.guide-chan { display: flex; align-items: center; gap: 8px; padding: 0 10px; min-width: 0; }
.guide-chan-num { min-width: 26px; color: var(--amber); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.guide-chan .channel-logo { width: 30px; height: 30px; font-size: 11px; }
.guide-chan-name { min-width: 0; overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.guide-chan-fav { flex: none; margin-left: auto; color: #f5c451; font-size: 12px; }
.guide-chan-fav[hidden] { display: none; }

.guide-line { position: relative; min-width: 0; }

.guide-cell {
  position: absolute;
  top: 3px;
  bottom: 3px;
  min-height: 0;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--panel-raised);
  text-align: left;
  scroll-margin-left: calc(var(--chan-w) + 6px);
  scroll-margin-top: calc(var(--guide-head-h) + 6px);
}

.guide-cell strong, .guide-cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide-cell strong { font-size: 12px; font-weight: 750; }
.guide-cell span { color: var(--muted); font-size: 10px; font-weight: 500; }
.guide-cell.is-air { border-color: #2bc87566; background: #11231b; }
.guide-cell.starts-before { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.guide-cell.ends-after { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.guide-cell.is-empty { border-style: dashed; background: transparent; }
.guide-cell.is-empty strong { color: var(--muted); font-weight: 500; }
.guide-cell.is-empty span { display: none; }
.guide-cell:focus-visible { z-index: 2; outline: 3px solid var(--amber); outline-offset: -1px; }

.guide-sentinel { height: 1px; }

.guide-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--chan-w) + (100% - var(--chan-w)) * var(--now, 0));
  z-index: 2;
  width: 2px;
  background: var(--red);
  pointer-events: none;
}

.guide-detail { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; }

.guide-detail-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: 80svh;
  padding: 18px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
}

.guide-detail-time { margin: 0; color: #c1c9d5; font-size: 13px; font-weight: 700; }

@media (max-width: 899px) {
  .app-view.guide-view { --chan-w: 104px; }
  .guide-grid { height: calc(100svh - var(--topbar-height) - var(--mobile-nav-height) - 190px); }
  .guide-chan { gap: 6px; padding: 0 6px; }
  .guide-chan .channel-logo { display: none; }
}

/* ---- Ajustes: Guía de TV --------------------------------------------- */

.guide-url-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.guide-url-form > button { margin-top: 25px; }
.guide-hint { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.guide-status { margin-top: 14px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--border-soft); border-radius: 10px; background: #0c1015; }
.guide-status-text p { margin: 0 0 3px; font-size: 13px; overflow-wrap: anywhere; }
.guide-status-text .guide-error { color: #ffaaa8; }
.guide-mappings-head { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.guide-mappings-head h4 { margin: 0; font-size: 14px; }
.guide-mappings-filters { display: flex; gap: 8px; }
.guide-mappings { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.guide-map-row { padding: 10px 12px; display: grid; gap: 8px; border: 1px solid var(--border-soft); border-radius: 10px; background: #0c1015; }
.guide-map-head { display: flex; align-items: center; gap: 12px; }
.guide-map-num { min-width: 38px; color: var(--amber); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.guide-map-text { min-width: 0; flex: 1; display: grid; gap: 2px; }
.guide-map-text strong { overflow-wrap: anywhere; font-size: 14px; }
.guide-map-target { color: #a9bdff; font-size: 12px; overflow-wrap: anywhere; }
.guide-map-target.is-missing { color: var(--muted); }
.guide-map-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.guide-map-change { display: grid; gap: 8px; }
.guide-map-change input { width: 100%; }
.guide-map-results { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.guide-map-result { width: 100%; padding: 8px 12px; display: grid; gap: 2px; text-align: left; }
.guide-map-result span { color: var(--muted); font-size: 11px; font-weight: 500; overflow-wrap: anywhere; }
.guide-map-note { color: var(--muted); font-size: 13px; }
.guide-map-more { text-align: center; }

@media (max-width: 560px) {
  .guide-url-form { grid-template-columns: 1fr; }
  .guide-url-form > button { margin-top: 0; }
  .guide-status, .guide-map-head { flex-direction: column; align-items: stretch; }
  .guide-map-actions { justify-content: flex-start; }
}

/* ---- Películas -------------------------------------------------------- */

.movies-toolbar { margin-bottom: 12px; display: grid; gap: 8px; }
.movie-search input { width: 100%; padding: 0 12px; color: var(--text); background: var(--panel); }
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.movie-card {
  min-width: 0;
  min-height: 0;
  padding: 0 0 10px;
  display: grid;
  gap: 4px;
  align-content: start;
  overflow: hidden;
  border-radius: 10px;
  background: var(--panel);
  text-align: left;
}
.movie-card strong, .movie-card > span:last-child {
  padding: 0 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.movie-card strong { font-size: 13px; }
.movie-card > span:last-child { color: var(--muted); font-size: 12px; }
.movie-card:focus-visible, .movie-card:focus { outline: 3px solid var(--blue); outline-offset: 2px; }
.movie-card.is-playing { box-shadow: inset 0 0 0 2px var(--green); }

.movie-poster {
  aspect-ratio: 2 / 3;
  width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(160deg, #202838, #11151b);
}
.movie-poster img { width: 100%; height: 100%; object-fit: cover; }
.movie-poster-fallback { color: #c1c9d5; font-size: 28px; font-weight: 800; letter-spacing: 1px; }
.movie-sentinel { height: 1px; }

.movie-detail-panel { width: min(640px, 100%); grid-template-columns: 160px 1fr; align-items: start; gap: 16px; }
.movie-detail-poster { border-radius: 10px; }
.movie-detail-copy { display: grid; gap: 12px; min-width: 0; }

.movie-controls {
  margin-top: 10px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.movie-progress { display: flex; align-items: center; gap: 10px; }
.movie-progress input { flex: 1; min-width: 0; accent-color: var(--blue); }
.movie-time { min-width: 56px; color: #c1c9d5; font-size: 13px; font-variant-numeric: tabular-nums; }
.movie-time:last-child { text-align: right; }
.movie-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.movie-actions button { flex: 1; min-width: 74px; }
.movie-note { margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 560px) {
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
  .movie-detail-panel { grid-template-columns: 96px 1fr; gap: 12px; }
}
