@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  color-scheme: dark;
  --bg: #050505;
  --fg: #f4f4f0;
  --dim: #94948e;
  --line: #343432;
  --panel: #0c0c0b;
  --focus: #d7ff44;
  --error: #ff7676;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--fg);
  font-family: "Space Mono", monospace;
}
body:not(.login-page) { overflow: hidden; }
button, input, select { font: inherit; }
button, input, select, audio { width: 100%; }
button, input, select {
  min-height: 42px;
  border: 1px solid var(--fg);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
}
button {
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
}
button:hover, button:focus-visible, .primary { background: var(--fg); color: var(--bg); }
button:disabled { cursor: not-allowed; opacity: .35; }
input, select { padding: 0 12px; }
input::placeholder { color: #72726d; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

main {
  width: min(1440px, calc(100% - 28px));
  height: 100dvh;
  margin: 0 auto;
  padding: 16px 0 12px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
}
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 1px solid var(--fg);
  padding-bottom: 10px;
}
h1 { font-size: clamp(2.4rem, 5vw, 4.8rem); line-height: .78; letter-spacing: -.09em; margin: 7px 0 0; }
h2 { font-size: clamp(1.15rem, 2vw, 2rem); line-height: 1.05; letter-spacing: -.04em; margin: 4px 0 8px; max-width: 30ch; }
h3 { font-size: 1rem; margin: 3px 0 0; }
p { margin: 0; }
.eyebrow, .label, .index, footer { color: var(--dim); font-size: .68rem; letter-spacing: .1em; }
.live-state { display: flex; gap: 9px; align-items: center; font-size: .75rem; }
.dot { width: 9px; height: 9px; border: 1px solid var(--fg); border-radius: 50%; }
.dot.live { background: var(--focus); border-color: var(--focus); box-shadow: 0 0 14px rgba(215,255,68,.6); }

.panel { background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); padding: 18px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px minmax(260px, 32%);
  gap: 18px;
  align-items: center;
  border-color: var(--fg);
}
.now { min-width: 0; }
.muted, .hint { color: var(--dim); font-size: .7rem; line-height: 1.5; }
.podcast { margin-top: 6px; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-title { display: flex; align-items: flex-start; gap: 9px; min-width: 0; }
.now-title h2 { min-width: 0; }
.restart-podcast {
  flex: 0 0 32px;
  width: 32px;
  min-height: 32px;
  padding: 6px;
  border-color: var(--line);
  color: var(--focus);
}
.restart-podcast[hidden] { display: none; }
.restart-podcast svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-width: 1.8;
}
.preparation-error {
  margin-top: 8px;
  padding: 7px 9px;
  border-left: 3px solid var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
  font-size: .66rem;
  line-height: 1.45;
}
.preparation-error[hidden] { display: none; }
.podcast-selector {
  width: min(100%, 520px);
  margin-top: 10px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: stretch;
  border: 1px solid var(--line);
  background: #090909;
}
.podcast-selector[hidden] { display: none; }
.podcast-selector > .podcast-nav {
  width: 38px;
  min-height: 54px;
  padding: 0;
  border: 0;
  color: var(--focus);
  font-size: 1.55rem;
}
.podcast-selector > .podcast-nav:first-child { border-right: 1px solid var(--line); }
.podcast-selector > .podcast-nav:last-child { border-left: 1px solid var(--line); }
.podcast-selector > .podcast-nav:disabled { color: var(--dim); }
.podcast-choice { min-width: 0; display: grid; align-content: center; gap: 2px; padding: 7px 10px; text-align: center; }
.podcast-choice strong, .podcast-choice span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podcast-choice strong { font-size: .72rem; }
.podcast-choice-actions { display: flex; justify-content: center; align-items: baseline; gap: 10px; }
.podcast-play-now {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--focus);
  font-size: .58rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.transport { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stream-player {
  min-width: 0;
  min-height: 124px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  grid-template-rows: minmax(92px, auto) 30px;
  border: 1px solid var(--fg);
  background: #080808;
}
.stream-play {
  grid-row: 1 / 3;
  width: 76px;
  min-height: 74px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--fg);
  color: var(--focus);
  font-size: .72rem;
}
.stream-play:hover, .stream-play:focus-visible, .stream-play.playing {
  background: var(--focus);
  color: var(--bg);
}
.stream-readout {
  min-width: 0;
  padding: 9px 12px 7px;
}
.stream-readout-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.stream-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
}
.stream-name i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--focus);
  box-shadow: 0 0 10px rgba(215,255,68,.55);
}
#streamStatus { color: var(--dim); font-size: .58rem; letter-spacing: .08em; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.music-break-link {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--dim);
  font-size: .56rem;
  letter-spacing: .06em;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.music-break-link:hover,
