:root {
  color-scheme: light;
  --bg: #eef2f2;
  --surface: #ffffff;
  --surface-soft: #f6f7f7;
  --surface-strong: #e8eded;
  --text: #202426;
  --muted: #687075;
  --line: #d8dddd;
  --line-strong: #bfc7c8;
  --brand: #7a2330;
  --brand-dark: #57151f;
  --accent: #d55b32;
  --accent-dark: #9f3f20;
  --role-center: #b85d40;
  --role-border: #3b8584;
  --role-corner: #c99a35;
  --role-border-outer: #526b96;
  --role-corner-outer: #9e5570;
  --role-plain: #c8baa6;
  --piece-full: #55958d;
  --piece-cut: #d97042;
  --success: #2f7a4d;
  --danger: #ad3138;
  --shadow: 0 8px 24px rgba(28, 38, 40, .09);
  --radius: 5px;
  --header-height: 54px;
  --status-height: 34px;
  --site-nav-height: 31px;
  --strip-height: 22px;
  --planner-page-texture: url("../assets/background-page-light.webp");
  --planner-surface-texture: url("../assets/background-surface-light.webp");
  --planner-mosaic-strip-image: url("../assets/strip-mosaicos-linea.jpg");
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0b111b;
  --surface: #121a26;
  --surface-soft: #172131;
  --surface-strong: #202c3d;
  --text: #edf2f8;
  --muted: #a9b2bd;
  --line: #2a3544;
  --line-strong: #435066;
  --brand: #d78a4d;
  --brand-dark: #ba6c32;
  --accent: #f08a32;
  --success: #68b984;
  --planner-page-texture: url("../assets/background-page-dark-crisp.webp");
  --planner-surface-texture: url("../assets/background-surface-dark-crisp.webp");
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; }

html { background-color: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--bg);
  background-image: var(--page-gradient), var(--planner-page-texture);
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, 170px 170px;
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

.site-frame {
  width: min(96vw, 1680px);
  height: auto;
  margin: 10px auto 0;
  display: grid;
  grid-template-rows: auto var(--strip-height) auto auto auto var(--status-height);
  overflow: hidden;
  border: 1px solid #e5d8c7;
  border-radius: 5px 5px 0 0;
  background-color: var(--card);
  background-image: var(--surface-gradient), var(--planner-surface-texture);
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, 160px 160px;
  box-shadow: 0 10px 30px rgba(124, 84, 36, .1);
}

.site-frame.has-floating-header {
  grid-template-rows: var(--strip-height) auto auto var(--status-height);
  padding-top: var(--floating-header-height, 0px);
}

.site-frame.has-floating-header:has(> .site-breadcrumbs) {
  grid-template-rows: var(--strip-height) auto auto auto var(--status-height);
}

button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

input:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

[hidden] { display: none !important; }

.app-header {
  height: var(--header-height);
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  z-index: 20;
}

.draft-recovery-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(8, 15, 20, .28);
}
.draft-recovery-dialog::backdrop { background: rgba(8, 15, 20, .58); backdrop-filter: blur(4px); }
.draft-recovery-dialog[open] { display: grid; grid-template-columns: 58px 1fr; gap: 18px; padding: 26px; }
.draft-recovery-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--brand); }
.draft-recovery-mark svg { width: 28px; height: 28px; }
.dialog-eyebrow { display: block; margin-bottom: 7px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.draft-recovery-dialog h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.draft-recovery-dialog p { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.draft-recovery-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; margin-top: 3px; }

.planner-professional-note { display: grid; grid-template-columns: 28px 1fr; gap: 10px; margin: 14px 16px; padding: 12px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); color: var(--muted); }
.planner-professional-note svg { width: 22px; height: 22px; color: var(--accent); }
.planner-professional-note p { margin: 0; font-size: 10px; line-height: 1.5; }
.planner-professional-note strong { color: var(--text); }

.top { font-family: Arial, Helvetica, sans-serif; }

.site-header { position: relative; z-index: 20; background: var(--surface); }

.site-nav {
  height: var(--site-nav-height);
  display: flex;
  align-items: center;
  gap: 23px;
  padding: 0 24px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: rgba(255, 255, 255, .92);
  font-size: 11px;
  font-weight: 700;
}
.site-nav a { color: var(--text); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }

.mosaic-strip {
  height: var(--strip-height);
  min-height: var(--strip-height);
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
  background-image: var(--planner-mosaic-strip-image), repeating-linear-gradient(90deg,#2b5a7f 0 22px,#e9d4b4 22px 44px,#872f2d 44px 66px,#f3f1e8 66px 88px,#3f8b8a 88px 110px,#d77855 110px 132px,#1d2d45 132px 154px,#dbb2a6 154px 176px);
  background-repeat: repeat-x, repeat;
  background-position: center;
  background-size: auto 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  height: 44px;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 215px;
  max-height: 42px;
  object-fit: contain;
  object-position: left center;
}

.product-title {
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 1px;
  white-space: nowrap;
}
.product-name { min-width: 0; margin: 0; display: inline-flex; align-items: center; gap: 6px; font-size: inherit; }
.product-title strong { color: var(--brand); font-size: 15px; line-height: 1.1; }
.product-name > b {
  min-width: 30px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--brand);
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0;
}
.product-title small { color: var(--muted); font-size: 10px; font-weight: 600; }

.project-name input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 12px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
}

.project-name { position: relative; }
.project-name::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 11px;
  width: 11px;
  height: 11px;
  border-right: 2px solid var(--muted);
  transform: rotate(45deg);
}

.header-actions {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.header-text-button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}
.header-text-button:hover { border-color: var(--brand); color: var(--brand); }
.header-text-button svg { width: 17px; height: 17px; }
.header-text-button b {
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--surface-strong);
  font-size: 9px;
}
.export-icon-button { color: var(--brand); }

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.save-status svg { width: 17px; height: 17px; color: var(--success); }
.save-status.is-saving svg { color: var(--accent); }
.save-status[data-state="dirty"] { color: var(--brand); }
.save-status[data-state="dirty"] svg { color: var(--accent); }
.save-status[data-state="error"] { color: var(--danger); }
.save-status[data-state="error"] svg { color: var(--danger); }

#saveProjectBtn { position: relative; }
#saveProjectBtn.has-unsaved-changes::after {
  content: "";
  width: 7px;
  height: 7px;
  position: absolute;
  top: 4px;
  right: 4px;
  border: 1px solid var(--brand);
  border-radius: 50%;
  background: var(--accent);
}

.primary-button,
.secondary-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover { background: var(--brand-dark); }

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

.mobile-steps { display: none; }

.app-shell {
  height: max(520px, calc(100dvh - 246px));
  display: grid;
  grid-template-columns: 304px minmax(500px, 1fr) 296px;
  min-height: 0;
}

.setup-panel,
.results-panel {
  min-height: 0;
  background: var(--surface);
  position: relative;
  z-index: 5;
}

.setup-panel {
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.setup-tabs {
  height: 48px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.setup-tabs button {
  position: relative;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}
.setup-tabs button svg { width: 15px; height: 15px; }

.setup-tabs button::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 2px;
  background: transparent;
}

.setup-tabs button.is-active { color: var(--brand); }
.setup-tabs button.is-active::after { background: var(--brand); }

.setup-section {
  height: calc(100% - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  scrollbar-width: thin;
}

.setup-section h2,
.results-panel h2,
.results-panel h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.25;
}

.setup-section h2:not(:first-child) { margin-top: 19px; }

.shape-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 11px;
}

