.routine-page[data-ladder-editor] {
  position: relative;
  min-height: 100%;
  background: var(--surface);
}

.routine-page[data-ladder-editor] .routine-toolbar {
  z-index: 30;
}

.routine-page[data-ladder-editor] .routine-tabs button {
  border-radius: 8px;
}

.routine-page[data-ladder-editor] .routine-tabs button:disabled {
  color: var(--ink-soft);
  cursor: default;
  opacity: 1;
}

.routine-page[data-ladder-editor] .routine-tabs button:disabled:hover {
  background: transparent;
}

.routine-view-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.routine-page[data-ladder-editor] .routine-changes-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  transition: color 120ms ease, background 120ms ease;
}

.routine-page[data-ladder-editor] .routine-changes-link:hover {
  color: var(--ink);
  background: var(--hover);
}

.routine-instructions-toggle {
  padding: 6px 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  flex: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 120ms ease;
}

.routine-instructions-toggle:hover {
  color: var(--blue-dark);
}

.routine-documentation-link {
  position: relative;
  display: grid;
  width: 32px;
  height: 32px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  color: color-mix(in srgb, var(--surface) 40%, var(--ink));
  background: var(--hover);
  flex: 0 0 32px;
  place-items: center;
  transition: color 120ms ease, background 120ms ease;
}

.routine-documentation-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.35;
}

.routine-documentation-link:hover {
  color: var(--blue);
  background: var(--hover);
}

.routine-documentation-link:focus-visible {
  color: var(--blue);
  background: var(--hover);
  outline: 2px solid color-mix(in srgb, var(--blue) 28%, transparent);
  outline-offset: 2px;
}

.routine-documentation-link.is-linked {
  color: var(--blue);
  background: var(--blue-pale);
}

.routine-documentation-link.is-linked::after {
  position: absolute;
  width: 6px;
  height: 6px;
  top: -2px;
  right: -2px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--blue);
  content: '';
}

.routine-generate-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-pale);
  flex: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, transform 120ms ease;
}

.routine-generate-button span {
  font-size: 14px;
  line-height: 1;
}

.routine-generate-button:hover {
  color: var(--blue-dark);
  background: var(--blue-pale);
  transform: translateY(-1px);
}

.routine-generate-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--blue) 28%, transparent);
  outline-offset: 2px;
}

.routine-generate-button:disabled {
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  background: var(--hover);
  cursor: default;
  transform: none;
}

.routine-agent-status:not([hidden]) {
  margin: 0;
  padding: 7px 16px;
  color: var(--danger, #a33);
  font-size: 12px;
}

.ladder-toolbox {
  position: sticky;
  z-index: 29;
  top: 46px;
  border-bottom: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  background: var(--surface);
}

.ladder-toolbox-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 37px;
  padding: 4px 18px 0;
  overflow: visible;
}

.ladder-toolbox-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px 4px 0;
  border: 0;
  color: color-mix(in srgb, var(--surface) 70%, var(--ink));
  background: transparent;
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  transition: color 120ms ease;
}

.ladder-toolbox-toggle:hover {
  color: var(--ink);
}

.ladder-toolbox-caret {
  width: 9px;
  font-size: 8px;
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1);
}

.ladder-toolbox.is-collapsed .ladder-toolbox-caret {
  transform: rotate(-90deg);
}

.ladder-toolbox-categories {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  min-width: 0;
  overflow-x: auto;
  flex: 0 1 auto;
  scrollbar-width: thin;
}

.ladder-toolbox-category {
  position: relative;
  padding: 6px 9px 8px;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: color 120ms ease;
}

.ladder-toolbox-category:hover {
  color: var(--ink);
}

.ladder-toolbox-category[aria-selected="true"] {
  color: var(--blue);
}

.ladder-toolbox-category[aria-selected="true"]::after {
  position: absolute;
  right: 5px;
  bottom: 0;
  left: 5px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--blue);
  content: '';
  animation: toolbox-underline-in 160ms cubic-bezier(.2, .8, .2, 1) both;
}

.ladder-toolbox-search {
  position: relative;
  width: 30px;
  height: 30px;
  margin: 0 0 4px auto;
  border: 0;
  border-radius: 50%;
  background: var(--hover);
  flex: none;
  transition: width 240ms cubic-bezier(.2, .8, .2, 1), border-radius 240ms ease, background 160ms ease;
}

.ladder-toolbox-search:hover {
  background: var(--blue-pale);
}

.ladder-toolbox-search:hover .ladder-toolbox-search-toggle {
  color: var(--blue);
}

.ladder-toolbox-search.is-open {
  width: clamp(240px, 25vw, 320px);
  border-radius: 16px;
  background: var(--hover);
}

.ladder-toolbox-search:focus-within {
  background: var(--hover);
}

.ladder-toolbox-search-toggle {
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 11.5px;
  font-weight: 600;
  transition: width 240ms cubic-bezier(.2, .8, .2, 1), color 160ms ease;
}

