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

.nest-section {
  padding: clamp(2.5rem, 6vw, 5.5rem) 0;
}

.nest-app {
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(16, 21, 30, 0.96);
  box-shadow: var(--shadow);
}

.nest-app-heading,
.nest-card-heading,
.nest-run-heading,
.nest-panel-heading,
.nest-file-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.nest-app-heading {
  padding-bottom: 1.35rem;
  margin-bottom: 1.35rem;
  border-bottom: 1px solid var(--line);
}

.nest-app-heading .eyebrow {
  margin-bottom: 0.45rem;
}

.nest-app-heading h2,
.nest-task-card h3,
.nest-import h3,
.nest-run h3,
.nest-panel h3 {
  margin: 0;
}

.nest-app-heading h2 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  letter-spacing: -0.04em;
}

.nest-state-chip {
  min-width: 8.5rem;
  text-align: center;
}

.nest-state-chip[data-state="reading"],
.nest-state-chip[data-state="validating"],
.nest-state-chip[data-state="stopping"] {
  color: var(--text);
  border-color: #b88b36;
}

.nest-state-chip[data-state="ready"],
.nest-state-chip[data-state="result-ready"],
.nest-state-chip[data-state="stopped-result"] {
  color: #b9fbd5;
  border-color: #3c9666;
}

.nest-state-chip[data-state="searching"],
.nest-state-chip[data-state="best-updated"] {
  color: #bceff2;
  border-color: var(--aqua);
}

.nest-state-chip[data-state="failed"],
.nest-state-chip[data-state="stopped-empty"] {
  color: #ffd0c6;
  border-color: #d85b42;
}

.nest-step,
.nest-summary-label {
  margin: 0 0 0.28rem;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nest-import,
.nest-task-card,
.nest-run {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 10, 15, 0.42);
}

.nest-import {
  padding: clamp(1rem, 2vw, 1.4rem);
}

.nest-import > div:first-child p:last-child,
.nest-run-heading p,
.nest-card-heading + p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.nest-dropzone {
  position: relative;
  display: grid;
  min-height: 11rem;
  place-items: center;
  align-content: center;
  gap: 0.28rem;
  padding: 1.5rem;
  margin-top: 1rem;
  color: var(--muted);
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 122, 69, 0.08), rgba(91, 207, 214, 0.04)),
    var(--bg-soft);
  border: 2px dashed #566274;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.nest-dropzone:hover,
.nest-dropzone.is-dragging {
  color: var(--text);
  border-color: var(--accent);
  background-color: rgba(255, 122, 69, 0.08);
}

.nest-dropzone.is-dragging {
  transform: translateY(-2px);
}

.nest-dropzone:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 4px;
}

.nest-dropzone[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

.nest-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.nest-drop-icon {
  display: grid;
  width: 3.1rem;
  height: 3.1rem;
  place-items: center;
  color: #160d08;
  background: var(--accent);
  border-radius: 0.8rem;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 900;
  transform: rotate(-3deg);
}

.nest-dropzone strong {
  margin-top: 0.35rem;
  color: var(--text);
  font-size: 1.05rem;
}

.nest-help,
.nest-unit-note,
.nest-stat-note {
  color: var(--subtle);
  font-size: 0.76rem;
}

.nest-help {
  margin: 0.6rem 0 0;
}

.nest-file-summary {
  align-items: center;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}

.nest-file-summary > div:first-child {
  display: grid;
  min-width: 0;
  gap: 0.16rem;
}

.nest-file-summary strong,
.nest-file-summary span {
  overflow-wrap: anywhere;
}

.nest-file-summary span:last-child {
  color: var(--subtle);
  font-size: 0.78rem;
}

.nest-inline-actions,
.nest-toolbar,
.nest-view-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.nest-inline-actions .button {
  min-height: 2.6rem;
}

.nest-status {
  padding: 0.85rem 1rem;
  margin: 1rem 0 0;
  color: var(--muted);
  background: var(--bg-soft);
  border-left: 3px solid var(--aqua);
  border-radius: 0.3rem var(--radius-sm) var(--radius-sm) 0.3rem;
}

.nest-error {
  margin-top: 0.75rem;
}

.nest-error:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 3px;
}

.nest-config {
  padding: 0;
  margin: 1rem 0 0;
  border: 0;
}

