:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: #050713;
  color: #f7f9ff;
  --cyan: #00c8ff;
  --blue: #236dff;
  --violet: #8f3fff;
  --panel: rgba(12, 18, 38, 0.76);
  --panel-solid: #0d1428;
  --border: rgba(145, 180, 255, 0.2);
  --muted: #a7b1c9;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #050713; }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(0, 174, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 88% 84%, rgba(141, 58, 255, 0.18), transparent 32rem),
    linear-gradient(145deg, #040610 0%, #080d1c 48%, #050816 100%);
}

button, input { font: inherit; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  filter: blur(84px);
  opacity: 0.28;
  pointer-events: none;
}

.ambient-a { top: -8rem; left: -7rem; background: var(--cyan); }
.ambient-b { right: -8rem; bottom: -8rem; background: var(--violet); }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1160px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: grid;
  align-items: center;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.78fr);
  gap: clamp(32px, 7vw, 92px);
  align-items: center;
}

.brand-panel { padding: clamp(8px, 3vw, 36px); }

.brand-icon {
  display: block;
  width: clamp(88px, 10vw, 126px);
  height: auto;
  margin-bottom: 28px;
  border-radius: 25%;
  box-shadow: 0 22px 70px rgba(29, 92, 255, 0.36);
}

.eyebrow, .version {
  margin: 0 0 12px;
  color: #70dcff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.17em;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.6rem);
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.brand-copy {
  max-width: 590px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.24rem);
  line-height: 1.55;
}

.feature-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 34px;
}

.feature-strip span {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(9, 16, 34, 0.72);
  color: #dce7ff;
  font-size: 0.88rem;
}

.login-card {
  padding: clamp(24px, 4vw, 38px);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(24px) saturate(1.25);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
}

.card-heading h2, dialog h2 { margin: 0; font-size: 1.75rem; letter-spacing: -0.025em; }
.card-heading > p:last-child { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }

fieldset {
  display: grid;
  gap: 14px;
  margin: 26px 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 12px;
  color: #dce6fb;
  font-size: 0.92rem;
  font-weight: 700;
}

label { display: grid; gap: 7px; }
label span { color: #aeb9d0; font-size: 0.86rem; font-weight: 650; }

input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid rgba(139, 167, 226, 0.22);
  border-radius: 14px;
  outline: none;
  background: rgba(3, 8, 22, 0.72);
  color: #fff;
  font-size: 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--cyan);
  background: rgba(5, 12, 29, 0.96);
  box-shadow: 0 0 0 4px rgba(0, 200, 255, 0.14);
}

