.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  background: var(--canvas);
}

.document-bar {
  display: flex;
  min-width: 0;
  height: 39px;
  flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.document-tabs {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  isolation: isolate;
}

.document-tabs::-webkit-scrollbar {
  display: none;
}

.document-tabs button {
  position: relative;
  height: 38px;
  padding: 0 15px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  color: var(--ink-soft);
  background: transparent;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.document-tabs button:hover {
  background: var(--surface);
}

.document-tabs button.active {
  color: var(--ink);
  font-weight: 600;
}

.document-tabs button.active::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  content: '';
  background: var(--blue);
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 0 8px;
  flex: none;
}

.panel-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  flex: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}

.panel-controls button:hover {
  color: var(--ink);
  background: var(--hover);
  transform: translateY(-1px);
}

.panel-controls button.active {
  color: var(--blue-dark);
  background: var(--blue-pale);
}

.panel-controls button:active {
  transform: scale(.94);
}

.workspace-scroll {
  min-height: 0;
  overflow: auto;
  flex: 1;
  background: var(--surface);
  view-transition-name: workspace-content;
}

.workspace-scroll[tabindex="-1"]:focus,
[data-workspace-start][tabindex="-1"]:focus {
  outline: none;
}

.workspace-scroll:has([data-ladder-editor]) {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: transparent transparent;
  scrollbar-width: thin;
}

.workspace-scroll:has([data-ladder-editor]):hover,
.workspace-scroll:has([data-ladder-editor]):focus-within {
  scrollbar-color: color-mix(in srgb, var(--surface) 80%, var(--ink)) transparent;
}

.workspace-scroll:has([data-ladder-editor])::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.workspace-scroll:has([data-ladder-editor])::-webkit-scrollbar-track,
.workspace-scroll:has([data-ladder-editor])::-webkit-scrollbar-corner {
  background: transparent;
}

.workspace-scroll:has([data-ladder-editor])::-webkit-scrollbar-thumb {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  background-clip: padding-box;
}

.workspace-scroll:has([data-ladder-editor]):hover::-webkit-scrollbar-thumb,
.workspace-scroll:has([data-ladder-editor]):focus-within::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--surface) 80%, var(--ink));
}

.workspace-scroll:has([data-ladder-editor])::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--surface) 70%, var(--ink));
}

.workspace-scroll:has([data-ladder-editor])::-webkit-scrollbar-thumb:active {
  background-color: color-mix(in srgb, var(--surface) 55%, var(--ink));
}

.routine-toolbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 46px;
  overflow-x: auto;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.routine-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: none;
}

.routine-title strong {
  font-size: 15px;
}

.routine-title small {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .06em;
}

.routine-tabs {
  display: flex;
  gap: 2px;
}

.routine-tabs button {
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.routine-tabs button:hover {
  background: var(--hover);
}

.routine-tabs button.active {
  color: var(--ink);
  background: var(--blue-pale);
}

.live-label {
  margin-left: auto;
  padding-left: 12px;
  color: var(--green);
  font-size: 12.5px;
  white-space: nowrap;
}

.ladder-canvas {
  min-width: 820px;
  padding: 8px 0 28px;
}

.rung {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 55px;
  padding: 15px 20px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  text-align: left;
}

button.rung {
  cursor: pointer;
}

button.rung:hover {
  background: var(--surface);
}

.rung.selected::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  content: '';
  background: var(--blue);
}

.change-marker {
  width: 10px;
  flex: none;
  font-size: 13px;
}

.rung-number {
  width: 30px;
  color: var(--muted);
  flex: none;
  font-size: 13px;
}

.ladder-rail {
  min-width: 4px;
  height: 2px;
  background: color-mix(in srgb, var(--surface) 85%, var(--ink));
  flex: 1;
}

.ladder-contact {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-size: 14.5px;
  white-space: nowrap;
}

.ladder-contact i {
  width: 2px;
  height: 24px;
  background: var(--green);
}

.ladder-contact.off {
  font-weight: 600;
}

.ladder-contact.off i {
  background: var(--red);
}

.ladder-contact small {
  color: var(--amber);
  font-size: 12px;
}

.ladder-coil {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  flex: none;
  white-space: nowrap;
}

