/* INKFORM: one continuous studio with floating controls.
   Current direction: docs/design/glass-concrete-studio.md. */
@font-face { font-family: Manrope; src: url('./fonts/Manrope-variable.ttf') format('truetype'); font-style: normal; font-weight: 200 800; font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #303030;
  --panel: #383838;
  --text: #f5f5f5;
  --muted: #c2c2c2;
  --line: #ffffff20;
  --edge: #ffffff30;
  --accent: #ffffff;
  --danger: #ffffff;
  --paper: #f4f4f4;
  --ink: #171717;
  --sans: Manrope, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --radius: 10px;
  --control-radius: 5px;
  --pane-width: 320px;
  --header-height: 60px;
  --workspace-gap: 20px;
  --panel-top: 96px;
  --surface-fill: var(--panel);
  --surface-fallback: var(--panel);
  --surface-shadow: 0 10px 32px #00000028;
  --surface-blur: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea, summary { font: inherit; color: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: #ffffff24; touch-action: manipulation; }
button { cursor: pointer; border: 0; border-radius: var(--control-radius); background: transparent; min-height: 44px; padding: 8px 12px; }
button:not(:disabled):hover, summary:hover { background-color: #ffffff0b; }
button:not(:disabled):active { background-color: #ffffff18; }
button:disabled, select:disabled, input:disabled { opacity: .45; cursor: not-allowed; }
:where(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select, textarea { accent-color: var(--accent); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h2, h3 { font-size: 14px; line-height: 1.5; font-weight: 550; }
[hidden] { display: none !important; }
input[type=text], input[type=search], input:not([type]), select, textarea {
  background: #ffffff0c; border: 1px solid var(--line); padding: 10px 12px;
  border-radius: var(--control-radius); width: 100%; min-height: 44px; max-width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: var(--edge); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; }
select { cursor: pointer; }
select option { background: var(--panel); color: var(--text); }
.skip-link { position: absolute; left: 20px; top: -80px; z-index: 100; padding: 12px 16px; background: var(--panel); border-radius: var(--control-radius); }
.skip-link:focus { top: 12px; }

/* A single material role; nested rows and fields never add a second blur. */
.glass-surface {
  background: var(--surface-fallback); border: 1px solid var(--edge);
  border-radius: var(--radius); box-shadow: var(--surface-shadow);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-surface {
    background: var(--surface-fill);
    -webkit-backdrop-filter: blur(var(--surface-blur)); backdrop-filter: blur(var(--surface-blur));
  }
}
.masthead {
  position: absolute; top: max(var(--workspace-gap),env(safe-area-inset-top)); left: var(--workspace-gap); right: var(--workspace-gap);
  height: var(--header-height); padding: 0 16px;
  display: flex; align-items: center; gap: 20px; z-index: 30;
}
.brand { flex: none; font-size: 28px; line-height: 1; letter-spacing: -1.6px; font-weight: 800; }
.brand:hover { text-decoration: none; color: var(--accent); }
.study-picker { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 2px; min-width: 0; padding-left: 16px; border-left: 1px solid var(--line); }
#project-select { border: 0; background: transparent; flex: 1; width: 320px; min-width: 0; max-width: 100%; padding: 10px 4px; font-size: 14px; text-overflow: ellipsis; }
.project-menu, .layer-menu { position: relative; }
.project-menu > summary, .layer-menu > summary {
  list-style: none; display: flex; align-items: center; gap: 8px;
  cursor: pointer; min-height: 44px; padding: 10px; border-radius: var(--control-radius); color: var(--muted); font-size: 13px;
}
.project-menu > summary::-webkit-details-marker, .layer-menu > summary::-webkit-details-marker { display: none; }
.project-menu > summary::after, .layer-menu > summary::after { content: ''; width: 6px; height: 6px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.project-menu[open] > summary::after, .layer-menu[open] > summary::after { transform: translateY(2px) rotate(225deg); }
.project-actions, .layer-menu-content { position: absolute; padding: 6px; z-index: 40; }
.project-actions { top: 50px; left: 0; width: 210px; }
.project-actions button, .project-actions a { display: block; width: 100%; text-align: left; min-height: 44px; padding: 11px 12px; }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
#save-status { flex-shrink: 0; font-size: 12px; color: var(--muted); max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 4px; }
.save-image { border: 1px solid var(--paper); min-width: 112px; background: var(--paper); color: var(--ink); font-weight: 650; font-size: 13px; }
.save-image:not(:disabled):hover { background: #ffffff; color: var(--ink); }
.save-label-compact { display: none; }

.workspace { height: 100dvh; position: relative; }
.stage { position: absolute; inset: 0; overflow: hidden; background: #b7b8b4; }
#viewport { position: absolute; inset: 0; touch-action: none; }
#viewport canvas { display: block; width: 100%; height: 100%; }
#viewport canvas:focus-visible { outline: 2px solid #171b19; outline-offset: -4px; }
#viewport:has(canvas:focus-visible)::after { content: ''; position: absolute; inset: 5px; border: 2px solid #fff; pointer-events: none; }
.stage-top, #status[data-idle=true] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.stage-bottom { position: absolute; left: calc(var(--workspace-gap) + var(--pane-width) + 20px); right: var(--workspace-gap); bottom: 24px; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.stage-bottom button { pointer-events: auto; }
#status { font-size: 13px; color: var(--text); text-align: center; max-width: min(540px,100%); max-height: 76px; overflow: auto; padding: 8px 12px; margin-bottom: 10px; pointer-events: auto; }
#status:empty { display: none; }
.stage-toolbar { max-width: 100%; }
.camera-bar { display: flex; align-items: center; gap: 3px; padding: 5px; border-radius: var(--camera-radius,10px); max-width: 100%; }
.camera-bar button { position: relative; color: var(--muted); font-size: 14px; min-width: 60px; padding: 8px 12px; }
.camera-bar button[aria-pressed=true] { color: var(--ink); background: var(--paper); font-weight: 650; }
.camera-bar #place-mode { margin-right: 8px; }
.camera-bar #place-mode::after { content: ''; position: absolute; right: -6px; top: 10px; bottom: 10px; border-right: 1px solid var(--line); }
.interaction-hint { font-size: 12px; color: #eeeeee; margin-top: 7px; text-shadow: 0 1px 5px #111111, 0 1px 2px #111111; }
.stage-bottom:has(#status[data-idle=true]) .interaction-hint { display: none; }

.controls-panel { position: absolute; top: max(var(--panel-top),calc(env(safe-area-inset-top) + var(--header-height) + 16px)); left: var(--workspace-gap); bottom: 24px; width: var(--pane-width); display: flex; flex-direction: column; z-index: 20; overflow: hidden; }
.controls-top { flex: none; }
.surface-tabs { display: flex; align-items: stretch; padding: 0 14px; border-bottom: 1px solid var(--line); gap: 10px; }
.surface-tabs button { flex: 1; padding: 14px 0; min-height: 54px; border-radius: 0; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.surface-tabs button[aria-pressed=true] { color: var(--text); border-bottom-color: var(--accent); font-weight: 750; }
.surface-tabs span { font-size: 12px; color: var(--muted); margin-left: 3px; font-variant-numeric: tabular-nums; }
#controls-toggle { display: none; }
.controls-scroll { padding: 22px 14px 28px 20px; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; min-height: 0; flex: 1; }
@supports not selector(::-webkit-scrollbar) {
  .controls-scroll { scrollbar-width: thin; scrollbar-color: #c2c2c245 transparent; }
}
.controls-scroll::-webkit-scrollbar { width: 6px; }
.controls-scroll::-webkit-scrollbar-track { background: transparent; }
.controls-scroll::-webkit-scrollbar-thumb { background: #c2c2c245; border-radius: 3px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.section-heading > h2, [data-panel-content=body] > h2 { font-size: 28px; line-height: 1.15; letter-spacing: -1.2px; font-weight: 750; }
.layer-menu-content { right: 0; top: 44px; width: 245px; }
.layer-menu-content .small-actions, .layer-menu-content .layer-tools { margin: 0; }
.layer-menu-content .hint { padding: 0 8px; }
.small-actions, .layer-tools { display: flex; gap: 4px; flex-wrap: wrap; margin: 7px 0; }
.small-actions button, .layer-tools button { font-size: 13px; color: var(--muted); padding: 8px 10px; }
.layer-tools button { flex: 1; }
.layers { display: grid; margin: 0 -7px 4px; gap: 3px; }
.layer { position: relative; display: grid; grid-template-columns: 20px 48px minmax(0,1fr); gap: 9px; padding: 9px 7px; border-left: 2px solid transparent; border-radius: 3px; align-items: center; }
.layer.selected { border-left-color: var(--accent); background: #ffffff12; }
.layer > input { width: 18px; height: 18px; margin: 0; }
.layer img { width: 48px; height: 52px; padding: 4px; object-fit: contain; background: var(--paper); border-radius: 4px; }
.layer-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer small { color: var(--muted); font-size: 12px; display: block; }
.layer-actions { grid-column: 2/-1; display: flex; gap: 1px; flex-wrap: wrap; max-height: 0; overflow: hidden; opacity: 0; }
.layer:hover .layer-actions, .layer:focus-within .layer-actions { max-height: 90px; opacity: 1; }
.layer-actions button { font-size: 12px; color: var(--muted); min-height: 44px; min-width: 44px; padding: 6px 8px; }
.hidden-layer > img { opacity: .55; }
.primary, .secondary { display: block; width: 100%; min-height: 44px; padding: 10px 12px; text-align: center; border: 1px solid var(--line); border-radius: var(--control-radius); background: #ffffff08; font-weight: 650; font-size: 13px; }
.primary { background: var(--paper); color: var(--ink); border-color: transparent; }
.primary:not(:disabled):hover { background: #ffffff; color: var(--ink); }
.secondary:not(:disabled):hover { background: #ffffff15; border-color: var(--edge); }
.secondary { margin-top: 10px; }
#browse-art { margin-top: 12px; text-align: center; font-weight: 550; }
#browse-art:not(:disabled):hover { color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 10px 0; }
.editor-divider { height: 1px; background: var(--line); margin: 12px 0 16px; }
.panel-intro { margin-bottom: 12px; }
.panel-intro h2 { font-size: 21px; line-height: 1.25; font-weight: 700; letter-spacing: -.6px; overflow-wrap: anywhere; }
.panel-intro > p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field { display: grid; gap: 8px; color: var(--muted); font-size: 14px; margin: 15px 0; }
.field > input, .field > select, .field > textarea { color: var(--text); }
.range-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; align-items: center; margin: 16px 0; }
.range-control label { font-size: 14px; color: var(--muted); }
.range-control output { font-size: 16px; font-weight: 500; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
#tattoo-controls > .range-control { margin: 13px 0; }
#tattoo-controls > .field { margin: 12px 0; }
.placement-action { margin: 4px 0 12px; font-weight: 400; text-align: left; }
.placement-action[aria-pressed=true] { background: #ffffff14; border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.protection-actions { margin: 4px -10px; }
.protection-actions button { color: var(--text); }
.alternative-action { margin-top: 12px; font-weight: 400; }
input[type=range] { grid-column: 1/-1; width: 100%; height: 44px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: #c2c2c240; border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { appearance: none; height: 16px; width: 16px; border-radius: 50%; background: var(--paper); border: 2px solid var(--bg); margin-top: -6.5px; }
input[type=range]::-moz-range-track { height: 3px; background: #c2c2c240; border-radius: 3px; }
input[type=range]::-moz-range-thumb { height: 13px; width: 13px; border: 2px solid var(--bg); border-radius: 50%; background: var(--paper); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; margin: 8px 0; }
.check input { width: 18px; height: 18px; flex: none; }
.nudge { display: flex; align-items: center; gap: 4px; }
.nudge button { min-width: 44px; border: 1px solid var(--line); }
.nudge span { font-size: 12px; color: var(--muted); margin-left: auto; }
.control-details { border-top: 1px solid var(--line); margin-top: 15px; }
.control-details > summary { cursor: pointer; color: var(--muted); min-height: 44px; padding: 12px 0; font-size: 14px; }
.control-details[open] > summary { color: var(--text); }
.advanced-tattoo, .study-notes { margin-top: 8px; }
.study-notes .notes { border: 0; padding-top: 0; margin-top: 0; }
.notes { border-top: 1px solid var(--line); padding-top: 15px; }
.upload { position: relative; display: grid; text-align: center; gap: 5px; padding: 20px 8px; border: 1px dashed var(--edge); border-radius: var(--control-radius); cursor: pointer; }
.upload strong { font-weight: 550; }
.upload small { font-size: 12px; color: var(--muted); }
.upload input, .upload-import input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.upload:focus-within, .upload-import:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.upload.dragging { border-color: var(--accent); background: #ffffff14; }
[data-left-content=library] { position: relative; }
.library-intro { margin: 2px 0 22px; min-height: 40px; display: flex; align-items: center; padding-right: 76px; }
.library-intro h2 { font-size: 32px; line-height: 1.05; font-weight: 750; letter-spacing: -1.3px; }
.library-intro p { margin-top: 9px; font-size: 13px; color: var(--muted); }
.library-import { margin: 0; border-radius: var(--control-radius); }
.library-import > summary { position: absolute; right: 0; top: -2px; min-height: 44px; cursor: pointer; padding: 11px 8px; font-size: 12px; font-weight: 650; border-radius: var(--control-radius); }
.library-import[open] { padding: 1px 12px 8px; margin-bottom: 14px; background: #ffffff08; }
.library-import .upload { padding: 13px 8px; }
.library-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.library-search input { min-width: 0; }
#art-results { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.artwork { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 12px; margin-top: 14px; }
.art-card { position: relative; min-width: 0; content-visibility: auto; contain-intrinsic-size: auto 190px; }
.art-card .preview-art { display: block; width: 100%; padding: 0; text-align: left; border-radius: 5px; color: var(--text); }
.art-card .preview-art:not(:disabled):hover { background: transparent; }
.art-paper { position: relative; display: grid; place-items: center; aspect-ratio: 1; padding: 15px; background: var(--paper); border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px #ffffffa0; }
.art-paper::after { content: ''; position: absolute; inset: 0; border: 1px solid var(--ink); border-radius: inherit; opacity: 0; pointer-events: none; }
.preview-art:not(:disabled):hover .art-paper::after, .preview-art:focus-visible .art-paper::after { opacity: 1; }
.art-paper img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; display: block; mix-blend-mode: multiply; }
.art-card strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12px; line-height: 1.5; font-weight: 550; overflow: hidden; overflow-wrap: anywhere; margin: 10px 39px 0 0; min-height: 36px; }
.art-card-actions { position: static; }
.art-card .add-art { position: absolute; right: -4px; bottom: 5px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; font-size: 24px; font-weight: 400; color: var(--text); }
.art-card .add-art span { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #ffffff45; border-radius: 50%; line-height: 1; }
.art-card .add-art:not(:disabled):hover { background: transparent; }
.art-card .add-art:not(:disabled):hover span { background: var(--paper); border-color: var(--paper); color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .art-paper::after { transition: opacity 140ms ease-out; }
  .artwork-preview[open] { animation: inspect-reveal 180ms ease-out; }
}
@keyframes inspect-reveal { from { opacity: .35; transform: scale(.985); } to { opacity: 1; transform: scale(1); } }
.empty { grid-column: 1 / -1; font-size: 14px; color: var(--muted); padding: 15px 7px; }
.history-bar { background: #00000015; display: flex; align-items: center; border-top: 1px solid var(--line); padding: 2px 12px; flex: none; }
.history-bar button { font-size: 13px; color: var(--muted); }
#engine, #footer-stats { display: none; }
.body-model-control { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.body-model-control .field { margin: 10px 0 4px; }
.body-model-control .hint { margin: 5px 0; }
.tone-section { border-top: 1px solid var(--line); padding-top: 17px; margin-top: 15px; }
.skin-swatches { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 7px; margin: 12px 0; }
.skin-swatches button { padding: 4px; display: grid; gap: 4px; border: 1px solid var(--edge); min-height: 54px; position: relative; }
.skin-swatches button span { display: block; height: 25px; border-radius: 2px; }
.skin-swatches button small { font-size: 12px; color: var(--text); }
.skin-swatches button[aria-pressed=true] { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: inset 0 -2px 0 var(--accent); }
.custom-color { display: grid; grid-template-columns: 1fr 44px 100px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
input[type=color] { width: 44px; height: 44px; padding: 3px; border: 1px solid var(--line); background: transparent; border-radius: 4px; }
#body-measurements { display: block; }
.loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(360px,calc(100% - 32px)); display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 10px; z-index: 25; text-align: center; padding: 24px; }
.loading p { font-size: 14px; color: var(--muted); }
footer { position: absolute; bottom: 8px; right: 20px; display: flex; gap: 10px; font-size: 12px; color: #eeeeee; text-shadow: 0 1px 5px #111111, 0 1px 2px #111111; pointer-events: none; z-index: 22; }
dialog { width: calc(100% - 32px); max-width: 460px; max-height: 85dvh; overflow: auto; overscroll-behavior: contain; padding: 30px; color: var(--text); }
dialog::backdrop { background: #171a184d; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog h2 { font-size: 23px; font-weight: 750; margin: 10px 0 15px; }
dialog p, dialog li { font-size: 14px; color: var(--muted); line-height: 1.65; margin: 12px 0; }
dialog ol { padding-left: 20px; }
.dialog-close { position: absolute; right: 10px; top: 8px; font-size: 13px; }
.upload-import { position: relative; cursor: pointer; }
#data-status { color: var(--text); }

/* Artwork inspection: the full-resolution image is always the final frame. */
.artwork-preview { width: min(800px,calc(100vw - 40px)); max-width: 800px; padding: 0; overflow: auto; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 24px 18px; }
.preview-heading > div { min-width: 0; }
.preview-heading h2 { font-size: 24px; line-height: 1.15; letter-spacing: -.65px; margin: 0; overflow-wrap: anywhere; }
.preview-heading p { margin: 6px 0 0; font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.preview-actions { display: flex; flex: none; align-items: center; }
.preview-actions > button { color: var(--muted); }
.preview-menu { position: relative; }
.preview-menu > summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--control-radius); font-size: 24px; }
.preview-menu > summary::-webkit-details-marker { display: none; }
.preview-menu-content { position: absolute; right: 0; top: 48px; z-index: 1; width: 185px; padding: 4px; }
.preview-menu-content button { width: 100%; text-align: left; font-size: 12px; color: var(--danger); }
.preview-paper { margin: 0 24px; height: min(54dvh,520px); display: grid; place-items: center; padding: 26px; border-radius: 5px; background: #fff; overflow: hidden; }
.preview-paper img, .preview-paper canvas { grid-area: 1 / 1; display: block; width: 100%; height: 100%; max-height: calc(min(54dvh,520px) - 52px); object-fit: contain; }
.preview-paper canvas { image-rendering: pixelated; }
.preview-paper p { grid-area: 1 / 1; margin: 0; color: var(--ink); text-align: center; max-width: 280px; }
.preview-paper p:empty { display: none; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 24px 22px; }
.preview-toolbar nav { display: flex; gap: 4px; }
.preview-toolbar .primary { width: auto; min-width: 130px; }
@media (max-height: 500px) {
  .artwork-preview { max-height: calc(100dvh - 24px); }
  .preview-heading { padding: 12px 24px; }
  .preview-paper { height: max(80px,calc(100dvh - 184px)); padding: 12px; }
  .preview-paper img, .preview-paper canvas { max-height: max(56px,calc(100dvh - 208px)); }
  .preview-toolbar { padding: 12px 24px; }
}
@media (max-width: 1000px) and (min-width: 701px) {
  .masthead { padding-inline: 12px; gap: 12px; }
  .camera-bar { gap: 1px; padding: 4px; }
  .camera-bar button { min-width: 44px; padding: 8px 6px; font-size: 12px; }
  .brand { font-size: 22px; }
  #project-select { width: 180px; max-width: 23vw; }
  #save-status { max-width: 125px; }
  .surface-tabs { padding-inline: 6px; }
  .surface-tabs button { font-size: 12px; }
  .surface-tabs span { margin-left: 1px; }
}
@media (min-width: 701px) and (max-height: 500px) {
  :root { --workspace-gap: 12px; --panel-top: 84px; }
  .controls-panel { bottom: 12px; }
  .stage-bottom { bottom: 12px; }
  .stage-bottom #status { position: fixed; top: 84px; right: 12px; max-width: 250px; max-height: 70px; }
  .interaction-hint, footer { display: none; }
}
@media (max-width: 700px) {
  :root { --header-height: 56px; --workspace-gap: 8px; --sheet-bottom: max(8px,env(safe-area-inset-bottom)); }
  .masthead { padding: 3px 8px; gap: 8px; }
  .brand { font-size: 22px; letter-spacing: -.8px; }
  .study-picker { max-width: none; padding-left: 8px; gap: 0; flex: 1; min-width: 0; }
  #project-select { width: 0; min-width: 0; max-width: none; flex: 1; font-size: 16px; padding: 8px 0; }
  .project-menu { flex-shrink: 0; position: static; }
  .project-menu > summary { padding: 10px 6px; font-size: 13px; min-width: 44px; }
  .project-actions { position: absolute; top: calc(100% + 8px); left: 0; right: auto; width: min(240px,calc(100vw - 16px)); }
  .header-right { gap: 0; }
  #save-status { position: absolute; top: 62px; right: 0; max-width: calc(100vw - 16px); background: var(--surface-fallback); padding: 5px 9px; border: 1px solid var(--edge); border-radius: 8px; font-size: 11px; margin: 0; }
  .save-image { min-width: 0; font-size: 13px; padding: 8px; }
  .save-label-wide { display: none; }
  .save-label-compact { display: inline; }
  #help-open { font-size: 13px; padding: 8px; }
  #retry-save { position: absolute; top: 96px; right: 0; background: var(--surface-fallback); border: 1px solid var(--edge); }
  .stage-bottom { left: 8px; right: 8px; bottom: calc(40dvh + 12px); }
  #status { font-size: 12px; max-height: 60px; padding: 7px 9px; margin-bottom: 7px; }
  .stage-toolbar { max-width: 100%; }
  .camera-bar { padding: 3px; gap: 1px; border-radius: 9px; max-width: 100%; }
  .camera-bar button { padding: 7px 6px; min-width: 44px; font-size: 12px; }
  .camera-bar #place-mode { margin-right: 5px; }
  .camera-bar #place-mode::after { right: -4px; }
  .interaction-hint { display: none; }
  .controls-panel { top: 60dvh; left: 8px; right: 8px; bottom: var(--sheet-bottom); width: auto; }
  .controls-top { display: flex; align-items: center; }
  .surface-tabs { flex: 1; min-width: 0; padding: 0 10px; gap: 7px; }
  .surface-tabs button { min-height: 52px; font-size: 12px; padding: 12px 0; }
  #controls-toggle { display: block; min-width: 64px; font-size: 12px; color: var(--muted); margin-right: 6px; }
  .controls-scroll { padding: 12px 16px 18px; }
  .controls-panel:is(.collapsed,[data-panel-state=collapsed]) { top: auto; height: 54px; }
  .controls-panel:is(.collapsed,[data-panel-state=collapsed]) :is(.controls-scroll,.history-bar) { display: none; }
  .workspace:has(.controls-panel:is(.collapsed,[data-panel-state=collapsed])) .stage-bottom { bottom: calc(54px + var(--sheet-bottom) + 12px); }
  .controls-panel:is(.expanded,[data-panel-state=expanded]) { top: max(28dvh,calc(max(8px,env(safe-area-inset-top)) + var(--header-height) + 8px)); }
  .workspace:has(.controls-panel:is(.expanded,[data-panel-state=expanded])) .stage-toolbar { display: none; }
  .workspace:has(.controls-panel:is(.expanded,[data-panel-state=expanded])) .stage-bottom { bottom: calc(72dvh + 12px); }
  .layer-actions, .layer:hover .layer-actions, .layer:focus-within .layer-actions { max-height: none; opacity: 1; }
  .layer-actions button, .small-actions button, .layer-tools button { min-height: 44px; }
  .layer > input { width: 20px; height: 20px; }
  .artwork { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .art-card .add-art { min-height: 44px; }
  .range-control { margin: 16px 0; }
  input[type=range] { height: 44px; }
  input[type=text], input[type=search], input:not([type]), select, textarea { font-size: 16px; }
  dialog { padding: 28px 22px; }
  .artwork-preview { width: calc(100vw - 20px); padding: 0; max-height: 92dvh; }
  .preview-heading { padding: 18px 16px 14px; }
  .preview-heading h2 { font-size: 21px; }
  .preview-paper { margin-inline: 16px; padding: 18px; }
  .preview-paper img, .preview-paper canvas { max-height: calc(min(54dvh,520px) - 36px); }
  .preview-toolbar { padding: 14px 12px 16px; gap: 4px; }
  .preview-toolbar nav { gap: 0; }
  .preview-toolbar button { font-size: 13px; padding-inline: 9px; }
  .preview-toolbar .primary { min-width: 112px; }
  .library-intro { margin-top: 2px; }
  .library-intro h2 { font-size: 28px; }

  footer { display: none; }
}
@media (max-width: 420px) {
  .masthead .brand { display: none; }
  .study-picker { border-left: 0; padding-left: 0; }
}
@media (max-width: 360px) {
  .camera-bar button { padding-inline: 6px; }
  .surface-tabs { padding-inline: 6px; }
  .surface-tabs button { font-size: 11px; }
  #controls-toggle { min-width: 60px; margin-right: 2px; }
  .custom-color { grid-template-columns: minmax(0,1fr) 44px 96px; }
}
@media (max-width: 700px) and (max-height: 500px) {
  .controls-panel { top: 52dvh; }
  .stage-bottom { bottom: calc(48dvh + 8px); }
  #save-status { max-width: 180px; }
  .controls-scroll { padding-block: 10px 16px; }
}
@media (pointer: coarse) {
  .layer-actions, .layer:hover .layer-actions, .layer:focus-within .layer-actions { max-height: none; opacity: 1; }
  .layer-actions button { min-height: 44px; min-width: 44px; }
  input[type=range] { height: 44px; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .glass-surface, #save-status { background: var(--surface-fallback); -webkit-backdrop-filter: none; backdrop-filter: none; }
  dialog::backdrop { background: #111111f5; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .glass-surface, #save-status { background: Canvas; color: CanvasText; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .surface-tabs button[aria-pressed=true], .camera-bar button[aria-pressed=true], .layer.selected { border-color: Highlight; outline: 1px solid Highlight; }
}
