/* ============================================================================
   SDF FORGE  ·  style.css
   ----------------------------------------------------------------------------
   Forge's visual language: a dark grey viewport, near-black panels with
   uppercase tracked labels, recessed value wells with right-aligned numbers,
   and one blue accent for every active state. Inter for labels, the system
   monospace for numbers.

   GREP MAP
     :root ............ the sizes (the palette is in lib/forge-ui.css)
     #bar / .tab ...... the top bar
     .panel ........... a floating panel, its header and sections
     .num / .xyz ...... the value wells (drag to scrub, click to type)
     .grid2 / .btn .... the button grids
     .pane ............ a viewport pane and its label menus
     #status .......... the bottom strip
     TOUCH / PHONE / LANDSCAPE   the coarse-pointer rules, the sheet, the dock
   ========================================================================== */
:root{
  /* the palette and the fonts: lib/forge-ui.css (shared with biome-parts) */
  --bar-h:52px; --gap:12px; --rw:300px; --lw:236px; --sw:292px;
  --row:26px; --dock-h:0px; --sheet-h:0px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;background:var(--bg);color:var(--txt);font-family:var(--sans);font-size:13px;-webkit-font-smoothing:antialiased}
button{font-family:inherit;color:inherit}
input{font-family:var(--mono)}
#viewport{position:fixed;left:0;top:0;right:0;bottom:var(--dock-h);touch-action:none;user-select:none;-webkit-user-select:none}

