/**
 * Shell layout - Step 1 + Step 2
 * Vertical sidebar + main + panes. Dark theme (Windows Phone style).
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  min-height: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: #ffffff;
  background: #000000;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: #000000;
}

body:not(.shell-authenticated) #app {
  display: none;
}

.shell-auth-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #000000;
  z-index: 9999;
}

body.shell-authenticated .shell-auth-gate,
body.shell-authenticated #auth-gate {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

.shell-auth-gate[hidden] {
  display: none !important;
}

.shell-auth-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid #1f1f1f;
  background: #0a0a0a;
  border-radius: 6px;
}

.shell-auth-card[hidden] {
  display: none;
}

.shell-auth-title {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
}

.shell-auth-subtitle {
  margin: 0 0 8px;
  font-size: 13px;
  color: #a9a9a9;
}

.shell-auth-label {
  font-size: 12px;
  color: #c8c8c8;
}

.shell-auth-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #2e2e2e;
  border-radius: 4px;
  background: #121212;
  color: #ffffff;
  font-size: 14px;
}

.shell-auth-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.shell-auth-input-row .shell-auth-input {
  flex: 1;
}

.shell-auth-toggle {
  border: 1px solid #303030;
  border-radius: 4px;
  background: #1b1b1b;
  color: #d0d0d0;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.shell-auth-toggle:hover {
  background: #262626;
}

.shell-auth-input:focus {
  outline: 1px solid #666;
}

.shell-auth-submit {
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  background: #222;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.shell-auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.shell-auth-submit--secondary {
  background: #171717;
  border-color: #2f2f2f;
  color: #d9d9d9;
}

.shell-auth-submit:disabled {
  opacity: 0.75;
  cursor: default;
}

.shell-auth-status {
  min-height: 1.2em;
  margin: 4px 0 0;
  color: #9fb8ff;
  font-size: 13px;
}

.shell-auth-status--error {
  color: #ff8a8a;
}

.shell-auth-switch {
  margin: 0;
  color: #a9a9a9;
  font-size: 12px;
}

.shell-auth-link {
  margin-left: 4px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #9fb8ff;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.shell-auth-link:hover {
  color: #c2d2ff;
}

/* Sidebar - fixed on the left */
.shell-sidebar {
  flex-shrink: 0;
  width: 130px;
  min-height: 0;
  align-self: stretch;
  background: #000000;
  border-right: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 8px 0;
  gap: 4px;
}

