/* WRO 2026 Game Mat Planner — styles.css
   Restyled to match The Magic Lab's design system (dark, Cabinet Grotesk /
   JetBrains Mono, robotics orange-red accent — same family as Robot Realm). */

:root {
  /* Pointed at assets/magic-lab.css rather than copied, so this file follows
     the system instead of drifting from it. Robot Realm's hue moved to
     --t-robot today; this planner is in its family, so it moves too. */
  --bg:        var(--ink-900);
  --bg2:       var(--ink-850);
  --surface:   rgba(255,255,255,0.045);
  --surface-2: rgba(255,255,255,0.07);
  --border:    var(--line);
  --muted:     var(--text-2);
  --muted-2:   var(--text-3);

  --accent:    var(--t-robot);
  --accent-2:  #d9552c;      /* a deeper step of the same hue, not a second one */
  --tick:      var(--warn);

  --font-display: "Cabinet Grotesk", sans-serif;
  --font-body:    "Cabinet Grotesk", sans-serif;
  --font-mono:    "JetBrains Mono", monospace;

  --radius-2xs: 6px;
  --radius-xs:  8px;
  --radius-sm:  12px;
  --radius-md:  16px;
  --radius-lg:  20px;
  --radius-full: 99px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 150ms;

  /* Zone-box colours (kept distinct from each other for at-a-glance reading) */
  --zone-start:   #4cc9f0;
  --zone-notes:   #80ffb4;
  --zone-cable:   #ff7ad9;
  --zone-target:  #ffa94d;
  --zone-stage:   #c084fc;
  --zone-barrier: #ff4d4d;
}

* { box-sizing: border-box; }

/* Every <select> on this page is on a dark background, but browsers render
   the native option-list popup using the OS light theme by default — pale
   grey text on white, unreadable. color-scheme tells Chromium/Firefox to
   draw that popup (and other native controls) in dark mode; the explicit
   option colours below are a belt-and-braces fallback for browsers that
   only partially honour color-scheme for popups. */
html { color-scheme: dark; }
select { color-scheme: dark; }
select option {
  background: #0d1226;
  color: #e4e8f8;
}

/* ------------------ CUSTOM DROPDOWN ------------------
   color-scheme doesn't get fully honoured for the option-list popup on
   every browser/OS combination — confirmed on a real user's machine, not
   just one test environment — so every <select> gets progressively
   enhanced (see enhanceAllSelects() in app.js) into this fully-styled
   widget. The original <select> stays in the DOM as the real data source;
   it's just visually hidden. */
.csel { position: relative; display: inline-flex; vertical-align: middle; }
.csel select { display: none; }
/* This widget can end up inside the toolbar, the export modal, or the
   program-config box — each of those has its own "button"/"select"
   styling with varying specificity (".modal .body button" in particular
   out-specifies a plain ".csel-btn" class). !important keeps this one
   component looking the same everywhere instead of inheriting whichever
   container it happens to sit in. */
