:root {
  color-scheme: light;
  --ink: #1d2522;
  --muted: #66736f;
  --line: #d8dfda;
  --surface: #f6f6f1;
  --paper: #ffffff;
  --accent: #235c4f;
  --accent-2: #b55837;
  --warn: #a06422;
  --danger: #9f2f27;
  --shadow: 0 18px 50px rgb(29 37 34 / 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 10;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(246 246 241 / 0.94);
  padding: 18px 28px;
  backdrop-filter: blur(16px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tabs,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab,
.quiet-button,
.primary-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.tab {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.tab.is-active,
.primary-button {
  background: var(--accent);
  color: #fff;
}

.quiet-button {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.danger {
  color: var(--danger);
}

.tab:hover,
.quiet-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: progress;
  opacity: 0.68;
  transform: none;
}

main {
  padding: 24px;
}

.workspace {
  display: none;
  gap: 20px;
}

.workspace.is-active {
  display: grid;
}

.planner-workspace {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
}

#catalog.workspace {
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr) minmax(260px, 340px);
}

#admin.workspace {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#data.workspace {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar,
.catalog-panel,
.inspector,
.planner-section,
.side-panel,
.admin-column,
.admin-wide,
.data-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.sidebar,
.inspector,
.planner-section,
.side-panel,
.admin-column,
.admin-wide,
.data-panel {
  padding: 18px;
}

.planner-main,
.planner-aside {
  display: grid;
  align-content: start;
  gap: 18px;
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(270px, 0.65fr);
  gap: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.step {
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.upload-zone {
  display: grid;
  gap: 4px;
  border: 1px dashed rgb(35 92 79 / 0.38);
  border-radius: 8px;
  background: #f5faf6;
  margin-bottom: 12px;
  padding: 14px;
  cursor: pointer;
}

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

.upload-zone span {
  color: var(--accent);
  font-weight: 900;
}

.upload-zone small {
  color: var(--muted);
}

.canvas-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #eef0ec 25%, transparent 25%),
    linear-gradient(-45deg, #eef0ec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef0ec 75%),
    linear-gradient(-45deg, transparent 75%, #eef0ec 75%);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

#photoCanvas {
  display: block;
  width: 100%;
  min-height: 260px;
  touch-action: none;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tool-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.tool-button.is-active {
  border-color: rgb(35 92 79 / 0.45);
  background: var(--accent);
  color: white;
}

.planner-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.missing-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.model-panel {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.compact-model-heading {
  margin-bottom: 12px;
}

.model-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.model-form .field {
  margin-bottom: 0;
}

.model-summary {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.model-wall-row,
.model-row {
  display: grid;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.model-wall-row {
  grid-template-columns: 1fr;
  background: #f5faf6;
}

.model-row {
  grid-template-columns: minmax(110px, 1fr) 86px 86px 34px;
}

.model-row strong,
.model-wall-row strong {
  font-size: 13px;
}

.model-row span,
.model-wall-row span {
  color: var(--muted);
  font-size: 12px;
}

.model-row label {
  display: grid;
  gap: 3px;
}

.model-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
}

.missing-item {
  border-left: 4px solid var(--warn);
  background: #fff7ea;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.missing-item.ok {
  border-left-color: var(--accent);
  background: #eff7f2;
}

.plan-board {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf7;
  min-height: 250px;
  padding: 12px;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.view-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 900;
}

.view-tab.is-active {
  border-color: rgb(35 92 79 / 0.45);
  background: var(--accent);
  color: white;
}

.visual-stage {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf7;
  min-height: 280px;
  padding: 12px;
}

.plan-svg {
  display: block;
  min-width: 720px;
  width: 100%;
  height: auto;
}

.front-svg,
.three-svg {
  display: block;
  min-width: 760px;
  width: 100%;
  height: auto;
}

.cabinet-rect {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 2;
}

.wall-line {
  stroke: #2f3734;
  stroke-width: 5;
  stroke-linecap: round;
}

.clearance {
  fill: #edf3ef;
}

.plan-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.marker-chip {
  fill: var(--accent-2);
}

.blocked-chip {
  fill: var(--danger);
}

.blocked-zone {
  fill: rgb(159 47 39 / 0.13);
  stroke: var(--danger);
  stroke-dasharray: 6 4;
}

.blocked-label {
  fill: var(--danger);
}

.front-wall {
  fill: #f5f1e9;
}

.front-floor {
  stroke: #8b918c;
  stroke-width: 3;
}

.front-fixture {
  fill: #dfe7e4;
  stroke: #9dafaa;
  stroke-width: 2;
}

.front-fixture.hood {
  fill: #eee1d7;
}

.front-fixture.electricity {
  fill: #f4d8cb;
}

.front-counter {
  fill: #3f4743;
}

.front-cabinet-frame {
  fill: #fbfaf6;
  stroke: var(--accent);
  stroke-width: 2;
}

.front-door-panel {
  fill: #ffffff;
  stroke: #d4dbd6;
  stroke-width: 1.5;
}

.front-label,
.front-title,
.three-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.front-title {
  font-size: 15px;
}

.three-bg {
  fill: #f6f6f1;
}

.three-wall {
  fill: #ede8df;
  stroke: #d8dfda;
}

.three-floor {
  fill: #d9ded8;
}

.three-window {
  fill: #dfe7e4;
  stroke: #9dafaa;
  stroke-width: 2;
}

.three-front {
  fill: #fbfaf6;
  stroke: var(--accent);
  stroke-width: 2;
}

.three-top {
  fill: #e7e0d6;
  stroke: #bfc9c3;
  stroke-width: 1.5;
}

.three-side {
  fill: #d9d2c8;
  stroke: #bfc9c3;
  stroke-width: 1.5;
}

.render-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(280px, 1.15fr);
  gap: 14px;
}

.render-preview,
.render-prompt-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.render-preview {
  display: grid;
  align-content: end;
  min-height: 330px;
  background:
    linear-gradient(#e8eee9 0 52%, #d4d8cf 52% 100%);
  position: relative;
  overflow: hidden;
}

.render-preview.has-render {
  align-content: stretch;
  background: #111;
  padding: 0;
}

.render-image {
  width: 100%;
  height: 100%;
  min-height: 330px;
  object-fit: cover;
}

.render-wall {
  position: absolute;
  inset: 18px 18px auto 18px;
  height: 160px;
}

.render-window {
  position: absolute;
  top: 18px;
  width: 64px;
  height: 72px;
  border: 3px solid #afc2bc;
  border-radius: 6px;
  background: rgb(255 255 255 / 0.65);
}

.render-kitchen {
  display: flex;
  position: relative;
  z-index: 1;
  align-items: stretch;
  height: 112px;
  border-top: 14px solid #3f4743;
  box-shadow: 0 18px 35px rgb(29 37 34 / 0.15);
}

.render-cabinet {
  display: grid;
  place-items: end center;
  min-width: 28px;
  border: 1px solid #d4dbd6;
  background: linear-gradient(180deg, #fff, #f3f1eb);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  padding-bottom: 8px;
}

.render-caption {
  position: relative;
  z-index: 2;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.render-preview.has-render .render-caption {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  border-radius: 7px;
  background: rgb(255 255 255 / 0.9);
  padding: 8px 10px;
}

.render-prompt {
  min-height: 250px;
}

.render-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.render-status,
.render-history {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5faf6;
  margin-top: 10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.render-history {
  display: grid;
  gap: 4px;
  background: #fff;
}

.render-history strong {
  color: var(--ink);
}

.render-history a {
  color: var(--accent);
  font-weight: 900;
}

.side-panel {
  display: grid;
  gap: 12px;
}

.compact-heading {
  margin-bottom: 0;
}

.bom-list {
  display: grid;
  gap: 10px;
}

.save-form {
  display: grid;
  gap: 10px;
}

.project-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.saved-projects {
  display: grid;
  gap: 8px;
}

.saved-project {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 11px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.saved-project:hover,
.saved-project.is-current {
  border-color: rgb(35 92 79 / 0.45);
  background: #f5faf6;
}

.saved-project strong {
  font-size: 13px;
}

.saved-project span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.bom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.bom-row strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.bom-row span {
  color: var(--muted);
  font-size: 12px;
}

.bom-qty {
  align-self: center;
  border-radius: 6px;
  background: #edf3ef;
  color: var(--accent);
  padding: 5px 8px;
  font-weight: 900;
}

.brief-output {
  min-height: 360px;
}

.catalog-panel {
  min-height: 72vh;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

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

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

.field input:focus,
.field select:focus,
textarea:focus {
  outline: 2px solid rgb(35 92 79 / 0.2);
  border-color: var(--accent);
}

.notice {
  border-left: 4px solid var(--accent-2);
  background: #f8eee8;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.notice strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.product-card {
  display: grid;
  grid-template-rows: 150px auto;
  overflow: hidden;
  min-height: 310px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.product-card:hover,
.product-card.is-selected {
  transform: translateY(-2px);
  border-color: rgb(35 92 79 / 0.45);
  box-shadow: 0 14px 36px rgb(29 37 34 / 0.1);
}

.product-image {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f4f2eb, #e9ede8);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 14px;
}

.schematic {
  display: grid;
  place-items: center;
  width: 74px;
  height: 112px;
  border: 3px solid currentColor;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.product-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.product-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 6px;
  background: #edf3ef;
  color: var(--accent);
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 900;
}

.pill.warn {
  background: #fff3df;
  color: var(--warn);
}

.product-name {
  min-height: 44px;
  font-size: 16px;
  line-height: 1.35;
}

.product-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.inspector {
  position: sticky;
  top: 96px;
  height: calc(100vh - 120px);
  overflow: auto;
}

.inspector-empty {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.detail-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  font-size: 13px;
}

.detail-row span {
  color: var(--muted);
  font-weight: 800;
}

.source-link {
  color: var(--accent);
  font-weight: 800;
  word-break: break-word;
}

.admin-form,
.product-form {
  display: grid;
  gap: 12px;
}

.product-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-wide {
  grid-column: 1 / -1;
}

.span-2 {
  grid-column: span 2;
}

textarea {
  min-height: 58vh;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.data-status {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 1100px) {
  #catalog.workspace,
  #admin.workspace,
  .planner-workspace,
  .planner-grid,
  .render-workspace {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
    height: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  main {
    padding: 12px;
  }

  .product-form,
  .metric-grid,
  .planner-form,
  .model-form,
  .model-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
