/* Editing workspace: the viewport retains its own bounds; the mobile tray is a separate row. */
/* Hair gestures must not start Safari text selection or image/link callouts. */
body:has(#stage) main,body:has(#stage) main *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
body:has(#stage) main img,body:has(#stage) main a{-webkit-user-drag:none}
body:has(#stage):not([data-mode=hero]){--st-button-fill:#fff;--st-button-hover:#f0eaff;--st-button-ink:#11132f;--st-focus:#6932ff;--st-line:#e5e5ec;--st-soft:#eee6ff;--st-muted:#596777;--rail-width:clamp(240px,21vw,320px);--edge:clamp(18px,2vw,32px);--tool-height:clamp(76px,12vh,118px)}
body:not([data-mode=hero]) main:has(#stage){position:relative;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);min-height:700px}
body:not([data-mode=hero]) main>header{grid-column:1;grid-row:1;grid-template-columns:minmax(0,1fr) minmax(180px,380px) minmax(0,1fr);padding:10px var(--edge);background:#fffefd;border-bottom:1px solid #e8e7ec;gap:16px}
body:not([data-mode=hero]) .viewer-brand .brand-name{display:none}
body:not([data-mode=hero]) .viewer-brand .brand-mark{width:42px;height:42px}
body:not([data-mode=hero]) #hairstyle{grid-column:2;grid-row:1;justify-self:stretch;width:100%;max-width:none;height:44px;min-height:44px;padding:8px 38px;text-align:center;text-align-last:center;font-size:16px;background-color:#fff;color:#11132f;border:1.5px solid #b8bfcb;border-radius:999px;appearance:none;background-size:20px;background-position:right 14px center;background-repeat:no-repeat}
body:not([data-mode=hero]) #stage{--viewer-framing:1.12;grid-column:1;grid-row:2;background:linear-gradient(to bottom,#cececf 0%,#d3d3d4 66.2%,#dadadb 66.2%,#dededf 100%)}
body:not([data-mode=hero]) #model-loader{--scan-size:min(70cqw,77.7cqh)}
body:has(#stage):not([data-mode=hero]) #hairstyle{border-color:#b8bfcb;background-image:url('/viewer-chevron.svg')}
#hairstyle:focus,#hairstyle:focus-visible{outline:none}
.viewer-tools{grid-column:1;grid-row:2;align-self:start;justify-self:end;z-index:3;margin:110px var(--edge) 0 0;width:var(--rail-width);padding:14px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;border-radius:22px;background:#fffdfbf5;box-shadow:0 8px 26px #27304409}
.viewer-simulation{grid-column:1 / -1;margin:0;padding:5px 10px;border-radius:8px;background:#eee6ff;color:#4b3581;text-align:center;font-size:12px;line-height:1.4}
.viewer-tools .tool{width:100%;min-height:var(--tool-height);padding:12px 4px;gap:7px;justify-content:center;border:1px solid #ececf1;border-radius:17px;background:#fff!important;color:#11132f;font-weight:400;box-shadow:0 3px 12px #27304406}
.viewer-tools .tool-icon,.viewer-history .tool-icon{width:44px;height:44px;padding:0;background:none;border:0;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none}
.viewer-tools .tool-icon svg{width:40px;height:40px}
.viewer-tools #auto-section .tool-icon svg{width:39px;height:44px}
.viewer-tools .tool-label{font-size:15px;line-height:1.2;text-shadow:none;color:inherit}
.viewer-tools .tool[aria-pressed=true]{background:#eee6ff!important;border-color:#eee6ff;color:#6932ff}
.viewer-tools .tool[aria-pressed=true] .tool-label{color:#281573}
.viewer-tools .tool[aria-pressed=true] .tool-icon{background:none;border:0;box-shadow:none}
.viewer-tools .tool[aria-pressed=true] .tool-icon:after{display:none}
/* Touch browsers retain :hover after a tap; only actual tool state may stay highlighted. */
@media(hover:hover) and (pointer:fine){.viewer-tools .tool:hover:not(:disabled):not([aria-pressed=true]){background:#f5f0ff!important;border-color:#d7c7fa;color:#6932ff}}
.viewer-history{position:absolute;top:22px;left:var(--edge);display:flex;gap:14px;z-index:3}
.viewer-history .tool{width:48px;min-height:48px;height:48px;padding:8px;justify-content:center;background:#fff!important;color:#11132f;border:1px solid #efeff3;border-radius:13px;box-shadow:0 3px 12px #27304406}
.viewer-history .tool-icon{width:28px;height:28px}
.viewer-history .tool-icon svg{width:26px;height:26px}
.viewer-history .tool-label{display:none}
@media(hover:hover) and (pointer:fine){.viewer-history .tool:hover:not(:disabled){background:#eee6ff!important;color:#6932ff}}
.viewer-create{position:absolute;top:22px;right:var(--edge);z-index:3;display:flex;align-items:center;justify-content:center;gap:14px;width:var(--rail-width);min-height:64px;padding:14px 18px;color:white;background:linear-gradient(110deg,#6932ff,#5924f5);border-radius:18px;text-decoration:none;font-size:22px;font-weight:600;box-shadow:0 5px 18px #6030e512;white-space:nowrap}
@media(hover:hover) and (pointer:fine){.viewer-create:hover{color:white;background:#5622df}}
.viewer-create span{color:inherit}
.create-sparkle{width:36px;height:36px;flex-shrink:0}
body:not([data-mode=hero]) .camera-controls{left:var(--edge);bottom:34px;grid-template-columns:repeat(3,48px);gap:5px}
body:not([data-mode=hero]) .camera-controls button{width:48px;height:48px;min-height:48px;padding:10px;background:#fff;color:#11132f;border:1px solid #efeff3;border-radius:13px;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none}
.camera-controls button{display:grid;place-items:center}
.camera-controls button svg{display:block;width:100%;height:100%}
.viewer-tools .tool-icon svg,.viewer-history .tool-icon svg{display:block}
body:not([data-mode=hero]) .camera-controls button.keyboard-active{background:#eee6ff;color:#6932ff}
@media(hover:hover) and (pointer:fine){body:not([data-mode=hero]) .camera-controls button:hover{background:#eee6ff;color:#6932ff}}
.control-caption{color:#596777;font-size:16px;line-height:22px;font-weight:400;text-align:center}
.camera-controls .control-caption{grid-column:1 / -1;margin-top:6px}
body:not([data-mode=hero]) .joystick-control{bottom:34px!important;right:calc(var(--edge) + (var(--rail-width) - 116px)/2);gap:8px}
body:not([data-mode=hero]) .joystick{width:116px;height:116px;--travel:33px;background:radial-gradient(circle at 40% 25%,#fff,#f6f6f8 75%);border:4px solid white;outline:1px solid #bec2c9;box-shadow:0 3px 14px #27304412}
body:not([data-mode=hero]) .joystick.active{outline:2px solid #6932ff}
body:not([data-mode=hero]) .joystick-knob{width:43px;height:43px;border:1px solid #fff;background:linear-gradient(155deg,#c8cbd0,#899198);box-shadow:0 0 0 1px #a7acb5,0 3px 6px #252d3c33,inset 0 1px 3px #fff8}
body:not([data-mode=hero]) .joystick-ticks i{background:#11132f;box-shadow:none}
body:not([data-mode=hero]) :is(#clipper-menu,#grab-menu),body:not([data-mode=hero]) :is(#clipper-size,#grab-size){top:22px;bottom:auto;right:calc(var(--rail-width) + var(--edge) + 16px);left:auto;background:#fff;color:#11132f;border-color:#e5e5ec;border-radius:12px}
body:not([data-mode=hero]) :is(#clipper-menu,#grab-menu){width:min(330px,calc(100% - var(--rail-width) - 190px));box-shadow:0 5px 20px #27304417}
body:not([data-mode=hero]) :is(#clipper-menu,#grab-menu) input{accent-color:#6932ff}
body:not([data-mode=hero]) :is(#clipper-done,#grab-done){background:#eee6ff;color:#5924d8;border:0}
@media(max-width:700px){
 body:has(#stage):not([data-mode=hero]){--edge:16px;overflow-y:auto;--tool-height:68px}
 body:not([data-mode=hero]) main:has(#stage){grid-template-rows:auto minmax(400px,1fr) auto;min-height:700px}
 body:not([data-mode=hero]) #stage{--viewer-framing:1.15;--viewer-lift:.06}
 body:not([data-mode=hero]) #model-loader{--scan-size:min(68.2cqw,75.7cqh)}
 body:not([data-mode=hero]) #model-loader img{top:44%}
 body:not([data-mode=hero]) main>header{grid-template-columns:36px minmax(0,1fr);gap:16px;padding:10px 16px;padding-top:max(10px,env(safe-area-inset-top))}
 body:not([data-mode=hero]) .viewer-brand .brand-mark{width:34px;height:34px;border-radius:8px}
 body:not([data-mode=hero]) #hairstyle{height:42px;min-height:42px;font-size:16px;padding:8px 30px;background-size:18px;background-position:right 12px center}
 body:not([data-mode=hero]) .header-actions{grid-column:1 / -1;grid-row:2;justify-self:end}
 .viewer-tools{grid-row:3;align-self:stretch;justify-self:stretch;width:auto;margin:0;padding:12px 16px max(18px,env(safe-area-inset-bottom));grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;border-radius:20px 20px 0 0;box-shadow:none;background:#fffdfb}
 .viewer-tools .tool{padding:8px 3px;gap:5px;border-radius:15px}
 .viewer-tools .tool-icon{width:32px;height:32px}
 .viewer-tools .tool-icon svg{width:30px;height:30px}
 .viewer-tools #auto-section .tool-icon svg{width:28px;height:32px}
 .viewer-tools .tool-label{font-size:12px}
 .viewer-history{top:14px;gap:10px}
 .viewer-history .tool{width:38px;height:38px;min-height:38px;padding:7px;border-radius:10px}
 .viewer-history .tool-icon,.viewer-history .tool-icon svg{width:23px;height:23px}
 .viewer-create{top:14px;min-height:38px;width:auto;gap:9px;font-size:15px;padding:8px 12px;border-radius:11px}
 .create-sparkle{width:24px;height:24px}
 body:not([data-mode=hero]) .camera-controls{bottom:16px;grid-template-columns:repeat(3,36px);gap:4px}
 body:not([data-mode=hero]) .camera-controls button{width:36px;height:36px;min-height:36px;padding:7px;border-radius:10px}
 .control-caption{font-size:13px;line-height:18px}
 .camera-controls .control-caption{margin-top:3px}
 body:not([data-mode=hero]) .joystick-control{bottom:16px!important;right:24px;gap:5px}
 body:not([data-mode=hero]) .joystick{width:84px;height:84px;--travel:23px;border-width:3px}
 body:not([data-mode=hero]) .joystick-knob{width:32px;height:32px}
 body:not([data-mode=hero]) :is(#clipper-menu,#grab-menu){top:64px;left:16px;right:16px;width:auto}
 body:not([data-mode=hero]) :is(#clipper-size,#grab-size){top:64px;left:auto;right:16px}
}
@media(min-width:701px) and (max-height:699px){body:has(#stage):not([data-mode=hero]){overflow-y:auto}}
/* Short phone screens need a little more space between the top action and bottom controls. */
@media(max-width:700px) and (max-height:740px){
 body:not([data-mode=hero]) #stage{--viewer-framing:1.2;--viewer-lift:.10}
 body:not([data-mode=hero]) #model-loader{--scan-size:min(65.4cqw,72.5cqh)}
 body:not([data-mode=hero]) #model-loader img{top:40%}
}

/* Account actions are shown only after auth and subscription checks. */
body:not([data-mode=hero]) main>header .header-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;min-width:0}
body:not([data-mode=hero]) main>header .heads-link{position:static;display:flex;align-items:center;min-height:42px;padding:9px 14px;border:1px solid #ded3f3;border-radius:12px;background:#f5f0ff;color:#5e2dd5;font-size:14px;font-weight:600;text-decoration:none;white-space:nowrap}
body:not([data-mode=hero]) main>header .editor-account-icon{display:grid;place-items:center;width:42px;height:42px;min-height:42px;padding:10px;border:1px solid #ded3f3;border-radius:50%;background:#f5f0ff;color:#6730ef}
.editor-account-icon svg{display:block;width:22px;height:22px}
@media(hover:hover) and (pointer:fine){body:not([data-mode=hero]) main>header .heads-link:hover,body:not([data-mode=hero]) main>header .editor-account-icon:hover{background:#eae0ff}}
@media(max-width:700px){body:not([data-mode=hero]) main>header .header-actions{gap:8px}body:not([data-mode=hero]) main>header .heads-link{font-size:13px}}
@media(max-width:800px){
 /* Reserve both rows before auth, subscription and editor controls load. */
 body:not([data-mode=hero]) main>header{grid-template-columns:36px minmax(0,1fr);grid-template-rows:44px 44px;gap:12px 16px;height:auto;min-height:120px;padding:10px 16px;padding-top:max(10px,env(safe-area-inset-top))}
 body:not([data-mode=hero]) main>header>.viewer-brand{grid-column:1;grid-row:1}
 body:not([data-mode=hero]) main>header .header-actions{grid-column:2;grid-row:1;justify-self:end;gap:8px}
 body:not([data-mode=hero]) main>header #hairstyle{grid-column:1/-1;grid-row:2;justify-self:center;width:min(440px,100%);height:44px;min-height:44px}
 body:not([data-mode=hero]) main>header .header-actions:has(>.viewer-create:not([hidden])){display:grid;grid-template-columns:minmax(0,1fr) 44px;width:100%;justify-self:stretch}
 .header-actions>.viewer-create{position:static;grid-column:1;grid-row:1;justify-self:center;min-height:44px;width:100%;max-width:280px;gap:9px;margin:0;font-size:17px;padding:8px 12px;border-radius:12px}
 .header-actions>.viewer-create .create-sparkle{width:28px;height:28px;flex:none}
 .header-actions:has(>.viewer-create:not([hidden]))>.editor-account-icon{grid-column:2;grid-row:1;justify-self:end}
}

.viewer-fit-notice{position:absolute;z-index:3;top:76px;left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 32px);margin:0;padding:10px 16px;border:1px solid #ddd0ef;border-radius:12px;background:#fffffff2;color:#493b5b;font-size:13px;line-height:1.4;text-align:center;pointer-events:none;box-shadow:0 4px 18px #3813540d}
@media(min-width:900px){.viewer-fit-notice{max-width:48%;top:20px}}