.csel .csel-btn {
  display: inline-flex !important; align-items: center !important; gap: 8px !important;
  background: rgba(255,255,255,0.05) !important; border: 1px solid var(--border) !important; color: var(--text) !important;
  border-radius: var(--radius-sm) !important; padding: 6px 10px !important; font-family: var(--font-body) !important; font-size: 12.5px !important;
  text-transform: none !important; letter-spacing: normal !important; font-weight: 400 !important;
  cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.csel .csel-btn:hover { background: rgba(255,255,255,0.09) !important; }
.csel .csel-btn.open { border-color: rgba(249,115,22,0.45) !important; }
.csel-btn::after { content: '▾'; font-size: 9px; color: var(--muted-2); }
.csel-list {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%;
  max-height: 280px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  z-index: 2000; display: none;
}
.csel-list.open { display: block; }
.csel-item {
  padding: 7px 12px; font-size: 12.5px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.csel-item:hover { background: rgba(255,255,255,0.08); }
.csel-item.active { background: rgba(249,115,22,0.16); color: #fdba74; }
.csel-group {
  padding: 6px 12px 2px; font-size:12px; text-transform:none; 
  color: var(--muted-2); font-family:inherit;
}

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    none;  /* Was two radial glows. */
}

/* width:100% matters here: linking magic-lab.css made body a flex column,
   and a centred child without it is sized to its content rather than the
   viewport - which had this page 642px wide on a 360px screen. */
.page { width: 100%; max-width: 1500px; margin: 0 auto; padding: 0 24px 64px; }

/* ------------------ NAV ------------------ */
nav.app-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.app-nav .nav-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: rgba(238,117,68,0.14);
  border: 1px solid rgba(249,115,22,0.28);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.app-nav .app-title {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(16px, 2vw, 20px);
  letter-spacing: -0.02em; line-height: 1;
  color: var(--paper); margin:0;}
.app-nav .nav-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-pill {
  font-family: var(--font-body);
  font-size: 12px; font-weight: 600; padding: 7px 15px;
  border-radius: var(--radius-full); border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  text-decoration: none; transition: all var(--dur) var(--ease); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1;
}
.nav-pill:hover { background: var(--surface-2); color: var(--text); border-color: rgba(255,255,255,0.18); }
.nav-tag {
  font-family:inherit; font-size:12px; font-weight: 700;
   text-transform:none;
  padding: 5px 10px; border-radius: var(--radius-full);
  border: 1px solid rgba(249,115,22,0.35); background: rgba(249,115,22,0.10); color: #fdba74;
}

.lead {
  max-width: 82ch;
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0 0 20px;
  color: var(--muted);
}
.lead strong { color: var(--text); }

/* ------------------ TOOLBAR ------------------ */
.toolbar {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-family: var(--font-body);
  font-size: 12px;
}
.toolbar .group {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.toolbar button {
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 8px 13px;
  cursor: pointer;
  font: inherit;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  transition: background var(--dur) var(--ease);
  border-right: 1px solid var(--border);
}
.toolbar .group button:last-child { border-right: 0; }
.toolbar button:hover { background: rgba(255,255,255,0.08); }
.toolbar button.active {
  background: rgba(238,117,68,0.22); color: var(--t-robot);
  color: #fff;
}
.toolbar .sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}
.toolbar .toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  color: var(--muted);
}
.toolbar .toggle input { margin: 0; accent-color: var(--accent); }
.toolbar select {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font: inherit;
  font-family: var(--font-body);
  cursor: pointer;
}
.toolbar input[type="number"] {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font: inherit;
  width: 70px;
  -moz-appearance: textfield;
}
.toolbar input[type="number"]::-webkit-outer-spin-button,
.toolbar input[type="number"]::-webkit-inner-spin-button {
  opacity: 1;
}
.toolbar .readout {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  background: rgba(255, 209, 102, 0.12);
  color: var(--tick);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  min-width: 170px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.toolbar .hint {
  color: var(--muted-2);
  font-size: 11px;
}
.toolbar #clearAll {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239,68,68,0.28);
  border-radius: var(--radius-sm);
  color: #fca5a5;
}
.toolbar #clearAll:hover { background: rgba(239, 68, 68, 0.22); color: #fff; }
.toolbar #exportCode {
  background: var(--paper); color: var(--ink-900);
  border-radius: var(--radius-sm);
}
.toolbar #saveBtn,
.toolbar #loadBtn,
.toolbar #printBtn,
.toolbar #savePathBtn,
.toolbar #robotSaveBtn {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.robot-custom-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: -6px 0 14px;
}
.robot-custom-list:empty,
.robot-custom-list[style*="display: none"] { margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-full); padding: 5px 6px 5px 12px; color: var(--muted);
}
.chip button {
  background: rgba(239,68,68,0.15); color: #fca5a5; border: 0;
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.chip button:hover { background: rgba(239,68,68,0.35); color: #fff; }

/* ---- open/closed robot state ---- */
/* #robotStateToggle (ID) lives inside .toolbar, whose ".toolbar button" rule
   is the same specificity as a plain ".robot-state-toggle button" class
   selector — an ID keeps this correct regardless of stylesheet order. */
.robot-state-toggle { display: flex; border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--border); flex-shrink: 0; }
#robotStateToggle button {
  font-family: var(--font-mono) !important; font-size: 11px !important; font-weight: 700 !important; padding: 7px 12px !important;
  border: 0 !important; background: rgba(255,255,255,0.03) !important; color: var(--muted-2) !important; cursor: pointer;
  text-transform: none !important; letter-spacing: normal !important;
  border-right: 1px solid var(--border) !important;
}
#robotStateToggle button:last-child { border-right: 0 !important; }
#robotStateToggle button.active { background: rgba(238,117,68,0.22) !important; color: var(--t-robot);color: #fff !important; }

