.draw-page { max-width: 1500px; margin: 0 auto; padding: 1.5rem; }
.draw-layout { display: grid; grid-template-columns: minmax(270px, 360px) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.draw-controls { position: sticky; top: 1rem; }
.draw-controls label { display:block; margin-top: 1rem; margin-bottom: .35rem; font-weight: 650; }
.draw-controls input, .draw-controls select { width: 100%; padding: .75rem .85rem; border: 1px solid rgba(0,0,0,.16); border-radius: .65rem; font: inherit; background: #fff; box-sizing: border-box; }
.button-row, .button-grid { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.button-grid button { flex: 1 1 145px; }
.draw-stage { overflow: hidden; min-width: 0; }
.stage-scroll { width: 100%; overflow: auto; border-radius: .7rem; background: #f7f5ef; }
.plot-surface { display: block; width: 100%; min-width: 680px; height: auto; aspect-ratio: 1100 / 850; touch-action: none; user-select: none; cursor: crosshair; background: #fffdf8; }
.output-card { margin-top: 1.25rem; }
#hpglPreview { white-space: pre-wrap; overflow: auto; max-height: 260px; }
.small { font-size: .9rem; line-height: 1.4; }
.muted { color: #59616a; }
@media (max-width: 900px) { .draw-layout { grid-template-columns: 1fr; } .draw-controls { position: static; } .plot-surface { min-width: 600px; } }


/* Rev3.3 draw-page fallback styles: keeps /draw/ readable even if the base stylesheet is cached or missing. */
:root{--bg:#faf8f1;--ink:#121212;--muted:#59616a;--card:#fffdf8;--line:rgba(0,0,0,.14);}
body{margin:0;background:var(--bg);color:var(--ink);font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;line-height:1.5;}
a{color:#111;text-decoration-thickness:1px;text-underline-offset:3px;}
.site-header{display:flex;justify-content:space-between;gap:1rem;align-items:center;padding:1rem 1.5rem;border-bottom:1px solid var(--line);background:#fffdf8;position:sticky;top:0;z-index:5;}
.brand{font-weight:800;text-decoration:none;font-size:1.15rem;}
.site-header nav{display:flex;gap:.8rem;flex-wrap:wrap;}
.site-header nav a{text-decoration:none;font-weight:650;color:#202020;}
.page-intro{max-width:980px;margin:0 auto 1.25rem;}
.page-intro h1{font-size:clamp(2rem,5vw,4.2rem);line-height:1;margin:.25rem 0 .75rem;}
.eyebrow{font-weight:800;text-transform:uppercase;letter-spacing:.08em;color:#59616a;font-size:.8rem;}
.card{background:var(--card);border:1px solid var(--line);border-radius:1.1rem;padding:1.25rem;box-shadow:0 8px 24px rgba(0,0,0,.04);}
button{border:1px solid #111;background:#111;color:white;border-radius:999px;padding:.72rem 1rem;font:inherit;font-weight:750;cursor:pointer;}
button:hover{filter:brightness(.95);}
hr{border:none;border-top:1px solid var(--line);margin:1rem 0;}
.site-footer{padding:2rem 1.5rem;margin-top:2rem;border-top:1px solid var(--line);color:#59616a;}
@media (max-width:800px){.site-header{align-items:flex-start;flex-direction:column}.site-header nav{gap:.5rem}.site-header nav a{font-size:.95rem}}


/* Rev4.1 draw stability: prevent browser gestures/scroll from moving the surface while drawing. */
.svg-draw-lab,
.draw-stage,
.stage-scroll,
.plot-surface,
#drawSvg {
  touch-action: none;
  overscroll-behavior: contain;
}
.stage-scroll {
  overflow: hidden !important;
  max-width: 100%;
}
.plot-surface,
#drawSvg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
  transform: none !important;
  transform-origin: top left !important;
}
#pathsLayer path {
  vector-effect: non-scaling-stroke;
}


/* Rev4.2 draw lock hardening */
html.annplot-drawing-lock,
body.annplot-drawing-lock {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

.plot-surface,
#drawSvg {
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  cursor: crosshair;
}

.svg-draw-lab .stage-scroll {
  overscroll-behavior: contain;
  touch-action: none;
}

.draw-page.board-locked .svg-draw-lab {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #f4efe6;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 12px;
  overflow: hidden;
}

.draw-page.board-locked .draw-controls {
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.draw-page.board-locked .draw-stage,
.draw-page.board-locked .stage-scroll {
  height: calc(100vh - 24px);
  overflow: hidden;
}

.draw-page.board-locked #drawSvg {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 28px);
  background: #fffdf8;
}

#drawDiag {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.04);
  word-break: break-word;
}


/* Rev4.4 pointer alignment helpers */
#cursorLayer line,
#cursorLayer circle {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}
#cursorLayer .cursor-cross {
  stroke: #111;
  stroke-width: 1.5;
  opacity: 0.85;
}
#cursorLayer .cursor-dot {
  fill: #111;
  opacity: 0.75;
}
.draw-page.board-locked .stage-scroll {
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Rev4.5 calibration controls */
.compact-controls {
  grid-template-columns: 1fr 100px;
  gap: 8px 10px;
  align-items: center;
}
.compact-controls input {
  width: 100%;
}