.ladder-coil.on {
  color: var(--green);
}

.ladder-coil b {
  font-size: 20px;
  font-weight: 400;
}

.ladder-coil strong {
  font-size: 14.5px;
}

.rung-end {
  width: 10px;
  flex: none;
}

.timer-block {
  padding: 7px 14px;
  border: 2px solid color-mix(in srgb, var(--surface) 85%, var(--ink));
  border-radius: 6px;
  flex: none;
  font-size: 14.5px;
  white-space: nowrap;
}

.timer-block em {
  color: var(--green);
  font-style: normal;
}

.insert-rung {
  padding: 16px 20px;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
}

.insert-rung:hover {
  color: var(--blue-dark);
  background: var(--surface);
}

.content-page {
  display: flex;
  min-width: 0;
  padding: 22px 24px 32px;
  flex-direction: column;
  gap: 22px;
}

.content-page.narrow {
  max-width: 740px;
}

.page-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.page-heading h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.01em;
}

.page-heading > span,
.page-heading > button {
  margin-left: auto;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12.5px;
}

.running {
  color: var(--green);
}

.warning {
  color: var(--amber);
}

.lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
}

.muted {
  color: var(--ink-soft);
}

.intro {
  max-width: 64ch;
  margin: 0 0 20px;
  font-size: 14px;
}

.two-columns,
.device-grid,
.overview-columns,
.change-summary {
  display: grid;
  gap: 22px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(230px, 1fr));
}

.two-columns p,
.two-columns a {
  display: block;
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 14px;
}

.two-columns a {
  color: var(--blue);
}

.two-columns a:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

.sequence-list > div {
  display: flex;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

.sequence-list span {
  width: 14px;
  color: var(--muted);
}

.sequence-list strong {
  font-weight: 400;
}

.sequence-list small {
  color: var(--amber);
}

.sequence-list em {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
  font-style: normal;
}

.dependency-graph {
  display: grid;
  grid-template-columns: auto 44px auto 44px auto;
  align-items: center;
  min-width: 660px;
}

.dependency-stack {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

.dependency-graph > i {
  height: 2px;
  background: color-mix(in srgb, var(--surface) 85%, var(--ink));
}

.node {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  white-space: nowrap;
}

.node.on {
  color: var(--green);
}

.node.off {
  color: var(--red);
  border-color: var(--status-red-soft);
  background: var(--hover);
  font-weight: 600;
}

.downstream {
  margin-top: 28px;
}

.node-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.node small {
  margin-left: 8px;
  color: var(--muted);
}

.diff-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  font-size: 13.5px;
}

.diff-heading span {
  color: var(--muted);
  font-size: 12.5px;
}

.diff-heading a,
.diff-heading .text-action {
  margin-left: auto;
  color: var(--blue);
}

.diff-heading .text-action:hover {
  color: var(--blue-dark);
}

.diff-view > p:not(.diff-summary) {
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 12px 20px;
  border-bottom: 1px solid;
}

.diff-view .removed {
  color: var(--red);
  border-color: var(--status-red-soft);
  background: var(--hover);
}

.diff-view .added {
  color: var(--green);
  border-color: var(--status-green-soft);
  background: var(--hover);
}

.diff-view p span {
  color: var(--ink-soft);
  font-size: 14px;
}

.diff-summary {
  max-width: 62ch;
  margin: 18px 20px 0;
  color: var(--muted);
  line-height: 1.6;
}

.warning-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--surface) 85%, var(--ink));
  border-radius: 10px;
  background: var(--hover);
  text-align: left;
}

.warning-banner b {
  color: var(--amber);
}

.warning-banner span {
  color: var(--muted);
  font-size: 13px;
}