.nest-config[disabled] {
  opacity: 0.58;
}

.nest-config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(17rem, 0.65fr);
  gap: 1rem;
}

.nest-task-card,
.nest-run {
  padding: clamp(1rem, 2vw, 1.35rem);
}

.nest-unit-badge {
  padding: 0.3rem 0.55rem;
  color: var(--aqua);
  border: 1px solid #365d64;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.nest-primary-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.nest-unit-note {
  padding: 0.65rem 0.75rem;
  margin: 0.75rem 0 0;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
}

.nest-sheet-choice {
  margin-top: 1rem;
}

.nest-sheet-choice h4 {
  margin: 0;
  font-size: 0.82rem;
}

.nest-sheet-choice > p {
  margin: 0.25rem 0 0.6rem;
  color: var(--subtle);
  font-size: 0.74rem;
}

.nest-sheet-list {
  display: grid;
  max-height: 12.5rem;
  gap: 0.35rem;
  padding: 0.15rem;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.nest-sheet-list label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.52rem 0.65rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nest-sheet-list label:hover,
.nest-sheet-list label:has(input:checked) {
  color: var(--text);
  border-color: var(--accent);
}

.nest-sheet-list input {
  width: 1.08rem;
  height: 1.08rem;
  accent-color: var(--accent);
}

.nest-sheet-list input:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 3px;
}

.nest-sheet-list small {
  color: var(--subtle);
}

.nest-geometry-stats,
.nest-run-stats {
  display: grid;
  gap: 1px;
  padding: 1px;
  margin: 1rem 0 0;
  overflow: hidden;
  background: var(--line);
  border-radius: var(--radius-sm);
}

.nest-geometry-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nest-run-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.nest-geometry-stats div,
.nest-run-stats div {
  padding: 0.72rem 0.8rem;
  background: var(--bg-soft);
}

