@font-face {
  font-family: 'Great Vibes';
  src: url('/assets/fonts/GreatVibes-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Baskervville';
  src: url('/assets/fonts/Baskervville[wght].ttf') format('truetype');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Adamina';
  src: url('/assets/fonts/Adamina-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Orelega One';
  src: url('/assets/fonts/OrelegaOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Scope One';
  src: url('/assets/fonts/ScopeOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Darumadrop One';
  src: url('/assets/fonts/DarumadropOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Tilt Warp';
  src: url('/assets/fonts/TiltWarp[XROT,YROT].ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DM Serif Display';
  src: url('/assets/fonts/DMSerifDisplay-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Almarai';
  src: url('/assets/fonts/Almarai-Light.ttf') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Almarai';
  src: url('/assets/fonts/Almarai-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Almarai';
  src: url('/assets/fonts/Almarai-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Almarai';
  src: url('/assets/fonts/Almarai-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Abril Fatface';
  src: url('/assets/fonts/AbrilFatface-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bangers';
  src: url('/assets/fonts/Bangers-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Glass Antiqua';
  src: url('/assets/fonts/GlassAntiqua-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Chiron Sung HK';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/assets/fonts/ChironSungHK-latin-ext.ttf') format('truetype');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Chiron Sung HK';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('/assets/fonts/ChironSungHK-latin.ttf') format('truetype');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Londrina Solid';
  src: url('/assets/fonts/LondrinaSolid-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Big Shoulders Inline';
  src: url('/assets/fonts/BigShouldersInline[opsz,wght].ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cabin Sketch';
  src: url('/assets/fonts/CabinSketch-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cabin Sketch';
  src: url('/assets/fonts/CabinSketch-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Love Ya Like A Sister';
  src: url('/assets/fonts/LoveYaLikeASister.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Advent Pro';
  src: url('/assets/fonts/AdventPro[wdth,wght].ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Alegreya';
  src: url('/assets/fonts/Alegreya[wght].ttf') format('truetype');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Chelsea Market';
  src: url('/assets/fonts/ChelseaMarket-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Aleo';
  src: url('/assets/fonts/Aleo[wght].ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Nixie One';
  src: url('/assets/fonts/NixieOne-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Chuner;
  src: url('/assets/fonts/Chuner.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Avoin Bold';
  src: url('/assets/fonts/Avoin-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Akshar;
  src: url('/assets/fonts/Akshar.ttf') format('truetype');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #e5e5dc;
  --ink: #191a17;
  --primary: #000;
  --primary-text: #fff;
  --primary-hover: #262626;
  --primary-active: #383838;
  --stage: #d6d6ce;
  --muted: #666;
  --muted-soft: #777;
  --border-soft: #0003;
  --border-faint: #0002;
  --border-preview: #0005;
  --hover: #0000000d;
  --hover-soft: #00000006;
  --hover-action: #00000010;
  --hover-variant: #00000012;
  --active: #00000018;
  --selected: #00000008;
  --selected-hover: #333;
  --brand-hover: #555;
  --focus-halo: #00000026;
  --handle-line: #222;
  --handle-bg: #fff;
  --handle-hover: #ddd;
  --selection-halo: #ffffff80;
  --guide-line: #0008;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23191a17' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --line: 1px solid var(--ink);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #1b1c19;
  --ink: #e5e5dc;
  --primary: #e5e5dc;
  --primary-text: #191a17;
  --primary-hover: #f3f3e8;
  --primary-active: #c7c7bd;
  --stage: #11120f;
  --muted: #b1b1a7;
  --muted-soft: #aaa99f;
  --border-soft: #e5e5dc33;
  --border-faint: #e5e5dc22;
  --border-preview: #e5e5dc66;
  --hover: #e5e5dc10;
  --hover-soft: #e5e5dc08;
  --hover-action: #e5e5dc18;
  --hover-variant: #e5e5dc1c;
  --active: #e5e5dc24;
  --selected: #e5e5dc0c;
  --selected-hover: #c9c9be;
  --brand-hover: #bdbdb2;
  --focus-halo: #e5e5dc33;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e5e5dc' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.4 Akshar, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, summary, input[type='range'], input[type='color'] { cursor: pointer; }
button { min-height: 42px; padding: 10px 16px; border: var(--line); border-radius: 4px; background: transparent; }
button, a, summary, select, textarea { transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease; }
button:disabled { opacity: .35; cursor: default; }
button:disabled:hover { background-color: transparent; }
button:active:not(:disabled) { background-color: var(--active); }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.primary { background: var(--primary); color: var(--primary-text); }
.primary:active:not(:disabled) { background: var(--primary-active); }
.icon { display: inline-block; width: 21px; height: 21px; vertical-align: middle; flex-shrink: 0; pointer-events: none; }
button .icon { margin-inline: 3px; }

header { display: flex; align-items: center; gap: 36px; height: 90px; padding: 0 36px; border-bottom: var(--line); }
.brand { color: inherit; font-size: 34px; font-weight: 700; letter-spacing: -1px; text-decoration: none; white-space: nowrap; }
.subtitle { padding-left: 28px; border-left: var(--line); font-size: 17px; }
.edition { margin-left: auto; color: var(--muted); font-size: 14px; }
main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; width: 100%; max-width: none; margin: 0; }
.workspace { min-width: 0; padding: 0 32px; }
.scene-head { display: flex; align-items: center; justify-content: space-between; height: 68px; font-size: 15px; }
.scene-head button { min-width: 42px; padding: 6px 10px; border: 0; }
.live { display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--primary); }
.stage { position: relative; display: flex; align-items: center; justify-content: center; height: min(65vw, 660px); min-height: 340px; padding: 58px 24px 24px; overflow: hidden; border: var(--line); background: var(--stage); }
.canvas-wrap { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; }
#canvas { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; cursor: grab; touch-action: none; }
#canvas.dragging { cursor: grabbing; }
#canvas:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.stage:fullscreen { height: 100dvh; padding: 60px 30px 30px; }
.scene-tools { position: absolute; top: 10px; left: 24px; z-index: 3; display: flex; gap: 6px; }
.scene-tools button { min-height: 34px; padding: 5px 10px; background: var(--paper); font-size: 14px; }
.scene-tools button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.scene-tools button:disabled { opacity: .4; }
.transport { display: flex; align-items: center; gap: 16px; min-height: 70px; font-size: 15px; }
.transport button { padding: 9px 12px; border: 0; font-size: 15px; }
.hint { margin: auto; color: var(--muted); }
.explore { display: flex; align-items: center; gap: 12px; padding: 22px 0; border-top: var(--line); border-bottom: var(--line); }
.explore > div { margin-right: auto; }
.eyebrow { font-size: 13px; letter-spacing: 1px; }
.explore p { margin: 7px 0 0; font-size: 28px; letter-spacing: -.6px; }
.explore button { font-size: 18px; }
.section-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 20px 0; font-size: 18px; }
.section-heading > span { margin-right: auto; }
.section-heading button { padding: 9px 12px; border: 0; font-size: 15px; }
#count { margin-left: 10px; color: var(--muted-soft); }
#gallery { display: flex; gap: 14px; overflow: auto; padding-bottom: 22px; }
.empty { padding: 20px 0; color: var(--muted-soft); font-size: 17px; }
.variant { min-width: 140px; max-width: 170px; overflow: hidden; border: var(--line); border-radius: 4px; }
.variant img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.variant button { padding: 9px; border: 0; border-radius: 0; font-size: 15px; }
.variant .restore { width: 78%; text-align: left; }
.variant .delete { width: 22%; }

aside { border-left: var(--line); }
.aside-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 25px 24px; border-bottom: var(--line); font-size: 25px; }
#sections-toggle { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-width: 42px; min-height: 42px; padding: 8px; border: 0; }
details { border-bottom: var(--line); }
summary { display: flex; align-items: center; gap: 8px; padding: 21px 24px; list-style: none; font-size: 19px; }
summary::-webkit-details-marker { display: none; }
summary button { min-width: 36px; min-height: 36px; margin-left: auto; padding: 0 4px; border: 0; }
summary::after, details[open] > summary::after { content: none; }
.controls { display: grid; gap: 25px; padding: 4px 24px 28px; }
label, .label-row { display: block; font-size: 18px; }
textarea, select { display: block; width: 100%; margin-top: 12px; padding: 12px; border: var(--line); border-radius: 3px; background: transparent; }
textarea { min-height: 100px; font-size: 30px; resize: vertical; }
select { min-height: 48px; padding-right: 52px; font-size: 18px; appearance: none; -webkit-appearance: none; cursor: pointer; background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 16px center; background-size: 20px 20px; }
.lock { float: right; min-height: 28px; padding: 2px 4px; border: 0; border-radius: 3px; color: var(--muted-soft); font-size: 14px; }
.lock[aria-pressed='true'] { color: var(--primary); }
.lock .icon { width: 16px; height: 16px; }
.colors { display: flex; align-items: center; gap: 20px; margin-top: -7px; }
.colors label { display: flex; align-items: center; gap: 7px; }
.colors button { padding: 3px; border: 0; }
input[type='color'] { width: 36px; height: 36px; padding: 0; overflow: hidden; border: var(--line); border-radius: 50%; background: none; }
input[type='color']::-webkit-color-swatch-wrapper { padding: 0; }
input[type='color']::-webkit-color-swatch { border: 0; border-radius: 50%; }
.palettes { display: flex; gap: 12px; margin-top: -7px; }
.palettes button { width: 42px; height: 30px; min-height: 30px; padding: 0; border-radius: 20px; }
.segments { display: flex; }
.segments button { flex: 1; min-height: 46px; margin-left: -1px; padding: 10px 8px; border-radius: 0; font-size: 17px; }
.segments button:first-child { margin-left: 0; border-radius: 3px 0 0 3px; }
.segments button:last-child { border-radius: 0 3px 3px 0; }
.segments .active { background: var(--ink); color: var(--paper); }
output { float: right; color: var(--muted-soft); font-size: 16px; }
input[type='range'] { display: block; width: 100%; height: 22px; margin: 15px 0 0; accent-color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; }
.note, .aside-foot { color: var(--muted); font-size: 15px; line-height: 1.6; }
.note { margin: 0; }
.aside-foot { padding: 24px; }
.parameter-group { display: grid; gap: 25px; }
.parameter-group[hidden], aside details[hidden], aside label[hidden] { display: none !important; }
.photo-controls { padding: 0; gap: 24px; }
.photo-panel [hidden], .type-treatment [hidden] { display: none !important; }
.photo-panel .note { margin: 0; }
.type-treatment #backing-settings { padding: 0; gap: 24px; }
.type-treatment .colors { margin-top: 0; }

.layers-panel { padding: 20px 24px; border-bottom: var(--line); }
.layers-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 21px; }
.layers-heading > #layer-count { color: var(--muted-soft); font-size: 14px; }
.layers-heading button { margin-left: auto; padding: 7px 10px; font-size: 16px; }
#layer-list { display: grid; gap: 6px; max-height: 270px; overflow: auto; }
.layer-row { display: flex; align-items: center; min-width: 0; border: 1px solid var(--border-soft); border-radius: 4px; }
.layer-row.selected { border-color: var(--ink); background: var(--selected); }
.layer-row .layer-select { flex: 1; min-width: 0; padding: 8px 10px; border: 0; text-align: left; }
.layer-name { display: block; overflow: hidden; font-size: 17px; white-space: nowrap; text-overflow: ellipsis; }
.layer-preview { display: block; overflow: hidden; color: var(--muted); font-size: 13px; white-space: nowrap; text-overflow: ellipsis; }
.layer-row .icon-action { min-width: 36px; min-height: 40px; padding: 7px; border: 0; }
.layer-row.hidden-layer .layer-select { opacity: .5; }
.layer-actions { display: flex; gap: 4px; margin: 12px 0 8px; }
.layer-actions button { min-width: 38px; padding: 7px; border: 0; }
.layer-actions #rename-layer { font-size: 15px; }
.layer-actions #delete-layer { margin-left: auto; }
.layers-panel .note { font-size: 13px; }
.layer-tools-disabled { opacity: .55; }

#selection-overlay { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
#selection-overlay[hidden] { display: none; }
.selection-outline { position: absolute; border: 1px solid var(--handle-line); box-shadow: 0 0 0 1px var(--selection-halo); transform-origin: center; pointer-events: none; }
.transform-handle { position: absolute; width: 12px; height: 12px; min-height: 12px; padding: 0; border: 1px solid var(--handle-line); border-radius: 2px; background: var(--handle-bg); transform: translate(-50%, -50%); pointer-events: auto; touch-action: none; }
.transform-handle:hover { background: var(--handle-hover) !important; }
.rotate-handle { width: 15px; height: 15px; min-height: 15px; border-radius: 50%; cursor: crosshair; }
.corner-handle { cursor: nwse-resize; }
.rotation-stem { position: absolute; height: 1px; background: var(--handle-line); transform-origin: left center; pointer-events: none; }
.snap-guides { position: absolute; inset: 0; pointer-events: none; }
.snap-guides[hidden] { display: none; }
.snap-guides span { position: absolute; display: block; }
.guide-x { border-left: 1px dashed var(--guide-line); }
.guide-y { border-top: 1px dashed var(--guide-line); }

#thermal-settings { display: grid; gap: 20px; }
#thermal-settings[hidden] { display: none !important; }
.advanced-controls { margin: 0; border: 1px solid var(--border-soft); border-radius: 4px; }
.advanced-controls summary { padding: 12px; font-size: 16px; }
.advanced-controls .parameter-group { padding: 4px 14px 16px; }
.advanced-panel [hidden] { display: none !important; }
.advanced-panel [data-show] { display: grid; gap: 22px; }
.inline-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.inline-controls > * { flex: 1; min-width: 0; }
.inline-controls select { margin-top: 0; }
.inline-controls button { font-size: 16px; }
.finish-row { display: flex; align-items: center; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--border-faint); }
.finish-row > span { flex: 1; font-size: 17px; }
.finish-row button { min-width: 34px; padding: 6px; border: 0; }
.advanced-panel meter { width: 100%; height: 22px; }
.advanced-panel input[type='range'] { width: 100%; }
.advanced-panel .colors { display: flex; justify-content: space-between; }
#before-after { user-select: none; -webkit-user-select: none; }
#before-after:active, [aria-pressed='true']#arm-brush, [aria-pressed='true']#record-pointer, [aria-pressed='true']#draw-path { background: var(--ink); color: var(--paper); }
.color-gradients { border: 1px solid var(--border-soft); border-radius: 4px; }
.color-gradients > summary { padding: 12px 14px; font-size: 17px; }
.gradient-options { display: grid; gap: 24px; padding: 0 14px 18px; }
.gradient-target { display: grid; gap: 20px; }
.gradient-target + .gradient-target { padding-top: 20px; border-top: 1px solid var(--border-faint); }
.gradient-options .colors { margin: 0; }
.gradient-options [hidden] { display: none !important; }
.gradient-preview { height: 30px; border: 1px solid var(--border-preview); border-radius: 3px; }
.gradient-options .note { font-size: 14px; }

footer { display: flex; justify-content: space-between; padding: 20px 36px; border-top: var(--line); font-size: 13px; letter-spacing: .3px; }
#toast { position: fixed; bottom: 25px; left: 50%; z-index: 10; padding: 13px 22px; border-radius: 4px; background: var(--ink); color: var(--paper); opacity: 0; transform: translateX(-50%); pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

@media (hover: hover) {
  button:hover:not(:disabled) { background-color: var(--hover); }
  .primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 0 0 1px var(--primary-hover); }
  .segments button.active:hover:not(:disabled) { background: var(--selected-hover); color: var(--paper); }
  .lock:hover:not(:disabled) { background: transparent; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
  summary:hover { background: var(--hover-soft); }
  summary button:hover:not(:disabled) { background: var(--hover-action); }
  select:hover, textarea:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--focus-halo); }
  .palettes button:hover:not(:disabled) { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--ink); }
  .brand:hover { color: var(--brand-hover); }
  .variant .restore:hover:not(:disabled), .variant .delete:hover:not(:disabled) { background: var(--hover-variant); }
}
@media (min-width: 851px) {
  html { height: 100%; overflow: hidden; }
  body { display: grid; grid-template-rows: 90px minmax(0, 1fr) auto; height: 100vh; height: 100dvh; overflow: hidden; }
  main { min-height: 0; overflow: hidden; align-items: stretch; }
  .workspace, aside { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
  aside { width: 100%; min-width: 0; }
  .aside-title { position: sticky; top: 0; z-index: 4; background: var(--paper); }
  .stage { height: clamp(260px, calc(100dvh - 360px), 900px); min-height: 0; }
  .stage:fullscreen { height: 100dvh; }
  footer { padding-top: 12px; padding-bottom: 12px; }
}
@media (min-width: 1500px) {
  main { grid-template-columns: minmax(0, 1fr) 400px; }
  .workspace { padding: 0 50px; }
}
@media (max-width: 1100px) {
  header { gap: 20px; padding: 0 24px; }
  .edition { display: none; }
  .workspace { padding: 0 20px; }
  .hint { display: none; }
  .transport { flex-wrap: wrap; gap: 8px 16px; }
  .explore { flex-wrap: wrap; }
  .explore > div { width: 100%; }
}
@media (max-width: 850px) {
  header { height: 75px; gap: 15px; padding: 0 18px; }
  header > .primary { margin-left: auto; }
  main { grid-template-columns: 1fr; }
  main, aside, .workspace { width: 100%; min-width: 0; }
  .workspace { padding: 0 18px; }
  .brand { font-size: 28px; }
  .subtitle { padding-left: 15px; font-size: 16px; }
  .stage { height: 65vh; min-height: 300px; padding: 58px 15px 15px; }
  .hint { display: none; }
  .transport { justify-content: space-between; }
  .explore > div { width: auto; }
  .explore button { padding: 10px; font-size: 17px; }
  aside { border-left: 0; border-top: var(--line); }
  footer { padding: 20px 18px; }
  footer span:nth-child(2) { display: none; }
}
@media (max-width: 600px) {
  header { flex-wrap: wrap; height: auto; min-height: 90px; gap: 8px 12px; padding: 16px 18px; }
  .brand { font-size: 29px; }
  .subtitle { order: 3; width: 100%; padding-left: 0; border-left: 0; }
  .explore > div { width: 100%; }
  .section-heading { gap: 10px 20px; }
  .section-heading > span { width: 100%; }
  .stage { padding-top: 55px; }
  .scene-tools { left: 15px; }
  .scene-tools button { font-size: 13px; }
  .layers-panel { padding: 18px 24px; }
  footer { font-size: 12px; }
}
@media (forced-colors: active) {
  select { appearance: auto; -webkit-appearance: auto; background-image: none; }
}
@media (prefers-reduced-motion: reduce) {
  button, a, summary, select, textarea, #toast { transition: none; }
}

/* Le panneau Calques partage le comportement des autres sections. */
details.layers-panel { padding: 0; }
summary.layers-heading { margin: 0; padding: 20px 24px; }
.layers-body { padding: 0 24px 20px; }

/* Même hauteur pour chaque section repliée, avec ou sans bouton dans le titre. */
aside details:not([open]) { height: 74px; }
aside .advanced-controls, aside .color-gradients { --section-border-width: 2px; }
aside details > summary,
aside summary.layers-heading,
aside .advanced-controls > summary,
aside .color-gradients > summary {
  height: calc(74px - var(--section-border-width, 1px));
  min-height: calc(74px - var(--section-border-width, 1px));
  margin: 0;
  padding: 0 24px;
  line-height: 1.3;
}

/* La caméra et les cadres de mise en situation appartiennent uniquement à l’aperçu. */
.stage { padding-bottom: 58px; }
.preview-viewport { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; }
.preview-scene { position: absolute; left: 50%; top: 50%; transform-origin: center; }
.preview-scene > .canvas-wrap { position: absolute; z-index: 1; min-width: 0; min-height: 0; }
#device-frame, #device-silhouette { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#device-frame { z-index: 2; fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
#device-frame * { vector-effect: non-scaling-stroke; }
#device-silhouette { z-index: 0; }
#device-frame[hidden], #device-silhouette[hidden] { display: none; }
.preview-modes { position: absolute; top: 10px; right: 24px; z-index: 4; display: flex; gap: 4px; }
.preview-modes button { display: inline-flex; align-items: center; justify-content: center; width: 36px; min-height: 34px; padding: 5px; background: var(--paper); }
.preview-modes button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.preview-zoom { position: absolute; bottom: 10px; left: 50%; z-index: 4; display: flex; align-items: center; gap: 3px; padding: 3px; border: var(--line); border-radius: 4px; background: var(--paper); transform: translateX(-50%); }
.preview-zoom button { min-height: 32px; padding: 4px 8px; border: 0; font-size: 15px; }
#zoom-in, #zoom-out { display: inline-flex; align-items: center; justify-content: center; width: 34px; }
#zoom-value { min-width: 56px; font-variant-numeric: tabular-nums; }
#zoom-fit { padding-inline: 12px; border-left: 1px solid var(--border-soft); border-radius: 0; }
.preview-viewport.panning, .preview-viewport.panning #canvas { cursor: grabbing !important; }
@media (hover: hover) {
  .preview-modes button[aria-pressed='true']:hover, .scene-tools button[aria-pressed='true']:hover { background: var(--selected-hover); color: var(--paper); }
}
@media (max-width: 650px) {
  .stage { padding-top: 72px; }
  .scene-tools, .preview-modes { top: 10px; gap: 0; padding: 2px; border: var(--line); border-radius: 6px; background: var(--paper); }
  .scene-tools { left: 10px; }
  .preview-modes { left: auto; right: 10px; }
  .scene-tools button, .preview-modes button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 3px; }
  .scene-tools button { font-size: 0; }
  .scene-tools button .icon, .preview-modes button .icon { width: 22px; height: 22px; margin: 0; }
}
.stage:fullscreen { padding-bottom: 58px; }
@media (max-width: 650px) {
  .stage:fullscreen { padding-top: 72px; }
}

/* Le thème ne change que l’interface, jamais les couleurs du moteur de rendu. */
.header-actions { display: flex; align-items: center; gap: 12px; }
#theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 8px; flex-shrink: 0; }
select option, select optgroup { background: var(--paper); color: var(--ink); }
input[type='checkbox'] { accent-color: var(--ink); }
@media (max-width: 1100px) { .header-actions { margin-left: auto; } }
@media (max-width: 600px) {
  .header-actions { gap: 6px; }
  .header-actions .primary { padding: 9px 10px; font-size: 15px; }
  #theme-toggle { width: 36px; min-height: 36px; height: 36px; padding: 5px; }
}

.perspective-outline { position:absolute; inset:0; width:100%; height:100%; overflow:visible; pointer-events:none; color:var(--handle-line); filter:drop-shadow(0 0 1px var(--selection-halo)); }

#orient-plane[aria-pressed='true'] { background:var(--ink); color:var(--paper); }
.preview-viewport.orienting, .preview-viewport.orienting #canvas, .preview-viewport.orienting .transform-handle { cursor:move !important; }
.orientation-hint { position:absolute; z-index:4; top:56px; left:50%; transform:translateX(-50%); max-width:calc(100% - 30px); padding:8px 14px; border:1px solid var(--ink); border-radius:3px; background:var(--paper); color:var(--ink); font-size:16px; text-align:center; pointer-events:none; }
.orientation-hint[hidden] { display:none; }

summary button[data-section-reset][hidden] { display: none; }

#video:disabled { opacity:1; cursor:progress; }

/* Sur mobile, les sections se consultent dans un tiroir de réglages. */
#settings-toggle { display: none; }
#mobile-settings { max-width: none; max-height: none; width: min(420px, 100%); height: 100dvh; margin: 0 0 0 auto; padding: 0; border: 0; background: var(--paper); color: var(--ink); overscroll-behavior: contain; }
#mobile-settings::backdrop { background: #0008; }
.settings-header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 8px; height: 70px; padding: 0 18px; border-bottom: var(--line); background: var(--paper); }
#settings-close { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 42px; height: 42px; min-height: 42px; padding: 8px; background: var(--paper); }
#mobile-settings[open] { animation: settings-enter 360ms cubic-bezier(.22, 1, .36, 1) both; }
#mobile-settings[open]::backdrop { animation: settings-shade-in 360ms ease both; }
#mobile-settings.closing { animation: settings-leave 240ms cubic-bezier(.4, 0, 1, 1) both; }
#mobile-settings.closing::backdrop { animation: settings-shade-out 240ms ease both; }
@keyframes settings-enter { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes settings-leave { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes settings-shade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes settings-shade-out { from { opacity: 1; } to { opacity: 0; } }
#mobile-settings aside { border: 0; }
html.settings-open { overflow: hidden; }
@media (max-width: 850px) {
  #preview-desktop { display: none; }
  body { padding-top: 70px; }
  header { position: fixed; inset: 0 0 auto; z-index: 6; height: 70px; min-height: 0; flex-wrap: nowrap; gap: 12px; padding: 0 18px; background: var(--paper); }
  header .subtitle { display: none; }
  header .brand { font-size: clamp(21px, 4.8vw, 28px); }
  .header-actions { margin-left: auto; flex-shrink: 0; gap: 8px; }
  #settings-toggle { order: 2; flex-shrink: 0; }
  main > aside { display: none; }
  #settings-toggle { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 8px; }
  #mobile-settings aside { display: block; }
}
@media (max-width: 600px) {
  .settings-header { padding-inline: 12px; }
  header { gap: 8px; padding-inline: 12px; }
  .header-actions #export .icon { display: none; }
  .settings-header #theme-toggle { width: 42px; height: 42px; min-height: 42px; padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  #mobile-settings[open], #mobile-settings[open]::backdrop { animation: none; }
}

footer { align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.footer-links { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.footer-links a { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; border-bottom: 1px solid transparent; transition: opacity 150ms ease, border-color 150ms ease; }
.footer-links a:hover { border-bottom-color: currentColor; opacity: .7; }
.footer-links a:focus-visible { outline: 2px solid currentColor; outline-offset: 5px; }
.footer-links .icon { width: 14px; height: 14px; }
