/* Responsive workspace overrides. Loaded last so desktop styles stay intact. */
.mobile-action-label, .mobile-save-status, .mobile-table-hint { display: none; }
.schedule-complete { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
@media (min-width: 801px) and (max-width: 1100px) and (min-height: 501px) {
  .sidebar { width: 76px; padding: 24px 10px 16px; }
  .sidebar .brand { padding: 0 8px 26px; }
  .sidebar .brand-mark { flex: none; }
  .sidebar .brand-text-wrap,
  .sidebar .workspace-switch,
  .sidebar .nav-label,
  .sidebar .nav-space,
  .sidebar .nav-item > span,
  .sidebar .project-link,
  .sidebar .tip-card,
  .sidebar .profile { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 0; min-height: 44px; }
  .main-shell { margin-left: 76px; width: calc(100% - 76px); }
  .project-heading { flex-wrap: wrap; }
  .heading-actions { flex-wrap: wrap; }
  .heading-actions .btn { min-height: 44px; font-size: 12px; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .script-column { display: none; }
  .script-full { grid-template-columns: minmax(0, 1fr); }
  .script-aside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .shot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { gap: 12px; }
  .breadcrumb { min-width: 0; }
  .breadcrumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { flex-shrink: 0; gap: 8px; }
  .saved-status { display: none; }
  #toast { left: calc(50% + 38px); }
}

@media (max-width: 800px), (min-width: 600px) and (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  :root {
    --mobile-nav-height: 70px;
    --mobile-bottom-space: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    --mobile-gutter: 18px;
  }

  html { -webkit-text-size-adjust: 100%; scroll-padding-top: 86px; scroll-padding-bottom: calc(var(--mobile-bottom-space) + 18px); }
  body { font-size: 14px; }
  .app-shell { min-height: 100vh; min-height: 100dvh; display: block; }
  .main-shell { width: 100%; margin-left: 0; }
  .page {
    width: 100%; max-width: 800px;
    padding: 18px max(var(--mobile-gutter), env(safe-area-inset-right, 0px)) calc(var(--mobile-bottom-space) + 28px) max(var(--mobile-gutter), env(safe-area-inset-left, 0px));
    overflow-wrap: anywhere;
  }

  /* The existing five workspace destinations become a labeled bottom bar. */
  .sidebar {
    inset: auto 0 0; width: 100%; height: var(--mobile-bottom-space);
    padding: 6px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
    border: 0; border-top: 1px solid #dfe5d8; background: #fbfcf8f5;
    box-shadow: 0 -4px 20px #273d2e08; z-index: 60;
  }
  .sidebar > :not(nav) { display: none; }
  .sidebar > nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; width: 100%; height: 100%; }
  .sidebar .nav-item {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 100%; min-width: 0; height: 100%; min-height: 54px; margin: 0; padding: 5px 1px;
    border-radius: 8px; text-align: center; font-size: 11px; line-height: 1.3;
  }
  .sidebar .nav-item > .icon { width: 21px; height: 21px; }
  .sidebar .nav-item > span { display: block; white-space: nowrap; letter-spacing: 0; }
  .sidebar .nav-item .count,
  .sidebar .nav-item[data-action="ai-settings"] { display: none; }
  .sidebar .director-nav-status { top: 4px; right: calc(50% - 18px); width: 8px; height: 8px; }
  .sidebar .nav-item.active { color: #2c5647; background: #e7eee1; }

  .topbar {
    position: sticky; top: 0; z-index: 40; background: #fbfcf9;
    min-height: 62px; height: auto; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) max(var(--mobile-gutter), env(safe-area-inset-right, 0px)) 8px max(var(--mobile-gutter), env(safe-area-inset-left, 0px));
  }
  .breadcrumb { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; font-size: 14px; gap: 5px; }
  .breadcrumb > .icon,
  .breadcrumb > span:first-of-type { display: none; }
  .breadcrumb strong { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: #385447; }
  .breadcrumb .mobile-save-status { display: flex; gap: 4px; font-size: 11px; color: #69785e; }
  .mobile-save-status .icon { width: 12px; height: 12px; }
  .breadcrumb > .icon { flex-shrink: 0; }
  .topbar-right { flex-shrink: 0; gap: 6px; }
  .topbar-right .saved-status { display: none; }
  .small-icon,
  .topbar-right .avatar,
  .ai-config-button { min-width: 44px; width: 44px; min-height: 44px; height: 44px; padding: 0; }
  .ai-config-button { justify-content: center; }
  .ai-config-button .icon { width: 19px; height: 19px; }
  .ai-config-button .ai-status-label { display: none; }
  .topbar-right .avatar { font-size: 14px; }
  .topbar:has(.director-background-link:not([hidden])) { flex-wrap: wrap; justify-content: space-between; }
  .topbar:has(.director-background-link:not([hidden])) .breadcrumb { display: flex; flex-basis: 100%; min-height: 22px; }
  .topbar:has(.director-background-link:not([hidden])) .topbar-right { width: 100%; }
  .director-background-link { min-width: 0; min-height: 44px; margin-right: auto; font-size: 12px; white-space: normal; text-align: left; }
  .director-background-link span { max-width: none; overflow-wrap: anywhere; }

  .project-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page > .project-heading .eyebrow { display: none; }
  .project-heading > div { min-width: 0; max-width: 100%; }
  .eyebrow { font-size: 9px; letter-spacing: 1.3px; line-height: 1.7; margin-bottom: 9px; }
  h1 { font-size: 25px; line-height: 1.45; overflow-wrap: anywhere; }
  .project-meta { flex-wrap: wrap; gap: 8px; font-size: 12px; line-height: 1.7; margin-top: 7px; color: #6b795f; }
  .pill { font-size: 11px; }
  .heading-actions { width: 100%; display: flex; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .btn,
  .btn.small,
  .heading-actions .btn,
  .heading-actions .btn.outline,
  .projects-heading .heading-actions .btn.outline {
    min-height: 44px; padding: 10px 13px; gap: 7px; font-size: 14px; line-height: 1.5;
    white-space: normal; overflow-wrap: anywhere;
  }
  .btn .icon { width: 17px; height: 17px; }
  .btn:hover, .shot-card:hover, .project-card:hover { transform: none; }
  .heading-actions .btn { flex: 1 1 auto; }
  .heading-actions .btn.primary { flex-grow: 2; }
  .page:not(.projects-page) .heading-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page:not(.projects-page) .heading-actions > .btn { min-width: 0; padding: 10px 8px; gap: 5px; font-size: 13px; }
  .page:not(.projects-page) .heading-actions > .btn.primary:last-child { grid-column: auto; }
  .page:not(.projects-page) .heading-actions > [data-action="pdf"] { font-size: 12px; gap: 4px; padding-inline: 5px; }
  .desktop-action-label { display: none; }
  .mobile-action-label { display: inline; }
  .workflow {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch;
    gap: 4px; height: auto; min-height: 56px; margin-top: 14px; overflow: visible;
  }
  .workflow-arrow, .workflow-note { display: none; }
  .workflow-step { justify-content: center; min-width: 0; min-height: 56px; padding: 8px 0 10px; gap: 5px; font-size: 12px; white-space: normal; line-height: 1.5; color: #728168; }
  .step-number { flex-shrink: 0; width: 19px; height: 19px; font-size: 9px; }

  .workspace-toolbar { flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 14px; }
  .toolbar-left, .toolbar-right { min-width: 0; flex-wrap: wrap; gap: 8px; }
  .toolbar-title { min-width: 0; flex-wrap: wrap; font-size: 16px; line-height: 1.6; gap: 8px; }
  .stat-count { font-size: 11px; }
  .toolbar-divider { display: none; }
  .toolbar-left > .muted { display: none; }
  .toolbar-right { margin-left: auto; }
  .tool-button { min-width: 44px; min-height: 44px; justify-content: center; font-size: 13px; padding: 8px; }
  .tool-button .icon { width: 18px; height: 18px; }
  .filter-select { min-width: 0; width: auto; max-width: 160px; min-height: 44px; padding: 8px; border: 1px solid #dfe5d7; border-radius: 6px; background: #fafcf7; }
  .view-switch { padding: 3px; }
  .view-switch button { min-width: 42px; min-height: 38px; padding: 7px; font-size: 13px; }
  .view-switch button span { display: inline; }
  .view-switch .icon { width: 17px; height: 17px; }
  .search-field { display: block; width: 100%; min-width: 0; min-height: 44px; margin-bottom: 16px; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .script-column { display: none; }
  .shots-area, #shot-collection { min-width: 0; }
  .shot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .shot-image-button { aspect-ratio: 16 / 9; }
  .shot-number, .shot-duration { font-size: 12px; }
  .image-caption { font-size: 9px; letter-spacing: .6px; }
  .shot-body { padding: 14px 16px 0; }
  .shot-title { gap: 8px; font-size: 16px; line-height: 1.6; margin-bottom: 8px; }
  .shot-title button { min-width: 0; min-height: 44px; white-space: normal; overflow-wrap: anywhere; text-overflow: clip; }
  .shot-tags { gap: 6px; }
  .tag { font-size: 11px; padding: 5px 7px; overflow-wrap: anywhere; }
  .shot-description { font-size: 14px; line-height: 1.85; min-height: 52px; margin: 12px 0; color: #66775d; }
  .shot-footer { min-height: 56px; padding: 5px 0; font-size: 12px; color: #78866d; }
  .shot-footer > span { min-width: 0; }
  .shot-more { min-width: 44px; min-height: 44px; justify-content: center; align-items: center; flex-shrink: 0; }
  .shot-more .icon { width: 20px; height: 20px; }
  .add-shot { min-height: 48px; font-size: 14px; }
  .workbench-footer { align-items: flex-start; font-size: 12px; line-height: 1.8; }
  .footer-tips { align-items: flex-start; }
  .footer-tips > .icon { flex: none; margin-top: 4px; }
  .footer-tips:last-child { display: none; }
  .film-footer { font-size: 9px; line-height: 1.7; letter-spacing: .8px; }
  .shot-table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .mobile-table-hint { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 12px; line-height: 1.8; color: #64785a; }
  .mobile-table-hint .icon { flex: none; width: 15px; height: 15px; }
  .shot-table { min-width: 700px; font-size: 14px; }
  .shot-table th { font-size: 12px; }
  .shot-table .micro { font-size: 12px; }
  .shot-table td { max-width: 280px; overflow-wrap: anywhere; }

  /* Editing stays in the page flow; the script tab has its own full editor. */
  .script-full { grid-template-columns: minmax(0, 1fr); gap: 18px; margin-top: 22px; }
  .editor-sheet, .script-aside, .aside-card { min-width: 0; }
  .editor-sheet .panel-heading { padding: 14px 16px; }
  .panel-heading strong { font-size: 14px; }
  .panel-heading .file-badge { font-size: 10px; }
  .script-filename { padding: 15px 16px 8px; font-size: 12px; overflow-wrap: anywhere; }
  .editor-sheet .script-textarea { height: 55vh; height: 55dvh; min-height: 300px; padding: 15px 18px 22px; line-height: 1.95; color: #53664b; }
  .script-editor-meta { gap: 12px; flex-wrap: wrap; padding: 13px 16px; font-size: 11px; line-height: 1.7; }
  .script-aside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .aside-card { padding: 18px; margin: 0; }
  .aside-card h3 { font-size: 15px; }
  .aside-card p { font-size: 14px; line-height: 1.9; }
  .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .field, .field-row > *, form { min-width: 0; }
  .field > span { font-size: 14px; line-height: 1.6; }
  .field input, .field select, .field textarea { min-height: 46px; padding: 10px 12px; }
  .field textarea { min-height: 100px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { min-width: 0; max-width: 100%; font-size: 16px !important; }
  .help-text { font-size: 12px !important; line-height: 1.85 !important; color: #7d8b70 !important; }
  .micro { font-size: 12px; }

  .projects-heading { margin-bottom: 26px; }
  .projects-intro { font-size: 14px; }
  .projects-toolbar { margin-top: 0; }
  .project-card-body { padding: 17px 16px; }
  .project-card-body h3 { font-size: 17px; line-height: 1.6; white-space: normal; overflow-wrap: anywhere; }
  .project-card-meta { flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }
  .project-card-body p { height: auto; min-height: 50px; font-size: 14px; line-height: 1.85; }
  .project-card-footer { margin: 0 16px; padding: 10px 0; }
  .project-card-date, .project-card-progress, .project-card-director { font-size: 12px; line-height: 1.6; }
  .project-delete { min-width: 64px; min-height: 44px; justify-content: center; font-size: 13px; }
  .project-cover-tags > span, .project-cover-ratio { font-size: 11px; }
  .projects-backup-note { justify-content: flex-start; font-size: 12px; }
  .projects-empty { min-height: 320px; padding: 30px 18px; }
  .projects-empty h2 { font-size: 20px; }
  .projects-empty p { font-size: 14px; }
  .projects-empty > div:last-child { flex-wrap: wrap; justify-content: center; }
  .project-delete-summary span, .project-delete-warning { font-size: 14px; }
  .project-delete-summary > div { min-width: 0; }
  .project-backup-link { min-height: 44px; font-size: 14px; text-align: left; }
  .legacy-projects-banner { flex-wrap: wrap; }
  .legacy-projects-banner > div { flex-basis: 100%; }
  .legacy-projects-banner strong { font-size: 14px; }
  .legacy-projects-banner p { font-size: 13px; }
  .legacy-projects-banner > .btn { flex: 1 1 auto; font-size: 13px; min-height: 44px; }
  .storage-warning { font-size: 13px; line-height: 1.85; overflow-wrap: anywhere; }
  .storage-warning button { min-height: 44px; padding: 6px; font-size: inherit; }

  /* Camera preparation keeps its information below the title on narrow screens. */
  .stats-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .stat-card { min-width: 0; padding: 15px 12px; }
  .stat-card > span { font-size: 12px; }
  .stat-card strong { font-size: 25px; }
  .stat-card strong small { font-size: 12px; }
  .schedule-heading { gap: 10px; padding: 15px; flex-wrap: wrap; font-size: 14px; }
  .schedule-heading strong { min-width: 0; overflow-wrap: anywhere; }
  .schedule-heading strong > .icon { flex: none; }
  .schedule-row { grid-template-columns: 44px 24px minmax(0, 1fr) auto; gap: 8px; padding: 12px; font-size: 14px; }
  .schedule-row > * { min-width: 0; }
  .schedule-row input { width: 24px; height: 24px; margin: 0; }
  .schedule-complete { width: 44px; min-height: 44px; border-radius: 7px; }
  .schedule-complete:active { background: #e8eee2; }
  .schedule-row > button { min-height: 44px; overflow-wrap: anywhere; }
  .schedule-row small { font-size: 12px; line-height: 1.8; }
  .schedule-params { display: block; grid-column: 3 / -1; font-size: 12px; line-height: 1.7; }
  .schedule-params small { display: inline; margin: 0 0 0 10px; }
  .schedule-equipment { display: block; grid-column: 3 / -1; font-size: 12px; line-height: 1.7; }
  .schedule-row > .tag { grid-column: 4; grid-row: 1; max-width: 76px; }
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .material-card { min-width: 0; }
  .material-card h3 { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
  .material-card p, .materials-note { font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
  .material-preview { aspect-ratio: 16 / 9; }

  /* AI text is readable without zoom; review diffs are stacked on phones. */
  .director-workspace { margin-top: 24px; }
  .director-intro { flex-wrap: wrap; gap: 14px; }
  .director-intro-title { min-width: 0; gap: 12px; }
  .director-intro-title > div { min-width: 0; }
  .director-symbol { flex: none; }
  .director-intro h2 { font-size: 24px; }
  .director-intro p { font-size: 14px; line-height: 1.8; }
  .director-intro > .btn { max-width: none; font-size: 13px; padding: 10px 12px; }
  .director-kicker { font-size: 9px; line-height: 1.7; letter-spacing: 1.1px; }
  .director-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .director-steps li { gap: 7px; padding: 13px 10px; min-width: 0; }
  .director-steps li > span { font-size: 11px; }
  .director-steps strong { font-size: 13px; line-height: 1.7; }
  .director-steps small { display: none; }
  .director-columns { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .director-brief { position: static; min-width: 0; padding: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .director-section-heading { flex-wrap: wrap; gap: 9px; }
  .director-section-heading h3 { font-size: 17px; }
  .director-section-heading > span { max-width: 100%; font-size: 12px; }
  .director-workspace .director-brief-note,
  .director-workspace .director-send-note,
  .director-workspace .director-proposal-footer > p,
  .director-workspace .director-composer-footer p { font-size: 13px; line-height: 1.9; }
  .director-workspace .director-field > span,
  .director-workspace .director-scope label { font-size: 14px; }
  .director-workspace .director-field textarea { padding: 12px; min-height: 112px; }
  .director-workspace .director-context,
  .director-workspace .director-context strong { font-size: 12px; }
  .director-context { margin-bottom: 16px; }
  .director-workspace .btn,
  .director-workspace .director-start { min-height: 44px; font-size: 14px !important; }
  .director-directions, .director-proposal, .director-conversation { padding: 18px; }
  .director-direction-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .director-direction { padding: 17px; }
  .director-direction-top { font-size: 11px; }
  .director-direction h4 { font-size: 17px; }
  .director-workspace .director-direction p,
  .director-workspace .director-direction dd,
  .director-workspace .director-message p,
  .director-workspace .director-proposal-rationale { font-size: 14px; line-height: 1.95; }
  .director-workspace .director-direction dt,
  .director-workspace .director-direction summary,
  .director-workspace .director-direction-footer > span,
  .director-workspace .director-selected-note,
  .director-workspace .director-conversation-empty p { font-size: 13px; line-height: 1.85; }
  .director-direction summary { min-height: 44px; padding: 10px 0; }
  .director-direction .btn { align-self: stretch; width: 100%; }
  .director-direction-footer { flex-wrap: wrap; align-items: stretch; gap: 12px; }
  .director-direction-footer > span { flex: 1 1 100%; }
  .director-direction-footer .btn { flex: 1; align-self: stretch; }
  .director-messages { max-height: 60vh; max-height: 60dvh; min-height: 200px; }
  .director-message { gap: 9px; padding: 18px 0; }
  .director-message-avatar { width: 28px; height: 28px; }
  .director-message-author { font-size: 12px; }
  .director-message.user p { padding: 12px; }
  .director-selected-note { overflow-wrap: anywhere; }
  .director-composer { padding: 12px; }
  .director-scope { flex-wrap: wrap; gap: 8px; }
  .director-scope select { flex: 1; min-width: 0; max-width: 100%; min-height: 44px; }
  .director-composer textarea { min-height: 118px; }
  .director-workspace .director-suggestions button { min-height: 44px; font-size: 12px; padding: 8px 10px; }
  .director-composer-footer { flex-wrap: wrap; gap: 12px; }
  .director-composer-footer p { flex: 1 1 100%; }
  .director-composer-footer .btn { width: 100%; }
  .director-conversation-empty { padding: 30px 0; }
  .director-conversation-empty h4 { font-size: 16px; line-height: 1.8; }
  .director-conversation-empty > div { flex-wrap: wrap; }
  .director-conversation-empty > div > span { font-size: 12px; }
  .director-text-button { min-height: 44px; font-size: 13px; }
  .director-thinking, .director-thinking small { font-size: 13px; line-height: 1.8; }
  .director-thinking small { margin-left: 0; }
  .director-workspace .director-alert,
  .director-workspace .director-alert > span { font-size: 13px; }
  .director-alert > strong, .director-alert button { font-size: 14px; }
  .director-alert button { min-height: 44px; margin-left: 0; padding: 7px; }
  .director-change-counts { gap: 7px; }
  .director-change-counts > span, .director-change-type { font-size: 11px; }
  .director-diff > summary { min-height: 48px; padding: 12px; font-size: 13px; }
  .director-workspace .director-diff-table-head,
  .director-workspace .director-diff-row { grid-template-columns: 70px minmax(0, 1fr) minmax(0, 1fr); font-size: 13px; }
  .director-diff-row > strong, .director-diff-row > div { padding: 10px; }
  .director-order-change, .director-unchanged { font-size: 13px; line-height: 1.85; }
  .director-proposal-footer > div > .btn { flex: 1 1 auto; }

  /* Fixed headers and action rows remain reachable while dialog contents scroll. */
  .overlay {
    top: var(--mobile-viewport-top, 0px); bottom: auto;
    height: var(--mobile-viewport-height, 100dvh);
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    align-items: center;
  }
  .modal, .modal.wide {
    display: flex; flex-direction: column; width: min(650px, 100%); min-width: 0;
    max-height: calc(100vh - 24px); max-height: calc(var(--mobile-viewport-height, 100dvh) - max(12px, env(safe-area-inset-top, 0px)) - max(12px, env(safe-area-inset-bottom, 0px)));
    overflow: hidden; border-radius: 12px;
  }
  .modal-header { flex-shrink: 0; padding: 12px 16px; }
  .modal-header > div { min-width: 0; }
  .modal-header h2 { font-size: 18px; line-height: 1.6; overflow-wrap: anywhere; }
  .modal-header > .small-icon { flex-shrink: 0; }
  .modal-body { flex: 1 1 auto; min-height: 0; padding: 18px 16px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .modal-body > p { font-size: 14px; }
  .modal-actions { flex-shrink: 0; flex-wrap: wrap; gap: 8px; padding: 12px 16px; background: #fff; }
  .modal-actions > .btn { flex: 1 1 auto; }
  .drawer-overlay { padding: 0; }
  .drawer {
    width: min(600px, 100%); min-width: 0; height: 100%; max-height: 100%;
    padding-top: env(safe-area-inset-top, 0px); padding-right: env(safe-area-inset-right, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px);
  }
  .drawer .modal-body { flex: 1 1 auto; }
  .drawer .modal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-toolbar { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 44px); justify-content: start; margin-right: 0; gap: 4px; }
  .drawer-toolbar:empty { display: none; }
  .drawer-toolbar button { width: 44px; height: 44px; padding: 0; }
  .drawer-top-info { font-size: 12px; line-height: 1.7; }
  .reference-actions { gap: 8px; }
  .reference-actions > .btn { flex: 1 1 auto; }
  .reference-actions .help-text { flex-basis: 100%; }
  .form-section h3 { font-size: 14px; letter-spacing: .5px; }
  .export-option { min-width: 0; min-height: 80px; gap: 12px; padding: 15px 12px; }
  .export-option > span { flex: 1; min-width: 0; }
  .export-option strong { font-size: 15px; line-height: 1.65; }
  .export-option small { display: block; font-size: 12px; line-height: 1.8; }
  .export-option > .icon { flex: none; }
  .drop-area { padding: 26px 16px; }
  .drop-area h3 { font-size: 16px; }
  .drop-area p, .guide-step p, .notice { font-size: 13px; line-height: 1.9; }
  .guide-step strong { font-size: 15px; }
  .guide-step > span { flex: none; }
  .notice progress, .modal-body progress { max-width: 100%; }

  .ai-image-panel { padding: 15px; }
  .ai-panel-heading { flex-wrap: wrap; }
  .ai-panel-heading strong { font-size: 16px; }
  .ai-link { min-height: 44px; font-size: 13px; }
  .ai-image-panel .field > span { font-size: 14px; }
  .ai-image-panel .field textarea { min-height: 100px; }
  .reference-toggle label { min-height: 44px; font-size: 14px; line-height: 1.8; }
  .reference-toggle input { flex: none; width: 22px; height: 22px; }
  .reference-toggle .micro { font-size: 12px; line-height: 1.8; margin-left: 29px; }
  .prompt-details summary { min-height: 44px; padding: 9px 0; font-size: 13px; line-height: 1.8; }
  .prompt-details textarea { min-height: 240px; }
  .ai-generate-actions > .btn { flex: 1 1 100%; }
  .ai-billing-note, .ai-generation-state, .ai-stale-notice { font-size: 12px; line-height: 1.9; }
  .provider-card { align-items: flex-start; gap: 11px; }
  .provider-card > div:last-child { min-width: 0; }
  .provider-card strong { font-size: 16px; line-height: 1.7; }
  .provider-card p { font-size: 13px; line-height: 1.8; }
  .api-endpoint span, .api-endpoint code, .ai-doc-links, .ai-error-message { font-size: 13px; }
  .ai-doc-links { gap: 10px 16px; }
  .ai-doc-links a { display: inline-flex; align-items: center; min-height: 44px; line-height: 1.8; }

  /* Registration is a single column, including the email verification row. */
  .account-page { min-height: 100vh; min-height: 100dvh; padding: max(18px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(18px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .account-layout { display: block; width: 100%; max-width: 520px; min-height: 0; border-radius: 14px; }
  .account-intro { padding: 24px; border-right: 0; border-bottom: 1px solid #e1e7d8; }
  .account-intro-body { padding: 20px 0 0; margin: 0; }
  .account-intro h2 { font-size: 20px; line-height: 1.6; margin: 0; }
  .account-intro h2 br { display: none; }
  .account-eyebrow, .account-intro-body > p, .account-frames, .account-intro-footer { display: none; }
  .account-panel { padding: 28px 24px; }
  .account-tabs { gap: 26px; margin-bottom: 24px; }
  .account-tabs button { min-height: 44px; font-size: 15px; padding: 0 3px 12px; }
  .account-panel h1 { font-size: 23px; }
  .account-form-heading p { font-size: 13px; }
  .account-field > span, .account-field > label { flex-wrap: wrap; font-size: 14px; line-height: 1.6; }
  .account-field small { font-size: 12px; }
  .account-field input { height: 48px; }
  .account-field input::placeholder { font-size: 14px; }
  .account-code-row { min-width: 0; gap: 8px; }
  .account-send-code { min-width: 112px; min-height: 48px; padding: 0 10px; font-size: 13px; }
  .account-code-message, .account-error, .account-message { font-size: 13px; }
  .account-submit { min-height: 48px; font-size: 15px; }
  .account-switch { font-size: 13px; }
  .account-switch button { min-height: 44px; font-size: 13px; }
  .account-local-note { font-size: 11px; line-height: 1.9; margin-top: 22px; }
  .account-profile-detail p { font-size: 13px; }
  .account-service-error > p { font-size: 14px; }
  .account-reconnect-logout { min-height: 44px; font-size: 13px; }
  #toast { bottom: calc(var(--mobile-bottom-space) + 14px); left: 50%; width: max-content; max-width: calc(100% - 32px); font-size: 13px; line-height: 1.8; padding: 12px 16px; overflow-wrap: anywhere; }
  input, textarea, select { scroll-margin-block: 90px; }
  html[data-mobile-keyboard] .sidebar { visibility: hidden; pointer-events: none; }
  html[data-mobile-keyboard] .page { padding-bottom: 24px; }
  html[data-mobile-keyboard] .drawer-toolbar { display: none; }
  html[data-mobile-keyboard] .modal-actions { padding-bottom: 12px; }
  html[data-mobile-keyboard] #toast { bottom: 16px; }
}

@media (max-width: 600px) {
  :root { --mobile-gutter: 16px; }
  .topbar-right > [data-action="guide"] { display: none; }
  .heading-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .heading-actions > .btn.primary:last-child:not(:nth-child(2)) { grid-column: 1 / -1; }
  .workflow-step { gap: 4px; font-size: 12px; }
  .workspace-toolbar .toolbar-left { flex-basis: 100%; }
  .toolbar-right { width: 100%; justify-content: flex-end; }
  .toolbar-right > .tool-button { margin-right: auto; }
  .view-switch button span { display: none; }
  .shot-grid, .project-grid, .material-grid { grid-template-columns: minmax(0, 1fr); }
  .script-aside, .director-brief { display: block; }
  .aside-card + .aside-card { margin-top: 16px; }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .director-intro-title { align-items: flex-start; }
  .director-steps li { flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px; }
  .director-section-heading > span { flex-shrink: 1; }
  .director-diff-count { display: none; }
  .director-diff-table-head { display: none; }
  .director-workspace .director-diff-row { display: block; font-size: 14px; }
  .director-diff-row > strong { display: block; padding: 11px 12px; }
  .director-diff-before, .director-diff-after { padding: 12px !important; border-left: 0; }
  .director-diff-before::before, .director-diff-after::before { display: block; margin-bottom: 5px; font-size: 11px; font-weight: 600; }
  .director-diff-before::before { content: "修改前"; color: #8d8b7a; }
  .director-diff-after::before { content: "修改后"; color: #587449; }
  .drawer { border-radius: 0; }
}

@media (max-width: 359px) {
  :root { --mobile-gutter: 12px; }
  .sidebar .nav-item { font-size: 10px; }
  h1 { font-size: 24px; }
  .workflow-step { flex-direction: column; gap: 4px; padding-bottom: 9px; }
  .workflow { min-height: 68px; }
  .schedule-row { grid-template-columns: 44px 20px minmax(0, 1fr) auto; gap: 5px; padding: 10px 8px; }
  .schedule-row > .tag { max-width: 59px; font-size: 10px; padding: 5px; }
  .director-directions, .director-proposal, .director-conversation { padding: 15px 12px; }
  .director-message-avatar { width: 23px; height: 25px; font-size: 10px; }
  .director-message { gap: 7px; }
  .account-page { padding-right: 12px; padding-left: 12px; }
  .account-panel { padding: 24px 18px; }
  .account-intro { padding: 22px 18px; }
  .account-send-code { min-width: 108px; padding: 0 7px; font-size: 12px; }
}

@media (min-width: 600px) and (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  :root { --mobile-nav-height: 58px; }
  .sidebar { padding-top: 3px; padding-bottom: calc(3px + env(safe-area-inset-bottom, 0px)); }
  .sidebar .nav-item { min-height: 46px; flex-direction: row; gap: 6px; }
  .sidebar .nav-item > .icon { width: 18px; height: 18px; }
  .page { padding-top: 18px; }
  .topbar { min-height: 54px; padding-top: calc(4px + env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
  .modal-header { padding-top: 6px; padding-bottom: 6px; }
  .modal-actions { padding-top: 8px; padding-bottom: 8px; }
  .drawer .modal-actions { display: flex; gap: 6px; }
  .drawer-toolbar { display: flex; gap: 0; margin-right: auto; }
  .drawer .modal-actions > .btn { flex: 0 1 auto; padding: 8px 12px; }
  .drawer-top-info { display: none; }
  .drawer-preview { max-height: 180px; }
  .director-messages { max-height: 240px; }
  .account-page { padding-top: 12px; padding-bottom: 12px; }
}