.music-break-link:focus-visible,
.music-break-link.selecting { color: var(--fg); }
.music-break-link:disabled { color: var(--dim); cursor: wait; }
.podcast-timeline { margin-top: 8px; }
.podcast-timeline-times {
  display: flex;
  justify-content: space-between;
  color: var(--dim);
  font-size: .56rem;
  letter-spacing: .04em;
}
.podcast-timeline-track {
  --podcast-progress: 0%;
  position: relative;
  height: 18px;
  margin-top: 1px;
  background: linear-gradient(
    to right,
    var(--focus) 0,
    var(--focus) var(--podcast-progress),
    var(--line) var(--podcast-progress),
    var(--line) 100%
  ) center / 100% 3px no-repeat;
}
.podcast-timeline-track.adding-break {
  background: linear-gradient(var(--fg), var(--fg)) center / 100% 3px no-repeat;
}
.podcast-breaks {
  position: absolute;
  inset: 2px 0;
  pointer-events: none;
}
.podcast-break {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  transform: translateX(-2px);
  background: #ffcb44;
  box-shadow: 0 0 7px rgba(255,203,68,.7);
}
.music-break-cursor {
  display: none;
  position: absolute;
  z-index: 2;
  top: 1px;
  width: 17px;
  height: 16px;
  transform: translateX(-8px);
  place-items: center;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.podcast-timeline-track.adding-break .music-break-cursor { display: grid; }
#podcastProgress {
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
}
.podcast-timeline-track.adding-break #podcastProgress::-webkit-slider-thumb {
  opacity: 0;
}
.podcast-timeline-track.adding-break #podcastProgress::-moz-range-thumb {
  opacity: 0;
}
#podcastProgress:disabled { cursor: wait; opacity: .65; }
#podcastProgress::-webkit-slider-runnable-track { height: 3px; background: transparent; }
#podcastProgress::-webkit-slider-thumb {
  appearance: none;
  width: 8px;
  height: 15px;
  margin-top: -6px;
  border: 1px solid var(--bg);
  border-radius: 0;
  background: var(--fg);
}
#podcastProgress::-moz-range-track { height: 3px; background: transparent; }
#podcastProgress::-moz-range-thumb {
  width: 8px;
  height: 15px;
  border: 1px solid var(--bg);
  border-radius: 0;
  background: var(--fg);
}
#podcastSeekLimit {
  display: block;
  overflow: hidden;
  color: var(--dim);
  font-size: .48rem;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stream-volume {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
}
.stream-volume button {
  width: 42px;
  min-height: 24px;
  padding: 0;
  border: 0;
  color: var(--dim);
  font-size: .58rem;
}
.stream-volume input {
  appearance: none;
  min-height: 20px;
  height: 2px;
  padding: 0;
  border: 0;
  background: var(--line);
  accent-color: var(--focus);
}
.stream-volume input::-webkit-slider-thumb {
  appearance: none;
  width: 9px;
  height: 14px;
  background: var(--focus);
  border: 0;
}
.stream-volume input::-moz-range-thumb {
  width: 9px;
  height: 14px;
  background: var(--focus);
  border: 0;
  border-radius: 0;
}
.stream-player audio { display: none; }
.management-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; min-height: 0; }
.management-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 13px; border-bottom: 1px solid var(--line); margin-bottom: 13px; }
label { display: block; font-size: .7rem; color: var(--dim); margin-bottom: 7px; }
.select-wrap { position: relative; margin-bottom: 10px; }
.select-wrap::after { content: "↓"; position: absolute; right: 13px; top: 50%; transform: translateY(-54%); pointer-events: none; color: var(--focus); }
select { appearance: none; padding-right: 42px; border-color: var(--line); background: #090909; }
select:hover { border-color: var(--fg); }
select option { background: #0b0b0b; color: var(--fg); }
.inline-form, .channel-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; flex: 0 0 auto; }
.inline-form button, .channel-form button { width: auto; border-left: 0; }
.bounded-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--dim) transparent; scrollbar-width: thin; }
.results { display: grid; margin-top: 10px; flex: 1 1 0; }
.result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding: 10px 2px; }
.result:first-child { border-top: 0; }
.result div { min-width: 0; }
.result strong, .result span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result span { color: var(--dim); font-size: .67rem; margin-top: 2px; }
.result button { width: auto; min-height: 32px; font-size: .65rem; }
.podcast-sources { min-height: 0; }
.source-pages {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 10px;
}
.source-page {
  min-height: 32px;
  padding: 0 8px;
  border-color: var(--line);
  font-size: .62rem;
}
.source-page + .source-page { border-left: 0; }
.source-page.active { background: var(--fg); color: var(--bg); }
.source-page-panel { min-height: 0; }
.source-page-panel[hidden] { display: none; }
.source-list-panel { display: flex; flex: 1 1 0; flex-direction: column; }
.compact-form input, .compact-form button { min-height: 34px; }
.source-search {
  flex: 0 0 auto;
  min-height: 34px;
  border-color: var(--line);
  background: #090909;
}
.channel-list { margin-top: 10px; flex: 1 1 0; }
.channel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 10px 2px;
  font-size: .7rem;
}
.channel-copy { min-width: 0; }
.channel-copy strong, .channel-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-copy strong { margin-bottom: 3px; font-size: .72rem; }
.channel-copy span { color: var(--dim); font-size: .59rem; }
.channel button { width: auto; min-height: 32px; border-color: var(--line); font-size: .63rem; }
.history-list { margin-top: 0; }
.history-list .channel button.primary { border-color: var(--focus); }
footer { display: flex; justify-content: space-between; gap: 20px; min-height: 18px; }
.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; }