.shape-button {
  min-width: 0;
  min-height: 80px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 8px 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.shape-button > span:last-child { width: 100%; min-width: 0; line-height: 1.15; white-space: nowrap; }

.shape-button.is-active,
.shape-button:hover {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent);
}

.shape-preview {
  width: 32px;
  height: 27px;
  display: block;
  border: 2px solid currentColor;
}

.shape-rectangle { width: 36px; height: 30px; border: 0; }
.shape-rectangle svg { width: 100%; height: 100%; overflow: visible; }
.shape-rectangle rect { fill: color-mix(in srgb, currentColor 7%, transparent); stroke: currentColor; stroke-width: 2; }

.shape-l {
  width: 36px;
  height: 30px;
  border: 0;
}
.shape-l svg { width: 100%; height: 100%; overflow: visible; }
.shape-l path { fill: color-mix(in srgb, currentColor 10%, transparent); stroke: currentColor; stroke-width: 2; stroke-linejoin: miter; }
.shape-u { width: 36px; height: 30px; border: 0; }
.shape-u svg { width: 100%; height: 100%; overflow: visible; }
.shape-u path { fill: color-mix(in srgb, currentColor 10%, transparent); stroke: currentColor; stroke-width: 2; stroke-linejoin: miter; }
.shape-custom { border: 0; }
.shape-custom svg { width: 36px; height: 30px; overflow: visible; }
.shape-custom path { fill: color-mix(in srgb, currentColor 8%, transparent); stroke: currentColor; stroke-width: 2; }
.shape-custom circle { fill: var(--surface); stroke: currentColor; stroke-width: 1.4; }

.vertex-editor-control { margin-top: 10px; }
.option-action-button {
  width: 100%;
  min-height: 50px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: left;
}
.option-action-button svg { grid-row: 1 / 3; width: 20px; height: 20px; color: var(--brand); }
.option-action-button > span { min-width: 0; display: grid; gap: 2px; }
.option-action-button strong { color: var(--text); font-size: 12px; font-weight: 700; }
.option-action-button small { color: var(--muted); font-size: 10px; font-weight: 500; }
.option-action-button:hover,
.option-action-button.is-active { border-color: var(--brand); background: var(--surface); }
.vertex-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  margin-top: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.vertex-actions[hidden] { display: none; }
.vertex-actions button {
  min-width: 0;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
}
.vertex-actions button svg { width: 14px; height: 14px; }
.vertex-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--brand); }
.vertex-actions-heading { display: flex; align-items: center; min-height: 24px; }
.vertex-actions-heading > span { color: var(--muted); font-size: 10px; white-space: nowrap; }
.vertex-mode-switch { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.vertex-mode-switch button { min-height: 30px; padding: 0 8px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--muted); }
.vertex-mode-switch button:last-child { border-right: 0; }
.vertex-mode-switch button.is-active { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); color: var(--brand); box-shadow: inset 0 -2px var(--accent); }
.vertex-move-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.vertex-move-actions[hidden] { display: none; }
.vertex-move-actions button.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); color: var(--brand); }
.wall-measure-empty { min-height: 64px; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 9px; padding: 10px; border: 1px dashed color-mix(in srgb, var(--brand) 34%, var(--line)); border-radius: var(--radius); background: color-mix(in srgb, var(--brand) 4%, var(--surface)); }
.wall-measure-empty[hidden], .wall-measure-editor[hidden], .wall-split-editor[hidden] { display: none; }
.wall-measure-empty > svg { width: 22px; height: 22px; color: var(--brand); }
.wall-measure-empty > span { min-width: 0; display: grid; gap: 2px; }
.wall-measure-empty strong { color: var(--text); font-size: 11px; }
.wall-measure-empty small { color: var(--muted); font-size: 9px; }
.wall-measure-editor { display: grid; gap: 9px; padding: 10px; border: 1px solid color-mix(in srgb, var(--brand) 34%, var(--line)); border-radius: var(--radius); background: var(--surface); box-shadow: inset 3px 0 var(--brand); }
.wall-measure-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wall-measure-heading > span { min-width: 0; display: grid; gap: 2px; }
.wall-measure-heading strong { color: var(--text); font-size: 12px; }
.wall-measure-heading small { color: var(--muted); font-size: 9px; }
.wall-measure-heading > b { color: var(--brand); font-size: 12px; white-space: nowrap; }
.wall-length-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; color: var(--muted); font-size: 10px; font-weight: 700; }
.wall-length-field .input-unit { height: 34px; }
.wall-anchor-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.wall-anchor-field legend { margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.wall-anchor-field > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.wall-anchor-field button { min-height: 31px; border: 0; border-right: 1px solid var(--line); border-radius: 0; color: var(--muted); }
.wall-anchor-field button:last-child { border-right: 0; }
.wall-anchor-field button i { width: 20px; height: 8px; position: relative; border-top: 2px solid currentColor; }
.wall-anchor-field button i::before, .wall-anchor-field button i::after { content: ""; width: 4px; height: 8px; position: absolute; top: -5px; border: 2px solid currentColor; border-radius: 50%; background: var(--surface); }
.wall-anchor-field button i::before { left: -2px; }
.wall-anchor-field button i::after { right: -2px; }
.wall-anchor-field button.is-active[data-wall-anchor="start"] i::before,
.wall-anchor-field button.is-active[data-wall-anchor="end"] i::after { background: var(--accent); }
.wall-anchor-field button.is-active { background: color-mix(in srgb, var(--brand) 8%, var(--surface)); color: var(--brand); }
.wall-measure-actions { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 7px; }
.vertex-actions button.is-primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.vertex-actions button.is-primary:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 88%, #000); color: #fff; }
.wall-measure-error { margin: 0; padding: 7px 8px; border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); color: var(--danger); font-size: 9px; line-height: 1.35; }
.wall-measure-error[hidden] { display: none; }
.wall-split-editor { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.wall-split-editor label { display: grid; grid-template-columns: minmax(0, 1fr) 112px; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; font-weight: 700; }
.wall-split-editor .input-unit { height: 32px; }
.wall-split-editor > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.vertex-actions .vertex-ortho-button { display: grid; grid-template-columns: 18px auto 1fr; justify-content: start; text-align: left; }
.vertex-actions .vertex-ortho-button svg { width: 15px; height: 15px; }
.vertex-actions .vertex-ortho-button small { justify-self: end; color: var(--muted); font-size: 9px; font-weight: 500; }
.vertex-actions .vertex-ortho-button.is-active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); color: var(--brand); }
.vertex-actions #finishVerticesBtn { border-color: var(--brand); color: var(--brand); }

.field-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.field-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.field > input,
.input-unit {
  height: 38px;
}

.field > input { width: 100%; padding: 0 10px; }

.input-unit {
  min-width: 0;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  overflow: hidden;
}

.input-unit:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent);
}

.input-unit input {
  width: 100%;
  height: 100%;
  padding: 0 8px;
  border: 0;
  background: transparent;
  font-weight: 700;
}