.sidebar-item {
  padding: 12px 16px;
  color: #ffffff;
  font-size: 14px;
  cursor: default;
  text-align: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e0e0e0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.sidebar-item--auth {
  margin-top: auto;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: center;
  font-family: inherit;
}

.sidebar-item--chat-meta {
  padding: 4px 10px 8px;
  font-size: 11px;
  color: #8a8a8a;
  cursor: default;
}

.sidebar-item[data-pane] {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-left: 14px;
  padding-right: 14px;
}

.sidebar-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-close {
  display: none;
  flex-shrink: 0;
  min-width: 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 2px;
  color: #888;
}

.sidebar-item-close:hover {
  background: #444;
  color: #fff;
}

.sidebar-item--pane-open .sidebar-item-close {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-item--active,
.sidebar-item--pane-open,
.sidebar-item--rail-active {
  background: #1a1a1a;
  border-left: 3px solid #ffffff;
  padding-left: 13px;
}

.sidebar-item--active:hover,
.sidebar-item--pane-open:hover,
.sidebar-item--rail-active:hover {
  background: #1a1a1a;
  color: #ffffff;
}

/* Content column: main + panes stacked vertically */
.shell-content {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Main wrap: main + right rail in a row */
.shell-main-wrap {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.shell-content.has-open-panes {
  --pane-ratio: 0.5;
}

.shell-content.has-open-panes .shell-main-wrap {
  flex: 1 1 calc(var(--pane-ratio, 0.5) * 100%);
  min-height: 0;
}

/* Main - takes remaining space (Radio view); container for player so width = main column only (art decompresses when main grows). */
.shell-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #000000;
  color: #ffffff;
  overflow: hidden;
  container-type: size;
  container-name: mainwrap;
}

/* Right rail - History / Requests, collapsible */
.shell-rail {
  position: relative;
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #080808;
  border-left: 1px solid #1a1a1a;
  transition: width 0.25s ease, min-width 0.25s ease;
}

.shell-rail.is-open {
  flex: 0 0 auto;
  width: 280px;
  min-width: 280px;
  min-height: 0;
}

.shell-rail-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  font-size: 14px;
  color: #e0e0e0;
  background: #080808;
}

.shell-main-inner {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000000;
  container-type: size;
  container-name: radio;
}

.shell-nowplaying-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--nowplaying-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(50px);
  transform: scale(1.15);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  box-shadow: inset 0 0 0 100vmax rgba(0, 0, 0, 0.6);
}

.shell-main-inner.has-nowplaying-bg {
  background: transparent;
}

.shell-main-inner.has-nowplaying-bg .shell-nowplaying-bg {
  opacity: 1;
}

.shell-placeholder {
  margin: 0;
  color: #999999;
  font-size: 15px;
}

/* Walking cat fixed to viewport bottom (like legacy taskbar) */
.shell-walking-cat {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 80px;
  z-index: 2;
  pointer-events: none;
  animation: shellCatWalk 50s linear infinite;
}

@media (max-width: 768px) {
  .shell-walking-cat {
    animation-duration: 24s;
  }
}

@media (max-width: 480px) {
  .shell-walking-cat {
    animation-duration: 16s;
  }
}

.shell-walking-cat-gif {
  width: 80px;
  height: auto;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

/* Cat walks right, turns at edge, walks back. Transform-only so it doesn’t stick at the end. */
@keyframes shellCatWalk {
  0% {
    transform: translateX(0) scaleX(1);
  }
  49.9% {
    transform: translateX(calc(100vw - 80px)) scaleX(1);
  }
  50% {
    transform: translateX(calc(100vw - 80px)) scaleX(-1);
  }
  50.1% {
    transform: translateX(calc(100vw - 82px)) scaleX(-1);
  }
  99.9% {
    transform: translateX(0) scaleX(-1);
  }
  100% {
    transform: translateX(0) scaleX(1);
  }
}

/* Radio player - Spotify-style (shell palette only) */
.shell-radio-player {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(16px, 5cqw, 40px) clamp(12px, 4cqw, 24px);
  min-height: 200px;
  width: 100%;
  max-width: 360px;
  min-width: 0;
}

.shell-radio-art {
  width: min(280px, 100%);
  min-width: 72px;
  max-width: 280px;
  aspect-ratio: 1;
  height: auto;
  flex-shrink: 0;
  border-radius: clamp(8px, 3cqw, 12px);
  overflow: hidden;
}

.shell-radio-art-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #282828 0%, #1a1a1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shell-radio-art-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.shell-radio-art-img.shell-radio-art-loading {
  opacity: 0;
}

.shell-radio-art-inner.has-art::before {
  display: none;
}

.shell-radio-art-inner::before {
  content: "";
  width: clamp(40px, 20%, 80px);
  height: clamp(40px, 20%, 80px);
  background: #535353;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.shell-radio-info {
  text-align: center;
  min-width: 0;
}

.shell-radio-station {
  display: none;
  font-size: clamp(18px, 5cqw, 30px);
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.shell-radio-nowplaying {
  margin: 0;
  transition: opacity 0.25s ease;
}

.shell-radio-nowplaying-title,
.shell-radio-nowplaying-artist {
  display: block;
  font-weight: 700;
  color: #ffffff;
  font-size: clamp(14px, 3.5cqw, 18px);
  line-height: 1.3;
  letter-spacing: -0.02em;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
}

.shell-radio-nowplaying-title {
  margin-bottom: 2px;
}

.shell-radio-nowplaying-artist {
  color: #b3b3b3;
  font-size: clamp(12px, 3cqw, 15px);
}

.shell-radio-nowplaying-album {
  display: block;
  color: #888;
  font-size: clamp(11px, 2.5cqw, 13px);
  margin-top: 2px;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
}

.shell-radio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
}

.shell-radio-btn-play {
  width: clamp(38px, 14cqi, 52px);
  height: clamp(38px, 14cqi, 52px);
  padding: 0;
  cursor: pointer;
  background: #ffffff;
  border: none;
  border-radius: 50%;
  color: #121212;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: 0;
  position: relative;
}

.shell-radio-btn-play::before {
  content: "";
  position: absolute;
  width: clamp(16px, 5cqi, 20px);
  height: clamp(18px, 5cqi, 22px);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.shell-radio-btn-play.is-playing::before {
  width: clamp(16px, 5cqi, 20px);
  height: clamp(16px, 5cqi, 20px);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 4h4v16H6V4zm8 0h4v16h-4V4z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 4h4v16H6V4zm8 0h4v16h-4V4z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.shell-radio-btn-play:hover {
  transform: scale(1.05);
  background: #f0f0f0;
}

.shell-radio-btn-play:active {
  transform: scale(0.98);
}

.shell-radio-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: min(280px, 100%);
  margin-top: 12px;
}

.shell-radio-progress-bar {
  width: 100%;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #535353;
  border-radius: 2px;
  overflow: hidden;
}

.shell-radio-progress-bar::-webkit-progress-bar {
  background: #535353;
  border-radius: 2px;
}

.shell-radio-progress-bar::-webkit-progress-value {
  background: #ffffff;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.shell-radio-progress-bar::-moz-progress-bar {
  background: #ffffff;
  border-radius: 2px;
}

.shell-radio-progress-times {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
  color: #888;
}

.shell-radio-time-elapsed,
.shell-radio-time-remaining {
  font-variant-numeric: tabular-nums;
}

.shell-radio-volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: min(200px, 100%);
}

.shell-radio-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #b3b3b3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.shell-radio-btn-icon:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.shell-radio-volume {
  flex: 1;
  min-width: 0;
  height: 12px;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border-radius: 2px;
}

