:root {
  --night: #070710;
  --deep: #0b0a18;
  --raised: #14122a;
  --self: #f5f3ff;
  --mist: #c8c3e9;
  --tone: #9d91ff;
  --tone-rgb: 157, 145, 255;
  --line: rgba(245, 243, 255, .12);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --sans: "Helvetica Neue", Helvetica, "SF Pro Display", system-ui, sans-serif;
  --serif: "New York", "Iowan Old Style", Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.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;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--night);
  color: var(--self);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 70% -10%, rgba(var(--tone-rgb), .18), transparent 42%),
    radial-gradient(ellipse at 10% 90%, rgba(var(--tone-rgb), .08), transparent 36%),
    var(--night);
}

button, input { font: inherit; color: inherit; }
button {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
}

/* ── Login ─────────────────────────────────────────────────── */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(1.5rem + var(--safe-top)) 1.25rem calc(1.5rem + var(--safe-bottom));
}

.login-card {
  width: min(100%, 22.5rem);
  padding: 2rem 1.6rem 1.75rem;
  border-radius: 1.35rem;
  background:
    linear-gradient(165deg, rgba(var(--tone-rgb), .12), transparent 42%),
    rgba(20, 18, 42, .72);
  box-shadow:
    inset 0 0 0 1px rgba(var(--tone-rgb), .16),
    0 30px 80px rgba(0, 0, 0, .45);
  backdrop-filter: blur(18px);
}

.login-mark {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: 1.6rem;
}
.login-mark span { color: var(--tone); }

.login-kicker {
  margin: 0 0 .45rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(245, 243, 255, .42);
}

.login-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.7rem, 5vw, 2.05rem);
  line-height: 1.15;
}

.login-sub {
  margin: .55rem 0 1.5rem;
  color: rgba(245, 243, 255, .48);
  font-size: .95rem;
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: .75rem;
}

.login-form input {
  width: 100%;
  padding: .95rem 1rem;
  border-radius: .9rem;
  border: 1px solid rgba(245, 243, 255, .12);
  background: rgba(7, 7, 16, .55);
  outline: none;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.login-form input:focus {
  border-color: rgba(var(--tone-rgb), .55);
  box-shadow: 0 0 0 3px rgba(var(--tone-rgb), .14);
}

.login-form button {
  padding: .95rem 1rem;
  border-radius: .9rem;
  background: linear-gradient(145deg, #d4ceff, var(--tone));
  color: #100f1c;
  font-weight: 700;
  letter-spacing: .02em;
  transition: transform 160ms var(--ease), filter 160ms var(--ease);
}

.login-form button:hover { filter: brightness(1.05); }
.login-form button:active { transform: scale(.985); }
.login-form button:disabled { opacity: .55; cursor: wait; }

.login-error {
  margin: .9rem 0 0;
  color: #ffb4a8;
  font-size: .88rem;
}

/* ── Player ────────────────────────────────────────────────── */
.player {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

.stage {
  position: absolute;
  inset: 0;
  background: #000;
}

.video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.slate {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(var(--tone-rgb), .18), transparent 45%),
    linear-gradient(160deg, #12101f, #070710 70%);
}

.slate span {
  display: block;
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(245, 243, 255, .45);
  margin-bottom: .55rem;
}

.slate h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.slate p {
  margin: .55rem 0 0;
  color: rgba(245, 243, 255, .5);
  max-width: 28rem;
  margin-inline: auto;
}

.signal {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: .35rem;
  height: 1.8rem;
  margin-bottom: 1.2rem;
}
.signal i, .signal b {
  display: block;
  width: .28rem;
  border-radius: 99px;
  background: var(--tone);
  animation: eq 1.1s ease-in-out infinite;
}
.signal i:nth-child(1) { height: 35%; animation-delay: 0s; }
.signal i:nth-child(2) { height: 70%; animation-delay: .15s; }
.signal i:nth-child(3) { height: 48%; animation-delay: .3s; }
.signal b { height: 90%; width: .34rem; animation-delay: .45s; box-shadow: 0 0 12px rgba(var(--tone-rgb), .55); }
@keyframes eq {
  0%, 100% { transform: scaleY(.55); opacity: .65; }
  50% { transform: scaleY(1); opacity: 1; }
}

.chrome {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding:
    calc(.9rem + var(--safe-top)) 1rem
    calc(.9rem + var(--safe-bottom));
  background:
    linear-gradient(to bottom, rgba(0,0,0,.55), transparent 28%),
    linear-gradient(to top, rgba(0,0,0,.72), transparent 38%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms var(--ease);
}

.chrome.visible,
.stage.idle-chrome .chrome {
  opacity: 1;
  pointer-events: auto;
}

.chrome-top, .chrome-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.brand {
  font-weight: 700;
  letter-spacing: .03em;
  text-shadow: 0 1px 12px rgba(0,0,0,.5);
}
.brand span { color: var(--tone); }
.brand em { font-style: normal; font-weight: 500; opacity: .55; }

.chrome-actions { display: flex; gap: .35rem; }

.icon-btn {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--self);
  background: rgba(10, 10, 20, .42);
  box-shadow: inset 0 0 0 1px rgba(245, 243, 255, .12);
  backdrop-filter: blur(10px);
}
.icon-btn:hover { background: rgba(var(--tone-rgb), .22); }

.now-card {
  align-self: flex-start;
  max-width: min(28rem, 92vw);
  margin-top: auto;
  margin-bottom: .35rem;
  padding: 1rem 1.1rem 1.05rem;
  border-radius: 1.05rem;
  background: rgba(10, 10, 18, .48);
  box-shadow: inset 0 0 0 1px rgba(245, 243, 255, .1);
  backdrop-filter: blur(14px);
}

.now-live {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(245, 243, 255, .55);
  margin-bottom: .4rem;
}

.live-dot {
  width: .48rem;
  height: .48rem;
  border-radius: 50%;
  background: #ff5d6c;
  box-shadow: 0 0 10px rgba(255, 93, 108, .7);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.now-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.25rem, 3.4vw, 1.7rem);
  line-height: 1.2;
}

.now-meta {
  margin: .4rem 0 .75rem;
  color: rgba(245, 243, 255, .55);
  font-size: .9rem;
}
.now-meta .sep { margin: 0 .35rem; opacity: .4; }

.progress {
  height: .18rem;
  border-radius: 99px;
  background: rgba(245, 243, 255, .12);
  overflow: hidden;
}
.progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--tone);
  box-shadow: 0 0 10px rgba(var(--tone-rgb), .55);
  transition: width 800ms linear;
}

