/* Version 0.4 — Package 1.0 */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #eef1f4;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

/* Version 1.3 */
#v3d-loading-screen.v3d-loading-screen { position:absolute; inset:0; z-index:1000000; background:#fff; opacity:1; visibility:visible; pointer-events:auto; overflow:hidden; transition:opacity .45s ease, visibility .45s ease; }
#v3d-loading-screen.v3d-loading-screen.hidden { opacity:0; visibility:hidden; pointer-events:none; }
.v3d-loading-spinner-overlay { position:absolute; inset:0; width:100%; height:100%; z-index:1; pointer-events:none; }
.v3d-loading-spin-group { transform-origin:0 0; animation:v3dLoadingBarSpin 1.15s linear infinite; }
.v3d-loading-bar { fill:rgba(140,140,140,.9); }
@keyframes v3dLoadingBarSpin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }
.v3d-loading-logo { position:absolute; left:50%; top:50%; width:36%; max-height:30%; object-fit:contain; transform:translate(-50%,-50%) translateY(var(--v3d-logo-offset,0px)); z-index:2; user-select:none; -webkit-user-drag:none; }
.v3d-loading-copy { position:absolute; left:7%; right:7%; bottom:5.5%; text-align:center; z-index:3; }
.v3d-loading-line { margin:0; white-space:pre-wrap; line-height:1.15; transform:translateY(var(--v3d-line-offset,0px)); }

/*
  v7.0.16 — fixed-design viewport-fit shell.

  IMPORTANT: #stage is always a true 1920 x 1080 design surface. The
  ViewportFit module applies one uniform CSS transform to that complete
  surface. This is intentionally different from changing #stage width/height:
  fixed-pixel HTML overlays (Guided Tutorial, menus, buttons) now scale in the
  same proportion as the SVG schematic and palette.

  This also compensates for browser zoom. At 33% browser zoom the CSS viewport
  becomes larger, so the stage transform grows; at 150% it becomes smaller, so
  the stage transform shrinks. The learner sees a consistently fitted builder.
*/
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(1);
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 10px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  will-change: transform;
}

/*
  #scrollArea fills the always-visible #stage viewport and scrolls
  vertically once a low-voltage section pushes the circuit taller than it.
  #circuitSvg is deliberately NOT height:100% here — with no width/height
  attributes on the element itself, "width:100%; height:auto" makes the
  browser derive its rendered height from the viewBox's own aspect ratio
  (updated in JS whenever a section is added), so it naturally grows
  taller than its scrollable container instead of being squashed to fit.
*/
#scrollArea {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#circuitSvg {
  display: block;
  width: 100%;
  height: auto;
  /* pinch-zoom (not none): keeps single-finger panning/scrolling under our
     own pointer-event drag logic, but still lets the browser handle
     two-finger pinch-to-zoom natively instead of swallowing it. */
  touch-action: pinch-zoom;
  user-select: none;
}

/*
  The palette is a separate SVG layered on top, outside #scrollArea, so it
  stays fixed in place while the circuit content scrolls underneath it.
*/
#paletteSvg {
  position: absolute;
  left: 0;
  top: 0;
  width: 13.5417%; /* Config.PALETTE_W / Config.VIEW_W */
  height: 100%;
  z-index: 15;
  display: block;
}

/* Check Circuit uses the reusable SC480 component. The panel is the same
   fixed 260/1920-width strip as the palette. The meter is fit by its native
   351.574 x 1080 aspect ratio and is never stretched. */
#sc480Panel {
  position: absolute;
  left: 0;
  top: 0;
  width: 13.5417%;
  height: 100%;
  z-index: 18;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #f5f7fa;
  border-right: 1px solid #c7cfd9;
}
#sc480Panel[hidden] { display: none !important; }
#sc480Meter { width: 100%; height: 100%; }

/* Critical integration override: contain the meter without distorting it.
   At a 260 x 1080 palette strip this yields about 260 x 799 and centers it. */
#sc480Meter .sc480-component__fit {
  display: flex;
  align-items: center;
  justify-content: center;
}
#sc480Meter .sc480-component__meter {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 351.574 / 1080;
  flex: 0 0 auto;
}

#overlays {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

#overlays * {
  pointer-events: auto;
}

.mode-btn {
  width: 50px;
  height: 50px;
  padding: 8px;
  border: 2px solid #2377e8;
  border-radius: 6px;
  background: #ffffff;
  color: #2377e8;
  font: 700 12px Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 1;
}

.mode-btn:hover:not(:disabled) {
  background: #2377e8;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(35, 119, 232, 0.3);
}

.mode-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.mode-toggle-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #2377e8;
  color: #ffffff;
  font: 700 14px Arial, Helvetica, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(35, 119, 232, 0.35);
  transition: all 0.2s ease;
}

