/* V24 / cold alloy. Elevation is reserved for the studio, controls and output. */
:root {
  color-scheme: dark;
  --safe-top: calc(max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: calc(max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
  --safe-left: calc(max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px)) + var(--tg-content-safe-area-inset-left, 0px));
  --safe-right: calc(max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px)) + var(--tg-content-safe-area-inset-right, 0px));
  --bg: #080b10; --stage: #0c121c; --surface: #151b24; --hover: #1d2837;
  --line: #ffffff18; --line-soft: #ffffff0d; --text: #edf3fc; --secondary: #b4c0d1; --muted: #8999af;
  --accent: #69aaff; --accent-hover: #a6d7ff; --on-accent: #fff; --danger: #ffadaf;
  --blue: #2462dd; --ice: #c9e5ff; --glass: #111b2bdd;
  --radius-sm: 7px; --radius: 11px; --radius-lg: 20px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --text-eyebrow: 10px; --text-xs: 11px; --text-sm: 12px; --text-label: 13px; --text-base: 14px;
  --text-heading-mobile: 23px; --text-lg: 28px; --control-height: 40px;
  --fast: 160ms; --motion: 280ms; --ease: cubic-bezier(.2,.7,.2,1);
  --bevel: inset 0 1px 0 #ffffff14, inset 0 -1px 0 #00000045;
  --float-shadow: 0 4px 12px #0005, inset 0 1px 0 #d9edff24;
  --workspace-height: clamp(690px, calc(100dvh - 112px), 860px);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: var(--text-base); line-height: 1.5; font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; padding: var(--safe-top) var(--safe-right) 0 var(--safe-left); min-width: 280px; color: var(--text); background: radial-gradient(ellipse at 35% -30%, #1c325650, transparent 63%), var(--bg); }
button, select, input { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: .42; }
button, a { touch-action: manipulation; }
button, select, summary { transition: background var(--fast), border-color var(--fast), color var(--fast), box-shadow var(--fast), transform var(--fast) var(--ease); }
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 3px; }
svg { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.app-header { max-width: 1440px; margin: auto; height: 80px; padding: 0 var(--s8); display: flex; align-items: center; gap: var(--s6); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: var(--ice); border: 1px solid #8ebeff39; border-radius: var(--radius-sm); background: linear-gradient(145deg, #60769388, #18263b 42%, #0e1420 62%, #29486c); box-shadow: var(--bevel), 0 0 18px #3983ff12; }
.brand-mark svg { width: 26px; height: 26px; stroke-width: 1.7; }
.brand-name { font-size: 16px; font-weight: 750; letter-spacing: -.03em; }
.brand-name > span { color: var(--secondary); font-weight: 450; margin-left: 3px; }
.app-context { padding-left: var(--s6); border-left: 1px solid var(--line); color: var(--muted); font-size: var(--text-label); }
.release-tag { margin-left: auto; font: 11px ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; color: var(--secondary); padding: 5px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--bevel); background: #ffffff03; }
.workspace { max-width: 1376px; margin: 0 auto var(--s8); display: grid; grid-template-columns: minmax(0, 1.27fr) minmax(375px, 1fr); align-items: start; border: 1px solid #9db5d32b; border-radius: var(--radius-lg); background: #10151e; box-shadow: 0 28px 80px #0005, inset 0 1px 0 #b2d7ff19; }
.viewer-slot { min-width: 0; height: var(--workspace-height); position: sticky; top: var(--s4); }
.viewer { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; border-radius: var(--radius-lg) 0 0 var(--radius-lg); background: radial-gradient(ellipse at 62% 43%, #1b3047 0%, #101d2b 35%, #090e17 78%); }
/* A static lightbox, not another animated canvas or a bloom post-process. */
.viewer::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1; background: linear-gradient(116deg, #b6dcff13, transparent 26% 77%, #2e79cb0c), linear-gradient(0deg, #03060bc9, transparent 24%); }
.viewer::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3; border-radius: inherit; box-shadow: inset 0 1px 0 #d7ecff33, inset 1px 0 0 #e6f5ff0c; }
.studio-light { position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(ellipse at 4% 15%, #377ed037, transparent 40%), radial-gradient(ellipse at 88% 76%, #2c66b01d, transparent 50%); }
.studio-light::before, .studio-light::after { content: ""; position: absolute; top: 14%; bottom: 15%; width: 1px; background: linear-gradient(transparent, #b7d8ff57 30%, #4068a733 80%, transparent); box-shadow: 0 0 20px 2px #3b83ed12; }
.studio-light::before { left: 7%; transform: rotate(12deg); }
.studio-light::after { right: 7%; transform: rotate(12deg); opacity: .35; }
#gl { position: relative; z-index: 1; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }
.character-caption { position: absolute; z-index: 2; top: var(--s6); left: var(--s6); display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.studio-kicker { color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .17em; }
.character-label { color: var(--ice); font-size: 17px; font-weight: 650; letter-spacing: .09em; }
.studio-signature { position: absolute; top: var(--s6); right: var(--s6); z-index: 2; color: #8da6c050; text-align: right; font-size: 22px; letter-spacing: -.075em; line-height: 1.1; font-weight: 800; pointer-events: none; }
.studio-signature span { display: block; font-size: 8px; font-weight: 500; letter-spacing: .22em; margin-top: 4px; }
.viewer-message { position: absolute; z-index: 4; top: 50%; left: 50%; transform: translate(-50%, -50%); width: max-content; max-width: 85%; background: #0b1426ee; color: var(--secondary); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4); text-align: center; font-size: var(--text-sm); pointer-events: none; box-shadow: var(--float-shadow); }
.viewer-actions { position: absolute; z-index: 4; bottom: max(var(--s5), var(--safe-bottom)); display: flex; gap: var(--s2); }
.viewer-actions-left { left: max(var(--s5), var(--safe-left)); }
.viewer-actions-right { right: max(var(--s5), var(--safe-right)); }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid #b6d5fc28; border-radius: var(--radius); color: var(--ice); background: linear-gradient(145deg, #7d9bb529, transparent 60%), var(--glass); box-shadow: var(--float-shadow); }
.icon-button svg { width: 19px; height: 19px; }
.icon-button[aria-pressed="true"] { color: #d3eaff; border-color: #699fec99; background: linear-gradient(145deg, #578dde70, #1a3762e8); box-shadow: var(--float-shadow), 0 0 16px #397eff17; }
.icon-button:active { transform: scale(.94); }
.playback-status { position: absolute; z-index: 2; bottom: var(--s8); left: 130px; right: 78px; display: flex; justify-content: center; align-items: center; gap: 7px; font-size: var(--text-xs); color: var(--muted); pointer-events: none; }
.status-light { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.playback-status[data-playing="true"] { color: var(--ice); }
.playback-status[data-playing="true"] .status-light { background: var(--accent); box-shadow: 0 0 7px #67afff80; }
#playbackLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer.expanded, .viewer:fullscreen { position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; z-index: 100; }
.viewer.expanded .character-caption { top: max(var(--s6), var(--safe-top)); left: max(var(--s6), var(--safe-left)); }
.viewer.expanded .studio-signature { top: max(var(--s6), var(--safe-top)); right: max(var(--s6), var(--safe-right)); }
.viewer.expanded .playback-status { bottom: max(var(--s8), calc(var(--safe-bottom) + 12px)); }
body.viewer-open { overflow: hidden; }
.customization { min-width: 0; height: var(--workspace-height); padding: var(--s8); display: flex; flex-direction: column; border-left: 1px solid #a1c0e219; border-radius: 0 var(--radius-lg) var(--radius-lg) 0; background: linear-gradient(140deg, #b7d9ff08, transparent 23%), linear-gradient(0deg, #090d14b0, #141b26c0); }
.panel-intro { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 0 0 var(--s6); }
.eyebrow { display: block; font: 10px ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .09em; color: var(--accent); margin-bottom: var(--s2); }
.eyebrow > span { color: #697c96; margin-left: var(--s2); }
h1 { font-size: var(--text-lg); letter-spacing: -.045em; line-height: 1.25; font-weight: 600; margin: 0; }
.selection-count { color: var(--secondary); font-size: var(--text-xs); padding: 5px 8px; white-space: nowrap; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #ffffff03; }
.selection-count[data-selected="true"] { color: var(--ice); border-color: #416a9c66; background: #2862a71a; }
.controls-scroll { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #344259 transparent; padding: var(--s1) var(--s1) var(--s2); margin: 0 calc(-1 * var(--s1)); }
.control-group { padding: var(--s4) 0; }
.control-row { position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: var(--s3); align-items: center; margin-bottom: 5px; }
.control-row:last-child { margin-bottom: 0; }
.control-row[data-category] { grid-template-columns: minmax(0, 1fr); }
.control-row[data-category] .block-reason { grid-column: 1 / -1; }
.control-row label { color: var(--secondary); font-size: var(--text-label); white-space: nowrap; }
.version-row { padding-bottom: var(--s4); border-bottom: 1px solid var(--line-soft); }
.version-row select { background: linear-gradient(110deg, #27334790, #161e2c); border-color: #99bde12b; box-shadow: var(--bevel); color: var(--ice); }
.select-wrap { position: relative; min-width: 0; }
select { width: 100%; min-width: 0; height: var(--control-height); appearance: none; border: 1px solid #ffffff08; background: #ffffff04; color: var(--text); padding: 0 var(--s8) 0 var(--s3); border-radius: var(--radius-sm); text-overflow: ellipsis; }
select:focus { border-color: var(--accent); }
select option { background: #172030; color: var(--text); }
.select-wrap > svg { pointer-events: none; width: 15px; height: 15px; position: absolute; right: var(--s3); top: 50%; transform: translateY(-50%); color: var(--muted); transition: color var(--fast); }
.select-wrap:focus-within > svg { color: var(--accent-hover); }
.control-row.has-selection select { background: linear-gradient(105deg, #26508e35, #15223866); border-color: #719adb30; color: var(--ice); }
.control-row.has-selection label { color: var(--text); }
.block-reason { grid-column: 2; margin: 0; font-size: var(--text-sm); color: var(--danger); overflow-wrap: anywhere; }
.group-heading { border-top: 1px solid var(--line); padding-top: var(--s4); display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--text-eyebrow); letter-spacing: .13em; font-weight: 600; }
.group-heading svg { width: 12px; height: 12px; margin-left: auto; color: var(--accent); }
#actionRows { padding: var(--s3) 0 0; }
.quiet-note { color: var(--muted); font-size: var(--text-sm); margin: var(--s2) 0 var(--s4); }
.secondary-actions { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; flex-wrap: wrap; }
.text-button { border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--secondary); padding: var(--s2); min-height: 40px; display: inline-flex; justify-content: center; align-items: center; gap: var(--s2); font-size: var(--text-label); }
.text-button svg { width: 15px; height: 15px; }
.text-button:active:not(:disabled) { transform: translateY(1px); }
.secondary-actions .text-button:first-child { margin-left: calc(-1 * var(--s2)); }
.selection-summary { margin-top: var(--s2); }
summary { cursor: pointer; color: var(--muted); font-size: var(--text-sm); }
.selection-summary > summary { display: flex; align-items: center; justify-content: space-between; padding: var(--s2) 0; list-style: none; }
summary::-webkit-details-marker { display: none; }
.selection-summary summary svg { width: 14px; height: 14px; transition: transform var(--motion) var(--ease); }
.selection-summary[open] summary svg { transform: rotate(180deg); }
.selection-summary p { font-size: var(--text-label); margin: var(--s2) 0; line-height: 1.7; color: var(--secondary); overflow-wrap: anywhere; }
.build-area { position: relative; border-top: 1px solid var(--line); margin-top: auto; padding-top: var(--s5); }
.build-area::before { content: ""; position: absolute; top: -1px; left: 0; width: 40%; height: 1px; background: linear-gradient(90deg, #6eafff7d, transparent); pointer-events: none; }
.build-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.primary-button { position: relative; overflow: hidden; isolation: isolate; min-height: 46px; min-width: 180px; border: 1px solid #77b4ff7a; border-radius: var(--radius); padding: 0 var(--s5); display: inline-flex; align-items: center; justify-content: center; gap: var(--s3); font-weight: 600; color: var(--on-accent); background: linear-gradient(175deg, #477fdd, #275fc9 50%, #1a479d); box-shadow: inset 0 1px 0 #d5eeff66, inset 0 -2px 1px #13376e90, 0 4px 18px #1c5ec521; }
.primary-button::before { content: ""; position: absolute; z-index: -1; inset: -10% -60%; transform: translateX(-70%) skewX(-20deg); background: linear-gradient(90deg, transparent 35%, #daeeff3b 50%, transparent 65%); transition: transform 650ms var(--ease); pointer-events: none; }
.primary-button svg { width: 18px; height: 18px; }
.primary-button:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 4px #09276399; }
#buildAll { border-color: var(--line); min-height: 44px; padding-inline: var(--s3); }
.progress { color: var(--secondary); font-size: var(--text-sm); margin-top: var(--s3); }
progress { appearance: none; width: 100%; height: 3px; border: 0; display: block; margin-top: var(--s2); border-radius: 2px; overflow: hidden; background: var(--line); accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); transition: width var(--motion); }
progress::-moz-progress-bar { background: var(--accent); }
progress:not([value]) { opacity: .6; }
.download { display: inline-block; color: var(--accent-hover); padding: var(--s3) 0; }
.error { margin: var(--s3) 0 0; color: var(--danger); font-size: var(--text-label); overflow-wrap: anywhere; }
.diagnostics { margin-top: var(--s2); }
.diagnostics pre { font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 140px; overflow: auto; color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .icon-button { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .icon-button:hover { border-color: #a6d7ff77; background-color: #264364db; transform: translateY(-2px); }
  select:hover:not(:disabled) { border-color: #90bfff42; background-color: var(--hover); }
  .text-button:hover:not(:disabled) { background: #8aaed912; color: var(--text); }
  .primary-button:hover:not(:disabled) { border-color: #b8e1ff; box-shadow: inset 0 1px 0 #e3f4ff80, 0 4px 24px #287cff3d; }
  .primary-button:hover:not(:disabled)::before, .primary-button:focus-visible::before { transform: translateX(70%) skewX(-20deg); }
}
@media (max-width: 1439px) and (min-width: 840px) { .workspace { margin-inline: var(--s8); } }
@media (min-width: 840px) and (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(365px, 1fr); margin-inline: var(--s5); }
  .customization { padding: var(--s6); }
  .panel-intro { align-items: flex-start; }
  .selection-count { font-size: 10px; }
  h1 { font-size: 25px; }
}
@media (max-width: 839px) {
  .app-header { height: 64px; padding-inline: var(--s4); gap: var(--s4); }
  .app-context { padding-left: var(--s4); font-size: var(--text-xs); }
  .brand-mark { width: 31px; height: 31px; }
  .brand-name { font-size: 14px; }
  .brand { gap: var(--s2); }
  .workspace { display: flex; flex-direction: column; margin: 0 var(--s3) max(var(--s5), var(--safe-bottom)); border-radius: var(--radius-lg); }
  .viewer-slot { width: 100%; position: static; height: clamp(300px, 48svh, 440px); }
  .viewer { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .character-caption { top: var(--s4); left: var(--s4); }
  .character-label { font-size: 14px; }
  .studio-signature { top: var(--s4); right: var(--s4); font-size: 19px; }
  .viewer-actions { bottom: var(--s3); }
  .viewer-actions-left { left: var(--s3); }
  .viewer-actions-right { right: var(--s3); }
  .playback-status { left: 120px; right: 66px; bottom: 26px; font-size: 10px; }
  .customization { width: 100%; height: auto; padding: var(--s5) var(--s4); border-left: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
  .panel-intro { padding-bottom: var(--s5); }
  h1 { font-size: var(--text-heading-mobile); }
  .eyebrow { font-size: 9px; margin-bottom: 6px; }
  .selection-count { font-size: 10px; }
  .controls-scroll { overflow: visible; }
  .control-row { grid-template-columns: 70px minmax(0, 1fr); gap: var(--s2); }
  select { --control-height: 44px; font-size: var(--text-base); }
  .control-row label { font-size: var(--text-label); }
  .build-area { margin-top: var(--s3); padding-top: var(--s4); }
  .build-actions { gap: var(--s3); }
  .primary-button { flex: 1; }
  #buildAll { flex: 1; white-space: nowrap; }
  .viewer.expanded .viewer-actions { bottom: max(var(--s4), var(--safe-bottom)); }
  .viewer.expanded .viewer-actions-left { left: max(var(--s4), var(--safe-left)); }
  .viewer.expanded .viewer-actions-right { right: max(var(--s4), var(--safe-right)); }
}
@media (max-width: 359px) {
  .workspace { margin-inline: var(--s2); }
  .customization { padding-inline: var(--s3); }
  .app-header { padding-inline: var(--s3); gap: var(--s3); }
  .app-context { display: none; }
  .control-row { grid-template-columns: 68px minmax(0, 1fr); }
  .panel-intro { gap: var(--s2); }
  h1 { font-size: 21px; }
  .selection-count { padding-inline: 6px; }
  .eyebrow > span { display: none; }
}
@media (max-height: 540px) and (orientation: landscape) and (min-width: 840px) {
  :root { --workspace-height: clamp(290px, calc(100dvh - 80px), 460px); }
  .app-header { height: 60px; }
  .customization { padding: var(--s5); }
  .panel-intro { padding-bottom: var(--s3); }
  .eyebrow { margin-bottom: var(--s1); }
  .build-area { padding-top: var(--s3); }
}
@media (max-height: 540px) and (orientation: landscape) and (max-width: 839px) {
  .viewer-slot { height: clamp(260px, calc(100svh - 80px), 360px); }
}
@media (prefers-reduced-motion: no-preference) {
  .workspace { animation: enter-studio 450ms var(--ease) both; }
  /* Keep transforms off the fixed viewer's ancestors: WebView fullscreen fallback
     must stay attached to the viewport, including during the entrance. */
  @keyframes enter-studio { from { opacity: 0; } to { opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .icon-button { backdrop-filter: none; -webkit-backdrop-filter: none; background: #16263e; }
  select { background: #192536; border-color: #69809c; }
  :root { --muted: #b1bfd1; --line: #ffffff50; }
}
@media (pointer: coarse) {
  #gl { touch-action: pan-y; }
  .viewer.expanded #gl { touch-action: none; }
}

/* V26 — native-inspired refinement of V24. No design-system dependency. */
:root {
  --bg: #090b0f;
  --stage: #090d13;
  --surface: #151a22;
  --hover: #242c39;
  --line: #ffffff16;
  --line-soft: #ffffff0a;
  --accent: #81aeff;
  --accent-hover: #c7dfff;
  --secondary: #adb8c9;
  --muted: #8996a8;
  --radius-sm: 13px;
  --radius: 17px;
  --radius-lg: 29px;
  --control-height: 46px;
  --workspace-height: clamp(660px, calc(100dvh - 52px), 858px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}
body {
  background: radial-gradient(ellipse 90% 70% at 25% -32%, #273a5826, transparent 78%), var(--bg);
}
.workspace {
  max-width: 1360px;
  grid-template-columns: minmax(0, 1.29fr) minmax(386px, 1fr);
  margin: clamp(16px, 3vh, 28px) auto 32px;
  border-radius: var(--radius-lg);
  border-color: #c1d6eb23;
  background: #121720;
  box-shadow: 0 28px 85px #0007, inset 0 1px #ffffff0f;
}
.viewer-slot { top: 12px; }
.viewer {
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: radial-gradient(ellipse at 55% 45%, #19232d 0%, #101720 36%, #080b10 84%);
}
.viewer::before {
  background: linear-gradient(115deg,#adccdd0b,transparent 40%),linear-gradient(to top,#04070bb6,transparent 28%);
}
.viewer::after { box-shadow: inset 0 1px 0 #c6d8e525, inset 1px 0 0 #ffffff0b; }
.studio-light { opacity: .55; }
.character-caption { top: 22px; left: 24px; }
.character-label { font-size: 17px; font-weight: 660; letter-spacing: .025em; color: #e5edf6; }
.viewer-actions { bottom: 20px; gap: 9px; }
.viewer-actions-left { left: 20px; }
.viewer-actions-right { right: 20px; }
.icon-button {
  width: 44px; height: 44px;
  border-radius: 16px;
  border-color: #d0dfec27;
  color: #deebfc;
  background: linear-gradient(155deg,#c6dff616,transparent 65%),#171e28d9;
  box-shadow: 0 5px 18px #0006, inset 0 1px 0 #fff2;
}
.icon-button[aria-pressed="true"] {
  background: linear-gradient(155deg,#739dea66,#253d6dcd);
  border-color: #85b6ff78;
  box-shadow: 0 4px 14px #03081494, inset 0 1px #e7f5ff33;
}
.customization {
  padding: 24px 27px 26px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background: linear-gradient(145deg,#c9e1ff09,transparent 30%),linear-gradient(180deg,#171d27,#111720);
}
.panel-intro { justify-content: flex-end; min-height: 50px; padding-bottom: 15px; }
.outfit-quick-actions { display: flex; gap: 8px; align-items: center; }
.quick-action, .sheet-close {
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  border: 1px solid #e5efff20;
  border-radius: 14px;
  color: #c9d5e5;
  background: linear-gradient(150deg,#ffffff0b,#ffffff04);
  box-shadow: inset 0 1px #fff0000a, 0 1px 8px #0002;
}
.quick-action svg, .sheet-close svg { width: 19px; height: 19px; }
.quick-action:active:not(:disabled), .sheet-close:active { transform: scale(.93); }
.controls-scroll { padding: 0 3px 5px; margin: 0 -3px; }
.control-group { padding: 0; }
.control-row {
  display: grid;
  grid-template-columns: minmax(108px, .35fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 9px;
  align-items: center;
}
#actionRows { padding: 0; }
.control-row label {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: #b8c4d3;
  font-size: 13px;
  font-weight: 520;
  white-space: nowrap;
  min-width: 0;
}
.category-icon {
  width: 19px; height: 19px;
  flex: 0 0 19px;
  color: #9aaec4;
  stroke-width: 1.65;
}
.control-row.has-selection .category-icon { color: #accaff; }
.select-wrap { min-width: 0; }
select {
  height: var(--control-height);
  padding-inline: 14px 37px;
  background: #0e141eac;
  border: 1px solid #d0e1f21d;
  border-radius: 15px;
  font-size: 13.5px;
  font-weight: 460;
  box-shadow: inset 0 1px #ffffff07, 0 1px 1px #0001;
}
select:focus { border-color: #a0c6fc80; box-shadow: 0 0 0 3px #6799dd15; }
.control-row.has-selection select {
  background: linear-gradient(110deg,#2e4c7a36,#111b2d80);
  border-color: #8cadde49;
  color: #edf4ff;
}
.select-wrap > svg { right: 13px; width: 15px; height: 15px; }
.block-reason { font-size: 11px; padding-bottom: 3px; }
.build-area { margin-top: auto; padding-top: 19px; }
.build-area::before { width: 0; }
.build-actions { display: block; }
.primary-button {
  width: 100%; min-height: 51px; min-width: 0;
  border-radius: 17px;
  border: 1px solid #9bc2fa72;
  font-size: 14px; font-weight: 650; letter-spacing: .005em;
  background: linear-gradient(180deg,#4d84da 0%,#3068ca 48%,#2454ac 100%);
  box-shadow: inset 0 1px 0 #f2f9ff51, 0 6px 18px #173f8f3d;
}
.primary-button::before { opacity: .35; }
.primary-button svg { width: 19px; height: 19px; }
.primary-button .build-chevron { width: 17px; height: 17px; position: absolute; right: 18px; opacity: .9; }
.primary-button:active:not(:disabled) { transform: scale(.992); }
.progress { margin-top: 14px; }
@media (hover:hover) and (pointer:fine) {
  .quick-action:hover:not(:disabled), .sheet-close:hover { background: #32405580; border-color: #c1d8ed55; color: #fff; }
  .icon-button:hover { background-color: #263344f0; transform: translateY(-1px); }
  select:hover:not(:disabled) { background: #1b2431; border-color: #9ab9e14f; }
}
/* Action sheet: compact desktop dialog, edge-docked and safe-area aware on mobile. */
body.sheet-open { overflow: hidden; }
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #020509b8;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: sheet-dim 190ms ease-out both;
}
.build-sheet {
  width: min(100%, 432px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #edf5ff2d;
  border-radius: 29px;
  padding: 9px 12px 12px;
  background: linear-gradient(160deg,#242c38,#181e28 62%,#161c26);
  box-shadow: 0 36px 110px #000b,inset 0 1px 0 #fff2;
  animation: sheet-rise 300ms var(--ease) both;
}
.sheet-handle { width: 38px; height: 5px; margin: 2px auto 9px; border-radius: 6px; background: #a2aeba63; touch-action: none; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 10px 10px 15px; }
.sheet-header h2 { margin: 0; font-size: 18px; font-weight: 660; letter-spacing: -.025em; line-height: 1.3; }
.sheet-header p { margin: 5px 0 0; font-size: 12px; line-height: 1.5; color: #9eacbc; }
.sheet-close { width: 32px; height: 32px; border-radius: 11px; flex-shrink: 0; }
.sheet-close svg { width: 15px; height: 15px; }
.sheet-options { border: 1px solid #ffffff10; padding: 5px; border-radius: 19px; background: #090f1775; }
.sheet-option {
  width: 100%; min-height: 51px; border: 0; border-radius: 13px;
  padding: 11px 13px; display: flex; align-items: center; justify-content: space-between;
  gap: 15px; background: transparent; color: #ebf1fa;
  font-size: 14px; font-weight: 510; text-align: left;
}
.sheet-option + .sheet-option { border-top: 1px solid #ffffff0c; }
.sheet-option svg { width: 17px; height: 17px; color: #8c9db0; }
.sheet-option-all { color: #bed7ff; font-weight: 640; }
.sheet-option:active { background: #ffffff14; transform: scale(.994); }
.audio-choice { margin: 14px 5px 2px; }
.audio-choice > p:first-child { margin: 0 7px 8px; font-size: 13px; color: #bccbdd; }
.audio-option { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 5px 0; padding: 10px 12px; border: 1px solid #ffffff18; border-radius: 12px; color: #dce8f7; background: #0b101b60; text-align: left; font-size: 13px; }
.audio-option[aria-pressed="true"] { border-color: #80b8ff90; background: #3874ac32; }
.audio-option span { opacity: 0; }
.audio-option[aria-pressed="true"] span { opacity: 1; }
.audio-option:disabled { opacity: .45; cursor: not-allowed; }
.audio-help { margin: 8px 7px 0; color: #9eacbc; font-size: 11px; line-height: 1.5; }
.sheet-cancel {
  display: block; width: 100%; min-height: 49px; margin-top: 10px;
  border: 1px solid #ffffff10; border-radius: 16px;
  background: #ffffff0c; color: #eef3fa; font-size: 14px; font-weight: 600;
}
@media (hover:hover) and (pointer:fine) {
  .sheet-option:hover { background: #c8dfff13; }
  .sheet-cancel:hover { background: #ffffff17; }
}
@keyframes sheet-dim { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-rise { from { opacity: .85; transform: translateY(15px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@supports (corner-shape: squircle) {
  .workspace, .viewer, .customization, .icon-button, .quick-action, select, .primary-button,
  .build-sheet, .sheet-options, .sheet-option, .sheet-cancel, .sheet-close { corner-shape: squircle; }
}
@media (max-width: 1439px) and (min-width: 840px) { .workspace { margin-inline: clamp(16px,3vw,36px); } }
@media (min-width: 840px) and (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(370px, .95fr); }
  .customization { padding: 24px 20px; }
  .control-row { grid-template-columns: 110px minmax(0,1fr); }
}
@media (max-width: 839px) {
  .workspace { margin: 10px 12px max(20px,var(--safe-bottom)); border-radius: 25px; }
  .viewer-slot { height: clamp(305px, 46svh, 425px); }
  .viewer { border-radius: 25px 25px 0 0; }
  .character-caption { top: 18px; left: 18px; }
  .character-label { font-size: 15px; }
  .viewer-actions { bottom: 12px; }
  .viewer-actions-left { left: 12px; }
  .viewer-actions-right { right: 12px; }
  .customization { height: auto; padding: 15px 17px 21px; border-radius: 0 0 25px 25px; }
  .panel-intro { min-height: 46px; padding-bottom: 13px; }
  .quick-action { width: 41px; height: 41px; }
  .control-row { grid-template-columns: 110px minmax(0,1fr); gap: 9px; margin-bottom: 9px; }
  .control-row label { font-size: 13px; gap: 8px; }
  select { --control-height: 45px; font-size: 13px; }
  .build-area { padding-top: 16px; }
  .primary-button { min-height: 51px; }
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .build-sheet { width: 100%; max-height: calc(100dvh - max(20px,var(--safe-top))); border-radius: 28px 28px 0 0; padding: 9px 14px max(14px, var(--safe-bottom)); border-bottom: none; }
  .sheet-header { padding-bottom: 14px; }
  .sheet-option { min-height: 51px; }
  .sheet-cancel { min-height: 51px; }
  @keyframes sheet-rise { from { transform: translateY(60px); opacity: .85; } to { transform: translateY(0); opacity: 1; } }
}
@media (max-width: 359px) {
  .workspace { margin-inline: 8px; }
  .customization { padding-inline: 12px; }
  .control-row { grid-template-columns: 96px minmax(0,1fr); gap: 6px; }
  .control-row label { font-size: 12px; gap: 7px; }
  .category-icon { width: 17px; height: 17px; flex-basis: 17px; }
}
@media (max-height: 540px) and (orientation: landscape) and (min-width: 840px) {
  :root { --workspace-height: max(350px,calc(100dvh - 28px)); }
}
@media (prefers-reduced-motion:reduce) {
  .sheet-backdrop,.build-sheet { animation: none; }
}

/* Larger grab area without a visually bulky drag indicator. */
.sheet-handle { position: relative; width: 78px; height: 17px; margin-top: -2px; margin-bottom: 1px; background: transparent; cursor: grab; }
.sheet-handle::before { content:""; position:absolute; top:7px; left:20px; right:20px; height:5px; border-radius:8px; background:#a2aeba63; }

/* V26.1 — native control geometry.
   Contextual radius system: buttons/selects are true capsules, while nested
   panels shrink their radii along with their inset. No runtime CSS library. */
:root {
  --native-radius-panel: 30px;
  --native-radius-sheet: 30px;
  --native-radius-sheet-list: 21px;
  --native-radius-sheet-option: 15px;
  --native-row-gap: 10px;
  --native-group-gap: 15px;
  --native-primary-height: 52px;
  --control-height: 48px;
}

/* Selector geometry: 48px tall / 24px radius. The inset chevron belongs to
   the capsule; the arrow itself stays fixed and centered. */
select {
  height: var(--control-height);
  border-radius: calc(var(--control-height) / 2);
  padding-inline: 17px 42px;
}
.select-wrap > svg { right: 17px; }

/* Rows are one continuous rhythm. V26 previously removed the bottom margin
   of Skin and overrode #actionRows' top padding: that collapsed the gap. */
#categoryRows, #actionRows {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--native-row-gap);
  padding: 0;
}
.control-row, .control-row:last-child { margin-bottom: 0; }
#actionRows { margin-top: var(--native-group-gap); }

/* One 52px capsule, rather than a rounded rectangle. */
.primary-button {
  height: var(--native-primary-height);
  min-height: var(--native-primary-height);
  border-radius: calc(var(--native-primary-height) / 2);
}

/* The shared surface makes two independent controls read as one island.
   The 44px segments maintain touch targets without separate floating boxes. */
.control-island {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0;
  padding: 2px;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #d1e4f233;
  border-radius: 999px;
  background: linear-gradient(153deg, #f0f7ff15, #ffffff04 55%), #17202bdc;
  box-shadow: 0 5px 18px #0006, inset 0 1px 0 #ffffff20;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.outfit-quick-actions { gap: 0; }
.viewer-actions-left { gap: 0; }
.control-island > :is(.quick-action, .icon-button) {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  position: relative;
  border: 0;
  border-radius: 0;
  color: #d6e2f0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: none;
}
.control-island > :is(.quick-action, .icon-button):first-child {
  border-radius: 999px 0 0 999px;
}
.control-island > :is(.quick-action, .icon-button):last-child {
  border-radius: 0 999px 999px 0;
}
.control-island > :is(.quick-action, .icon-button) + :is(.quick-action, .icon-button)::before {
  content: '';
  position: absolute;
  width: 1px;
  height: 21px;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(to bottom, transparent, #d7e8fa36 23% 77%, transparent);
  pointer-events: none;
}
.control-island > .icon-button[aria-pressed="true"] {
  color: #f2f8ff;
  background: linear-gradient(155deg, #7098d650, #34547e43);
  box-shadow: inset 0 1px #e7f5ff14;
}
.control-island > :is(.quick-action, .icon-button):active:not(:disabled) {
  transform: none;
  background-color: #accfff21;
}
/* Focus must remain visible even though the shared glass clips its children. */
.control-island > :is(.quick-action, .icon-button):focus-visible {
  z-index: 1;
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-hover);
}
/* The ungrouped fullscreen button belongs to the same 44px family. */
.viewer-actions-right .icon-button {
  border-radius: 50%;
}

/* Large panels keep smooth but non-capsule curves; nested radii account for
   the sheet's 12px padding and the options' 6px internal padding. */
.workspace { border-radius: var(--native-radius-panel); }
.viewer { border-radius: var(--native-radius-panel) 0 0 var(--native-radius-panel); }
.customization { border-radius: 0 var(--native-radius-panel) var(--native-radius-panel) 0; }
.build-sheet { border-radius: var(--native-radius-sheet); }
.sheet-options { border-radius: var(--native-radius-sheet-list); padding: 6px; }
.sheet-option { border-radius: var(--native-radius-sheet-option); }
.sheet-close { width: 44px; height: 44px; border-radius: 50%; }
.sheet-cancel { min-height: 52px; border-radius: 26px; }

@media (hover: hover) and (pointer: fine) {
  .control-island > :is(.quick-action, .icon-button):hover:not(:disabled) {
    color: #f5faff;
    background: #b6d6ff18;
    transform: none;
  }
  .control-island > .icon-button[aria-pressed="true"]:hover:not(:disabled) {
    background: linear-gradient(155deg,#85aeeb67,#395f9654);
  }
}
@media (max-width: 839px) {
  :root { --control-height: 46px; --native-row-gap: 10px; --native-group-gap: 15px; }
  /* Override V26's select-local 45px token, not only the root token. */
  select { --control-height: 46px; }
  .workspace { border-radius: 26px; }
  .viewer { border-radius: 26px 26px 0 0; }
  .customization { border-radius: 0 0 26px 26px; }
  /* Keep identical 44px targets in the shared islands on mobile. */
  .outfit-quick-actions > .quick-action { width: 44px; height: 44px; }
  .build-sheet { border-radius: 29px 29px 0 0; }
}
/* Chromium's corner-shape feature is optional. It must never turn true
   capsules into squircles, so apply it only to large/medium surfaces. */
@supports (corner-shape: squircle) {
  .control-island, .control-island > :is(.quick-action,.icon-button),
  .viewer-actions-right .icon-button, select, .primary-button,
  .sheet-cancel, .sheet-close { corner-shape: round; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .control-island { background: #1c2c40; backdrop-filter: none; -webkit-backdrop-filter: none; border-color: #7797bd; }
}

/* Build queue action: unobtrusive cancellation on the existing V26.1 surface. */
.cancel-build { margin-top: 9px; border: 1px solid var(--line); border-radius: 999px; min-height: 36px; padding: 0 14px; color: var(--secondary); background: transparent; font: inherit; cursor: pointer; }
.cancel-build:hover { color: var(--text); background: var(--surface); }
.cancel-build:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cancel-build[hidden] { display: none; }

/* V26.4 — image-first outfit picker. Existing V26.1 control proportions
   and all existing build/preview behaviors remain unchanged. */
.picker-native-select { display: none !important; }
.item-select-wrap { display: block; }
.picker-trigger {
  display: flex; align-items: center; gap: 11px;
  width: 100%; min-width: 0; height: var(--control-height);
  border: 1px solid #a9c5e324; border-radius: calc(var(--control-height) / 2);
  background: linear-gradient(110deg,#25344b5c,#131a26c2);
  color: var(--text); text-align: left; padding: 4px 15px 4px 5px;
  transition: border-color .16s ease, background-color .16s ease;
}
.picker-trigger:disabled { opacity: .48; cursor: not-allowed; }
.picker-trigger:not(:disabled):hover { border-color: #88b4eb7a; background-color: #27394d; }
.picker-trigger:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.picker-trigger .chosen-icon {
  flex: 0 0 calc(var(--control-height) - 10px);
  width: calc(var(--control-height) - 10px); height: calc(var(--control-height) - 10px);
  display: grid; place-items: center; overflow: hidden; border-radius: 50%;
  background: #243042; border: 1px solid #98b2d321;
}
.picker-trigger .chosen-icon img { width: 100%; height: 100%; object-fit: contain; }
.picker-trigger .chosen-icon svg { width: 18px; height: 18px; color: #a6b7ce; }
.picker-trigger .chosen-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.picker-trigger > svg:last-child { width: 16px; height: 16px; flex: 0 0 16px; color: #8fa5c1; }
.control-row.has-selection .picker-trigger { border-color: #719adb70; color: var(--ice); background: linear-gradient(105deg, #26508e45, #15223888); }
.item-select-wrap > svg { display: none; }

.picker-backdrop { z-index: 260; }
.item-picker-sheet {
  width: min(100%, 560px);
  height: min(81dvh, 760px);
  min-height: min(425px, 85dvh);
  overflow: hidden; display: flex; flex-direction: column;
  padding: 8px 16px 14px;
  border: 1px solid #e2eeff27; border-radius: 30px;
  color: var(--text);
  background: linear-gradient(145deg,#263245b0,transparent 30%), #121923;
  box-shadow: 0 24px 80px #000b, inset 0 1px 0 #ffffff16;
}
.picker-header { flex: 0 0 auto; display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 4px 0 13px; }
.picker-header h2 { margin: 0 0 4px; font-size: 19px; font-weight: 650; letter-spacing: -.035em; }
.picker-header p { color: var(--muted); font-size: 12px; margin: 0; }
.picker-search-wrap { position: relative; flex: 0 0 auto; margin: 0 0 14px; }
.picker-search-wrap > svg { position: absolute; width: 18px; height: 18px; left: 15px; top: 50%; transform: translateY(-50%); color: #8ea6c2; pointer-events: none; }
.picker-search-wrap input {
  width: 100%; min-width: 0; min-height: 46px; padding: 0 16px 0 43px;
  font: inherit; font-size: 14px; color: var(--text);
  background: #090f18; border: 1px solid #b0d1ff26; border-radius: 23px;
  -webkit-appearance: none; appearance: none;
}
.picker-search-wrap input:focus { border-color: #83b7f0a0; outline: none; }
.picker-grid {
  min-height: 0; flex: 1 1 auto; overflow: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  grid-auto-rows: min-content; align-content: start; gap: 10px;
  padding: 2px 3px 10px;
  scrollbar-width: thin; scrollbar-color: #455875 transparent;
}
.item-card {
  position: relative; min-width: 0; min-height: 128px;
  padding: 9px 5px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 1px solid #a7c8e525; border-radius: 19px;
  background: #1e293855; color: #d9e4f1;
  text-align: center; font: inherit;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.item-card .item-art {
  width: min(100%, 86px); aspect-ratio: 1;
  display: grid; place-items: center; overflow: hidden;
  border-radius: 15px; background: linear-gradient(155deg,#33445c,#192433);
}
.item-card .item-art img { width: 100%; height: 100%; object-fit: contain; }
.item-card .item-art svg { width: 35px; height: 35px; color: #8296b5; }
.item-card .item-title { width: 100%; font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card.is-selected { color: #f5faff; background: #2e559044; border-color: #91c1ffae; box-shadow: inset 0 0 0 1px #76adf936; }
.item-card.is-selected::after { content:'✓'; position:absolute; right:6px; top:5px; width:19px; height:19px; border-radius:50%; display:grid; place-items:center; background:#4c82ce; color:white; font-size:12px; box-shadow: 0 2px 6px #0007; }
.item-card:focus-visible { outline: 2px solid #b1d9ff; outline-offset: 1px; }
.item-card:active { transform: scale(.98); }
.picker-sentinel { grid-column: 1 / -1; height: 1px; pointer-events: none; }
@media(hover:hover) and (pointer:fine) { .item-card:hover { background: #344760a6; border-color: #91b4e264; } }
@media(max-width:839px) {
  .item-picker-sheet { width: 100%; height: min(84dvh, 790px); min-height: min(390px, 84dvh); border-radius: 29px 29px 0 0; border-bottom: none; padding: 8px 13px max(13px,var(--safe-bottom)); }
  .picker-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
  .item-card { min-height: 120px; }
  .item-card .item-art { width: min(100%, 80px); }
}
@media(max-width:359px) { .picker-grid { gap: 7px; } .item-card { padding: 7px 3px; } }
@media(prefers-reduced-motion: reduce) { .item-card { transition: none; } }
