:root {
  color-scheme: dark;
  --bg: #0d0e11;
  --bg-warm: #151210;
  --panel: #17191d;
  --panel-soft: #1e2228;
  --panel-strong: #252a31;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f7f7f5;
  --muted: #b8bec7;
  --soft: #89919c;
  --accent: #ff5f57;
  --accent-2: #30d5c8;
  --gold: #f4c95d;
  --danger: #ff6b6b;
  --focus: rgba(48, 213, 200, 0.24);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    linear-gradient(135deg, rgba(255, 95, 87, 0.08), rgba(48, 213, 200, 0.04) 36%, rgba(13, 14, 17, 0) 72%),
    linear-gradient(180deg, var(--bg-warm), var(--bg) 48%, #101418);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 1000;
  background: var(--bg);
  pointer-events: none;
}

button,
input,
audio {
  font: inherit;
}

button,
.controls a {
  appearance: none;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:hover,
.controls a:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.12);
}

button:active,
.controls a:active {
  transform: translateY(1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.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;
}

.login-page {
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 40px);
}

.login-shell {
  width: min(100%, 440px);
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(23, 25, 29, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.login-kicker,
.browse-kicker {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 40px);
  line-height: 1.05;
  letter-spacing: 0;
}

.login-panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.login-panel .remember-row {
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  font-weight: 500;
}

.login-panel input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 14, 17, 0.72);
  color: var(--text);
  padding: 0 13px;
}

.login-panel input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent-2);
}

.login-panel input:focus {
  border-color: var(--accent-2);
}

.login-panel button {
  height: 50px;
  border-color: transparent;
  background: var(--text);
  color: #101214;
  font-weight: 800;
}

.login-panel button:hover {
  background: #ffffff;
}

.login-panel button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.login-error {
  min-height: 22px;
  margin: 0;
  color: #ffb4ab;
  font-size: 14px;
}

.app {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: clamp(340px, 32vw, 500px) minmax(0, 1fr);
}

.player {
  --player-pad: clamp(18px, 2.2vw, 34px);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(180px, auto) auto auto auto;
  gap: clamp(14px, 2vh, 22px);
  align-content: start;
  padding: calc(var(--player-pad) + env(safe-area-inset-top, 0px)) var(--player-pad) var(--player-pad);
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(18, 19, 23, 0.96);
  box-shadow: 18px 0 60px rgba(0, 0, 0, 0.22);
  overflow-y: auto;
}

.brand-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.art-wrap {
  width: min(100%, clamp(180px, calc(100svh - 350px), 430px));
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.42);
}

.art-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.now {
  min-width: 0;
}

.channel-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
}

.channel {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-live {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 107, 107, 0.7);
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.16);
  color: #ffd8d8;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}

.content-live[hidden] {
  display: none;
}

.now h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.02;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.now p {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 1.7vw, 21px);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

audio {
  display: none;
}

.transport {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 76px 1fr;
  align-items: center;
  gap: 18px;
}

.transport-btn {
  min-width: 0;
  min-height: 54px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-weight: 900;
}

.transport-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.step-btn {
  width: 56px;
  height: 56px;
  min-height: 56px;
  border-color: transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.step-btn:hover {
  border-color: transparent;
  background: transparent;
  color: var(--text);
}

.step-btn:active {
  transform: none;
}

#step-back {
  justify-self: end;
}

#step-forward {
  justify-self: start;
}

.play-toggle {
  width: 76px;
  height: 76px;
  min-height: 76px;
  justify-self: center;
  border-color: transparent;
  border-radius: 50%;
  background: var(--text);
  color: #111317;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.transport-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: inherit;
}

.step-btn .transport-icon {
  width: 34px;
  height: 34px;
}

.transport-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.transport-icon path {
  vector-effect: non-scaling-stroke;
}

.track-icon,
.play-toggle.playing .play-icon,
.play-toggle:not(.playing) .pause-icon {
  display: none;
}

.transport.is-track-mode .seek-icon {
  display: none;
}

.transport.is-track-mode .track-icon {
  display: inline-grid;
}

.seek-icon {
  position: relative;
}

.seek-count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: inherit;
  font-size: 7.5px;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-0.5px);
}

.play-toggle:hover {
  background: #ffffff;
  color: #111317;
}

.play-toggle .transport-icon {
  width: 34px;
  height: 34px;
}

