:root {
  --page: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #eef3f8;
  --surface-strong: #dbe4ef;
  --ink: #151c27;
  --muted: #5b6472;
  --faint: #7b8492;
  --line: #c9d2df;
  --line-strong: #9aa8ba;
  --brand: #0570de;
  --brand-deep: #043f7c;
  --cyan: #00a8c8;
  --green: #11845b;
  --amber: #c47a00;
  --red: #cc3340;
  --violet: #6d54c8;
  --shadow: rgba(21, 28, 39, 0.12);
  color: var(--ink);
  background: var(--page);
  font-family: "IBM Plex Sans", "Inter", "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --page: #0b0f14;
  --surface: #121923;
  --surface-soft: #172130;
  --surface-strong: #223045;
  --ink: #edf4ff;
  --muted: #a9b5c6;
  --faint: #7e8da1;
  --line: #2f3b4c;
  --line-strong: #4a5a70;
  --brand: #4aa3ff;
  --brand-deep: #9fd0ff;
  --cyan: #27c2df;
  --green: #57d79a;
  --amber: #f2b84b;
  --red: #ff6b72;
  --violet: #a994ff;
  --shadow: rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--page);
}

body {
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

code,
pre {
  font-family: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.boot-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: var(--page);
}

.boot-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 18px;
}

.boot-lockup img {
  width: 42px;
  height: 42px;
}

.product-shell {
  display: grid;
  grid-template-rows: auto minmax(calc(100vh - 150px), 1fr) auto;
  min-height: 100vh;
  background: var(--page);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 66px;
  padding: 10px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
}

.brand-button {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-button img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand-button span {
  display: grid;
  min-width: 0;
}

.brand-button strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-button small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.primary-nav,
.support-nav {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
}

.primary-nav {
  justify-content: flex-end;
}

.support-nav {
  justify-content: flex-end;
}

.primary-nav button,
.support-nav button,
.tab-strip button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-nav button:hover,
.support-nav button:hover,
.tab-strip button:hover {
  border-color: var(--line);
  color: var(--ink);
}

.primary-nav button.active,
.support-nav button.active,
.tab-strip button.active {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--brand-deep);
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 16px clamp(16px, 3vw, 36px);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-copy {
  display: grid;
  gap: 4px;
}

.footer-copy strong {
  color: var(--ink);
  font-size: 14px;
}

.footer-copy span {
  color: var(--muted);
  font-size: 12px;
}

.footer-actions,
.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.footer-links button,
.theme-toggle {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.footer-links button:hover,
.theme-toggle:hover,
.footer-links button.active {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.theme-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
}

.theme-icon.dark {
  background: transparent;
  box-shadow: inset -5px 0 0 var(--ink);
  border: 1px solid var(--ink);
}

.page-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 34px);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: clamp(18px, 4vw, 46px);
  align-items: center;
  min-height: calc(100vh - 156px);
  padding: clamp(16px, 3vw, 34px) 0;
}

.hero-copy {
  display: grid;
  max-width: 760px;
  gap: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero-copy h1,
.content-heading h1,
.stage-header h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1.02;
  letter-spacing: 0;
}

.stage-header h1,
.content-heading h1 {
  font-size: clamp(28px, 4vw, 46px);
}

.hero-copy p:not(.eyebrow),
.content-heading p:not(.eyebrow),
.stage-header p {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.hero-actions,
.control-cluster,
.editor-mode-pills,
.hmi-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-action,
.secondary-action,
.text-link {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.primary-action {
  padding: 10px 15px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(5, 112, 222, 0.18);
}

.primary-action:hover {
  background: var(--brand-deep);
}

.secondary-action {
  padding: 10px 14px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-action:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.secondary-action.compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 0;
  background: transparent;
  color: var(--brand);
}

.text-link:hover {
  color: var(--brand-deep);
}

.as-link {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-content: center;
}

.hero-panel {
  display: grid;
  gap: 24px;
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 243, 248, 0.86)),
    var(--surface);
  box-shadow: 0 18px 46px var(--shadow);
}

.hero-panel img {
  width: min(420px, 100%);
  height: auto;
}

.hero-system,
.signal-chain {
  display: grid;
  gap: 8px;
}

.hero-system span,
.signal-chain span,
.expected-list span,
.limit-list span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.hero-system span:nth-child(2),
.signal-chain span:nth-child(2) {
  border-left-color: var(--cyan);
}

.hero-system span:nth-child(3),
.signal-chain span:nth-child(3) {
  border-left-color: var(--green);
}

