/* Phone layouts keep the document fixed while individual galleries and the canvas move. */
.ss-segment-actions { display: contents; }
@media (max-width: 760px) {
  html { width: 100%; overflow-x: hidden; overflow-x: clip; }
  body { width: 100%; max-width: 100%; overflow-x: hidden; overflow-x: clip; }
  main, main > *, section, .card, .composer, .ss-segment, .screenplay-workspace { min-width: 0; max-width: 100%; }
  button, summary, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
  button, summary { touch-action: manipulation; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]), select, textarea { font-size: 16px !important; }
  .mobile-disclosure { display: block; flex: 1 1 100%; min-width: 0; max-width: 100%; margin: 8px 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
  .mobile-disclosure > summary { display: grid; grid-template-columns: minmax(0, 1fr) 16px; align-items: center; gap: 2px 8px; min-height: 44px; padding: 10px 12px; font-size: 13px; line-height: 20px; color: var(--ink); cursor: pointer; list-style: none; }
  .mobile-disclosure > summary > span { grid-column: 1; grid-row: 1; }
  .mobile-disclosure > summary::-webkit-details-marker { display: none; }
  .mobile-disclosure > summary::after { content: '⌄'; grid-column: 2; grid-row: 1 / span 2; justify-self: end; color: var(--muted); }
  .mobile-disclosure[open] > summary::after { content: '⌃'; }
  .mobile-disclosure-note { grid-column: 1; grid-row: 2; min-width: 0; max-width: 100%; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; line-height: 16px; color: var(--muted); }
  .mobile-disclosure[open] > summary { border-bottom: 1px solid var(--line); }
  .mobile-disclosure:not([open]) > :not(summary) { display: none !important; }
  .mobile-disclosure > :not(summary) { max-width: 100%; margin: 0; padding: 12px; border: 0; border-radius: 0; }
  .mobile-disclosure > .model-picker { padding: 12px; }
  .mobile-disclosure > .planning-image-options, .mobile-disclosure > .planning-effort-control, .mobile-disclosure > .shot-image-settings { display: flex; flex-wrap: wrap; gap: 10px; }
  .mobile-disclosure > .ss-segment-actions, .mobile-disclosure > .screenplay-actions, .mobile-disclosure > .asset-actions, .mobile-disclosure > .ss-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .mobile-disclosure button { min-height: 40px; white-space: normal; overflow-wrap: anywhere; }
  .mobile-plan-options > summary { min-height: 44px; font-size: 12px; }
  .ss-segment-heading h3 { flex-basis: 100%; min-width: 0; }
  .ss-segment-heading > .mobile-disclosure { margin: 4px 0 0; }
  .shot-image-strip, .ss-segment-images, .revision-reference-list, .shot-nav-marks, .curated-section.curated-showcase .library-grid { overflow-y: hidden; overscroll-behavior-x: contain; max-width: 100%; }
  .shot-image-strip > .asset-tile { flex-basis: min(300px, 100%); }
  .ss-material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-tabs { display: flex; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; padding-bottom: 5px; }
  .view-tabs > button { flex: 0 0 auto; min-height: 40px; white-space: nowrap; }
  .vp-heading { align-items: center; }
  .vp-heading .vp-preview-badge { display: none; }
  .video-production .vp-back { min-height: 40px; white-space: nowrap; }
  .vp-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .video-production .vp-controls > label, .video-production .vp-controls select { width: 100%; min-width: 0; max-width: 100%; }
  .video-production .vp-controls select { min-height: 42px; height: 42px; }
  .vp-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; margin-bottom: 10px; }
  .vp-steps > button { justify-content: center; gap: 4px; padding: 6px 2px; min-height: 40px; font-size: 11px; }
  .vp-canvas-commands { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; align-items: start; }
  .vp-canvas-commands > .mobile-disclosure { width: 100%; min-width: 0; margin: 0; background: var(--paper); }
  .vp-canvas-commands > .mobile-disclosure[open] { grid-column: 1 / -1; }
  .vp-canvas-commands .mobile-disclosure > summary { min-height: 40px; padding: 8px; font-size: 12px; }
  .vp-canvas-commands .vp-production-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 9px; }
  .vp-canvas-commands .vp-production-actions > button { width: 100%; min-height: 40px; padding: 6px 3px; font-size: 12px; }
  .vp-canvas-commands .vp-canvas-search { display: flex; flex-wrap: wrap; width: 100%; max-width: 100%; padding: 9px; }
  .vp-canvas-commands .vp-canvas-search input { flex-basis: 100%; width: 100%; min-height: 42px; }
  .vp-canvas-toolbar .vp-canvas-tools { gap: 3px; }
  .video-production .vp-canvas-tools > button { min-height: 36px; height: 36px; padding: 4px 6px; }
  .vp-more-tools { display: block; min-width: 0; flex: 1 1 auto; margin: 0; padding: 0; border: 0; }
  .vp-more-tools > summary { display: block; min-height: 36px; padding: 7px 6px; font-size: 12px; cursor: pointer; list-style: none; }
  .vp-more-tools > summary::-webkit-details-marker { display: none; }
  .vp-more-tools[open] { flex-basis: 100%; }
  .vp-more-tools:not([open]) > .vp-advanced-tools { display: none; }
  .vp-advanced-tools { display: flex; flex-wrap: wrap; gap: 5px; padding: 7px 0 0; }
  .vp-canvas-toolbar { max-height: calc(100% - 64px); overflow-y: auto; overscroll-behavior: contain; }
  .vp-canvas-help-body { position: static; max-width: 100%; width: auto; }
  .library-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .library-filters > *, .library-filters select { min-width: 0; max-width: 100%; width: 100%; }
  .library-filters > input { grid-column: 1 / -1; }
  .library-batch { display: flex; flex-wrap: wrap; gap: 8px; }
  .is-admin-view .admin { grid-template-columns: minmax(0, 1fr); }
  .is-admin-view .admin-navigation { display: flex; flex-direction: row; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 8px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .is-admin-view .admin-content { min-width: 0; padding: 0; }
  .is-admin-view .admin-navigation button { min-height: 40px; white-space: nowrap; }
}