.ladder-toolbox-search-toggle svg {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.ladder-toolbox-search.is-open .ladder-toolbox-search-toggle {
  width: 30px;
  color: var(--blue);
}

.ladder-toolbox-search-field {
  position: absolute;
  inset: 0 4px 0 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  visibility: hidden;
  opacity: 0;
  transform: translateX(7px);
  transition: opacity 140ms ease, transform 200ms ease, visibility 0s linear 200ms;
}

.ladder-toolbox-search.is-open .ladder-toolbox-search-field {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 180ms ease 70ms, transform 220ms ease, visibility 0s;
}

.ladder-toolbox-search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  flex: 1;
  font-family: inherit;
  font-size: 12px;
}

.ladder-toolbox-search input::-webkit-search-cancel-button {
  display: none;
}

.ladder-toolbox-search-field > span {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.ladder-toolbox-search-field > span:empty {
  display: none;
}

.ladder-toolbox-search-close {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  flex: none;
  font-size: 17px;
  line-height: 1;
  transition: color 120ms ease, background 120ms ease;
}

.ladder-toolbox-search-close:hover {
  color: var(--blue);
  background: var(--blue-pale);
}

.ladder-toolbox-disclosure {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 190ms cubic-bezier(.2, .8, .2, 1), opacity 150ms ease;
}

.ladder-toolbox.is-collapsed .ladder-toolbox-disclosure {
  grid-template-rows: 0fr;
  opacity: 0;
}

.ladder-toolbox-items {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 0;
  padding: 8px 18px 9px;
  overflow-x: auto;
  overflow-y: hidden;
  border-top: 1px solid color-mix(in srgb, var(--surface) 95%, var(--ink));
  scrollbar-width: thin;
}

.ladder-toolbox.is-collapsed .ladder-toolbox-items {
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
}

.ladder-toolbox-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  border-radius: 7px;
  color: color-mix(in srgb, var(--surface) 15%, var(--ink));
  background: var(--surface);
  flex: none;
  cursor: grab;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  transition: border-color 130ms ease, background 130ms ease, box-shadow 130ms ease, color 130ms ease, opacity 130ms ease, transform 130ms ease;
}

.ladder-toolbox-item:hover {
  border-color: color-mix(in srgb, var(--surface) 75%, var(--ink));
  background: var(--surface);
  transform: translateY(-1px);
}

.ladder-toolbox-item:active {
  cursor: grabbing;
  transform: translateY(0) scale(.98);
}

.ladder-toolbox-item.active {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: var(--blue-pale);
  box-shadow: 0 0 0 1px var(--blue);
}

.ladder-toolbox-item.is-dragging {
  opacity: .45;
  transform: scale(.97);
}

.ladder-toolbox-item:disabled {
  opacity: .5;
  cursor: default;
  transform: none;
}

.ladder-toolbox-item[data-toolbox-add-rung] {
  cursor: pointer;
}

.ladder-toolbox-divider {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: color-mix(in srgb, var(--surface) 90%, var(--ink));
  flex: none;
}

.ladder-instruction-glyph {
  display: block;
  width: 36px;
  height: 21px;
  flex: none;
  color: currentColor;
}

.ladder-toolbox-placement {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  padding-left: 14px;
  flex: none;
  animation: toolbox-placement-in 150ms ease-out both;
}

.ladder-toolbox-placement span {
  color: var(--blue);
  font-size: 12px;
  white-space: nowrap;
}

.ladder-toolbox-placement button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ladder-toolbox-placement button:hover {
  color: var(--ink);
}

.ladder-toolbox-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.ladder-editor-layout {
  display: flex;
  align-items: stretch;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
}

.routine-page[data-ladder-editor] .ladder-canvas {
  position: relative;
  min-width: 440px;
  padding: 0 0 26px;
  flex: 1;
  isolation: isolate;
}

.ladder-global-rail {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--surface) 40%, var(--ink));
  pointer-events: none;
}

.ladder-global-rail-left {
  left: 62px;
}

.ladder-global-rail-right {
  right: 42px;
}

.ladder-rung-wrap {
  min-width: 440px;
}

.ladder-rung {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 94px;
  padding: 7px 0 9px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background 120ms ease;
}

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

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

.ladder-rung-meta {
  display: flex;
  align-items: flex-start;
  width: 62px;
  padding: 3px 0 0 16px;
  flex: none;
}

