:root {
  --ink: #172026;
  --muted: #65727c;
  --line: #d9e0e4;
  --surface: #f6f8f7;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5954;
  --warm: #c47b35;
  --focus: #2b8bdc;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  padding: 18px;
}

.workspace,
.side-panel,
.panel-section {
  min-width: 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.canvas-toolbar,
.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.upload-btn,
.primary-btn,
.secondary-btn,
.icon-btn,
.segmented button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.upload-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.upload-btn input {
  display: none;
}

.secondary-btn,
.icon-btn {
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.icon-btn {
  width: 42px;
  font-size: 22px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #edf2f1;
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
}

.segmented button.active {
  color: #fff;
  background: var(--ink);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 138px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e8eeec 25%, transparent 25%),
    linear-gradient(-45deg, #e8eeec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8eeec 75%),
    linear-gradient(-45deg, transparent 75%, #e8eeec 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  cursor: crosshair;
}

.empty-state {
  width: min(430px, calc(100% - 32px));
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--ink);
  font-size: 24px;
}

.empty-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 18px;
  border: 1px solid #cdd8dc;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(80, 154, 188, .5), rgba(233, 241, 238, .4) 45%),
    linear-gradient(135deg, transparent 45%, #8d4f31 46% 56%, transparent 57%),
    linear-gradient(90deg, #e2d4bf 0 30%, #f4ead8 30% 70%, #d4c5ad 70%);
}

#housePhoto {
  display: none;
  max-width: 100%;
  max-height: calc(100vh - 138px);
  object-fit: contain;
  user-select: none;
}

.placed-item {
  position: absolute;
  display: none;
  width: 160px;
  height: 260px;
  transform-origin: center;
  cursor: move;
  border: 2px solid rgba(255, 255, 255, .9);
  outline: 1px solid rgba(23, 32, 38, .35);
  background-size: cover;
  background-position: center;
  box-shadow: 0 20px 26px rgba(0, 0, 0, .28);
}

.placed-item.no-shadow {
  box-shadow: none;
}

.resize-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--focus);
}

.mask-box {
  position: absolute;
  display: none;
  border: 2px dashed var(--warm);
  background: rgba(196, 123, 53, .18);
  pointer-events: none;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section {
  padding: 14px;
}

.qr-section {
  display: grid;
  grid-template-columns: 1fr 116px;
  gap: 12px;
  align-items: center;
}

.qr-section p,
.status-text {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

#qrImage {
  width: 116px;
  height: 116px;
  border: 1px solid var(--line);
}

.qr-section .secondary-btn {
  grid-column: 1 / -1;
}

.section-head,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

select {
  min-height: 36px;
  padding: 0 10px;
}

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

.product-card {
  min-height: 142px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.product-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}

.product-art {
  height: 88px;
  margin-bottom: 8px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
}

.product-art.door {
  background:
    linear-gradient(90deg,#252b2d 0 16%,#9fb6bf 16% 30%,#8a5a34 30% 84%,#252b2d 84%),
    linear-gradient(180deg,rgba(255,255,255,.18),rgba(0,0,0,.16));
}

.product-art.window {
  background:
    linear-gradient(90deg,#15191a 0 8%,#9bc5d4 8% 48%,#15191a 48% 55%,#9bc5d4 55% 92%,#15191a 92%),
    linear-gradient(180deg,#15191a 0 9%,transparent 9% 91%,#15191a 91%);
}

.marker-help p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.product-card strong {
  display: block;
  font-size: 13px;
}

.product-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.product-card small {
  display: inline-flex;
  margin-top: 7px;
  color: #b42318;
  font-size: 12px;
  font-weight: 700;
}

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

.product-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.product-form input[type="text"],
.product-form input[type="file"],
.product-form textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.product-form input[type="file"] {
  padding: 7px;
}

.controls {
  display: grid;
  gap: 12px;
}

.controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 8px !important;
  color: var(--ink) !important;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 10px;
  color: #263238;
  line-height: 1.4;
}

.ai-panel {
  display: grid;
  gap: 10px;
}

.primary-btn:hover,
.upload-btn:hover {
  background: var(--accent-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.placed-item:focus-visible {
  outline: 3px solid rgba(43, 139, 220, .35);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 62vh;
  }

  #housePhoto {
    max-height: 62vh;
  }
}

@media (max-width: 560px) {
  .topbar,
  .app-shell {
    padding: 12px;
  }

  .canvas-toolbar {
    flex-wrap: wrap;
  }

  h1 {
    font-size: 21px;
  }

  .qr-section {
    grid-template-columns: 1fr;
  }
}
