:root {
  color-scheme: dark;
  --bg: #090a0b;
  --panel: #111315;
  --panel-2: #17191c;
  --panel-3: #202328;
  --line: #2a2e33;
  --text: #f5f7f8;
  --muted: #9299a1;
  --soft: #c7ccd1;
  --accent: #e5ff59;
  --danger: #ff766f;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; min-height: 100%; overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

[hidden] { display: none !important; }

.login-screen {
  height: 100%;
  min-height: 100vh;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 25%, rgba(229, 255, 89, .08), transparent 34%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 34px;
  box-shadow: 0 28px 80px rgba(0,0,0,.35);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #0b0c0d;
  font-weight: 900;
  letter-spacing: -.05em;
  margin-bottom: 26px;
}

.brand-mark--small {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  margin: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: 10px; font-size: 34px; letter-spacing: -.04em; }
.login-copy { color: var(--muted); margin-bottom: 28px; }
.field-label { display: block; color: var(--soft); font-size: 13px; margin-bottom: 8px; }

input[type="password"], input[type="search"], .otp-input {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  background: #0d0f11;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

input[type="password"], .otp-input {
  height: 52px;
  border-radius: 13px;
  padding: 0 14px;
  margin-bottom: 14px;
}

.otp-input {
  text-align: center;
  letter-spacing: .38em;
  font-size: 22px;
  font-weight: 800;
}

.login-secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 15px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--soft);
  padding: 8px 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.link-button:hover { color: var(--accent); }
.link-button:disabled { opacity: .45; cursor: wait; }

input:focus {
  border-color: #596117;
  box-shadow: 0 0 0 3px rgba(229,255,89,.08);
}

.primary-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 13px;
  background: var(--accent);
  color: #101112;
  font-weight: 850;
  cursor: pointer;
}

.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin: 12px 0 0; }

.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 74px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(9,10,11,.96);
}