.ladder-rung .rung-number {
  width: auto;
  color: var(--muted);
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ladder-rung-body {
  min-width: 0;
  padding-right: 42px;
  flex: 1;
}

.ladder-rung-comment {
  margin: 0 0 4px;
  padding-left: 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  text-wrap: pretty;
}

.ladder-network {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.ladder-line {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  min-height: calc(96px * var(--line-legs, 1));
}

.ladder-side-rail {
  width: 4px;
  align-self: stretch;
  border-radius: 2px;
  background: transparent;
  flex: none;
}

.ladder-side-rail-right {
  background: transparent;
}

.ladder-continuation {
  display: flex;
  align-items: center;
  height: 96px;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  flex: none;
  font-size: 15px;
}

.ladder-continuation-in {
  padding-left: 4px;
}

.ladder-continuation-out {
  padding-right: 4px;
}

.ladder-gap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  flex: 1 1 auto;
}

.ladder-gap > i {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 2px;
  background: color-mix(in srgb, var(--surface) 80%, var(--ink));
  transform: translateY(-50%);
  transition: height 130ms ease, background 130ms ease;
}

.ladder-gap > span {
  position: relative;
  display: grid;
  width: 20px;
  height: 20px;
  border: 1px solid color-mix(in srgb, var(--surface) 95%, var(--ink));
  border-radius: 50%;
  color: color-mix(in srgb, var(--surface) 90%, var(--ink));
  opacity: 0;
  background: var(--surface);
  place-items: center;
  font-size: 0;
  transition: width 120ms ease, height 120ms ease, color 120ms ease, border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.ladder-gap > span::before {
  position: absolute;
  top: 50%;
  left: 50%;
  content: '+';
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transform: translate(-50%, -53%);
}

.ladder-rung:hover .ladder-gap > span,
.ladder-gap:focus-visible > span,
.ladder-gap.armed > span,
.ladder-gap.drop-available > span {
  opacity: 1;
}

.ladder-gap:hover > span {
  border-color: var(--blue);
  color: #fff;
  background: var(--accent-solid);
  transform: scale(1.06);
}

.ladder-gap.armed > span {
  width: 22px;
  height: 22px;
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-pale);
}

.ladder-gap.drop-available {
  cursor: copy;
}

.ladder-gap.drop-move {
  cursor: move;
}

.ladder-gap.drop-unavailable {
  cursor: not-allowed;
}

.ladder-gap.drop-available > span {
  width: 22px;
  height: 22px;
  border-color: var(--blue-pale);
  color: color-mix(in srgb, var(--surface) 50%, var(--blue));
  background: var(--surface);
}

.ladder-gap.drop-active > i {
  height: 3px;
  background: var(--blue);
}

.ladder-gap.drop-active > span {
  width: 26px;
  height: 26px;
  border-color: var(--blue);
  color: #fff;
  background: var(--accent-solid);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--blue) 10%, transparent);
  transform: scale(1.04);
  animation: ladder-drop-pulse 1s ease-in-out infinite;
}

.ladder-gap.drop-unavailable > span {
  opacity: .35;
}

.ladder-gap.armed:hover > span {
  color: #fff;
  background: var(--accent-solid);
}

.ladder-instruction {
  position: relative;
  height: 96px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  flex: none;
  cursor: pointer;
  white-space: nowrap;
}

.ladder-instruction[draggable="true"] {
  cursor: grab;
}

.ladder-instruction.is-dragging {
  opacity: .45;
  cursor: grabbing;
}

.ladder-instruction::before {
  position: absolute;
  z-index: -1;
  top: 7px;
  right: -8px;
  bottom: 7px;
  left: -8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  content: '';
  transition: border-color 120ms ease, background 120ms ease;
}

.ladder-instruction:hover::before,
.ladder-instruction:focus-visible::before {
  border-color: var(--blue-pale);
  background: var(--surface);
}

.routine-page[data-ladder-editor] .ladder-contact,
.routine-page[data-ladder-editor] .ladder-coil {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 52px;
  padding: 5px 0;
  box-sizing: border-box;
  flex-direction: column;
}

