/* Phones (narrow screens) and reduced motion. Loaded last: these override the other files. */

/* ---------- mobile ---------- */
.mob, .tabbar, .mini, .mini-wrap { display: none; }
@media (max-width: 899px) {
  :root { --bar-h: 0px; }
  .desk { display: none !important; }
  .mob { display: inline-flex; }
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto; grid-template-areas: "main" "mini" "tabs"; }
  .page { padding: 4px 16px 32px; }
  .page-title { font-size: 26px; margin: 4px 0 18px; }
  .app-head { height: 56px; padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .app-head .icon-btn:first-child { margin-left: -8px; }
  .app-head .head-title { text-align: center; font-size: 16px; }
  .tabbar { grid-area: tabs; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(5,5,6,.96); border-top: 1px solid #16161b; padding: 4px 4px max(4px, env(safe-area-inset-bottom)); }
  .tabbar .nav-link { flex-direction: column; gap: 2px; height: 54px; justify-content: center; font-size: 11px; padding: 0; background: none; }
  .tabbar .nav-link.on { color: var(--text); }
  .mini-wrap { display: block; grid-area: mini; min-width: 0; }
  .mini { position: relative; display: flex; align-items: center; gap: 10px; margin: 0 8px 6px; padding: 8px 6px 8px 8px; border-radius: 10px; background: #2a2324; cursor: pointer; overflow: hidden; }
  .mini-art { width: 42px; height: 42px; border-radius: 6px; }
  .mini-info { flex: 1; min-width: 0; text-align: left; }
  .mini-sub { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
  .mini-where { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 0 auto; max-width: 70%; }
  .mini-where.remote, .mini-where.cast { color: var(--accent); font-weight: 600; }
  .mini-where.offline { color: var(--warn); font-weight: 600; }
  .mini-artist { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .mini-dot { flex: none; }
  .mini.empty { cursor: default; }
  .mini.empty .mini-art { display: grid; place-items: center; background: var(--raised); color: var(--text-3); flex: none; }
  .mini.empty .np-title { color: var(--text-2); }
  .mini-progress { position: absolute; left: 8px; bottom: 0; height: 2px; background: var(--text); border-radius: 2px; max-width: calc(100% - 16px); }
  .shelf-row { grid-auto-columns: 140px; gap: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
  .card-play { display: none; }
  .quick-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .quick { height: 52px; font-size: 13px; padding-right: 8px; }
  .quick .art { width: 52px; height: 52px; }
  .quick-play { display: none; }
  /* phone rows show: lead (number/art), title, ⋯ menu. Album, heart and duration are hidden. */
  .trow { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; height: 60px; padding: 0 0 0 4px; }
  .tracklist .trow:not(:has(.trow-album)) { grid-template-columns: auto minmax(0, 1fr) auto; }
  .trow-dur { display: none; }
  .trow .menu-wrap > .icon-btn { opacity: 1; }
  .detail-head { margin: 0 -16px 12px; padding: 24px 16px 12px; }
  .detail-head-inner { flex-direction: column; align-items: center; text-align: center; gap: 18px; }
  .detail-art { width: min(240px, 62vw); height: auto; }
  .detail-meta { justify-content: center; }
  .detail-actions { justify-content: center; }
  .lib-actions { justify-content: flex-start; }
  /* Library: the filter goes under the title instead of squeezing beside it */
  .page-head-row { flex-wrap: wrap; gap: 0 16px; }
  .page-head-row .filter-box { flex: 1 1 100%; width: auto; height: 44px; order: 4; margin-bottom: 16px; }
  .filter-box .search-input { font-size: 16px; } /* 16px: iPhones zoom into smaller inputs */
  /* Settings rows: the control wraps under its label on narrow screens */
  .set-row { flex-wrap: wrap; }
  .device-name { flex: 1 1 100%; }
  .search-top { grid-template-columns: 1fr; }
  .search-box { height: 48px; }
  .discover { grid-template-columns: minmax(0, 1fr); }
  .discover-hero { padding: 18px; }
  .discover-hero h2 { font-size: 24px; }
  .discover-collage { width: 112px; }
  .discover-collage > * { width: 53px; height: 53px; }
  .discover-modes { grid-template-columns: 1fr 1fr; gap: 10px; }
  .discover-mode { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; position: relative; }
  .discover-mode-play { position: absolute; top: 14px; right: 14px; }
  .discover-mode-text span { font-size: 12px; }
  .tile-grid { grid-template-columns: 1fr 1fr; gap: 8px; --tile-rows: 3; }
  .gcards { grid-auto-columns: 136px; gap: 10px; }
  .gcard-name { font-size: 15px; }
  .decades { grid-auto-columns: 124px; }
  .decade { height: 104px; }
  .decade b { font-size: 34px; }
  .qlinks { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; }
  .qlink { flex: none; }
  .tile-grid.folded > .tile:nth-child(n) { margin-bottom: 8px; }
  .tile { height: 48px; font-size: 14px; padding: 0 12px; }
  .np-full { overflow-y: auto; overflow-x: hidden; }
  .np-full-head { position: sticky; top: 0; z-index: 2; padding-top: max(12px, env(safe-area-inset-top)); }
  .np-full-body { grid-template-columns: minmax(0, 1fr); padding: 4px 24px max(16px, env(safe-area-inset-bottom)); gap: 0; align-content: start; flex: none; }
  /* long titles: two lines, then … (one line pushed the whole page wider than the phone) */
  .np-full-row .np-title { font-size: 21px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .np-full-main { min-width: 0; }
  .np-full-main { gap: 16px; }
  .np-full-art { max-width: min(82vw, 40vh); max-width: min(82vw, 38svh); }
  /* pinned to the bottom of the screen: Play on is always in the same place, without scrolling */
  .np-full-dock { position: sticky; bottom: 0; z-index: 2; padding: 20px 20px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(7,7,8,0), rgba(7,7,8,.85) 45%); }
  .drawer-backdrop { inset: 0; z-index: 75; }
  .drawer { width: 100%; border-left: 0; padding-top: max(8px, env(safe-area-inset-top)); }
  .q-remove { opacity: 1; }
  .toasts { top: max(12px, env(safe-area-inset-top)); bottom: auto; }
  .mode-grid { grid-template-columns: 1fr; gap: 10px; margin-top: 16px; }
  .mode-card { grid-template-columns: 110px 1fr; justify-items: start; text-align: left; align-items: center; column-gap: 14px; row-gap: 2px; padding: 14px; }
  .mode-art { grid-row: span 2; max-width: 110px; margin: 0; }
  .mode-name { font-size: 17px; align-self: end; }
  .mode-desc { font-size: 13px; align-self: start; }
  .dialog-title { font-size: 22px; }
  .dialog { padding: 24px 18px; }
  .speaker-inner { padding: 20px 16px; }
  .speaker-now { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .speaker-name { font-size: 22px; }
  .speaker-track h2 { font-size: 26px; }
  .onboard-card { padding: 28px 22px; }
  .hero-title { font-size: 36px; }
}
@media (max-width: 899px) {
  .sheet-backdrop { place-items: end stretch; }
  .sheet { width: 100%; max-height: 85vh; border-radius: 16px 16px 0 0; border-width: 1px 0 0; padding: 10px 10px max(14px, env(safe-area-inset-bottom)); animation: sheet-up .2s var(--ease); }
  .sheet .menu-item { height: 50px; font-size: 16px; gap: 16px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }
/* Touch screens: a song row plays wherever it's tapped (Go to artist / album are in its menu), and a
   long press opens the menu instead of selecting text. */
@media (pointer: coarse) {
  .trow-sub a, .trow-album a { pointer-events: none; color: inherit; }
  .trow, .card, .top-card, .quick { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
