/* Installed / phone app shell. Class is set before paint by mobile.js. */
#appMenuBtn,
#appLibraryTabs,
#appLibraryBackdrop,
.s5-mobile-tools,
.s5-mobile-more,
.s5-sheet-backdrop { display: none; }

html.app-phone {
  --studio-rail-width: 0px;
  --studio-dock: calc(58px + env(safe-area-inset-bottom, 0px));
  --app-composer: 92px;
  --phone-header: calc(56px + env(safe-area-inset-top, 0px));
  --keyboard-inset: 0px;

  html, body {
    height: 100%;
    min-height: 100dvh;
  }

  /* ===== Studio shell: left rail becomes the bottom dock ===== */
  body.studio-app {
    height: 100dvh;
    overflow: hidden;
  }
  body.studio-app .studio-shell {
    display: block;
    height: 100dvh;
    max-height: 100dvh;
    width: 100%;
    overflow: hidden;
  }
  body.studio-app .studio-workspace,
  body.studio-app .studio-workspace > .app-wrapper,
  body.studio-app .main-container {
    height: 100%;
    min-height: 0;
  }
  body.studio-app .studio-workspace {
    padding-bottom: var(--studio-dock);
  }

  .studio-rail {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 80;
    width: 100%;
    height: var(--studio-dock);
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    padding: 4px 4px env(safe-area-inset-bottom, 0px);
    border-right: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(8, 8, 8, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .studio-rail-gap,
  .studio-rail-rule,
  .studio-rail-home {
    display: none;
  }
  .studio-rail-btn {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 48px;
    padding: 6px 2px 4px;
    gap: 3px;
    font-size: 9px;
    border-radius: 12px;
  }
  .studio-rail-btn svg {
    width: 20px;
    height: 20px;
  }
  .studio-rail-btn span {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.05;
  }
  .studio-rail-btn[data-rail="agent"] {
    display: none !important;
  }
  .studio-rail-btn[data-rail="projects"],
  .studio-rail-btn[data-rail="chats"],
  .studio-rail-btn[data-rail="projects"]::after,
  .studio-rail-btn[data-rail="chats"]::after {
    display: none !important;
  }
  .studio-rail-btn.active {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff;
  }

  /* Projects and chats share one left drawer, like chat. */
  .projects-sidebar,
  .chats-sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0;
    bottom: var(--studio-dock);
    width: min(320px, 86vw);
    height: auto !important;
    border-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 0;
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45);
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 95;
    padding-top: 8px;
    background: #09090a;
    overflow: hidden;
  }
  body.app-library-open .projects-sidebar.open {
    top: var(--phone-header) !important;
    bottom: auto !important;
    height: calc(50dvh - var(--phone-header)) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 12px !important;
  }
  body.app-library-open .chats-sidebar.open {
    top: 50dvh !important;
    bottom: var(--studio-dock) !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }
  body.app-library-open .chats-sidebar.open .chats-sidebar-list,
  body.app-library-open .projects-sidebar.open .sidebar-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .chats-history-item {
    flex: 0 0 auto;
    min-height: 36px;
    height: auto;
  }
  body.app-library-open .projects-sidebar.open,
  body.app-library-open .chats-sidebar.open {
    left: 0;
    transform: none;
  }
  .projects-sidebar.no-anim,
  .chats-sidebar.no-anim {
    transition: none !important;
  }
  .projects-sidebar-top { display: none; }
  .projects-sidebar-label { display: block; padding-top: 8px; }
  #appMenuBtn,
  .app-menu-btn {
    position: relative;
    top: auto;
    left: auto;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: #fff;
    box-shadow: none !important;
    transform: none !important;
  }
  .app-menu-btn svg { width: 22px; height: 22px; }
  .app-library-tabs {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 96;
    width: min(320px, 86vw);
    height: 52px;
    align-items: center;
    gap: 6px;
    padding: 8px;
    background: #09090a;
  }
  body.app-library-open .app-library-tabs { display: none !important; }
  .app-library-tabs button {
    flex: 1;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: transparent !important;
    color: #8e8e93;
    font: 650 13px/1 var(--font-main, system-ui);
    box-shadow: none !important;
    transform: none !important;
  }
  .app-library-tabs button.is-on {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #fff;
  }
  #appLibraryBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 94;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
  }
  body.app-library-open #appLibraryBackdrop { display: block; }
  body.studio-app header#mainHeader {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "menu logo profile" "pipe pipe pipe";
    align-items: center;
    padding: 8px 12px 8px 8px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    background: #0c0c0e;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none !important;
  }
  #appMenuBtn { grid-area: menu; }
  .phone-header-lead {
    grid-area: menu;
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    justify-self: start;
  }
  .phone-header-lead #appMenuBtn {
    grid-area: auto;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }
  body.studio-app header .phone-header-lead .studio-rail-btn[data-rail="agent"] {
    display: inline-flex !important;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: auto;
    min-width: 0;
    min-height: 32px;
    height: 32px;
    margin: 0;
    padding: 0 10px 0 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff;
    font: 650 12px/1 var(--font-main, system-ui);
    box-shadow: none !important;
    transform: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.studio-app header .phone-header-lead .studio-rail-btn[data-rail="agent"] svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
  }
  body.studio-app header .phone-header-lead .studio-rail-btn[data-rail="agent"] span {
    display: block;
    overflow: visible;
    line-height: 1;
    font-size: 12px;
    -webkit-line-clamp: unset;
  }
  body.studio-app header .phone-header-lead .studio-rail-btn[data-rail="agent"].active {
    background: rgba(255, 255, 255, 0.16) !important;
    color: #fff;
  }
  body.studio-app header .header-brand {
    grid-area: logo;
    justify-self: center;
  }
  body.studio-app header .logo {
    grid-area: auto;
    justify-self: center;
    text-align: center;
  }
  body.studio-app .header-right { grid-area: profile; margin-left: 0; }
  body.studio-app .project-title { grid-area: pipe; order: 0; flex: none; }

  .seq-engine-row { display: none !important; }
  html.app-phone,
  body.studio-app {
    overflow: hidden !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
  }
  #stage-1.active,
  #stage1-flow,
  #s1-dynamic:has(.s1-home-workspace) {
    height: 100%;
    min-height: 0;
    overflow: hidden !important;
  }
  #s1-dynamic:has(.s1-home-workspace) { justify-content: flex-start !important; }
  .s1-home-workspace {
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    padding: 4px 16px 0 !important;
    box-sizing: border-box !important;
  }
  .s1-home-prompt { display: contents !important; }
  h1.seq-header {
    order: 2;
    position: fixed !important;
    left: 16px;
    right: 16px;
    bottom: calc(var(--studio-dock) + 78px + var(--keyboard-inset, 0px));
    margin: 0 !important;
    z-index: 61;
    font-size: clamp(1.35rem, 5.4vw, 1.7rem) !important;
    line-height: 1.15;
    text-align: center;
    pointer-events: none;
  }
  .seq-bottom {
    order: 1;
    flex: 1 1 auto;
    min-height: 0;
    width: 100% !important;
    max-width: none !important;
    overflow: auto;
    padding-bottom: calc(var(--studio-dock) + 150px) !important;
  }
  .s1-home-workspace .prompt-box {
    position: fixed !important;
    left: 12px;
    right: 12px;
    bottom: calc(var(--studio-dock) + 10px + var(--keyboard-inset, 0px));
    z-index: 60;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    opacity: 1;
  }
  #s1-recent-projects-grid {
    display: flex !important;
    flex-direction: column;
    grid-template-columns: none !important;
    gap: 10px;
  }
  #s1-recent-projects-grid .project-card {
    align-items: center;
    gap: 14px;
    padding: 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
  }
  #s1-recent-projects-grid .project-card-thumb {
    width: 92px !important;
    height: 92px !important;
    border-radius: 16px;
  }
  #s1-recent-projects-grid .project-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #f5f5f7;
  }
  #s1-recent-projects-grid .project-card-type {
    font-size: 13px;
    margin-top: 4px;
  }
  #stage-1:has(.s1-home-workspace) { padding-bottom: 0; }
  #chatBar:not(.show),
  #stage-1:has(.s1-home-workspace) #chatBar {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* ===== Header ===== */
  body.studio-app header,
  body.account-page header,
  body.pricing-page header,
  body.chat-page header {
    transform: none !important;
    opacity: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px;
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    background: #0c0c0e;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  body.studio-app .logo,
  body.account-page .logo,
  body.pricing-page .logo {
    font-size: 14px;
  }
  body.studio-app .project-title {
    order: 3;
    flex: 1 0 100%;
    justify-content: flex-start;
    min-width: 0;
    overflow: hidden;
  }
  body.studio-app.ai-generate-mode .project-title,
  html.ai-generate-mode body.studio-app .project-title {
    display: none;
  }
  .pipeline:not(.show-pipeline) { display: none; }
  body.studio-app .project-title:not(:has(.show-pipeline)) { display: none; }
  .pipeline {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
    padding: 3px;
    gap: 2px;
  }
  .pipeline::-webkit-scrollbar { display: none; }
  .pipeline span {
    flex: 0 0 auto;
    padding: 7px 12px;
    font-size: 12px;
    letter-spacing: 0;
  }
  .header-right {
    margin-left: auto;
    gap: 8px;
  }
  .s5-view-switch-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .profile-dropdown,
  .studio-hub-dropdown {
    position: fixed !important;
    top: calc(var(--phone-header) + 8px) !important;
    right: 12px !important;
    bottom: auto !important;
    left: 12px !important;
    width: auto !important;
    max-height: min(68dvh, 520px);
    overflow: auto;
    z-index: 4000 !important;
    transform: none !important;
  }
  #profileToggle {
    position: relative;
    z-index: 5;
    pointer-events: auto;
  }
  body.account-page .profile-dropdown,
  body.pricing-page .profile-dropdown,
  body.chat-page .profile-dropdown,
  body.account-page .studio-hub-dropdown,
  body.pricing-page .studio-hub-dropdown,
  body.chat-page .studio-hub-dropdown {
    bottom: 12px;
  }

  .stages-container,
  .stage.active {
    min-height: 0;
  }
  .stage {
    padding-bottom: 8px;
  }

  /* Stage 1 */
  .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .action-btn { padding: 18px 10px; }
  .recent-grid { grid-template-columns: 1fr; }
  .workspace-title { font-size: 24px; }
  #s1-text { font-size: 22px; letter-spacing: 1px; width: calc(100% - 32px); text-align: center; }
  .s1-make-idea {
    left: 0;
    right: 0;
    top: 72px;
    bottom: calc(var(--studio-dock) + 88px);
    padding: 0 18px;
    font-size: 1.25rem;
  }
  .idea-card.idea-card-focused {
    left: 50% !important;
    width: min(100% - 24px, 700px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - var(--studio-dock) - 96px);
  }
  body.studio-app .chat-container,
  body.studio-app #ideas-container {
    left: 0;
    right: 0;
  }
  body.studio-app .chat-container {
    bottom: var(--studio-dock);
    padding-bottom: 10px;
  }
  #ideas-container:not(.vertical):not(.masonry) .idea-card {
    min-width: min(78vw, 260px);
  }
  #ideas-container.vertical .idea-card {
    width: calc(100% - 24px);
  }
  .content-constrained {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Stage 2 editor: groups stay in a row; the phone rules below wrap those groups. */
  .ql-toolbar.ql-snow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    overflow: visible;
    padding: 6px 8px !important;
  }
  .ql-editor { padding: 16px; }
  #stage-2 #stage2-flow { padding-bottom: 12px !important; }

  /* Stage 3 */
  #stage-3 .s3-stage { padding: 8px 12px; max-width: none; }
  #stage-3 .s3-header-actions {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }
  #stage-3 .s3-style-rail { max-width: 100%; }
  #stage-3 .s3-style-tile,
  #stage-3 .s3-style-cover { width: 60px; }
  #stage-3 .s3-style-cover { height: 60px; border-radius: 16px; }

  /* Stage 4 shots */
  .s4-header-controls {
    flex-wrap: wrap;
    padding: 0 12px;
    margin-bottom: 12px;
  }
  .s4-header-left,
  .s4-header-right {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .s4-grid-view,
  .s4-grid-view .s4-multishot-group {
    grid-template-columns: 1fr !important;
  }

  /* ===== Stage 5 generate: Flow-style gallery + bottom composer ===== */
  #stage-5 .s5-workspace {
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: visible;
  }
  #stage-5 .s5-panel-drag-handle,
  #stage-5 .s5-splitter,
  #stage-5 .s5-panel-handle-slot {
    display: none !important;
  }

  #stage-5.s5-gallery-mode .s5-gallery-pane,
  body.ai-generate-mode #stage-5 .s5-gallery-pane {
    order: 0;
    flex: 1 1 auto;
    width: 100% !important;
    min-height: 0;
    padding: 8px 8px 280px;
  }
  #stage-5.s5-gallery-mode .s5-gallery-pane::before { display: none; }
  .s5-gallery-toolbar {
    flex-wrap: nowrap;
    overflow: visible;
    position: relative;
    z-index: 6;
    margin-bottom: 8px;
  }
  .s5-gallery-filter { flex: 0 0 auto; height: 32px; padding: 0 12px; }
  .s5-gallery-type-wrap {
    position: relative;
    flex: 0 0 auto;
    z-index: 8;
  }
  .s5-gallery-type-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 148px;
    padding: 6px;
    border-radius: 16px;
    background: rgba(22, 22, 24, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
  }
  .s5-gallery-type-menu[hidden] { display: none !important; }
  .s5-gallery-type-menu .s5-gallery-filter {
    width: 100%;
    justify-content: flex-start;
    border-radius: 12px;
  }
  .s5-gallery-zoom-wrap {
    position: relative;
    z-index: 7;
  }
  .s5-gallery-zoom-pop {
    z-index: 50;
  }
  .s5-gallery-zoom-pop:not([hidden]) {
    display: flex !important;
  }
  .s5-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--s5-gallery-tile, 290px)), 1fr)) !important;
    gap: 8px !important;
  }
  .s5-gallery-grid.is-folders {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--s5-gallery-folder-tile, 116px)), 1fr)) !important;
  }
  .s5-gallery-card,
  .s5-gallery-card img,
  .s5-gallery-card video {
    border-radius: 12px;
  }
  .s5-gallery-card,
  .s5-gallery-card img,
  .s5-gallery-card video {
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    user-select: none;
  }
  html.app-phone.is-gallery-drag-lock,
  html.app-phone.is-gallery-drag-lock body {
    overflow: hidden !important;
  }
  html.app-phone.is-gallery-drag-lock .s5-gallery-scroll {
    overflow: hidden !important;
    touch-action: none !important;
    overscroll-behavior: none;
  }
  html.app-phone.is-gallery-drag-lock .s5-gallery-card {
    touch-action: none !important;
  }

  #stage-5.s5-gallery-mode .s5-settings-panel,
  body.ai-generate-mode #stage-5 .s5-settings-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--studio-dock) + 8px);
    z-index: 70;
    width: auto !important;
    height: auto !important;
    max-height: min(58dvh, 460px);
    margin: 0;
    padding: 12px 12px 10px;
    border-radius: 22px;
    background: #141414;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
    overflow: auto;
  }
  #stage-5.s5-gallery-mode .s5-history-list,
  body.ai-generate-mode #stage-5 .s5-history-list,
  #stage-5.active .s5-history-list,
  #stage-5.s5-gallery-mode .s5-section-title,
  body.ai-generate-mode #stage-5 .s5-section-title,
  #stage-5.active .s5-section-title {
    display: none !important;
  }
  #stage-5.s5-gallery-mode .s5-settings-panel > .s5-tab-content[style*="display: block"],
  body.ai-generate-mode #stage-5 .s5-settings-panel > .s5-tab-content[style*="display: block"],
  #stage-5.active .s5-settings-panel > .s5-tab-content[style*="display: block"] {
    display: flex !important;
    flex-direction: column;
    order: 1;
    gap: 8px;
  }
  #stage-5.s5-gallery-mode .s5-prompt-container,
  body.ai-generate-mode #stage-5 .s5-prompt-container,
  #stage-5.active .s5-prompt-container { order: 1; margin: 0; }
  #stage-5.s5-gallery-mode .s5-controls-row,
  body.ai-generate-mode #stage-5 .s5-controls-row,
  #stage-5.active .s5-controls-row {
    order: 2;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    overflow: visible;
    position: relative;
    z-index: 8;
  }
  #stage-5.active .s5-control-btn-dropdown,
  #stage-5.active .s5-controls-row .s5-model-selector {
    position: relative;
    z-index: 2;
    overflow: visible;
    pointer-events: auto;
    cursor: pointer;
  }
  #stage-5.active .s5-control-dropdown {
    top: auto !important;
    bottom: calc(100% + 8px);
    z-index: 40;
    max-height: min(220px, 42dvh);
  }
  #stage-5.s5-gallery-mode .s5-controls-row::-webkit-scrollbar,
  body.ai-generate-mode #stage-5 .s5-controls-row::-webkit-scrollbar { display: none; }
  #stage-5.s5-gallery-mode .s5-control-btn,
  body.ai-generate-mode #stage-5 .s5-control-btn,
  #stage-5.active .s5-control-btn,
  #stage-5.s5-gallery-mode .s5-controls-row .s5-model-selector,
  body.ai-generate-mode #stage-5 .s5-controls-row .s5-model-selector,
  #stage-5.active .s5-controls-row .s5-model-selector {
    flex: 1 1 0;
    align-self: center;
    min-width: 0;
    width: auto;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    margin: 0 !important;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    box-sizing: border-box;
  }
  #stage-5.s5-gallery-mode .s5-controls-row .s5-model-selector,
  body.ai-generate-mode #stage-5 .s5-controls-row .s5-model-selector,
  #stage-5.active .s5-controls-row .s5-model-selector { order: -1; }
  #stage-5.s5-gallery-mode .s5-controls-row .s5-model-left,
  body.ai-generate-mode #stage-5 .s5-controls-row .s5-model-left {
    min-width: 0;
  }
  #stage-5.s5-gallery-mode .s5-controls-row [data-smp-label],
  body.ai-generate-mode #stage-5 .s5-controls-row [data-smp-label] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #stage-5.s5-gallery-mode .s5-ref-grid-2,
  #stage-5.s5-gallery-mode .s5-ref-grid-4,
  body.ai-generate-mode #stage-5 .s5-ref-grid-2,
  body.ai-generate-mode #stage-5 .s5-ref-grid-4,
  #stage-5.active .s5-ref-grid-2,
  #stage-5.active .s5-ref-grid-4 {
    order: 0;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #stage-5 .s5-style-picker { order: 0; }
  #stage-5 .s5-ref-box,
  #stage-5 .s5-add-media-bar,
  #stage-5 .s5-ref-thumb {
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
  }
  #stage-5 .s5-ref-tag-label {
    display: block;
  }
  #stage-5.s5-gallery-mode .s5-mobile-more,
  body.ai-generate-mode #stage-5 .s5-mobile-more {
    display: none !important;
  }
  #stage-5.s5-gallery-mode .s5-tabs,
  body.ai-generate-mode #stage-5 .s5-tabs,
  #stage-5.active .s5-tabs {
    display: flex !important;
    order: 2;
    margin: 8px 0 0;
    padding: 0;
    gap: 4px;
  }
  #stage-5.active .s5-tab,
  #stage-5.s5-gallery-mode .s5-tab,
  body.ai-generate-mode #stage-5 .s5-tab {
    height: 34px;
    padding: 0 6px;
    border-radius: 12px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
  }
  #stage-5.active .s5-tab.active,
  #stage-5.s5-gallery-mode .s5-tab.active,
  body.ai-generate-mode #stage-5 .s5-tab.active {
    background: #2a2a2e;
    color: #fff;
  }
  body.ai-generate-mode #stage-5 .s5-tabs {
    display: none !important;
  }
  #stage-5 .s5-settings-panel.is-agent-tab {
    height: min(78dvh, 720px) !important;
    max-height: min(78dvh, 720px) !important;
  }
  #s5-phone-sheet-toggle {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 12;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #d0d0d4;
    display: grid;
    place-items: center;
    box-shadow: none;
  }
  #s5-phone-sheet-toggle svg {
    width: 16px;
    height: 16px;
  }
  body:not(.ai-generate-mode) #stage-5.active.is-phone-collapsed .s5-tabs,
  #stage-5.is-phone-collapsed .s5-ref-grid-2,
  #stage-5.is-phone-collapsed .s5-ref-grid-4,
  #stage-5.is-phone-collapsed .s5-ref-thumb,
  #stage-5.is-phone-collapsed .s5-controls-row,
  #stage-5.is-phone-collapsed .s5-tabs,
  #stage-5.is-phone-collapsed .s5-style-picker,
  #stage-5.is-phone-collapsed .s5-section-title,
  #stage-5.is-phone-collapsed .s5-add-media-bar {
    display: none !important;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container {
    padding: 8px 52px 8px 46px;
    margin: 0 !important;
    min-height: 52px;
    border-radius: 28px;
    background: rgba(18, 18, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.05),
      0 12px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
  }
  #stage-5.is-phone-collapsed #s5-phone-sheet-toggle {
    top: 50%;
    right: auto;
    left: 18px;
    width: 28px;
    height: 28px;
    background: transparent;
    color: #8e8e93;
    transform: translateY(-50%);
  }
  #stage-5.is-phone-collapsed #s5-phone-sheet-toggle svg {
    transform: rotate(180deg);
  }
  #stage-5.is-phone-collapsed .s5-settings-panel:not(.is-agent-tab) #s5-phone-sheet-toggle {
    display: none !important;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container .s5-prompt-tools,
  #stage-5 .s5-prompt-container:not(.is-phone-open) .s5-prompt-tools {
    display: none !important;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container > #s5-generate-btn {
    inset: 0;
    right: 0;
    top: 0;
    width: auto !important;
    height: auto !important;
    transform: none !important;
    pointer-events: none;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container > #s5-generate-btn .s5-generate-credits {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container > #s5-generate-btn .s5-generate-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
  }
  #stage-5.is-phone-collapsed .s5-gallery-pane,
  #stage-5.is-phone-collapsed.s5-gallery-mode .s5-gallery-pane {
    padding-bottom: 96px !important;
  }
  #stage-5 .s5-controls-row > .s5-model-selector .ai-model-logo,
  #stage-5 .s5-controls-row > .s5-model-selector .smp-logo-fallback {
    width: 18px;
    height: 18px;
    border-radius: 6px;
  }
  #stage-5 .s5-prompt-container {
    display: flex;
    flex-direction: column;
    height: auto !important;
    min-height: 56px !important;
    max-height: none !important;
    margin: 0 0 12px !important;
    padding: 12px 112px 12px 14px;
    border-radius: 26px;
    background: rgba(18, 18, 18, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }
  #stage-5 .s5-prompt-container .s5-prompt-highlight-wrap {
    min-height: 24px;
    max-height: 44px;
    margin: 0;
  }
  #stage-5 .s5-prompt-container .s5-prompt-editor {
    min-height: 24px;
    max-height: 44px;
    height: auto;
    padding: 2px 0;
    font-size: 16px !important;
    line-height: 1.6;
  }
  #stage-5 .s5-prompt-container.is-phone-open {
    padding: 8px 12px 48px 14px !important;
    min-height: 168px !important;
  }
  #stage-5 .s5-prompt-container.is-phone-open .s5-prompt-highlight-wrap {
    flex: 1 1 auto;
    align-items: stretch;
    justify-content: flex-start;
    align-self: stretch;
    min-height: 104px;
    max-height: 34dvh;
  }
  #stage-5 .s5-prompt-container.is-phone-open .s5-prompt-editor {
    box-sizing: border-box;
    align-self: stretch;
    height: auto !important;
    min-height: 104px;
    max-height: 34dvh;
    padding: 0 96px 0 0 !important;
  }
  #stage-5 .s5-prompt-footer,
  #stage-5 .s5-prompt-expand-btn { display: none !important; }
  #stage-5 .s5-settings-panel .s5-prompt-tools {
    display: none !important;
    top: 8px;
    right: 8px;
    bottom: auto;
    transform: none;
  }
  #stage-5 .s5-prompt-container.is-phone-open .s5-prompt-tools,
  #stage-5 .s5-prompt-container.is-phone-open .s5-prompt-clear-btn {
    display: inline-flex !important;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container.is-phone-open .s5-prompt-tools,
  #stage-5.is-phone-collapsed .s5-prompt-container.is-phone-open .s5-prompt-clear-btn {
    display: none !important;
  }
  #stage-5 .s5-prompt-container.is-phone-open > #s5-generate-btn {
    top: auto !important;
    bottom: 8px !important;
    right: 8px !important;
    transform: none !important;
  }
  #stage-5 .s5-prompt-container > #s5-generate-btn {
    position: absolute !important;
    top: 50%;
    right: 8px;
    bottom: auto;
    left: auto;
    transform: translateY(-50%) !important;
    z-index: 7;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    background-image: none !important;
    color: inherit !important;
    font-size: inherit !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }
  #stage-5 .s5-prompt-container > #s5-generate-btn .s5-generate-label { display: none !important; }
  #stage-5 .s5-prompt-container > #s5-generate-btn .s5-generate-credits {
    display: inline-flex !important;
    align-items: center;
    padding: 0 !important;
    background: transparent !important;
    color: #f0b429 !important;
    font-size: 13px !important;
    font-weight: 650;
    line-height: 1;
    letter-spacing: 0;
  }
  #stage-5 .s5-prompt-container > #s5-generate-btn .s5-generate-arrow {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f7;
    color: #111;
    flex: 0 0 auto;
  }
  #stage-5 .s5-prompt-container > #s5-generate-btn .s5-generate-arrow svg {
    width: 16px;
    height: 16px;
    display: block;
  }
  #stage-5.is-phone-collapsed .s5-prompt-container > #s5-generate-btn .s5-generate-arrow {
    background: transparent;
    color: #8e8e93;
    border: 1px solid rgba(255, 255, 255, 0.14);
  }
  #stage-5.is-phone-collapsed .s5-prompt-container > #s5-generate-btn.is-ready .s5-generate-arrow {
    background: #f5f5f7;
    color: #111;
    border-color: #f5f5f7;
  }
  #stage-5:not(.active) .s5-settings-panel,
  #stage-5:not(.active) .s5-right-panel,
  #stage-5:not(.active) .s5-mobile-tools {
    display: none !important;
  }
  .s5-mobile-more { display: none !important; }

  /* Stage 5 editor: preview over timeline, panels as sheets */
  #stage-5:not(.s5-gallery-mode) .s5-editor-container {
    order: 1;
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 0;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0;
    height: 100% !important;
    overflow: hidden;
  }
  #stage-5:not(.s5-gallery-mode) .s5-preview-area {
    --s5-preview-ratio: 16 / 9;
    --s5-preview-w: 16;
    --s5-preview-h: 9;
    flex: 0 0 auto !important;
    align-self: center;
    width: min(100%, calc(34dvh * var(--s5-preview-w) / var(--s5-preview-h))) !important;
    height: auto !important;
    aspect-ratio: var(--s5-preview-ratio);
    min-height: 0 !important;
    max-height: 34dvh;
    margin: 0 auto;
    border-radius: 0;
    background: #000;
    overflow: hidden;
  }
  #stage-5:not(.s5-gallery-mode) .s5-timeline-layout {
    flex: 1 1 auto;
    width: 100% !important;
    min-height: 88px;
    height: auto !important;
    max-height: none;
    overflow: hidden;
    border-radius: 0;
    --s5-track-height: 44px;
  }
  #stage-5:not(.s5-gallery-mode) .s5-timeline-tracks-scroll {
    flex: 0 1 auto;
    height: auto;
    min-height: 0;
    max-height: 36dvh;
    overflow-x: hidden;
    overflow-y: auto;
    flex-wrap: wrap;
  }
  #stage-5:not(.s5-gallery-mode) .s5-timeline-inner,
  #stage-5:not(.s5-gallery-mode) .s5-fixed-headers {
    min-height: 0;
    height: auto;
  }
  #stage-5:not(.s5-gallery-mode) .s5-timeline-container {
    min-height: 0;
    height: auto;
  }
  #stage-5:not(.s5-gallery-mode) .s5-fixed-tails {
    order: 3;
    flex: 1 0 100%;
    width: 100%;
    height: auto;
    max-height: none;
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(12, 12, 14, 0.96);
  }
  #stage-5:not(.s5-gallery-mode) .s5-timeline-tools {
    position: static;
    flex-direction: row;
    padding: 4px 8px;
    gap: 6px;
  }
  #stage-5:not(.s5-gallery-mode) .s5-tl-vzoom {
    flex-direction: row;
    margin: 0;
    padding: 4px 8px;
  }
  #stage-5:not(.s5-gallery-mode) .s5-tl-add-menu {
    right: 0;
    top: auto;
    bottom: calc(100% + 6px);
  }
  #stage-5:not(.s5-gallery-mode) .s5-top-gutter-end,
  #stage-5:not(.s5-gallery-mode) .s5-hscroll-gutter-end {
    width: 8px;
  }
  .s5-phone-track-hidden { display: none !important; }
  #stage-5:not(.s5-gallery-mode) .s5-settings-panel,
  #stage-5:not(.s5-gallery-mode) .s5-right-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--studio-dock);
    z-index: 75;
    width: 100% !important;
    height: min(72dvh, 620px) !important;
    max-height: min(72dvh, 620px);
    margin: 0;
    padding: 14px 12px 18px;
    border-radius: 22px 22px 0 0;
    background: #141414;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(110%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: auto;
  }
  #stage-5.s5-gen-open:not(.s5-gallery-mode) .s5-settings-panel,
  #stage-5.s5-clip-open:not(.s5-gallery-mode) .s5-right-panel {
    transform: translateY(0);
  }
  #stage-5:not(.s5-gallery-mode) .s5-right-panel {
    display: flex !important;
  }
  #stage-5:not(.active) .s5-mobile-tools,
  #stage-5.s5-gallery-mode .s5-mobile-tools,
  body.ai-generate-mode #stage-5 .s5-mobile-tools { display: none !important; }
  #stage-5.active:not(.s5-gallery-mode) .s5-mobile-tools {
    display: flex !important;
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 30;
    gap: 8px;
  }
  .s5-mobile-tools button {
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(20, 20, 22, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #fff;
    font-size: 12px;
    font-weight: 650;
    box-shadow: none !important;
    transform: none !important;
  }
  .s5-sheet-backdrop {
    display: none;
  }
  #stage-5.s5-gen-open:not(.s5-gallery-mode) .s5-sheet-backdrop,
  #stage-5.s5-clip-open:not(.s5-gallery-mode) .s5-sheet-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.35);
  }

  /* Agent panel becomes a sheet above the dock */
  body.studio-app.studio-agent-entering:not(.ai-generate-mode) .studio-agent-panel,
  body.studio-app.studio-agent-open.studio-agent-available:not(.ai-generate-mode) .studio-agent-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--studio-dock);
    top: auto;
    width: 100% !important;
    flex-basis: auto !important;
    height: min(78dvh, 680px);
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px 22px 0 0;
    transform: none;
    z-index: 85;
  }
  .studio-agent-toggle {
    right: 8px;
    bottom: calc(var(--studio-dock) + 12px);
    transform: none;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
  }

  /* Concept generator modal */
  .s3-layout-container {
    flex-direction: column;
    padding: 12px;
    overflow: auto;
  }
  .s3-center-area {
    order: 1;
    width: 100%;
    height: auto;
    flex: 0 0 auto;
    min-height: 0;
  }
  #s5-gallery-modal,
  #stage3-modal,
  #s5-gallery-modal .s3-modal-content,
  #stage3-modal .s3-modal-content {
    height: 100dvh;
    max-height: 100dvh;
  }
  #s5-gallery-modal .s3-layout-container,
  #stage3-modal .s3-layout-container {
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }
  #s5-gallery-modal .s3-layout-container {
    overflow-anchor: none;
  }
  #s5-gallery-modal .s3-close,
  #stage3-modal .s3-close {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(20, 20, 22, 0.78);
    color: #fff;
    display: grid;
    place-items: center;
    z-index: 10020;
  }
  #s5-gallery-modal .s3-top-toolbar,
  #stage3-modal .s3-top-toolbar {
    width: calc(100% + 24px);
    margin: 0 -12px;
    padding: 0 48px;
    box-sizing: border-box;
    justify-content: center;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #s5-gallery-modal.is-phone-fs .s3-top-toolbar,
  #s5-gallery-modal.is-phone-fs #s5g-chatBar,
  #s5-gallery-modal.is-phone-fs #s5g-left-panel,
  #s5-gallery-modal.is-phone-fs .s3-right-sidebar,
  #s5-gallery-modal.is-phone-fs .s3-close {
    display: none !important;
  }
  #s5-gallery-modal.is-phone-fs .s3-layout-container {
    padding: 0;
    overflow: hidden;
  }
  #s5-gallery-modal.is-phone-fs #s5g-media-stage {
    position: fixed;
    inset: 0;
    z-index: 10040;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    border-radius: 0;
    background: #000;
    touch-action: none;
  }
  #s5-gallery-modal.is-phone-fs #s5g-media-stage .s5g-stage-image,
  #s5-gallery-modal.is-phone-fs #s5g-media-stage .s5g-stage-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  #s5-gallery-modal .toolbar-btn,
  #stage3-modal .toolbar-btn {
    flex: 0 0 auto;
  }
  #s5g-media-stage,
  .s3-center-area .image-preview-wrapper {
    height: 42dvh;
    min-height: 220px;
  }
  #s5g-chatBar .s5g-chat-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }
  #s5g-chatBar .s5g-chat-head textarea {
    flex: 1 1 auto;
    min-width: 0;
  }
  #s5g-attach-slot {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: flex-end;
    max-width: 46%;
  }
  #s5g-attach-slot:empty {
    display: none;
  }
  #s5g-attach-wrap {
    justify-content: flex-end;
  }
  #s5g-attach-thumbs {
    max-width: 108px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  #s5g-chatBar .chat-controls-row {
    gap: 6px;
    align-items: center;
  }
  #s5g-chatBar .chat-left-controls {
    min-width: 0;
    flex: 1 1 auto;
    gap: 6px;
    overflow: hidden;
  }
  #s5g-chatBar .s5g-param-slots {
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
  }
  #s5g-model-btn {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #s3-right-panel,
  #s5g-left-panel {
    order: 2;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
  }
  .s3-right-sidebar {
    order: 3;
    width: 100%;
    min-width: 0;
    height: 84px;
    min-height: 84px;
    flex: 0 0 auto;
    margin: 0;
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    padding-top: 0;
  }
  #s5-gallery-modal #s5g-thumbnails,
  #s5-gallery-modal #s3-thumbnails,
  #stage3-modal #s5g-thumbnails,
  #stage3-modal #s3-thumbnails {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    height: 76px;
    min-height: 76px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 4px 2px !important;
    touch-action: pan-x;
    scrollbar-width: none;
  }
  #s5-gallery-modal #s5g-thumbnails .thumb-wrapper,
  #s5-gallery-modal #s3-thumbnails .thumb-wrapper,
  #stage3-modal #s5g-thumbnails .thumb-wrapper,
  #stage3-modal #s3-thumbnails .thumb-wrapper {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
  }

  /* Shared overlays */
  .vision-modal-content,
  .pr-modal,
  .s5-audio-modal-content,
  .s5-render-box {
    width: min(100% - 16px, 520px) !important;
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
  .smp-panel {
    width: calc(100vw - 16px);
    max-height: min(72dvh, 520px);
  }

  /* Chat */
  body.chat-page .chat-shell { min-height: 0; }
  body.chat-page .chat-thread,
  body.chat-page .chat-skills-panel { padding-top: calc(52px + env(safe-area-inset-top, 0px)); }
  body.chat-page .chat-composer-wrap {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  body.chat-page .chat-sidebar {
    width: min(100%, 320px);
  }
  .chat-skills-grid { grid-template-columns: 1fr !important; }

  /* Account */
  body.account-page .account-switcher {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }
  body.account-page .account-switcher span {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  body.account-page .account-main,
  body.account-page .account-panel {
    padding-left: 12px;
    padding-right: 12px;
  }
  .password-row { grid-template-columns: 1fr !important; }
  .acc-toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 24px); }

  /* Pricing / checkout */
  body.pricing-page .pricing-hero h1 { font-size: 28px; }
  body.pricing-page .pricing-shell { width: min(100% - 20px, 1180px); }
  .compare-wrap { overflow-x: auto; }
  .compare-table { min-width: 640px; }
  .billing-bar, .cat-filters { flex-wrap: wrap; }
  .checkout-grid { grid-template-columns: 1fr !important; }

  /* App stack: content, then chat/generate box, then the black menu. */
  body.studio-app .chat-container.show,
  body.studio-app #chatBar.chat-container,
  body.studio-app #s2-chatBar.chat-container,
  body.studio-app.studio-agent-open.studio-agent-available:not(.ai-generate-mode) #chatBar.chat-container,
  body.studio-app.studio-agent-open.studio-agent-available:not(.ai-generate-mode) #s2-chatBar.chat-container,
  body.studio-app.studio-agent-entering:not(.ai-generate-mode) #chatBar.chat-container,
  body.studio-app.studio-agent-entering:not(.ai-generate-mode) #s2-chatBar.chat-container {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: var(--studio-dock) !important;
    top: auto !important;
    width: auto !important;
    z-index: 75;
    margin: 0;
    padding: 8px 10px;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    background: #101012;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px 16px 0 0;
  }
  #stage-1:not(.active) #chatBar,
  #stage-2:not(.active) #s2-chatBar {
    display: none !important;
  }
  #stage-1.active,
  #stage-2.active,
  #stage-3.active,
  #stage-4.active {
    padding-bottom: calc(var(--app-composer) + 8px);
  }
  #stage-5.active .s5-settings-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(var(--studio-dock) + var(--keyboard-inset, 0px)) !important;
    top: auto !important;
    width: auto !important;
    height: auto !important;
    max-height: 42dvh !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 75;
    padding: 10px 12px 12px;
    border-radius: 18px 18px 0 0 !important;
    background: #141414 !important;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  }
  #stage-5.active .s5-settings-panel.is-phone-prompt-open {
    max-height: min(72dvh, 640px) !important;
  }
  #stage-5.active .s5-settings-panel.is-agent-tab {
    display: flex !important;
    flex-direction: column;
    height: min(78dvh, 720px) !important;
    max-height: min(78dvh, 720px) !important;
    overflow: hidden;
  }
  #stage-5.active .s5-settings-panel.is-agent-tab > .s5-agent-host {
    flex: 1 1 auto;
    min-height: 0;
  }
  #stage-5.active .s5-editor-container,
  #stage-5.active .s5-preview-area,
  #stage-5.active .s5-timeline-layout,
  #stage-5.active .s5-gallery-pane {
    width: 100% !important;
  }
  #stage-5.active .s5-workspace {
    padding-bottom: 0;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-workspace {
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    padding-bottom: var(--s5-sheet-h, 72px);
  }
  #stage-5.active .s5-gallery-pane,
  #stage-5.s5-gallery-mode .s5-gallery-pane {
    padding-bottom: 230px !important;
  }
  #stage-5.active:not(.s5-gallery-mode) {
    --s5-transport: 58px;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-editor-container {
    height: 100% !important;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-stage-nav {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    z-index: 4;
    width: 100% !important;
    flex: 0 0 auto;
    margin: 0 !important;
    padding: 4px 6px;
    min-height: var(--s5-transport);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #101012;
    border-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-bottom-center-tools {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    gap: 4px;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-zoom-controls {
    min-width: 0;
    width: auto;
    flex: 1 1 auto;
    justify-content: space-between;
    gap: 2px;
    padding: 0 2px;
    overflow: hidden;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-toolbar-left,
  #stage-5.active:not(.s5-gallery-mode) .s5-toolbar-right {
    flex: 0 1 auto;
    padding: 0;
    gap: 0;
    min-width: 0;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-zoom-label,
  #stage-5.active:not(.s5-gallery-mode) .s5-volume-wrapper,
  #stage-5.active:not(.s5-gallery-mode) #s5-btn-prev,
  #stage-5.active:not(.s5-gallery-mode) #s5-import-s4-btn {
    display: none !important;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-timeline-play-btn {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    margin: 0 2px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-timeline-play-btn:hover,
  #stage-5.active:not(.s5-gallery-mode) .s5-timeline-play-btn:focus,
  #stage-5.active:not(.s5-gallery-mode) .s5-timeline-play-btn:active {
    transform: none !important;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-zoom-btn,
  #stage-5.active:not(.s5-gallery-mode) .s5-tool-btn {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
  }
  #stage-5.active:not(.s5-gallery-mode) #s5-export-btn {
    padding: 6px 4px;
    letter-spacing: 0.08em;
    font-size: 10px;
  }
  #stage-5.active.is-phone-collapsed .s5-settings-panel {
    padding: 0 12px 8px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  #stage-5.active.is-phone-collapsed .s5-settings-panel.is-agent-tab {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    padding: 0 12px 8px !important;
    overflow: visible !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  #stage-5.active.is-phone-collapsed .s5-settings-panel.is-agent-tab > .s5-agent-host {
    display: flex !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  #stage-5.active.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-panel.is-docked {
    height: auto !important;
    min-height: 0 !important;
    flex: 0 0 auto !important;
    overflow: visible !important;
  }
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-header,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-thread,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-error,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-gen-blank,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-autospend,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-surface-row,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-plus,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-mode-wrap,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-gen-refs,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab #s5-phone-sheet-toggle {
    display: none !important;
  }
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-composer {
    padding: 0;
  }
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-form {
    min-height: 52px;
    padding: 8px 8px 8px 16px;
    border-radius: 28px;
    background: rgba(18, 18, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.05),
      0 12px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
  }
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab textarea.studio-agent-input {
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 4px 0 !important;
    font-size: 16px !important;
    line-height: 28px !important;
  }
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-form-actions {
    display: flex !important;
  }
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-send {
    width: 36px;
    height: 36px;
    opacity: 1;
  }
  #stage-5 .studio-agent-form.is-phone-open,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-form.is-phone-open {
    display: flex;
    flex-direction: column;
    min-height: 168px;
    padding: 10px 12px 12px 14px;
    border-radius: 22px;
  }
  #stage-5 .studio-agent-form.is-phone-open .studio-agent-form-row,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-form.is-phone-open .studio-agent-form-row {
    align-items: flex-end;
    flex: 1 1 auto;
    min-height: 140px;
  }
  #stage-5 .studio-agent-form.is-phone-open textarea.studio-agent-input,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-form.is-phone-open textarea.studio-agent-input {
    align-self: stretch;
    min-height: 120px !important;
    max-height: 34dvh !important;
    padding: 0 8px 0 0 !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    overflow-y: auto !important;
  }
  #stage-5 .studio-agent-form.is-phone-open .studio-agent-form-actions,
  #stage-5.is-phone-collapsed .s5-settings-panel.is-agent-tab .studio-agent-form.is-phone-open .studio-agent-form-actions {
    align-self: flex-end;
    margin-bottom: 2px;
  }
  #stage-5.active.is-phone-collapsed .s5-gallery-pane,
  #stage-5.active.is-phone-collapsed.s5-gallery-mode .s5-gallery-pane {
    padding-bottom: 96px !important;
  }
  .s5-settings-panel.is-agent-tab .studio-agent-header {
    padding-right: 44px;
  }
  .studio-agent-panel.is-docked .studio-agent-collapse {
    display: none !important;
  }
  #stage-5.active:not(.s5-gallery-mode) .s5-mobile-tools {
    bottom: auto;
    top: 8px;
    right: 8px;
  }
  #stage-5 .s5-mobile-tools button[data-sheet="gen"] { display: none; }

  body.chat-page .chat-composer-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--studio-dock) + var(--keyboard-inset, 0px));
    z-index: 40;
    padding: 8px 12px 10px;
    background: #0a0a0c;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  body.chat-page .chat-thread,
  body.chat-page .chat-skills-panel {
    padding-bottom: calc(var(--studio-dock) + 96px);
  }
  body.chat-page.chat-phone-shell {
    --phone-chat-composer: 92px;
  }
  body.chat-page.chat-phone-shell .chat-sidebar-toggle,
  body.chat-page.chat-phone-shell .chat-phone-history,
  body.chat-page.chat-phone-shell .chat-phone-backdrop {
    display: none !important;
  }
  body.chat-page.chat-phone-shell .chat-sidebar {
    display: flex !important;
    position: fixed;
    top: var(--phone-header, 52px);
    bottom: 0;
    left: 0;
    z-index: 90;
    width: min(280px, 86vw);
    background: #080808;
    transform: translateX(-105%);
  }
  body.chat-page.chat-phone-shell.chat-sidebar-open .chat-sidebar {
    transform: none;
  }
  body.chat-page header#mainHeader {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
  }
  body.chat-page header .logo {
    display: none !important;
  }
  body.chat-page header .profile-wrapper {
    margin-left: auto;
  }
  body.chat-page.chat-phone-shell #mainHeader .chat-phone-menu {
    position: static;
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent !important;
    color: #fff;
    box-shadow: none !important;
    backdrop-filter: none;
    transform: none !important;
    pointer-events: auto;
  }
  body.chat-page.chat-phone-shell .chat-phone-menu[hidden] {
    display: none !important;
  }
  body.chat-page.chat-phone-shell #mainHeader .chat-phone-menu svg {
    display: block;
    width: 16px;
    height: 16px;
    stroke: #fff;
    fill: none;
    opacity: 1;
  }
  body.chat-page .chat-phone-recents {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin: 4px 0 22px;
    text-align: start;
  }
  body.chat-page .chat-phone-recents[hidden] {
    display: none !important;
  }
  body.chat-page .chat-phone-recents-label {
    margin: 0 2px 2px;
    color: #8e8e93;
    font: 650 12px/1 var(--font-main, system-ui);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  body.chat-page .chat-phone-recents-list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  body.chat-page .chat-empty {
    max-width: 560px;
    margin: 8px auto 0;
    padding: 0 4px;
    text-align: start;
  }
  body.chat-page .chat-empty h1,
  body.chat-page .chat-empty p {
    text-align: start;
  }
  body.chat-page.chat-phone-shell .chat-phone-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1102;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  body.chat-page.chat-phone-shell.chat-phone-history-open .chat-phone-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.chat-page.chat-phone-shell .chat-phone-history {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--phone-header, 56px);
    left: 0;
    bottom: var(--studio-dock);
    z-index: 1104;
    width: min(84vw, 320px);
    padding: 16px 14px 18px;
    background: #101012;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 18px 0 48px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
  }
  body.chat-page.chat-phone-shell.chat-phone-history-open .chat-phone-history {
    transform: none;
  }
  body.chat-page.chat-phone-shell .chat-phone-history[hidden] {
    display: none !important;
  }
  body.chat-page.chat-phone-shell .chat-phone-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    margin-bottom: 14px;
  }
  body.chat-page.chat-phone-shell .chat-phone-history-head .chat-history-label {
    margin: 0;
    padding: 0;
    letter-spacing: 0.12em;
  }
  body.chat-page.chat-phone-shell .chat-phone-new-btn {
    flex-shrink: 0;
    height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: #f5f5f7;
    color: #111;
    font: 650 12px/1 var(--font-main, system-ui);
  }
  body.chat-page.chat-phone-shell .chat-phone-history-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }
  body.chat-page.chat-phone-shell .chat-phone-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045) !important;
    color: #f5f5f7;
    text-align: start;
    font: 560 15px/1.35 var(--font-main, system-ui);
    box-shadow: none !important;
    backdrop-filter: none;
    transform: none !important;
  }
  body.chat-page.chat-phone-shell .chat-phone-item span {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: start;
  }
  body.chat-page.chat-phone-shell .chat-phone-item.active,
  body.chat-page.chat-phone-shell .chat-phone-item:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
    transform: none !important;
    box-shadow: none !important;
  }
  body.chat-page.chat-phone-shell .chat-thread,
  body.chat-page.chat-phone-shell .chat-skills-panel {
    padding-bottom: calc(var(--studio-dock) + var(--phone-chat-composer, 92px) + 12px + var(--keyboard-inset, 0px));
  }
  body.account-page .account-main,
  body.pricing-page .main-container {
    padding-bottom: var(--studio-dock);
  }

  .app-phone-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    height: var(--studio-dock);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    padding: 4px 4px env(safe-area-inset-bottom, 0px);
    background: rgba(8, 8, 8, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .app-phone-dock a,
  .app-phone-dock button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px 4px;
    border: 0;
    border-radius: 12px;
    background: transparent !important;
    color: #86868b;
    text-decoration: none;
    font: 700 9px/1.1 var(--font-main, system-ui);
    box-shadow: none !important;
    transform: none !important;
  }
  .app-phone-dock svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }
  .app-phone-dock .is-on { color: #fff; background: rgba(255, 255, 255, 0.1) !important; }

  textarea,
  .main-textarea,
  .s5-prompt-container textarea,
  .s5-prompt-editor,
  .s3-chat-input-box {
    font-size: 16px !important;
  }
}