.play-btn {
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #100f1c;
  background: linear-gradient(145deg, #d4ceff, var(--tone));
  box-shadow: 0 8px 28px rgba(var(--tone-rgb), .28);
}

.hint {
  margin: 0;
  font-size: .78rem;
  color: rgba(245, 243, 255, .42);
  text-align: right;
  max-width: 14rem;
  line-height: 1.35;
}

.connection {
  position: absolute;
  left: 50%;
  bottom: calc(1.1rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 5;
  padding: .45rem .8rem;
  border-radius: 999px;
  font-size: .68rem;
  letter-spacing: .14em;
  font-weight: 700;
  color: rgba(245, 243, 255, .7);
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  transition: opacity 280ms var(--ease);
}
.connection.connected { opacity: 0; pointer-events: none; }

.activation {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  transform: translate(-50%, -50%);
  padding: .9rem 1.3rem;
  border-radius: 999px;
  background: linear-gradient(145deg, #d4ceff, var(--tone));
  color: #100f1c;
  font-weight: 700;
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}

/* ── EPG ───────────────────────────────────────────────────── */
.epg {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: rgba(7, 7, 16, .88);
  backdrop-filter: blur(22px);
  padding:
    calc(1rem + var(--safe-top)) 1rem
    calc(1rem + var(--safe-bottom));
  animation: epg-in 220ms var(--ease);
}
@keyframes epg-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.epg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.epg-kicker {
  display: block;
  font-size: .68rem;
  letter-spacing: .18em;
  font-weight: 700;
  color: rgba(245, 243, 255, .4);
  margin-bottom: .25rem;
}

.epg-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
}

.epg-days {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.epg-days::-webkit-scrollbar { display: none; }

.epg-days button {
  flex: 0 0 auto;
  padding: .55rem .9rem;
  border-radius: 999px;
  border: 1px solid rgba(245, 243, 255, .12);
  color: rgba(245, 243, 255, .62);
  background: rgba(255,255,255,.03);
  font-size: .86rem;
}
.epg-days button.active {
  color: #100f1c;
  background: linear-gradient(145deg, #d4ceff, var(--tone));
  border-color: transparent;
  font-weight: 700;
}

.epg-list {
  flex: 1;
  overflow: auto;
  padding-right: .2rem;
  mask-image: linear-gradient(#000 88%, transparent);
  -webkit-overflow-scrolling: touch;
}

.epg-row {
  display: grid;
  grid-template-columns: 4.4rem 1fr;
  gap: .85rem;
  padding: .85rem .2rem;
  border-bottom: 1px solid rgba(245, 243, 255, .07);
}

.epg-row.current {
  background: linear-gradient(90deg, rgba(var(--tone-rgb), .14), transparent 70%);
  border-radius: .7rem;
  border-bottom-color: transparent;
  padding-inline: .65rem;
}

.epg-row time {
  font-variant-numeric: tabular-nums;
  color: rgba(245, 243, 255, .42);
  font-size: .88rem;
  padding-top: .12rem;
}
.epg-row.current time { color: var(--tone); font-weight: 700; }

.epg-row strong {
  display: block;
  font-weight: 600;
  line-height: 1.3;
}
.epg-row small {
  display: block;
  margin-top: .2rem;
  color: rgba(245, 243, 255, .42);
  font-size: .82rem;
  line-height: 1.35;
}
.epg-row .tag {
  display: inline-block;
  margin-top: .35rem;
  padding: .12rem .45rem;
  border-radius: 999px;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(245, 243, 255, .62);
  background: rgba(255,255,255,.06);
}
.epg-row.current .tag {
  color: #100f1c;
  background: rgba(var(--tone-rgb), .85);
}

.epg-empty {
  padding: 2rem 0;
  text-align: center;
  color: rgba(245, 243, 255, .42);
}

@media (min-width: 860px) {
  .epg {
    left: auto;
    width: min(28rem, 42vw);
    border-left: 1px solid rgba(245, 243, 255, .08);
    background: rgba(7, 7, 16, .92);
  }
  .hint { max-width: none; }
}

@media (max-width: 520px) {
  .hint { display: none; }
  .now-card { max-width: 100%; }
}
