:root {
  color-scheme: light;
  font-family: "Segoe UI Variable", "Segoe UI", Aptos, system-ui, -apple-system, sans-serif;
  color: #142033;
  background: #eef2f6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --shell: #10263f;
  --shell-deep: #0b1c2e;
  --surface: #ffffff;
  --surface-muted: #f5f7fa;
  --line: #d8e0e9;
  --line-strong: #b8c5d3;
  --text: #142033;
  --muted: #627084;
  --action: #246bce;
  --action-hover: #1e5caf;
  --danger: #8f2f35;
  --danger-surface: #fff0f1;
  --focus: #5d9cff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: #eef2f6;
}

::selection {
  color: #ffffff;
  background: #246bce;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  color: #ffffff;
  background: var(--shell);
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
  padding: max(18px, env(safe-area-inset-top)) 20px 18px;
}

.brand {
  width: min(100%, 560px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: var(--shell-raised, #173654);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-copy {
  min-width: 0;
}

.brand-title,
.brand-subtitle {
  margin: 0;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  margin-top: 3px;
  color: #c8d5e4;
  font-size: 14px;
  line-height: 1.35;
}

.workspace {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 24px 18px max(28px, env(safe-area-inset-bottom));
  align-self: start;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(21, 45, 75, 0.09);
}

.status {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.status-indicator {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border: 2px solid var(--action);
  border-radius: 50%;
  background: var(--surface);
}

.status[data-state="connected"] .status-indicator {
  background: var(--action);
  box-shadow: 0 0 0 4px rgba(36, 107, 206, 0.12);
}

.status[data-state="error"] {
  background: var(--danger-surface);
}

.status[data-state="error"] .status-indicator {
  border-color: var(--danger);
  background: var(--danger);
}

.status-title,
.status-detail,
.application-label,
.application-id,
.project-title,
.project-id,
.project-date,
.empty-state-title,
.empty-state-detail,
.room-section-title,
.room-section-detail,
.room-code,
.room-type,
.room-status-title,
.room-status-detail,
.wall-title,
.wall-detail,
.wall-code,
.wall-length,
.form-error {
  margin: 0;
}

.status-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.status[data-state="error"] .status-title {
  color: var(--danger);
}

.status-detail {
  max-width: 60ch;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.content {
  padding: 22px 18px 20px;
}

.application-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.application-id {
  margin-top: 7px;
  color: var(--shell-deep);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.project-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.project-id {
  margin-top: 5px;
  color: var(--shell-deep);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.project-date {
  max-width: 18ch;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

.project-date time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.project-details {
  margin: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.72fr) minmax(0, 1.7fr);
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.detail-row dt,
.detail-row dd {
  margin: 0;
}

.detail-row dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.detail-row dd {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.detail-row-comment dd {
  font-weight: 400;
  white-space: pre-wrap;
}

.empty-state {
  margin-top: 20px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-muted);
}

.empty-state-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.empty-state-detail {
  max-width: 60ch;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.room-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.room-empty {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-muted);
}

.room-section-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.room-section-detail {
  max-width: 60ch;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--action);
  color: #ffffff;
  background: var(--action);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--action-hover);
  background: var(--action-hover);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: var(--surface);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.field input:focus-visible,
.field select:focus-visible {
  outline: 3px solid rgba(93, 156, 255, 0.42);
  outline-offset: 2px;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.room-form-heading {
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field > span {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
  font-size: 16px;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-surface);
}

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

.form-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(104px, 0.8fr);
  gap: 10px;
  margin-top: 18px;
}

.form-actions .primary-button {
  margin-top: 0;
}

.room-summary {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.room-summary-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.room-code {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.35;
}

.room-type {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.room-status {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.room-status-marker {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--surface);
}

.room-status-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.room-status-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.wall-empty,
.wall-form,
.wall-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.wall-empty .primary-button {
  margin-top: 0;
}

.wall-form-heading {
  margin-bottom: 16px;
}

.wall-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.wall-detail {
  max-width: 60ch;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.length-field {
  position: relative;
  display: block;
}

.length-field input {
  padding-right: 48px;
  font-variant-numeric: tabular-nums;
}

.length-unit {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-50%);
}

.wall-diagram {
  margin: 16px 0 0;
}

.wall-diagram svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #ffffff;
}

.draft-layer {
  color: #111111;
  shape-rendering: geometricPrecision;
}

.draft-contour,
.draft-dimension,
.draft-extension {
  fill: none;
  stroke: currentColor;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.draft-contour {
  stroke-width: 3;
}

.draft-dimension,
.draft-extension {
  stroke-width: 1;
}

.draft-arrow {
  fill: #111111;
  stroke: none;
}

.draft-node {
  fill: currentColor;
  stroke: #ffffff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.draft-point-label-backdrop {
  fill: #ffffff;
  stroke: none;
}

.draft-outside-arrow[hidden] {
  display: none;
}

.draft-glyph {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  vector-effect: none;
}

.wall-diagram figcaption {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.wall-preview {
  padding-block: 2px;
}

.wall-summary-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.wall-code {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.35;
}

.wall-length {
  flex: 0 0 auto;
  color: var(--shell-deep);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.35;
}

.second-wall-empty,
.second-wall-form,
.second-wall-summary,
.third-wall-form,
.third-wall-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.turn-fieldset {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.turn-fieldset legend {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.turn-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.turn-option {
  position: relative;
  min-height: 46px;
}

.turn-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.turn-option span {
  display: grid;
  min-height: 46px;
  place-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.turn-option input:checked + span {
  border-color: var(--action);
  color: var(--action-hover);
  background: var(--surface-muted);
}

.turn-option input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--action) 42%, transparent);
  outline-offset: 2px;
}

.second-wall-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.third-wall-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.third-wall-summary h5 {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.third-wall-summary div > p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.second-wall-summary h5 {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.second-wall-summary div > p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.contour-completion,
.contour-complete-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.contour-completion > p:first-child,
.contour-complete-summary > p:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.contour-completion > .primary-button {
  width: 100%;
  margin-top: 12px;
}

.continuation-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.continuation-actions .secondary-button {
  min-height: 48px;
  padding-inline: 10px;
}

.complex-completion-action {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
}

.complex-completion-panel {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.complex-completion-panel h4 {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.complex-completion-panel > p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.complex-completion-panel .complex-completion-residual {
  color: var(--shell-deep);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.complex-completion-panel .form-actions {
  margin-top: 12px;
}

.contour-complete-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.contour-complete-summary > p:last-child {
  margin-top: 3px;
}

.draft-contour-preview {
  stroke-dasharray: 5 3;
}

.traverse-workspace {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.traverse-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.traverse-heading h5 {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.traverse-heading p {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.traverse-ledger {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border-block: 1px solid var(--line);
}

.traverse-ledger li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-block: 6px;
}

.traverse-ledger li + li {
  border-top: 1px solid var(--line);
}

.traverse-wall-name,
.traverse-wall-length {
  color: var(--shell-deep);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.traverse-wall-turn {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.continuation-form {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.continuation-form .primary-button {
  min-height: 48px;
}

.launch-reference {
  min-height: 56px;
}

[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  .topbar {
    padding-inline: 28px;
  }

  .workspace {
    padding-top: 36px;
  }

  .status,
  .content {
    padding-inline: 22px;
  }
}

@media (max-width: 380px) {
  .project-header {
    display: block;
  }

  .project-date {
    max-width: none;
    margin-top: 8px;
    text-align: left;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .turn-options {
    grid-template-columns: 1fr;
  }

  .continuation-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html:not([data-ready="true"]) .panel {
    opacity: 0.99;
  }
}

