
.studio-shell {
  font-family: var(--font-ui);
  color: var(--ink);
}
.studio-shell .topbar {
  background: var(--steel-deep);
  border-bottom: 1px solid var(--n-700);
  color: var(--n-100);
}
.studio-shell .topbar button,
.studio-shell .topbar input {
  color: var(--n-100);
}
.studio-shell .topbar button:hover {
  background: var(--n-800);
}
.studio-shell .topbar .primary {
  background: var(--accent-400);
}
.studio-shell .topbar #project-name {
  background: transparent;
}
.studio-shell .topbar #save-state {
  color: var(--n-400);
}
.studio-shell .workspace-tabs {
  background: var(--n-100);
  border-bottom: 1px solid var(--n-300);
}
.studio-shell .workspace-tabs button.active {
  background: var(--n-150);
  border-color: var(--n-400);
  color: var(--accent-700);
  font-weight: 650;
}
.studio-shell .sidebar {
  background: var(--n-50);
}
.studio-shell .library-tabs {
  background: var(--n-150);
}
.studio-shell .plant-library-item {
  min-height: 62px;
  padding: 6px 8px;
  gap: 8px;
}
.studio-shell .plant-library-item .component-icon {
  width: 30px;
  min-width: 30px;
}
.studio-shell .plant-library-item small {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: var(--fs-2xs);
  line-height: 1.3;
  color: var(--n-600);
  margin-top: 3px;
}
.studio-shell .plant-library-item > span:nth-child(2) {
  font-size: var(--fs-xs);
  line-height: 1.3;
  min-width: 0;
}
.studio-shell .drag-grip {
  display: none;
}
.studio-shell .component-group {
  font-size: var(--fs-2xs);
  letter-spacing: 0.12em;
  color: var(--n-600);
}
.studio-shell .canvas-toolbar,
.studio-shell .plant-toolbar {
  background: var(--n-25);
  border-bottom: 1px solid var(--n-300);
  gap: 5px;
}
.studio-shell button {
  border-radius: var(--r-sm);
}
.studio-shell .ladder-tools {
  overflow: visible;
}
.studio-shell .canvas-toolbar strong {
  display: none;
}
.studio-shell .ladder-sheet {
  padding: 0;
  background: var(--n-25);
  position: relative;
}
.studio-shell .sheet-heading {
  height: 25px;
  min-height: 25px;
  background: var(--n-50);
  border-bottom: 1px solid var(--n-200);
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 5px 10px;
  white-space: nowrap;
  overflow: hidden;
  font-size: var(--fs-2xs);
}
.studio-shell #rungs-container.continuous-board {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background-color: var(--canvas);
  background-image: radial-gradient(var(--n-300) 0.8px, transparent 0.8px);
  background-size: 20px 20px;
  touch-action: none;
  outline: none;
  min-height: 800px;
  overflow: visible;
}
.continuous-board .graph-node {
  cursor: move;
}
.continuous-board .graph-rail {
  stroke: var(--n-600);
}
.continuous-board .ladder-cell {
  color: var(--n-800);
}
.continuous-board .cell-address {
  font-size: var(--fs-2xs);
  color: var(--accent-600);
}
.continuous-board .cell-tag {
  font-size: var(--fs-2xs);
  color: var(--n-800);
}
.continuous-board .port {
  border-color: var(--accent-400);
}
.continuous-board .graph-node:hover .port {
  background: var(--n-200);
}
.continuous-board .wire {
  stroke: var(--n-700);
  stroke-width: 1.8;
}
.continuous-board .wire.live {
  stroke: var(--accent-400);
}
.continuous-board .wire.selected-wire {
  stroke: var(--warn);
  stroke-width: 3;
}
.multi-selected > .ladder-cell,
.scene-object.multi-selected {
  outline: 1.5px solid var(--warn) !important;
  outline-offset: 4px;
  background: color-mix(in srgb, var(--warn) 7%, transparent) !important;
}
.selection-marquee {
  position: absolute;
  border: 1px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 13%, transparent);
  z-index: 1000;
  pointer-events: none;
}
.studio-shell .graph-node .ladder-cell.selected {
  background: transparent;
  border-color: transparent;
}
.studio-shell .plant-viewport {
  background: var(--n-200);
}
.studio-shell #plant-stage {
  background-color: var(--n-25);
  background-image: radial-gradient(var(--n-300) 0.8px, transparent 0.8px);
  box-shadow: 0 0 0 1px var(--n-300);
}
.studio-shell .object-caption {
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--n-800);
  font-size: var(--fs-sm);
}
.studio-shell .object-signal {
  color: var(--n-600);
  font-size: var(--fs-2xs);
}
.studio-shell .scene-status {
  background: var(--n-50);
  color: var(--n-700);
}
#properties-host h2 {
  font-size: var(--fs-3xl);
  line-height: 1.2;
  margin: 3px 0;
  color: var(--n-800);
}
.component-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}
.component-preview {
  width: 50px;
  height: 50px;
  background: var(--n-100);
  border: 1px solid var(--n-200);
  border-radius: var(--r-md);
  padding: 8px;
}
.component-preview svg,
.component-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.component-heading .eyebrow {
  font-size: var(--fs-2xs);
  letter-spacing: 0.13em;
  color: var(--n-600);
}
.component-description {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--n-600);
  margin: 12px 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--n-200);
}
#scene-props,
#element-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#scene-props label,
#element-form label {
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--n-700);
  margin: 0;
}
#scene-props input,
#scene-props select,
#element-form input,
#element-form select {
  font-size: var(--fs-sm);
  min-height: 35px;
  border: 1px solid var(--n-300);
  background: var(--n-0);
  border-radius: var(--r-sm);
  width: 100%;
  margin-top: 5px;
}
.property-section-title {
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 6px 0 0;
  color: var(--accent-600);
  border-left: 3px solid var(--warn);
  padding-left: 8px;
}
.signal-list {
  border: 1px solid var(--n-200);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.signal-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--n-50);
  border-bottom: 1px solid var(--n-200);
}
.signal-field:last-child {
  border-bottom: 0;
}
.signal-field small {
  display: block;
  font-size: var(--fs-2xs);
  line-height: 1.4;
  font-weight: 400;
  color: var(--n-600);
  margin-top: 3px;
}
.signal-field select {
  margin: 0 !important;
}
.appearance-options {
  border-top: 1px solid var(--n-200);
  border-bottom: 1px solid var(--n-200);
  padding: 0;
  margin: 6px 0;
}
.appearance-options summary {
  padding: 12px 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  color: var(--n-600);
}
.appearance-options[open] {
  padding-bottom: 12px;
}
.property-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.check-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
}
.check-label input {
  width: 15px !important;
  min-height: 15px !important;
  height: 15px;
  margin: 0 !important;
  accent-color: var(--accent-400);
}
.property-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  bottom: -18px;
  background: var(--n-0);
  padding: 12px 0 8px;
  border-top: 1px solid var(--n-200);
  z-index: 3;
}
.property-actions button {
  min-height: 36px;
  padding: 6px 16px;
}
.secondary-actions {
  margin-top: 15px;
  padding-top: 8px;
  border-top: 1px solid var(--n-150);
}
.secondary-actions button {
  font-size: var(--fs-xs);
  border: 0;
  color: var(--n-600);
}
.secondary-actions .danger {
  color: var(--fault-ink);
}
.route-a,
.route-b {
  position: absolute;
  right: 0;
  font: var(--fs-sm) var(--font-mono);
  color: var(--n-700);
}
.route-a {
  top: 0;
}
.route-b {
  bottom: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 700px) {
  .signal-field {
    grid-template-columns: 1fr;
  }
  .studio-shell .sheet-heading > span:last-child {
    display: none;
  }
  .studio-shell .ladder-tools {
    overflow-x: auto;
  }
  .studio-shell .canvas-toolbar {
    overflow: auto;
  }
  .studio-shell .plant-library-item {
    min-height: 64px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .scene-object * {
    animation-duration: 0s !important;
    transition: none !important;
  }
}

.studio-shell .topbar .brand,
.studio-shell .topbar .brand strong {
  color: var(--n-100);
}
.studio-shell .topbar .edition,
.studio-shell .topbar #run-state {
  color: var(--n-400);
}
.studio-shell .topbar #connect-board {
  border-color: var(--n-600);
}
.ladder-preview svg {
  fill: none;
  stroke: var(--n-700);
  stroke-width: 2;
}
.ladder-preview text {
  fill: var(--n-700);
  stroke: none;
  font: var(--fs-sm) var(--font-mono);
  text-anchor: middle;
}
#inspector-content #scene-props,
#inspector-content #element-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#inspector-content #scene-props .signal-field {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
}
#inspector-content #scene-props .property-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#inspector-content #element-form > .primary {
  min-height: 36px;
  margin-top: 2px;
}
#inspector-content #element-mapping {
  min-height: 32px;
  margin-top: 8px;
}
@media (max-width: 650px) {
  #inspector-content #scene-props .signal-field {
    grid-template-columns: 1fr;
  }
}
.material-route {
  fill: none;
  stroke: var(--warn);
  stroke-width: 2;
  stroke-dasharray: 7 6;
  opacity: 0.6;
  pointer-events: none;
}
#plant-stage[data-mode="operate"] .material-route {
  opacity: 0.25;
}
#plant-stage[data-mode="operate"] [data-kind="cargo"] {
  transition: left 0.08s linear,
    top 0.08s linear;
}
@media (pointer: coarse) {
  #properties-dialog button,
  #properties-dialog input,
  #properties-dialog select {
    min-height: 44px !important;
  }
  .studio-shell .port:before {
    content: "";
    position: absolute;
    inset: -8px;
  }
  .studio-shell .canvas-toolbar,
  .studio-shell .plant-toolbar {
    min-height: 38px;
  }
}
#plant-stage:not(.simulation-running) .scene-object * {
  animation-play-state: paused !important;
}
/* Connection workbench: ordered evidence, explicit recovery, compact controls. */
#hardware-dialog {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  overflow: auto;
  color: var(--n-800);
}
#hardware-dialog .dialog-heading {
  margin: 0 0 12px;
  align-items: center;
}
#hardware-dialog h2 {
  font-size: var(--fs-4xl);
  margin: 0;
}
.hardware-intro,
.hardware-execution {
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--n-600);
  margin: 12px 0;
}
.hardware-progress {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--n-200);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin: 16px 0;
}
.hardware-progress span {
  padding: 12px 8px;
  font-size: var(--fs-sm);
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--n-50);
}
.hardware-progress b {
  border: 1px solid var(--n-500);
  border-radius: 50%;
  height: 22px;
  min-width: 22px;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
}
.hardware-progress .current {
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.hardware-progress .complete {
  background: var(--n-100);
  color: var(--accent-700);
}
.hardware-profile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-md);
  padding-bottom: 14px;
}
#hardware-dialog .connection-methods {
  gap: 10px;
}
#hardware-dialog .radio-option {
  padding: 12px;
  font-size: var(--fs-lg);
}
#hardware-dialog .hardware-auto-recovery {
  min-height: 52px;
  margin: 0 0 6px;
  border: 1px solid var(--n-300);
  border-radius: var(--r-sm);
  background: var(--n-25);
  align-items: flex-start;
}
#hardware-dialog .hardware-auto-recovery:has(input:checked) {
  border-color: var(--accent-400);
  background: var(--n-50);
}
#hardware-dialog .hardware-auto-recovery input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}
.firmware-preparation {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: center;
  margin: 12px 0 4px;
  padding: 14px;
  border: 1px solid var(--n-300);
  border-radius: var(--r-sm);
  background: var(--n-25);
}
.firmware-preparation > div:first-child {
  display: grid;
  gap: 4px;
}
.firmware-preparation small {
  color: var(--n-600);
  line-height: 1.4;
}
.firmware-preparation #prepare-board {
  border-color: var(--accent-600);
  color: var(--accent-700);
  font-weight: 700;
}
.preparation-progress {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--n-200);
}
.preparation-progress[hidden] {
  display: none;
}
.preparation-progress span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  background: var(--accent-400);
  transition: width 180ms ease;
}
#preparation-status {
  grid-column: 1 / -1;
  min-height: 1.4em;
  margin: 0;
  color: var(--n-700);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