/* Track: dark unfilled, white filled – good contrast */
.shell-radio-volume::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #ffffff 0%, #ffffff var(--vol, 100%), #404040 var(--vol, 100%));
}

.shell-radio-volume::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #ffffff 0%, #ffffff var(--vol, 100%), #404040 var(--vol, 100%));
}

/* Thumb: dark so it’s visible on white fill; centered vertically */
.shell-radio-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s ease;
}

.shell-radio-volume::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.shell-radio-volume::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Compact/horizontal layout: only when space is actually short and/or landscape. */

/* Compact horizontal when viewport is narrow AND short (not tall portrait e.g. phone) */
@media (max-width: 420px) and (max-height: 560px) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 8px 14px;
    max-width: 100%;
    min-height: 0;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    width: 112px;
    min-width: 112px;
    max-height: 112px;
    aspect-ratio: 1;
  }
  .shell-radio-controls {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: center;
    align-self: center;
  }
  .shell-radio-btn-play {
    width: 36px;
    height: 36px;
  }
  .shell-radio-btn-play::before {
    width: 14px;
    height: 16px;
  }
  .shell-radio-btn-play.is-playing::before {
    width: 14px;
    height: 14px;
  }
  .shell-radio-info {
    grid-column: 3;
    grid-row: 1;
    text-align: left;
    justify-self: start;
    align-self: end;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    justify-self: stretch;
    align-self: start;
    max-width: 100%;
  }
  .shell-radio-volume-row {
    display: none;
  }
}

/* Compact horizontal when main column is narrow AND short – container query */
@container mainwrap (max-width: 380px) and (max-height: 560px) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 8px 14px;
    max-width: 100%;
    min-height: 0;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    width: 112px;
    min-width: 112px;
    max-height: 112px;
    aspect-ratio: 1;
  }
  .shell-radio-controls {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: center;
    align-self: center;
  }
  .shell-radio-btn-play {
    width: 36px;
    height: 36px;
  }
  .shell-radio-btn-play::before {
    width: 14px;
    height: 16px;
  }
  .shell-radio-btn-play.is-playing::before {
    width: 14px;
    height: 14px;
  }
  .shell-radio-info {
    grid-column: 3;
    grid-row: 1;
    text-align: left;
    justify-self: start;
    align-self: end;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    justify-self: stretch;
    align-self: start;
    max-width: 100%;
  }
  .shell-radio-volume-row {
    display: none;
  }
}

