/* ============================================================
   Mitch Radio — MOBILE FIRST
   Base styles = phone layout. Desktop is the override.
   ============================================================ */

:root {
  --bg: #0b0e14;
  --panel: #10141d;
  --border: #1f2733;
  --accent: #ff9d3d;
  --accent-dim: #ad6a26;
  --text: #d7dbe2;
  --text-dim: #6b7482;
  --active: #1a2130;
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, 'Courier New', Consolas, monospace;

  /* Fill exactly one viewport, no more. dvh accounts for the
     phone browser's collapsing address bar; vh is the fallback. */
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;

  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
#topbar {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--accent);
  white-space: nowrap;
}

.status {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Playlist tabs (horizontal strip) ---------- */
#playlist-list {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 6px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#playlist-list::-webkit-scrollbar { display: none; }

.playlist-item {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.playlist-item:hover { background: var(--active); }

.playlist-item.active {
  border-bottom-color: var(--accent);
  background: var(--active);
  color: var(--accent);
}

.playlist-item .count {
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- Track panel ---------- */
#track-panel {
  flex: 1 1 auto;
  min-height: 0;          /* critical: lets the list scroll instead of growing */
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-header {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  min-width: 0;
}

#current-playlist-name {
  letter-spacing: 1px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#shuffle-btn {
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
}

#shuffle-btn:hover { background: var(--active); }

#track-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.track-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  min-width: 0;
}

.track-item:hover { background: var(--active); }

.track-item.playing {
  border-left-color: var(--accent);
  color: var(--accent);
  background: var(--active);
}

.track-index {
  flex: 0 0 auto;
  width: 26px;
  text-align: right;
  color: var(--text-dim);
  font-size: 12px;
  padding-top: 1px;
}

.track-item > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- Player bar ---------- */
#player-bar {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.now-playing {
  min-width: 0;
  width: 100%;
  text-align: center;
}

#now-title {
  font-size: 14px;
  line-height: 1.3;
  color: var(--accent);
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.now-playlist {
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.controls button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  padding: 8px 12px;
  min-width: 44px;
  min-height: 40px;
  cursor: pointer;
}

.controls button:hover { background: var(--active); }

.controls button.on {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.progress-wrap,
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  font-size: 11px;
  color: var(--text-dim);
}

#seek, #volume {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--accent);
}

input[type="range"] { height: 24px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }

/* ============================================================
   DESKTOP OVERRIDE — sidebar layout on wide screens only
   ============================================================ */
@media (min-width: 900px) {
  body {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "top   top"
      "plist panel"
      "bar   bar";
  }

  #topbar      { grid-area: top; padding: 14px 20px; }
  h1           { font-size: 18px; }
  #playlist-list { grid-area: plist; }
  #track-panel { grid-area: panel; }
  #player-bar  { grid-area: bar; }

  #playlist-list {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 12px 0;
    overflow-x: hidden;
    overflow-y: auto;
    border-bottom: none;
    border-right: 1px solid var(--border);
    min-height: 0;
  }

  .playlist-item {
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: none;
    border-left: 3px solid transparent;
  }

  .playlist-item.active {
    border-bottom-color: transparent;
    border-left-color: var(--accent);
  }

  #track-panel { min-height: 0; }
  .panel-header { padding: 14px 20px; }
  .track-item { padding: 10px 20px; }

  #player-bar {
    flex-direction: row;
    align-items: center;
    gap: 24px;
    padding: 12px 20px;
  }

  .now-playing {
    width: auto;
    flex: 0 0 240px;
    text-align: left;
  }

  .progress-wrap { flex: 1 1 auto; width: auto; }
  .volume-wrap   { flex: 0 0 130px; width: auto; }
}
