/* Use available touch space, never a device name or physical pixel count. */
@media (min-width: 600px) and (max-width: 1180px) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .brand {
    grid-template-rows: minmax(0, 1fr);
  }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .brandLogo {
    min-height: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .stage {
    padding: calc(112px + env(safe-area-inset-top))
      max(28px, env(safe-area-inset-right))
      calc(120px + env(safe-area-inset-bottom))
      max(28px, env(safe-area-inset-left));
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .player {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 32px;
    width: min(920px, 100%);
    min-width: 0;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .coverWrap {
    justify-self: center;
    width: min(100%, 360px, calc(var(--app-viewport-height, 100dvh) - 250px));
    min-width: 0;
    border-radius: 20px;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .meta {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .nowPlaying {
    margin-bottom: 12px;
    font-size: 12px;
    letter-spacing: 0;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .meta h1 {
    display: -webkit-box;
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    font-size: 30px;
    line-height: 1.12;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    text-wrap: balance;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .meta > #artist {
    max-width: 100%;
    margin: 14px 0 0;
    overflow: hidden;
    font-size: 18px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app.is-mobile:not(.is-echo-show) .mobileReactionMount {
    justify-content: flex-start;
    margin-top: 20px;
  }

  .app.is-mobile:not(.is-echo-show) .sheet:not(.is-mobile-editor) .sheetPanel {
    top: auto;
    right: auto;
    bottom: calc(106px + env(safe-area-inset-bottom));
    left: 50%;
    width: min(620px, calc(100% - 32px));
    max-height: calc(var(--app-viewport-height, 100dvh) - 124px - env(safe-area-inset-bottom));
    transform: translateX(-50%);
  }

  .app.is-mobile:not(.is-echo-show) .sheetClose { width: 44px; height: 44px; }

  html.is-keyboard-open .app.is-mobile:not(.is-echo-show) .sheet .sheetPanel {
    bottom: 8px;
    max-height: calc(var(--app-viewport-height, 100dvh) - 16px);
  }

  /* Text editors stay outside the composited player, including unfolded screens. */
  html.is-mobile .sheet.is-mobile-editor {
    align-items: center;
    justify-content: center;
  }

  html.is-mobile .sheet.is-mobile-editor .sheetPanel {
    flex: 0 1 auto;
    max-width: 620px;
    max-height: 680px !important;
  }
}

/* Extend touch controls beyond the old 820px desktop breakpoint. */
@media (min-width: 821px) and (max-width: 1180px) {
  .app.is-mobile:not(.is-echo-show) .topbar {
    top: max(12px, env(safe-area-inset-top));
    left: max(20px, env(safe-area-inset-left));
    right: max(20px, env(safe-area-inset-right));
  }

  .app.is-mobile:not(.is-echo-show) .brand { width: 148px; height: 88px; }
  .app.is-mobile:not(.is-echo-show) .topbar .iconButton { width: 44px; height: 44px; }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .coverWrap .playButton { display: none; }
  .app.is-mobile:not(.is-echo-show) .dockInner > .dockItem,
  .app.is-mobile:not(.is-echo-show) .dockInner > .siteTab,
  .app.is-mobile:not(.is-echo-show) .dockInner > .streamsTab,
  .app.is-mobile:not(.is-echo-show) .dockInner > .is-mobile-overflow { display: none; }

  .app.is-mobile:not(.is-echo-show) .dock {
    position: fixed;
    inset: auto 0 max(12px, env(safe-area-inset-bottom));
    width: min(440px, calc(100% - 32px));
    height: 76px;
    margin-inline: auto;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 7%, #101114);
    box-shadow: 0 12px 32px #0006, inset 0 1px 0 #ffffff0d;
    transform: none;
  }

  .app.is-mobile:not(.is-echo-show) .dockInner {
    display: grid;
    grid-template-columns: repeat(var(--mobile-dock-items, 5), minmax(0, 1fr));
    gap: 0;
    width: 100%;
    height: 62px;
    margin: 0;
  }

  .app.is-mobile:not(.is-echo-show) .dockTab {
    display: flex;
    grid-row: 1;
    grid-column: var(--mobile-menu-column, auto);
    order: var(--mobile-menu-order, 3);
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
    height: 62px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
    transform: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .app.is-mobile:not(.is-echo-show) .dockTab::before { content: none; }
  .app.is-mobile:not(.is-echo-show) .dockGlyph { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 999px; }
  .app.is-mobile:not(.is-echo-show) .dockGlyph svg { width: 23px; height: 23px; }
  .app.is-mobile:not(.is-echo-show) .dockTab.is-active .dockGlyph { background: #ffffff1a; color: var(--accent); }
  .app.is-mobile:not(.is-echo-show) .dockLabel {
    position: static;
    width: auto;
    height: 14px;
    margin: 0;
    overflow: visible;
    clip: auto;
    clip-path: none;
    font-size: 10px;
    line-height: 14px;
    letter-spacing: 0;
  }
  .app.is-mobile:not(.is-echo-show) .mobileLiveTab { display: flex !important; }
  .app.is-mobile:not(.is-echo-show) .mobileLiveGlyph {
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    max-width: 50px;
    border-radius: 50%;
    background: var(--accent);
    transform: none;
  }
  .app.is-mobile:not(.is-echo-show) .mobileLiveIcon {
    display: block;
    width: 0;
    height: 0;
    margin-left: 3px;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 14px solid var(--accent-contrast);
  }
  .app.is-mobile:not(.is-echo-show) .mobileLiveTab.is-playing .mobileLiveIcon {
    display: flex;
    justify-content: space-between;
    width: 12px;
    height: 18px;
    margin-left: 0;
    border: 0;
  }
  .app.is-mobile:not(.is-echo-show) .mobileLiveTab.is-playing .mobileLiveIcon::before,
  .app.is-mobile:not(.is-echo-show) .mobileLiveTab.is-playing .mobileLiveIcon::after {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 2px;
    background: var(--accent-contrast);
  }
  .app.is-mobile:not(.is-echo-show) .programNotification {
    top: 112px;
    right: auto;
    left: 50%;
    width: min(360px, calc(100% - 24px));
    transform: translate(-50%, -14px);
  }
  .app.is-mobile:not(.is-echo-show) .programNotification.is-visible { transform: translate(-50%, 0); }
  .app.is-mobile:not(.is-echo-show) .mobileOnlyMenuAction:not([hidden]) { display: flex; }
  .app.is-mobile:not(.is-echo-show) .mobileReactionMount { display: flex; }
  .app.is-mobile:not(.is-echo-show) .mobileReactionMount > .reactionItem { display: flex; height: 44px; }
  .app.is-mobile:not(.is-echo-show) .reactionToggle { display: none; }
  .app.is-mobile:not(.is-echo-show) .mobileReactionMount .reactionTray {
    position: static;
    display: flex;
    gap: 4px;
    padding: 2px;
    width: auto;
    border-radius: 999px;
    transform: none;
  }
  .app.is-mobile:not(.is-echo-show) .reactionTray button { width: 44px; height: 44px; }
  .app.is-mobile.is-webtv .mobileReactionMount { display: none; }
  html.is-keyboard-open .app.is-mobile .dock { visibility: hidden; pointer-events: none; }
}

@media (min-width: 600px) and (max-width: 1180px) and (max-height: 480px) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .stage { padding-top: 72px; padding-bottom: 100px; }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .coverWrap { width: min(100%, 200px, calc(100dvh - 190px)); }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .meta h1 { font-size: 24px; -webkit-line-clamp: 2; }
  .app.is-mobile:not(.is-echo-show) .brand { height: 56px; }
  .app.is-mobile:not(.is-echo-show) .mobileReactionMount { margin-top: 10px; }
}

/* A compact, wide touch viewport leaves room for a right-hand navigation rail.
   This is a layout rule, not an assumption about a device's name or DPR. */
@media (min-width: 600px) and (max-width: 1180px),
       (min-width: 440px) and (max-width: 599px) and (min-aspect-ratio: 2/3) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .stage {
    padding-right: calc(88px + env(safe-area-inset-right));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dock {
    top: auto;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    left: auto;
    width: 54px;
    height: auto;
    max-height: calc(var(--app-viewport-height, 100dvh) - 140px);
    margin: 0;
    padding: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 8%, #202126e8);
    box-shadow: 0 8px 28px #0004, inset 0 1px 0 #ffffff18;
    transform: none;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dock::before,
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dock::after { content: none; }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockInner {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(var(--mobile-dock-items, 5), 44px);
    width: 100%;
    height: auto;
    gap: 0;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab {
    grid-column: 1;
    grid-row: var(--mobile-menu-column, auto);
    width: 44px;
    min-width: 0;
    height: 44px;
    gap: 0;
    padding: 0;
    border-radius: 50%;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab::before { content: none; }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab .dockGlyph {
    flex: 0 0 36px;
    width: 36px;
    max-width: 36px;
    height: 36px;
    border-radius: 50%;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab.is-active .dockGlyph {
    background: #ffffff21;
    color: var(--accent);
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab[data-menu-key] .dockGlyph::after {
    inset: 8px;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab .mobileLiveGlyph {
    flex-basis: 38px;
    width: 38px;
    max-width: 38px;
    height: 38px;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockGlyph svg,
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockIcon { width: 20px; height: 20px; }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .currentTrackVoteHeart { font-size: 24px; }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .mobileLiveTab:not(.is-playing) .mobileLiveIcon {
    border-top-width: 7px;
    border-bottom-width: 7px;
    border-left-width: 11px;
  }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .mobileLiveTab.is-playing .mobileLiveIcon,
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .mobileLiveTab.is-playing .mobileLiveIcon::before,
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .mobileLiveTab.is-playing .mobileLiveIcon::after { height: 14px; }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab .dockLabel {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -3px;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .sheet:not(.is-mobile-editor) .sheetPanel {
    top: max(100px, env(safe-area-inset-top));
    right: calc(88px + env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    left: max(20px, env(safe-area-inset-left));
    width: auto;
    max-width: 620px;
    max-height: calc(var(--app-viewport-height, 100dvh) - 124px);
    margin-inline: auto;
    transform: none;
  }

  html.is-keyboard-open .app.is-mobile:not(.is-echo-show) .dock {
    visibility: hidden;
    pointer-events: none;
  }
}

@media (min-width: 600px) and (max-width: 700px),
       (min-width: 440px) and (max-width: 599px) and (min-aspect-ratio: 2/3) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .stage {
    padding-top: calc(116px + env(safe-area-inset-top));
    padding-left: max(20px, env(safe-area-inset-left));
  }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .player {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 22px;
  }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .coverWrap {
    width: min(100%, 300px, max(92px, calc(var(--app-viewport-height, 100dvh) - 380px)));
    min-width: 0;
  }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .meta { text-align: center; }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .meta h1 { font-size: 26px; }
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .mobileReactionMount {
    justify-content: center;
    margin-top: 14px;
  }
}

@media (hover: hover) and (min-width: 600px) and (max-width: 1180px),
       (hover: hover) and (min-width: 440px) and (max-width: 599px) and (min-aspect-ratio: 2/3) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dockTab:hover .dockLabel {
    right: calc(100% + 16px);
    width: max-content;
    max-width: 160px;
    height: auto;
    margin: 0;
    padding: 7px 10px;
    border-radius: 6px;
    background: #202126;
    color: #fff;
    clip: auto;
    clip-path: none;
    font-size: 12px;
    line-height: 1.4;
  }
}

@media (min-width: 440px) and (max-width: 1180px) and (max-height: 480px) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dock {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
  }
}

/* In landscape, keep artwork, metadata and navigation on the same visual axis.
   A short, three-action rail must not drift into an unrelated bottom corner. */
@media (min-width: 701px) and (max-width: 1180px) and (min-aspect-ratio: 1/1) {
  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .stage {
    padding: calc(100px + env(safe-area-inset-top))
      calc(104px + env(safe-area-inset-right))
      calc(100px + env(safe-area-inset-bottom))
      max(32px, env(safe-area-inset-left));
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .player {
    grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
    width: min(790px, 100%);
    gap: 36px;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .coverWrap {
    width: min(100%, 300px, max(96px, calc(var(--app-viewport-height, 100dvh) - 220px)));
    border-radius: 18px;
  }

  .app.is-mobile:not(.is-echo-show):not(.is-webtv) .dock {
    top: calc(50% + (env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 2);
    bottom: auto;
    max-height: calc(var(--app-viewport-height, 100dvh) - 180px);
    transform: translateY(-50%);
  }
}