.mode-toggle-btn:hover:not(:disabled) {
  background: #1c63c4;
}

.mode-toggle-btn:disabled {
  cursor: default;
  opacity: 0.5;
}


@media (max-width: 900px) {
  #app {
    padding: 10px;
  }

  #stage {
    border-radius: 8px;
  }
}

@media (max-width: 800px) and (orientation: portrait) {
  body::before {
    content: "Rotate device to landscape for this trainer.";
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #ffffff;
    color: #111111;
    font: 900 20px/1.3 Arial, sans-serif;
    text-align: center;
  }
}

/* =====================================================
   Global menu/modal interaction lock — Package 1.0
   ===================================================== */
#menuInteractionShield {
  position: absolute;
  inset: 0;
  z-index: 19990;
  background: rgba(17, 25, 36, 0.18);
  pointer-events: auto;
  cursor: default;
}

#menuInteractionShield[hidden] {
  display: none !important;
}

/* While the menu system owns input, tutorial and builder controls remain
   visible but cannot receive pointer input through their own high z-index. */
body.menu-system-locked .guided-tutorial,
body.menu-system-locked .guided-tutorial-modal {
  pointer-events: none !important;
}

/* =====================================================
   Main menu and Coming Soon modal — Version 1.2
   ===================================================== */
#mainMenuButton {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 20010;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #1f2b3a;
  cursor: pointer;
  box-shadow: none;
}

#mainMenuButton:hover,
#mainMenuButton.is-open {
  background: rgba(35, 119, 232, 0.10);
  color: #2377e8;
}

#mainMenuButton:focus-visible {
  outline: 2px solid #2377e8;
  outline-offset: 2px;
}

.menu-bars {
  width: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-bars span {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}

#mainMenuPanel {
  position: absolute;
  top: 54px;
  left: 14px;
  z-index: 20020;
  width: 230px;
  min-height: 270px;
  padding: 10px 0 46px;
  border: 1px solid #d8dee7;
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(17, 25, 36, 0.18);
}

#mainMenuPanel[hidden],
#comingSoonModal[hidden],
#helpModal[hidden] {
  display: none;
}

.main-menu-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.main-menu-item,
.main-menu-exit {
  appearance: none;
  width: 100%;
  min-height: 38px;
  padding: 8px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #2a3340;
  font: 800 18px Arial, Helvetica, sans-serif;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.main-menu-item:hover,
.main-menu-exit:hover,
.main-menu-item:focus-visible,
.main-menu-exit:focus-visible {
  background: #eef5ff;
  color: #1769d2;
  outline: none;
}

.main-menu-exit {
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 100%;
  border-top: 1px solid #e2e7ee;
}

#comingSoonModal {
  position: absolute;
  inset: 0;
  z-index: 20030;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 25, 36, 0.56);
}

.coming-soon-dialog {
  position: relative;
  width: min(420px, 52%);
  min-height: 220px;
  padding: 38px 34px;
  border-radius: 12px;
  background: #ffffff;
  text-align: center;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.28);
}

.coming-soon-section {
  margin-bottom: 18px;
  color: #2377e8;
  font: 800 18px Arial, Helvetica, sans-serif;
}

.coming-soon-dialog h2 {
  margin: 0;
  color: #1f2b3a;
  font: 900 34px Arial, Helvetica, sans-serif;
}

.coming-soon-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #596675;
  font: 400 32px/32px Arial, Helvetica, sans-serif;
  cursor: pointer;
}


/* Thermoswitch selection menu — Version 0.1 */
.thermoswitch-picker {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.34);
}

.thermoswitch-picker.is-open {
  display: flex;
}

.thermoswitch-picker__dialog {
  width: 620px;
  max-width: calc(100% - 64px);
  padding: 26px;
  border: 1px solid #dce2ea;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.26);
}

.thermoswitch-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.thermoswitch-picker__header h2 {
  margin: 0;
  color: #253044;
  font: 800 24px/1.2 Arial, Helvetica, sans-serif;
}