.header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 8px;
  border-color: var(--line);
  background: #090909;
}
.icon-button svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; }
.icon-button:hover svg, .icon-button:focus-visible svg { stroke: var(--bg); }
.roll-clockwise { animation: roll-clockwise .42s cubic-bezier(.2,.8,.2,1); }
.roll-counterclockwise { animation: roll-counterclockwise .42s cubic-bezier(.2,.8,.2,1); }
@keyframes roll-clockwise { to { transform: rotate(180deg); } }
@keyframes roll-counterclockwise { to { transform: rotate(-180deg); } }
.dot.paused { background: #ffcb44; border-color: #ffcb44; box-shadow: 0 0 14px rgba(255,203,68,.55); }
.playlist-picker { position: relative; margin-bottom: 10px; }
.playlist-picker input {
  border-color: var(--line);
  background: #090909;
  padding-right: 48px;
}
.playlist-picker input::-webkit-search-cancel-button { display: none; }
.playlist-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: #090909;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
}
.playlist-options[hidden] { display: none; }
.playlist-option {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  text-align: left;
  text-transform: none;
}
.playlist-option:last-child { border-bottom: 0; }
.playlist-option:hover,
.playlist-option:focus,
.playlist-option[aria-selected="true"] {
  color: var(--bg);
  background: var(--focus);
}
.playlist-clear {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 40px;
  min-height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--focus);
  background: #090909;
}
.playlist-clear[hidden] { display: none; }
.playlist-clear span { font-size: 1.45rem; line-height: 1; }
.active-source-clear {
  position: absolute;
  top: 50%;
  right: 8px;
  z-index: 1;
  width: 38px;
  min-height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border-color: var(--line);
  color: var(--focus);
  background: #090909;
}
.active-source-clear[hidden] { display: none; }
.active-source-clear span { font-size: 1.4rem; line-height: 1; }
.active-source {
  position: relative;
  min-height: 76px;
  padding: 12px 58px 12px 12px;
  border: 1px solid var(--line);
  margin-bottom: 9px;
  display: grid;
  align-content: center;
  gap: 5px;
  overflow: hidden;
}
.active-source strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; }
.source-confirm {
  position: absolute;
  inset: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  background: #0b0b0b;
}
.source-confirm[hidden] { display: none; }
.source-confirm span { min-width: 0; font-size: .65rem; }
.source-confirm button { width: auto; min-height: 34px; padding: 0 9px; font-size: .58rem; }
.video-form { margin-top: 10px; }
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.76);
  backdrop-filter: blur(8px);
  animation: overlay-in .24s ease-out both;
}
.settings-overlay[hidden] { display: none; }
.settings-overlay.closing { animation: overlay-out .26s ease-in both; }
@keyframes overlay-in { from { opacity: 0; } }
@keyframes overlay-out { to { opacity: 0; } }
.settings-panel {
  width: min(100%, 660px);
  max-height: min(760px, calc(100dvh - 40px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--fg);
  background: #090909;
  box-shadow: 14px 14px 0 rgba(215,255,68,.18);
}
.settings-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-head h2 { margin-bottom: 0; }
.close-button { font-size: 1.3rem; line-height: 1; }
.settings-body { min-height: 0; overflow-y: auto; }
.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row strong { display: block; margin-bottom: 5px; }
.setting-row.stacked { display: block; }
.setting-row.stacked select, .setting-row.stacked input { margin-bottom: 7px; background: #050505; }
.switch { margin: 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  display: block;
  width: 54px;
  height: 28px;
  border: 1px solid var(--fg);
  padding: 3px;
  cursor: pointer;
}
.switch span::before { content: ""; display: block; width: 20px; height: 20px; background: var(--dim); transition: transform .2s, background .2s; }
.switch input:checked + span::before { transform: translateX(26px); background: var(--focus); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
.settings-actions {
  flex: 0 0 auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  background: #090909;
  box-shadow: 0 -16px 24px rgba(9,9,9,.94);
}
#saveSettings { margin: 0; }

.login-page { display: grid; min-height: 100dvh; place-items: center; overflow: auto; }
.login-shell { width: min(100% - 28px, 520px); height: auto; display: block; padding: 32px 0; }
.login-card { position: relative; border: 1px solid var(--fg); background: rgba(8,8,8,.96); padding: clamp(26px, 7vw, 52px); box-shadow: 12px 12px 0 #1b1b19; }
.login-mark { position: absolute; top: 18px; right: 18px; display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--focus); color: var(--focus); font-weight: 700; }
.login-title { margin: 14px 0 24px; font-size: clamp(3.5rem, 15vw, 6.5rem); }
.login-intro { max-width: 38ch; color: var(--dim); font-size: .78rem; line-height: 1.65; margin-bottom: 28px; }
.login-form { display: grid; }
.login-form input { margin-bottom: 16px; background: #090909; }
.login-form button { margin-top: 6px; }
.login-error { min-height: 1.4em; margin-top: 14px; color: var(--error); font-size: .72rem; }

@media (max-width: 760px) {
  body:not(.login-page) { overflow: auto; }
  main { width: min(100% - 20px, 640px); height: auto; min-height: 100dvh; padding: 20px 0; display: block; }
  .masthead { align-items: flex-start; margin-bottom: 12px; }
  h1 { font-size: clamp(3rem, 18vw, 5.5rem); }
  .hero { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
  .transport { grid-template-columns: 1fr 1fr; }
  .management-grid { grid-template-columns: 1fr; gap: 12px; }
  .management-panel { min-height: 330px; max-height: 430px; }
  .management-panel:first-child { min-height: 0; }
  .bounded-list { max-height: 260px; }
  .inline-form, .channel-form { grid-template-columns: 1fr; gap: 7px; }
  .inline-form button, .channel-form button { width: 100%; border-left: 1px solid var(--fg); }
  .podcast-sources .compact-form { grid-template-columns: minmax(0, 1fr) auto; gap: 0; }
  .podcast-sources .compact-form button {
    width: auto;
    min-width: 76px;
    border-left: 0;
  }
  .podcast-sources .compact-form input { min-width: 0; }
  footer { flex-direction: column; padding-top: 18px; }
  .login-card { box-shadow: 7px 7px 0 #1b1b19; }
  .source-confirm { grid-template-columns: 1fr 1fr; }
  .source-confirm span { grid-column: 1 / -1; }
  .settings-overlay { padding: 10px; }
  .settings-panel { max-height: calc(100dvh - 20px); padding: 18px; box-shadow: 7px 7px 0 rgba(215,255,68,.18); }
  .setting-row { gap: 14px; }
}