.playback-readout {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.playback-readout span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playback-readout span:last-child {
  flex: 0 0 auto;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.controls button,
.controls a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.control-primary {
  border-color: transparent;
  background: var(--text);
  color: #111317;
}

.control-primary:hover {
  background: #ffffff;
  color: #111317;
}

.favorite-btn {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
}

.favorite-btn::before {
  content: "\2606";
  font-size: 22px;
  line-height: 1;
}

.favorite-btn.active {
  border-color: rgba(244, 201, 93, 0.8);
  background: rgba(244, 201, 93, 0.16);
  color: var(--gold);
}

.favorite-btn.active::before {
  content: "\2605";
}

.favorite-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.player-favorite {
  justify-self: stretch;
  width: auto;
}

.live-button {
  color: var(--muted);
}

.live-button.live {
  border-color: rgba(255, 107, 107, 0.72);
  background: rgba(255, 107, 107, 0.16);
  color: #ffe1e1;
}

.live-button.behind {
  border-color: rgba(48, 213, 200, 0.48);
  background: rgba(48, 213, 200, 0.1);
  color: #ddfffb;
}

.live-button.live:not(:disabled):hover {
  background: rgba(255, 107, 107, 0.22);
}

.live-button.behind:not(:disabled):hover {
  background: rgba(48, 213, 200, 0.16);
}

.live-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.browse {
  --browse-pad: clamp(16px, 2.2vw, 34px);
  min-width: 0;
  padding: var(--browse-pad);
}

.browse-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: calc(0px - var(--browse-pad)) calc(0px - var(--browse-pad)) 18px;
  padding: calc(var(--browse-pad) + env(safe-area-inset-top, 0px)) var(--browse-pad) 16px;
  background:
    linear-gradient(180deg, rgba(13, 14, 17, 0.98), rgba(13, 14, 17, 0.88) 78%, rgba(13, 14, 17, 0));
  backdrop-filter: blur(18px);
}

.browse-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.browse-header h2 {
  margin: 0;
  font-size: clamp(28px, 4.4vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

.channel-count {
  flex: 0 0 auto;
  color: var(--soft);
  font-size: 14px;
  font-weight: 800;
}

.search-wrap {
  position: relative;
  display: block;
}

.search-wrap::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid var(--soft);
  border-radius: 50%;
  transform: translateY(-58%);
  pointer-events: none;
}

.search-wrap::after {
  content: "";
  position: absolute;
  left: 29px;
  top: 50%;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: var(--soft);
  transform: rotate(45deg) translate(2px, 5px);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 16px 0 46px;
  font-size: 16px;
  font-weight: 650;
}

#search::placeholder {
  color: #7f8792;
}

#search:focus {
  border-color: rgba(48, 213, 200, 0.72);
  background: rgba(255, 255, 255, 0.1);
}

.channels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.channel-row {
  min-height: 86px;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 71px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.035)),
    rgba(30, 34, 40, 0.82);
  overflow: hidden;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.channel-row:hover {
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05)),
    rgba(37, 42, 49, 0.92);
  transform: translateY(-1px);
}

.channel-row.active {
  border-color: rgba(48, 213, 200, 0.72);
  background:
    linear-gradient(135deg, rgba(48, 213, 200, 0.16), rgba(255, 95, 87, 0.08)),
    rgba(29, 35, 38, 0.95);
}

.channel-play {
  min-width: 0;
  min-height: 84px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 13px;
}

.channel-play:hover {
  border-color: transparent;
  background: transparent;
  transform: none;
}

.channel-art {
  width: 58px;
  height: 58px;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: #282d33;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.channel-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.channel-meta {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.channel-title-line {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: center;
}

.channel-number {
  width: fit-content;
  min-width: 0;
  max-width: none;
  overflow: visible;
  border: 0;
  border-radius: 0;
  color: var(--accent-2);
  padding: 0;
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.channel-meta strong,
.channel-meta small {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.channel-meta strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.channel-meta small {
  color: var(--soft);
  font-size: 13px;
}

.channel-favorite {
  width: 58px;
  height: 58px;
  justify-self: end;
  margin-right: 13px;
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 130px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 750;
}

@media (min-width: 1500px) {
  .channels {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

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

  .player {
    position: relative;
    height: auto;
    grid-template-columns: minmax(120px, 190px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-row {
    grid-column: 1 / -1;
  }

  .art-wrap {
    grid-column: 1;
    grid-row: span 3;
    width: min(100%, 190px);
  }

  .now,
  .transport,
  .playback-readout,
  .controls {
    grid-column: 2;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .browse-toolbar {
    top: 0;
  }
}

@media (max-width: 640px) {
  body {
    background: var(--bg);
  }

  .player {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .brand-row {
    font-size: 13px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    padding: 3px;
  }

  .art-wrap {
    width: 92px;
    align-self: start;
  }

  .now h1 {
    font-size: 24px;
    line-height: 1.08;
  }

  .now p {
    margin-top: 6px;
    font-size: 15px;
  }

  audio,
  .transport,
  .playback-readout,
  .controls {
    grid-column: 1 / -1;
  }

  .transport {
    grid-template-columns: 1fr 68px 1fr;
    gap: 14px;
  }

  .transport-btn {
    min-height: 50px;
  }

  .step-btn {
    width: 50px;
    height: 50px;
  }

  .step-btn .transport-icon {
    width: 32px;
    height: 32px;
  }

  .play-toggle {
    width: 68px;
    height: 68px;
    min-height: 68px;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .controls button,
  .controls a {
    min-height: 44px;
    padding-inline: 9px;
    font-size: 13px;
  }

  .browse {
    padding: 14px;
  }

  .browse-toolbar {
    margin: -14px -14px 14px;
    padding: 14px 14px 12px;
  }

  .browse-header {
    align-items: start;
    margin-bottom: 12px;
  }

  .browse-header h2 {
    font-size: 28px;
  }

  .channel-count {
    padding-top: 3px;
    font-size: 12px;
  }

  #search {
    height: 48px;
  }

  .channels {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .channel-row {
    min-height: 74px;
    grid-template-columns: minmax(0, 1fr) 63px;
  }

  .channel-play {
    min-height: 74px;
    grid-template-columns: 52px minmax(0, 1fr);
    padding: 11px;
  }

  .channel-art {
    width: 52px;
    height: 52px;
  }

  .channel-favorite {
    width: 52px;
    height: 52px;
    margin-right: 11px;
  }
}

@media (max-width: 380px) {
  .player {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .art-wrap {
    width: 78px;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