.brand-wrap { display: flex; gap: 12px; align-items: center; }
.brand-wrap h1 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.brand-wrap .eyebrow { margin-bottom: 1px; font-size: 9px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-button, .text-button, .category-button, .channel-row, .favourite-button, .favourite-large {
  border: 0;
  cursor: pointer;
}

.icon-button, .text-button {
  height: 42px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.icon-button { width: 46px; font-size: 21px; }
.text-button { padding: 0 15px; font-weight: 700; color: var(--soft); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 330px minmax(0, 1fr);
  height: calc(100vh - 74px);
  height: calc(100dvh - 74px);
  overflow: hidden;
}


.sidebar, .channel-panel {
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: #0c0e10;
  padding: 16px 12px;
}

.search-wrap { margin-bottom: 12px; }
input[type="search"] { height: 46px; border-radius: 12px; padding: 0 13px; }

.categories {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.category-button {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  text-align: left;
  border-radius: 10px;
  background: transparent;
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

.category-button:hover { background: var(--panel-2); }
.category-button.active { background: var(--accent); color: #111; }
.category-button.favourites { margin-bottom: 8px; }

.channel-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}

.panel-heading {
  min-height: 75px;
  padding: 16px 15px 13px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.panel-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.channel-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.channel-list { min-height: 0; overflow: auto; padding: 7px; }

.channel-row {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 10px;
  padding: 7px;
  border-radius: 12px;
  background: transparent;
  text-align: left;
}

.channel-row:hover { background: var(--panel-2); }
.channel-row.active { background: var(--panel-3); }

.channel-logo {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: contain;
  background: #0c0e10;
  padding: 4px;
}

.channel-logo-fallback {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: #0c0e10;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 800;
  font-size: 11px;
}

.channel-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 720;
  font-size: 13px;
}

.favourite-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
}

.favourite-button.on { color: var(--accent); }
.empty-state, .guide-empty {
  color: var(--muted);
  padding: 26px 18px;
  font-size: 13px;
  line-height: 1.5;
}

.viewer {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 62vh;
  background: #000;
  overflow: hidden;
}

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

.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  background: radial-gradient(circle at center, #181b1e, #050607 70%);
  color: var(--muted);
}

.video-placeholder p { margin: 0; font-weight: 700; }
.play-symbol {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 1px solid #363b41;
  border-radius: 50%;
  font-size: 25px;
  padding-left: 4px;
}

.player-status {
  position: absolute;
  top: 14px;
  left: 14px;
  max-width: calc(100% - 28px);
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(12px);
  font-size: 12px;
  color: #fff;
}

.now-playing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.now-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.now-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--panel-2);
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
}
.now-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.now-copy { min-width: 0; }
.now-copy h2 { margin: 0 0 4px; font-size: 21px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-programme { margin: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.favourite-large {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 29px;
  color: var(--muted);
}
.favourite-large.on { color: var(--accent); }
.favourite-large:disabled { opacity: .45; cursor: not-allowed; }

.guide { padding: 8px 22px 22px; }
.guide-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 15px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.guide-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.guide-title { font-weight: 750; font-size: 14px; margin-bottom: 4px; }
.guide-description { color: var(--muted); font-size: 12px; line-height: 1.45; }
.guide-row.current .guide-time, .guide-row.current .guide-title { color: var(--accent); }

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #16191c;
  box-shadow: 0 18px 50px rgba(0,0,0,.4);
  font-size: 13px;
}


.categories, .channel-list, .viewer {
  scrollbar-width: thin;
  scrollbar-color: #3b4046 transparent;
  overscroll-behavior: contain;
}

.categories::-webkit-scrollbar,
.channel-list::-webkit-scrollbar,
.viewer::-webkit-scrollbar { width: 8px; height: 8px; }

.categories::-webkit-scrollbar-thumb,
.channel-list::-webkit-scrollbar-thumb,
.viewer::-webkit-scrollbar-thumb {
  background: #3b4046;
  border-radius: 999px;
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 180px 280px minmax(0, 1fr); }
}

/* Phone / small tablet: video stays visible, categories become a horizontal
   rail and the channel list keeps its own vertical scroll. */
@media (max-width: 820px) {
  html, body { overflow: hidden; }

  .topbar {
    height: 62px;
    padding: 0 12px;
  }

  .brand-mark--small { width: 38px; height: 38px; border-radius: 11px; }
  .brand-wrap h1 { font-size: 16px; }
  .top-actions { gap: 6px; }
  .icon-button { width: 42px; }
  .text-button { padding: 0 11px; }

  .workspace {
    height: calc(100vh - 62px);
    height: calc(100dvh - 62px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(190px, 38vh) auto minmax(0, 1fr);
    grid-template-areas:
      "viewer"
      "sidebar"
      "channels";
    overflow: hidden;
  }

  .viewer {
    grid-area: viewer;
    min-height: 0;
    overflow: auto;
    border-bottom: 1px solid var(--line);
  }

  .video-stage {
    max-height: none;
    min-height: 180px;
  }

  .now-playing { padding: 11px 13px; gap: 10px; }
  .now-logo { width: 46px; height: 46px; border-radius: 11px; }
  .now-copy h2 { font-size: 17px; }
  .favourite-large { width: 44px; height: 44px; border-radius: 12px; }
  .guide { padding: 5px 13px 15px; }
  .guide-row { grid-template-columns: 88px minmax(0, 1fr); gap: 10px; padding: 10px 0; }

  .sidebar {
    grid-area: sidebar;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
  }

  .search-wrap {
    flex: 0 0 clamp(130px, 34vw, 210px);
    margin: 0;
  }

  input[type="search"] { height: 42px; }

  .categories {
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 2px 2px;
  }

  .category-button {
    width: auto;
    min-width: max-content;
    min-height: 42px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .category-button.favourites { margin: 0; }

  .channel-panel {
    grid-area: channels;
    min-height: 0;
    border-right: 0;
  }

  .panel-heading { min-height: 56px; padding: 9px 12px; align-items: center; }
  .panel-heading h2 { font-size: 16px; }
  .channel-list { min-height: 0; overflow-y: auto; }
}

@media (max-width: 520px) {
  .login-screen { padding: 14px; }
  .login-card { padding: 24px 19px; border-radius: 22px; }
  .login-card h1 { font-size: 29px; }

  .workspace { grid-template-rows: minmax(170px, 34vh) auto minmax(0, 1fr); }
  .video-stage { min-height: 165px; }
  .search-wrap { flex-basis: 118px; }
  input[type="search"] { padding: 0 10px; font-size: 13px; }
  .category-button { min-height: 40px; padding: 7px 10px; }
  .channel-row { min-height: 58px; grid-template-columns: 40px minmax(0, 1fr) 36px; }
  .channel-logo, .channel-logo-fallback { width: 40px; height: 40px; }
  .text-button { font-size: 12px; }
  .guide-description { display: none; }
}

@media (pointer: coarse) {
  .category-button { min-height: 50px; }
  .channel-row { min-height: 70px; }
  .icon-button, .text-button { height: 46px; }
}