.robot-size-fields { display: inline-flex; align-items: center; gap: 10px; ;flex-wrap:wrap;}
.mini-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.mini-label input[type="number"] {
  width: 58px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 5px 7px; font: inherit;
}

.robot-save-form {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: -6px 0 14px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.robot-save-form input[type="text"] {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 10px; font-family: var(--font-body); font-size: 12.5px; width: 160px;
}
.robot-save-form input[type="number"] {
  width: 58px; background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 8px; font: inherit;
}
.robot-save-form button {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: var(--radius-full); border: 0; cursor: pointer;
  background: var(--paper); color: var(--ink-900);
}
.robot-save-form button:hover { filter: brightness(1.1); }
.robot-save-form button#robotSaveCancel {
  background: rgba(255,255,255,0.05); color: var(--muted);
}

/* ------------------ STAGE ------------------ */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2362 / 1143;
  background: #0a0e1c;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 28px 60px -30px rgba(0,0,0,0.6);
}
.stage img.mat {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: fill;
  user-select: none; -webkit-user-drag: none;
}
.stage svg.overlay,
.stage svg.measure {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
}
.stage svg.overlay { pointer-events: none; }
/* touch-action:none stops the browser's own pan/pinch-zoom from fighting
   with our touch handlers (measuring, placing, dragging) -- without it,
   a touch-drag on the mat scrolls or zooms the page instead. */
.stage svg.measure { cursor: crosshair; touch-action: none; }
.stage[data-tool="none"] svg.measure { cursor: default; pointer-events: none; }
.stage[data-tool="footprint"] svg.measure,
.stage[data-tool="pose"] svg.measure { cursor: move; }

/* Toggle visibility of static overlay groups */
.stage[data-show-grid="false"] g.grid-minor,
.stage[data-show-grid="false"] g.grid-major { display: none; }
.stage[data-show-zones="false"] g.zones-layer { display: none; }
.stage[data-show-ruler="false"] g.ruler-layer { display: none; }

/* SVG element styling */
.grid-minor { stroke: rgba(255,255,255,0.14); stroke-width: 1; vector-effect: non-scaling-stroke; fill: none; }
.grid-major { stroke: rgba(255,255,255,0.30); stroke-width: 1.4; vector-effect: non-scaling-stroke; fill: none; }
.border-stroke { stroke: var(--tick); stroke-width: 3; vector-effect: non-scaling-stroke; fill: none; }
.tick { stroke: var(--tick); stroke-width: 2; vector-effect: non-scaling-stroke; }

.dim-text-light {
  font-family: var(--font-mono);
  font-weight: 800;
  fill: #ffffff;
  paint-order: stroke;
  stroke: rgba(0,0,0,.85);
  stroke-width: 5;
  stroke-linejoin: round;
}
.label-text {
  font-family: var(--font-mono);
  fill: #f4f1ea;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(8,12,26,0.92);
  stroke-width: 5;
  stroke-linejoin: round;
}
.zone-box { fill: none; stroke-width: 2.4; stroke-dasharray: 14 8; vector-effect: non-scaling-stroke; }
.zone-box.start   { stroke: var(--zone-start); }
.zone-box.notes   { stroke: var(--zone-notes); }
.zone-box.cable   { stroke: var(--zone-cable); }
.zone-box.target  { stroke: var(--zone-target); }
.zone-box.stage   { stroke: var(--zone-stage); }
.zone-box.barrier { stroke: var(--zone-barrier); stroke-dasharray: 6 5; }
.leader { stroke: rgba(255,255,255,0.6); stroke-width: 1.2; vector-effect: non-scaling-stroke; fill: none; }