html.app-phone body.studio-app #s2-chatBar.chat-container.show,
html.app-phone body.studio-app.studio-agent-open.studio-agent-available:not(.ai-generate-mode) #s2-chatBar.chat-container.show,
html.app-phone body.studio-app.studio-agent-entering:not(.ai-generate-mode) #s2-chatBar.chat-container.show,
html.app-phone body.studio-app #chatBar.chat-container.show {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: var(--studio-dock) !important;
  top: auto !important;
  width: auto !important;
  transform: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  z-index: 75;
}
html.app-phone #chatBar:not(.show),
html.app-phone #stage-1:has(.s1-home-workspace) #chatBar {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
html.app-phone body.app-library-open .projects-sidebar.open {
  position: fixed !important;
  transform: none !important;
  top: var(--phone-header) !important;
  bottom: auto !important;
  height: calc(50dvh - var(--phone-header)) !important;
  padding-top: 12px !important;
  z-index: 96 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  box-sizing: border-box;
}
html.app-phone body.app-library-open .chats-sidebar.open {
  position: fixed !important;
  transform: none !important;
  top: 50dvh !important;
  bottom: var(--studio-dock) !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  z-index: 97 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
html.app-phone body.chat-page,
html.app-phone body.chat-page .app-wrapper,
html.app-phone body.account-page,
html.app-phone body.account-page .app-wrapper {
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
}
html.app-phone body.pricing-page {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html.app-phone body[data-auth-standalone="1"] .app-wrapper {
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}
html.app-phone body.app-library-open #appLibraryBackdrop { display: block !important; }
html.app-phone #appMenuBtn { display: grid !important; }
html.app-phone #appLibraryTabs { display: none !important; }

html.app-phone:has(#stage-1.active .s1-home-workspace),
html.app-phone:has(#stage-1.active .s1-home-workspace) body {
  overflow: hidden !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
}
html.app-phone #stage-1.active:has(.s1-home-workspace) {
  overflow: hidden !important;
  padding: 0 !important;
  height: 100% !important;
}
html.app-phone #stage1-flow:has(.s1-home-workspace) {
  max-width: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  justify-content: flex-start;
}
html.app-phone .s1-home-workspace {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

/* Phone-only style popover. Anchored above the Style button by s5-style-picker.js. */
html.app-phone #s5-style-picker.is-phone-pop:not([hidden]) {
  top: auto;
  right: auto;
  left: var(--s5-style-pop-left, 12px);
  bottom: var(--s5-style-pop-bottom, 140px);
  width: var(--s5-style-pop-width, 240px);
  height: auto;
  padding: 8px 8px 7px;
  gap: 6px;
  border-radius: 18px;
  z-index: 120;
  overflow: visible;
  background: rgba(18, 18, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
html.app-phone #s5-style-picker.is-phone-pop:not([hidden])::after {
  content: "";
  position: absolute;
  left: var(--s5-style-pop-arrow, 24px);
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: rgba(18, 18, 20, 0.96);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  transform: rotate(45deg);
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-search-wrap svg {
  left: 9px;
  width: 13px;
  height: 13px;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-search {
  height: 32px;
  padding: 0 10px 0 28px;
  border-radius: 10px;
  font-size: 12px;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tabs {
  gap: 4px;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tabs button,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tabs button:hover,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tabs button:active {
  height: 26px;
  border-radius: 8px;
  font-size: 11px;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px 5px;
  padding: 1px 1px 2px;
  min-height: 0;
  max-height: min(168px, calc(var(--s5-style-pop-max, 280px) - 108px));
  overflow-y: auto;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tile,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tile:hover,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tile:focus,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-tile:active {
  gap: 3px;
  padding: 0;
  border-radius: 8px;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-cover {
  border-radius: 9px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-fallback {
  font-size: 15px;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-name {
  font-size: 9px;
  line-height: 1.15;
}
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-drop,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-drop:hover,
html.app-phone #s5-style-picker.is-phone-pop .s5-style-picker-drop:active {
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 11px;
}

/* Movie Maker phone: idea, story, concept, timeline only. */
html.app-phone body.studio-app #ideas-container {
  top: calc(var(--phone-header, 96px) + 6px) !important;
  right: 0 !important;
  bottom: calc(var(--studio-dock) + var(--mm-composer, 168px) + 8px) !important;
  left: 0 !important;
  width: auto !important;
  padding: 8px 12px 24px;
  box-sizing: border-box;
  scroll-padding-bottom: 24px;
  overscroll-behavior: contain;
}

html.app-phone #chatBar .bottom-toolbar {
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  overflow: visible;
}
html.app-phone #chatBar .toolbar-left,
html.app-phone #chatBar .toolbar-right {
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 6px !important;
  min-width: 0;
  width: auto;
}
html.app-phone #chatBar .toolbar-right { justify-content: flex-end; }
html.app-phone #chatBar .setting-pill,
html.app-phone #chatBar .view-toggle-btn,
html.app-phone #chatBar .smp-trigger {
  flex: 0 0 auto;
}
html.app-phone #chatBar .smp-trigger { max-width: 128px; }
html.app-phone #chatBar .smp-trigger-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.app-phone #menu-lang.show,
html.app-phone #menu-genre.show {
  position: fixed !important;
  left: 12px !important;
  right: 12px !important;
  width: auto !important;
  min-width: 0 !important;
  bottom: calc(var(--studio-dock) + var(--mm-composer, 168px) + 8px) !important;
  top: auto !important;
  transform: none !important;
  max-height: min(52dvh, calc(100dvh - var(--studio-dock) - var(--mm-composer, 168px) - var(--phone-header, 96px) - 28px));
  z-index: 220;
  animation: none !important;
  overflow: hidden;
  box-sizing: border-box;
}
html.app-phone #menu-lang.show {
  display: flex !important;
  flex-direction: column;
  padding: 10px;
}
html.app-phone #menu-lang .search-box-wrapper { flex: 0 0 auto; }
html.app-phone #menu-lang .lang-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}
html.app-phone #menu-genre.show {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

html.app-phone #s2-quill-toolbar.ql-toolbar.ql-snow {
  display: flex !important;
  flex-flow: row wrap;
  align-items: center;
  gap: 4px 2px;
  overflow: visible;
  padding: 6px 8px !important;
}
html.app-phone #s2-quill-toolbar .ql-formats {
  display: inline-flex !important;
  align-items: center;
  float: none !important;
  flex: 0 0 auto;
  margin-right: 8px !important;
}
html.app-phone #s2-quill-toolbar .ql-formats::after {
  display: none !important;
  content: none !important;
}
html.app-phone #s2-quill-toolbar button,
html.app-phone #s2-quill-toolbar .ql-picker {
  float: none !important;
}
html.app-phone #s2-quill-toolbar .ql-toolbar button,
html.app-phone #s2-quill-toolbar.ql-toolbar button {
  width: 30px;
  height: 30px;
  padding: 4px;
}
html.app-phone #s2-quill-toolbar .ql-snow .ql-picker.ql-font,
html.app-phone #s2-quill-toolbar.ql-snow .ql-picker.ql-font { width: 92px; }
html.app-phone #s2-quill-toolbar .ql-snow .ql-picker.ql-size,
html.app-phone #s2-quill-toolbar.ql-snow .ql-picker.ql-size { width: 54px; }
html.app-phone #stage-2 .s2-phone-align {
  position: relative;
  display: inline-flex;
  align-items: center;
}
html.app-phone #stage-2 .s2-phone-align-btn {
  width: 30px;
  height: 30px;
  padding: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
