:root {
  --bg: #f9f8f4;
  --panel: #ffffff;
  --line: #e4e2dc;
  --tab-off: #ebe9e3;
  --chip: #ecebe6;
  --chip-text: #8b8a82;
  --text: #3b3b37;
  --muted: #b3b2ab;
  --olive: #7c7f63;
  --olive-dark: #696c53;
  font-family: "Basic Sans", "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); font-weight: 400; }

/* ---------- layout ---------- */
.top { max-width: 1440px; margin: 0 auto; padding: 22px 60px 18px; }
.logo { height: 26px; mix-blend-mode: multiply; display: block; }
.layout {
  max-width: 1440px; margin: 0 auto; padding: 0 60px 40px;
  display: grid; grid-template-columns: 396px 1fr; gap: 16px;
  height: calc(100vh - 66px); min-height: 560px;
}

/* ---------- left panel ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--tab-off); }
.tabs button {
  border: 0; background: transparent; padding: 10px 0 9px; font-size: 16px; color: #77766f;
}
.tabs button.active { background: var(--panel); color: var(--text); }
.pane { display: flex; flex-direction: column; padding: 14px 14px 0; min-height: 0; flex: 1; }
.pane[hidden] { display: none; }

.search {
  display: flex; align-items: center; gap: 6px; border: 1px solid #d9d7d0; padding: 0 9px; height: 30px;
}
.search svg { width: 12px; height: 12px; fill: none; stroke: #8b8a82; stroke-width: 1.6; flex: none; }
.search input { border: 0; outline: 0; flex: 1; font: inherit; font-size: 13px; background: transparent; }
.filters { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.select {
  appearance: none; border: 0; background: var(--chip) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" fill="none" stroke="%236b6a63" stroke-width="1.4"/></svg>') no-repeat right 9px center / 10px;
  padding: 6px 32px 6px 8px; font: inherit; font-size: 13px; color: #6b6a63; min-width: 176px;
}
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 0; background: var(--chip); color: var(--chip-text); padding: 6px 14px; font-size: 13px; min-width: 66px;
}
.chip.active { background: var(--olive); color: #fff; }

.grid { overflow-y: auto; flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; padding: 14px 0 16px; align-content: start; }
.card {
  border: 1px solid transparent; border-radius: 9px; background: none; padding: 6px 2px 5px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; position: relative;
}
.card:hover { border-color: #e2e0d9; }
.card.active { border-color: var(--olive); }
.card .name { font-size: 13px; line-height: 1.15; }
.card .sub { font-size: 11px; color: #8b8a82; line-height: 1.2; }

.pots .thumb { width: 60px; height: 58px; object-fit: contain; mix-blend-mode: multiply; }
.pots .thumb.fallback { opacity: .35; }

.swatches .card { border-radius: 50% 50% 9px 9px; }
.swatches .dot {
  width: 58px; height: 58px; border-radius: 50%; overflow: hidden; display: block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); margin-bottom: 4px; background-size: cover; background-position: center;
}
.swatches .card.active .dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--olive); }
.swatches .card.active { border-color: transparent; }
.badge {
  position: absolute; top: 2px; right: 6px; font-size: 9px; letter-spacing: .04em; text-transform: uppercase;
  background: var(--olive); color: #fff; padding: 1px 4px; border-radius: 3px;
}

.patterns .thumb { width: 54px; height: 54px; object-fit: cover; margin-bottom: 4px; }
.patterns .none { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 4px; }
.patterns .none svg { width: 18px; height: 18px; stroke: #6b6a63; fill: none; stroke-width: 1.4; }
.empty { font-size: 13px; color: #8b8a82; padding: 6px 2px; }

/* ---------- stage ---------- */
.stage { position: relative; display: flex; flex-direction: column; min-height: 0; }
.stage-head { position: relative; z-index: 2; }
.stage h1 { font-size: 22px; font-weight: 500; margin: 0 0 6px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { background: var(--chip); padding: 4px 10px; font-size: 13px; }
#v3d-container { position: absolute; inset: 0; z-index: 1; }
#v3d-container canvas { outline: none; }
.stage-foot {
  position: absolute; right: 64px; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: flex-end; gap: 22px;
}
.plant { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; margin-right: 6px; }
.plant .label { color: #8b8a82; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; border: 0; background: var(--chip);
  border-radius: 4px; padding: 3px 7px; font-size: 12px;
}
.pill:disabled { cursor: not-allowed; opacity: .7; }
.pill svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.actions { display: flex; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--olive); background: var(--olive); color: #fff;
  padding: 10px 20px; font-size: 14px; letter-spacing: .06em; text-transform: uppercase;
}
.btn:hover { background: var(--olive-dark); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.btn-outline { background: transparent; color: var(--olive); }
.btn-outline:hover { background: #f0efe8; }
.btn:disabled { opacity: .5; cursor: wait; }

/* ---------- compare modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(40, 40, 35, .45); z-index: 10; display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--bg); width: min(1180px, 100%); max-height: 100%; overflow: auto; padding: 24px 28px 28px; position: relative; }
.modal-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.modal h2 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.modal h3 { margin: 26px 0 10px; font-size: 17px; font-weight: 500; }
.modal p { margin: 0; font-size: 13px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.close { border: 0; background: none; font-size: 30px; line-height: 1; padding: 0 4px; color: #77766f; }
.cmp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.cmp-pair { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.cmp-cell { background: #fff; border: 1px solid var(--line); position: relative; }
.cmp-cell img.render { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.cmp-cell .swatch { position: absolute; right: 10px; bottom: 44px; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px #fff; }
.cmp-pair .cmp-cell .swatch { width: 96px; height: 96px; }
.cmp-cell .cap { padding: 8px 12px 10px; font-size: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; }
.cmp-busy { position: absolute; inset: 0; background: rgba(249, 248, 244, .85); display: grid; place-items: center; font-size: 16px; }
.cmp-busy[hidden] { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 0 16px 24px; }
  .top { padding: 16px; }
  .panel { order: 2; height: 460px; }
  .stage { height: 70vh; }
  .stage-foot { right: 8px; }
  .cmp-grid { grid-template-columns: repeat(2, 1fr); }
}