/* Snap indicator */
.snap-ring {
  fill: none;
  stroke: var(--tick);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* Measurement primitives */
.m-line { stroke-width: 2.5; vector-effect: non-scaling-stroke; fill: none; stroke-linecap: round; }
.m-line-shadow { stroke: rgba(0,0,0,0.6); stroke-width: 5; vector-effect: non-scaling-stroke; fill: none; stroke-linecap: round; }
.m-label {
  font-family: var(--font-mono);
  font-weight: 700;
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(8,12,26,0.92);
  stroke-width: 4;
  stroke-linejoin: round;
}
.m-arc { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
.m-footprint {
  fill: rgba(76, 201, 240, 0.18);
  stroke: #4cc9f0;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 8 6;
}
.m-footprint-label {
  font-family: var(--font-mono);
  font-weight: 800;
  fill: #4cc9f0;
  paint-order: stroke;
  stroke: rgba(0,0,0,.7);
  stroke-width: 4;
  stroke-linejoin: round;
}
.m-pose-arrow {
  fill: rgba(255, 209, 102, 0.85);
  stroke: rgba(0,0,0,0.7);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
/* A committed POSE's silhouette, draggable while the POSE tool is active
   (see tools.js drawRobotShape opts.draggable). */
.m-pose-draggable { cursor: grab; touch-action: none; }
.m-pose-draggable:active { cursor: grabbing; }

/* Measurements list */
.meas-list {
  margin: 16px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  max-height: 240px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
}
.meas-list:empty { display: none; }
.meas-list .row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.meas-list .row:last-child { border-bottom: 0; }
.meas-list .row .swatch-dot {
  width: 12px; height: 12px; border-radius: 3px;
}
.meas-list .row .delete {
  background: transparent;
  color: var(--muted-2);
  border: 0;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.meas-list .row .delete:hover { color: var(--accent-2); }
.meas-list .row .desc { color: var(--text); }
.meas-list .row .info { color: var(--muted); font-size: 11px; }

/* ------------------ SAVED PATHS ------------------ */
#savedPathsSection {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px;
}
#savedPathsSection h2 {
  font-family:inherit; font-size:12px; text-transform:none;
   margin: 0 0 10px; color: #fdba74;
}
.saved-paths-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.saved-paths-table th {
  text-align: left; font-family:inherit; font-size:12px; text-transform:none;
   color: var(--muted-2); padding: 0 10px 8px; font-weight: 600;
}
.saved-paths-table td { padding: 8px 10px; border-top: 1px solid var(--border); color: var(--muted); }
.saved-paths-table td:first-child { color: var(--text); font-weight: 600; }
.saved-paths-table td.best { color: #86efac; font-weight: 700; }
.saved-paths-table td.actions { display: flex; gap: 6px; }
.chip-btn {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  padding: 5px 11px; border-radius: var(--radius-full); border: 1px solid var(--border);
  background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer;
}
.chip-btn:hover { background: rgba(255,255,255,0.10); }
.chip-btn.danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.28); color: #fca5a5; }
.chip-btn.danger:hover { background: rgba(239,68,68,0.25); color: #fff; }

/* ------------------ KEY ZONES TABLE ------------------ */
#keyZones {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px;
  overflow-x: auto;
}
#keyZones h2 {
  font-family:inherit; font-size:12px; text-transform:none;
   margin: 0 0 10px; color: #fdba74;
}
.zones-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 12.5px; }
.zones-table th {
  text-align: right; font-family:inherit; font-size:12px; text-transform:none;
   color: var(--muted-2); padding: 0 10px 8px; font-weight: 600;
}
.zones-table th:first-child { text-align: left; }
.zones-table td {
  padding: 7px 10px; border-top: 1px solid var(--border); color: var(--muted);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right;
  white-space: nowrap;
}
.zones-table td.zone-name {
  text-align: left; color: var(--text); font-family: var(--font-body); font-weight: 600;
  white-space: normal;
}
.zones-table tr:hover td { background: rgba(255,255,255,0.03); }