.thermoswitch-picker__close {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #5b6573;
  font: 400 32px/34px Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.thermoswitch-picker__close:hover {
  background: #f0f3f7;
  color: #182235;
}

.thermoswitch-picker__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.thermoswitch-picker__option {
  min-height: 78px;
  padding: 16px 18px;
  border: 1px solid #dce2ea;
  border-radius: 12px;
  background: #ffffff;
  color: #2a3340;
  text-align: left;
  font: 700 18px/1.25 Arial, Helvetica, sans-serif;
  cursor: grab;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.thermoswitch-picker__option:hover {
  border-color: #2377e8;
  box-shadow: 0 7px 18px rgba(35, 119, 232, 0.14);
  transform: translateY(-1px);
}

.thermoswitch-picker__option:active {
  cursor: grabbing;
}

/* ================================================================
   Circuit zoom control — v0.2
   Positioned immediately to the right of the Build/Check controls.
   ================================================================ */
.circuit-zoom-control {
  position: absolute;
  left: calc(13.5417% + 14px);
  bottom: 16px;
  z-index: 26;
  width: 168px;
  padding: 9px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 1px solid #d6dde7;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 12px rgba(25, 42, 66, 0.12);
  color: #2a3340;
  font-family: Arial, Helvetica, sans-serif;
  pointer-events: auto;
}

.circuit-zoom-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  line-height: 1;
}

.circuit-zoom-label {
  font-size: 14px;
  font-weight: 800;
}

.circuit-zoom-value {
  min-width: 28px;
  text-align: right;
  font-size: 14px;
  font-weight: 800;
  color: #2377e8;
}

.circuit-zoom-range {
  width: 100%;
  margin: 0;
  accent-color: #2377e8;
  cursor: pointer;
}

.circuit-zoom-control.is-disabled {
  opacity: 0.48;
  box-shadow: none;
}

.circuit-zoom-control.is-disabled .circuit-zoom-range {
  cursor: not-allowed;
}

/* Canvas action controls — Version 1.0 */
.canvas-action-controls {
  position: absolute;
  left: calc(13.5417% + 196px);
  bottom: 16px;
  z-index: 27;
  display: flex;
  gap: 7px;
  align-items: center;
  pointer-events: auto;
}
.canvas-action-controls button {
  min-width: 62px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #bfc9d6;
  border-radius: 7px;
  background: rgba(255,255,255,0.97);
  color: #2a3340;
  font: 800 13px Arial, Helvetica, sans-serif;
  box-shadow: 0 3px 10px rgba(25,42,66,0.11);
  cursor: pointer;
}
.canvas-action-controls button:hover:not(:disabled) { border-color: #2377e8; color: #2377e8; }
.canvas-action-controls button:disabled { opacity: 0.42; cursor: not-allowed; box-shadow: none; }


/* ================================================================
   Interaction cursor restoration — v3.3
   The body-level class prevents component hit targets from overriding the
   crosshair while a wire is actively being drawn.
   ================================================================ */
html.esb-wire-dragging,
html.esb-wire-dragging *,
body.esb-wire-dragging,
body.esb-wire-dragging * {
  cursor: crosshair !important;
}

/* =====================================================
   Scenario Author Mode — Version 1.0
   ===================================================== */
#versionLabel.is-author-holding { color:#2878c8 !important; }
.scenario-author-modal {
  position:absolute;
  inset:0;
  z-index:120;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(15, 27, 42, 0.48);
  font-family:Arial, Helvetica, sans-serif;
}
.scenario-author-modal[hidden], #scenarioAuthorBanner[hidden], #scenarioAuthorOpenButton[hidden] { display:none !important; }
.scenario-author-dialog {
  box-sizing:border-box;
  width:min(760px, 86%);
  max-height:88%;
  overflow:auto;
  border:2px solid #26384d;
  border-radius:14px;
  background:#fff;
  box-shadow:0 18px 54px rgba(0,0,0,.28);
  padding:24px;
  color:#152235;
}
.scenario-author-password-dialog { width:min(430px, 84%); }
.scenario-author-dialog h2 { margin:0 0 18px; font-size:26px; }
.scenario-author-dialog label { display:flex; flex-direction:column; gap:6px; font-size:14px; font-weight:700; }
.scenario-author-dialog input, .scenario-author-dialog textarea, .scenario-author-dialog select {
  box-sizing:border-box;
  width:100%;
  border:1px solid #9ba9b8;
  border-radius:7px;
  background:#fff;
  padding:10px 11px;
  font:400 15px Arial, Helvetica, sans-serif;
  color:#152235;
}

.scenario-author-dev-toggle {
  display:flex !important;
  flex-direction:row !important;
  align-items:center;
  gap:10px !important;
  margin:0 0 16px;
  padding:10px 12px;
  border:1px solid #cfd9e6;
  border-radius:8px;
  background:#f7faff;
}
.scenario-author-dev-toggle input { width:auto !important; margin:0; }
.scenario-author-dev-toggle span { margin-left:auto; color:#68788b; font-size:12px; font-weight:700; }

.scenario-author-show-password { flex-direction:row !important; align-items:center; margin-top:10px; font-weight:400 !important; }
.scenario-author-show-password input { width:auto; }
.scenario-author-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:18px; }
.scenario-author-actions button, #scenarioAuthorOpenButton {
  border:1px solid #596d82;
  border-radius:7px;
  background:#f2f5f8;
  padding:9px 16px;
  font:700 14px Arial, Helvetica, sans-serif;
  color:#17293d;
  cursor:pointer;
}
.scenario-author-actions button.primary { border-color:#1766ac; background:#2878c8; color:#fff; }
.scenario-author-error { min-height:20px; margin-top:8px; color:#b42318; font-weight:700; }
.scenario-author-heading-row { display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
.scenario-author-kicker { color:#2878c8; font-size:12px; font-weight:900; letter-spacing:.12em; }
.scenario-author-close { border:0; background:transparent; color:#52657a; font-size:32px; line-height:1; cursor:pointer; }
.scenario-author-notice { margin:-4px 0 18px; border-left:5px solid #2878c8; background:#eef6ff; padding:12px 14px; font-size:14px; line-height:1.4; }
.scenario-author-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.scenario-author-grid .span-2 { grid-column:1 / -1; }
.scenario-author-status { min-height:21px; margin-top:14px; color:#2878c8; font-weight:700; }
.scenario-author-status.is-error { color:#b42318; }
.scenario-author-panel-actions { justify-content:space-between; flex-wrap:wrap; }
#scenarioAuthorBanner {
  position:absolute;
  top:8px;
  left:50%;
  transform:translateX(-50%);
  z-index:70;
  border:1px solid #824d00;
  border-radius:5px;
  background:#fff1c7;
  padding:5px 13px;
  color:#6b3d00;
  font:900 12px Arial, Helvetica, sans-serif;
  letter-spacing:.09em;
  pointer-events:none;
}
#scenarioAuthorOpenButton { position:absolute; right:64px; bottom:8px; z-index:70; padding:5px 10px; font-size:12px; }
@media (max-width: 760px) {
  .scenario-author-dialog { padding:18px; }
  .scenario-author-grid { grid-template-columns:1fr; }
  .scenario-author-grid .span-2 { grid-column:auto; }
}

/* ================================================================
   Diagnostic Scenario Session — Version 1.0
   ================================================================ */
#diagnosticsModal {
  position:absolute; inset:0; z-index:160; display:flex; align-items:center; justify-content:center;
  background:rgba(14, 25, 39, .58); padding:32px; box-sizing:border-box;
}
#diagnosticsModal[hidden], #diagnosticSessionBanner[hidden] { display:none !important; }
.diagnostics-dialog {
  position:relative; width:min(760px, 88%); max-height:84%; overflow:auto; box-sizing:border-box;
  background:#fff; border-radius:18px; padding:30px; box-shadow:0 24px 70px rgba(0,0,0,.28);
  font-family:Arial, Helvetica, sans-serif;
}
.diagnostics-dialog h2 { margin:4px 0 6px; color:#1f2b38; font-size:28px; }
.diagnostics-intro { margin:0 0 18px; color:#667486; }
.diagnostics-status { min-height:24px; margin:8px 0 14px; color:#2878c8; font-weight:700; }
.diagnostics-status.is-error { color:#b42318; }
.diagnostics-list { display:flex; flex-direction:column; gap:12px; }
.diagnostics-card {
  width:100%; display:flex; align-items:center; gap:15px; text-align:left; border:1px solid #d9e1ea;
  border-radius:13px; padding:14px 16px; background:#f9fbfd; cursor:pointer; color:#253445;
}
.diagnostics-card:hover, .diagnostics-card:focus-visible { border-color:#2878c8; background:#eef6ff; outline:none; }
.diagnostics-card:disabled { opacity:.6; cursor:wait; }
.diagnostics-card-number {
  flex:0 0 38px; height:38px; border-radius:50%; display:grid; place-items:center;
  background:#2878c8; color:#fff; font-weight:900;
}
.diagnostics-card-copy { display:flex; flex-direction:column; gap:4px; min-width:0; }
.diagnostics-card-copy strong { font-size:17px; }
.diagnostics-card-copy small { color:#667486; font-size:13px; line-height:1.35; }
#diagnosticSessionBanner {
  position:absolute; top:8px; left:50%; transform:translateX(-50%); z-index:75;
  display:flex; align-items:center; gap:18px; max-width:58%; min-width:420px; box-sizing:border-box;
  padding:8px 10px 8px 16px; border:1px solid #9dbfe1; border-radius:10px;
  background:rgba(239,247,255,.96); box-shadow:0 3px 10px rgba(38,80,120,.15);
  font-family:Arial, Helvetica, sans-serif;
}
.diagnostic-session-text { display:flex; flex-direction:column; min-width:0; flex:1; }
#diagnosticSessionTitle { color:#1f5689; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#diagnosticSessionDescription { color:#617386; font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#diagnosticResetButton {
  flex:0 0 auto; border:1px solid #2878c8; border-radius:7px; background:#fff; color:#1f5689;
  padding:7px 10px; font-weight:800; cursor:pointer;
}
.diagnostic-session-active #scenarioAuthorBanner,
.diagnostic-session-active #scenarioAuthorOpenButton,
.diagnostic-session-active #canvasActionControls { display:none !important; }


/* v4.15 Text Editor */
.text-editor-box,.text-editor-input{position:absolute;transform:translate(-50%,-50%);z-index:60;font:700 15px Arial,Helvetica,sans-serif;text-align:center;border:2px solid #2377e8;border-radius:4px;background:#fff;padding:3px 6px;min-width:72px;color:#1a2230}
.text-editor-box{cursor:text}
.canvas-action-controls button.selected,#textEditorButton.selected{background:#2377e8;color:#fff;border-color:#155bb5}
.text-editor-active #stage svg{cursor:default!important}

/* v4.16 Text Editor interaction isolation */
.text-editor-active #paletteSvg {
  pointer-events: none;
}

/* v4.19 Text Editor cleanup; behavior unchanged. */
#textEditorOverlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  pointer-events: none !important;
  overflow: hidden;
}
#textEditorOverlay[hidden] { display: none !important; }
#textEditorOverlay .text-editor-box,
#textEditorOverlay .text-editor-input {
  position: absolute;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  min-width: 72px;
  min-height: 28px;
  max-width: 220px;
  padding: 3px 7px;
  border: 2px solid #2377e8;
  border-radius: 3px;
  background: rgba(255,255,255,.96);
  color: #1a2230;
  font: 700 15px Arial, Helvetica, sans-serif;
  line-height: 18px;
  text-align: center;
  pointer-events: auto !important;
  box-shadow: 0 1px 4px rgba(20,45,80,.18);
}
#textEditorOverlay .text-editor-box {
  cursor: text;
}
#textEditorOverlay .text-editor-box:hover,
#textEditorOverlay .text-editor-box:focus-visible {
  border-color: #155bb5;
  background: #eef6ff;
  outline: 2px solid rgba(35,119,232,.25);
  outline-offset: 1px;
}
#textEditorOverlay .text-editor-input {
  z-index: 2;
  width: 150px;
}
#textEditorButton.selected,
#textEditorButton[aria-pressed="true"] {
  background: #2377e8;
  color: #fff;
  border-color: #155bb5;
}
.text-editor-active #circuitSvg,
.text-editor-active #paletteSvg {
  pointer-events: none !important;
  cursor: default !important;
}
.text-editor-active #undoCanvasButton,
.text-editor-active #clearCanvasButton {
  pointer-events: none !important;
}


.text-editor-input.invalid {
  outline: 3px solid #c62828;
}

/* Palette search and scrollable symbol library — Version 4.23 */
.palette-search-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

.palette-search-input {
  width: 100%;
  height: 38px;
  box-sizing: border-box;
  border: 1px solid #cbd3dd;
  border-radius: 8px;
  background: #ffffff;
  color: #202936;
  font-size: 14px;
  font-weight: 600;
  padding: 0 12px;
  outline: none;
}

.palette-search-input:focus {
  border-color: #2768b7;
  box-shadow: 0 0 0 2px rgba(39, 104, 183, 0.18);
}

.palette-search-input::placeholder {
  color: #747f8d;
  font-weight: 600;
}

/* ================================================================
   v6.8 — SC480 selector dial magnifier
   The magnifier now lives inside the existing SC480 SVG. No HTML lens
   surface is required; the SVG overlay is pointer-events:none.
   ================================================================ */

/* ==========================================================================
   Guided Tutorial — Package 1.0
   Instruction-only workflow. The real builder remains fully interactive.
   ========================================================================== */
.guided-tutorial {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 360px));
  z-index: 9000;
  pointer-events: none;
}
.guided-tutorial[hidden] { display: none !important; }
.guided-tutorial-card {
  pointer-events: auto;
  background: rgba(255,255,255,.97);
  border: 2px solid #2377e8;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15,23,42,.18);
  padding: 14px 18px 15px;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
}
.guided-tutorial-progress {
  color: #2377e8;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.guided-tutorial-title {
  margin: 0 0 6px;
  color: #17283c;
  font: 900 22px/1.2 Arial, Helvetica, sans-serif;
}
.guided-tutorial-text {
  margin: 0 auto 8px;
  color: #45566b;
  font: 600 15px/1.4 Arial, Helvetica, sans-serif;
  max-width: 590px;
}
.guided-tutorial-status {
  margin: 8px auto 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #eef3f8;
  color: #5c6b7c;
  font: 700 13px/1.3 Arial, Helvetica, sans-serif;
}
.guided-tutorial-status.is-complete { background: #e8f7ed; color: #18743a; }
.guided-tutorial-actions { display: flex; justify-content: center; gap: 10px; }
.guided-tutorial-actions button,
.guided-tutorial-modal-actions button {
  min-height: 38px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 2px solid #2377e8;
  background: #2377e8;
  color: #fff;
  font: 800 14px/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.guided-tutorial-actions button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.guided-tutorial-actions .guided-tutorial-exit,
.guided-tutorial-modal-actions .secondary {
  background: #fff;
  color: #26364a;
  border-color: #b9c6d7;
}
.guided-tutorial-modal {
  position: absolute;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: center;
  background: rgba(15,23,42,.30);
  padding: 24px;
}
.guided-tutorial-modal[hidden] { display: none !important; }
.guided-tutorial-modal-card {
  width: min(620px, calc(100% - 48px));
  background: #fff;
  border: 2px solid #2377e8;
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(15,23,42,.25);
  padding: 28px;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
}
.guided-tutorial-modal-card h2 { margin: 0 0 12px; color:#17283c; font:900 26px/1.2 Arial,Helvetica,sans-serif; }
.guided-tutorial-modal-card p { margin:0 auto 22px; max-width:520px; color:#53657a; font:600 16px/1.5 Arial,Helvetica,sans-serif; }
.guided-tutorial-modal-actions { display:flex; justify-content:center; gap:12px; flex-wrap:wrap; }

.guided-tutorial.is-right-panel {
  left: auto;
  right: 22px;
  transform: none;
  width: min(560px, calc(100% - 360px));
}
@media (max-width: 1100px) {
  .guided-tutorial.is-right-panel {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 24px);
  }
}

@media (max-width: 900px) {
  .guided-tutorial { width: calc(100% - 24px); top: 12px; }
}

/* v6.8 — preserve the learner's viewport during live schematic redraws.
   Meter-lead movement and thermostat/relay state changes rebuild SVG groups;
   browser scroll anchoring must not reinterpret those DOM replacements as a
   reason to move the scroll position. */
#scrollArea,
#circuitSvg {
  overflow-anchor: none;
}


/* ==========================================================================
   Guided Tutorial — Package 1.0
   Topology-aware correction state + contextual Show Me CTA.
   ========================================================================== */
.guided-tutorial-text {
  text-align: left;
}
.guided-tutorial-lead {
  text-align: center;
  margin-bottom: 5px;
}
.guided-tutorial-substeps {
  margin: 5px auto 8px;
  padding-left: 26px;
  max-width: 560px;
}
.guided-tutorial-substeps li {
  margin: 4px 0;
}
.guided-tutorial-status.is-correction {
  background: #fff3e6;
  color: #8f4700;
  border: 1px solid #f2b66d;
}
.guided-tutorial-actions .guided-tutorial-show-me {
  background: #fff7ed;
  color: #8f4700;
  border-color: #f28c18;
}
.guided-tutorial-actions .guided-tutorial-show-me:hover {
  background: #ffedd5;
}


/* ========================================================================== 
   Guided Tutorial — Package 1.0
   Progressive Show Hint assistance.
   ========================================================================== */
.guided-hint-palette-target rect,
.guided-hint-palette-target > rect {
  stroke: #f28c18 !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 6px rgba(242,140,24,.65));
}
.guided-hint-palette-target text {
  fill: #8f4700 !important;
  font-weight: 900 !important;
}
.guided-tutorial-actions .guided-tutorial-show-me {
  min-width: 148px;
}

.guided-hint-control-target {
  outline: 4px solid #f28c18 !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 6px rgba(242,140,24,.18), 0 0 14px rgba(242,140,24,.7) !important;
  border-radius: 8px !important;
}


/* ================================================================
   LT Instructions / Menu Popups — Package 1.0
   ================================================================ */
#instructionsModal {
  position:absolute; inset:0; z-index:20030; display:flex; align-items:center; justify-content:center;
  padding:28px; box-sizing:border-box; background:rgba(14,25,39,.58);
}
#instructionsModal[hidden] { display:none !important; }
.instructions-dialog {
  position:relative; width:min(900px,92%); max-height:88%; overflow:auto; box-sizing:border-box;
  padding:30px 34px 34px; border-radius:18px; background:#fff;
  box-shadow:0 24px 70px rgba(0,0,0,.28); font-family:Arial,Helvetica,sans-serif; color:#263646;
}
.instructions-eyebrow { color:#2377e8; font-size:13px; font-weight:900; letter-spacing:.08em; text-transform:uppercase; }
.instructions-dialog h2 { margin:5px 48px 8px 0; color:#1f2b38; font-size:30px; line-height:1.15; }
.instructions-intro { margin:0 0 5px; color:#526477; font-size:16px; line-height:1.5; }
.instructions-contact { margin:0 0 24px; color:#526477; font-weight:700; }
.instructions-contact a { color:#1769d2; }
.instructions-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.instructions-grid section { padding:16px 18px; border:1px solid #dce4ee; border-radius:12px; background:#f8fbff; }
.instructions-grid h3 { margin:0 0 7px; color:#20344a; font-size:17px; }
.instructions-grid p { margin:0; color:#526477; font-size:14px; line-height:1.5; }
.coming-soon-message { margin:18px auto 0; max-width:340px; color:#596a7b; font:700 15px/1.5 Arial,Helvetica,sans-serif; }
@media (max-width:760px) {
  .instructions-dialog { width:96%; padding:24px 20px 26px; }
  .instructions-grid { grid-template-columns:1fr; }
}


/* Why This Builder popup — Package 1.0 */
#whyBuilderModal {
  position: absolute;
  inset: 0;
  z-index: 20030;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}
#whyBuilderModal[hidden] { display: none; }
.why-builder-dialog { max-height: min(86vh, 820px); overflow: auto; }


/* Canvas coordinate grid guide — Package 1.0 */
#coordinateGuideLayer { pointer-events: none; }
.coordinate-guide-point {
  fill: #ffffff;
  stroke: #2878c8;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}
.coordinate-guide-crosshair {
  stroke: #2878c8;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.coordinate-guide-label-bg {
  fill: #1f2b38;
  opacity: .94;
}
.coordinate-guide-label {
  fill: #ffffff;
  font: 700 18px Arial, Helvetica, sans-serif;
  dominant-baseline: middle;
}


/* ========================================================================== 
   Guided Tutorial — Package 1.0
   Explicit Show Hint / Complete controls for authored click-through tutorial.
   ========================================================================== */
.guided-tutorial-actions .guided-tutorial-complete {
  background: #2377e8;
  color: #fff;
  border-color: #2377e8;
}
.guided-tutorial-substeps {
  list-style-position: outside;
}
.guided-tutorial-substeps li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.guided-substep-actions {
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}
.guided-substep-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1.5px solid #f28c18;
  background: #fff7ed;
  color: #8f4700;
  font: 800 12px/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
}
.guided-substep-actions button[data-substep-complete] {
  border-color: #2377e8;
  background: #2377e8;
  color: #fff;
}
.guided-substep-actions button:disabled {
  opacity: .55;
  cursor: default;
}
@media (max-width: 720px) {
  .guided-tutorial-substeps li { grid-template-columns: 1fr; }
  .guided-substep-actions { justify-content: flex-start; }
}


/* Help / About popup — Package 1.0 */
#helpModal {
  position:absolute;
  inset:0;
  z-index:20030;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:28px;
  box-sizing:border-box;
  background:rgba(14,25,39,.58);
}
#helpModal[hidden] { display:none !important; }
.help-dialog {
  position:relative;
  width:min(720px,88%);
  max-height:86%;
  overflow:auto;
  box-sizing:border-box;
  padding:28px 34px 24px;
  border-radius:18px;
  background:#fff;
  box-shadow:0 24px 70px rgba(0,0,0,.28);
  font-family:Arial,Helvetica,sans-serif;
  color:#263646;
}
.help-logo-window {
  width:100%;
  min-height:170px;
  overflow:visible;
  display:flex;
  align-items:center;
  justify-content:center;
  margin:0 auto 10px;
}
.help-logo-image {
  display:block;
  width:min(590px,96%);
  max-height:205px;
  height:auto;
  object-fit:contain;
  transform:none;
}
.help-product-block { text-align:center; }
.help-dialog h2 {
  margin:5px 44px 4px;
  color:#1f2b38;
  font-size:34px;
  line-height:1.15;
}
.help-version {
  margin:0 0 12px;
  color:#526477;
  font-size:16px;
}
.help-description {
  max-width:590px;
  margin:0 auto 22px;
  color:#526477;
  font-size:15px;
  line-height:1.5;
}
.help-info-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}
.help-info-grid section {
  padding:16px 18px;
  border:1px solid #dce4ee;
  border-radius:12px;
  background:#f8fbff;
}
.help-info-grid h3 { margin:0 0 7px; color:#20344a; font-size:17px; }
.help-info-grid p { margin:4px 0; color:#526477; font-size:14px; line-height:1.5; }
.help-info-grid a { color:#1769d2; font-weight:800; }
.help-footer {
  margin:20px 0 0;
  padding-top:14px;
  border-top:1px solid #e2e7ee;
  color:#6b7c8f;
  font-size:13px;
  font-weight:700;
  text-align:center;
}
@media (max-width:760px) {
  .help-dialog { width:96%; padding:24px 20px 22px; }
  .help-info-grid { grid-template-columns:1fr; }
  .help-logo-window { min-height:140px; }
  .help-logo-image { width:min(500px,98%); max-height:170px; transform:none; }
}

.main-menu-section-label {
  margin: 8px 14px 2px;
  padding: 9px 4px 4px;
  border-top: 1px solid #d8dee7;
  color: #6b7280;
  font: 800 13px Arial, Helvetica, sans-serif;
  letter-spacing: .08em;
  line-height: 1.2;
  text-transform: uppercase;
  pointer-events: none;
}

/* ================================================================
   LT Templates popup — Package 1.0
   ================================================================ */
#templatesModal {
  position:absolute;
  inset:0;
  z-index:20030;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:28px;
  box-sizing:border-box;
  background:rgba(14,25,39,.58);
}
#templatesModal[hidden] { display:none !important; }
.templates-dialog { width:min(760px,92%); }
.template-list { margin-top:24px; }
.template-card {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:24px;
  padding:20px 22px;
  border:1px solid #dce4ee;
  border-radius:14px;
  background:#f8fbff;
}
.template-card-copy { min-width:0; }
.template-card h3 {
  margin:0 0 7px;
  color:#20344a;
  font-size:20px;
}
.template-card p {
  margin:0;
  color:#526477;
  font-size:14px;
  line-height:1.5;
}
.template-load-button {
  flex:0 0 auto;
  min-width:140px;
  min-height:44px;
  padding:10px 18px;
  border:0;
  border-radius:9px;
  background:#2377e8;
  color:#fff;
  font:800 14px Arial,Helvetica,sans-serif;
  cursor:pointer;
}
.template-load-button:hover,
.template-load-button:focus-visible { background:#1769d2; }
.template-pro-note {
  margin:22px 0 0;
  padding-top:18px;
  border-top:1px solid #dce4ee;
  color:#526477;
  font:800 14px/1.45 Arial,Helvetica,sans-serif;
  text-align:center;
}
.template-status {
  min-height:20px;
  margin-top:10px;
  color:#2377e8;
  font:800 13px/1.4 Arial,Helvetica,sans-serif;
  text-align:center;
}
@media (max-width:760px) {
  .template-card { align-items:stretch; flex-direction:column; }
  .template-load-button { width:100%; }
}

/* Protected Review Gate */
html.v3d-review-locked #app { visibility: hidden !important; }
#v3d-review-gate { position:fixed; inset:0; z-index:2147483647; display:flex; align-items:center; justify-content:center; padding:24px; background:#101317; color:#f4f6f8; font-family:Arial,Helvetica,sans-serif; }
.v3d-review-card { width:min(520px,calc(100vw - 48px)); box-sizing:border-box; padding:36px; border:1px solid rgba(255,255,255,.16); border-radius:18px; background:#1b2026; box-shadow:0 24px 70px rgba(0,0,0,.45); }
.v3d-review-brand { font-size:14px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; opacity:.72; }
.v3d-review-card h1 { margin:10px 0 14px; font-size:30px; line-height:1.12; }
.v3d-review-badge { display:inline-block; margin-bottom:18px; padding:7px 10px; border-radius:999px; border:1px solid rgba(255,255,255,.22); font-size:12px; font-weight:700; letter-spacing:.08em; }
.v3d-review-badge.expired { border-color:#ff8080; }
.v3d-review-copy { margin:8px 0 16px; line-height:1.55; opacity:.9; }
.v3d-review-expiry { margin:18px 0 4px; font-size:15px; }
.v3d-review-countdown { min-height:22px; margin-bottom:22px; font-variant-numeric:tabular-nums; opacity:.78; }
#v3d-review-form label { display:block; margin-bottom:8px; font-size:14px; font-weight:700; }
#v3d-review-key { width:100%; box-sizing:border-box; padding:13px 14px; border-radius:10px; border:1px solid rgba(255,255,255,.24); background:#0f1317; color:#fff; font-size:17px; outline:none; }
#v3d-review-key:focus { border-color:#fff; }
#v3d-review-unlock { width:100%; margin-top:12px; padding:13px 16px; border:0; border-radius:10px; background:#fff; color:#111; font-size:15px; font-weight:800; cursor:pointer; }
#v3d-review-unlock:disabled { opacity:.55; cursor:default; }
.v3d-review-status { min-height:22px; margin-top:14px; font-size:14px; }
.v3d-review-build { margin-top:24px; padding-top:16px; border-top:1px solid rgba(255,255,255,.12); font-size:12px; opacity:.48; }