/* Horizontal: two equal halves – only when viewport is short (landscape or low height). */
@media (max-height: 480px) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: 0.5fr 0.5fr 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 8px 12px;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    text-align: left;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 100%;
    width: auto;
    min-width: 64px;
    max-width: 100%;
    min-height: 64px;
    max-height: 140px;
    aspect-ratio: 1;
    justify-self: end;
    align-self: center;
  }
  .shell-radio-info {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: start;
    align-self: center;
    text-align: left;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  .shell-radio-controls {
    grid-column: 3;
    grid-row: 1;
    justify-self: center;
    max-width: min(240px, 82cqi);
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    justify-self: center;
    width: 100%;
    max-width: min(240px, 82cqi);
  }
  .shell-radio-volume-row {
    grid-column: 3;
    grid-row: 3;
    justify-self: center;
    max-width: min(240px, 82cqi);
  }
}

@media (min-aspect-ratio: 1) and (max-height: 500px) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: 0.5fr 0.5fr 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 8px 12px;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    text-align: left;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 100%;
    width: auto;
    min-width: 64px;
    max-width: 100%;
    min-height: 64px;
    max-height: 140px;
    aspect-ratio: 1;
    justify-self: end;
    align-self: center;
  }
  .shell-radio-info {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: start;
    align-self: center;
    text-align: left;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  .shell-radio-controls {
    grid-column: 3;
    grid-row: 1;
    justify-self: center;
    max-width: min(240px, 82cqi);
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    justify-self: center;
    width: 100%;
    max-width: min(240px, 82cqi);
  }
  .shell-radio-volume-row {
    grid-column: 3;
    grid-row: 3;
    justify-self: center;
    max-width: min(240px, 82cqi);
  }
}

/* Horizontal only when now-playing container is short AND wide (landscape), not tall portrait. */
@container radio (max-height: 420px) and (min-aspect-ratio: 1) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: 0.5fr 0.5fr 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 8px 12px;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    text-align: left;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 100%;
    width: auto;
    min-width: 64px;
    max-width: 100%;
    min-height: 64px;
    max-height: 140px;
    aspect-ratio: 1;
    justify-self: end;
    align-self: center;
  }
  .shell-radio-info {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: start;
    align-self: center;
    text-align: left;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  .shell-radio-controls {
    grid-column: 3;
    grid-row: 1;
    justify-self: center;
    max-width: min(240px, 82cqi);
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    justify-self: center;
    width: 100%;
    max-width: min(240px, 82cqi);
  }
  .shell-radio-volume-row {
    grid-column: 3;
    grid-row: 3;
    justify-self: center;
    max-width: min(240px, 82cqi);
  }
}

/* When now-playing area gets short (and landscape): gentle scale – leave art size alone */
@container radio (max-height: 320px) and (min-aspect-ratio: 1) {
  .shell-radio-player {
    padding: clamp(14px, 4cqh, 24px) clamp(12px, 4cqw, 24px);
    gap: clamp(8px, 2.5cqh, 12px);
    transition: padding 0.25s ease, gap 0.25s ease;
  }
  /* Titles/info: don’t scale down too much – higher minimums */
  .shell-radio-nowplaying-title,
  .shell-radio-nowplaying-artist {
    font-size: clamp(14px, 4cqh, 18px);
    transition: font-size 0.2s ease;
  }
  .shell-radio-nowplaying-artist {
    font-size: clamp(13px, 3.5cqh, 15px);
  }
  .shell-radio-nowplaying-album {
    font-size: clamp(12px, 3cqh, 13px);
  }
  /* Player: scale down a tad as container shrinks */
  .shell-radio-btn-play {
    width: clamp(32px, 10cqi, 48px);
    height: clamp(32px, 10cqi, 48px);
    transition: width 0.2s ease, height 0.2s ease;
  }
  .shell-radio-btn-play::before {
    width: clamp(14px, 4cqi, 20px);
    height: clamp(14px, 4cqi, 20px);
    transition: width 0.2s ease, height 0.2s ease;
  }
  .shell-radio-btn-play.is-playing::before {
    width: clamp(14px, 4cqi, 18px);
    height: clamp(14px, 4cqi, 18px);
  }
  .shell-radio-progress {
    margin-top: clamp(4px, 1.5cqh, 12px);
    gap: clamp(2px, 1cqh, 6px);
    transition: margin-top 0.2s ease, gap 0.2s ease;
  }
  .shell-radio-progress-bar {
    height: clamp(3px, 1cqh, 4px);
    transition: height 0.2s ease;
  }
  .shell-radio-time-elapsed,
  .shell-radio-time-remaining {
    font-size: clamp(11px, 3cqh, 13px);
    transition: font-size 0.2s ease;
  }
  .shell-radio-volume-row {
    gap: clamp(4px, 1.5cqi, 12px);
  }
  .shell-radio-volume {
    height: 12px;
  }
  .shell-radio-btn-icon {
    width: clamp(28px, 7cqi, 32px);
    height: clamp(28px, 7cqi, 32px);
    font-size: clamp(12px, 3cqh, 14px);
    transition: width 0.2s ease, height 0.2s ease;
  }
  /* Player section: scale down more when container is short */
  .shell-radio-controls {
    max-width: min(176px, 66cqi);
  }
  .shell-radio-progress {
    max-width: min(176px, 66cqi);
  }
  .shell-radio-volume-row {
    max-width: min(176px, 66cqi);
  }
}

