/* PC keeps its existing layout. All phone rules require touch-mobile. */
.mobile-only{display:none}
html.touch-mobile{
  --phone-left:max(12px,env(safe-area-inset-left,0px));
  --phone-right:max(12px,env(safe-area-inset-right,0px));
  --phone-top:calc(env(safe-area-inset-top,0px) + 12px);
  --phone-bottom:max(10px,env(safe-area-inset-bottom,0px));
  --phone-nav-height:64px;
  --phone-info-bottom:calc(var(--phone-bottom) + var(--phone-nav-height) + 10px);
  --phone-tools-bottom:calc(var(--phone-info-bottom) + 62px);
  --mobile-model-top:120px;
  --mobile-model-bottom:210px;
  --phone-info-content-height:min(48dvh,calc(100dvh - var(--phone-info-bottom) - var(--phone-top) - 112px));
  overscroll-behavior:none;
}
.touch-mobile body{overflow:hidden;overscroll-behavior:none}
.touch-mobile #app{height:100dvh;min-height:100dvh;overflow:hidden}
.touch-mobile .header{position:fixed;top:var(--phone-top);left:var(--phone-left);right:var(--phone-right);align-items:center;gap:12px;z-index:60}
.touch-mobile .wordmark{height:44px;padding:10px 14px;border-radius:17px}
.touch-mobile .wordmark img{width:54px}
.touch-mobile .header .header-actions{gap:10px}
.touch-mobile .menu-toggle{min-height:44px;height:44px;gap:10px;padding:10px 14px;border-radius:18px;font-size:13px}
.touch-mobile .music-controls{--music-size:44px;--volume-width:116px}
.touch-mobile .music-controls button.music-toggle{padding:12px}
.touch-mobile .music-volume-panel{gap:8px;padding:0 12px}
.touch-mobile .music-controls input.music-volume{width:57px;height:44px}
.touch-mobile .music-controls .music-volume::-webkit-slider-thumb{width:18px;height:18px;margin-top:-7.5px}
.touch-mobile .music-controls .music-volume::-moz-range-thumb{width:18px;height:18px}
.touch-mobile .music-controls output{width:27px}
/* On narrow phones the volume drawer sits below its fixed sound button. */
.touch-mobile .music-controls::before{transition:none}
.touch-mobile .music-controls[data-expanded="true"]::before{width:44px}
.touch-mobile .music-volume-panel{top:calc(100% + 8px);right:0;height:48px;border-radius:18px;background:rgba(255,255,255,.95);border:var(--glass-border);box-shadow:var(--glass-shadow);backdrop-filter:blur(16px);transform:translateY(-6px)}
.touch-mobile .music-controls[data-expanded="true"] .music-volume-panel{transform:translateY(0)}
.touch-mobile .music-status:not(:empty){top:calc(100% + 64px);max-width:calc(100vw - 36px)}