/* ── top bar ─────────────────────────────────────────────────────────────── */
#bar{position:fixed;left:0;right:0;top:0;height:var(--bar-h);display:flex;justify-content:space-between;align-items:center;padding:12px 14px 0;z-index:30;pointer-events:none}
#bar > div{display:flex;gap:8px;pointer-events:auto}
.tab{height:34px;padding:0 17px;border:0;border-radius:3px;background:rgba(22,22,25,0.9);color:#b9bbc5;font-size:12.5px;font-weight:500;letter-spacing:0.17em;cursor:pointer}
.tab:hover{background:#26262b;color:var(--txt)}
.tab.on{background:var(--acc);color:var(--accTxt)}
.ico{height:34px;width:38px;border:0;border-radius:3px;background:rgba(22,22,25,0.9);color:#c4c6cf;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0}
.ico svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.ico:hover{background:#26262b}
.ico:disabled{opacity:0.35;cursor:default}

/* ── panels ─────────────────────────────────────────────────────────────── */
.col{position:fixed;top:calc(var(--bar-h) + 8px);display:flex;gap:var(--gap);align-items:flex-start;z-index:25;pointer-events:none;max-height:calc(100% - var(--bar-h) - 60px)}
#leftCol{left:14px}
#rightCol{right:14px;flex-direction:row-reverse}
.panel{pointer-events:auto;background:var(--panel);border:1px solid var(--line);border-radius:3px;box-shadow:0 8px 28px rgba(0,0,0,0.35);display:flex;flex-direction:column;max-height:calc(100vh - var(--bar-h) - 64px);max-height:calc(100dvh - var(--bar-h) - 64px)}
.panel[hidden]{display:none}
#p-objects{width:var(--lw)} #p-selection{width:var(--sw)}
#p-create,#p-modify,#p-view,#p-scene{width:var(--rw)}
.ph{display:flex;align-items:center;justify-content:space-between;height:44px;padding:0 12px 0 16px;background:var(--head);border-bottom:1px solid var(--line);flex:none}
.ph h2{margin:0;font-size:13.5px;font-weight:500;letter-spacing:0.15em;color:var(--txt)}
.ph .x{width:18px;height:18px;border:0;border-radius:2px;background:#1f1f23;cursor:pointer;color:transparent;font-size:0}
.ph .x:hover{background:#2c2c32}
.pb{padding:6px 14px 14px;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#2c2c33 transparent}
.sec{display:flex;align-items:center;gap:8px;margin:14px 0 7px;font-size:11px;font-weight:500;letter-spacing:0.17em;color:var(--dim)}
.sec::after{content:"";flex:1;height:1px;background:var(--line2)}
.sec .r{color:var(--faint);letter-spacing:0.08em}
.note{font-size:11.5px;line-height:1.5;color:var(--dim);margin:6px 0}
.note b{color:var(--txt);font-weight:500}

/* OBJECTS */
.olist{display:flex;flex-direction:column;gap:2px;margin-top:4px}
.orow{display:flex;align-items:center;gap:4px;height:30px;padding:0 4px 0 calc(10px + var(--d,0) * 14px);border-radius:3px;cursor:pointer;color:#b4b6c0;font-family:var(--mono);font-size:13px;position:relative}
.orow:hover{background:#1a1a1e}
.orow.sel{background:var(--acc);color:var(--accTxt)}
.orow.hid .nm{opacity:0.4;text-decoration:line-through}
.orow .nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.orow .k{font-family:var(--sans);font-size:9.5px;letter-spacing:0.12em;color:var(--faint);padding:0 4px}
.orow.sel .k{color:#cfe0ff}
.orow .eye{width:24px;height:24px;border:0;background:transparent;border-radius:2px;cursor:pointer;color:inherit;opacity:0.55;font-size:12px}
.orow .eye:hover{opacity:1;background:rgba(255,255,255,0.08)}
.orow.drop-before{box-shadow:inset 0 2px 0 var(--acc)}
.orow.drop-into{outline:1px solid var(--acc)}
.orow.drop-after{box-shadow:inset 0 -2px 0 var(--acc)}
.orow input{flex:1;min-width:0;height:22px;background:var(--well);border:1px solid var(--acc);color:var(--txt);font-size:12.5px;padding:0 6px}
.empty{color:var(--faint);font-size:12px;padding:10px 4px;line-height:1.5}

/* the value wells */
.name{width:100%;height:36px;background:var(--well);border:1px solid transparent;border-radius:3px;color:var(--txt);font-size:14.5px;padding:0 12px;margin-top:8px}
.name:focus{outline:none;border-color:var(--acc)}
.rowv{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:var(--row);margin:4px 0}
.rowv > label,.rowv > .lab{font-size:11.5px;letter-spacing:0.13em;color:#b3b5bf;font-weight:500}
.num{position:relative;display:flex;align-items:center;justify-content:flex-end;height:var(--row);min-width:110px;background:var(--well);border-radius:2px;padding:0 9px;font-family:var(--mono);font-size:13.5px;color:var(--txt);cursor:ew-resize;touch-action:pan-y;user-select:none;-webkit-user-select:none}
.num:hover{background:#0e0e11}
.num.hot{box-shadow:inset 0 0 0 1px var(--acc)}
.num input{position:absolute;inset:0;width:100%;background:var(--well);border:1px solid var(--acc);color:var(--txt);text-align:right;font-size:13.5px;padding:0 8px;border-radius:2px}
.xyz{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;margin:4px 0}
.xyz .num{min-width:0;justify-content:space-between;padding:0 7px 0 0}
.xyz .num::before{content:"";width:2px;align-self:stretch;margin:4px 6px 4px 0}
.xyz .num i{font-style:normal;font-family:var(--sans);font-size:12px;font-weight:500;margin-right:4px}
.xyz .num:nth-child(1)::before{background:var(--x)} .xyz .num:nth-child(1) i{color:var(--x)}
.xyz .num:nth-child(2)::before{background:var(--y)} .xyz .num:nth-child(2) i{color:var(--y)}
.xyz .num:nth-child(3)::before{background:var(--z)} .xyz .num:nth-child(3) i{color:var(--z)}
.swatch{width:110px;height:var(--row);border:0;border-radius:2px;padding:0;background:none;cursor:pointer}
.swatch::-webkit-color-swatch-wrapper{padding:0}
.swatch::-webkit-color-swatch{border:1px solid var(--line2);border-radius:2px}
.swatch::-moz-color-swatch{border:1px solid var(--line2);border-radius:2px}

/* buttons */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.btn{height:32px;border:0;border-radius:3px;background:var(--btn);color:#b4b6bf;font-size:11.5px;font-weight:500;letter-spacing:0.14em;cursor:pointer;padding:0 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.btn:hover{background:var(--btn-h);color:var(--txt)}
.btn.on{background:var(--acc);color:var(--accTxt);box-shadow:inset 0 0 0 1px #9cc0f0}
.btn.wide{grid-column:1 / -1}
.grid3 .btn{letter-spacing:0.08em;font-size:11px}
.btn:disabled{opacity:0.35;cursor:default}
.btn.warn:hover{background:#4a2326;color:#ffd5d5}
.tog{display:flex;align-items:center;justify-content:space-between;width:100%;height:34px;border:0;background:transparent;padding:0;cursor:pointer;font-size:12.5px;letter-spacing:0.13em;color:#c9cbd4;font-weight:500}
.tog::after{content:"";width:34px;height:18px;border-radius:9px;background:#2a2a30;box-shadow:inset -16px 0 0 2px #2a2a30, inset 0 0 0 2px #2a2a30;background-image:radial-gradient(circle at 9px 9px,#8b8d97 6px,transparent 6.5px)}
.tog.on::after{background:var(--acc);background-image:radial-gradient(circle at 25px 9px,#eef4ff 6px,transparent 6.5px);box-shadow:none}

/* modifier stack */
.stack{display:flex;flex-direction:column;gap:2px;background:var(--well);border-radius:3px;padding:4px;min-height:40px}
.mrow{display:flex;align-items:center;gap:4px;height:30px;padding:0 4px 0 8px;border-radius:2px;cursor:pointer;font-size:12px;letter-spacing:0.12em;color:#b9bbc5;font-weight:500}
.mrow:hover{background:#16161a}
.mrow.sel{background:#1e2a3d;color:var(--accTxt)}
.mrow.off .nm{opacity:0.45;text-decoration:line-through}
.mrow .nm{flex:1}
.mrow .base{color:var(--faint)}
.mrow button{width:26px;height:24px;border:0;background:transparent;color:inherit;opacity:0.6;cursor:pointer;border-radius:2px;font-size:12px}
.mrow button:hover{opacity:1;background:rgba(255,255,255,0.08)}
.prog{height:4px;background:var(--well);border-radius:2px;overflow:hidden;margin-top:8px}
.prog > i{display:block;height:100%;width:0;background:var(--acc);transition:width 0.15s}
.stats{font-family:var(--mono);font-size:11.5px;color:var(--dim);line-height:1.7;display:grid;grid-template-columns:auto 1fr;column-gap:12px}
.stats b{color:var(--txt);font-weight:400;text-align:right}
details.learn summary{cursor:pointer;font-size:11px;letter-spacing:0.17em;color:var(--dim);margin:14px 0 6px;list-style:none}
details.learn summary::before{content:"\25B8  "}
details.learn[open] summary::before{content:"\25BE  "}
.learn p{font-size:12px;line-height:1.6;color:#b9bbc5;margin:0 0 8px}
.learn .eq{color:#e8e9ee;margin:4px 0 12px;overflow-x:auto}
.learn .eq svg{max-width:100%;height:auto}

/* ── panes ──────────────────────────────────────────────────────────────── */
.pane{position:absolute;overflow:hidden;background:#19191c}
.pane[hidden]{display:none}
.pane canvas{position:absolute;left:0;top:0;width:100%;height:100%;display:block}
.pane.active::after{content:"";position:absolute;inset:0;border:1px solid rgba(107,159,226,0.55);pointer-events:none}
.plabel{position:absolute;left:10px;bottom:calc(10px + var(--lift,0px));display:flex;gap:4px;z-index:3}
.plabel button{height:24px;padding:0 9px;border:0;border-radius:2px;background:rgba(14,14,16,0.78);color:#a8aab4;font-size:10.5px;font-weight:500;letter-spacing:0.15em;cursor:pointer}
.plabel button:hover{color:var(--txt);background:rgba(30,30,34,0.92)}
.pane.active .plabel button.v{color:#cfe0ff}
.pcube{position:absolute;top:calc(var(--bar-h) + 112px);right:24px;display:flex;gap:4px;z-index:3}
.pcube button{width:24px;height:22px;border:1px solid #3a3a42;border-radius:2px;background:rgba(14,14,16,0.8);color:#a8aab4;font-size:11px;cursor:pointer;padding:0}
.pcube button.on{background:var(--acc);border-color:var(--acc);color:var(--accTxt)}
.menu{position:fixed;z-index:60;background:var(--panel);border:1px solid var(--line2);border-radius:3px;padding:4px;min-width:150px;box-shadow:0 10px 30px rgba(0,0,0,0.5)}
.menu button{display:flex;justify-content:space-between;width:100%;height:28px;border:0;background:transparent;color:#c2c4cd;font-size:11.5px;letter-spacing:0.13em;font-weight:500;padding:0 10px;border-radius:2px;cursor:pointer;text-align:left}
.menu button:hover{background:#1f1f24}
.menu button.on{color:var(--acc)}
.menu button kbd{font-family:var(--mono);color:var(--faint);font-size:11px;letter-spacing:0}

/* ── status strip ───────────────────────────────────────────────────────── */
#status{position:fixed;left:14px;bottom:calc(var(--dock-h) + 14px);display:flex;align-items:center;gap:8px;z-index:26;pointer-events:none;max-width:calc(100% - 28px)}
#status > *{pointer-events:auto}
.tag{height:30px;display:inline-flex;align-items:center;padding:0 12px;background:#2d4630;color:#cfe9cc;font-family:var(--mono);font-size:13.5px;border-radius:2px;min-width:132px}
.seg{display:inline-flex;background:rgba(18,18,21,0.92);border-radius:3px;padding:2px;gap:2px}
.seg button{height:26px;min-width:32px;border:0;background:transparent;color:#a9abb5;font-family:var(--mono);font-size:12.5px;border-radius:2px;cursor:pointer;padding:0 8px}
.seg button span{font-family:var(--sans);font-size:9.5px;letter-spacing:0.14em;margin-left:6px;color:var(--faint)}
.seg button.on{background:var(--acc);color:var(--accTxt)}
.seg button.on span{color:#dbe8ff}
.chip{height:30px;border:0;border-radius:3px;background:rgba(18,18,21,0.92);color:#a9abb5;font-size:10.5px;font-weight:500;letter-spacing:0.15em;padding:0 10px;cursor:pointer}
.chip.on{background:var(--acc);color:var(--accTxt)}
#hint{max-width:min(520px,36vw);font-size:11.5px;color:#9a9ca6;letter-spacing:0.04em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:rgba(18,18,21,0.75);padding:7px 10px;border-radius:3px;pointer-events:none}
#hint:empty{display:none}
#toast{position:fixed;left:50%;bottom:calc(var(--dock-h) + 62px);transform:translateX(-50%);background:rgba(16,16,19,0.95);border:1px solid var(--line2);color:var(--txt);font-size:12.5px;padding:9px 14px;border-radius:3px;z-index:70;opacity:0;transition:opacity 0.2s;pointer-events:none;max-width:min(560px,90vw)}
#toast.on{opacity:1}
#nogpu{position:fixed;inset:30% 10% auto;padding:20px;background:var(--panel);border:1px solid var(--line2);border-radius:4px;line-height:1.6;z-index:80;text-align:center}
#dock,#sheet{display:none}

/* ── TOUCH: every target is 44px or more ────────────────────────────────── */
@media (pointer:coarse){
  :root{--row:44px}
  .tab,.ico{height:44px} .ico{width:44px}
  .btn{height:44px}
  .num{height:44px;font-size:15px}
  .num input{font-size:15px}
  .orow{height:44px} .orow .eye{width:44px;height:44px}
  .mrow{height:44px} .mrow button{width:44px;height:44px}
  .tog{height:44px}
  .name{height:44px}
  .swatch{height:44px}
  .ph{height:48px} .ph .x{width:44px;height:44px;background:transparent;position:relative}
  .ph .x::after{content:"";position:absolute;inset:13px;background:#1f1f23;border-radius:2px}
  .seg button{height:44px;min-width:44px}
  .chip,.tag{height:44px}
  .plabel button{height:44px;padding:0 12px}
  .pcube button{width:44px;height:44px}
  .menu button{height:44px}
  details.learn summary{min-height:44px;display:flex;align-items:center}
}

/* ── PHONE: one pane, the panels in a sheet, a dock at the base ─────────── */
body.phone{--dock-h:calc(60px + env(safe-area-inset-bottom))}
body.phone #bar,body.phone .col{display:none}
body.phone #dock{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:45;gap:8px;align-items:center;
  padding:8px calc(10px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  background:rgba(13,13,15,0.96);border-top:1px solid var(--line)}
body.phone #dock > button{flex:0 0 44px;height:44px;border:0;border-radius:3px;background:var(--btn);color:var(--txt);font-size:17px;cursor:pointer}
body.phone #dock > button.on{background:var(--acc);color:var(--accTxt)}
body.phone #dockPanes{flex:1;min-width:0;display:flex}
body.phone #dockPanes button{flex:1;min-width:0;font-family:var(--sans);font-size:10.5px;letter-spacing:0.12em;padding:0 2px}
body.phone #status{left:calc(8px + env(safe-area-inset-left));right:auto;bottom:calc(var(--dock-h) + var(--sheet-h) + 8px);gap:6px}
body.phone #status .seg button span{display:none}
body.phone .tag{display:none}
body.phone #status{flex-wrap:nowrap}
body.phone #hint{display:none}
body.phone #viewport{bottom:calc(var(--dock-h) + var(--sheet-h))}
body.phone .pcube{top:12px;right:12px}
html.in-frame body.phone .pcube{top:12px}
body.phone #sheet{display:flex;flex-direction:column;position:fixed;left:0;right:0;bottom:var(--dock-h);height:min(46vh,480px);height:min(46dvh,480px);z-index:40;
  background:var(--panel);border-top:1px solid var(--line2);border-radius:12px 12px 0 0;transform:translateY(calc(100% + var(--dock-h)));transition:transform 0.25s cubic-bezier(0.4,0,0.2,1),height 0.25s;
  padding:0 calc(6px + env(safe-area-inset-right)) 0 calc(6px + env(safe-area-inset-left))}
body.phone #sheet.open{transform:translateY(0)}
body.phone #sheet.full{height:calc(100vh - var(--dock-h) - 60px);height:calc(100dvh - var(--dock-h) - 60px)}
#sheetGrip{display:flex;justify-content:center;align-items:center;height:44px;flex:none;touch-action:none;cursor:grab}
#sheetGrip span{width:44px;height:5px;border-radius:3px;background:#4a4c55}
#sheetTabs{display:flex;gap:4px;overflow-x:auto;flex:none;padding:0 4px 6px;scrollbar-width:none}
#sheetTabs::-webkit-scrollbar{display:none}
#sheetTabs button{flex:none;height:44px;padding:0 12px;border:0;border-radius:3px;background:var(--btn);color:#b4b6bf;font-size:11px;font-weight:500;letter-spacing:0.14em;cursor:pointer}
#sheetTabs button.on{background:var(--acc);color:var(--accTxt)}
#sheetClose{display:none}
#sheetBody{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain}
#sheetBody .panel{width:auto!important;border:0;box-shadow:none;max-height:none;background:transparent}
#sheetBody .ph{display:none}
#sheetBody .pb{overflow:visible;padding:0 8px 18px}

/* LANDSCAPE phone: the sheet is a drawer at the right edge */
@media (max-height:500px) and (orientation:landscape){
  body.phone #viewport{bottom:var(--dock-h);right:var(--sheet-w,0px)}
  body.phone #status{bottom:calc(var(--dock-h) + 8px)}
  body.phone #sheet,body.phone #sheet.full{top:0;bottom:0;left:auto;right:0;width:min(46vw,380px);height:auto;border-radius:0;border-top:0;border-left:1px solid var(--line2);transform:translateX(100%)}
  body.phone #sheet.open{transform:translateX(0)}
  body.phone #sheetGrip{display:none}
  body.phone #sheetClose{display:block;position:absolute;top:6px;right:8px;width:44px;height:44px;border:0;border-radius:3px;background:var(--btn);color:var(--txt);z-index:2}
  body.phone #sheetTabs{padding-top:6px;padding-right:56px}
  body.phone #dock{right:auto;width:min(520px,60vw);border-right:1px solid var(--line);border-radius:0 10px 0 0}
}