/* Really small (and landscape): same two halves, tighter */
@container radio (max-height: 260px) and (min-aspect-ratio: 1) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: 0.5fr 0.5fr 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 4px 10px;
    padding: 8px 12px;
    min-height: 0;
    text-align: left;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    height: 100%;
    width: auto;
    min-width: 48px;
    max-width: 100%;
    min-height: 48px;
    max-height: 80px;
    aspect-ratio: 1;
    justify-self: end;
    align-self: center;
  }
  .shell-radio-info {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: start;
    align-self: center;
    text-align: left;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  /* Titles/info: stay readable – don’t shrink too much */
  .shell-radio-nowplaying-title,
  .shell-radio-nowplaying-artist {
    font-size: clamp(12px, 3.5cqh, 14px);
  }
  .shell-radio-nowplaying-artist {
    font-size: clamp(11px, 3cqh, 13px);
  }
  .shell-radio-nowplaying-album {
    font-size: clamp(10px, 2.5cqh, 12px);
  }
  /* Player: scale down more when really small */
  .shell-radio-controls {
    grid-column: 3;
    grid-row: 1;
    justify-self: center;
    max-width: min(152px, 58cqi);
  }
  .shell-radio-btn-play {
    width: clamp(28px, 9cqi, 40px);
    height: clamp(28px, 9cqi, 40px);
  }
  .shell-radio-btn-play::before {
    width: clamp(12px, 3.5cqi, 16px);
    height: clamp(12px, 3.5cqi, 16px);
  }
  .shell-radio-btn-play.is-playing::before {
    width: clamp(12px, 3.5cqi, 14px);
    height: clamp(12px, 3.5cqi, 14px);
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    margin-top: 0;
    justify-self: center;
    width: 100%;
    max-width: min(152px, 58cqi);
    gap: 2px;
  }
  .shell-radio-progress-bar {
    height: clamp(2px, 0.8cqh, 4px);
  }
  .shell-radio-time-elapsed,
  .shell-radio-time-remaining {
    font-size: clamp(9px, 2.5cqh, 12px);
  }
  .shell-radio-volume-row {
    grid-column: 3;
    grid-row: 3;
    justify-self: center;
    max-width: min(152px, 58cqi);
    gap: 4px;
  }
  .shell-radio-btn-icon {
    width: clamp(24px, 6cqi, 30px);
    height: clamp(24px, 6cqi, 30px);
    font-size: clamp(11px, 2.5cqh, 13px);
  }
}

/* Compact horizontal only when viewport is very small. */
@media (max-width: 380px) and (max-height: 320px) {
  .shell-radio-player {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 8px 14px;
    max-width: 100%;
  }
  .shell-radio-art {
    grid-column: 1;
    grid-row: 1 / -1;
    width: 112px;
    min-width: 112px;
    max-height: 112px;
    aspect-ratio: 1;
  }
  .shell-radio-controls {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: center;
    align-self: center;
  }
  .shell-radio-btn-play {
    width: 36px;
    height: 36px;
  }
  .shell-radio-btn-play::before {
    width: 14px;
    height: 16px;
  }
  .shell-radio-btn-play.is-playing::before {
    width: 14px;
    height: 14px;
  }
  .shell-radio-info {
    grid-column: 3;
    grid-row: 1;
    text-align: left;
    justify-self: start;
    align-self: end;
    min-width: 0;
    overflow: hidden;
  }
  .shell-radio-info .shell-radio-station {
    display: none;
  }
  .shell-radio-info .shell-radio-nowplaying {
    margin: 0;
  }
  .shell-radio-progress {
    grid-column: 3;
    grid-row: 2;
    justify-self: stretch;
    align-self: start;
    max-width: 100%;
    margin-top: 0;
  }
  .shell-radio-volume-row {
    display: none;
  }
  .shell-nowplaying-bg {
    transform: none;
  }
}