html.app-phone #stage-2 .s2-phone-align-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
}
html.app-phone #stage-2 .s2-phone-align-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  z-index: 40;
}
html.app-phone #stage-2 .s2-phone-align-menu[hidden] { display: none !important; }
html.app-phone #stage-2 .s2-phone-align-menu button { float: none !important; }

html.app-phone #stage-3 .style-header {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
  width: 100%;
  z-index: 8;
}
html.app-phone #stage-3 .s3-header-actions {
  position: static !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  width: 100%;
  order: 1;
  justify-content: flex-start;
  flex-wrap: wrap;
  overflow: visible;
  gap: 8px;
}
html.app-phone #stage-3 #s3-image-gen-wrap {
  position: static !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  order: 2;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
html.app-phone #stage-3 #s3-image-model-btn {
  min-width: 0;
  flex: 1 1 auto;
}
html.app-phone #stage-3 #s3-image-model-label,
html.app-phone #stage-3 #s3-generate-images-btn {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html.app-phone #stage-3 #s3-image-model-label { max-width: 38vw; }
html.app-phone #stage-3 .style-section-wrapper {
  max-width: none;
  padding: 6px 0 10px;
  justify-content: flex-start;
  box-sizing: border-box;
  overflow: auto;
}
html.app-phone #stage-3 .style-content,
html.app-phone #stage-3 .s3-style-dock { width: 100%; min-width: 0; }
html.app-phone #stage-3 .s3-style-dock,
html.app-phone #stage-3 .s3-style-dock.is-two-rows {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 10px;
}
html.app-phone #stage-3 .s3-style-rail {
  max-width: calc(100% - 72px);
  width: auto;
  flex: 1 1 auto;
}
html.app-phone #stage-3 .s3-style-add {
  align-self: flex-end;
  margin: 0 0 8px;
}
html.app-phone #stage-3 .s3-extract-bar {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 12px;
  overflow: hidden;
}
html.app-phone #stage-3 .s3-extract-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
  gap: 8px;
  max-width: 100%;
}
html.app-phone #stage-3 .s3-extract-settings,
html.app-phone #stage-3 .s3-extract-types,
html.app-phone #stage-3 .s3-field,
html.app-phone #stage-3 .vision-checkbox-row {
  min-width: 0;
  max-width: 100%;
}
html.app-phone #stage-3 .s3-field {
  gap: 6px;
  padding: 6px 8px;
}
html.app-phone #stage-3 .s3-field > span {
  min-width: 0;
  flex: 1 1 auto;
}
html.app-phone #stage-3 .vision-select {
  min-width: 0;
  width: auto;
  flex: 0 1 74px;
  max-width: 46%;
  padding: 6px 4px;
}

html.app-phone #stage-5.active:not(.s5-gallery-mode) .s5-preview-area {
  max-height: 18dvh;
}
html.app-phone #stage-5.active:not(.s5-gallery-mode) .s5-settings-panel:not(.is-phone-prompt-open):not(.is-agent-tab) {
  max-height: 26dvh !important;
}
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-timeline-layout {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-timeline-tracks-scroll {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow-x: clip;
  overflow-y: auto;
  flex-wrap: wrap;
  align-content: flex-start;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-timeline-container {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  touch-action: pan-x pan-y;
}
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-clip,
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-audio-block,
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-trim-handle,
html.app-phone #stage-5:not(.s5-gallery-mode) .s5-audio-trim-handle {
  touch-action: none;
}
html.app-phone.is-tl-clip-drag,
html.app-phone.is-tl-clip-drag body {
  overflow: hidden !important;
  overscroll-behavior: none;
}
html.app-phone.is-tl-clip-drag #stage-5 .s5-timeline-container,
html.app-phone.is-tl-clip-drag #stage-5 .s5-timeline-tracks-scroll {
  touch-action: none;
}
