/* Shared page layout, loaded last by every Media Hub page. */
:root { --page-width: 1460px; --page-gutter: clamp(12px, 2.4vw, 32px); --page-space: clamp(16px, 2.4vw, 28px); --control-height: 44px; --topbar-top: 10px; --topbar-height: 64px; --sticky-panel-gap: clamp(16px, 2vw, 24px); --sticky-panel-top: calc(var(--topbar-top) + var(--topbar-height) + var(--sticky-panel-gap)); }
html { scroll-padding-top: 100px; }
body { min-height: 100dvh; }
.shell, .shell.subpage-shell, .shell.music-shell, .shell.spotify-shell {
  width: min(var(--page-width), calc(100% - var(--page-gutter) * 2));
  padding-inline: 0;
  padding-top: max(10px, env(safe-area-inset-top));
  margin-inline: auto;
}
.shell .topbar { top: var(--topbar-top); align-items: center; gap: 12px; margin: 0 0 var(--page-space); min-height: var(--topbar-height); }
.brand { min-width: 0; flex-shrink: 1; }
.brand span { min-width: 0; }
.brand small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { flex-shrink: 0; gap: 6px; }
.nav-menu { margin-left: 0; }
.nav-link { min-height: var(--control-height); }
.nav-dropdown { max-height: calc(100dvh - 105px); overflow-y: auto; overscroll-behavior: contain; }
.quick-search-toggle { display: none !important; width: 44px; padding: 0; }
.shell > .standalone-panel, .shell > .services, .shell > .automation, .shell > .accounts { margin-top: 0; padding: var(--page-space); }
.shell .section-heading { flex-wrap: wrap; align-items: center; gap: 16px; }
.section-heading > div, .activity-heading > div, .music-content-heading > div, .search-query { min-width: 0; }
.page-title { margin: 0; font-size: clamp(1.8rem, 3.5vw, 2.65rem); line-height: 1.15; }
.automation-intro { line-height: 1.6; max-width: 78ch; }
.library-search, .search-query, .music-search { min-width: 0; }
.library-search input { width: 100%; }
.shell :is(input:not([type="range"]):not([type="checkbox"]), select, textarea) { max-width: 100%; min-height: var(--control-height); }
.shell :is(.quiet, .primary-action, .refresh, .library-filter, .save-settings) { min-height: var(--control-height); display: inline-flex; justify-content: center; align-items: center; gap: 7px; text-decoration: none; }
.shell :is(.library-toolbar, .hero-actions, .account-row-actions, .music-heading-actions) { flex-wrap: wrap; }
.shell .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); }
.shell .settings-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); }
.shell .settings-actions { grid-column: 1 / -1; }
.shell :is(.card-copy, .activity-copy, .search-result-copy, .music-replace-copy, .account-row) { min-width: 0; overflow-wrap: anywhere; }
.shell .activity-heading { flex-wrap: wrap; gap: 12px; }
.shell .card { grid-template-columns: 48px minmax(0, 1fr) auto; }
.music-content { min-width: 0; }
.music-shell .music-content-heading { gap: 14px; flex-wrap: wrap; }
.music-shell .music-heading-actions { justify-content: flex-start; }
.music-shell .music-controls-card { min-width: 0; }
.shell > :is(.standalone-panel, .services, .automation, .accounts, .music-app), .spotify-shell > :not(.topbar) { scroll-margin-top: var(--sticky-panel-top); }
.media-progress-panel, .music-sidebar, .lyrics-panel { top: var(--sticky-panel-top); scroll-margin-top: var(--sticky-panel-top); }
.media-dialog { padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.media-dialog .media-dialog-card { width: min(900px, 100%); max-width: 100%; max-height: calc(100dvh - 24px); margin: 0 auto; overflow-y: auto; overscroll-behavior: contain; }
.media-dialog .music-replace-card { width: min(1000px, 100%); padding: var(--page-space); }
.media-dialog-card > h2 { overflow-wrap: anywhere; padding-right: 44px; }
.hub-dialog-open { overflow: hidden; }
.music-replace-preview { background: transparent; overflow: visible; aspect-ratio: auto; }
.music-replace-preview iframe, .youtube-preview-stage iframe { display: block; width: 100%; height: auto; min-height: 200px; aspect-ratio: 16 / 9; border: 0; border-radius: 14px; background: #080b10; }
.youtube-preview-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.youtube-preview-actions .quiet { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 14px; text-decoration: none; text-align: center; }
.music-preview-status { margin: 8px 0 12px; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.youtube-preview-audio { display: block; width: 100%; margin-block: 16px; }
.preview-page { padding: var(--page-space); }
.youtube-preview-stage { max-width: 1050px; margin-inline: auto; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 999; padding: 12px 18px; border-radius: 12px; color: var(--text); background: var(--panel-strong); }
.skip-link:focus { top: 12px; }
.back-to-top { position: fixed; z-index: 85; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: grid; place-items: center; width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0; gap: 0; border-radius: 50%; background: var(--glass-strong); box-shadow: var(--shadow); }
.back-to-top svg { width: 16px; height: 16px; }
.back-to-top span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.music-body .back-to-top { display: none !important; }
.hub-dialog-open .back-to-top, .music-focus-open .back-to-top { display: none; }
.shell .spotify-hero { padding: 22px 0 28px; }
.shell .spotify-hero h1 { font-size: clamp(1.8rem, 3.5vw, 2.65rem); }
.spotify-shell > :not(.topbar) { width: 100%; max-width: none; }
.spotify-shell :is(.panel, .progress-panel) { padding: var(--page-space); border: 1px solid var(--line); border-radius: var(--radius-xl, 24px); background: var(--panel); box-shadow: var(--shadow); }
.spotify-shell .layout, .spotify-shell .youtube-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spotify-shell :is(p, label, .metric-label, .worker-note, .progress-meta, .playlist-url) { color: var(--muted); }
.spotify-shell .metric-value, .spotify-shell .track-list li, .spotify-shell .playlist-copy strong { color: var(--text); }
.spotify-shell .worker-form { grid-template-columns: minmax(0, 1fr) 90px auto; }
.spotify-shell .metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr)); }
@media (min-width: 1121px) { .quick-search-toggle { display: inline-flex; } }
@media (max-width: 900px) {
  body:not(.quick-focus-open) .home-quick-player { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .home-quick-player .quick-player-right { width: 100%; min-width: 0; }
  .shell .search-layout, .spotify-shell .layout, .spotify-shell .youtube-layout { grid-template-columns: 1fr; }
  .shell .media-search-form { grid-template-columns: minmax(0, 1fr) minmax(150px, .6fr); }
  .shell .media-search-form .primary-action { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  :root { --topbar-top: max(6px, env(safe-area-inset-top)); --topbar-height: 60px; --sticky-panel-gap: 14px; }
  .shell .topbar { padding: 8px 10px; }
  .shell .brand img { width: 34px; height: 34px; }
  .shell .brand { gap: 8px; }
  .shell .brand strong { font-size: .92rem; }
  .shell .brand small { display: block; font-size: .7rem; max-width: 36vw; }
  .quick-search-toggle { display: inline-flex; }
  .shell .nav-menu-toggle { min-height: 44px; }
  .shell .nav-menu-toggle span { display: none; }
  .shell .nav-menu-toggle { width: 44px; padding: 0; }
  .shell :is(input:not([type="range"]):not([type="checkbox"]), select, textarea) { font-size: 16px; }
  .shell .section-heading { align-items: stretch; }
  .shell .library-heading > *, .shell .library-search { width: 100%; }
  .shell .media-search-form, .shell .account-grid { grid-template-columns: 1fr; }
  .shell .library-toolbar { gap: 8px; }
  .shell .library-toolbar > :is(.primary-action, .library-refresh) { flex: 1 1 180px; }
  .shell .hero { padding: 30px 0; }
  .shell .hero h1 { font-size: clamp(2rem, 9vw, 3.3rem); }
  .shell .hero-actions { align-items: stretch; }
  .shell .hero-actions > * { flex: 1 1 180px; justify-content: center; }
  .shell .card { grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
  .shell .card .service-icon { width: 40px; height: 40px; }
  .shell .card .state { grid-column: 2; }
  .spotify-shell .worker-form { grid-template-columns: minmax(0, 1fr) 80px; }
  .spotify-shell .worker-save { grid-column: 1 / -1; }
  .youtube-preview-actions > a { flex: 1 1 180px; }
  .back-to-top { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); width: 32px; height: 32px; min-width: 32px; min-height: 32px; }
  .back-to-top svg { width: 14px; height: 14px; }
  .music-body .back-to-top { bottom: calc(168px + env(safe-area-inset-bottom)); }
}
@media (max-height: 540px) and (orientation: landscape) {
  .shell .topbar { position: relative; top: 0; }
  .nav-dropdown { max-height: calc(100dvh - 85px); }
  .media-dialog .media-dialog-card { max-height: calc(100dvh - 20px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