.warning-banner a,
.warning-banner .banner-link {
  margin-left: auto;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.warning-banner:hover {
  border-color: color-mix(in srgb, var(--surface) 75%, var(--ink));
  background: var(--status-amber-soft);
}

.warning-banner:hover .banner-link {
  color: var(--blue-dark);
}

.process-sequence {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.process-sequence span,
.process-sequence strong {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px;
}

.process-sequence strong {
  color: var(--blue);
  background: var(--blue-pale);
}

.process-sequence i {
  color: color-mix(in srgb, var(--surface) 80%, var(--ink));
  font-style: normal;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px 24px;
}

.metrics div {
  display: flex;
  gap: 4px;
  flex-direction: column;
}

.metrics small {
  color: var(--muted);
}

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

.overview-columns button {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  text-align: left;
}

.overview-columns button > :last-child {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
  font-style: normal;
}

.overview-columns button:hover {
  padding-right: 8px;
  padding-left: 8px;
  border-radius: 7px;
  background: var(--hover);
}

.overview-columns button em {
  color: var(--amber);
}

.overview-columns button i {
  color: var(--blue);
}

.overview-columns button b {
  color: var(--green);
}

.device-page {
  max-width: 860px;
  gap: 20px;
}

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

.device-grid p {
  margin: 0 0 4px;
  font-size: 14px;
}

.device-grid small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
}

.eyebrow.offset {
  margin-top: 16px;
}

.value-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
}

.value-row > :last-child {
  margin-left: auto;
}

.value-row b {
  color: var(--green);
}

.value-row em {
  color: var(--muted);
  font-style: normal;
}

.value-row i {
  color: var(--red);
  font-style: normal;
}

.text-link {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
}

.text-link:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

.more-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  background: transparent;
}

.more-row strong {
  color: var(--ink-soft);
}

.more-row:hover {
  color: var(--ink-soft);
  background: var(--hover);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-actions > button:not(.primary-action) {
  height: 32px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--surface) 75%, var(--ink));
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}

.page-actions a,
.page-actions .text-action {
  color: var(--muted);
  font-size: 13px;
}

.page-actions > button:not(.primary-action):hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--surface) 50%, var(--blue));
  background: var(--hover);
}

.page-actions .text-action {
  height: auto !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.page-actions .text-action:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

.text-action {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: inherit;
}

.change-page {
  max-width: 900px;
  gap: 18px;
}

.change-kicker {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .06em;
}

.change-kicker strong,
.change-kicker em {
  color: var(--amber);
  font-style: normal;
}

.change-kicker em {
  margin-left: auto;
}

.change-summary {
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.change-summary section {
  display: flex;
  gap: 4px;
  padding: 15px;
  border-right: 1px solid var(--line);
  flex-direction: column;
}

.change-summary span {
  color: var(--muted);
  font-size: 12.5px;
}

.revision-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--surface);
}

.revision-detail > div {
  display: flex;
  gap: 2px;
  flex-direction: column;
}

.revision-detail span {
  color: var(--muted);
  font-size: 11.5px;
}

.revision-detail strong {
  font-size: 13px;
}

.revision-detail button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
}

.revision-detail button:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--surface) 75%, var(--ink));
}

.change-items > div {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(220px, 1.4fr) auto;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.change-items span {
  color: var(--ink-soft);
}

.change-items em {
  color: var(--amber);
  font-style: normal;
}

.document-entry {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  flex: 0 0 auto;
  max-width: 240px;
  border-right: 1px solid var(--line-soft);
  background: transparent;
  contain: layout style;
  transition: background-color 160ms ease, color 160ms ease;
}

.document-entry.active {
  background: var(--blue-pale);
}

.document-entry::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  content: '';
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1);
}

.document-entry.active::after {
  transform: scaleX(1);
}

.document-entry:hover:not(.active) {
  background: var(--surface);
}

.document-entry > a {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 38px;
  overflow: hidden;
  padding: 0 10px 0 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  transition: color 160ms ease;
}

.document-entry.active > a {
  color: var(--ink);
}

.document-entry > button {
  display: grid;
  width: 28px;
  height: 28px;
  margin-right: 5px;
  flex: none;
  place-items: center;
  padding: 0;
  border-right: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  opacity: .62;
  transition: background-color 140ms ease, color 140ms ease, opacity 140ms ease, transform 100ms ease;
}

.document-entry > button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.document-entry.active > button,
.document-entry:hover > button,
.document-entry > button:focus-visible {
  opacity: 1;
}

.document-entry > button:hover {
  color: var(--ink);
  background: var(--hover);
}

.document-entry > button:active {
  background: color-mix(in srgb, var(--surface) 90%, var(--ink));
  transform: scale(.9);
}

.document-entry.closing {
  pointer-events: none;
}
