/* App shell owns page geometry. Track rows and controls never set global overflow. */
.music-shell {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: 88px minmax(0, 1fr) 112px;
  grid-template-areas: 'header header' 'sidebar content' 'player player';
}
.music-header {
  grid-area: header;
  display: grid;
  grid-template-columns: 208px minmax(180px, 1fr) auto;
  gap: 2rem;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--line);
}
.search-form {
  display: flex;
  max-width: 500px;
  align-items: center;
  gap: 0.35rem;
}
.account-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}
.demo-session {
  color: var(--accent);
  font-size: 0.75rem;
  white-space: nowrap;
}
.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--surface-low);
  min-height: 0;
}
.primary-nav {
  display: grid;
  gap: 0.25rem;
}
.primary-nav a {
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  text-decoration: none;
  border-radius: var(--radius);
}
.primary-nav a[aria-current] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar-heading h2 {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.playlist-nav {
  overflow: auto;
  min-height: 0;
}
.playlist-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.2rem;
  text-decoration: none;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
.credits-link {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: auto;
}
.music-content {
  grid-area: content;
  padding: clamp(1.5rem, 3vw, 3rem);
  overflow: auto;
  min-width: 0;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.section-heading p {
  max-width: 62ch;
  margin-bottom: 0;
}
.section-heading .actions {
  flex: 0 1 auto;
  max-width: 100%;
}
.playlist-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 2.5rem;
}
.playlist-tile {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--surface-raised);
  border-radius: 0.65rem;
  padding: 1.3rem;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.playlist-tile:hover {
  background: var(--line);
}
.playlist-kind {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.07em;
  font-weight: 400;
}

.empty-state {
  max-width: 500px;
  padding: 3rem 0;
}
.empty-state p {
  color: var(--muted);
}
.player {
  position: relative;
  grid-area: player;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.3fr) minmax(140px, 0.65fr);
  gap: 2rem;
  padding: 1rem 2rem;
  align-items: center;
  border-top: 1px solid var(--line);
  background: var(--surface-low);
}
.now-playing {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}
.now-art {
  display: flex;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-ink);
  font: 300 2rem var(--font-display);
}
.now-art[data-style='Chill'] {
  background: #bacbb1;
}
.now-art[data-style='Electronic'] {
  background: #c8b9d5;
}
.now-info {
  display: grid;
  min-width: 0;
}
.now-info strong {
  font-size: 0.875rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.now-info > span {
  color: var(--muted);
  font-size: 0.75rem;
}
.transport {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}
.player-options {
  display: contents;
}
.player-options-toggle {
  display: none;
}
#prevButton {
  order: 1;
}
#playButton {
  order: 2;
}
#nextButton {
  order: 3;
}
#repeatButton {
  order: 4;
}
.play-toggle {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 50%;
}
.play-toggle:hover {
  color: var(--accent-ink);
  background: #fff19a;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.progress-row time {
  color: var(--muted);
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
  min-width: 2.2rem;
}
.volume-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
  max-width: 160px;
}
#repeatButton {
  position: relative;
  border-radius: 50%;
}
#repeatButton[data-mode='one']::after {
  content: '1';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  line-height: 1;
  pointer-events: none;
}
.app-status {
  position: fixed;
  bottom: 128px;
  right: 1.5rem;
  z-index: 5;
  max-width: min(400px, calc(100vw - 3rem));
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 5px 15px #0004;
  font-size: 0.875rem;
}
dialog {
  width: min(440px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--ink);
  padding: 1.5rem;
}
dialog::backdrop {
  background: #0009;
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dialog-heading h2 {
  margin: 0;
}
#playlistForm {
  display: grid;
  gap: 1rem;
}
.playlist-choices {
  display: grid;
  gap: 0.5rem;
}
.playlist-choice {
  background: var(--surface-raised);
  border: 0;
  text-align: left;
  padding: 0.8rem;
  min-height: 48px;
}
@media (max-width: 1000px) {
  .music-header {
    gap: 1rem;
    grid-template-columns: 180px minmax(100px, 1fr) auto;
    padding: 1rem 1.5rem;
  }
  #welcome {
    display: none;
  }
  .demo-session {
    display: none;
  }
  .player {
    gap: 1rem;
    padding: 1rem;
  }
  .volume-control {
    max-width: 110px;
  }
}
@media (max-width: 700px) {
  .music-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 60px 44px minmax(0, 1fr) auto;
    grid-template-areas: 'header' 'sidebar' 'content' 'player';
  }
  .music-header {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
  }
  .music-header .brand-mark {
    width: 32px;
    height: 32px;
  }
  .music-header .brand-name {
    display: none;
  }
  .music-header .brand {
    min-height: 44px;
  }
  .account-menu .text-button {
    padding: 0.5rem;
    font-size: 0.7rem;
  }
  .search-form {
    gap: 0;
    max-width: none;
  }
  .search-form input:not([type='range']) {
    min-height: 40px;
    font-size: 1rem;
    padding: 0.45rem 0.6rem;
  }
  .sidebar {
    display: block;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .primary-nav {
    display: flex;
    justify-content: space-between;
  }
  .primary-nav a {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    border-radius: 0;
    border-bottom: 2px solid transparent;
  }
  .primary-nav a[aria-current] {
    background: transparent;
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
  .sidebar-heading,
  .playlist-nav,
  .credits-link {
    display: none;
  }
  .music-content {
    padding: 1.25rem 1rem;
  }
  .section-heading {
    margin-bottom: 1.75rem;
  }
  .section-heading h1 {
    font-size: 1.7rem;
  }
  .playlist-list {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .playlist-tile {
    flex-direction: row;
    align-items: center;
    padding: 1rem;
  }
  .playlist-kind {
    display: none;
  }

  .player {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 44px 28px;
    gap: 0 0.5rem;
    padding: 0.5rem 1rem max(0.25rem, env(safe-area-inset-bottom));
  }
  .now-art {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }
  .now-playing {
    gap: 0.7rem;
  }
  .now-info strong {
    font-size: 0.75rem;
  }
  .now-info > span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.65rem;
  }
  .now-info #playerState {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .playback {
    display: contents;
  }
  .volume-control {
    display: none;
  }
  .transport {
    gap: 0;
    align-items: center;
  }
  .player-options-toggle {
    display: inline-flex;
    order: 5;
  }
  .player-options-toggle[aria-expanded='true'] .icon {
    transform: rotate(180deg);
  }
  .player-options {
    display: none;
  }
  .transport:has(.player-options-toggle[aria-expanded='true']) .player-options {
    display: flex;
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 1rem;
    padding: 0.5rem;
    gap: 0.5rem;
    background: var(--surface-raised);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px #0006;
    z-index: 6;
  }
  .progress-row {
    gap: 0.4rem;
    grid-column: 1 / -1;
  }
  .app-status {
    bottom: calc(104px + env(safe-area-inset-bottom));
  }
}
@media (max-height: 650px) and (min-width: 701px) {
  .music-shell {
    grid-template-rows: 76px minmax(0, 1fr) 104px;
  }
}