.ladder-instruction-name {
  display: flex;
  align-items: center;
  height: 20px;
  padding: 0 4px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

.ladder-instruction-caption {
  position: absolute;
  top: 21px;
  height: 16px;
  color: color-mix(in srgb, var(--surface) 45%, var(--ink));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
}

.ladder-contact-symbol {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0;
  transform: translateY(-50%);
}

.ladder-contact-symbol::before,
.ladder-contact-symbol::after {
  width: auto;
  min-width: 9px;
  height: 2px;
  background: color-mix(in srgb, var(--surface) 80%, var(--ink));
  content: '';
  flex: 1 1 auto;
}

.ladder-contact-symbol i {
  width: 3px;
  height: 28px;
  background: var(--ink);
}

.ladder-contact-symbol b {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 28px;
  overflow: visible;
  font-size: 0;
}

.ladder-contact.inverse .ladder-contact-symbol b::after {
  position: absolute;
  left: -3px;
  width: 24px;
  height: 2px;
  background: var(--ink);
  content: '';
  transform: rotate(-40deg);
}

.ladder-coil-symbol {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0;
  transform: translateY(-50%);
}

.ladder-coil-symbol::before,
.ladder-coil-symbol::after {
  width: auto;
  min-width: 9px;
  height: 2px;
  background: color-mix(in srgb, var(--surface) 80%, var(--ink));
  content: '';
  flex: 1 1 auto;
}

.ladder-coil-symbol i {
  width: 11px;
  height: 28px;
  border: 3px solid var(--ink);
  box-sizing: border-box;
}

.ladder-coil-symbol i:first-child {
  border-right: 0;
  border-radius: 16px 0 0 16px;
}

.ladder-coil-symbol i:last-child {
  border-left: 0;
  border-radius: 0 16px 16px 0;
}

.ladder-coil-symbol b {
  display: grid;
  width: 17px;
  height: 28px;
  color: var(--ink);
  place-items: center;
  font-size: 12.5px;
  font-weight: 800;
}

.ladder-block {
  display: flex;
  align-items: stretch;
  height: auto;
  min-height: 54px;
  min-width: 175px;
  margin: 9px 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(20 24 33 / 5%);
}

.ladder-block::before {
  display: none;
}

.ladder-block:hover,
.ladder-block:focus-visible {
  border-color: color-mix(in srgb, var(--surface) 75%, var(--ink));
  box-shadow: 0 3px 10px rgb(20 24 33 / 9%);
}

.ladder-block-edge {
  width: 5px;
  background: color-mix(in srgb, var(--surface) 20%, var(--ink));
  flex: none;
}

.ladder-block-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.ladder-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--hover);
  white-space: nowrap;
}

.ladder-block-head strong {
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  background: color-mix(in srgb, var(--surface) 20%, var(--ink));
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .06em;
}

.ladder-block-head b {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

.ladder-block-head small {
  color: color-mix(in srgb, var(--surface) 20%, var(--ink));
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
}

.ladder-block-body {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 4px;
  padding: 5px 10px 6px;
  white-space: nowrap;
}

.ladder-block-body > em {
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  font-size: 11px;
  font-style: normal;
}

.ladder-block-field {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.ladder-block-field b {
  min-width: 48px;
  color: color-mix(in srgb, var(--surface) 45%, var(--ink));
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .07em;
}

.ladder-block-field em {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-style: normal;
}

.ladder-block-timer .ladder-block-edge,
.ladder-block-timer .ladder-block-head strong {
  background: var(--blue);
}

.ladder-block-timer .ladder-block-head {
  background: var(--hover);
}

.ladder-block-timer .ladder-block-head small {
  color: var(--blue);
}

.ladder-block-counter .ladder-block-edge,
.ladder-block-counter .ladder-block-head strong {
  background: #127b84;
}

.ladder-block-counter .ladder-block-head {
  background: var(--hover);
}

.ladder-block-counter .ladder-block-head small {
  color: #127b84;
}

.ladder-block-math .ladder-block-edge,
.ladder-block-math .ladder-block-head strong,
.ladder-block-compare .ladder-block-edge,
.ladder-block-compare .ladder-block-head strong {
  background: var(--amber);
}

.ladder-block-math .ladder-block-head,
.ladder-block-compare .ladder-block-head {
  background: var(--status-amber-soft);
}

.ladder-block-math .ladder-block-head small,
.ladder-block-compare .ladder-block-head small {
  color: var(--amber);
}

.ladder-block-control .ladder-block-edge,
.ladder-block-control .ladder-block-head strong {
  background: var(--accent-solid);
}

.ladder-block-control .ladder-block-head {
  background: var(--hover);
}

.ladder-block-control .ladder-block-head small {
  color: var(--blue);
}

.ladder-branch {
  align-self: center;
  height: auto;
  margin: 25px 0;
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--surface) 85%, var(--ink));
  border-radius: 5px;
  color: var(--blue-dark);
  background: var(--surface);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
}

.ladder-branch-group {
  position: relative;
  display: flex;
  min-width: 170px;
  padding-bottom: 31px;
  flex: 1 1 auto;
  flex-direction: column;
}

.ladder-branch-leg {
  position: relative;
  display: flex;
  align-items: flex-start;
  min-width: 0;
  min-height: calc(96px * var(--path-rows, 1));
  padding: 0 3px;
}

.ladder-branch-leg:has(+ .ladder-branch-leg)::before,
.ladder-branch-leg:has(+ .ladder-branch-leg)::after {
  position: absolute;
  z-index: 1;
  top: 48px;
  bottom: -48px;
  width: 2px;
  background: color-mix(in srgb, var(--surface) 80%, var(--ink));
  content: '';
  pointer-events: none;
}

.ladder-branch-leg::before {
  left: 0;
}

.ladder-branch-leg::after {
  right: 0;
}

.ladder-branch-actions {
  position: absolute;
  right: 3px;
  bottom: 3px;
  left: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
}

.ladder-branch-actions button,
.ladder-branch-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, transform 120ms ease;
}

.ladder-branch-add {
  color: var(--blue);
  background: var(--blue-pale);
}

.ladder-branch-add span {
  font-size: 17px;
  font-weight: 500;
  transform: translateY(-1px);
}

