  :root{
    /* Light theme matching the GCode Emulator (and pancakebot.com's own site) —
       clean white/cream chrome, the site's brand green as the accent. The canvas
       area stays dark on purpose in both tools: it represents the griddle
       itself, not the UI chrome. Kept identical to emulator/css/style.css's
       :root block so the two tools read as one product. */
    --bg-app:#faf7f2;
    --bg-panel:#ffffff;
    --bg-panel-2:#fdfbf7;
    --bg-canvas:#15120e;
    --text:#2b2620;
    --text-dim:#7d7468;
    --accent:#1c9a05;
    --accent-dim:#0f6b02;
    --accent-tint:rgba(28,154,5,.10);
    --danger:#c8402f;
    --line:#e6e0d5;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  }
  *{ box-sizing:border-box; }
  html,body{ height:100%; margin:0; background:var(--bg-app); color:var(--text); font-family:var(--sans); overflow:hidden; }
  button{ font-family:var(--sans); cursor:pointer; }
  input{ font-family:var(--sans); }

  #topbar{
    height:52px; display:flex; align-items:center; gap:10px;
    padding:0 14px; background:var(--bg-panel-2); border-bottom:1px solid var(--line);
  }
  #topbar h1{ font-size:15px; font-weight:600; letter-spacing:.2px; margin:0 14px 0 0; color:var(--accent); }
  .topbtn{
    background:transparent; border:1px solid var(--line); color:var(--text);
    padding:7px 12px; border-radius:5px; font-size:13px;
  }
  .topbtn:hover{ border-color:var(--accent); color:var(--accent-dim); }
  .topbtn.primary{ background:var(--accent); border-color:var(--accent); color:#ffffff; font-weight:600; }
  .topbtn.primary:hover{ background:var(--accent-dim); border-color:var(--accent-dim); }
  .topspacer{ flex:1; }
  .editGroup{ display:flex; gap:4px; margin-left:10px; padding-left:10px; border-left:1px solid var(--line); }
  .topbtn.editbtn{ padding:7px 9px; }
  .topbtn:disabled{ opacity:.4; cursor:not-allowed; }
  .topbtn:disabled:hover{ border-color:var(--line); color:var(--text); }
  #editStatus{
    position:absolute; left:50%; bottom:14px; transform:translateX(-50%); font-family:var(--mono); font-size:12px;
    color:#f2ece1; background:rgba(21,18,14,.7); padding:5px 12px; border-radius:5px; pointer-events:none;
    opacity:0; transition:opacity .25s; z-index:6; max-width:70%;
  }
  .field-inline{ display:flex; align-items:center; gap:6px; font-size:12px; color:var(--text-dim); }
  .field-inline input{
    width:56px; background:var(--bg-app); border:1px solid var(--line); color:var(--text);
    border-radius:4px; padding:5px 6px; font-family:var(--mono); font-size:12px;
  }

  #app{ display:flex; height:calc(100% - 52px); }

  #toolbar{
    width:72px; background:var(--bg-panel); border-right:1px solid var(--line);
    display:flex; flex-direction:column; align-items:center; padding:10px 6px; gap:5px;
  }
  .tool{
    width:60px; height:50px; border-radius:8px; border:1px solid transparent;
    background:transparent; color:var(--text-dim); display:flex; flex-direction:column;
    align-items:center; justify-content:center; gap:2px;
  }
  .tool .ic{ font-size:18px; line-height:1; }
  .tool .lb{ font-size:9px; letter-spacing:.02em; line-height:1; }
  .tool:hover{ background:var(--bg-panel-2); color:var(--text); }
  .tool.active{ background:var(--accent-dim); border-color:var(--accent); color:var(--accent); }
  .tool-sep{ width:40px; height:1px; background:var(--line); margin:4px 0; }

  #canvasWrap{
    flex:1; background:#efe9de;
    display:flex; align-items:center; justify-content:center; overflow:hidden; position:relative;
  }
  /* No shadow on #canvasShell: the canvas fills the whole area and is transparent around the griddle. */
  #canvasShell{ }
  #coordReadout{
    position:absolute; left:16px; bottom:14px; font-family:var(--mono); font-size:12px;
    color:#f2ece1; background:rgba(21,18,14,.55); padding:5px 9px; border-radius:5px;
    pointer-events:none;
  }
  #hoverInfo{ position:absolute; left:16px; bottom:76px; font-family:var(--mono); font-size:12px; color:#f2ece1; background:rgba(21,18,14,.55); padding:3px 8px; border-radius:5px; pointer-events:none; }
  #hoverInfo:empty{ display:none; }
  .layerName{ min-width:0; }
  /* Tips: a small pill that opens on hover or click. It used to be a large box permanently over the top-left of the
     canvas, which now would cover the griddle and its axis numbers. */
  #hint{
    position:absolute; left:16px; top:14px; z-index:5; font-size:12px; color:#f2ece1;
    background:rgba(21,18,14,.55); padding:5px 10px; border-radius:6px; max-width:360px; line-height:1.4;
  }
  #hintTitle{ font-family:var(--mono); font-size:11px; letter-spacing:.04em; cursor:pointer; user-select:none; }
  #hint #hintBody{ display:none; margin-top:6px; }
  #hint:hover #hintBody, #hint.open #hintBody{ display:block; }

  /* The whole sidebar scrolls. It used to be overflow:hidden with only the Layers panel
     scrollable, which stopped working once enough fixed panels (Reference Image, Autotrace,
     Trace Image, Print Settings, Base & Griddle) were stacked below it: they took all the
     height, the Layers panel was squeezed to a sliver, and whatever ran past the bottom was
     clipped with no way to reach it. */
  #sidebar{
    width:290px; background:var(--bg-panel); border-left:1px solid var(--line);
    display:flex; flex-direction:column; overflow-y:auto; overflow-x:hidden;
    scrollbar-width:thin; scrollbar-color:var(--line) transparent;
  }
  .panel{ border-bottom:1px solid var(--line); padding:12px 14px; }
  .panel h2{
    font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-dim);
    margin:0 0 10px 0; font-weight:600;
  }
  /* flex:1 0 auto — grows to use spare height, but NEVER shrinks below its content, so the panels
     below can't crush it and its rows can't spill over them; any overflow scrolls the sidebar.
     (This layout used to be an inline style on the element, which silently beat this rule.) */
  #layersPanel{ flex:1 0 auto; display:flex; flex-direction:column; }
  #layerList{ display:flex; flex-direction:column; gap:6px; }
  .layerRow{
    background:var(--bg-panel-2); border:1px solid var(--line); border-radius:6px; padding:8px 9px;
  }
  .layerRow.active{ border-color:var(--accent); }
  .layerRowTop{ display:flex; align-items:center; gap:7px; }
  .layerName{ flex:1; font-size:13px; background:transparent; border:none; color:var(--text); outline:none; }
  .layerName:focus{ text-decoration:underline; }
  input[type=color].layerColor{
    width:24px; height:24px; padding:0; border:1px solid var(--line); border-radius:5px;
    background:transparent; flex-shrink:0;
  }
  input[type=color].layerColor::-webkit-color-swatch-wrapper{ padding:2px; }
  input[type=color].layerColor::-webkit-color-swatch{ border:none; border-radius:3px; }
  .miniBtn{
    background:transparent; border:1px solid var(--line); color:var(--text-dim);
    width:24px; height:24px; border-radius:4px; font-size:12px; display:flex; align-items:center; justify-content:center;
  }
  .miniBtn:hover{ color:var(--text); border-color:var(--text-dim); }
  .miniBtn.danger:hover{ color:var(--danger); border-color:var(--danger); }
  .miniBtn.on{ color:var(--accent); border-color:var(--accent); }
  .opacityRow{ display:flex; align-items:center; gap:8px; margin-top:7px; }
  .opacityRow input[type=range]{ flex:1; accent-color:var(--accent); }
  .opacityRow span{ font-family:var(--mono); font-size:11px; color:var(--text-dim); width:30px; text-align:right; }
  .purgeRow{ margin-top:6px; }
  .fillStyleRow{ display:flex; align-items:center; gap:8px; margin-top:7px; font-size:11px; color:var(--text-dim); }
  .fillStyleSel{
    flex:1; background:var(--bg-app); border:1px solid var(--line); color:var(--text);
    border-radius:4px; padding:4px 5px; font-size:11px;
  }
  .purgeBtn{
    width:100%; font-size:11px; padding:5px; border-radius:4px; border:1px dashed var(--line);
    background:transparent; color:var(--text-dim);
  }
  .purgeBtn.set{ border-style:solid; border-color:#5aa7d9; color:#5aa7d9; }
  #addLayerBtn{
    margin-top:10px; width:100%; padding:8px; border-radius:6px; border:1px solid var(--line);
    background:transparent; color:var(--text); font-size:13px;
  }
  #addLayerBtn:hover{ border-color:var(--accent); color:var(--accent); }

  .settingRow{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; font-size:12px; color:var(--text-dim); }
  .settingRow input{
    width:70px; background:var(--bg-app); border:1px solid var(--line); color:var(--text);
    border-radius:4px; padding:5px 6px; font-family:var(--mono); font-size:12px; text-align:right;
  }
  /* These are the ONLY way to size/position the printable-area border, so they must show whole
     values like "237.5" (44px cut them to "23"). Spinner arrows hidden: they ate the space. */
  .settingRow input.narrow{ width:62px; padding-left:6px; padding-right:6px; text-align:right; }
  .settingRow input[type=number]::-webkit-inner-spin-button,
  .settingRow input[type=number]::-webkit-outer-spin-button{ -webkit-appearance:none; margin:0; }
  .settingRow input[type=number]{ -moz-appearance:textfield; appearance:textfield; }
  .settingNote{ font-size:11px; color:var(--text-dim); opacity:.75; line-height:1.4; margin-top:2px; }

  #fillBtnRow{ display:flex; gap:6px; }
  #fillBtnRow button{ flex:1; }

  ::-webkit-scrollbar{ width:8px; }
  ::-webkit-scrollbar-thumb{ background:var(--line); border-radius:4px; }

