/* Mobile tasks share one reserved control area; the photo remains unobstructed. */
.mobile-only { display: none; }
.mask-tools > div[data-mobile-options], .mask-refinement-body > div[data-mobile-options] { display: contents; }
@media (max-width: 900px) {
  :root { --toolbar-height: calc(52px + env(safe-area-inset-top)); --mobile-photo-bar-height: calc(56px + env(safe-area-inset-bottom)); --filmstrip-height: 128px; }
  .mobile-only { display: block; }
  .desktop-only { display: none; }
  .toolbar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .toolbar-ai, .brand { display: none; }
  .toolbar-history-actions { border: 0; background: none; padding: 0; }
  .stage-view-actions { display: none !important; }
  .stage { min-height: 0; }
  .mobile-photo-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-inline: 8px; }
  .mobile-photo-bar > button { width: 100%; min-width: 0; height: 44px; padding: 4px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface-raised); justify-content: center; font-size: 13px; }
  .mobile-filmstrip-toggle { display: flex; gap: 5px; }
  .mobile-current-thumb, .mobile-current-copy, .mobile-filmstrip-toggle > svg, .mobile-edit-toggle > svg { display: none; }
  .mobile-filmstrip-toggle::before { content: attr(data-label); }
  .mobile-filmstrip-toggle output { font-size: 12px; }
  .mobile-filmstrip-toggle[aria-expanded="true"] { background: var(--color-accent-soft); }
  .filmstrip-shell { gap: 4px; }
  .editor-column.is-filmstrip-open .filmstrip-shell { padding: 4px 8px; }
  .filmstrip-shell > .photo-management { display: none; }
  .mobile-filmstrip-header { display: flex; align-items: center; justify-content: space-between; height: 44px; font-size: 13px; }
  .mobile-filmstrip-header > span { color: var(--color-text-muted); }
  .mobile-filmstrip-header button { min-height: 44px; padding-inline: 8px; }
  .filmstrip-shell { grid-template-rows: 44px minmax(0, 1fr); }
  .filmstrip-shell .filmstrip-item { flex-basis: 72px; height: 68px; padding: 2px; grid-template-rows: minmax(0, 1fr); }
  .filmstrip-shell .filmstrip-caption, .filmstrip-shell .photo-rating, .filmstrip-shell .reference-marker { display: none; }
  .filmstrip-shell .filmstrip-add { flex-basis: 68px; min-height: 0; padding: 4px; gap: 0; }
  .filmstrip-shell .filmstrip-add span { display: none; }
  .filmstrip-shell .filmstrip-thumb { border-radius: 5px; }
  .inspector, .inspector[data-mobile-tool="crop"], .inspector[data-mobile-tool="retouch"], .inspector[data-mobile-tool="mask"] { height: calc(204px + env(safe-area-inset-bottom)); max-height: 48dvh; padding-bottom: env(safe-area-inset-bottom); }
  .inspector-header { min-height: 48px; height: 48px; padding: 0 8px; gap: 4px; position: static; font-size: 13px; }
  #inspector-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #inspector-back { flex: none; width: 44px; min-width: 44px; padding: 0; font-size: 28px; }
  .inspector-close { min-width: 48px; width: auto; padding: 4px; font-size: 13px; border: 0; background: none; color: var(--color-accent-hover); }
  #mobile-tool-options { flex: none; width: 44px; min-width: 44px; height: 44px; border: 0; background: none; font-size: 24px; }
  .toolbar #mobile-before-after { position: static; flex: none; width: 84px; min-width: 84px; padding: 4px; font-size: 12px; background: var(--color-surface-raised); }
  .toolbar #mobile-before-after[aria-pressed="true"] { background: var(--color-accent); color: white; }
  .toolbar { gap: 4px; }
  .toolbar-history-actions { gap: 0; }
  .mobile-photo-bar > button[aria-expanded="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); }
  .inspector[data-mobile-tool="chooser"] #mobile-tool-options { display: none; }
  .mobile-tool-tabs, body[data-mobile-focus] .mobile-tool-tabs { display: none; }
  .inspector[data-mobile-tool="chooser"] .mobile-tool-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; min-height: 0; overflow: auto; padding: 6px 8px; border: 0; background: none; }
  .mobile-tool-tabs button { min-width: 0; padding: 5px; min-height: 44px; white-space: normal; overflow-wrap: anywhere; background: rgba(255,255,255,.035); }
  .inspector .tool-section { margin: 0; }
  .inspector .controls, .inspector .tool-body { padding: 6px 12px 8px; }
  .inspector .tool-section [data-mobile-options] { display: none; }
  .inspector .controls { display: flex; flex-direction: column; }
  .inspector .control-row { order: 1; }
  .mobile-adjustment-tabs { order: 2; flex: none; margin: 4px -4px 0; padding: 0 4px; min-height: 44px; }
  .mobile-adjustment-tabs button { border: 0; border-radius: 0; }
  .mobile-adjustment-tabs button[aria-selected="true"] { border-bottom: 2px solid var(--color-accent); background: none; }
  .control-row .control-label { font-size: 13px; }
  .auto-tool-body { gap: 6px; }
  .auto-tool-body .tool-group { padding: 0; border: 0; }
  .auto-tool-body h3, .auto-tool-body #auto-confidence { display: none; }
  .auto-tool-body .auto-buttons { display: flex; }
  .auto-tool-body [data-auto-scope="all"] { width: 100%; min-height: 44px; }
  .auto-tool-body .field-label { margin: 2px 0 0; font-size: 12px; }
  .auto-meta { min-height: 0; margin: 0; }
  .auto-meta:has(#auto-status:empty) { display: none; }
  .inspector[data-mobile-tool="crop"] .tool-section[open] { overflow: auto; }
  .inspector[data-mobile-tool="crop"] .crop-settings { position: static; overflow: visible; padding: 6px 12px; }
  .inspector[data-mobile-tool="crop"] .crop-confirmation { position: static; padding: 0 12px 6px; }
  .crop-settings > .field-label { display: none; }
  body[data-mobile-focus="crop"] .stage { display: block; }
  body[data-mobile-focus="crop"] .crop-overlay { bottom: 0; }
  .inspector [data-section="retouch"] .tool-body > .field-label { display: none; }
  #retouch-size-fields { display: flex; align-items: center; gap: 12px; margin-top: 4px; min-height: 44px; }
  #retouch-size-fields .field-label { flex: none; margin: 0; font-size: 12px; }
  #retouch-size { flex: 1; min-width: 0; }
  #retouch-hint { margin: 4px 0 0; min-height: 44px; font-size: 12px; line-height: 1.4; }
  .tool-body:has(#retouch-delete:not([hidden])) #retouch-hint,
  .tool-body:has(#retouch-apply:not([hidden])) #retouch-hint,
  .tool-body:has(#retouch-apply:not([hidden])) #retouch-delete { display: none; }
  #retouch-delete { min-height: 44px; margin-top: 4px; }
  #retouch-apply { margin-top: 2px; }
  .mask-tools { display: grid; gap: 4px; }
  .inspector .selected-mask-name { display: none; }
  .inspector[data-mobile-tool="mask"]:has(.has-selected-mask) { height: calc(272px + env(safe-area-inset-bottom)); max-height: 52dvh; }
  .mobile-mask-actions { display: flex; gap: 8px; }
  .mobile-mask-actions .button { flex: 1; min-width: 0; min-height: 44px; padding-block: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-mask-actions [aria-pressed="true"] { background: var(--color-accent-soft); }
  .mobile-mask-actions > .icon-button { flex: none; width: 44px; height: 44px; }
  .mobile-mask-modes { display: flex; gap: 4px; }
  .mobile-mask-modes .button { flex: 1; min-height: 44px; }
  .mobile-mask-modes [aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); }
  .mask-tools.has-selected-mask .mobile-mask-empty,
  .mask-tools:not(.has-selected-mask) :is(.mobile-mask-modes, .mobile-mask-parameter, .mask-local-controls, #mask-refinement, #mobile-mask-overlay, #mobile-mask-settings) { display: none; }
  .mobile-mask-empty { margin: 8px 0; line-height: 1.5; }
  #mobile-task-body .mask-select-copy small { display: none; }
  #mobile-task-body .mask-select { min-height: 48px; }
  #mobile-task-body .mask-row-actions { flex-wrap: wrap; }
  .mask-tools > .tool-subheading, #mask-refinement > summary { display: none; }
  #mask-refinement { border: 0; margin: 0; }
  .mask-refinement-body { padding: 0; gap: 2px; }
  .mask-refinement-body > .field-label { display: none; }
  .mask-tools:has(#mask-refinement[open]) > .mobile-mask-parameter,
  .mask-tools:has(#mask-refinement[open]) > .mask-local-controls { display: none; }
  .mobile-mask-parameter select { width: 100%; min-height: 44px; height: 44px; padding-block: 2px; }
  .inspector .mask-local-controls { padding: 0; }
  .mask-local-controls > .control-row { display: none; }
  .mask-local-controls > .control-row.is-mobile-active { display: grid; grid-template-columns: minmax(0, 1fr) 64px; min-height: 44px; }
  .mask-local-controls .control-label { display: none; }
  .inspector .mask-local-controls > .control-row input[type="range"] { grid-column: 1; grid-row: 1; }
  .mask-local-controls > .control-row .control-value { grid-column: 2; grid-row: 1; }
  .mask-local-controls:has(input:disabled), .mobile-mask-parameter:has(select:disabled) { opacity: .5; }
  .inspector [data-section="presets"] h3 { display: none; }
  .inspector [data-section="presets"] .preset-tool-group { padding: 0; border: 0; }
  .inspector [data-section="presets"] .tool-body { display: grid; gap: 8px; }
  .mobile-task-dialog { width: 100%; max-width: none; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; }
  .mobile-task-dialog form { min-height: 100%; }
  .mobile-task-dialog .dialog-header { padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; }
  #mobile-task-body { display: grid; gap: 16px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  #mobile-task-body .tool-group { padding: 0; border: 0; }
  #mobile-task-body > div[data-mobile-options] { display: grid; gap: 12px; }
  #mobile-task-body .mask-list { max-height: none; }
  #mobile-task-body .mask-row-action { width: 44px; height: 44px; }
  #mobile-task-body #filmstrip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); height: auto; overflow: visible; }
  #mobile-task-body .filmstrip-item { width: 100%; height: 160px; grid-template-rows: minmax(0, 1fr) 44px; }
  #mobile-task-body .filmstrip-add { min-height: 160px; }
  #mobile-task-body .filmstrip-caption { display: grid; }
  #mobile-task-body .photo-pick { width: 44px; height: 44px; }
  #mobile-task-body .photo-management { display: grid; }
  #project-actions-dialog .update-toast { position: static; transform: none; width: auto; max-width: none; margin: 16px; box-shadow: none; }
  body:has(#update-toast:not([hidden])) #project-menu-toggle::after { content: ''; position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; background: var(--color-accent-hover); border-radius: 50%; }
  #project-menu-toggle { position: relative; }
  .toast { top: 0; bottom: auto; left: 0; transform: none; display: grid; align-items: center; width: 100%; max-width: none; min-height: var(--toolbar-height); max-height: var(--toolbar-height); padding: calc(4px + env(safe-area-inset-top)) 12px 4px; overflow: auto; border-radius: 0; border: 0; box-shadow: none; font-size: 12px; animation: none; }
}
@media (min-width: 600px) and (max-width: 900px) and (max-height: 500px) {
  .workspace:has(.inspector.is-open) { grid-template-columns: minmax(0, 1fr) 280px; grid-template-rows: minmax(0, 1fr); }
  .workspace .inspector.is-open { height: 100%; max-height: none; }
  .inspector[data-mobile-tool="chooser"] .mobile-tool-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.menu-groups { display: grid; gap: 20px; padding: 0 16px 20px; }
.menu-group h3 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--color-text-muted); }
.menu-list { display: grid; overflow: hidden; border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface-raised); }
.menu-list > .button { min-height: 48px; padding: 12px 16px; text-align: left; border: 0; border-radius: 0; background: transparent; }
.menu-list > .button + .button { border-top: 1px solid var(--color-border); }
.menu-list > .button[aria-pressed="true"] { color: var(--color-accent-hover); background: var(--color-accent-soft); }
#mobile-alpha-message { margin: 0; line-height: 1.6; }
@media (max-width: 900px) {
  html, body { background: var(--color-surface); }
  .menu-view-actions { display: flex; width: fit-content; }
  .menu-view-actions > .icon-button { display: inline-grid; width: 48px; height: 48px; padding: 12px; }
  .menu-view-actions > .button + .button { border-top: 0; border-left: 1px solid var(--color-border); }
  .menu-view-actions > .icon-button svg { width: 22px; height: 22px; }
  .menu-view-actions > .button[aria-pressed="true"] { background: var(--color-accent-soft); }
  #mobile-tool-reset { flex: none; min-height: 44px; padding: 4px; font-size: 12px; white-space: nowrap; }
  #project-actions-dialog { width: min(360px, calc(100% - 32px)); max-width: none; height: 100%; max-height: 100%; margin: 0 auto 0 0; border: 0; border-right: 1px solid var(--color-border); border-radius: 0; background: var(--color-surface); }
  #project-actions-dialog .dialog-header { position: sticky; top: 0; z-index: 1; background: var(--color-surface); padding-top: calc(8px + env(safe-area-inset-top)); }
  #project-actions-dialog .menu-groups { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
  #project-actions-dialog { animation: none; opacity: 0; transform: translateX(-100%); transition: transform 220ms ease, opacity 220ms ease, display 220ms allow-discrete, overlay 220ms allow-discrete; }
  #project-actions-dialog[open] { opacity: 1; transform: translateX(0); }
  #project-actions-dialog::backdrop { animation: none; opacity: 0; transition: opacity 220ms ease, display 220ms allow-discrete, overlay 220ms allow-discrete; }
  #project-actions-dialog[open]::backdrop { opacity: 1; }
  @starting-style {
    #project-actions-dialog[open] { opacity: 0; transform: translateX(-100%); }
    #project-actions-dialog[open]::backdrop { opacity: 0; }
  }
}