.input-unit b {
  padding: 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

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

.preset-list button {
  min-width: 0;
  min-height: 54px;
  padding: 9px 10px;
  display: grid;
  gap: 3px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.preset-list button:hover { border-color: var(--accent); background: var(--surface); }
.preset-list strong { font-size: 12px; }
.preset-list span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.tile-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}

.tile-preset {
  min-height: 82px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 42px auto;
  align-items: end;
  gap: 0 3px;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}

.tile-preset i {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  width: calc(36px * var(--tile-w));
  height: calc(36px * var(--tile-h));
  min-width: 18px;
  min-height: 18px;
  display: block;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, #6c2e1b);
  background: #b95838;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.tile-preset span { text-align: right; }
.tile-preset small { color: var(--muted); font-weight: 500; }
.tile-preset.is-active,
.tile-preset:hover { border-color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 20%, transparent); }

.tile-dimensions {
  grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr);
  align-items: end;
}
.inline-icon { width: 36px; height: 38px; }

.range-field {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  color: var(--text);
  font-size: 12px;
}
.range-field > span { display: flex; justify-content: space-between; align-items: center; }
.range-field output { color: var(--muted); }

input[type="range"] {
  width: 100%;
  height: 4px;
  padding: 0;
  border: 0;
  border-radius: 0;
  accent-color: var(--brand);
}

.assignment-card {
  margin-top: 11px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.assignment-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.assignment-heading > span { min-width: 0; display: grid; gap: 2px; }
.assignment-heading strong { font-size: 12px; }
.assignment-heading small { color: var(--muted); font-size: 9px; }
.switch-control { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 700; cursor: pointer; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch-control > span {
  width: 32px;
  height: 18px;
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-strong);
}
.switch-control > span::after {
  content: "";
  width: 12px;
  height: 12px;
  position: absolute;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(34, 29, 25, .25);
  transition: transform .16s ease;
}
.switch-control input:checked + span { border-color: var(--brand); background: var(--brand); }
.switch-control input:checked + span::after { transform: translateX(14px); }
.switch-control input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.role-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.role-options button {
  min-width: 0;
  min-height: 52px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 5px 2px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}
.role-options button i,
[data-role-swatch] { width: 19px; height: 19px; display: block; border: 1px solid rgba(46, 42, 38, .34); }
.role-options [data-tile-role="center"] i, [data-role-swatch="center"] { background: var(--role-center); }
.role-options [data-tile-role="border"] i, [data-role-swatch="border"] { background: var(--role-border); }
.role-options [data-tile-role="corner"] i, [data-role-swatch="corner"] { background: var(--role-corner); }
.role-options [data-tile-role="borderOuter"] i, [data-role-swatch="borderOuter"] { background: var(--role-border-outer); }
.role-options [data-tile-role="cornerOuter"] i, [data-role-swatch="cornerOuter"] { background: var(--role-corner-outer); }
.role-options [data-tile-role="plain"] i, [data-role-swatch="plain"] { background: var(--role-plain); }
.role-options button > span { min-width: 0; display: grid; gap: 1px; line-height: 1.05; }
.role-options button small { color: inherit; font-size: 7px; font-weight: 600; }
.role-options button:hover,
.role-options button.is-active { border-color: var(--brand); color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent); }
.role-options button.is-selected:not(.is-active) { border-color: var(--line-strong); color: var(--text); background: color-mix(in srgb, var(--brand) 3%, var(--surface)); }
.assignment-footer { min-height: 22px; display: flex; align-items: end; justify-content: space-between; gap: 8px; padding-top: 7px; color: var(--muted); font-size: 9px; }

.origin-heading { align-items: center; gap: 8px; }
.origin-heading-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 5px; }
.origin-heading-actions .text-button { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.origin-heading-actions svg { width: 13px; height: 13px; }
.origin-heading #resetOriginBtn { width: 27px; height: 27px; justify-content: center; padding: 0; }
.origin-heading #resetOriginBtn span { display: none; }

.material-assignment { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.material-assignment-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.material-assignment-heading > span:first-child { display: grid; gap: 2px; }
.material-assignment-heading strong { font-size: 12px; }
.material-assignment-heading small { color: var(--muted); font-size: 9px; line-height: 1.35; }
.catalog-status { flex: 0 0 auto; padding: 3px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.catalog-status.is-ready { border-color: color-mix(in srgb, var(--success) 40%, var(--line)); color: var(--success); }
.catalog-status.is-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.material-slots { display: grid; gap: 5px; }
.material-role-entry { display: grid; gap: 5px; }
.material-slot-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 5px; }
.material-slot-row > [data-material-role] { width: 100%; min-height: 52px; display: grid; grid-template-columns: 42px minmax(0, 1fr) 14px; align-items: center; gap: 9px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; }
.material-slot-row > [data-material-role]:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.material-slot-row > [data-material-role].is-incompatible { border-color: color-mix(in srgb, var(--danger) 38%, var(--line)); }
.material-slot-row > [data-material-role] > span:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.material-add-variant { min-width: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); color: var(--brand); }
.material-add-variant:hover:not(:disabled) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
.material-add-variant svg { width: 15px; height: 15px; }
.material-slots strong { font-size: 10px; }
.material-slots small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.material-slot-preview { width: 40px; height: 40px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line-strong); background: var(--surface-soft); }
.material-slot-preview.is-pair { grid-template-columns: 1fr 1fr; }
.material-slot-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.material-slot-preview svg { width: 17px; height: 17px; color: var(--muted); }
.material-slot-chevron { width: 13px; height: 13px; color: var(--muted); }
.material-variant-strip { display: flex; gap: 4px; padding: 1px 0 2px; overflow-x: auto; scrollbar-width: thin; }
.material-variant-strip[hidden], .center-pattern-mini[hidden] { display: none; }
.material-variant-chip { flex: 0 0 auto; display: grid; grid-template-columns: 28px 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-soft); }
.material-variant-chip.is-active { border-color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 30%, transparent); }
.material-variant-select { position: relative; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; background: var(--surface); }
.material-variant-select img { width: 100%; height: 100%; object-fit: cover; }
.material-variant-select b { position: absolute; left: 1px; bottom: 1px; min-width: 12px; height: 12px; display: grid; place-items: center; padding: 0 2px; border-radius: 2px; background: rgba(17, 24, 33, .82); color: #fff; font-size: 7px; }
.material-variant-remove { width: 18px; display: grid; place-items: center; padding: 0; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; }
.material-variant-remove:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.center-pattern-mini { display: grid; grid-template-columns: minmax(0, 1fr) 74px; align-items: center; gap: 8px; padding: 6px 7px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.center-pattern-mini > div:first-child { min-width: 0; display: grid; gap: 2px; }
.center-pattern-mini > div:first-child strong { font-size: 9px; }
.center-pattern-mini > div:first-child small { font-size: 7px; }
.center-pattern-cells { width: 74px; height: 74px; display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line-strong); background: var(--line); gap: 1px; }
.center-pattern-cell { position: relative; min-width: 0; min-height: 0; padding: 0; overflow: hidden; border: 0; background: var(--surface); }
.center-pattern-cell:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.center-pattern-cell img { width: 100%; height: 100%; object-fit: cover; }
.center-pattern-cell b { position: absolute; left: 1px; top: 1px; min-width: 11px; height: 11px; display: grid; place-items: center; border-radius: 2px; background: rgba(17, 24, 33, .82); color: #fff; font-size: 6px; }
.material-compatibility-hint { margin: 7px 0 0; color: var(--danger); font-size: 9px; line-height: 1.35; }
.saved-design-picker { width: 100%; min-height: 42px; display: grid; grid-template-columns: 24px minmax(0, 1fr) 22px 14px; align-items: center; gap: 8px; margin-top: 7px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); color: var(--text); text-align: left; }
.saved-design-picker:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.saved-design-picker:disabled { opacity: .65; }
.saved-design-picker > svg:first-child { width: 18px; height: 18px; color: var(--brand); }
.saved-design-picker > span { min-width: 0; display: grid; gap: 1px; }
.saved-design-picker strong { font-size: 10px; }
.saved-design-picker small { overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.saved-design-picker b { min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--brand) 10%, var(--surface)); color: var(--brand); font-size: 9px; }