/* ---- zoom controls (same look as the Emulator's) ---- */
#zoomControls{
  position:absolute; right:16px; bottom:14px; display:flex; align-items:center; gap:4px;
  background:rgba(21,18,14,.55); border-radius:7px; padding:4px;
}
#zoomControls button{
  width:26px; height:26px; border-radius:5px; border:none; background:transparent;
  color:#f2ece1; font-size:15px; display:flex; align-items:center; justify-content:center; line-height:1; cursor:pointer;
}
#zoomControls button:hover{ background:rgba(255,255,255,.15); }
#zoomControls #btnZoomReset{ width:auto; padding:0 8px; font-size:11px; font-family:var(--mono); }
#zoomLabel{ font-family:var(--mono); font-size:11px; color:#f2ece1; min-width:38px; text-align:center; }
#viewHint{
  position:absolute; right:16px; bottom:52px; font-family:var(--mono); font-size:10.5px; color:#f2ece1;
  background:rgba(21,18,14,.45); padding:3px 8px; border-radius:5px; pointer-events:none;
}
/* Space held / panning: a grab cursor over the canvas (Fabric sets its own inline cursor, hence !important) */
#canvasWrap.panReady canvas, #canvasWrap.panReady .upper-canvas{ cursor:grab !important; }
#canvasWrap.panning canvas, #canvasWrap.panning .upper-canvas{ cursor:grabbing !important; }
.purgeBtn.areaBtn.active{ background:var(--accent-dim); border-color:var(--accent); color:var(--accent); }