.nest-geometry-stats dt,
.nest-run-stats dt {
  color: var(--subtle);
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nest-geometry-stats dd,
.nest-run-stats dd {
  margin: 0.18rem 0 0;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
  font-weight: 850;
}

.nest-stat-note {
  margin: 0.75rem 0 0;
}

.nest-controls-card,
.nest-run {
  margin-top: 1rem;
}

.nest-control-fields {
  max-width: 46rem;
}

.nest-settings {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.nest-settings summary {
  min-height: 2.75rem;
  padding: 0.82rem 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.nest-settings summary:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 3px;
}

.nest-settings summary::marker {
  color: var(--accent);
}

.nest-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
}

.nest-checks {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.nest-checks label {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.nest-checks input {
  width: 1.08rem;
  height: 1.08rem;
  accent-color: var(--accent);
}

.nest-run-heading {
  align-items: end;
}

.nest-run-heading > p {
  max-width: 38rem;
  font-size: 0.8rem;
  text-align: right;
}

.nest-toolbar {
  margin-top: 1rem;
}

.nest-toolbar .button {
  min-height: 2.9rem;
}

.nest-toolbar button:disabled,
.nest-view-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.nest-progress {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
}

.nest-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
}

.nest-progress progress {
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  background: var(--bg-soft);
  border: 0;
  border-radius: 999px;
  accent-color: var(--accent);
}

.nest-workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.nest-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.nest-panel-heading {
  align-items: center;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.nest-panel-heading > div:first-child {
  min-width: 0;
}

.nest-panel-heading h3 {
  font-size: 0.95rem;
}

.nest-panel-heading span {
  display: block;
  margin-top: 0.18rem;
  color: var(--subtle);
  font-size: 0.68rem;
}

.nest-view-controls {
  flex-wrap: nowrap;
  gap: 0.3rem;
}

.nest-view-controls button {
  min-width: 2.7rem;
  min-height: 2.7rem;
  padding: 0.4rem 0.5rem;
  color: var(--muted);
  background: #171d28;
  border: 1px solid #3a4454;
  border-radius: 0.42rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.nest-view-controls button:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.nest-view-controls button:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 2px;
}

.nest-canvas {
  position: relative;
  min-height: 28rem;
  max-height: 42rem;
  padding: 1rem;
  overflow: auto;
  color: #303641;
  background-color: #f6f4ee;
  background-image:
    linear-gradient(45deg, #e8e5de 25%, transparent 25%),
    linear-gradient(-45deg, #e8e5de 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e5de 75%),
    linear-gradient(-45deg, transparent 75%, #e8e5de 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.nest-canvas:focus-visible {
  outline: 4px solid var(--aqua);
  outline-offset: -4px;
}

.nest-viewport-stage {
  display: grid;
  min-width: 100%;
  min-height: 26rem;
  place-items: center;
  align-content: start;
  gap: 1rem;
}

.nest-svg-stack {
  position: relative;
  display: inline-block;
  max-width: none;
  line-height: 0;
}

.nest-viewport-stage[data-zoom="fit"] .nest-svg-stack {
  width: 100%;
}

.nest-viewport-stage[data-zoom="fit"] .nest-svg-stack svg,
.nest-viewport-stage[data-zoom="fit"] .nest-result-sheet svg {
  max-width: 100%;
  height: auto;
}

.nest-viewport-stage[data-zoom="fit"] .nest-result-sheet {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.nest-svg-stack > svg:first-child {
  display: block;
}

.nest-svg-stack > svg + svg {
  position: absolute;
  inset: 0;
}

.nest-svg-stack svg {
  overflow: visible;
}

.nest-svg-stack [data-nest-selectable="true"] {
  cursor: pointer;
}

.nest-svg-stack [data-nest-selectable="true"]:hover,
.nest-svg-stack [data-nest-selectable="true"]:focus,
.nest-svg-stack .nest-bin-active {
  filter: drop-shadow(0 0 4px #ff7a45);
  stroke: #ff5722;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.nest-result .nest-viewport-stage {
  place-items: stretch;
}

.nest-result-sheet {
  min-width: 12rem;
  margin: 0;
  border: 1px solid #c9c5bb;
  background: #fff;
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.14);
}

.nest-result-sheet figcaption {
  position: sticky;
  left: 0;
  padding: 0.45rem 0.6rem;
  color: #303641;
  background: #ece9e1;
  border-bottom: 1px solid #c9c5bb;
  font-size: 0.72rem;
  font-weight: 850;
}

.nest-result-sheet svg {
  display: block;
  background: #fff;
}

.nest-empty {
  align-self: center;
  max-width: 20rem;
  margin: auto;
  color: #59616e;
  font-weight: 750;
  text-align: center;
}

@media (max-width: 70rem) {
  .nest-run-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 62rem) {
  .nest-config-grid,
  .nest-workspace {
    grid-template-columns: 1fr;
  }

  .nest-canvas {
    min-height: 22rem;
  }

  .nest-viewport-stage {
    min-height: 20rem;
  }
}

@media (max-width: 44rem) {
  .nest-app-heading,
  .nest-card-heading,
  .nest-run-heading,
  .nest-panel-heading,
  .nest-file-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .nest-state-chip {
    align-self: flex-start;
  }

  .nest-inline-actions,
  .nest-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nest-inline-actions > *,
  .nest-toolbar > * {
    width: 100%;
  }

  .nest-primary-fields,
  .nest-settings-grid,
  .nest-checks,
  .nest-geometry-stats,
  .nest-run-stats {
    grid-template-columns: 1fr;
  }

  .nest-run-heading > p {
    text-align: left;
  }

  .nest-panel-heading {
    gap: 0.7rem;
  }

  .nest-view-controls {
    width: 100%;
  }

  .nest-view-controls button {
    flex: 1;
  }

  .nest-canvas {
    min-height: 18rem;
    max-height: 31rem;
  }

  .nest-viewport-stage {
    min-height: 16rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nest-dropzone {
    transition: none;
  }

  .nest-dropzone.is-dragging {
    transform: none;
  }
}

@media (forced-colors: active) {
  .nest-dropzone,
  .nest-task-card,
  .nest-run,
  .nest-panel,
  .nest-sheet-list label,
  .nest-result-sheet,
  .nest-view-controls button {
    forced-color-adjust: auto;
    border-color: CanvasText;
  }

  .nest-dropzone:focus-visible,
  .nest-canvas:focus-visible,
  .nest-view-controls button:focus-visible,
  .nest-sheet-list input:focus-visible {
    outline-color: Highlight;
  }

  .nest-svg-stack .nest-bin-active {
    filter: none;
    stroke: Highlight;
  }
}
