/*
 * Phone top (redesign 2026-11, as in the PhoneMain mockup). Phones only.
 *   56 px: room name + version ▾ · Room chip · Save   (src/ui/phoneTop.js)
 *   52 px: Original Seed: play · name · wave · sound · insert
 *   transport keys (44 px, Play 72 px) and BAR / TIME / BPM / SIG
 *   floating "+ Track" above the tab bar
 * The master output row of the footer is left to the Mixer tab, which has
 * the master strip with its fader and meter.
 */

.sw-ph-head,
.sw-ph-display,
.sw-ph-more-actions,
.sw-ph-room-actions,
.sw-tab-room {
  display: none;
}

@media (max-width: 760px) {
  /* ---------- Header ---------- */
  html body header.topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    gap: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-bottom: 0 !important;
    background: #0e0e0c !important;
  }

  html body header.topbar > .brand,
  html body header.topbar > .footer-status {
    display: none !important;
  }

  html body header.topbar > .sw-ph-head {
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    height: 56px;
    padding: 0 12px;
    border-bottom: 1px solid #2a2822;
    background: #0e0e0c;
    color: #f4efe4;
  }

  html body .sw-ph-name {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
  }

  html body .sw-ph-room-name {
    overflow: hidden;
    font-size: 15px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body .sw-ph-version {
    all: unset;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    color: #c9c2b3;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
  }

  html body .sw-ph-version-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html body .sw-ph-caret {
    flex: 0 0 auto;
    color: #a7a197;
  }

  html body .sw-ph-room {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    height: 44px;
    padding: 0 10px 0 6px;
    overflow: hidden;
    border: 1px solid #504b40;
    border-radius: 12px;
    background: #151512;
    color: #f4efe4;
    cursor: pointer;
  }

  html body .sw-ph-room::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: #8bd17c;
    opacity: 0.7;
  }

  html body .sw-ph-people {
    display: flex;
  }

  html body .sw-ph-people .sw-room-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 13px;
    background: #64b5f6;
    box-shadow: 0 0 0 2px #151512;
    color: #0b1520;
    font-size: 9px;
    font-weight: 700;
  }

  html body .sw-ph-people .sw-room-avatar + .sw-room-avatar {
    margin-left: -6px;
  }

  html body .sw-ph-people .sw-room-avatar.is-you {
    position: relative;
    z-index: 1;
    background: #d4a855;
    color: #17130a;
  }

  html body .sw-ph-room-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
  }

  html body .sw-ph-room-label {
    font-size: 12px;
    font-weight: 600;
  }

  html body .sw-ph-room-count {
    color: #a7a197;
    font-size: 11px;
    white-space: nowrap;
  }

  html body .sw-ph-save {
    flex: 0 0 auto;
    height: 44px;
    padding: 0 14px;
    border: 1px solid #6b5426;
    border-radius: 12px;
    background: transparent;
    color: #e8bf6a;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
  }

  html body .sw-ph-save:disabled {
    border-color: #3a3428;
    color: #6f6757;
    cursor: default;
  }

  /* ---------- Original Seed ---------- */
  html body header.topbar > .top-room-summary {
    grid-row: 2 !important;
  }

  html body header.topbar > .top-room-summary > .top-seed {
    box-sizing: border-box !important;
    height: 52px !important;
    padding: 0 12px !important;
    border: 0 !important;
    border-bottom: 1px solid #4a3d22 !important;
    border-radius: 0 !important;
    background: linear-gradient(90deg, #2a2112, #17140e) !important;
  }

  html body header.topbar > .top-room-summary > .top-seed .seed-card-body {
    height: 100% !important;
  }

  html body header.topbar > .top-room-summary > .top-seed .seed-wave-row {
    gap: 8px !important;
    height: 100% !important;
  }

  html body header.topbar .top-seed .seed-player {
    display: contents !important;
  }

  html body header.topbar .top-seed .sw-seed-icon,
  html body header.topbar .top-seed .seed-wave-label,
  html body header.topbar .top-seed #seedSeekInput,
  html body header.topbar .top-seed .sw-seed-time {
    display: none !important;
  }

  html body header.topbar .top-seed #seedPlayBtn {
    order: 1;
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: #d4a855 !important;
    color: #17130a !important;
  }

  html body header.topbar .top-seed .sw-seed-meta {
    order: 2;
    display: flex;
    flex: 0 0 96px;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
  }

  html body header.topbar .top-seed .sw-seed-kicker {
    color: #d1b06c;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  html body header.topbar .top-seed .sw-seed-name {
    overflow: hidden;
    color: #f4efe4;
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html body header.topbar .top-seed .sw-seed-wave {
    order: 3;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 1px;
    min-width: 0;
    height: 24px;
    cursor: pointer;
  }

  html body header.topbar .top-seed .sw-seed-wave > span {
    flex: 1 1 0;
    height: var(--h, 12%);
    min-height: 2px;
    border-radius: 1px;
    background: #6b5426;
  }

  /* 32 of the 64 bars, so each one stays visible on a phone. */
  html body header.topbar .top-seed .sw-seed-wave > span:nth-child(2n) {
    display: none;
  }

  html body header.topbar .top-seed .sw-seed-wave > span.played {
    background: #e8bf6a;
  }

  html body header.topbar .top-seed .sw-seed-wave:not(.has-wave) > span {
    animation: sw-seed-wait 1.4s ease-in-out infinite;
    animation-delay: calc(var(--i, 0) * 60ms);
  }

  html body header.topbar .top-seed #seedVolumeBtn {
    order: 4;
  }

  html body header.topbar .top-seed #seedInsertBtn {
    order: 5;
  }

  html body header.topbar .top-seed #seedVolumeBtn,
  html body header.topbar .top-seed #seedInsertBtn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    border: 1px solid #6b5426 !important;
    border-radius: 10px !important;
    background: #2a2112 !important;
    color: #e8bf6a !important;
  }

  /* ---------- Transport keys and display ---------- */
  html body .room > .transport-strip {
    position: relative !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex: 0 0 auto !important;
    gap: 8px 5px !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 8px 12px !important;
    overflow: visible !important;
    border-bottom: 1px solid #2a2822 !important;
    background: #121210 !important;
  }

  html body .room > .transport-strip > .transport-primary-row,
  html body .room > .transport-strip > .transport-primary-row > .transport,
  html body .room > .transport-strip .transport-core,
  html body .room > .transport-strip > .transport-secondary-row {
    display: contents !important;
  }

  html body .room > .transport-strip #positionDisplay,
  html body .room > .transport-strip #stopReturnBtn,
  html body .room > .transport-strip .essential-bpm-control {
    display: none !important;
  }

  html body .room > .transport-strip #rewindBtn { order: 1; }
  html body .room > .transport-strip #stopBtn { order: 2; }
  html body .room > .transport-strip #playBtn { order: 3; }
  html body .room > .transport-strip #recordBtn { order: 4; }
  html body .room > .transport-strip #loopBtn { order: 5; }
  html body .room > .transport-strip .metro-control { order: 6; }
  html body .room > .transport-strip .mobile-edit-drawer { order: 7; }
  html body .room > .transport-strip > .sw-ph-display { order: 9; }

  html body .room > .transport-strip :is(#rewindBtn, #stopBtn, #playBtn, #recordBtn, #loopBtn),
  html body .room > .transport-strip .metro-control,
  html body .room > .transport-strip .metro-control > #metroBtn,
  html body .room > .transport-strip .mobile-edit-drawer,
  html body .room > .transport-strip .mobile-edit-drawer > summary {
    position: relative !important;
    flex: 1 1 0 !important;
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 11px !important;
    transform: none !important;
    inset: auto !important;
  }

  html body .room > .transport-strip :is(#rewindBtn, #stopBtn, #recordBtn),
  html body .room > .transport-strip .mobile-edit-drawer > summary {
    border: 1px solid transparent !important;
    background: #1f1e19 !important;
    color: #e8e2d4 !important;
  }

  html body .room > .transport-strip #recordBtn {
    color: #ef5350 !important;
  }

  html body .room > .transport-strip #recordBtn[aria-pressed="true"] {
    border-color: #ef5350 !important;
    background: #3a1a19 !important;
  }

  html body .room > .transport-strip #playBtn {
    flex-grow: 1.64 !important;
    max-width: 72px !important;
    border: 1px solid #d4a855 !important;
    background: #d4a855 !important;
    color: #17130a !important;
  }

  html body .room > .transport-strip .metro-control > #metroBtn {
    flex: none !important;
    width: 100% !important;
    max-width: none !important;
  }

  /* The Mixer tab keeps the keys and leaves the display to the arrange
     view, as in the PhoneMixer mockup. */
  html body:has(#mixerBtn.active) .room > .transport-strip > .sw-ph-display {
    display: none !important;
  }

  html body .room > .transport-strip .metro-control > .tp-caret {
    position: absolute !important;
    right: -4px !important;
    bottom: -4px !important;
    width: 20px !important;
    min-width: 20px !important;
    height: 20px !important;
    min-height: 20px !important;
  }

  /* More (the View drawer): a ⋮ key; its panel opens under the keys. */
  html body .room > .transport-strip .mobile-edit-drawer > summary {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0 !important;
    list-style: none !important;
    cursor: pointer;
  }

  html body .room > .transport-strip .mobile-edit-drawer > summary::-webkit-details-marker {
    display: none;
  }

  html body .room > .transport-strip .mobile-edit-drawer > summary::before {
    content: "";
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='5' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='12' cy='19' r='2'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='5' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='12' cy='19' r='2'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  html body .room > .transport-strip .mobile-edit-drawer[open] > summary {
    border-color: #8a6f37 !important;
    background: #2a2316 !important;
    color: #d4a855 !important;
  }

  html body .room > .transport-strip .mobile-edit-drawer > .mobile-edit-body {
    position: fixed !important;
    top: var(--sw-ph-sheet-top, 230px) !important;
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
    max-height: calc(100dvh - var(--sw-ph-sheet-top, 230px) - var(--sw-tabbar-space, 64px) - 8px) !important;
  }

  html body .sw-ph-more-actions {
    display: flex;
    gap: 6px;
  }

  html body .sw-ph-more-actions > button {
    flex: 1 1 auto;
  }

  /* Room (the room drawer): no key of its own, the Room tab opens it as a
     sheet above the tab bar. */
  html body .room > .transport-strip .mobile-settings-drawer {
    position: absolute !important;
    width: 0 !important;
    min-width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
  }

  html body .room > .transport-strip .mobile-settings-drawer > summary {
    display: none !important;
  }

  html body .room > .transport-strip .mobile-settings-drawer > .mobile-settings-body {
    position: fixed !important;
    top: auto !important;
    right: 8px !important;
    bottom: calc(var(--sw-tabbar-space, 64px) + 8px) !important;
    left: 8px !important;
    width: auto !important;
    max-height: calc(100dvh - var(--sw-tabbar-space, 64px) - var(--sw-ph-sheet-top, 230px) - 12px) !important;
    overflow: auto !important;
  }

  html body .sw-ph-room-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
  }

  html body .sw-ph-room-actions > button {
    flex: 1 1 0;
    min-height: 40px;
  }

  html body .sw-ph-room-actions > .sw-ph-leave {
    border-color: #6b5426;
    color: #e8bf6a;
  }

  /* BAR · TIME · BPM · SIG */
  html body .room > .transport-strip > .sw-ph-display {
    display: grid;
    flex: 0 0 100%;
    grid-template-columns: 76px minmax(0, 1fr) 72px 40px;
    align-items: center;
    box-sizing: border-box;
    height: 34px;
    padding: 0 12px;
    border: 1px solid #2c2a24;
    border-radius: 9px;
    background: #050504;
    color: #f4efe4;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
  }

  html body .sw-ph-cell {
    all: unset;
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
  }

  html body .sw-ph-cell > span {
    display: none;
  }

  html body .sw-ph-bar output {
    color: #d4a855;
  }

  html body .sw-ph-bpm,
  html body .sw-ph-sig {
    cursor: pointer;
  }

  html body .sw-ph-bpm > span {
    display: inline;
    order: 2;
    color: #a7a197;
    font-family: Inter, system-ui, sans-serif;
    font-size: 11px;
    font-weight: 600;
  }

  html body .sw-ph-sig {
    justify-content: flex-end;
    color: #c9c2b3;
  }

  /* ---------- Footer: the Mixer tab has the master strip ---------- */
  html body .room-footer .footer-capture {
    display: none !important;
  }

  /* ---------- Floating "+ Track" ----------
     On phones phoneTop.js moves the menu to the body: inside the track
     column (overflow hidden, so the tracks scroll) Safari on iPhone clipped
     the fixed button away. */
  html :is(body .track-toolbar, body) > .add-track-menu {
    position: fixed !important;
    z-index: 40 !important;
    right: 12px !important;
    bottom: calc(var(--sw-tabbar-space, 64px) + 12px) !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    margin: 0 !important;
  }

  html body.mobile-chat-open > .add-track-menu,
  html body.mobile-chat-open .track-toolbar > .add-track-menu,
  html body:has(#mixerBtn.active) .track-toolbar > .add-track-menu,
  html body:has(#mixerBtn.active) > .add-track-menu {
    display: none !important;
  }

  html :is(body .track-toolbar, body) > .add-track-menu > #addAudioBtn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    height: 56px !important;
    min-height: 56px !important;
    padding: 0 18px 0 14px !important;
    border: 0 !important;
    border-radius: 28px !important;
    background: #d4a855 !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5) !important;
    color: transparent !important;
    font-size: 0 !important;
  }

  html :is(body .track-toolbar, body) > .add-track-menu > #addAudioBtn::before {
    content: "";
    width: 18px;
    height: 18px;
    background: #17130a;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  html :is(body .track-toolbar, body) > .add-track-menu > #addAudioBtn::after {
    content: "Track";
    color: #17130a;
    font-size: 14px;
    font-weight: 700;
  }

  html :is(body .track-toolbar, body) > .add-track-menu > #addTrackMenu {
    position: fixed !important;
    top: auto !important;
    right: 12px !important;
    bottom: calc(var(--sw-tabbar-space, 64px) + 76px) !important;
    left: auto !important;
  }

  /* ---------- Tab bar: Room ---------- */
  html body .mobile-room-footer-actions.sw-phone-tabs .sw-tab-room {
    --sw-tab-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 20v-1a5 5 0 0 1 5-5h2a5 5 0 0 1 5 5v1M9 10a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM16 4.5a3 3 0 0 1 0 5.5M21 20v-1a4.5 4.5 0 0 0-3-4.2'/%3E%3C/svg%3E");
  }

  /* Save As now sits in the head of the Versions sheet. */
  html body #mobileVersionsSheet .mobile-sheet-head {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  html body #mobileVersionsSheet .mobile-sheet-head > strong {
    margin-right: auto;
  }

  html body #mobileVersionsSheet .mobile-sheet-head > #mobilePublishBtn {
    display: inline-flex !important;
    align-items: center;
    height: 2.1rem;
    padding: 0 0.9rem;
    border-color: #6b5426;
    border-radius: 999px;
    color: #e8bf6a;
  }
}

/* The taller top takes about 4.5rem more than before, so the phone mixer
   gives the same back and still ends above the tab bar. */
@media (max-width: 760px) {
  html body .workspace .mixer-dock {
    min-height: max(14rem, calc(100dvh - var(--sw-ph-sheet-top, 230px) - 5.5rem)) !important;
    max-height: calc(100dvh - var(--sw-ph-sheet-top, 230px) - 5.5rem) !important;
  }
}

/* The timeline takes the height the screen leaves it, so its last tracks can be
   scrolled to: sized by its content, it ran on below the bottom bar. */
@media (max-width: 760px) {
  html body .room > .timeline-frame {
    grid-template-rows: minmax(0, 1fr) !important;
  }

  html body .room > .timeline-frame > :is(.track-column, .timeline-viewport) {
    min-height: 0 !important;
    max-height: 100% !important;
  }

  html body .room > .timeline-frame > .track-column {
    overflow: hidden !important;
  }
}

