:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f4ef;
  color: #202522;
  font-synthesis: none;
  --ink: #202522;
  --muted: #68706a;
  --line: #d9ddd8;
  --paper: #fff;
  --accent: #d7ff43;
  --accent-dark: #526500;
  --danger: #b23428;
  --shadow: 0 18px 50px rgb(31 40 34 / 9%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 12% 8%, rgb(215 255 67 / 12%), transparent 23rem), #f5f4ef;
}

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgb(96 118 0 / 30%);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0 4vw;
  border-bottom: 1px solid rgb(32 37 34 / 9%);
  background: rgb(245 244 239 / 88%);
  backdrop-filter: blur(16px);
}

.brand {
  width: max-content;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-decoration: none;
}

.brand span { font-weight: 450; }

.phase-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #555d57;
  font-size: 0.78rem;
  font-weight: 700;
}

.phase-label > span:first-child {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
}

.status-pill {
  justify-self: end;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: #e8eae7;
  color: #58605a;
  font-size: 0.72rem;
  font-weight: 750;
}

.status-pill[data-state="drawing"] { background: #fff4ce; color: #745c00; }
.status-pill[data-state="complete"],
.status-pill[data-state="confirmed"] { background: #e9f6bd; color: #465900; }

.topbar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.editor-unit-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preference-switch {
  display: flex;
  padding: 3px;
  border: 1px solid #d8dcd7;
  border-radius: 10px;
  background: rgb(255 255 255 / 74%);
}

.preference-switch button {
  min-width: 38px;
  min-height: 44px;
  padding: 0 0.55rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #687069;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
}

.preference-switch button.is-active {
  background: var(--ink);
  color: white;
}

.metric-unit-switch button { min-width: 34px; }

.measurement-setup {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: clamp(1.25rem, 5vw, 4rem);
}

.measurement-setup-card {
  width: min(820px, 100%);
  padding: clamp(1.4rem, 4vw, 3.4rem);
  border: 1px solid rgb(32 37 34 / 10%);
  border-radius: 26px;
  background: rgb(255 255 255 / 91%);
  box-shadow: var(--shadow);
}

.measurement-setup-card h1 { max-width: 680px; }
.measurement-setup-intro {
  max-width: 650px;
  margin: 0.85rem 0 1.7rem;
  color: var(--muted);
  line-height: 1.55;
}

.measurement-system-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.measurement-system-card {
  min-height: 142px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 0.55rem;
  padding: 1.35rem;
  border: 1px solid #d7dbd6;
  border-radius: 18px;
  background: #f9faf6;
  cursor: pointer;
  text-align: left;
}

.measurement-system-card:hover { border-color: #8a9871; }
.measurement-system-card.is-active {
  border-color: var(--ink);
  background: #eff6d2;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.measurement-system-name { font-size: 1.15rem; font-weight: 850; }
.measurement-system-example { color: var(--muted); font-size: 0.88rem; }

.setup-metric-units {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  background: #f2f3ed;
}
.setup-metric-units > p { margin: 0 0 0.7rem; color: var(--muted); font-size: 0.78rem; font-weight: 750; }
.setup-metric-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; }
.setup-metric-options button {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #d2d7d1;
  border-radius: 12px;
  background: white;
  cursor: pointer;
}
.setup-metric-options button.is-active { border-color: var(--ink); background: var(--ink); color: white; }
.setup-metric-options strong { font-size: 0.78rem; }
.setup-metric-options span { font-size: 0.75rem; opacity: 0.72; }
.measurement-setup-note { margin: 1rem 0 0; color: var(--muted); font-size: 0.76rem; }
.measurement-start { width: 100%; margin-top: 1rem; }

.editor-shell {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 2.4vw, 2.4rem) 4vw 3rem;
}

.guidance {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.35rem;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: #697169;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(1.75rem, 3.4vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.guidance p:last-child {
  max-width: 720px;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: clamp(0.92rem, 1.2vw, 1.05rem);
  line-height: 1.55;
}

.wall-counter {
  flex: none;
  padding-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 1rem;
  align-items: stretch;
}

.view-switch {
  width: max-content;
  display: flex;
  gap: 4px;
  margin: -0.35rem 0 1rem;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 78%);
}

.view-switch button {
  min-height: 44px;
  padding: 0 1.15rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 820;
}

.view-switch button.is-active { background: var(--ink); color: white; }

.canvas-card {
  position: relative;
  min-width: 0;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid rgb(32 37 34 / 10%);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.viewer-card {
  position: relative;
  min-width: 0;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid rgb(32 37 34 / 10%);
  border-radius: 22px;
  background: #eff0ea;
  box-shadow: var(--shadow);
}

.elevation-card {
  position: relative;
  min-width: 0;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid rgb(32 37 34 / 10%);
  border-radius: 22px;
  background: #f0f1eb;
  box-shadow: var(--shadow);
}

.elevation-header {
  position: absolute;
  z-index: 2;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: none;
}

.elevation-header > * { pointer-events: auto; }
.elevation-header h2 { margin: 0.15rem 0 0; font-size: 1.25rem; }

#wall-elevation {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 590px;
  padding: 5.8rem 2.2rem 3.2rem;
}

.elevation-wall { fill: #dfe2d8; stroke: #5f675f; stroke-width: 18; vector-effect: non-scaling-stroke; }
.elevation-floor { stroke: #303632; stroke-width: 4; vector-effect: non-scaling-stroke; }
.elevation-opening { fill: #f7f8f3; stroke: #687459; stroke-width: 7; vector-effect: non-scaling-stroke; cursor: pointer; }
.elevation-opening.is-door { fill: #ecefdf; }
.elevation-opening.is-draft { fill: rgb(215 255 67 / 42%); stroke-dasharray: 18 12; }
.elevation-opening.is-selected { stroke: #526500; stroke-width: 10; }
.elevation-dimension { fill: #454c47; font-size: 115px; font-weight: 800; }
.elevation-legend { position: absolute; left: 1rem; right: 1rem; bottom: 0.8rem; display: flex; justify-content: space-between; color: var(--muted); font-size: 0.68rem; font-weight: 750; }

#room-viewer {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 590px;
  touch-action: none;
  cursor: grab;
}

#room-viewer:active { cursor: grabbing; }

.viewer-toolbar {
  position: absolute;
  z-index: 3;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 8px 24px rgb(31 40 34 / 8%);
}

.wall-mode-switch {
  position: absolute;
  z-index: 3;
  top: 4.8rem;
  left: 1rem;
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 8px 24px rgb(31 40 34 / 8%);
}

.viewer-back-2d {
  position: absolute;
  z-index: 4;
  top: 1rem;
  left: 1rem;
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-size: 0.76rem;
  font-weight: 820;
  cursor: pointer;
  box-shadow: 0 8px 24px rgb(31 40 34 / 14%);
}

.viewer-back-2d:hover { background: #343b37; }

.wall-mode-switch button {
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
  cursor: pointer;
}

.wall-mode-switch button.is-active {
  background: var(--ink);
  color: white;
}

.viewer-hint {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0.6rem 0.85rem;
  border-radius: 999px;
  background: rgb(32 37 34 / 82%);
  color: white;
  font-size: 0.69rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.asset-status {
  position: absolute;
  z-index: 3;
  left: 1rem;
  bottom: 1rem;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgb(32 37 34 / 12%);
  border-radius: 10px;
  background: rgb(255 255 255 / 88%);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
  pointer-events: none;
}

.asset-status[data-fallback="true"] { color: #9a3d16; }

.wall-body.is-opening-target {
  fill: rgb(215 255 67 / 58%);
  stroke: #6d8500;
  stroke-width: 2.5;
}

.opening-gap { stroke: white; stroke-width: 13; stroke-linecap: butt; pointer-events: none; }
.opening-symbol { stroke: #6d8500; stroke-width: 4; stroke-linecap: butt; pointer-events: none; }
.opening-symbol.is-door { stroke: #875f2d; }
.opening-hit-target {
  stroke: rgb(0 0 0 / 0.001);
  stroke-width: 24;
  cursor: pointer;
  pointer-events: stroke;
  touch-action: manipulation;
}

.opening-library-card,
.opening-form-card {
  padding: 1.05rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgb(31 40 34 / 6%);
}

.opening-library-card h2,
.opening-form-card h2 { margin: 0.25rem 0 0.45rem; font-size: 1.2rem; }
.opening-library-card > p:not(.eyebrow),
.opening-form-card > p:not(.eyebrow) { margin: 0 0 0.9rem; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }

.opening-categories { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; margin-bottom: 0.65rem; }
.opening-categories button,
.opening-subtypes button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f8f4;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 760;
  cursor: grab;
}
.opening-categories button { display: flex; align-items: center; justify-content: center; gap: 0.4rem; }
.opening-categories button.is-active,
.opening-subtypes button.is-active { border-color: var(--ink); background: var(--ink); color: white; }
.opening-subtypes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.opening-subtypes button { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 0.35rem; padding: 0.5rem; text-align: left; }
.opening-type-symbol { font-size: 1.25rem; text-align: center; }
.opening-placement-hint { margin: 0.7rem 0 0 !important; padding: 0.65rem; border-radius: 11px; background: #f0f3df; color: #506000 !important; font-weight: 700; }

.opening-form-card form { display: grid; gap: 0.65rem; }
.opening-form-card label { color: #525a54; font-size: 0.7rem; font-weight: 760; }
.opening-form-card select { width: 100%; min-height: 44px; padding: 0.55rem; border: 1px solid var(--line); border-radius: 10px; background: white; }
.opening-measure-group { display: grid; gap: 0.3rem; }
.danger-button { min-height: 44px; border: 1px solid rgb(178 52 40 / 28%); border-radius: 12px; background: #fff3f1; color: var(--danger); font-weight: 780; cursor: pointer; }
.compact-button { width: auto; min-height: 44px; padding: 0.55rem 0.75rem; }
.start-openings { width: 100%; margin-top: 0.6rem; }

.workspace-grid[data-opening-stage="active"] .help-card,
.workspace-grid[data-opening-stage="active"] .thickness-card,
.workspace-grid[data-opening-stage="active"] .height-card,
.workspace-grid[data-opening-stage="active"] .edit-card,
.workspace-grid[data-opening-stage="active"] .shape-actions { display: none; }

.workspace-grid[data-view="elevation"] .opening-library-card { display: none; }
.workspace-grid[data-view="3d"] .opening-library-card,
.workspace-grid[data-view="3d"] .opening-form-card { display: none; }

.canvas-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

#room-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: #fff;
}

.canvas-toolbar {
  position: absolute;
  z-index: 3;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 24px rgb(31 40 34 / 8%);
}

.icon-button,
.fit-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-weight: 760;
}

.icon-button { font-size: 1.25rem; }
.fit-button { padding: 0 0.8rem; font-size: 0.78rem; }
.icon-button:hover, .fit-button:hover { background: #f0f2ef; }

.empty-prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  width: min(340px, calc(100% - 3rem));
  transform: translate(-50%, -50%);
  pointer-events: none;
  text-align: center;
}

.empty-prompt strong { font-size: clamp(1.05rem, 2vw, 1.3rem); }
.empty-prompt > span:last-child { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }

.start-dot {
  width: 15px;
  height: 15px;
  margin-bottom: 0.5rem;
  border: 4px solid white;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 10px rgb(215 255 67 / 35%);
}

.room-wall {
  stroke: #202522;
  stroke-width: 5;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.room-wall.is-selected { stroke: #6f8505; stroke-width: 7; }

.wall-body {
  fill: #e3ebc5;
  stroke: none;
}

.wall-body.has-override { fill: #cbdc89; }

.corner-join { fill: #e3ebc5; stroke: none; }

.outer-boundary {
  fill: none;
  stroke: #87936d;
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.wall-hit-target {
  stroke: rgb(0 0 0 / 0.001);
  stroke-width: 24;
  cursor: pointer;
  pointer-events: stroke;
  touch-action: manipulation;
  vector-effect: non-scaling-stroke;
}

.preview-wall {
  stroke: #7c867f;
  stroke-width: 3;
  stroke-dasharray: 8 8;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.room-point {
  fill: white;
  stroke: #202522;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.start-point.can-close {
  fill: var(--accent);
  stroke: var(--accent-dark);
  animation: close-pulse 1.2s ease-out infinite;
}

@keyframes close-pulse { 50% { r: 10px; } }

.wall-length-label {
  paint-order: stroke;
  stroke: white;
  stroke-width: 7px;
  stroke-linejoin: round;
  fill: #59615b;
  font-size: 13px;
  font-weight: 750;
  pointer-events: none;
}

.alignment-guide {
  stroke: #9cb03f;
  stroke-width: 1;
  stroke-dasharray: 4 7;
  opacity: 0.45;
  vector-effect: non-scaling-stroke;
}

.close-hint {
  position: absolute;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.78rem;
  font-weight: 750;
  pointer-events: none;
}

.notice {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 1rem;
  max-width: min(430px, calc(100% - 9rem));
  transform: translateX(-50%);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  box-shadow: 0 10px 30px rgb(31 40 34 / 20%);
  font-size: 0.8rem;
  text-align: center;
}

.notice[data-tone="success"] { background: #4f6400; }
.notice[data-tone="error"] { background: var(--danger); }

.side-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.help-card,
.edit-card,
.thickness-card,
.height-card,
.shape-actions {
  border: 1px solid rgb(32 37 34 / 10%);
  border-radius: 16px;
  background: rgb(255 255 255 / 76%);
}

.help-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  padding: 1rem;
}

.help-number {
  color: #788176;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.help-card strong { font-size: 0.88rem; }
.help-card p { margin: 0.28rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }

.edit-card { padding: 1.1rem; }
.edit-card h2, .measure-dialog h2, .thickness-card h2, .height-card h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.02em; }
.edit-card form { margin-top: 1rem; }
.edit-thickness-form { padding-top: 1rem; border-top: 1px solid #dfe2de; }
.edit-thickness-form .secondary-button { width: 100%; }
label { display: block; margin-bottom: 0.4rem; color: #4f5751; font-size: 0.75rem; font-weight: 750; }

.measure-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid #cdd2ce;
  border-radius: 10px;
  background: white;
}

.measure-field:focus-within { border-color: #687d07; box-shadow: 0 0 0 3px rgb(111 133 5 / 12%); }
.measure-field input { min-width: 0; padding: 0.75rem; border: 0; outline: 0; background: transparent; font-weight: 750; }
.measure-field span { padding: 0 0.8rem; color: #727a74; font-size: 0.75rem; font-weight: 700; }
.measure-field.is-large input { padding: 0.9rem 1rem; font-size: 1.35rem; }

.imperial-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.imperial-grid label { margin: 0; }
.imperial-grid input,
.imperial-grid select,
.thickness-imperial-input > .imperial-grid > input,
.thickness-imperial-input > .imperial-grid > select {
  width: 100%;
  min-height: 46px;
  margin-top: 0.35rem;
  padding: 0.65rem;
  border: 1px solid #cdd2ce;
  border-radius: 9px;
  background: white;
  color: var(--ink);
  font-weight: 700;
}

.thickness-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.dialog-imperial-grid input,
.dialog-imperial-grid select { font-size: 1rem; }

.field-error { min-height: 1.2em; margin: 0.45rem 0; color: var(--danger); font-size: 0.72rem; line-height: 1.35; }

.shape-actions {
  margin-top: auto;
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
}

.thickness-card { padding: 1.1rem; }
.height-card { padding: 1.1rem; }
.height-card > p:not(.eyebrow, .field-error),
.height-summary { margin: 0.45rem 0 1rem; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.height-card form { margin-top: 1rem; }
.height-card form > .secondary-button,
.view-3d-primary { width: 100%; margin-top: 0.6rem; }
.height-summary { padding: 0.65rem 0; border-top: 1px solid #dfe2de; font-weight: 750; }
.thickness-card h2 + p,
.thickness-card #thickness-summary,
.temporary-note,
.single-wall-hint {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.choice-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 1rem; }
.thickness-card form > .primary-button,
#configure-single-walls { width: 100%; margin-top: 0.35rem; }
.temporary-note { padding: 0.7rem; border-radius: 9px; background: #fff4ce; color: #6f5900; }
.single-wall-hint { padding-left: 0.7rem; border-left: 3px solid #a9bf45; }

.primary-button,
.secondary-button,
.text-button {
  min-height: 46px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; }
.primary-button:hover { background: #343b37; }
.secondary-button { border: 1px solid #cdd2ce; background: white; }
.text-button { border: 0; background: transparent; color: #616a63; }
button:disabled { cursor: not-allowed; opacity: 0.4; }
.edit-card .primary-button { width: 100%; }

.measure-dialog {
  width: min(460px, calc(100% - 2rem));
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 30px 90px rgb(19 25 21 / 28%);
}

.measure-dialog::backdrop { background: rgb(25 31 27 / 36%); backdrop-filter: blur(3px); }
.measure-dialog form { padding: clamp(1.25rem, 4vw, 2rem); }
.measure-dialog form > p:not(.eyebrow, .field-error) { margin: 0.55rem 0 1.35rem; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 0.6rem; margin-top: 0.85rem; }

.workspace-grid[data-view="3d"] .help-card,
.workspace-grid[data-view="3d"] .thickness-card,
.workspace-grid[data-view="3d"] .edit-card,
.workspace-grid[data-view="3d"] .shape-actions { display: none; }

@media (max-width: 1400px) {
  .topbar { grid-template-columns: auto 1fr; }
  .phase-label { display: none; }
}

@media (max-width: 920px) {
  .topbar { grid-template-columns: auto 1fr; }
  .phase-label { display: none; }
  .workspace-grid { grid-template-columns: 1fr; }
  .canvas-card { min-height: 58vh; }
  .viewer-card, #room-viewer, .elevation-card, #wall-elevation { min-height: 62vh; }
  .side-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .shape-actions { grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); }
  .edit-card, .thickness-card, .height-card { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .topbar { min-height: 138px; grid-template-columns: 1fr; align-content: center; gap: 0.45rem; padding: 0.6rem 0.8rem; }
  .topbar-actions { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 0.4rem; }
  .editor-unit-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: space-between;
    min-width: 0;
  }
  .preference-switch button { min-width: 44px; }
  .unit-switch { justify-self: end; }
  .metric-unit-switch button { min-width: 38px; padding-inline: 0.35rem; }
  .status-pill { grid-column: 2; grid-row: 1; justify-self: stretch; padding: 0.38rem; font-size: 0.64rem; text-align: center; }
  .editor-shell { padding: 1.15rem 0.75rem 1.5rem; }
  .measurement-setup { min-height: calc(100vh - 138px); padding: 0.9rem 0.75rem 1.5rem; place-items: start center; }
  .measurement-setup-card { padding: 1.25rem; border-radius: 18px; }
  .measurement-setup-card h1 { font-size: clamp(1.85rem, 10vw, 2.55rem); }
  .measurement-setup-intro { margin-bottom: 1.15rem; font-size: 0.88rem; }
  .measurement-system-options { grid-template-columns: 1fr; gap: 0.55rem; }
  .measurement-system-card { min-height: 96px; padding: 1rem; }
  .setup-metric-options { grid-template-columns: 1fr; }
  .setup-metric-options button { min-height: 54px; }
  .guidance { display: block; margin-bottom: 0.9rem; }
  .guidance h1 { font-size: clamp(1.7rem, 9vw, 2.35rem); }
  .guidance p:last-child { font-size: 0.88rem; }
  .wall-counter { margin-top: 0.55rem; }
  .canvas-card { min-height: 55vh; border-radius: 16px; }
  .viewer-card { min-height: 54vh; border-radius: 16px; }
  .elevation-card { min-height: 54vh; border-radius: 16px; }
  #room-viewer { min-height: 54vh; }
  #wall-elevation { min-height: 54vh; padding: 8.2rem 1rem 3rem; }
  .elevation-header { top: 0.7rem; left: 0.7rem; right: 0.7rem; display: grid; }
  .elevation-header .compact-button { width: 100%; }
  .elevation-legend { font-size: 0.6rem; }
  .opening-library-card, .opening-form-card { border-radius: 16px; }
  .opening-subtypes { grid-template-columns: 1fr; }
  .viewer-toolbar { top: 0.65rem; right: 0.65rem; }
  .viewer-back-2d { top: 0.65rem; left: 0.65rem; }
  .wall-mode-switch {
    top: 4.5rem;
    right: 0.65rem;
    left: 0.65rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .wall-mode-switch button { padding-inline: 0.45rem; }
  .viewer-hint { bottom: 0.65rem; border-radius: 12px; font-size: 0.64rem; }
  .asset-status { left: 0.65rem; bottom: 4rem; }
  .view-switch { width: 100%; margin-top: -0.15rem; }
  .view-switch button { flex: 1; }
  .canvas-toolbar { top: 0.65rem; right: 0.65rem; }
  .icon-button, .fit-button { min-width: 44px; min-height: 44px; }
  .side-panel { display: flex; }
  .help-card { display: none; }
  .shape-actions { order: -1; grid-template-columns: 1fr 1fr; }
  .shape-actions .primary-button { grid-column: 1 / -1; grid-row: 1; }
  .notice { top: 4.1rem; max-width: calc(100% - 1.3rem); }
  .dialog-actions { grid-template-columns: 1fr; }
  .dialog-actions .primary-button { grid-row: 1; }
  .imperial-grid { grid-template-columns: 1fr 1fr; }
  .imperial-grid label:last-child { grid-column: 1 / -1; }
  .dialog-imperial-grid { grid-template-columns: repeat(3, 1fr); }
  .dialog-imperial-grid label:last-child { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; }
}