.ladder-branch-add:hover,
.ladder-branch-add:focus-visible {
  color: #fff;
  background: var(--accent-solid);
  transform: scale(1.06);
}

.ladder-branch-remove {
  color: var(--red);
  background: var(--hover);
}

.ladder-branch-remove:hover,
.ladder-branch-remove:focus-visible {
  color: #fff;
  background: var(--red);
}

.ladder-branch-remove svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.ladder-branch-remove {
  position: absolute;
  z-index: 3;
  top: 0;
  right: clamp(28px, 12%, 48px);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: color 120ms ease, opacity 120ms ease, background 120ms ease;
}

.ladder-branch-remove:active:not(:disabled) {
  transform: translateY(-50%);
}

.ladder-branch-group:hover:not(:has(.ladder-branch-group:hover)) > .ladder-branch-leg > .ladder-branch-remove,
.ladder-branch-group:focus-within:not(:has(.ladder-branch-group:focus-within)) > .ladder-branch-leg > .ladder-branch-remove,
.ladder-branch-remove:focus-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.ladder-branch-empty {
  display: flex;
  align-items: center;
  height: 96px;
  color: color-mix(in srgb, var(--surface) 75%, var(--ink));
  flex: none;
  font-size: 11.5px;
}

.ladder-source-block {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 310px;
  height: auto;
  margin: 16px 0;
  padding: 9px 11px;
  border: 1px dashed color-mix(in srgb, var(--surface) 75%, var(--ink));
  border-radius: 7px;
  color: var(--ink-soft);
  background: var(--surface);
}

.ladder-source-block strong {
  color: var(--amber);
  font-size: 10px;
  letter-spacing: .06em;
}

.ladder-source-block span {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
}

.ladder-pending-instruction {
  --edit-accent: var(--blue);
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
  position: relative;
  z-index: 3;
  display: flex;
  align-items: stretch;
  flex-direction: column;
  width: 350px;
  max-width: calc(100vw - 64px);
  margin: 8px 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--edit-accent) 45%, color-mix(in srgb, var(--surface) 90%, var(--ink)));
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 6px 22px rgb(26 42 66 / 10%), 0 1px 3px rgb(26 42 66 / 5%);
  flex: none;
  animation: ladder-edit-in 180ms ease-out both;
}