.pattern-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}
.pattern-options button {
  min-width: 0;
  min-height: 88px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 10px;
  font-weight: 700;
}
.pattern-options button.is-active,
.pattern-options button:hover { border-color: var(--brand); color: var(--brand); }
.pattern-options i {
  width: 42px;
  height: 36px;
  display: block;
  border: 1px solid var(--line-strong);
  background-size: 14px 12px;
}
.pattern-straight { background-image: linear-gradient(to right, transparent 13px, #777 13px, #777 14px), linear-gradient(to bottom, transparent 11px, #777 11px, #777 12px); }
.pattern-running { overflow: hidden; background: var(--surface); }
.pattern-running svg { width: 100%; height: 100%; display: block; }
.pattern-running path { fill: none; stroke: currentColor; stroke-width: .72; vector-effect: non-scaling-stroke; shape-rendering: geometricPrecision; }
.pattern-diagonal { background-image: linear-gradient(45deg, transparent 47%, #777 48%, #777 52%, transparent 53%), linear-gradient(-45deg, transparent 47%, #777 48%, #777 52%, transparent 53%); }

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.section-heading-row h2 { margin-top: 0 !important; }
.setup-section > .section-heading-row { margin-top: 24px; }
.text-button { padding: 3px 0; border: 0; background: none; color: var(--brand); font-size: 11px; font-weight: 700; }

.origin-control {
  display: grid;
  grid-template-columns: 114px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-top: 11px;
}
.anchor-grid {
  width: 114px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-image: linear-gradient(to right, transparent 33%, var(--line) 33%, var(--line) 34%, transparent 34%, transparent 66%, var(--line) 66%, var(--line) 67%, transparent 67%), linear-gradient(to bottom, transparent 33%, var(--line) 33%, var(--line) 34%, transparent 34%, transparent 66%, var(--line) 66%, var(--line) 67%, transparent 67%);
}
.anchor-grid button {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
}
.anchor-grid button::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid #92999a;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
}
.anchor-grid button.is-active::before {
  width: 13px;
  height: 13px;
  border: 3px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.origin-summary { min-width: 0; display: grid; grid-template-columns: 30px 1fr; gap: 3px 8px; align-items: center; }
.origin-summary svg { grid-row: 1 / 3; width: 28px; height: 28px; color: var(--accent); }
.origin-summary strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.origin-summary span { color: var(--muted); font-size: 10px; }

.offset-fields { margin-top: 14px; }

.plan-workspace {
  min-width: 0;
  min-height: 0;
  position: relative;
  background: var(--bg);
}

.canvas-toolbar {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
}
.segmented-tools {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 3px 10px rgba(30, 42, 44, .08);
}
.tool-cluster { display: flex; align-items: center; }
.tool-cluster + .tool-cluster { margin-left: 3px; padding-left: 3px; border-left: 1px solid var(--line); }
.segmented-tools button,
.toolbar-toggle {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.segmented-tools button svg { width: 15px; height: 15px; }
.segmented-tools button.is-active { background: var(--brand); color: #fff; }
.segmented-tools button:disabled { opacity: .34; cursor: default; }
.toolbar-toggle {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
}
.toolbar-toggle.is-active { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 42%, var(--line)); }
.cut-legend { width: 14px; height: 14px; border: 1px solid var(--piece-cut); background: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--piece-cut) 48%, transparent) 3px 5px); }

.canvas-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: #edf1f1;
  touch-action: none;
}
.canvas-viewport::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

#planCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
#planCanvas.is-panning { cursor: grab; }
#planCanvas.is-panning:active { cursor: grabbing; }
#planCanvas.is-moving-origin { cursor: crosshair; }
#planCanvas.is-editing-vertices { cursor: pointer; }
#planCanvas.is-assigning { cursor: cell; }
#planCanvas.is-panning { cursor: grab; }
#planCanvas.is-panning.is-dragging { cursor: grabbing; }
#planCanvas.is-editing-vertices { cursor: crosshair; }
#planCanvas.is-editing-vertices.is-hovering-wall { cursor: move; }
#planCanvas.is-inserting-vertex { cursor: copy; }
#planCanvas.is-measuring-walls { cursor: pointer; }
#planCanvas.is-assigning { cursor: cell; }
#planCanvas.is-temporary-pan { cursor: grab !important; }
#planCanvas.is-temporary-pan.is-dragging { cursor: grabbing !important; }

.wall-dimension-overlay { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.wall-dimension-overlay[hidden] { display: none; }
.wall-dimension-overlay button {
  min-width: 38px;
  min-height: 28px;
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border: 1px solid rgba(82, 88, 90, .25);
  border-radius: 4px;
  background: rgba(255, 255, 255, .94);
  color: #42494c;
  font: 700 10px/1 Inter, Segoe UI, sans-serif;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 7px rgba(28, 32, 33, .12);
  pointer-events: auto;
}
.wall-dimension-overlay button:hover,
.wall-dimension-overlay button:focus-visible { border-color: var(--accent); color: var(--brand); outline: 0; }
.wall-dimension-overlay button.is-selected { border-color: #fff; background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(86, 16, 30, .3); }

.wall-inline-editor {
  width: min(246px, calc(100% - 16px));
  position: absolute;
  z-index: 9;
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--brand) 42%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(22, 27, 29, .22), inset 3px 0 var(--brand);
  backdrop-filter: blur(8px);
  touch-action: auto;
}
.wall-inline-editor[hidden] { display: none; }
.wall-inline-main { display: grid; grid-template-columns: minmax(56px, auto) minmax(100px, 1fr); align-items: center; gap: 7px; }
.wall-inline-main > strong { overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.wall-inline-length { height: 34px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); overflow: hidden; }
.wall-inline-length input { width: 100%; height: 100%; min-width: 0; padding: 0 4px 0 9px; border: 0; outline: 0; background: transparent; color: var(--text); font: 700 12px/1 Inter, Segoe UI, sans-serif; }
.wall-inline-length b { padding-right: 9px; color: var(--muted); font-size: 10px; }
.wall-inline-apply { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--brand); border-radius: var(--radius); background: var(--brand); color: #fff; }
.wall-inline-apply svg { width: 17px; height: 17px; }
.wall-inline-apply:disabled { border-color: var(--line); background: var(--surface-soft); color: var(--muted); opacity: .62; cursor: not-allowed; }
.wall-inline-anchor { display: grid; grid-template-columns: minmax(0, 1fr) 42px 42px; align-items: center; gap: 5px; }
.wall-inline-anchor > span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 9px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.wall-inline-anchor button { height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 3px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 800; }
.wall-inline-anchor button svg { width: 12px; height: 12px; }
.wall-inline-anchor button.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, var(--surface)); color: var(--brand); }
.wall-inline-error { margin: 0; padding: 5px 7px; border-left: 2px solid var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); color: var(--danger); font-size: 9px; line-height: 1.3; }
.wall-inline-error[hidden] { display: none; }