.form-message { min-height: 22px; margin: 18px 0 0; color: #ff8d9c; font-size: 0.88rem; }

.primary-button, .install-button {
  width: 100%;
  min-height: 54px;
  border-radius: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border: 0;
  background: linear-gradient(110deg, #00bff5, #2374ff 56%, #8a46ff);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 40px rgba(35, 109, 255, 0.27);
}

.primary-button:active { transform: translateY(1px); }

.install-button {
  margin-top: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: #c9d6ef;
  font-weight: 700;
}

dialog {
  width: min(420px, calc(100% - 32px));
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #0b1225;
  color: #fff;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.68);
}

dialog::backdrop { background: rgba(0, 3, 12, 0.78); backdrop-filter: blur(10px); }
dialog ol { margin: 20px 0 0; padding-left: 24px; color: #c9d4ea; line-height: 1.65; }
.dialog-close { position: absolute; top: 13px; right: 14px; border: 0; background: transparent; color: #fff; font-size: 1.8rem; cursor: pointer; }

@media (max-width: 820px) {
  .app-shell { align-items: start; }
  .login-shell { grid-template-columns: 1fr; gap: 26px; }
  .brand-panel { padding: 12px 4px 0; }
  .brand-icon { width: 86px; margin-bottom: 20px; }
  h1 { font-size: clamp(2.2rem, 11vw, 3.7rem); }
  .brand-copy { margin-top: 18px; }
  .feature-strip { margin-top: 22px; }
}

@media (max-width: 480px) {
  .app-shell { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .brand-panel { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center; }
  .brand-icon { width: 72px; margin: 0; grid-row: 1 / 3; }
  .brand-panel .eyebrow { align-self: end; }
  .brand-panel h1 { align-self: start; font-size: 2rem; line-height: 1.02; }
  .brand-copy, .feature-strip { grid-column: 1 / -1; }
  .feature-strip span { font-size: 0.8rem; }
  .login-card { border-radius: 22px; padding: 22px 18px; }
}

[hidden] { display: none !important; }

.tv-shell {
  min-width: 0;
  min-height: calc(100dvh - max(48px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  display: grid;
  grid-template-rows: auto auto minmax(460px, 1fr);
  gap: 12px;
}

.tv-header {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(7, 12, 27, 0.86);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.tv-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.tv-brand img { border-radius: 12px; box-shadow: 0 7px 22px rgba(35, 109, 255, 0.32); }
.tv-brand div { display: grid; gap: 2px; }
.tv-brand strong { font-size: 1rem; }
.tv-brand span { color: #7f8ba6; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.13em; }

.day-control { display: grid; grid-template-columns: 42px minmax(130px, auto) 42px; align-items: center; gap: 7px; }
.day-control button, .header-actions button {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(16, 25, 49, 0.86);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.day-control > button:not(.day-label) { font-size: 1.65rem; line-height: 1; }
.day-label { padding: 0 16px; font-weight: 800; white-space: nowrap; }
.header-actions { display: flex; justify-content: flex-end; gap: 8px; }
.now-button { padding: 0 15px; font-weight: 750; }
.account-button { width: 44px; font-size: 1.35rem; }

.notice {
  min-height: 20px;
  padding: 0 8px;
  color: #9eadc9;
  font-size: 0.86rem;
}
.notice.error { color: #ff99a8; }

.guide {
  --channel-width: clamp(112px, 17vw, 174px);
  --row-height: 70px;
  --time-height: 44px;
  display: grid;
  grid-template-columns: var(--channel-width) minmax(0, 1fr);
  grid-template-rows: var(--time-height) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(5, 9, 21, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

.guide-corner {
  z-index: 5;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #0c1428;
  color: #8997b3;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.time-viewport {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: #0c1428;
}

.time-track { position: relative; height: 100%; will-change: transform; }
.time-label {
  position: absolute;
  top: 0;
  height: 100%;
  padding: 13px 0 0 10px;
  border-left: 1px solid rgba(139, 165, 221, 0.13);
  color: #a4b0c8;
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
}

.channel-viewport {
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: #090f20;
}
.channel-track { position: relative; will-change: transform; }
.channel-row {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  height: var(--row-height);
  padding: 7px 10px;
  border-bottom: 1px solid rgba(139, 165, 221, 0.11);
}
.channel-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 9px;
  background: #f4f6fb;
  color: #07101f;
}
.channel-logo-fallback {
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  font-weight: 900;
}
.channel-name { overflow: hidden; color: #edf3ff; font-size: 0.86rem; font-weight: 750; line-height: 1.15; text-overflow: ellipsis; }

.program-viewport {
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: rgba(111, 139, 200, 0.45) transparent;
}
.program-canvas { position: relative; min-width: 100%; }
.program-row {
  position: absolute;
  left: 0;
  display: block;
  height: var(--row-height);
  border-bottom: 1px solid rgba(139, 165, 221, 0.1);
  background-image: linear-gradient(90deg, rgba(138, 164, 219, 0.08) 1px, transparent 1px);
  background-size: var(--hour-width, 300px) 100%;
}
.program-card {
  position: absolute;
  top: 5px;
  bottom: 5px;
  min-width: 28px;
  padding: 9px 11px;
  overflow: hidden;
  border: 1px solid rgba(146, 171, 224, 0.22);
  border-radius: 10px;
  background: #1a243b;
  color: #f6f9ff;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.program-card strong, .program-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.program-card strong { font-size: 0.86rem; }
.program-card span { margin-top: 4px; color: #b7c2d9; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.program-card.playable { border-color: rgba(49, 223, 154, 0.55); background: linear-gradient(135deg, #104b3c, #12352f); }
.program-card.unavailable { border-color: rgba(255, 90, 116, 0.42); background: linear-gradient(135deg, #45202d, #2d1b28); color: #d9a8b1; }
.program-card.live-now { border-color: rgba(0, 206, 255, 0.85); background: linear-gradient(120deg, #086497, #245dcc 62%, #6d3ac9); box-shadow: 0 0 0 1px rgba(0, 208, 255, 0.2), 0 9px 28px rgba(0, 110, 255, 0.28); }
.program-card.future { opacity: 0.72; cursor: default; }
.program-card:focus-visible { outline: 3px solid #fff; outline-offset: -4px; }

.now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 4;
  width: 2px;
  background: #ff3c68;
  box-shadow: 0 0 14px rgba(255, 60, 104, 0.8);
  pointer-events: none;
}
.now-line::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff3c68;
}

.guide-loading {
  position: absolute;
  z-index: 8;
  inset: 18px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(5, 10, 23, 0.86);
  color: #c5d1e8;
  font-weight: 750;
}

.player-sheet {
  position: fixed;
  z-index: 50;
  inset: 0;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: #02040a;
}
.player-topbar {
  position: absolute;
  z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(178, 199, 238, 0.2);
  border-radius: 16px;
  background: rgba(3, 7, 17, 0.74);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 200ms ease;
}
.player-topbar p { margin: 0 0 3px; color: #7bdcff; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.player-topbar h2 { margin: 0; font-size: clamp(1rem, 3vw, 1.35rem); }
.player-topbar button { width: 48px; height: 48px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(22,30,50,.76); color: #fff; font-size: 1.9rem; cursor: pointer; }
.video-stage { position: relative; display: grid; place-items: center; width: 100%; height: 100%; }
#video-player { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-state { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%); padding: 10px 15px; border-radius: 999px; background: rgba(3,8,18,.78); color: #d7e4ff; font-size: 0.86rem; pointer-events: none; }

@media (max-width: 720px) {
  .app-shell:has(.tv-shell:not([hidden])) { padding: max(8px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .tv-shell { min-height: calc(100dvh - 16px); grid-template-rows: auto auto minmax(420px, 1fr); }
  .tv-header { grid-template-columns: auto 1fr auto; gap: 7px; min-height: 58px; padding: 8px; border-radius: 16px; }
  .tv-brand strong { display: none; }
  .tv-brand img { width: 38px; height: 38px; }
  .tv-brand span { font-size: 0.62rem; }
  .day-control { grid-template-columns: 36px minmax(90px, 1fr) 36px; gap: 4px; }
  .day-control button, .header-actions button { min-height: 38px; border-radius: 10px; }
  .day-label { padding: 0 7px; font-size: 0.78rem; }
  .now-button { display: none; }
  .guide { --channel-width: 104px; --row-height: 64px; border-radius: 15px; }
  .guide-corner { padding: 0 9px; font-size: 0.67rem; }
  .channel-row { grid-template-columns: 34px minmax(0, 1fr); gap: 7px; padding: 6px 7px; }
  .channel-logo { width: 34px; height: 34px; border-radius: 7px; }
  .channel-name { font-size: 0.76rem; }
  .program-card { top: 4px; bottom: 4px; padding: 8px 9px; border-radius: 9px; }
  .program-card strong { font-size: 0.78rem; }
  .program-card span { font-size: 0.67rem; }
}