/* Secondary actions use their label width instead of filling the row. */
:is(.actions,.asset-actions,.library-actions,.project-tools,.header-actions,.screenplay-actions,.ss-card-actions,.vp-node-actions) > button { flex: 0 0 auto; width: auto; justify-self: start; }
.video-production .vp-controls > button { flex: 0 0 auto; width: auto; justify-self: start; }
@media (max-width: 760px) {
  .mobile-disclosure { flex: 0 1 auto; width: fit-content; max-width: 100%; }
  .mobile-disclosure[open] { width: 100%; flex-basis: 100%; }
  .mobile-disclosure > summary { min-height: 40px; padding: 8px 10px; }
  .mobile-disclosure button { flex: 0 0 auto; width: auto; }
  .vp-canvas-toolbar { max-width: calc(100% - 14px); gap: 5px 8px; overflow: visible; }
  .vp-canvas-commands { display: flex; flex-wrap: wrap; gap: 5px; }
  .vp-canvas-commands > .mobile-disclosure { width: fit-content; flex: 0 0 auto; }
  .vp-canvas-commands > .mobile-disclosure[open] { width: 100%; flex-basis: 100%; }
  .vp-canvas-commands .vp-production-actions { display: flex; flex-wrap: wrap; padding: 8px; gap: 6px; }
  .vp-canvas-commands .vp-production-actions > button { width: auto; min-height: 38px; padding: 5px 8px; }
  .vp-more-tools, .vp-more-tools[open] { flex: 0 0 auto; width: max-content; }
  .vp-more-tools > summary { min-height: 36px; padding: 7px 6px; }
  .vp-more-tools > .vp-advanced-tools { display: flex; padding: 10px; }
  .vp-more-tools:not([open]) > .vp-advanced-tools { display: none; }
}