/* Panes container - below main when panes exist; empty = no height. When open, 50% of content. */
.shell-panes {
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
  max-height: 45vh;
  display: flex;
  flex-direction: column-reverse;
  gap: 0;
  border-top: 2px solid #1a1a1a;
  background: #080808;
  overflow: hidden;
}

.shell-panes.has-panes {
  min-height: 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25);
}

.shell-content.has-open-panes .shell-panes {
  flex: 1 1 calc((1 - var(--pane-ratio, 0.5)) * 100%);
  min-height: 0;
  max-height: none;
  transition: flex-basis 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.shell-content.has-open-panes .shell-panes.has-panes {
  min-height: 0;
}

.shell-content.has-open-panes .shell-panes.has-panes.is-opening {
  flex: 1 1 0;
  overflow: hidden;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .shell-content.has-open-panes .shell-panes {
    transition: none;
  }
}

.shell-panes-resizer {
  display: none;
  flex-shrink: 0;
  height: 6px;
  background: #000000;
  border: none;
  cursor: row-resize;
  user-select: none;
  transition: opacity 0.15s ease-out, height 0.15s ease-out;
}

.shell-panes-resizer:hover {
  background: #000000;
}

.shell-content.has-open-panes .shell-panes-resizer {
  display: block;
}

/* Hide resizer during open animation so divider doesn't appear before the panes container */
.shell-content.is-panes-opening .shell-panes-resizer {
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: none;
}

/* Resizer between two panes (when 2+ panes open) */
.shell-pane-resizer {
  flex: 0 0 6px;
  min-height: 6px;
  background: #000000;
  border: none;
  cursor: row-resize;
  user-select: none;
}

.shell-pane-resizer:hover {
  background: #000000;
}

.shell-panes.is-opening .shell-pane-resizer {
  visibility: hidden;
  pointer-events: none;
}

.shell-pane {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #141414;
  background: #080808;
  color: #e0e0e0;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .shell-pane {
    transition: transform 0.05s ease-out, opacity 0.05s ease-out;
  }
  .shell-pane.is-closing {
    transition-timing-function: ease-in;
  }
}

.shell-pane.is-open {
  transform: translateY(0);
  opacity: 1;
}

.shell-pane.is-closing {
  transform: translateY(100%);
  opacity: 0;
  transition-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
}

.shell-pane-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  background: #0c0c0c;
  border-bottom: 1px solid #141414;
}

.shell-demo-btn {
  margin-top: 12px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  background: #0c0c0c;
  border: 1px solid #333;
  color: #e0e0e0;
  border-radius: 2px;
}

.shell-demo-btn:hover {
  background: #1a1a1a;
  color: #fff;
}

.shell-pane-title {
  display: block;
}

.shell-pane-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding: 12px;
  overflow: auto;
  font-size: 14px;
  background: #080808;
  display: flex;
  flex-direction: column;
}

/* Videos pane - embedded video, native controls */
.shell-videos-loading,
.shell-videos-empty {
  margin: 0;
  color: #888;
  font-size: 14px;
}

.shell-videos-player-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-height: 0;
  min-width: 0;
  flex: 1 1 0;
}

.shell-videos-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}

.shell-videos-prev,
.shell-videos-next {
  min-width: 44px;
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: #e0e0e0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.shell-videos-prev:hover,
.shell-videos-next:hover {
  background: #252525;
  color: #fff;
}

.shell-videos-label {
  font-size: 13px;
  color: #999;
  min-width: 4ch;
  text-align: center;
}

/* Video fills remaining pane space and scales to fit (never grows the container) */
.shell-videos-video-wrap {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  background: #000;
  overflow: hidden;
  contain: layout;
}

.shell-videos-embed {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

.shell-coming-soon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #888;
  font-size: 15px;
}

.shell-stations-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shell-station-item {
  margin: 0 0 4px;
}

.shell-station-btn {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  color: #e0e0e0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.shell-station-btn:hover {
  background: #252525;
  border-color: #444;
  color: #ffffff;
}

.shell-station-item--current .shell-station-btn {
  border-color: #666;
  background: #252525;
  color: #ffffff;
}

/* Requests rail: header + scrollable content */
.shell-requests-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.shell-requests-header {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.shell-requests-reload-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: #333;
  border: 1px solid #555;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.shell-requests-reload-btn:hover {
  background: #444;
  border-color: #666;
  color: #ffffff;
}

.shell-requests-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Shared rail list: History and Requests use same track row layout */
.shell-history-list,
.shell-requests-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shell-rail-track-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px 12px;
  padding: 8px 0;
  border-bottom: 1px solid #2a2a2a;
  font-size: 13px;
}