.ladder-pending-instruction[data-edit-kind="contact"] {
  --edit-accent: #287466;
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-pending-instruction[data-edit-kind="coil"] {
  --edit-accent: var(--blue);
  --edit-tint: var(--blue-pale);
}

.ladder-pending-instruction[data-edit-kind="timer"] {
  --edit-accent: var(--blue);
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-pending-instruction[data-edit-kind="counter"] {
  --edit-accent: #127b84;
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-pending-instruction[data-edit-kind="compare"] {
  --edit-accent: #746039;
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-pending-instruction[data-edit-kind="math"] {
  --edit-accent: #956019;
  --edit-tint: var(--status-amber-soft);
}

.ladder-pending-instruction[data-edit-kind="control"],
.ladder-pending-instruction[data-edit-kind="aoi"] {
  --edit-accent: #6e5c94;
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-pending-instruction[data-edit-kind="alarms"] {
  --edit-accent: #a64f38;
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-pending-instruction[data-edit-kind="io"],
.ladder-pending-instruction[data-edit-kind="motion"] {
  --edit-accent: var(--blue);
  --edit-tint: color-mix(in srgb, var(--surface) 95%, var(--ink));
}

.ladder-edit-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 9px 9px 0 0;
  background: var(--edit-tint);
}

.ladder-edit-glyph {
  display: grid;
  width: 38px;
  height: 30px;
  place-items: center;
  color: var(--edit-accent);
  flex: none;
}

.ladder-edit-heading > div {
  min-width: 0;
  flex: 1;
}

.ladder-edit-heading strong {
  display: block;
  color: var(--edit-accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  letter-spacing: .04em;
}

.ladder-edit-heading small {
  display: block;
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.4;
}

.ladder-edit-kind {
  align-self: flex-start;
  padding-top: 2px;
  color: var(--edit-accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
}

.ladder-operand-fields {
  display: flex;
  max-height: 330px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex-direction: column;
  gap: 12px;
}

.ladder-operand-field {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 11px;
}

.ladder-operand-field label {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  line-height: 1.45;
}

.ladder-operand-field label small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.ladder-operand-control {
  position: relative;
  min-width: 0;
}

.ladder-pending-instruction input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--blue-pale);
  border-radius: 5px;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.ladder-operand-control:has([data-browse-tags]) input {
  padding-right: 30px;
}

.ladder-pending-instruction input::placeholder {
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  font-size: 11px;
}

.ladder-pending-instruction input:hover {
  border-color: color-mix(in srgb, var(--surface) 65%, var(--ink));
}

.ladder-pending-instruction input:focus {
  border-color: var(--edit-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--edit-accent) 12%, transparent);
}

.ladder-pending-instruction input[aria-invalid="true"] {
  border-color: #c04747;
  background: var(--surface);
}

.ladder-operand-control [data-browse-tags] {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 27px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.ladder-operand-control [data-browse-tags]:hover {
  color: var(--edit-accent);
  background: var(--edit-tint);
}

.ladder-operand-source label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
}

.ladder-edit-footer {
  padding: 11px 14px 9px;
  border-top: 1px solid var(--line-soft);
}

.ladder-edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.ladder-edit-actions button {
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--ink-soft);
  background: var(--hover);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.ladder-edit-actions button:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 90%, var(--ink));
}

.ladder-edit-actions button:active {
  transform: translateY(1px);
}

.ladder-pending-instruction button:focus-visible {
  outline: 2px solid var(--edit-accent);
  outline-offset: 3px;
}

.ladder-edit-actions button[type="submit"] {
  color: #fff;
  background: var(--edit-accent);
}

.ladder-edit-actions button[type="submit"]:hover {
  background: color-mix(in srgb, var(--edit-accent) 85%, #142038);
  box-shadow: 0 2px 5px rgb(26 42 66 / 15%);
}

.ladder-edit-actions [data-remove-instruction] {
  margin-right: auto;
  padding-right: 5px;
  padding-left: 5px;
  color: var(--muted);
  background: transparent;
}

.ladder-edit-actions [data-remove-instruction]:hover {
  color: #ac3636;
  background: var(--hover);
}

.ladder-edit-shortcuts {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 9px;
}

.ladder-edit-shortcuts b {
  color: var(--muted);
  font-weight: 400;
}

.ladder-edit-note,
.ladder-edit-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.ladder-edit-empty {
  padding: 7px 0;
}

.ladder-edit-error {
  margin: 0 14px 12px;
  color: #ae3636;
  font-size: 11px;
  line-height: 1.5;
}

.remove-rung {
  position: absolute;
  z-index: 4;
  top: 50%;
  right: 8px;
  display: grid;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: color-mix(in srgb, var(--surface) 60%, var(--ink));
  opacity: 0;
  background: transparent;
  flex: none;
  place-items: center;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  transform: translateY(-50%);
  cursor: pointer;
  transition: color 140ms ease, opacity 140ms ease, background 140ms ease, transform 140ms ease;
}

.ladder-rung:hover .remove-rung,
.remove-rung:focus-visible {
  opacity: 1;
}

.remove-rung:hover {
  color: var(--red) !important;
  background: var(--hover);
  transform: translateY(-50%) scale(1.05);
}

.remove-rung:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--blue) 22%, transparent);
  outline-offset: 2px;
  background: var(--surface);
}

.remove-rung:active {
  transform: translateY(-50%) scale(.96);
}

.instruction-browser {
  position: fixed;
  z-index: 86;
  display: flex;
  min-height: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 18px 46px rgb(16 24 40 / 18%), 0 2px 8px rgb(16 24 40 / 7%);
  flex-direction: column;
  transform-origin: top right;
  animation: browser-in 180ms cubic-bezier(.2, .8, .2, 1) both;
}

.instruction-browser[hidden] {
  display: none;
}

.instruction-browser.is-closing {
  pointer-events: none;
  animation: browser-out 130ms ease-in both;
}

.instruction-browser-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 13px 9px;
  flex: none;
}

.instruction-browser-heading strong {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .08em;
}

.instruction-browser-heading button {
  margin-left: auto;
  padding: 0;
  border: 0;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  background: transparent;
  font-size: 15px;
  line-height: 1;
}

.instruction-browser > label {
  display: block;
  padding: 0 13px 8px;
  flex: none;
}

.instruction-browser input,
.instruction-popover-search input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  border-radius: 7px;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.instruction-browser input:focus,
.instruction-popover-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 8%, transparent);
}

[data-instruction-list] {
  min-height: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  overscroll-behavior: contain;
}

[data-instruction-list] > p {
  margin: 0;
  padding: 8px 13px 4px;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

[data-instruction-list] > button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 13px;
  border: 0;
  background: transparent;
  text-align: left;
}

[data-instruction-list] > button:hover {
  background: var(--hover);
}

[data-instruction-list] > button strong {
  width: 52px;
  color: var(--blue);
  flex: none;
  font-size: 12.5px;
  letter-spacing: .03em;
}

[data-instruction-list] > button span {
  color: var(--ink-soft);
  font-size: 12.5px;
}

[data-instruction-list] > small {
  display: block;
  padding: 11px 13px;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  font-size: 12.5px;
}

.instruction-browser-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-top: 1px solid var(--line-soft);
  color: var(--blue);
  background: var(--surface);
  flex: none;
  text-align: left;
  transition: color 120ms ease, background 120ms ease;
}

.instruction-browser-agent:hover {
  color: var(--blue-dark);
  background: var(--hover);
}