.touch-mobile .intro{position:fixed;top:auto;bottom:var(--phone-bottom);left:var(--phone-left);right:var(--phone-right);width:auto;height:var(--phone-nav-height);max-height:none;transform:none;padding:5px;border-radius:22px;overflow:visible;z-index:60}
.touch-mobile .state-nav{position:static;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:3px;margin:0;max-width:none}
.touch-mobile .state-nav button{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:3px;min-height:52px;height:52px;padding:5px 2px;font-size:14px;line-height:1.4;border-radius:17px;text-align:center;white-space:nowrap}
.touch-mobile .state-nav button>span{font-size:12px;line-height:1.2}
.touch-mobile .state-nav button.active{background:rgba(23,25,27,.09);color:#17191b}

.touch-mobile .model-header{position:fixed;top:calc(var(--phone-top) + 53px);left:var(--phone-left);right:var(--phone-right);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:0;z-index:25}
.touch-mobile .model-header>.scene-meta{display:flex;margin:0;padding:0 8px;font-size:12px;line-height:1.5;letter-spacing:.035em;text-align:center;border:0;background:none;box-shadow:none;backdrop-filter:none}
.touch-mobile .scene-meta>span:first-child{display:block}
.touch-mobile .model-header>.interaction-hint{display:block;margin:0;padding:3px 9px;font-size:12px;line-height:1.6;text-align:center;white-space:normal;background:rgba(255,255,255,.72);border:0;box-shadow:none;max-width:100%}
.touch-mobile .viewport{position:fixed;inset:auto;top:var(--mobile-model-top);bottom:var(--mobile-model-bottom);left:0;right:0;width:auto;height:auto;min-height:0;padding:0;overflow:hidden}
.touch-mobile #model-canvas{inset:0;width:100%;height:100%}
.touch-mobile .load-screen{inset:0}
.touch-mobile .load-screen p{font-size:14px;padding:0 16px;text-align:center}
.touch-mobile .load-screen button{min-height:44px;padding:10px 20px}
.touch-mobile .hover-label{display:none}
.touch-mobile .model-selection-tools{position:fixed;top:calc(var(--mobile-model-top) + 6px);left:var(--phone-left);right:auto;max-width:calc(100% - var(--phone-left) - var(--phone-right));padding:3px;z-index:35}
.touch-mobile .model-selection-tools button{min-height:44px;font-size:14px;padding:8px 12px}
.touch-mobile .gizmo-handle{min-height:44px;padding:10px;font-size:12px;gap:4px}
.touch-mobile .gizmo-handle span{font-size:12px}

/* Thumb-level actions; camera presets open only when requested. */
.touch-mobile .model-toolbar{position:fixed;left:var(--phone-left);right:var(--phone-right);bottom:var(--phone-tools-bottom);display:grid;grid-template-columns:auto minmax(0,1fr);align-items:end;gap:10px;z-index:40}
.touch-mobile .mobile-view-toggle{display:flex;grid-column:1;grid-row:1;align-items:center;gap:8px;height:46px;min-width:86px;padding:10px 14px;font-size:14px;border-radius:24px;background:var(--glass);border:var(--glass-border);box-shadow:var(--glass-shadow);backdrop-filter:blur(16px)}
.touch-mobile .mobile-view-toggle svg{width:18px;height:18px}
.touch-mobile .view-tools{position:absolute;left:0;right:auto;bottom:calc(100% + 10px);width:244px;max-width:100%;height:auto;min-height:52px;transform:none;display:none;grid-column:auto;grid-row:auto;gap:0;justify-content:space-between;padding:4px;border-radius:22px;background:rgba(255,255,255,.96)}
.touch-mobile.mobile-camera-open .view-tools{display:flex}
.touch-mobile .view-tools button{min-height:44px;padding:9px 10px;font-size:14px;flex:1}
.touch-mobile .view-tools .divider{margin:0 2px}
.touch-mobile .toolbar-actions{grid-column:2;grid-row:1;justify-self:end;display:flex;min-width:0}
.touch-mobile .assembly-actions{display:flex;flex-direction:row;align-items:center;gap:8px}
.touch-mobile .toolbar-actions #assemble,.touch-mobile .reset-adjustment,.touch-mobile .primary-button{height:46px;min-height:44px;padding:11px 16px;font-size:14px;border-radius:24px;white-space:nowrap}
.touch-mobile .primary-button{gap:9px}
/* Phone adjustments use the handles on the model, without a control sheet. */
.touch-mobile .adjust-controls{display:none}

/* Collapsible information sheet, independent of the model camera. */
.touch-mobile .inspector{position:fixed;top:auto;bottom:var(--phone-info-bottom);left:var(--phone-left);right:var(--phone-right);width:auto;height:auto;min-height:0;max-height:calc(100dvh - var(--phone-info-bottom) - var(--phone-top) - 54px);margin:0;padding:0;border-radius:22px;overflow:hidden;z-index:50;background:rgba(255,255,255,.94)}
.touch-mobile .mobile-info-toggle{display:flex;align-items:center;gap:12px;width:100%;min-height:52px;padding:9px 16px;text-align:left;font-size:14px;color:#17191b}
.touch-mobile .mobile-info-toggle>span{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
.touch-mobile .mobile-info-toggle small{font-size:12px;font-weight:400;line-height:1.3;color:#7a8189}
.touch-mobile .mobile-info-toggle strong{font-size:14px;font-weight:500;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.touch-mobile .mobile-info-toggle svg{width:18px;height:18px;transition:transform .2s}
.touch-mobile.mobile-info-open .mobile-info-toggle svg{transform:rotate(180deg)}
.touch-mobile .inspector-content{display:none;max-height:var(--phone-info-content-height);overflow:auto;overscroll-behavior:contain;touch-action:pan-y;padding:4px 20px 22px}
/* Halve the expanded component sheet, including its 52px summary; keep a usable scroll area. */
.touch-mobile .component-model .inspector-content{max-height:max(80px,calc((var(--phone-info-content-height) - 52px) / 2))}
.touch-mobile.mobile-info-open .inspector-content{display:block}
.touch-mobile.mobile-info-open .model-toolbar{visibility:hidden;pointer-events:none}
.touch-mobile.mobile-info-open .model-toolbar *{pointer-events:none}
.touch-mobile .project-intro{margin-bottom:20px}
.touch-mobile .eyebrow{font-size:12px}
.touch-mobile h1{font-size:26px;margin-top:8px;line-height:1.35}
.touch-mobile h1>span{font-size:14px;margin-top:5px}
.touch-mobile .inspector .project-details{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px;margin-top:14px}
.touch-mobile .project-details>div{padding:12px 0}
.touch-mobile .inspector .project-details dt{font-size:14px}
.touch-mobile .inspector .project-details dd{font-size:16px;line-height:1.6;overflow-wrap:anywhere}
.touch-mobile .system-row{min-height:66px}
.touch-mobile .system-list strong{font-size:16px}.touch-mobile .system-list small{font-size:12px}
.touch-mobile .system-count{display:block}
.touch-mobile .selection-note p,.touch-mobile .component-model .selection-note p{font-size:16px;line-height:1.7}
.touch-mobile #selection h2,.touch-mobile #adjust-inspector h2{font-size:23px}
.touch-mobile .part-preview{height:160px}
.touch-mobile .part-description,.touch-mobile .adjust-description{font-size:16px;line-height:1.75}
.touch-mobile .data-note,.touch-mobile .adjust-note{font-size:12px;line-height:1.8}
.touch-mobile .project-menu{width:calc(100% - var(--phone-left) - var(--phone-right));max-width:440px;max-height:80dvh;padding:24px;border-radius:26px}
.touch-mobile #menu-close{min-height:44px;min-width:44px;font-size:26px}
.touch-mobile .project-entry{min-height:72px}
.touch-mobile .status-message{bottom:calc(var(--phone-tools-bottom) + 60px);font-size:14px;max-width:calc(100% - 32px);z-index:70}
.touch-mobile .adjusted-badge{bottom:12px}
.touch-mobile button,.touch-mobile a,.touch-mobile select{touch-action:manipulation}
.touch-mobile .gizmo-handle{touch-action:none}

@media(orientation:landscape){
  html.touch-mobile{--phone-nav-height:58px;--phone-tools-bottom:calc(var(--phone-bottom) + var(--phone-nav-height) + 12px);--phone-side-width:232px;--phone-info-content-height:calc(100dvh - var(--phone-top) - var(--phone-tools-bottom) - 110px)}
  .touch-mobile .intro{height:58px}
  .touch-mobile .state-nav button{flex-direction:row;gap:8px;min-height:46px;height:46px}
  .touch-mobile .model-header{top:calc(var(--phone-top) + 5px);left:calc(var(--phone-left) + 96px);right:calc(var(--phone-right) + 180px);height:38px;justify-content:center}
  .touch-mobile .model-header>.scene-meta{display:none}
  .touch-mobile .viewport{top:calc(var(--phone-top) + 54px);bottom:calc(var(--phone-bottom) + var(--phone-nav-height) + 12px);left:var(--phone-left);right:calc(var(--phone-right) + var(--phone-side-width) + 10px)}
  .touch-mobile .model-toolbar{left:auto;right:var(--phone-right);width:var(--phone-side-width);gap:8px}
  .touch-mobile .inspector{top:calc(var(--phone-top) + 54px);bottom:auto;left:auto;right:var(--phone-right);width:var(--phone-side-width);max-height:calc(100dvh - var(--phone-top) - var(--phone-tools-bottom) - 4px)}
  .touch-mobile .inspector-content{padding:4px 16px 18px}
  .touch-mobile .inspector .project-details{grid-template-columns:1fr}
  .touch-mobile .mobile-info-toggle{padding:8px 14px}
  .touch-mobile .toolbar-actions #assemble,.touch-mobile .reset-adjustment,.touch-mobile .primary-button{padding:11px 12px}
  .touch-mobile .mobile-view-toggle{min-width:78px;padding:10px 12px}
  .touch-mobile .assembly-actions{gap:6px}
  .touch-mobile .model-selection-tools{top:calc(var(--phone-top) + 56px);left:var(--phone-left)}
  .touch-mobile .part-preview{height:115px}
}
@media(max-width:360px){
  .touch-mobile .state-nav button{font-size:13px}
  .touch-mobile .inspector .project-details{column-gap:12px}
  .touch-mobile .model-header>.interaction-hint{font-size:12px;padding-left:0;padding-right:0}
}
@media(prefers-reduced-motion:reduce){.touch-mobile .mobile-info-toggle svg{transition:none}}