.shell-rail-track-art {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  background: #282828;
  flex-shrink: 0;
}

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

.shell-rail-track-art--no-art {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #535353;
  font-size: 18px;
}

.shell-rail-track-art--no-art::before {
  content: "♪";
}

.shell-rail-track-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shell-rail-track-title {
  color: #e0e0e0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-rail-track-artist {
  color: #e0e0e0;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-rail-track-time {
  color: #888;
  font-size: 12px;
}

.shell-requests-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
  color: #e0e0e0;
  background: #333;
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.shell-requests-btn:hover:not(:disabled) {
  background: #444;
  border-color: #555;
}

.shell-requests-btn:disabled {
  cursor: default;
  opacity: 0.8;
}

.shell-requests-btn--requesting {
  background: #2e3a3a;
  border-color: #4d6363;
  color: #cfe6e6;
}

.shell-requests-btn--requested {
  background: #242424;
  border-color: #3b3b3b;
  color: #a8a8a8;
  cursor: default;
}

.shell-requests-btn--error {
  background: #4a2b2b;
  border-color: #704040;
  color: #ffd2d2;
}

.shell-history-empty,
.shell-history-error,
.shell-history-more,
.shell-requests-empty,
.shell-requests-error,
.shell-requests-hint,
.shell-requests-more {
  margin: 0;
  color: #999;
  font-size: 14px;
}

.shell-requests-hint {
  margin-top: 8px;
  font-size: 12px;
}

.shell-history-more,
.shell-requests-more {
  margin-top: 8px;
}

/* Chat pane */
.shell-chat-wrap {
  height: 100%;
  min-height: 0;
}

.shell-chat-root {
  height: 100%;
  min-height: 0;
}

.shell-chat-loading {
  margin: 0;
  color: #9a9a9a;
}

.shell-chat {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
  font-family: "Courier New", monospace;
}

.shell-chat-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.shell-chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  background: #000;
  border: 1px solid #2d2d2d;
}

.shell-chat-line {
  margin-bottom: 4px;
  font-size: 12px;
  word-break: break-word;
}

.shell-chat-time {
  color: #8a8a8a;
}

.shell-chat-system {
  color: #83a598;
}

.shell-chat-text {
  color: #e6e6e6;
}

.shell-chat-input-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #151515;
  border: 1px solid #2d2d2d;
  padding: 6px;
}

.shell-chat-prompt {
  color: #b8bb26;
  font-weight: 700;
}

.shell-chat-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #f2f2f2;
  font-family: inherit;
}

.shell-chat-send {
  border: 1px solid #3a3a3a;
  background: #242424;
  color: #f2f2f2;
  padding: 6px 10px;
  cursor: pointer;
}

.shell-chat-users {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #2d2d2d;
  background: #111;
}

.shell-chat-users-header {
  padding: 6px 8px;
  border-bottom: 1px solid #2d2d2d;
  color: #d0d0d0;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.shell-chat-users-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
}

.shell-chat-user-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 11px;
}

.shell-chat-user-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8ec07c;
  flex-shrink: 0;
}

.shell-chat-users-count {
  border-top: 1px solid #2d2d2d;
  padding: 6px 8px;
  color: #8a8a8a;
  font-size: 10px;
}

@media (max-width: 760px) {
  .shell-chat {
    grid-template-columns: 1fr;
  }
  .shell-chat-users {
    max-height: 130px;
  }
}

/* Mobile: sidebar becomes a thin strip */
@media (max-width: 640px) {
  .shell-sidebar {
    width: 90px;
  }

  .sidebar-item {
    padding: 10px 8px;
    font-size: 12px;
  }

  .sidebar-item--active {
    padding-left: 5px;
  }

  .shell-main-inner {
    padding: 16px;
  }

  .shell-panes {
    max-height: 40vh;
  }
}