.instruction-browser-agent > span {
  font-size: 12.5px;
}

.instruction-browser-agent > strong {
  font-size: 13px;
  font-weight: 600;
}

.instruction-popover-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
  animation: backdrop-in 120ms ease-out both;
}

.instruction-popover-backdrop.is-closing {
  animation: backdrop-out 130ms ease-in both;
}

.instruction-popover {
  position: fixed;
  z-index: 90;
  width: 336px;
  max-height: min(545px, calc(100vh - 20px));
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 46px rgb(16 24 40 / 18%);
  transform: translateX(-50%);
  transform-origin: top center;
  animation: instruction-popover-in 180ms cubic-bezier(.2, .8, .2, 1) both;
}

.instruction-popover.opens-up {
  transform-origin: bottom center;
}

.instruction-popover.is-closing {
  animation: instruction-popover-out 130ms ease-in both;
}

.instruction-popover-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 11px 13px 0;
}

.instruction-popover-heading strong {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
}

.instruction-popover-heading span {
  margin-left: auto;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  font-size: 11.5px;
}

.instruction-popover-panel {
  min-height: 0;
}

.instruction-popover-search {
  display: block;
  padding: 9px 11px 0;
}

.instruction-quick-picks {
  padding: 7px 0 6px;
}

.instruction-quick-picks > div {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 29px;
  padding: 2px 13px;
}

.instruction-quick-picks > div > strong {
  width: 60px;
  color: color-mix(in srgb, var(--surface) 70%, var(--ink));
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
}

.instruction-quick-picks > div > span {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.instruction-quick-picks button {
  padding: 3px 7px;
  border: 0;
  border-radius: 6px;
  color: var(--ink-soft);
  background: var(--hover);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  transition: background 120ms ease, transform 120ms ease;
}

.instruction-quick-picks button:hover {
  background: var(--blue-pale);
  transform: translateY(-1px);
}

.instruction-popover-list {
  max-height: 278px;
  padding: 2px 0 6px;
  overflow-y: auto;
  border-top: 1px solid color-mix(in srgb, var(--surface) 95%, var(--ink));
  overscroll-behavior: contain;
}

.instruction-category-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 9px 13px 4px;
  border: 0;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  background: transparent;
  text-align: left;
}

.instruction-category-heading:hover:not(.static) {
  color: var(--ink-soft);
}

.instruction-category-heading.static {
  cursor: default;
}

.instruction-category-heading > span {
  width: 8px;
  color: color-mix(in srgb, var(--surface) 70%, var(--ink));
  flex: none;
  font-size: 9px;
}

.instruction-category-heading > strong {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
}

.instruction-category-heading > small {
  margin-left: auto;
  color: color-mix(in srgb, var(--surface) 80%, var(--ink));
  font-size: 11px;
}

.instruction-category-items {
  animation: category-open 140ms ease-out both;
}

.instruction-popover-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 13px;
  border: 0;
  background: transparent;
  text-align: left;
}

.instruction-popover-item:hover,
.instruction-popover-item.highlighted {
  background: var(--blue-pale);
}

.instruction-popover-item strong {
  width: 52px;
  color: var(--blue);
  flex: none;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .03em;
}

.instruction-popover-item span {
  color: var(--ink-soft);
  font-size: 13px;
}

.instruction-empty {
  margin: 0;
  padding: 11px 13px;
  color: color-mix(in srgb, var(--surface) 55%, var(--ink));
  font-size: 13px;
}

.instruction-agent-action {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 13px;
  border: 0;
  border-top: 1px solid var(--line-soft);
  color: var(--blue);
  background: var(--surface);
  text-align: left;
}

.instruction-agent-action:hover {
  background: var(--hover);
}

.instruction-agent-action > span {
  font-size: 12.5px;
}

.instruction-agent-action > strong {
  font-size: 13px;
  font-weight: 600;
}

.instruction-agent-panel {
  display: flex;
  padding: 9px 13px 13px;
  flex-direction: column;
  gap: 9px;
}

.instruction-agent-panel > p:first-child {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.instruction-agent-panel textarea {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--surface) 90%, var(--ink));
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  resize: vertical;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
}

.instruction-agent-panel textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 8%, transparent);
}

.instruction-agent-buttons {
  display: flex;
  align-items: center;
  gap: 9px;
}

.instruction-agent-buttons button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12.5px;
}

.instruction-agent-buttons button:first-child {
  padding: 6px 12px;
  border-radius: 7px;
  color: #fff;
  background: var(--accent-solid);
  font-weight: 600;
}

.instruction-agent-buttons button:first-child:hover {
  background: var(--accent-solid);
}

.instruction-agent-buttons button:last-child:hover {
  color: var(--ink);
}

.instruction-agent-status {
  margin: 0;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--surface) 80%, var(--ink));
  border-radius: 7px;
  color: var(--amber);
  background: var(--hover);
  font-size: 11.5px;
  line-height: 1.45;
  animation: status-in 140ms ease-out both;
}