/* ------------------ ROUTE PLANNER ------------------ */
#programSection {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 14px 16px 16px;
}
.program-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.program-head h2 {
  font-family:inherit; font-size:12px; text-transform:none;
   margin: 0; color: #fdba74;
}
.program-config {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
  padding: 10px 12px; margin-bottom: 12px;
  background: rgba(8,12,26,0.35); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.program-config label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); font-family: var(--font-mono);
}
.program-config input[type="number"] {
  width: 60px; background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-xs); padding: 4px 6px; font-family: var(--font-mono); font-size: 12px;
}
.program-config select {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-xs); padding: 4px 6px; font-family: var(--font-mono); font-size: 12px;
}
.program-add-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 4px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border);
  /* Pinned so it's always in reach while scrolling a long step list --
     the whole point being you shouldn't have to scroll back to the top
     just to add or change what's next. */
  position: sticky; top: 0; z-index: 5; background: var(--surface);
}
.program-insert-status { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }
.program-insert-status a { color: var(--accent-2); cursor: pointer; }
.program-insert-status a:hover { text-decoration: underline; }
.program-add-row select,
.program-add-row input[type="number"],
.program-add-row input[type="text"] {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 9px; font-family: var(--font-body); font-size: 12.5px;
}
.program-add-row input[type="number"] { width: 78px; }
.program-add-row input[type="text"] { width: 180px; }
.program-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#stepAddBtn {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: var(--radius-full); border: 0; cursor: pointer;
  background: var(--paper); color: var(--ink-900);
  margin-left: auto;
}
#stepAddBtn:hover { filter: brightness(1.1); }