.canvas-error {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: min(360px, calc(100% - 40px));
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .96);
  color: var(--danger);
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow);
}

.zoom-controls {
  position: absolute;
  right: 14px;
  bottom: 48px;
  z-index: 4;
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 3px 10px rgba(30, 42, 44, .08);
  overflow: hidden;
}
.zoom-controls .icon-button { border: 0; border-radius: 0; }
.zoom-controls output { min-width: 42px; padding: 5px; border-block: 1px solid var(--line); color: var(--muted); font-size: 10px; text-align: center; }
.zoom-controls .icon-button:last-child { border-top: 1px solid var(--line); }

.canvas-key {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  gap: 14px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  font-size: 10px;
}
.canvas-key span { display: inline-flex; align-items: center; gap: 5px; }
.canvas-key i { width: 12px; height: 12px; border: 1px solid; }
.full-key { border-color: var(--piece-full) !important; background: color-mix(in srgb, var(--piece-full) 72%, var(--surface)); }
.cut-key { border-color: var(--piece-cut) !important; background: repeating-linear-gradient(135deg, var(--surface) 0 3px, color-mix(in srgb, var(--piece-cut) 58%, var(--surface)) 3px 5px); }

.results-panel {
  border-left: 1px solid var(--line);
  overflow: hidden;
}
.results-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.result-sheet-toggle { display: none; }

