/* Shared visual scale. Keep controls readable without scaling the canvas shell. */
:root {
  --ui-control: 40px;
  --ui-button-font: 14px;
  --ui-caption: 12px;
  --ui-radius: 10px;
  --ui-border: #d9d5e4;
  --ui-secondary: #635d72;
}
.ui-symbols { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.ui-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-welcome { display: none; }
.workspace button { min-height: var(--ui-control); border-radius: var(--ui-radius); font-size: var(--ui-button-font); font-weight: 650; line-height: 1.3; }
.workspace button:disabled { cursor: not-allowed; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #8d80f0; outline-offset: 3px; }
.workspace button[hidden], .mobile-welcome[hidden] { display: none; }
.section-title h2, .section-heading h2 { font-size: 16px; font-weight: 700; }
.section-heading > span { font-size: 12px; }
.desktop-start-file-actions button, .gallery-entry-row button, .recent-projects-button { min-height: var(--ui-control); padding: 8px 14px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); font-size: var(--ui-button-font); background: #fff; color: var(--ui-secondary); }
.desktop-start-file-actions button + button { padding-left: 14px; }
.desktop-start-file-actions button + button::before { content: none; }
.desktop-start-file-actions, .gallery-entry-row { gap: 10px; }
.desktop-start-file-actions { flex-wrap: wrap; }
.gallery-entry-row button:hover:not(:disabled), .recent-projects-button:hover { border-color: #aaa0f1; background: #f5f3ff; color: var(--purple); }
body .desktop-start-generate, .generate-button { min-height: 52px; height: 52px; font-size: 16px; font-weight: 700; border-radius: 12px; box-shadow: 0 5px 16px #5c4de823; }
.desktop-preview-empty > small { color: var(--ui-secondary); font-size: 12px; line-height: 1.6; }
.desktop-preview-replace-hint { font-size: 13px; padding: 10px 16px; white-space: nowrap; }
.desktop-ready-badge, #desktopPreviewStatus { font-size: 12px; }
.desktop-start-ready-copy > p { color: var(--ui-secondary); font-size: 14px; }
.desktop-simple-heading small, .desktop-simple-heading > span, .desktop-quality-options button small,
.desktop-quality-summary span, .desktop-quality-summary small, .desktop-advanced-settings > summary small,
.desktop-advanced-settings > summary > i, .desktop-cutout-action small, .desktop-setting-row > small,
.desktop-palette-definition small, .desktop-palette-definition > span i, .desktop-expert-size summary small { font-size: 12px; color: var(--ui-secondary); }
.desktop-quality-summary strong, .desktop-select-setting > span, .desktop-advanced-settings > summary b,
.desktop-setting-heading label, .desktop-setting-heading output, .desktop-palette-definition > span,
.desktop-expert-size summary, .desktop-cutout-action button { font-size: 14px; }
.desktop-quality-options button { min-height: 64px; }
.desktop-quality-options button b { font-size: 16px; }
.desktop-quality-options button.active small { color: #fff; }
.desktop-quality-summary { grid-template-columns: 1fr; gap: 5px; }
.desktop-quality-summary span { grid-row: auto; }
.desktop-quality-summary strong, .desktop-quality-summary small { text-align: left; }
.desktop-select-setting select, .desktop-palette-definition select, .desktop-expert-size input { height: 40px; font-size: 14px; }
.desktop-advanced-settings > summary { min-height: 56px; }
.desktop-basic-settings[aria-disabled="true"] { opacity: .65; }

/* Persistent, concise editor actions. */
body .studio-toolbar { min-height: 56px; gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
body .studio-toolbar .editor-back-button { width: auto; flex: 0 0 auto; min-height: var(--ui-control); margin: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; font-size: 14px; color: #5142c7; border-color: #c8c0f4; background: #f5f3ff; }
body .studio-toolbar .editor-back-button[hidden] { display: none; }
body .canvas-shortcut-hint { display: none; }
body .active-color-indicator { min-width: 138px; max-width: 174px; height: var(--ui-control); grid-template-columns: 28px minmax(0,1fr); gap: 8px; padding: 4px 8px; }
body .active-color-indicator > i { width: 28px; height: 28px; }
body .active-color-indicator strong { font-size: 13px; }
body .active-color-indicator small { font-size: 11px; }
body .view-group { margin-left: auto; gap: 6px; }
body .view-group button, body.editor-compact .view-group button { width: auto; min-width: var(--ui-control); height: var(--ui-control); padding: 0 10px; font-size: 14px; flex-shrink: 0; }
body .view-group label, body.editor-compact .view-group label { display: flex; align-items: center; gap: 3px; min-height: var(--ui-control); font-size: 13px; white-space: nowrap; }
body .view-group label input { width: 18px; height: 18px; margin: 0 3px; accent-color: var(--purple); }
body .view-group output, body.editor-compact .view-group output { min-width: 40px; font-size: 13px; }
body.editor-compact .active-color-indicator { min-width: 138px; max-width: 174px; height: 40px; grid-template-columns: 28px minmax(0,1fr); padding: 4px 8px; }
body.editor-compact .active-color-indicator > i { width: 28px; height: 28px; }
body.editor-compact #zoomFit { font-size: 14px; }
body.editor-compact #zoomFit::before { content: none; }
body .reference-toggle-copy b { font-size: 14px; }
body .reference-toggle-copy small { font-size: 12px; }
body .reference-toggle { min-height: 58px; }
.section-title > span, .layer-opacity-control > span, .layer-opacity-control output { font-size: 12px; }
.reference-actions .layer-opacity-control > span, .reference-actions .layer-opacity-control output { font-size: 12px; }
.summary-card { grid-template-columns: 1fr 1fr 1.8fr; }
.summary-card small { font-size: 12px; color: var(--ui-secondary); }
.summary-card strong { font-size: 20px; }
.summary-card #physicalSize { font-size: 15px; }
.export-stack { gap: 8px; }
body .export-button, body .save-project-button, body .materials-export { min-height: 64px; padding: 10px 12px; border-radius: 12px; box-shadow: none; }
body .export-button strong, body .save-project-button strong, body .materials-export strong { font-size: 14px; font-weight: 700; }
body .export-button small, body .save-project-button small, body .materials-export small { margin-top: 4px; font-size: 12px; color: var(--ui-secondary); line-height: 1.4; }
body .export-button > span, body .save-project-button > span, body .materials-export > span { width: 36px; height: 36px; font-size: 20px; }
body #exportPrint { border-color: var(--purple); background: var(--purple); color: #fff; }
body #exportPrint :is(strong, small, b) { color: #fff; }
body #exportPrint > span { color: #fff; background: #ffffff24; }
body #exportPrint:hover:not(:disabled) { background: var(--purple-dark); }
body .gallery-share-button, body .recent-projects-button { min-height: var(--ui-control); font-size: 14px; }
.export-utilities { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.export-utilities button { min-width: 0; padding: 8px; border: 1px solid var(--ui-border); background: #fff; color: var(--ui-secondary); }
.toast { font-size: 13px; line-height: 1.5; }
body .palette-main { min-height: 44px; }
body .palette-main strong, body .palette-code, body .palette-edit-color, body .materials-code { font-size: 13px; }
body .palette-main small, body .palette-count, body .materials-count, body .materials-name, body .materials-total { font-size: 12px; }
.standard-color-search { min-height: 44px; }
.standard-color-search input { font-size: 16px; }
.standard-color-option { height: 62px; grid-template-rows: 34px auto; }
.standard-color-option b { font-size: 12px; }
.standard-color-option small { font-size: 11px; }
.color-editor-dialog button, .cutout-dialog button, .recent-projects-dialog button { min-height: var(--ui-control); border-radius: var(--ui-radius); font-size: var(--ui-button-font); }
.color-editor-actions button, .cutout-actions button { min-width: 80px; }
.color-editor-head small, .color-editor-footer, .color-editor-hint { font-size: 12px; }
.standard-color-option:focus-visible { outline: 3px solid #8d80f0; outline-offset: 1px; }

@media (min-width: 901px) {
  body.desktop-quick-start .desktop-start:not([hidden]) { padding: 24px; align-items: safe center; }
  .desktop-start-card { width: min(1160px,100%); min-height: 0; }
  .desktop-start-ready { min-height: 0; gap: 28px; padding: 28px; grid-template-columns: minmax(0,1.15fr) minmax(340px,1fr); }
  .desktop-start-preview { height: clamp(440px,72vh,630px); }
  .desktop-start-ready-copy h1 { font-size: 26px; }
  .desktop-preview-empty { padding: 24px; }
  body.editor-ready .workspace, body.editor-compact .workspace { grid-template-columns: minmax(0,1fr) 310px; }
  body.editor-ready .studio, body.editor-compact .studio { grid-template-columns: 72px minmax(0,1fr); grid-template-rows: auto auto minmax(0,1fr) 28px; }
  body.editor-ready .editor-tool-rail { padding: 8px; gap: 4px; }
  body.editor-ready .editor-tool-rail > .tool, body.editor-compact .editor-tool-rail > .tool { width: 55px; min-width: 55px; height: 52px; min-height: 52px; padding: 5px 2px; font-size: 12px; flex-shrink: 0; overflow: visible; }
  body.editor-ready .editor-tool-rail > .tool .tool-icon { width: 24px; height: 24px; }
  body.editor-ready .tool-icon svg { width: 20px; height: 20px; }
  body.editor-ready .editor-tool-rail .history-tool > span { font-size: 22px; }
  body.editor-ready .statusbar, body.editor-compact .statusbar { height: 28px; min-height: 28px; max-height: 28px; padding: 0 12px; font-size: 11px; }
  body.editor-ready .inspector { padding: 16px; }
  body.editor-ready .preview-wrap { height: 160px; }
  body.editor-ready .preview-wrap.portrait { height: 184px; }
  body.editor-ready .preview-wrap.landscape { height: 128px; }
  body.editor-ready .quick-palette-bar { min-height: 52px; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 4px 6px; }
  body.editor-ready .quick-palette-heading { display: none; }
  body.editor-ready .quick-color-chip { min-width: 44px; width: 44px; height: 40px; padding: 3px; grid-template-columns: 1fr; }
  body.editor-ready .quick-color-chip > i { width: 36px; height: 32px; }
  body.editor-ready .quick-color-chip > i b { max-width: 34px; font-size: 11px; }
  body.editor-ready .quick-add-color { min-width: 44px; width: 44px; height: 40px; flex-basis: 44px; font-size: 0; }
  body.editor-ready .palette-manager-toggle { width: auto; min-width: 100px; height: 40px; padding: 0 12px; font-size: 14px; }
  body.editor-ready .brush-size-bar { min-height: 50px; flex-wrap: wrap; gap: 8px; padding: 4px 6px; }
  body.editor-ready .brush-preset { min-width: 66px; height: 40px; padding: 4px 7px; }
  body.editor-ready .brush-preset > span { font-size: 13px; }
  body.editor-ready .inline-custom-brush { height: 44px; }
  body.editor-ready .inline-custom-brush > strong { font-size: 13px; }
  body.editor-ready .inline-custom-brush input { height: 36px; font-size: 14px; }
  body.editor-ready .inline-custom-brush label { font-size: 12px; }
  body.editor-ready .symmetry-bar { flex-wrap: wrap; }
  body.editor-ready .symmetry-bar strong, body.editor-ready .simple-tool-bar strong, body.editor-ready .recolor-title strong, body.editor-ready .batch-title strong { font-size: 14px; }
  body.editor-ready .simple-tool-bar small, body.editor-ready .recolor-title small, body.editor-ready .batch-title small, body.editor-ready .symmetry-bar label { font-size: 12px; }
  body.editor-ready .batch-color span, body.editor-ready .recolor-chip span { font-size: 12px; }
}
@media (min-width: 901px) and (max-width: 1150px) {
  body.editor-ready .workspace { grid-template-columns: minmax(0,1fr) 286px; }
  body.editor-ready .studio-toolbar .view-group { flex-basis: 100%; justify-content: flex-end; }
  .summary-card small { white-space: nowrap; }
  .summary-card strong { font-size: 18px; }
  .desktop-start-ready { gap: 20px; padding: 22px; grid-template-columns: minmax(0,1fr) minmax(330px,1fr); }
}

@media (max-width: 900px) {
  :root { --ui-control: 44px; --ui-button-font: 15px; }
  .control-panel { max-width: 540px; margin-inline: auto; padding: 24px 20px 90px; background: transparent; }
  body:not(.mobile-source-ready)[data-mobile-view="settings"] .control-panel { min-height: calc(100dvh - 64px); padding-top: clamp(28px,7dvh,72px); }
  body:not(.mobile-source-ready) .control-panel > section:first-child > .section-heading { display: none; }
  .mobile-welcome { display: block; margin-bottom: 28px; text-align: center; }
  .mobile-welcome-brand { display: flex; align-items: center; justify-content: center; gap: 10px; color: #403952; font-size: 16px; font-weight: 700; }
  .mobile-welcome h1 { margin: 25px 0 12px; font-size: clamp(26px,7vw,32px); line-height: 1.45; font-weight: 750; letter-spacing: -.5px; }
  .mobile-welcome p { margin: 0; color: var(--ui-secondary); font-size: 14px; line-height: 1.6; }
  body.mobile-source-ready .mobile-welcome { display: none; }
  .mobile-photo-actions { grid-template-columns: minmax(0,1fr); gap: 12px; padding: 22px; border: 1px solid #e3deef; border-radius: 20px; background: #fff; box-shadow: 0 12px 32px #352d6010; }
  .mobile-photo-actions button { min-height: 52px; font-size: 16px; border-radius: 12px; }
  .mobile-photo-actions #mobileGalleryButton { background: var(--purple); border-color: var(--purple); color: #fff; }
  .mobile-photo-actions #mobileCameraButton { background: #fff; color: #514764; border-color: var(--ui-border); }
  .mobile-photo-actions p { margin: 3px -10px 0; color: var(--ui-secondary); font-size: 12px; line-height: 1.5; text-align: center; }
  body .mobile-project-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 18px 0 0; }
  body .mobile-project-actions button { min-width: 0; min-height: 44px; padding: 6px 2px; font-size: 13px; border: 1px solid var(--ui-border); border-radius: 10px; background: #fff; color: var(--ui-secondary); white-space: nowrap; }
  body.mobile-source-ready .mobile-project-actions { display: none; }
  .mobile-import-preview:not([hidden]) { height: 200px; }
  .mobile-import-preview b, .mobile-import-preview small { font-size: 13px; }
  .mobile-import-preview > span { padding: 10px; }
  .cutout-entry { grid-template-columns: auto minmax(0,1fr); padding: 8px; gap: 10px; background: #fff; border-color: var(--ui-border); }
  .cutout-entry button, .cutout-entry.done button { height: 44px; background: #f5f3ff; color: #5142c7; border: 1px solid #ddd6fa; box-shadow: none; font-size: 14px; }
  .cutout-entry strong { font-size: 12px; line-height: 1.5; color: var(--ui-secondary); }
  .mobile-simple-settings { padding: 16px; box-shadow: none; background: #fff; }
  .mobile-simple-heading strong { font-size: 16px; }
  .mobile-simple-heading small, .mobile-simple-heading > span, .mobile-quality-options button small, .mobile-quality-summary span, .mobile-quality-summary small, .mobile-simple-settings > p { font-size: 12px; color: var(--ui-secondary); }
  .mobile-quality-options button { min-height: 64px; }
  .mobile-quality-options button b { font-size: 16px; }
  .mobile-quality-options button.active small { color: #fff; }
  .mobile-quality-summary { grid-template-columns: minmax(0,1fr); gap: 5px; padding: 12px; }
  .mobile-quality-summary span { grid-row: auto; }
  .mobile-quality-summary strong, .mobile-quality-summary small { text-align: left; line-height: 1.5; }
  .mobile-quality-summary strong { font-size: 14px; }
  .mobile-bead-choice { grid-template-columns: 1fr; gap: 8px; }
  .mobile-bead-choice > span { font-size: 14px; }
  .mobile-bead-choice button { min-height: 44px; font-size: 14px; }
  body .generate-button { font-size: 16px; }
  body.mobile-source-ready[data-mobile-view="settings"] .generate-button { width: auto; left: max(14px,calc((100vw - 500px)/2)); right: max(14px,calc((100vw - 500px)/2)); }
  .mobile-workspace-nav button { font-size: 12px; gap: 4px; }
  body[data-mobile-view="editor"] { overflow: hidden; }
  body[data-mobile-view="editor"] .studio { height: calc(100dvh - 64px - env(safe-area-inset-bottom)); min-height: 0; grid-template-rows: 60px 58px auto minmax(0,1fr) 52px; }
  body .studio-toolbar { display: flex; grid-row: 1; min-height: 60px; padding: 8px 12px; flex-wrap: nowrap; overflow: hidden; }
  body .studio-toolbar .editor-back-button { font-size: 14px; }
  body .studio-toolbar .active-color-indicator { margin-left: auto; min-width: 126px; max-width: 160px; height: 44px; }
  .studio-toolbar .view-group { display: none; }
  body .editor-tool-rail { grid-row: 2; gap: 4px; padding: 6px 10px; justify-content: space-between; overflow-x: auto; }
  body .editor-tool-rail > .tool { min-width: 48px; height: 44px; padding: 3px 7px; font-size: 12px; display: grid; place-content: center; gap: 2px; }
  body .editor-tool-rail > .tool .tool-icon { width: 20px; height: 20px; margin: auto; }
  body .editor-tool-rail > .tool .tool-icon svg { width: 18px; height: 18px; }
  body .editor-tool-rail > .history-tool span { font-size: 20px; margin: 0; }
  body .editor-tool-rail > :is(.mobile-pan-tool,[data-tool="fill"],[data-tool="eyedropper"],[data-tool="recolor"],[data-tool="batch"]) { display: none; }
  #undoButton { margin-left: auto; }
  .tool-context-slot { grid-row: 3; }
  .canvas-scroller { grid-row: 4; }
  body .statusbar { grid-row: 5; height: 52px; min-height: 52px; max-height: 52px; padding: 4px 10px; gap: 6px; }
  body .statusbar button { min-height: 44px; height: 44px; font-size: 12px; border-radius: 10px; }
  .brush-size-bar { min-height: 54px; padding: 4px; }
  .brush-presets { flex: 1 1 auto; gap: 6px; }
  .brush-preset { min-width: 0; min-height: 44px; height: 44px; flex: 1; padding: 4px; grid-template-columns: 22px minmax(0,1fr); grid-template-rows: 1fr; }
  .brush-preset > span { font-size: 12px; align-self: center; }
  .brush-preset > .brush-grid-icon { grid-row: 1; }
  .gesture-hint > button { min-width: 58px; min-height: 44px; font-size: 12px; }
  .gesture-hint strong { font-size: 14px; }
  .gesture-hint small { font-size: 12px; }
  .gesture-hint:not([hidden]) { bottom: calc(124px + env(safe-area-inset-bottom)); grid-template-columns: minmax(0,1fr) auto; }
  .gesture-visual { display: none; }
  .inspector { min-height: calc(100dvh - 64px); padding: 20px 16px 88px; }
  .palette-section .quick-add-color { min-height: 44px; font-size: 14px; }
  body .export-button strong, body .save-project-button strong, body .materials-export strong { font-size: 15px; }
  .mobile-export-tip { font-size: 12px; }
  .standard-color-grid { grid-template-columns: repeat(5,minmax(0,1fr)); gap: 6px; }
  .color-editor-dialog button { min-height: 44px; }
  .symmetry-bar { grid-template-rows: 44px 44px; min-height: 106px; }
  .symmetry-bar input[type="number"] { height: 40px; }
  .generation-progress { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(126px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px); }
  body.mobile-source-ready[data-mobile-view="settings"] .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .control-panel { padding-inline: 14px; }
  .mobile-photo-actions { padding: 18px; }
  .mobile-simple-settings { padding: 12px; }
  .mobile-quality-options { gap: 4px; }
  .mobile-quality-options button small { font-size: 11px; }
  body .studio-toolbar { padding-inline: 8px; gap: 8px; }
  body .studio-toolbar .editor-back-button { padding-inline: 9px; }
  body .studio-toolbar .active-color-indicator { min-width: 112px; }
}
@media (prefers-reduced-motion: reduce) {
  .workspace button, .desktop-start-preview, .reference-toggle { transition: none; }
}