#preparation-status[data-state="error"] {
  color: var(--fault-ink);
}
#preparation-status[data-state="success"] {
  color: var(--accent-700);
  font-weight: 700;
}
#hardware-recovery-log {
  min-height: 1.5em;
  margin: 4px 0 14px;
  line-height: 1.5;
}
#hardware-dialog .connection-notice {
  margin: 14px 0;
  padding: 14px;
  border-left: 3px solid var(--n-400);
  font-size: var(--fs-lg);
}
#hardware-status[data-state="error"] {
  background: var(--n-50);
  border-color: var(--fault);
  color: var(--fault-ink);
}
#hardware-status[data-state="success"] {
  background: var(--n-100);
  border-color: var(--accent-400);
  color: var(--accent-700);
}
#hardware-remedy {
  background: var(--n-25);
  border: 1px solid var(--warn-line);
  padding: 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  line-height: 1.55;
}
#hardware-remedy p {
  margin: 6px 0 10px;
}
#hardware-remedy code {
  white-space: normal;
  overflow-wrap: anywhere;
}
#hardware-feedback {
  padding: 12px;
  background: var(--n-50);
  font-size: var(--fs-sm);
  display: grid;
  gap: 8px;
}
#hardware-feedback[hidden],
#hardware-remedy[hidden] {
  display: none;
}
.pin-feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pin-feedback span {
  padding: 5px 8px;
  background: var(--n-0);
  border: 1px solid var(--n-200);
  border-radius: var(--r-xs);
}
#hardware-dialog .dialog-actions {
  position: sticky;
  bottom: -24px;
  background: var(--n-0);
  padding: 16px 0;
  margin: 16px 0 0;
  border-top: 1px solid var(--n-200);
}
#offline-status {
  font-size: var(--fs-xs);
  white-space: nowrap;
  color: var(--n-600);
  margin-left: auto;
  padding: 0 8px;
}
#app-install,
#app-update {
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.continuous-board .rail-strip {
  top: 0;
  width: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  transform: none;
  z-index: 3;
  cursor: crosshair;
  opacity: 1;
}
.continuous-board .rail-strip:hover,
.continuous-board .rail-strip.armed,
.continuous-board .rail-strip.snap-target {
  background: color-mix(in srgb, var(--warn) 17%, transparent);
  outline: 1px solid var(--warn);
}
.continuous-board .rail-handle {
  position: absolute;
  top: 0;
  width: 30px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  font-size: var(--fs-xs);
  z-index: 4;
  background: var(--n-700);
  color: var(--n-0);
  border: 0;
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  cursor: ew-resize;
  touch-action: none;
}
.is-simulating .continuous-board .port,
.is-simulating .rail-handle,
.is-simulating .object-resize {
  pointer-events: none;
  opacity: 0;
}
.is-simulating .graph-node .ladder-cell {
  cursor: pointer;
}
.is-simulating .graph-node .ladder-cell:active {
  background: var(--ok-bg);
}
.is-simulating .multi-selected {
  outline: 0 !important;
  box-shadow: none !important;
}
.image-mode {
  padding: 12px;
  border: 1px solid var(--n-200);
  border-radius: var(--r-sm);
  margin: 14px 0;
}
.image-mode label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.image-mode input {
  width: auto !important;
}
#image-behavior {
  padding: 12px;
  background: var(--n-50);
  display: grid;
  gap: 12px;
}
#image-behavior[hidden] {
  display: none;
}
.scene-object[data-kind="image"] .scene-graphic {
  transform-origin: center;
  position: relative;
}
.scene-object.image-lit .scene-graphic {
  filter: drop-shadow(0 0 10px var(--component-color));
}
.scene-object.image-lit .scene-graphic:after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--component-color);
  mix-blend-mode: color;
  opacity: 0.65;
  pointer-events: none;
}
.scene-object.drop-compatible {
  outline: 2px dashed var(--accent-400);
  background: color-mix(in srgb, var(--ok-bg) 25%, transparent);
}
.ladder-tools {
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  #hardware-dialog {
    padding: 16px;
  }
  #hardware-dialog .dialog-actions {
    bottom: -16px;
  }
  .hardware-progress span {
    flex-direction: column;
    text-align: center;
    gap: 5px;
    padding: 8px 4px;
  }
  .hardware-profile {
    flex-wrap: wrap;
  }
  .firmware-preparation {
    grid-template-columns: 1fr;
  }
  .firmware-preparation #prepare-board {
    width: 100%;
  }
  #offline-status {
    max-width: 140px;
    white-space: normal;
    font-size: var(--fs-2xs);
  }
  #hardware-dialog button,
  #hardware-dialog select {
    min-height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .scene-object[data-kind="image"] .scene-graphic {
    transform: none !important;
  }
}
.studio-shell .sheet-heading {
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}
.studio-shell .sheet-heading #sheet-count {
  flex-shrink: 0;
  white-space: nowrap;
}
.studio-shell .sheet-heading span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
