/* Phone layout only. Desktop geometry lives in the existing stylesheets and is
   intentionally untouched by this file. */

.mobile-studio-dock { display: none; }

@media (max-width: 760px) {
  :root { --mobile-gutter: 12px; --head: 118px; --row: 72px; --detail: 0px; }

  html, body, #app { width: 100%; max-width: 100%; min-height: 100%; height: 100%; }
  body { overflow: hidden; overscroll-behavior: none; }
  #app { overflow: hidden; }
  button, input, select, textarea { touch-action: manipulation; }

  /* DAW shell */
  .topbar { height: 48px; min-height: 48px; padding: 0 var(--mobile-gutter); gap: 8px; overflow: hidden; }
  .topbar::-webkit-scrollbar, .transport::-webkit-scrollbar, .arrangement-toolbar::-webkit-scrollbar { display: none; }
  .topbar > * { flex: 0 0 auto; }
  .topbar .brand { font-size: 13px; }
  .topbar .project-title { flex: 1 1 auto; max-width: none; min-width: 0; justify-content: flex-start; overflow: hidden; text-overflow: ellipsis; }
  .topbar .saved, .topbar > .separator, .topbar > .share, .topbar > .export, .topbar > .icon-btn, .topbar > .avatar { display: none !important; }
  .transport { height: 52px; min-height: 52px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
  .transport > * { flex: 0 0 auto; }
  .transport .output-volume, .transport .output-icon, .transport .view-toggle, .transport > .separator, .transport-value:has(#tempo), .transport [data-action="signature"] { display: none; }
  .transport .primary, .transport .icon-btn { min-width: 40px; min-height: 40px; }
  .transport-value { min-height: 38px; height: 38px; }
  .transport .position { display: flex; min-width: 92px; margin-left: 3px; }

  .studio { display: block; position: relative; width: 100%; max-width: 100%; height: calc(100dvh - 164px - env(safe-area-inset-bottom)); min-height: 0; }
  .workarea { width: 100%; max-width: 100%; height: 100%; min-height: 0; }
  .arrangement-toolbar { min-height: 44px; height: 44px; padding: 0 8px; overflow-x: auto; justify-content: flex-start; white-space: nowrap; }
  .arrangement-toolbar > * { flex: 0 0 auto; }
  .arrangement-toolbar button { min-width: 40px; min-height: 40px; }
  .arrangement-toolbar .title, .arrangement-toolbar > .separator, .arrangement-toolbar .toolbar-label { display: none; }
  .arrangement-toolbar [data-action="add-track"] { margin-left: auto; }
  .arrangement { min-height: 0; height: calc(100% - 44px); touch-action: pan-x pan-y; }
  .arrangement .track-lane { touch-action: pan-x pan-y; }
  .arrangement .clip { touch-action: none; }
  .detail { position: fixed; z-index: 125; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; width: 100vw; height: auto; min-height: 0; border-top: 0; transform: translateY(105%); visibility: hidden; pointer-events: none; transition: transform .2s ease, visibility 0s linear .2s; }
  html.mobile-detail-open .detail { transform: translateY(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
  .detail-resize { display: none; }
  .detail-bar { min-height: 52px; height: 52px; overflow-x: auto; white-space: nowrap; padding-inline: 12px; }
  .detail-bar > * { flex: 0 0 auto; }
  .detail-tabs { gap: 4px; }
  .detail-tabs button { min-height: 40px; padding-inline: 8px; }
  .detail-content { min-height: 0; width: 100%; }
  .detail-content .clip-inspector[hidden] { display: none; }
  .piano-editor, .audio-editor { width: 100%; }
  .piano-tools { min-height: 46px; padding: 4px 8px; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  .piano-tools > * { flex: 0 0 auto; }
  .piano-tools button, .piano-tools select { min-height: 34px; }
  .piano-grid-wrap { min-height: 150px; touch-action: pan-x pan-y; }
  .piano-grid { min-width: 680px; }
  .piano-note { min-width: 20px; }
  .mixer { padding: 8px; gap: 7px; touch-action: pan-x; }
  .mixer-channel, .mixer-channel.master-channel { min-width: 118px !important; width: 118px; }
  .devices { min-width: 0; overflow-x: auto; }
  .device { min-width: min(82vw, 300px); }
  .audio-actions { overflow-x: auto; padding-bottom: 4px; }
  .statusbar { display: none; }

  .track-head { padding: 6px 27px 6px 7px; gap: 5px; }
  .track-name { min-width: 0; }
  .track-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .track-controls { gap: 3px; }
  .track-controls button { min-width: 27px; width: 27px; height: 27px; font-size: 10px; }
  .track-controls input, .track-controls .track-meter { display: none; }
  .ruler-row .timeline-head { padding-inline: 8px; }
  .ruler-row .timeline-head span:first-child { display: none; }

  .mobile-studio-dock { position: fixed; z-index: 140; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: calc(64px + env(safe-area-inset-bottom)); padding: 4px 4px env(safe-area-inset-bottom); border-top: 1px solid #3b3c44; background: #191a1fee; backdrop-filter: blur(14px); }
  .mobile-studio-dock button { min-width: 0; min-height: 56px; flex-direction: column; gap: 3px; border-radius: 7px; color: #999ca7; font-size: 10px; }
  .mobile-studio-dock button .ph-icon { width: 20px; height: 20px; font-size: 20px; }
  .mobile-studio-dock button.active, html.mobile-browser-open .mobile-studio-dock [data-mobile-action="sounds"], html.mobile-detail-open .mobile-studio-dock [data-mobile-action="edit"] { color: var(--accent); background: #f08b6214; }

  /* Sounds are a complete working view, not a narrow overlay over the timeline. */
  .sidebar { display: flex; position: fixed; z-index: 125; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; width: 100vw; max-width: 100vw; transform: translateX(-105%); visibility: hidden; pointer-events: none; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: none; border-right: 0; }
  html.mobile-browser-open .sidebar { transform: translateX(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
  #extend-browser { display: none !important; }
  .browser-title { min-height: 48px; padding: 8px 12px; }
  .search { min-height: 42px; }
  .browser-nav button, .library-item { min-height: 44px; }
  .library-list { min-height: 120px; }

  /* Full-screen dialogs and editors keep controls within the safe viewport. */
  dialog { width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: calc(100dvh - 20px); margin: 10px auto; }
  .modal-head { min-height: 52px; padding: 12px 15px; }
  .modal-body { max-height: calc(100dvh - 155px); overflow: auto; padding: 15px; }
  .modal-footer { flex-wrap: wrap; padding: 12px 15px; }
  .modal-footer button { flex: 1 1 130px; min-height: 42px; }
  .large-effect-window { inset: 8px; left: 8px; top: 8px; width: auto; max-height: calc(100dvh - 16px); transform: none; }
  .plugin-overlay, .plugin-window { max-width: calc(100vw - 16px) !important; }
  #modal.daw-settings-dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  #modal.daw-settings-dialog > .modal-body { max-height: calc(100dvh - 112px); padding-inline: 12px; }
  .form-scroll, .shortcut-list, .library-manager { max-height: 54dvh; overflow: auto; }
  main.workspace-home { max-width: none !important; margin: 0 !important; padding: var(--mobile-gutter) !important; }
}

@media (max-width: 760px) {
  /* Workspace / home / settings pages */
  #modal.workspace-home, #modal.workspace-home > .modal-body { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; overflow: hidden; }
  .workspace-shell, .wh-main, .wh-page, .wh-sidebar { width: 100%; max-width: 100%; min-width: 0; }
  .workspace-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100%; overflow: hidden; }
  .wh-main { grid-row: 1; min-height: 0; overflow: hidden; }
  .wh-sidebar { grid-row: 2; grid-column: 1; min-height: 65px; height: auto; padding: 5px 6px max(5px, env(safe-area-inset-bottom)); border-top: 1px solid var(--wh-line); border-right: 0; overflow: hidden; }
  .wh-sidebar nav { width: 100%; min-width: 0; flex-direction: row; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .wh-sidebar nav::-webkit-scrollbar { display: none; }
  .wh-sidebar nav button { width: auto; flex: 0 0 62px; min-height: 55px; padding: 5px 3px; flex-direction: column; gap: 2px; font-size: 9px; }
  .wh-sidebar nav button .ph-icon { width: 19px; height: 19px; font-size: 19px; }
  .wh-sidebar nav button > span { display: block; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wh-brand, .wh-account { display: none !important; }
  .workspace-shell .wh-sidebar { flex-direction: row; align-items: center; }
  .workspace-shell .wh-sidebar nav { flex: 1 1 auto; width: auto; }
  .workspace-shell .wh-broadcast-slot { flex: 0 0 42px; align-self: auto; width: 42px; margin: 0 0 0 4px; }
  .wh-topbar { min-height: 56px; padding: 9px var(--mobile-gutter); }
  .wh-topbar > span { max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wh-actions { margin-left: auto; }
  .wh-page { padding: 18px var(--mobile-gutter) 24px; overflow-x: hidden; overflow-y: auto; }
  .wh-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .wh-heading > * { max-width: 100%; }
  .wh-heading h1 { font-size: 25px; line-height: 1.15; }
  .wh-heading p { line-height: 1.45; }
  .wh-heading #home-primary { width: 100%; }
  .wh-heading #home-primary > button { width: 100%; }
  .wh-project-layout, .wh-content-grid, .wh-settings-layout, .wh-storage-grid { grid-template-columns: 1fr !important; }
  .wh-project-layout { min-width: 0; }
  .wh-projects, .wh-project-list, .wh-storage-panel, .wh-settings-main { min-width: 0; }
  .wh-table-head { display: none; }
  .wh-project-row { grid-template-columns: 42px minmax(0, 1fr) auto !important; gap: 9px; min-height: 64px; }
  .wh-project-row .wh-modified, .wh-project-row > small { display: none; }
  .wh-project-row .wh-menu { justify-self: end; }
  .wh-list-tools { align-items: stretch; flex-direction: column; gap: 8px; }
  .wh-list-tools .wh-search { max-width: none; min-height: 42px; }
  .wh-settings-nav { position: static; overflow-x: auto; scrollbar-width: none; }
  .wh-settings-nav::-webkit-scrollbar { display: none; }
  .wh-settings-main { gap: 14px; }
  .wh-settings-card, .wh-settings-page .wh-settings-section { padding: 16px; }
  .wh-settings-form-grid, .wh-settings-security-grid { grid-template-columns: 1fr; }
  .wh-settings-actions, .wh-settings-links { justify-content: stretch; }
  .wh-settings-actions button, .wh-settings-links button { flex: 1 1 140px; }
  .wh-storage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wh-storage-rules ul { grid-template-columns: 1fr !important; }
  .wh-notification-center { width: calc(100vw - 16px); }
  .social-messages { grid-template-columns:1fr; }
  .social-messages > aside { border-right: 0; border-bottom:1px solid var(--ui-border,#3c4142); }
  .social-thread { min-height:0; }
  .social-thread-messages { max-height:42dvh; }
  .social-message-compose textarea { min-height:44px; }
  .profile-header { grid-template-columns: 78px minmax(0, 1fr) !important; }
  .profile-title-block { padding-left: 8px !important; }
  .profile-actions { grid-column: 1 / -1 !important; justify-content: stretch; }
  .profile-actions button { flex: 1 1 130px; }
}

@media (max-width: 480px) {
  .topbar .brand { display: none; }
  .topbar .project-title { max-width: none; }

  .detail-name { max-width: 105px; }
  .wh-sidebar nav button { flex-basis: 58px; }
  .wh-heading h1 { font-size: 22px; }
  .pd-cards > section { height: auto; min-height: 220px; }
  .pd-slide > div { padding: 18px; }
  .pd-cards h2 { font-size: 21px; }
  .catalog-filters { gap: 7px !important; }
  .catalog-filters > * { flex-basis: 100% !important; width: 100%; max-width: none !important; }
  .catalog-upload { grid-template-columns: 1fr !important; }
  .pack-actions { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .detail { transition: none; }
}