.hero-system span:nth-child(4),
.signal-chain span:nth-child(4) {
  border-left-color: var(--amber);
}

.hero-system span:nth-child(5),
.signal-chain span:nth-child(5) {
  border-left-color: var(--violet);
}

.guided-band,
.snapshot-band,
.content-page {
  padding: clamp(24px, 4vw, 44px) 0;
  border-top: 1px solid var(--line);
}

.snapshot-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}

.section-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.section-heading h2,
.panel-heading h2,
.checkout-panel h2,
.hmi-panel h2,
.saved-projects h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 22px;
  letter-spacing: 0;
}

.path-grid,
.learning-grid,
.profile-grid,
.fault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.path-card,
.learning-card,
.profile-card,
.rack-panel,
.checkout-panel,
.hmi-panel,
.scada-panel,
.runtime-bottom,
.fault-injection,
.trace-panel,
.profile-form,
.saved-projects,
.contact-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(21, 28, 39, 0.06);
}

.path-card,
.learning-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 170px;
  padding: 18px;
}

.path-card h3,
.learning-card h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.path-card p,
.learning-card li,
.empty-copy,
.fine-print,
.statement-list p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.learning-card span,
.profile-status,
.fault-boundary {
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.learning-card ul {
  display: grid;
  gap: 7px;
  margin: 6px 0 0;
  padding-left: 18px;
}

.runtime-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.runtime-summary span,
.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.build-layout,
.practice-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.build-sidebar,
.practice-sidebar {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 12px;
}

.sidebar-title {
  display: grid;
  gap: 5px;
}

.sidebar-title strong {
  font-size: 20px;
}

.stage-list,
.practice-sidebar {
  display: grid;
  gap: 8px;
}

.build-start-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.build-template-list {
  display: grid;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.build-template-list button {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
}

.build-template-list button.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
}

.build-template-list strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-template-list span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.stage-list button,
.practice-sidebar button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px 10px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.practice-sidebar button {
  grid-template-columns: minmax(0, 1fr);
}

.stage-list button.active,
.practice-sidebar button.active,
.profile-card.selected {
  border-color: var(--brand);
  background: #eef6ff;
}

.stage-list span {
  grid-row: span 2;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 900;
}

.stage-list strong,
.practice-sidebar strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-list small,
.practice-sidebar small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-stage,
.practice-main {
  min-width: 0;
}

.stage-header,
.content-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.content-heading {
  grid-template-columns: minmax(0, 1fr);
}

.stage-header.compact {
  align-items: center;
}

.stage-deliverable {
  display: grid;
  width: min(310px, 100%);
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stage-deliverable span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stage-deliverable strong {
  font-size: 14px;
}

.hardware-grid,
.wiring-layout,
.communication-grid,
.hmi-scada-layout,
.fault-layout,
.account-grid,
.test-layout,
.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.profile-card {
  display: grid;
  min-height: 148px;
  align-content: start;
  gap: 8px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
}

.profile-card strong {
  color: var(--ink);
  font-size: 16px;
}

.profile-card small,
.profile-card > span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.profile-status.ready {
  border-color: rgba(17, 132, 91, 0.35);
  color: var(--green);
}

.profile-status.foundation {
  border-color: rgba(5, 112, 222, 0.35);
  color: var(--brand);
}

.rack-panel,
.checkout-panel,
.scada-panel,
.profile-form,
.saved-projects,
.contact-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.panel-heading {
  display: grid;
  gap: 4px;
}

.panel-heading.inline {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.rack-visual {
  display: grid;
  grid-template-columns: 0.8fr 1.3fr 1fr 1fr 1fr;
  min-height: 160px;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.rack-visual span {
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand-deep);
  font-weight: 900;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
}

.detail-list dd {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.wiring-board {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1.4fr 1.2fr 1.2fr;
  gap: 12px;
  min-height: 390px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.terminal-strip,
.device-terminal,
.module-terminal,
.wire-path {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.terminal-strip strong,
.device-terminal strong,
.module-terminal strong,
.wire-path strong {
  color: var(--ink);
  font-size: 13px;
}

.terminal-strip span,
.device-terminal span,
.module-terminal span,
.wire-path span {
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.wire-path {
  align-self: center;
  border-width: 2px;
}

.network-map {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-height: 380px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.network-node,
.network-switch {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  min-height: 118px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.network-switch {
  grid-column: 1 / -1;
  width: min(360px, 100%);
  justify-self: center;
  min-height: 92px;
  background: var(--surface-soft);
}

.programming-layout {
  display: grid;
  gap: 14px;
}

.program-toolbar,
.runtime-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.runtime-toolbar {
  grid-template-columns: minmax(190px, 1fr) auto auto;
}

.program-toolbar h2 {
  margin: 0;
  font-size: 22px;
}

.editor-mode-pills span {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.editor-mode-pills button {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.editor-mode-pills span.active,
.editor-mode-pills button.active {
  border-color: var(--brand);
  color: var(--brand-deep);
}

.ladder-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ladder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #edf2f8;
}

.ladder-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ladder-head-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.zoom-control button {
  min-width: 34px;
  min-height: 30px;
  padding: 5px 8px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.zoom-control button:last-child {
  border-right: 0;
}

.zoom-control button:hover {
  background: var(--surface-soft);
  color: var(--brand-deep);
}

.ladder-rungs {
  display: grid;
  background: #fdfefe;
}

.ladder-rung {
  display: grid;
  grid-template-columns: 82px minmax(560px, 1fr) 178px;
  min-height: 102px;
  border-bottom: 1px solid var(--line);
}

.ladder-rung.energized {
  background: #f2fff9;
}

.rung-number {
  display: grid;
  align-items: start;
  padding: 12px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 800;
}

.rung-canvas {
  position: relative;
  min-height: 102px;
  overflow-x: auto;
  background-image:
    linear-gradient(to right, rgba(201, 210, 223, 0.3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(201, 210, 223, 0.3) 1px, transparent 1px);
  background-size: 24px 24px;
}

.power-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #111827;
}

.power-rail.left {
  left: 18px;
}

.power-rail.right {
  right: 18px;
}

.logic-line {
  position: absolute;
  top: 50%;
  left: 18px;
  right: 18px;
  height: 2px;
  background: #111827;
  transform: translateY(-50%);
}

.instruction-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  min-width: 560px;
  min-height: 102px;
  gap: 22px;
  padding: 18px 44px;
}

.ld-element {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  min-width: 118px;
  min-height: 56px;
  padding: 7px 10px;
  border: 2px solid #111827;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  text-align: center;
}

.ld-element.hot {
  border-color: var(--green);
  background: #e7fff4;
  color: var(--green);
}

.ld-element.coil {
  margin-left: auto;
}

.ld-element.timer {
  min-width: 190px;
  align-items: center;
}

.ld-element .mnemonic {
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 13px;
  font-weight: 900;
}

.ld-element code {
  max-width: 170px;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 800;
}

.ld-element small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.rung-comment {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border-left: 1px solid var(--line);
}

.rung-comment strong {
  font-size: 13px;
}

.rung-comment > span,
.rung-state-badge {
  width: fit-content;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.st-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 14px;
}

.st-preview pre {
  min-height: 250px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #e7edf4;
  font-size: 13px;
  line-height: 1.6;
}

.test-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
}

.runtime-workbench {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.runtime-state {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: center;
}

.runtime-state small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--faint);
}

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(17, 132, 91, 0.12);
}

.icon-btn {
  position: relative;
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--brand);
}

.icon-btn.run::before {
  width: 0;
  height: 0;
  margin-left: 2px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 12px solid var(--green);
  content: "";
}

.icon-btn.stop::before {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--red);
  content: "";
}

.icon-btn.pause::before {
  width: 14px;
  height: 16px;
  border-right: 4px solid var(--amber);
  border-left: 4px solid var(--amber);
  content: "";
}

.icon-btn.step::before {
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 11px solid var(--brand);
  content: "";
}

.icon-btn.step::after {
  width: 3px;
  height: 16px;
  margin-left: 3px;
  background: var(--brand);
  content: "";
}

.icon-btn.reset::before {
  width: 16px;
  height: 16px;
  border: 3px solid var(--faint);
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.speed-control input {
  width: 86px;
  accent-color: var(--brand);
}

.factory-frame,
.mini-sim {
  min-height: 430px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mini-sim {
  min-height: 300px;
}

#factory-canvas,
#mini-factory-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 410px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8fb;
}

#mini-factory-canvas {
  min-height: 278px;
}

.acceptance-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.acceptance-metric {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.acceptance-metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.acceptance-metric strong {
  font-size: 20px;
}

.runtime-aside {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.hmi-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.hmi-indicators {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hmi-indicators div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.hmi-indicators span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.hmi-indicators strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.hmi-button {
  flex: 1 1 90px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 900;
}

.hmi-button.start {
  color: var(--green);
}

.hmi-button.stop {
  color: var(--red);
}

.hmi-button.feed {
  color: var(--brand);
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented button {
  flex: 1;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.segmented button.active {
  background: var(--surface);
  color: var(--brand-deep);
  box-shadow: inset 0 0 0 1px var(--line);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toggle-line input,
.fault-card input {
  accent-color: var(--brand);
}

.command-readout {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.runtime-bottom {
  overflow: hidden;
}

.tab-strip {
  display: flex;
  gap: 4px;
  min-width: 0;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab-body {
  max-height: 410px;
  overflow: auto;
  padding: 10px;
}

.tag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tag-table th,
.tag-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: left;
}

.tag-table th {
  color: var(--ink);
  font-weight: 900;
}

.tag-table code {
  color: var(--brand-deep);
  font-weight: 800;
}

.build-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.build-field input,
.build-form-table input,
.build-form-table select {
  width: 100%;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.build-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.build-form-table th:last-child,
.build-form-table td:last-child {
  width: 74px;
  text-align: right;
}

.build-program-editor,
.fbd-editor {
  display: grid;
  gap: 12px;
}

.build-program-palette {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.build-program-palette button {
  display: grid;
  grid-template-rows: 26px 14px;
  flex: 0 0 66px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 900;
}

.build-program-palette .secondary-action {
  display: inline-flex;
  flex-basis: auto;
  min-width: 92px;
  font-family: inherit;
}

.build-program-element {
  --symbol-bg: var(--surface);
  display: grid;
  grid-template-rows: 18px 32px 16px;
  min-width: 128px;
  place-items: center;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.build-program-element span:first-child,
.build-program-element small {
  overflow: hidden;
  max-width: 126px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-program-element.coil {
  margin-left: auto;
}

.build-empty-rung {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.build-code-editor textarea {
  width: 100%;
  min-height: 250px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #e7edf4;
  font-family: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.fbd-canvas,
.hmi-design-canvas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.fbd-block,
.hmi-design-object {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 96px;
  padding: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.fbd-block input {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
}

.hmi-design-object code {
  color: var(--brand-deep);
  font-size: 11px;
  font-weight: 800;
}

.hmi-design-object.button-object {
  border-radius: 999px;
}

.hmi-design-object.alarm-object {
  border-color: var(--red);
}

.hmi-design-object.trend-object {
  min-height: 128px;
  background:
    linear-gradient(to top right, transparent 48%, color-mix(in srgb, var(--brand) 55%, transparent) 49% 51%, transparent 52%),
    var(--surface);
}

.alarm-list,
.trace-list,
.check-list,
.log-list,
.statement-list,
.limit-list,
.expected-list {
  display: grid;
  gap: 8px;
}

.alarm-row,
.trace-row,
.check-row,
.log-row,
.saved-row {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.trace-row {
  grid-template-columns: 34px 90px 78px minmax(0, 1fr);
  align-items: center;
}

.trace-row p,
.log-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.trace-row code,
.log-row code {
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 800;
}

.check-row {
  grid-template-columns: minmax(150px, 0.45fr) minmax(0, 1fr);
  align-items: center;
}

.check-row span,
.saved-row span {
  color: var(--muted);
  font-size: 13px;
}

.log-row {
  grid-template-columns: 58px 96px 120px minmax(0, 1fr);
  align-items: center;
}

.fault-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.fault-card {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px 10px;
  min-height: 126px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.fault-card.active {
  border-color: var(--red);
  background: #fff5f5;
}

.fault-card .fault-boundary,
.fault-card strong,
.fault-card small {
  grid-column: 2;
}

.fault-card strong {
  font-size: 14px;
}

.fault-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.hmi-scada-layout {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.trend-strip {
  display: flex;
  align-items: end;
  gap: 4px;
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.trend-strip span {
  flex: 1;
  min-width: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(#0570de, #00a8c8);
}

.practice-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.practice-grid > div {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.expected-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 14px;
}

.practice-lab {
  display: grid;
  gap: 18px;
}

.practice-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.practice-topbar h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

.practice-topbar p:not(.eyebrow) {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.practice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.practice-scan-controls {
  display: flex;
  gap: 6px;
}

.practice-state-pill {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.practice-state-pill.online {
  border-color: color-mix(in srgb, var(--green) 55%, var(--line));
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--green);
}

.practice-lab-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.template-panel {
  grid-row: 1 / span 2;
}

.practice-editor {
  grid-column: 2;
}

.template-panel,
.practice-editor,
.practice-sim-panel,
.io-simulator,
.instruction-palette,
.practice-results {
  min-width: 0;
}

.template-panel,
.io-simulator,
.practice-results {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.template-panel button {
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.template-panel button.active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
}

.template-panel button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.practice-sim-panel {
  display: grid;
  grid-column: 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.instruction-palette {
  display: flex;
  gap: 10px;
  margin: 10px 0;
  padding: 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.instruction-palette.locked {
  background: color-mix(in srgb, var(--surface-soft) 60%, var(--surface));
}

.palette-group {
  display: flex;
  flex: 0 0 auto;
  align-content: start;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.palette-group > strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.palette-group > div {
  display: flex;
  gap: 5px;
}

.instruction-tool {
  display: grid;
  grid-template-rows: 28px 14px;
  align-items: center;
  justify-items: center;
  gap: 2px;
  width: 68px;
  min-height: 48px;
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.instruction-tool:hover {
  border-color: var(--brand);
}

.instruction-tool strong {
  overflow: hidden;
  width: 100%;
  color: var(--ink);
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instruction-tool:disabled,
.practice-actions button:disabled,
.rung-comment button:disabled,
.bit-button:disabled,
.force-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.practice-rung {
  grid-template-columns: 56px minmax(640px, 1fr) 190px;
  min-height: 132px;
}

.practice-rung.selected {
  outline: 0;
}

.practice-rung-stack {
  --slot: 128px;
  --wire-origin: 44px;
  --branch-height: 88px;
  --wire-y: 44px;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0;
  min-width: var(--diagram-width, 620px);
  padding: 0 210px 0 0;
}

.practice-branch {
  --slot: 128px;
  --branch-left: 0px;
  --branch-width: var(--slot);
  --element-slots: 1;
  position: relative;
  display: block;
  height: var(--branch-height);
  min-height: var(--branch-height);
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
}

.practice-branch::before {
  position: absolute;
  top: var(--wire-y);
  right: 0;
  left: var(--wire-origin);
  height: 2px;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  content: "";
  transform: translateY(-50%);
}

.ladder-editor.practice .logic-line {
  top: 44px;
}

.practice-branch.main::before {
  display: none;
}

.practice-branch.parallel {
  min-height: var(--branch-height);
}

.practice-branch.parallel::before {
  right: auto;
  left: calc(var(--wire-origin) + var(--branch-left));
  width: var(--branch-width);
  z-index: 2;
}

.practice-branch.hot {
  border-color: transparent;
  background: transparent;
}

.practice-branch.hot::before {
  background: var(--green);
}

.practice-branch.selected {
  box-shadow: none;
}

.practice-branch.parallel.selected::before {
  background: var(--brand);
}

.practice-branch.tail {
  border-style: dashed;
}

.branch-elements {
  position: absolute;
  top: 0;
  left: var(--wire-origin);
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--element-slots), var(--slot));
  align-items: start;
  gap: 0;
  height: var(--branch-height);
  min-width: 0;
  overflow: visible;
  padding: 0;
}

.practice-branch.parallel .branch-elements {
  left: calc(var(--wire-origin) + var(--branch-left));
  margin-left: 0;
  min-width: var(--branch-width);
}

.branch-label {
  display: grid;
  position: absolute;
  top: calc(var(--wire-y) - 13px);
  left: 0;
  z-index: 1;
  width: 34px;
  min-height: 26px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 900;
}

.practice-branch.main .branch-label {
  color: transparent;
}

.practice-element,
.practice-coil-card {
  --symbol-bg: var(--surface);
  position: relative;
  display: grid;
  grid-template-rows: 20px 34px 18px;
  align-content: start;
  align-items: center;
  justify-items: center;
  gap: 1px;
  width: var(--slot);
  min-width: 0;
  height: var(--branch-height);
  min-height: 0;
  padding: 4px 8px 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
}

.practice-element {
  cursor: grab;
  touch-action: none;
}

.practice-element.dragging {
  cursor: grabbing;
  opacity: 0.86;
  pointer-events: none;
  transform: translate(var(--drag-x, 0), var(--drag-y, 0));
  z-index: 30;
  filter: drop-shadow(0 12px 18px rgba(21, 28, 39, 0.2));
}

.practice-dragging,
.practice-dragging * {
  cursor: grabbing !important;
}

.practice-element input,
.practice-coil-card input {
  cursor: text;
}

.practice-element.hot,
.practice-coil-card.hot {
  border-color: transparent;
  background: transparent;
  color: var(--green);
}

.practice-element:hover,
.practice-element.selected,
.practice-coil-card:hover,
.practice-coil-card.selected {
  border-color: transparent;
  background: transparent;
  color: var(--brand-deep);
}

.practice-element.selected .ld-symbol,
.practice-coil-card.selected .ld-symbol {
  color: var(--brand);
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--brand) 30%, transparent));
}

.practice-element.selected .element-tag,
.practice-element.selected .element-label,
.practice-coil-card.selected .element-tag,
.practice-coil-card.selected .element-label {
  color: var(--brand-deep);
  font-weight: 900;
}

.io-practice-row.forced {
  outline: 2px solid color-mix(in srgb, var(--violet) 60%, transparent);
  outline-offset: 1px;
}

.practice-element.forced .element-status,
.practice-coil-card.forced .element-status {
  border-color: var(--violet);
  background: color-mix(in srgb, var(--violet) 12%, var(--surface));
  color: var(--violet);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 16%, transparent);
}

.practice-element.hot .element-tag,
.practice-element.hot .element-label,
.practice-coil-card.hot .element-tag,
.practice-coil-card.hot .element-label {
  color: var(--green);
}

.element-tag,
.element-label,
.rung-comment input {
  width: 100%;
  min-height: 18px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.element-tag,
.element-label,
.rung-comment input {
  padding: 1px 4px;
}

.element-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.element-tag:hover,
.element-label:hover,
.element-tag:focus,
.element-label:focus {
  border-color: var(--brand);
  background: var(--surface);
  outline: 0;
}

.rung-comment input {
  min-height: 28px;
  border-color: var(--line);
  background: var(--surface);
  font-size: 12px;
  text-align: left;
}

.element-inspector {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.element-inspector.empty {
  opacity: 0.66;
}

.inspector-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.element-inspector select,
.inspector-field input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.element-inspector select {
  padding: 5px 8px;
}

.element-inspector select:disabled,
.inspector-field input:disabled {
  color: var(--faint);
}

.inspector-field {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.inspector-field input {
  padding: 5px 8px;
}

.inspector-buttons {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 6px;
}

.inspector-buttons .icon-btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 7px;
}

.rung-panel-actions {
  display: grid;
  gap: 6px;
}

.rung-panel-actions .text-link {
  justify-content: center;
  min-height: 30px;
  padding: 5px 8px;
}

.insert-pointer {
  position: absolute;
  top: var(--wire-y);
  left: var(--insert-left);
  z-index: 3;
  width: 10px;
  height: 10px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.insert-pointer.active::before,
.insert-pointer.drag-target::before {
  position: absolute;
  inset: 3px;
  width: 5px;
  height: 5px;
  border: 0;
  border-radius: 50%;
  background: #111827;
  box-shadow: 0 0 0 2px var(--surface);
  content: "";
}

.insert-pointer.drag-target::before {
  background: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, var(--surface));
}

.branch-handle {
  position: absolute;
  top: var(--handle-top);
  z-index: 5;
  width: 18px;
  height: var(--handle-height);
  padding: 0;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--ink) 78%, transparent);
  cursor: ew-resize;
  transform: translateX(-50%);
}

.branch-handle.start {
  left: calc(var(--wire-origin) + var(--branch-left));
}

.branch-handle.end {
  left: calc(var(--wire-origin) + var(--branch-left) + var(--branch-width));
}

.branch-handle::before {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 50%;
  width: 3px;
  border-radius: 0;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.branch-handle:hover,
.branch-handle:focus {
  color: var(--brand);
  outline: 0;
}

.branch-handle:disabled {
  cursor: default;
}

.branch-handle:disabled::before {
  opacity: 0.45;
}

.icon-btn.move-left::before,
.icon-btn.move-right::before {
  width: 8px;
  height: 8px;
  border-bottom: 2px solid var(--muted);
  border-left: 2px solid var(--muted);
  content: "";
}

.icon-btn.move-left::before {
  transform: rotate(45deg);
}

.icon-btn.move-right::before {
  transform: rotate(225deg);
}

.icon-btn.delete::before,
.icon-btn.delete::after {
  position: absolute;
  width: 13px;
  height: 2px;
  border-radius: 2px;
  background: var(--red);
  content: "";
}

.icon-btn.delete::before {
  transform: rotate(45deg);
}

.icon-btn.delete::after {
  transform: rotate(-45deg);
}

.branch-empty {
  min-width: 74px;
  min-height: 32px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand);
  cursor: pointer;
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 900;
}

.mini-tool {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.practice-coil-card {
  position: absolute;
  top: 44px;
  right: 30px;
  z-index: 2;
  grid-template-columns: minmax(0, 1fr);
  width: 128px;
  min-width: 128px;
  height: 88px;
  min-height: 88px;
  transform: translateY(-50%);
}

.ladder-editor.practice .practice-coil-card {
  top: 44px;
}

.element-status {
  position: absolute;
  top: 14px;
  right: 4px;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
}

.element-status.true {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.ld-symbol {
  --symbol-bg: var(--surface);
  position: relative;
  display: inline-block;
  width: 64px;
  height: 30px;
  color: currentColor;
}

.instruction-tool .ld-symbol {
  width: 58px;
  height: 24px;
}

.ld-symbol::before {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  content: "";
  transform: translateY(-50%);
}

.ld-symbol::after {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  min-width: 32px;
  min-height: 24px;
  place-items: center;
  border-radius: 3px;
  background: var(--symbol-bg);
  color: currentColor;
  content: "";
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.contact-xic::after {
  content: "| |";
}

.contact-xio::after {
  content: "|/|";
}

.edge-ons::after {
  content: "|^|";
}

.compare-equ::after {
  content: "EQU";
  border: 2px solid currentColor;
}

.compare-grt::after {
  content: "GRT";
  border: 2px solid currentColor;
}

.compare-les::after {
  content: "LES";
  border: 2px solid currentColor;
}

.timer-ton::after {
  content: "TON";
  border: 2px solid currentColor;
}

.timer-tof::after {
  content: "TOF";
  border: 2px solid currentColor;
}

.counter-ctu::after {
  content: "CTU";
  border: 2px solid currentColor;
}

.coil-ote::after {
  min-width: 42px;
  content: "( )";
  font-size: 12px;
}

.coil-otl::after {
  min-width: 42px;
  content: "(L)";
  font-size: 12px;
}

.coil-otu::after {
  min-width: 42px;
  content: "(U)";
  font-size: 12px;
}

.coil-res::after {
  min-width: 42px;
  content: "RES";
  border: 2px solid currentColor;
}

.io-practice-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.io-practice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 78px;
  gap: 8px;
  align-items: center;
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.io-practice-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.io-practice-row strong,
.io-practice-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.io-practice-row span {
  color: var(--muted);
  font-size: 11px;
}

.bit-button,
.force-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.bit-button.on {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 13%, var(--surface));
  color: var(--green);
}

.force-button {
  color: var(--violet);
}

.bit-spacer {
  width: 42px;
  height: 1px;
}

.practice-results-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
}

.variable-table select,
.variable-table input {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.variable-table input {
  padding: 4px 6px;
}

.variable-table span {
  color: var(--muted);
  font-size: 12px;
}

.results-table tr.row-true td {
  background: color-mix(in srgb, var(--green) 9%, transparent);
}

.results-table tr.row-forced td {
  color: var(--violet);
  font-weight: 800;
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .product-shell,
:root[data-theme="dark"] .boot-screen {
  background: var(--page);
}

:root[data-theme="dark"] .hero-panel {
  background:
    linear-gradient(135deg, rgba(18, 25, 35, 0.96), rgba(23, 33, 48, 0.88)),
    var(--surface);
}

:root[data-theme="dark"] .stage-list button.active,
:root[data-theme="dark"] .practice-sidebar button.active,
:root[data-theme="dark"] .profile-card.selected {
  background: color-mix(in srgb, var(--brand) 16%, var(--surface));
}

:root[data-theme="dark"] .wiring-board,
:root[data-theme="dark"] .network-map {
  background: #0e141d;
}

:root[data-theme="dark"] .rack-visual,
:root[data-theme="dark"] .hmi-indicators div,
:root[data-theme="dark"] .segmented,
:root[data-theme="dark"] .command-readout,
:root[data-theme="dark"] .factory-frame,
:root[data-theme="dark"] .mini-sim {
  background: var(--surface-soft);
}

:root[data-theme="dark"] .ladder-head {
  background: #172130;
}

:root[data-theme="dark"] .ladder-rungs,
:root[data-theme="dark"] .rung-canvas {
  background-color: #101722;
}

:root[data-theme="dark"] .rung-canvas {
  background-image:
    linear-gradient(to right, rgba(74, 90, 112, 0.38) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(74, 90, 112, 0.38) 1px, transparent 1px);
}

:root[data-theme="dark"] .ladder-rung.energized {
  background: #102319;
}

:root[data-theme="dark"] .power-rail,
:root[data-theme="dark"] .logic-line {
  background: #d8e4f3;
}

:root[data-theme="dark"] .ld-element,
:root[data-theme="dark"] .practice-element,
:root[data-theme="dark"] .practice-coil-card {
  --symbol-bg: #101722;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
}

:root[data-theme="dark"] .ld-element.hot,
:root[data-theme="dark"] .practice-element.hot,
:root[data-theme="dark"] .practice-coil-card.hot {
  border-color: transparent;
  background: transparent;
  color: var(--green);
}

:root[data-theme="dark"] .insert-pointer.active::before,
:root[data-theme="dark"] .insert-pointer.drag-target::before {
  border-color: var(--page);
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

:root[data-theme="dark"] .insert-pointer.drag-target::before {
  background: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent);
}

:root[data-theme="dark"] .insert-pointer.active::after {
  background: var(--ink);
}

:root[data-theme="dark"] .st-preview pre {
  background: #080b10;
}

:root[data-theme="dark"] #factory-canvas,
:root[data-theme="dark"] #mini-factory-canvas {
  background: #0f151d;
}

:root[data-theme="dark"] .alarm-row,
:root[data-theme="dark"] .trace-row,
:root[data-theme="dark"] .check-row,
:root[data-theme="dark"] .log-row,
:root[data-theme="dark"] .saved-row,
:root[data-theme="dark"] .io-practice-row,
:root[data-theme="dark"] .template-panel button,
:root[data-theme="dark"] .instruction-palette,
:root[data-theme="dark"] .instruction-tool,
:root[data-theme="dark"] .branch-empty,
:root[data-theme="dark"] .mini-tool,
:root[data-theme="dark"] .bit-button,
:root[data-theme="dark"] .force-button {
  background: var(--surface);
}

.content-page.narrow {
  width: min(860px, 100%);
  margin: 0 auto;
}

.account-grid {
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
}

.profile-form label,
.contact-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.profile-form input,
.profile-form select,
.contact-panel input,
.contact-panel textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.contact-panel textarea {
  resize: vertical;
}

.saved-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.saved-row span {
  grid-column: 1;
}

.saved-row button {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.healthy {
  border-color: rgba(17, 132, 91, 0.45) !important;
  color: var(--green) !important;
}

.running {
  border-color: rgba(17, 132, 91, 0.5) !important;
  color: var(--green) !important;
}

.stopped {
  border-color: rgba(123, 132, 146, 0.5) !important;
  color: var(--faint) !important;
}

.warning {
  border-color: rgba(196, 122, 0, 0.55) !important;
  color: var(--amber) !important;
}

.fault,
.alarm {
  border-color: rgba(204, 51, 64, 0.58) !important;
  color: var(--red) !important;
}

.disconnected {
  border-color: rgba(123, 132, 146, 0.65) !important;
  color: var(--muted) !important;
}

@media (max-width: 1180px) {
  .site-header {
    grid-template-columns: minmax(200px, 1fr);
    gap: 8px;
  }

  .primary-nav,
  .support-nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .home-hero,
  .build-layout,
  .practice-layout,
  .hardware-grid,
  .wiring-layout,
  .communication-grid,
  .hmi-scada-layout,
  .fault-layout,
  .account-grid,
  .test-layout,
  .practice-grid,
  .practice-lab-grid,
  .st-preview {
    grid-template-columns: minmax(0, 1fr);
  }

  .instruction-palette {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .build-sidebar,
  .practice-sidebar {
    position: static;
  }

  .stage-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .runtime-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .practice-topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .practice-actions {
    justify-content: flex-start;
  }

  .template-panel,
  .practice-editor,
  .practice-sim-panel {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding: 14px;
  }

  .home-hero {
    min-height: auto;
  }

  .hero-copy h1,
  .content-heading h1,
  .stage-header h1 {
    font-size: 32px;
    line-height: 1.08;
  }

  .snapshot-band,
  .stage-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .wiring-board,
  .network-map,
  .acceptance-strip,
  .hmi-indicators {
    grid-template-columns: minmax(0, 1fr);
  }

  .instruction-palette {
    grid-template-columns: minmax(0, 1fr);
  }

  .practice-sim-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .ladder-rung {
    grid-template-columns: minmax(0, 1fr);
  }

  .rung-number,
  .rung-comment {
    border-right: 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .trace-row,
  .check-row,
  .log-row,
  .saved-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .saved-row button {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }
}
