/* Keep the listening controls and navigation inside the usable screen area. */
:root {
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
body { padding: env(safe-area-inset-top, 0px) var(--safe-right) 0 var(--safe-left); }
.player, .mobile-nav { left: var(--safe-left); right: var(--safe-right); }
.mobile-nav button { min-width: 0; flex: 1; overflow-wrap: anywhere; }
dialog { max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - var(--safe-bottom)); }
.app-shell[data-mode=desktop] main { container-type: inline-size; }
#shell[data-mode=desktop] .station-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(130px, 24cqi, 185px)), 1fr));
}
.content-tabs { overflow-x: auto; }
.content-tabs button { flex-shrink: 0; }
.player-controls { flex-shrink: 0; }
.setting-row { flex-wrap: wrap; }
.section-heading { gap: 10px; }
.section-heading > div { min-width: 0; }
.section-heading h2 { overflow-wrap: anywhere; }
@media (pointer: coarse) {
  .play-toggle, .heart-button { min-width: 44px; min-height: 44px; }
  .side-nav button, .content-tabs button, .filter-selects select { min-height: 44px; }
  .search-row input, dialog input:not([type=range]) { font-size: 16px; }
}
@media (max-width: 360px) {
  .preview-bar > span { display: none; }
  .preview-bar { justify-content: flex-end; }
  .content-tabs { gap: 12px; }
  .chips { margin-inline-end: 0; }
  .wordmark-mobile { min-width: 0; }
  .wordmark-mobile img { width: 62px; }
  .filter-selects { flex-wrap: wrap; }
  dialog { padding-inline: 17px; }
}
/* A short, wide phone needs room to browse while the player is visible. */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 540px) {
  #shell[data-mode=desktop] { padding-inline-start: 112px; padding-bottom: calc(65px + var(--safe-bottom)); }
  #shell[data-mode=desktop] .sidebar { display: flex; width: 112px; padding: 10px 5px; bottom: 65px; }
  #shell[data-mode=desktop] .brand { margin: 0 auto 8px; }
  #shell[data-mode=desktop] .brand-logo { width: 58px; }
  #shell[data-mode=desktop] :is(.brand-tagline,.brand-name,.sidebar-bottom,.topline,.intro,.mobile-nav) { display: none; }
  #shell[data-mode=desktop] .side-nav { gap: 2px; }
  #shell[data-mode=desktop] .side-nav button { padding: 7px 3px; gap: 4px; }
  #shell[data-mode=desktop] .player { bottom: 0; height: calc(60px + var(--safe-bottom)); padding-block: 6px calc(6px + var(--safe-bottom)); }
}
/* Two physical segments are used only when the browser reports a hinge. */
@media (horizontal-viewport-segments: 2) {
  #shell[data-mode=desktop] { padding-inline: 0; max-width: none; }
  #shell[data-mode=desktop] .sidebar {
    display: flex; position: absolute; inset-inline: auto; left: 0; top: 0;
    width: calc(env(viewport-segment-width 0 0) - var(--safe-left)); padding: 20px;
  }
  #shell[data-mode=desktop] main {
    margin: 0; margin-left: calc(env(viewport-segment-left 1 0) - var(--safe-left));
    padding: 16px; width: calc(env(viewport-segment-width 1 0) - var(--safe-right));
  }
  #shell[data-mode=desktop] .player {
    left: var(--safe-left); right: auto; bottom: 0; margin: 0; display: grid;
    height: auto; padding: 16px 16px calc(16px + var(--safe-bottom)); gap: 10px;
    width: calc(env(viewport-segment-width 0 0) - var(--safe-left));
  }
  #shell[data-mode=desktop] .player-extras, #shell[data-mode=desktop] .mobile-nav,
  #shell[data-mode=desktop] .topline { display: none; }
  #shell[data-mode=desktop] .filter-selects { flex-wrap: wrap; }
  :root[data-view=desktop] dialog {
    left: env(viewport-segment-left 1 0); right: 0; width: calc(env(viewport-segment-width 1 0) - 24px);
  }
  .preview-bar { margin-left: env(viewport-segment-left 1 0); padding-inline: 6px; justify-content: center; }
  .preview-bar > span, .views button > span:last-child:not([data-icon]) { display: none; }
}
@media (vertical-viewport-segments: 2) {
  :root[data-view=desktop] { --fold-top: env(viewport-segment-height 0 0); }
  :root[data-view=desktop] .preview-bar { display: none; }
  #shell[data-mode=desktop] { height: 100dvh; min-height: 0; padding: 0; }
  #shell[data-mode=desktop] .sidebar { display: none; }
  #shell[data-mode=desktop] main { overflow-y: auto; height: var(--fold-top); padding: 16px; }
  #shell[data-mode=desktop] .player { top: env(viewport-segment-top 0 1); bottom: auto; height: auto; min-height: 65px; }
  #shell[data-mode=desktop] .mobile-nav { display: flex; position: fixed; bottom: 0; height: calc(56px + var(--safe-bottom)); }
  :root[data-view=desktop] dialog { bottom: calc(100dvh - var(--fold-top)); max-height: calc(var(--fold-top) - 16px); }
}
:root[data-surface] .preview-bar { display: none; }
:root[data-installed] .preview-bar { display: none; }
.favorite-step { min-width: 48px; min-height: 48px; font-size: 20px; border: 1px solid var(--line); border-radius: 10px; color: var(--accent); }
.now-art[tabindex]:focus { outline: 4px solid var(--accent); outline-offset: 4px; }
:root[data-surface] #shell { min-height: 100dvh; }
:root[data-view=tv] { scroll-padding-bottom: 132px; }
/* On the dashboard, lead with browse, favorites, recent and playback. */
#shell[data-mode=car] { margin-block-start: 0; border-radius: 0; min-height: 100dvh; padding-bottom: 95px; }
#shell[data-mode=car] main { display: flex; flex-direction: column; padding: 14px clamp(14px, 4vw, 42px); }
#shell[data-mode=car] :is(.topline,.search-row,.say-feature-slot,.discovery,.legal-links,.tv-help) { display: none; }
#shell[data-mode=car] .mobile-nav { order: -2; position: static; width: 100%; height: auto; margin: 0; padding: 0; gap: 8px; max-width: none; }
#shell[data-mode=car] .mobile-nav button { min-height: 48px; padding: 8px; min-width: 0; flex-direction: row; }
#shell[data-mode=car] .mobile-nav [data-action=profile] { display: none; }
#shell[data-mode=car] .content-tabs { margin-top: 8px; gap: 16px; }
#shell[data-mode=car] .station-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 10px; }
#shell[data-mode=car] .station-art { aspect-ratio: 2.6; }
#shell[data-mode=car] .player { position: fixed; bottom: 0; height: calc(76px + var(--safe-bottom)); padding: 8px 20px calc(8px + var(--safe-bottom)); }
#shell[data-mode=car] .player-extras { display: none; }

.now-playing #dialogBody .now-artist { font-size:clamp(1.15rem, 3vw, 1.65rem); color:var(--accent); margin:.2em 0 .85em; line-height:1.25; overflow-wrap:anywhere; }
.now-playing #dialogBody .now-station { color:var(--text); font-weight:650; margin-bottom:0; }
.now-playing #dialogBody h2:has(+ .now-artist:not([hidden])) { margin-bottom:.12em; font-weight:650; line-height:1.1; }
.now-playing .dialog-close { z-index:1; }
.now-playing .now-art:not(:has(img)) { color:#6b382e; background:radial-gradient(ellipse at 75% 15%,#f8e9df,transparent 70%),linear-gradient(135deg,#d9afa2,#eed4c8); }
.now-copy h2 { overflow-wrap:anywhere; }

.track-credit { color:var(--accent); font-size:.75rem; line-height:1.2; text-underline-offset:.18em; }
#playerTrackCredit { max-inline-size:8em; padding-block:.45em; }
@media(max-width:600px) { #playerTrackCredit { max-inline-size:5em; } }