.program-steps { list-style: none; margin: 0; padding: 0; }
.program-steps:empty { display: none; }
.program-step {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 12.5px;
}
.program-step:last-child { border-bottom: 0; }
.program-step-num {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted-2);
  width: 18px; text-align: right; flex-shrink: 0;
}
.program-step-desc { flex: 1; color: var(--text); }
.program-step-actions { display: flex; gap: 4px; flex-shrink: 0; }
.program-step-actions button {
  width: 22px; height: 22px; border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: rgba(255,255,255,0.04); color: var(--muted); cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.program-step-actions button:hover:not(:disabled) { background: rgba(255,255,255,0.10); color: var(--text); }
.program-step-actions button:disabled { opacity: 0.3; cursor: default; }
.program-step-actions button.danger { color: #fca5a5; }
.program-step-actions button.danger:hover { background: rgba(239,68,68,0.25); color: #fff; }

.program-step[draggable="true"] { cursor: grab; }
.program-step.dragging { opacity: 0.35; }

/* A strip between every pair of steps (and above the first / below the
   last): click it to say "add the next new step here", or drag a step
   onto it to move that step here. Visible at rest -- not hidden until
   hover -- since it's a real, always-available control, not decoration. */
.program-insert-marker {
  height: 18px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; transition: height .12s ease;
}
.program-insert-marker::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: var(--border); transform: translateY(-50%);
}
.program-insert-plus {
  width: 24px; height: 24px; border-radius: 50%; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.09); color: var(--muted);
  opacity: 1; transform: scale(1); transition: background .12s ease, color .12s ease, transform .12s ease;
}
.program-insert-marker:hover .program-insert-plus { transform: scale(1.15); background: rgba(255,255,255,0.16); color: var(--text); }
.program-insert-marker:hover::before { background: var(--muted-2); }
.program-insert-marker.active { height: 30px; }
.program-insert-marker.active .program-insert-plus {
  transform: scale(1.2); background: var(--accent); color: #fff;
}
.program-insert-marker.active::before { background: var(--accent); opacity: 0.5; }
.program-insert-marker.drag-over { height: 30px; }
.program-insert-marker.drag-over .program-insert-plus { transform: scale(1.3); background: var(--accent-2); color: #fff; }
.program-insert-marker.drag-over::before { background: var(--accent-2); }

/* ---- mosaic frame pattern configurator ---- */
.mosaic-pattern-box {
  padding: 10px 12px; margin-bottom: 12px;
  background: rgba(8,12,26,0.35); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.mosaic-pattern-hint { margin: 0 0 10px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.mosaic-pattern-grid {
  display: grid; grid-template-columns: repeat(4, 44px); gap: 6px;
  margin-bottom: 10px;
}
.mosaic-slot {
  width: 44px; height: 33px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  color: rgba(0,0,0,0.55); background: rgba(255,255,255,0.04);
}
.mosaic-slot[data-colour="empty"] { color: var(--muted-2); background: rgba(255,255,255,0.04); }
.mosaic-slot[data-colour="white"]  { background: #e9edf5; }
.mosaic-slot[data-colour="green"]  { background: #22c55e; }
.mosaic-slot[data-colour="blue"]   { background: #3b82f6; color: rgba(255,255,255,0.85); }
.mosaic-slot[data-colour="yellow"] { background: #facc15; }

.program-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
#programExportBtn {
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  padding: 9px 18px; border-radius: var(--radius-full); border: 0; cursor: pointer;
  background: var(--paper); color: var(--ink-900);
}
#programExportBtn:hover { filter: brightness(1.1); }
#programCode {
  width: 100%; min-height: 340px;
  font-family: var(--font-mono); font-size: 12px;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  resize: vertical; background: #060912; color: #e2e8f0; white-space: pre;
}

/* ---- route walker ---- */
.walker-box {
  margin-top: 14px; padding: 12px 14px;
  background: rgba(8,12,26,0.35); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.walker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.walker-head h3 {
  margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--text);
}
.walker-ref-label {
  display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-family: var(--font-mono);
}
.walker-ref-label select {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-xs); padding: 4px 6px; font-family: var(--font-mono); font-size: 12px;
}
.walker-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.walker-controls button:disabled { opacity: 0.35; cursor: default; }
.walker-readout {
  font-family: var(--font-mono); font-size: 11.5px; color: #fdba74;
  background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.20);
  border-radius: var(--radius-sm); padding: 8px 12px; line-height: 1.5;
}

/* SVG robot marker drawn by the walker */
.walker-footprint {
  fill: rgba(250,204,21,0.16);
  stroke: #facc15;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}
/* Closed (folded, pre-unfold) draws dashed to read as "tucked in";
   open (unfolded) draws solid as the robot's real running footprint. */
.walker-footprint-closed { stroke-dasharray: 6 5; }
.walker-footprint-open { stroke-dasharray: none; }
.walker-arrow {
  fill: rgba(250,204,21,0.9);
  stroke: rgba(0,0,0,0.6);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.walker-trail {
  fill: none;
  stroke: #facc15;
  stroke-width: 2;
  stroke-dasharray: 3 5;
  vector-effect: non-scaling-stroke;
  opacity: 0.75;
}
.walker-refdot {
  fill: #fff;
  stroke: #facc15;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}
/* Drive wheels, front/back attachment motors, and line sensors -- drawn
   inside the robot's own rotated <g> so they turn with it. Wheels/motors
   are a fixed visual convention (no configurable position beyond a port
   letter); sensors are drawn at their real configured Robot config offset. */
.walker-wheel {
  fill: #1f2937;
  stroke: rgba(255,255,255,0.5);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.walker-motor-marker {
  fill: #fb923c;
  stroke: rgba(0,0,0,0.6);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.walker-sensor-marker {
  stroke: rgba(0,0,0,0.6);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.walker-sensor-a { fill: #22d3ee; }
.walker-sensor-b { fill: #f472b6; }
.walker-marker-label {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  fill: #fff;
  stroke: rgba(0,0,0,0.85);
  stroke-width: 3px;
  paint-order: stroke;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
/* "In hand" preview shown while placing the robot, before either click has
   landed — translucent and unrooted so it clearly reads as not-yet-placed. */
.walker-ghost {
  opacity: 0.5;
  pointer-events: none;
}
.walker-ghost .walker-footprint {
  stroke-dasharray: 4 4;
}
/* The placed robot stays draggable even while the mat is otherwise idle --
   svg.measure goes pointer-events:none there (see .stage[data-tool="none"]
   svg.measure), so this opts the robot's own hit area back in explicitly. */
.walker-robot-live {
  pointer-events: all;
  touch-action: none;
  cursor: grab;
}
.walker-robot-live:active { cursor: grabbing; }

/* ---- simulated-run game elements (Senior only) ---- */
.elem-tile {
  stroke: rgba(0,0,0,0.55); stroke-width: 1.5; vector-effect: non-scaling-stroke;
}
.elem-cement {
  stroke: rgba(0,0,0,0.5); stroke-width: 1.5; vector-effect: non-scaling-stroke;
}
.elem-cement-loose { opacity: 0.55; stroke-dasharray: 2 3; }
.elem-cement-settled { opacity: 1; }
.elem-tool {
  fill: rgba(226,232,240,0.85); stroke: #64748b; stroke-width: 2;
  vector-effect: non-scaling-stroke; stroke-dasharray: 5 4;
}
.elem-tool-delivered { fill: rgba(34,197,94,0.35); stroke: #22c55e; stroke-dasharray: none; }
.elem-frame-tile { stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.elem-frame-tile-correct { stroke: #22c55e; }
.elem-frame-tile-incorrect { stroke: #ef4444; }
.elem-frame-tile-unknown { stroke: #94a3b8; stroke-dasharray: 3 3; }
.elem-carried {
  stroke: #fff; stroke-width: 1.5; stroke-dasharray: 3 2;
  vector-effect: non-scaling-stroke; opacity: 0.95;
}

/* ---- 3D-printed mosaic frame (static, traced from the official STL) ---- */
.frame-body {
  fill: rgba(226,232,240,0.16);
  stroke: rgba(226,232,240,0.55);
  stroke-width: 2; vector-effect: non-scaling-stroke;
}
.frame-pocket {
  fill: rgba(8,12,26,0.45);
  stroke: rgba(226,232,240,0.4);
  stroke-width: 1.5; vector-effect: non-scaling-stroke;
}

/* ------------------ SCORING PANEL ------------------ */
#scoringPanel {
  margin-top: 16px;
  border: 1px solid rgba(249,115,22,0.25);
  border-radius: var(--radius-lg);
  background: var(--ink-850);
  padding: 18px 20px 20px;
}
.scoring-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.scoring-head h2 {
  font-family: var(--font-display); font-weight: 800; font-size: 17px; margin: 0;
  color: #fff; letter-spacing: -0.01em;
}
.scoring-total {
  font-family: var(--font-mono); font-weight: 700; font-size: 20px;
  color: #fdba74; font-variant-numeric: tabular-nums;
}
.scoring-reset {
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: var(--radius-full); padding: 5px 12px; cursor: pointer;
}
.scoring-reset:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.scoring-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.score-cat {
  background: rgba(8,12,26,0.35); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px;
}
.score-cat-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.score-cat-name { font-family: var(--font-display); font-weight: 700; font-size: 12.5px; color: var(--text); }
.score-cat-sub { font-family: var(--font-mono); font-size: 11px; color: #fdba74; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.05); }
.score-row:first-of-type { border-top: 0; }
.score-row-label { font-size: 12px; color: var(--muted); flex: 1; }
.score-row-ctrl { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tristate { display: flex; border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--border); }
.tristate button {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; padding: 5px 10px;
  border: 0; background: rgba(255,255,255,0.03); color: var(--muted-2); cursor: pointer;
  border-right: 1px solid var(--border);
}
.tristate button:last-child { border-right: 0; }
.tristate button.active { background: rgba(238,117,68,0.22); color: var(--t-robot); }
.score-row-hint { font-family: var(--font-mono); font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.score-row input[type="number"] {
  width: 52px; background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-xs); padding: 4px 6px; font-family: var(--font-mono); font-size: 12px;
}
.score-check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.score-check input { accent-color: var(--accent); }

/* ------------------ INFO PANEL ------------------ */
.info {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.info section {
  font-size: 12.5px; line-height: 1.55;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px;
}
.info h2 {
  font-family:inherit;
  font-size:12px;
  text-transform:none;
  
  margin: 0 0 10px;
  color: #fdba74;
}
.info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; }
.info dt { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-2); }
.info dd { margin: 0; color: var(--muted); }
.info .legend ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.info .legend li { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 8px; color: var(--muted); }
.info .swatch { width: 18px; height: 6px; border-radius: 1px; }

footer.site {
  margin-top: 28px;
  font-family:inherit;
  font-size:12px;
  text-transform:none;
  
  color: var(--muted-2);
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}

/* ------------------ MODAL (code export) ------------------ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(5, 7, 15, 0.75);
  
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 90px rgba(0,0,0,0.7);
}
.modal h2 {
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.modal h2 button {
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted-2);
}
.modal h2 button:hover { color: var(--accent-2); }
.modal .body {
  padding: 16px 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal .body textarea {
  width: 100%;
  min-height: 280px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  background: #060912;
  color: #e2e8f0;
}
.modal .body .row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.modal .body label { font-size: 12px; color: var(--muted); }
.modal .body select {
  padding: 6px 10px; font-size: 13px;
  background: rgba(255,255,255,0.05); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.modal .body p { color: var(--muted-2) !important; }
.modal .body button {
  background: var(--paper); color: var(--ink-900);
  
  border: 0;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
}
.modal .body button:hover { filter: brightness(1.1); }
.modal .body p.import-ok { color: #86efac !important; font-weight: 700; }
.modal .body p.import-warn { color: #fca5a5 !important; font-weight: 700; margin-top: 6px; }
.modal .body ul.import-warn-list {
  margin: 4px 0 0; padding-left: 18px; color: var(--muted-2); font-size: 12px;
  font-family: var(--font-mono); max-height: 140px; overflow: auto;
}
.modal .body ul.import-warn-list li { margin-bottom: 3px; }
.modal .body p.import-note-head { color: #fbbf24 !important; font-weight: 700; margin-top: 6px; }
.modal .body ul.import-note-list {
  margin: 4px 0 0; padding-left: 18px; color: var(--muted-2); font-size: 12px;
  font-family: var(--font-mono); max-height: 160px; overflow: auto;
}
.modal .body ul.import-note-list li { margin-bottom: 3px; }

/* Tiny toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--tick);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: transform 240ms, opacity 240ms;
  z-index: 1100;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 720px) {
  .info { grid-template-columns: 1fr 1fr; }
  .scoring-body { grid-template-columns: 1fr; }
  nav.app-nav { justify-content: center; text-align: center; }
}

/* Touch-target sizing for touch/stylus input specifically (not just narrow
   screens -- a tablet in landscape can be wider than most phone breakpoints
   but still needs a finger-sized hit area, not a mouse-sized one). */
@media (pointer: coarse) {
  .program-step-actions button { width: 36px; height: 36px; font-size: 15px; }
  .meas-list .row .delete { padding: 10px 12px; font-size: 18px; }
  .toolbar button, .chip-btn { min-height: 38px; }
}

/* ------------------ PRINT STYLES ------------------ */
@media print {
  @page { size: A3 landscape; margin: 12mm; }
  body { background: #fff; color: #000; }
  .page { max-width: none; padding: 0; }
  .toolbar, .meas-list .delete, .modal-bg, .toast, nav.app-nav, #savedPathsSection .actions { display: none !important; }
  .stage { box-shadow: none; border: 1px solid #000; page-break-inside: avoid; }
  .info { page-break-before: auto; }
  .info section { background: #fff; border-color: #ccc; }
  footer.site { font-size: 10px; }
  .zone-box { stroke-dasharray: 8 4 !important; }
}


/* The zones table is 560px of real columns and should not be squeezed —
   a reference table you read across. It gets its own scroll container so
   the table scrolls instead of the whole page. */
section:has(> .zones-table) { overflow-x: auto; }
.zones-table { min-width: 520px; }