.panel-enter {
  animation: panel-enter 150ms ease-out both;
}

.ladder-tag-picker {
  position: fixed;
  z-index: 200;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--blue-pale);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 12px 32px rgb(27 45 78 / 16%), 0 2px 6px rgb(27 45 78 / 6%);
  flex-direction: column;
  animation: ladder-tags-in 120ms ease-out both;
}

@keyframes ladder-tags-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.ladder-tag-heading,
.ladder-tag-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  flex: none;
}

.ladder-tag-heading {
  border-bottom: 1px solid var(--line-soft);
}

.ladder-tag-heading strong {
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: .09em;
}

.ladder-tag-heading [data-close-tags] {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.ladder-tag-heading [data-close-tags]:hover {
  color: var(--ink);
  background: var(--hover);
}

.ladder-tag-heading > span {
  color: var(--muted);
  font-size: 11px;
}

.ladder-tag-options {
  min-height: 0;
  max-height: 205px;
  padding: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ladder-tag-options:empty {
  display: none;
}

.ladder-tag-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
}

.ladder-tag-option + .ladder-tag-option {
  margin-top: 2px;
}

.ladder-tag-option:hover {
  background: var(--hover);
}

.ladder-tag-option[aria-selected="true"] {
  color: var(--blue-dark);
  background: var(--blue-pale);
  box-shadow: inset 2px 0 var(--blue);
}

.ladder-tag-option > strong {
  align-self: center;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}

.ladder-tag-type {
  align-self: start;
  padding: 2px 5px;
  border: 1px solid var(--blue-pale);
  border-radius: 4px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 10px;
  font-weight: 600;
}

.ladder-tag-option > small {
  grid-column: 1 / -1;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 11px;
}

.ladder-tag-option > p {
  display: -webkit-box;
  grid-column: 1 / -1;
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  font-size: 11.5px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ladder-tag-empty {
  margin: 0;
  padding: 20px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.ladder-tag-footer {
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  background: var(--surface);
  font-size: 10px;
}

.ladder-tag-footer kbd {
  margin-right: 3px;
  color: var(--ink-soft);
  font: inherit;
}

.ladder-save-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.ladder-save-status[data-kind="saving"] {
  color: var(--muted);
}

.ladder-save-status[data-kind="error"] {
  position: fixed;
  z-index: 20;
  right: 14px;
  bottom: 42px;
  width: auto;
  height: auto;
  max-width: 420px;
  padding: 8px 11px;
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--surface) 75%, var(--ink));
  border-radius: 7px;
  color: var(--red);
  background: var(--surface);
  box-shadow: 0 8px 22px rgb(20 24 33 / 12%);
  clip: auto;
  white-space: normal;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@keyframes instruction-popover-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-7px) scale(.97);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes instruction-popover-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px) scale(.98);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes backdrop-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes category-open {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateX(5px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes browser-in {
  from {
    opacity: 0;
    transform: translateY(-7px) scale(.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes browser-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-4px) scale(.98);
  }
}

@keyframes ladder-edit-in {
  from {
    opacity: 0;
    transform: scale(.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes status-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toolbox-underline-in {
  from {
    opacity: 0;
    transform: scaleX(.35);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes toolbox-placement-in {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ladder-drop-pulse {
  0%, 100% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 8%, transparent);
  }
  50% {
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--blue) 14%, transparent);
  }
}

@media (max-width: 760px) {
  .instruction-popover {
    width: min(336px, calc(100vw - 20px));
  }

  .ladder-toolbox-tabs {
    padding-right: 12px;
    padding-left: 12px;
  }

  .ladder-toolbox-search.is-open {
    width: 230px;
    max-width: calc(100vw - 120px);
  }

  .ladder-toolbox-items {
    padding-right: 12px;
    padding-left: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ladder-pending-instruction *,
  .ladder-toolbox-search,
  .ladder-toolbox-search *,
  .ladder-toolbox-search.is-open * {
    transition: none;
  }

  .ladder-tag-picker,
  .instruction-popover,
  .instruction-popover-backdrop,
  .instruction-category-items,
  .instruction-browser,
  .ladder-pending-instruction,
  .ladder-toolbox-placement,
  .panel-enter,
  .instruction-agent-status {
    animation: none;
  }

  .ladder-gap > span,
  .ladder-gap > i,
  .routine-instructions-toggle,
  .routine-documentation-link,
  .routine-generate-button,
  .routine-page[data-ladder-editor] .routine-changes-link,
  .ladder-toolbox-caret,
  .ladder-toolbox-category,
  .ladder-toolbox-disclosure,
  .ladder-toolbox-item {
    transition: none;
  }

  .ladder-gap.drop-active > span {
    animation: none;
  }
}
.ladder-managed-pid {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.ladder-managed-pid a {
  color: var(--blue);
  font-weight: 600;
}