.result-heading {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.result-heading p { margin: 5px 0 0; color: var(--success); font-size: 10px; }
.result-heading > strong { color: var(--brand); font-size: 34px; line-height: 1; }

.result-primary-meta {
  min-height: 32px;
  display: grid;
  gap: 3px;
  padding: 0 18px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}
.result-primary-meta strong { color: var(--text); font-size: 10px; font-weight: 700; }

.calculation-details-body { background: color-mix(in srgb, var(--surface-soft) 45%, var(--surface)); }
.placed-total {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
}
.placed-total span { color: var(--muted); font-size: 10px; }
.placed-total strong { font-size: 16px; }

.result-breakdown { padding: 7px 18px; border-bottom: 1px solid var(--line); }
.result-breakdown > div {
  min-height: 40px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 9px;
}
.result-breakdown strong { font-size: 16px; }
.metric-icon { position: relative; width: 18px; height: 18px; border: 1px solid; }
.full-icon {
  border-color: color-mix(in srgb, var(--role-center) 72%, var(--line-strong));
  background: color-mix(in srgb, var(--role-center) 82%, var(--surface));
  box-shadow: inset 0 0 0 3px color-mix(in srgb, #fff 58%, transparent);
}
.cut-icon { border-color: var(--piece-cut); background: repeating-linear-gradient(135deg, var(--surface) 0 3px, color-mix(in srgb, var(--piece-cut) 64%, var(--surface)) 3px 5px); }

.role-breakdown { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 13px; padding: 11px 18px; border-bottom: 0; }
.role-breakdown-heading { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.role-breakdown-heading small { color: var(--muted); font-size: 9px; }
.role-breakdown > div:not(.role-breakdown-heading) { min-height: 28px; display: grid; grid-template-columns: 15px 1fr auto; align-items: center; gap: 6px; font-size: 10px; }
.role-breakdown [data-role-swatch] { width: 13px; height: 13px; }

.room-metrics {
  margin: 0;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.room-metrics > div { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-metrics dt { color: var(--muted); }
.room-metrics dd { margin: 0; font-weight: 700; }

.waste-control { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.waste-control output { color: var(--muted); font-size: 10px; }
.reserve-heading-actions { display: flex; align-items: center; gap: 9px; }
.reserve-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.reserve-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.reserve-switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-soft);
  transition: border-color .16s ease, background-color .16s ease;
}
.reserve-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .16s ease, background-color .16s ease;
}
.reserve-switch input:checked + .reserve-switch-track { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 22%, var(--surface)); }
.reserve-switch input:checked + .reserve-switch-track::after { transform: translateX(15px); background: var(--brand); }
.reserve-switch input:focus-visible + .reserve-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.waste-control .stepper { transition: opacity .16s ease; }
.waste-control.is-disabled .stepper { opacity: .42; }
.waste-control.is-disabled .stepper button { cursor: default; }
.waste-control.is-disabled .stepper button:hover { color: inherit; background: var(--surface); }
.stepper {
  height: 38px;
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  margin-top: 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.stepper button { display: grid; place-items: center; border: 0; background: var(--surface); }
.stepper button:hover { color: #fff; background: var(--accent); }
.stepper button:first-child { border-right: 1px solid var(--line); }
.stepper button:last-child { border-left: 1px solid var(--line); }
.stepper label { display: flex; align-items: center; justify-content: center; }
.stepper input { width: 52px; height: 100%; padding: 0; border: 0; background: transparent; font-weight: 800; text-align: right; }
.stepper b { padding-left: 4px; }

.purchase-total {
  margin: 14px 18px;
  padding: 15px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line));
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.purchase-total > span { align-self: end; font-weight: 700; }
.purchase-total strong { grid-row: 1 / 3; grid-column: 2; color: var(--brand); font-size: 38px; line-height: 1; }
.purchase-total small { color: var(--muted); }
.purchase-total em { grid-column: 1 / -1; margin-top: 8px; color: var(--muted); font-size: 10px; font-style: normal; }

.box-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 12px;
  align-items: end;
  padding: 0 18px 16px;
  border-bottom: 1px solid var(--line);
}
.box-row > div {
  height: 55px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.box-row > div strong { color: var(--brand); font-size: 20px; }
.box-row > div span { color: var(--muted); font-size: 10px; }

details { border-bottom: 1px solid var(--line); }
summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 18px;
  list-style: none;
  font-weight: 700;
  cursor: pointer;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; color: var(--brand); font-size: 18px; font-weight: 400; }
details[open] summary::after { content: "−"; }
summary span { margin-left: auto; color: var(--muted); font-size: 10px; font-weight: 500; }

.cut-list-body {
  padding: 0 18px 14px;
  transition: opacity .12s ease;
}
.cut-list.is-updating .cut-list-body { opacity: .58; }
.cut-analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}
.cut-analysis-stat { min-width: 0; display: grid; gap: 2px; padding: 9px 7px; background: var(--surface-soft); }
.cut-analysis-stat strong { color: var(--text); font-size: 15px; }
.cut-analysis-stat small { color: var(--muted); font-size: 8px; line-height: 1.25; }
.microcut-notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 9px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.microcut-notice > span { min-width: 0; display: grid; gap: 3px; }
.microcut-notice strong { font-size: 10px; }
.microcut-notice small { color: var(--muted); font-size: 8px; line-height: 1.35; }
.microcut-notice button { min-height: 30px; padding: 0 9px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); color: var(--brand); font-size: 8px; font-weight: 700; }
.microcut-notice button:hover { background: var(--surface-soft); }
.cut-repeat-heading { display: flex; align-items: end; justify-content: space-between; gap: 8px; margin-top: 12px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.cut-repeat-heading strong { font-size: 10px; }
.cut-repeat-heading small { color: var(--muted); font-size: 8px; text-align: right; }
.cut-list-row {
  min-height: 43px;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
}
.cut-list-row:first-child { border-top: 0; }
.cut-list-preview { width: 30px; height: 30px; display: block; }
.cut-list-row > span { min-width: 0; display: grid; gap: 2px; }
.cut-list-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cut-list-row small { color: var(--muted); }
.cut-list-empty { min-height: 42px; display: grid; place-items: center; margin: 0; padding: 12px 0 0; color: var(--muted); font-size: 9px; line-height: 1.4; text-align: center; }

.status-bar {
  height: var(--status-height);
  display: grid;
  grid-template-columns: 210px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
}
.status-bar b { color: var(--text); }
.status-ok { display: inline-flex; align-items: center; gap: 5px; color: var(--success); }
.status-ok svg { width: 14px; height: 14px; }

.project-site-footer {
  width: min(96vw, 1680px);
  margin: 0 auto 10px;
  border-top: 0;
  border-radius: 0 0 5px 5px;
}

.project-site-footer h2 { font-size: 22px; }

.export-dialog,
.projects-dialog,
.catalog-dialog,
.saved-design-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 70px rgba(21, 27, 29, .24);
}
.projects-dialog { width: min(720px, calc(100vw - 28px)); }
.catalog-dialog { width: min(760px, calc(100vw - 28px)); }
.saved-design-dialog { width: min(720px, calc(100vw - 28px)); }
.export-dialog::backdrop,
.projects-dialog::backdrop,
.catalog-dialog::backdrop,
.saved-design-dialog::backdrop { background: rgba(21, 27, 29, .48); backdrop-filter: blur(3px); }
.export-dialog form > header,
.projects-dialog form > header,
.catalog-dialog form > header,
.saved-design-dialog form > header { min-height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.export-dialog h2,
.projects-dialog h2,
.catalog-dialog h2,
.saved-design-dialog h2 { margin: 0; font-size: 18px; }
.export-dialog header p,
.projects-dialog header p,
.catalog-dialog header p,
.saved-design-dialog header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.export-dialog header .icon-button,
.projects-dialog header .icon-button,
.catalog-dialog header .icon-button,
.saved-design-dialog header .icon-button { font-size: 22px; }
.pdf-export-body { padding: 16px; }
.pdf-mode-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pdf-mode-picker button {
  min-width: 0;
  min-height: 112px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}
.pdf-mode-picker button:hover { border-color: var(--line-strong); background: var(--surface); }
.pdf-mode-picker button.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.pdf-mode-picker svg { width: 24px; height: 24px; color: var(--brand); }
.pdf-mode-picker span { min-width: 0; display: grid; gap: 6px; }
.pdf-mode-picker strong { font-size: 12px; line-height: 1.3; }
.pdf-mode-picker small { color: var(--muted); font-size: 9px; line-height: 1.45; }
.pdf-mode-summary { min-height: 36px; margin: 10px 0 0; padding: 9px 11px; border-left: 3px solid var(--accent); background: var(--surface-soft); color: var(--muted); font-size: 10px; line-height: 1.45; }
.export-dialog form > footer .secondary-button svg,
.export-dialog form > footer .primary-button svg { width: 16px; height: 16px; }
.export-dialog form > footer button:disabled { opacity: .58; cursor: wait; }
.pdf-preview-dialog { width: min(1080px, calc(100vw - 30px)); height: min(900px, calc(100vh - 30px)); padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(8, 15, 20, .3); }
.pdf-preview-dialog::backdrop { background: rgba(8, 15, 20, .62); backdrop-filter: blur(3px); }
.pdf-preview-dialog form { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.pdf-preview-dialog header, .pdf-preview-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.pdf-preview-dialog footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.pdf-preview-dialog h2 { margin: 0; font-size: 18px; }
.pdf-preview-dialog header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.pdf-preview-frame { min-height: 0; padding: 0; background: #d8dbde; }
.pdf-preview-pages { display: block; overflow: hidden; overscroll-behavior: contain; }
.pdf-preview-document { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.optimize-dialog { width: min(460px, calc(100vw - 28px)); }
.optimize-dialog-body { padding: 16px; }
.optimize-comparison { display: grid; grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr); align-items: center; gap: 8px; }
.optimize-comparison > div { min-width: 0; display: grid; gap: 5px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.optimize-comparison > div.is-proposal { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.optimize-comparison > svg { width: 18px; height: 18px; color: var(--muted); }
.optimize-comparison small { color: var(--muted); font-size: 9px; }
.optimize-comparison strong { font-size: 26px; color: var(--text); }
.optimize-comparison span { font-size: 9px; color: var(--muted); }
.optimize-dialog-body > p { margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.export-dialog form > footer,
.projects-dialog form > footer,
.catalog-dialog form > footer,
.saved-design-dialog form > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

.saved-design-grid { min-height: 210px; max-height: min(58vh, 540px); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 9px; padding: 12px 16px 16px; overflow-y: auto; }
.saved-design-option { min-width: 0; min-height: 104px; display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 10px; padding: 7px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: left; }
.saved-design-option:hover:not(:disabled) { border-color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent); }
.saved-design-option:disabled { opacity: .52; }
.saved-design-option-preview { width: 116px; height: 88px; display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; border: 1px solid var(--line); background: var(--surface-soft); }
.saved-design-option-preview img { width: 100%; height: 100%; grid-column: 1 / -1; object-fit: cover; }
.saved-design-option-preview i { border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); background: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.saved-design-option > span:last-child { min-width: 0; display: grid; gap: 5px; }
.saved-design-option strong { overflow: hidden; font-size: 11px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.saved-design-option small { color: var(--muted); font-size: 8px; line-height: 1.4; }
.saved-design-grid-empty { grid-column: 1 / -1; min-height: 210px; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }

.catalog-search { height: 42px; flex: 0 0 auto; display: flex; align-items: center; gap: 8px; margin: 12px 16px 0; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.catalog-search svg { width: 16px; height: 16px; color: var(--muted); }
.catalog-search input { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; }
.catalog-compatibility-notice { margin: 9px 16px 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); color: var(--muted); font-size: 10px; line-height: 1.4; }
.catalog-grid { min-height: 180px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-content: start; gap: 8px; margin-top: 10px; padding: 0 16px 14px; overflow: auto; }
.catalog-item { min-width: 0; min-height: 142px; display: grid; grid-template-rows: 92px auto; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; }
.catalog-item:hover,
.catalog-item.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.catalog-item:disabled { opacity: .56; }
.catalog-item-preview { position: relative; display: grid; grid-template-columns: 1fr; overflow: hidden; border: 1px solid var(--line); background: var(--surface-soft); }
.catalog-item-preview.is-pair { grid-template-columns: 1fr 1fr; }
.catalog-item-preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.catalog-item-preview em { position: absolute; right: 3px; bottom: 3px; padding: 2px 4px; background: rgba(17, 24, 33, .82); color: #fff; font-size: 7px; font-style: normal; }
.catalog-item-copy { min-width: 0; display: grid; gap: 2px; }
.catalog-item-copy strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.catalog-item-copy small { color: var(--muted); font-size: 8px; }
.catalog-grid-empty { grid-column: 1 / -1; min-height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.catalog-load-more { flex: 0 0 auto; align-self: center; margin: 0 0 12px; padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }

.project-library-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 12px 16px 0; }
.project-library-toolbar .secondary-button { min-height: 40px; padding-inline: 12px; white-space: nowrap; }
.project-library-toolbar .secondary-button svg { width: 15px; height: 15px; }
.project-search {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.project-library-toolbar .project-search { margin: 0; }
.project-search svg { width: 16px; height: 16px; color: var(--muted); }
.project-search input { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; }
.project-library { max-height: min(55vh, 520px); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px 16px 16px; overflow-y: auto; }
.project-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  gap: 9px 11px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.project-card.is-current { border-color: var(--brand); box-shadow: inset 3px 0 var(--brand); }
.project-card.has-pending-changes { border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.project-card canvas { width: 96px; height: 66px; grid-row: 1 / 3; align-self: center; border: 1px solid var(--line); background: #eee8de; object-fit: cover; }
.project-card > div:not(.project-card-actions) { min-width: 0; display: grid; align-content: center; gap: 5px; }
.project-card > div > strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.project-card > div > span { color: var(--muted); font-size: 9px; line-height: 1.35; }
.project-card-actions { display: grid; grid-template-columns: 1fr 32px 32px; gap: 5px; }
.project-card-actions button { min-width: 0; height: 30px; display: grid; place-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-soft); font-size: 9px; font-weight: 700; }
.project-card-actions button:first-child { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.project-card-actions button:hover { border-color: var(--brand); }
.project-card-actions svg { width: 13px; height: 13px; }
.project-card-actions .is-confirming { grid-column: 2 / 4; width: auto; color: #fff; border-color: var(--danger); background: var(--danger); }
.project-library-empty { grid-column: 1 / -1; min-height: 210px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
.project-library-empty svg { width: 34px; height: 34px; color: var(--brand); }
.project-library-empty strong { color: var(--text); }
.project-library-empty span { max-width: 320px; font-size: 11px; }
.new-project-dialog { width: min(440px, calc(100vw - 28px)); }
.new-project-body { display: grid; gap: 12px; padding: 16px; }
.new-project-body .field { margin: 0; }
.preserve-project-option { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.preserve-project-option input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--brand); }
.preserve-project-option > span { display: grid; gap: 3px; }
.preserve-project-option strong { font-size: 10px; }
.preserve-project-option small { color: var(--muted); font-size: 9px; line-height: 1.4; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 28px));
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--line));
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.mobile-sheet-handle { display: none; }

@media (max-width: 1120px) {
  .app-header { grid-template-columns: minmax(150px, 190px) minmax(170px, 1fr) auto; gap: 10px; }
  .app-shell { grid-template-columns: 288px minmax(380px, 1fr) 286px; }
  .save-status { display: none; }
  .header-text-button span { display: none; }
  .header-text-button { width: 38px; padding: 0; justify-content: center; position: relative; }
  .header-text-button b { position: absolute; right: -5px; top: -5px; }
}

@media (max-width: 1400px) { .save-status { display: none; } }

@media (min-width: 821px) and (max-width: 1366px) {
  .canvas-toolbar { top: 10px; right: 8px; }
  .segmented-tools button { width: 34px; padding: 0; justify-content: center; }
  .segmented-tools button span { display: none; }
  .segmented-tools button.is-active { width: auto; min-width: 86px; padding: 0 9px; }
  .segmented-tools button.is-active span { display: inline; }
  .toolbar-toggle { padding-inline: 10px; }
}

@media (max-width: 820px) {
  :root {
    --header-height: 48px;
    --mobile-steps-height: 44px;
    --mobile-sheet-height: clamp(190px, 29dvh, 250px);
  }
  body { overflow-x: hidden; overflow-y: auto; }
  .draft-recovery-dialog[open] { grid-template-columns: 46px 1fr; gap: 14px; padding: 20px; }
  .draft-recovery-mark { width: 46px; height: 46px; }
  .draft-recovery-dialog h2 { font-size: 21px; }
  .draft-recovery-actions { align-items: stretch; flex-direction: column-reverse; }
  .draft-recovery-actions button { width: 100%; }
  .pdf-preview-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; }
  .pdf-preview-frame { padding: 0; }
  .pdf-preview-dialog header, .pdf-preview-dialog footer { padding: 11px 12px; }
  .new-project-header-button { display: none; }
  .site-frame { width: 100%; height: 100dvh; margin: 0; padding-top: var(--floating-header-height, 0px); border: 0; border-radius: 0; grid-template-rows: auto 22px auto auto minmax(0, 1fr); }
  .site-frame.has-floating-header { grid-template-rows: 22px auto auto minmax(0, 1fr); }
  .site-frame.has-floating-header:has(> .site-breadcrumbs) { grid-template-rows: 22px auto auto auto minmax(0, 1fr); }
  .project-site-footer { width: 100%; margin: 0; border-radius: 0; }
  body.project-footer-visible .setup-panel,
  body.project-footer-visible .results-panel { visibility: hidden; pointer-events: none; }
  .mosaic-strip { height: 22px; min-height: 22px; }
  .app-header {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 10px;
  }
  .product-title, .project-name, .save-status { display: none; }
  .header-actions { gap: 3px; justify-content: flex-end; }
  .header-actions .icon-button { width: 32px; height: 34px; border-color: transparent; }
  .header-actions .primary-button, .header-text-button { width: 36px; height: 36px; min-height: 36px; padding: 0; }
  .header-actions .primary-button span, .header-text-button span { display: none; }
  .header-actions #saveProjectBtn { width: auto; min-width: 68px; padding: 0 8px; }
  .header-actions #saveProjectBtn span { display: inline; }

  .mobile-steps {
    height: var(--mobile-steps-height);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 5px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    position: relative;
    z-index: 18;
  }
  .mobile-steps button {
    min-width: 0;
    min-height: 34px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }
  .mobile-steps button::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: -5px;
    left: 18px;
    height: 2px;
    background: transparent;
  }
  .mobile-steps button.is-active { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--accent); }
  .mobile-steps button.is-active::after { background: var(--accent); }
  .mobile-steps svg { width: 16px; height: 16px; flex: 0 0 16px; }
  .mobile-steps span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .app-shell {
    height: auto;
    display: block;
  }
  .plan-workspace { width: 100%; height: 100%; }
  .canvas-toolbar { top: 8px; right: 8px; }
  .segmented-tools button { width: 34px; padding: 0; justify-content: center; }
  .segmented-tools button span, .toolbar-toggle { display: none; }
  .segmented-tools button.is-active { width: auto; min-width: 82px; padding: 0 8px; }
  .segmented-tools button.is-active span { display: inline; }
  .saved-design-grid { grid-template-columns: 1fr; }
  .saved-design-option { grid-template-columns: 104px minmax(0, 1fr); }
  .saved-design-option-preview { width: 104px; height: 78px; }
  .canvas-key { display: none; }
  .wall-dimension-overlay button { min-width: 44px; min-height: 40px; }
  .zoom-controls { right: 8px; bottom: calc(var(--mobile-sheet-height) + 12px); }

  .setup-panel,
  .results-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    width: 100%;
    height: var(--mobile-sheet-height);
    min-height: 190px;
    max-height: 250px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 28px rgba(27, 36, 38, .14);
    overflow: hidden;
  }
  body.sheet-expanded .setup-panel,
  body.sheet-expanded .results-panel { height: 68dvh; min-height: 0; max-height: none; }
  body.sheet-expanded .zoom-controls { bottom: calc(68dvh + 12px); }
  body[data-mobile-panel="results"] .setup-panel,
  body:not([data-mobile-panel="results"]) .results-panel { display: none; }

  .mobile-sheet-handle {
    width: 64px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .mobile-sheet-handle span { width: 34px; height: 4px; border-radius: 4px; background: #aeb4b5; }
  .mobile-sheet-handle svg { width: 15px; height: 15px; color: var(--muted); transform: rotate(-90deg); }
  body.sheet-expanded .mobile-sheet-handle svg { transform: rotate(90deg); }
  .setup-tabs { height: 38px; }
  .setup-tabs button { font-size: 11px; }
  .setup-section { height: calc(100% - 62px); padding: 10px 16px 22px; }
  body[data-mobile-panel="room"] .setup-tabs { display: none; }
  body[data-mobile-panel="room"] .setup-section { height: calc(100% - 24px); }
  body[data-mobile-panel="tile"] .setup-tabs { grid-template-columns: repeat(2, 1fr); }
  body[data-mobile-panel="tile"] .setup-tabs button[data-setup-tab="room"] { display: none; }

  .result-sheet-toggle {
    width: 100%;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border: 0;
    background: var(--surface);
  }
  .result-sheet-toggle span { width: 44px; height: 4px; margin-left: calc(50% - 22px); border-radius: 4px; background: #aeb4b5; }
  .result-sheet-toggle svg { width: 18px; height: 18px; transform: rotate(-90deg); }
  body.sheet-expanded .result-sheet-toggle svg { transform: rotate(90deg); }
  .results-scroll { height: calc(100% - 25px); }
  .result-heading { min-height: 64px; padding: 10px 16px; }
  .result-heading > strong { font-size: 30px; }
  .result-primary-meta { min-height: 26px; padding: 0 16px 7px; }
  .result-breakdown { display: grid; grid-template-columns: repeat(2, 1fr); padding: 4px 16px; }
  .result-breakdown > div { grid-template-columns: 20px 1fr auto; gap: 6px; }
  .room-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; padding: 8px 16px; }
  .room-metrics > div:last-child { grid-column: 1 / -1; }
  .purchase-total { margin: 10px 16px; }
  .status-bar { display: none; }
  .toast { bottom: calc(var(--mobile-sheet-height) + 12px); }
  body.sheet-expanded .toast { bottom: calc(68dvh + 12px); }
  .project-library { grid-template-columns: 1fr; }
  .project-library-toolbar { grid-template-columns: 1fr; }
  .project-library-toolbar .secondary-button { width: 100%; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-item { min-height: 132px; grid-template-rows: 82px auto; }
  .catalog-dialog form > footer { position: sticky; bottom: 0; background: var(--surface); }
}

@media (max-width: 440px) {
  .app-header { grid-template-columns: 1fr; }
  .product-title { overflow: hidden; white-space: nowrap; }
  .product-title strong { font-size: 13px; }
  .mobile-steps { padding-inline: 7px; }
  .mobile-steps button { gap: 4px; font-size: 10px; }
  .shape-options { grid-template-columns: repeat(4, 1fr); }
  .shape-button { min-height: 70px; font-size: 10px; }
  .tile-presets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile-preset { min-height: 75px; padding: 5px 2px; font-size: 9px; }
  .tile-preset i { width: calc(31px * var(--tile-w)); height: calc(31px * var(--tile-h)); }
  .tile-dimensions { grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr); }
  .pattern-options button { min-height: 72px; }
  .origin-control { grid-template-columns: 98px minmax(0, 1fr); }
  .anchor-grid { width: 98px; }
  .project-card { grid-template-columns: 82px minmax(0, 1fr); }
  .project-card canvas { width: 82px; height: 62px; }
  .projects-dialog form > footer { position: sticky; bottom: 0; background: var(--surface); }
  .export-dialog form > footer { flex-wrap: wrap; }
  .export-dialog form > footer button { flex: 1 1 150px; }
}

@media (max-width: 360px) {
  .site-frame .top { padding-inline: 9px; }
  .site-frame .top .brand-row { gap: 4px; }
  .site-frame .top .logo img { width: auto; max-width: 124px; height: 34px; }
  .site-frame .top .langs { gap: 1px; font-size: 9px; }
  .site-frame .top .theme-toggle { width: 28px; height: 28px; }
  .site-frame .top .mobile-nav-toggle { width: 34px; height: 34px; flex-basis: 34px; }
  .wall-inline-editor { width: min(270px, calc(100% - 12px)); padding: 7px; }
}

@media print {
  @page { size: letter portrait; margin: 10mm; }
  body { overflow: visible; background: #fff; }
  .site-frame { width: 100%; height: auto; margin: 0; display: block; border: 0; box-shadow: none; }
  .app-header { height: 54px; grid-template-columns: 210px 1fr; padding: 0; border-bottom: 1px solid #999; }
  .brand img { width: 190px; }
  .product-title { border: 0; text-align: right; }
  .site-nav, .mosaic-strip, .project-name, .header-actions, .mobile-steps, .setup-panel, .canvas-toolbar, .zoom-controls, .canvas-key, .wall-dimension-overlay, .wall-inline-editor, .status-bar, .result-sheet-toggle { display: none !important; }
  .app-shell { height: auto; display: block; }
  .plan-workspace { height: 150mm; break-inside: avoid; }
  .canvas-viewport { border: 1px solid #aaa; }
  .results-panel { position: static; display: block !important; width: 100%; height: auto; max-height: none; border: 0; box-shadow: none; overflow: visible; break-before: page; }
  .results-scroll { height: auto; overflow: visible; display: grid; grid-template-columns: 1fr 1fr; }
  .result-heading, .result-primary-meta, .result-breakdown, .role-breakdown, .room-metrics, .waste-control, details { break-inside: avoid; }
  .result-heading, .result-primary-meta, .result-breakdown, .role-breakdown, .room-metrics, .waste-control { grid-column: auto; }
  details > * { display: block !important; }
  details { display: block; }
  details > * { display: block; }
  .cut-list-body { height: auto; overflow: visible; }
  .export-dialog, .projects-dialog, .catalog-dialog, .saved-design-dialog, .toast, .project-site-footer { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
