:root {
  --bg0: #e8efe9;
  --panel: rgba(247, 244, 239, 0.94);
  --panel-border: rgba(13, 92, 86, 0.18);
  --teal: #0d5c56;
  --teal-deep: #084742;
  --teal-soft: #c4e8e2;
  --ink: #1a2b2a;
  --ink-soft: #3d5250;
  --muted: #5c706e;
  --accent: #c45c26;
  --accent-soft: #f5e6dc;
  --text: #1a2b2a;
  --line: rgba(13, 92, 86, 0.22);
  --danger: #9a2f1a;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --side-w: min(380px, 42vw);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #d8e0d6; color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
#app { position: relative; width: 100%; height: 100%; }
#stage { position: absolute; inset: 0; right: var(--side-w); }
#c { display: block; width: 100%; height: 100%; outline: none; }
#overlay { position: absolute; inset: 0; pointer-events: none; }

.topbar {
  position: absolute; top: 0; left: 0; right: var(--side-w); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(247,244,239,0.88), rgba(247,244,239,0.2) 80%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; flex-direction: column; gap: 1px; min-width: 0; text-shadow: 0 1px 2px rgba(255,255,255,0.7); }
.brand .wordmark { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--teal); font-weight: 700; }
.brand h1 { font-size: clamp(14px, 2.4vw, 20px); font-weight: 650; color: var(--ink); line-height: 1.2; }

.steps { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; flex: 1; }
.steps button {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 650;
  padding: 6px 9px; border-radius: 999px; cursor: pointer;
}
.steps button:hover { background: rgba(13,92,86,0.08); color: var(--ink); }
.steps button.active { background: var(--teal); color: #fff; }
.steps button .n { display: inline-block; width: 16px; opacity: 0.7; }

.top-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.unit-toggle { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.unit-toggle .btn { border: none; border-radius: 0; padding: 6px 8px; font-size: 12px; }
.unit-toggle .btn.active { background: var(--teal); color: #fff; }

.view-bar {
  position: absolute; left: 12px; bottom: 12px; z-index: 20;
  display: flex; gap: 6px; padding: 6px; background: var(--panel);
  border: 1px solid var(--panel-border); border-radius: 12px;
  backdrop-filter: blur(10px);
}
.warnings {
  position: absolute; left: 12px; right: calc(var(--side-w) + 12px); bottom: 58px; z-index: 19;
  max-height: 22vh; overflow: auto; padding: 8px 12px;
  background: var(--accent-soft); border: 1px solid rgba(196,92,38,0.35); border-radius: 10px;
  font-size: 12px; color: #7a3a14;
}
.warnings li { margin-left: 16px; }

.side {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--side-w);
  z-index: 25; background: var(--panel); border-left: 1px solid var(--panel-border);
  display: flex; flex-direction: column;
}
.side-scroll { flex: 1; min-height: 0; overflow: auto; padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 12px; }

.card h2, .step-card h2 {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--teal); margin-bottom: 8px;
}
.step-card h3 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 8px; }
.step-card p, .hint { font-size: 13px; line-height: 1.45; color: var(--muted); margin-bottom: 10px; }
.prompt { font-size: 15px; font-weight: 650; color: var(--ink); margin-bottom: 10px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: rgba(13, 92, 86, 0.06);
  color: var(--ink); font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: rgba(13, 92, 86, 0.14); border-color: var(--teal); }
.btn:active { transform: scale(0.97); }
.btn.active { background: var(--teal); border-color: var(--teal-deep); color: #fff; }
.btn.primary { background: linear-gradient(135deg, #0d5c56, #14756e); border-color: #0d5c56; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.icon-btn { padding: 8px 10px; }
.btn.listening { background: var(--accent); border-color: var(--accent); color: #fff; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.choice {
  appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 8px; cursor: pointer; text-align: left; color: inherit; font: inherit;
}
.choice:hover { border-color: var(--teal); }
.choice.active { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
.choice canvas { width: 100%; height: auto; display: block; border-radius: 8px; background: #e8efe9; }
.choice .name { font-size: 13px; font-weight: 700; margin-top: 6px; }
.choice .blurb { font-size: 11px; color: var(--muted); line-height: 1.3; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2); cursor: pointer; padding: 0;
}
.swatch.active { box-shadow: 0 0 0 2px var(--teal); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.field input, .field select, .chat-form input {
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); width: 100%;
}
.size-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.size-pills button {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-size: 12px; font-weight: 650; padding: 5px 8px; border-radius: 8px; cursor: pointer;
}
.size-pills button.active { background: var(--teal); border-color: var(--teal-deep); color: #fff; }

.cat-group { margin-bottom: 10px; }
.cat-group h4 { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal); margin-bottom: 6px; }
.cat-row { display: flex; flex-wrap: wrap; gap: 4px; }

.list { width: 100%; border-collapse: collapse; font-size: 12px; }
.list th, .list td { border-bottom: 1px solid var(--line); padding: 5px 4px; text-align: left; vertical-align: top; }
.list th { color: var(--teal); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.list tr.selected td { background: rgba(196,92,38,0.12); }
.totals { font-size: 13px; margin: 8px 0; color: var(--ink-soft); }
.disclaimer {
  background: var(--accent-soft); border: 1px solid rgba(196,92,38,0.35);
  color: #7a3a14; font-size: 12px; font-weight: 650; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px;
}
.prod-cab { margin: 12px 0; }
.prod-cab h4 { font-size: 13px; color: var(--accent); margin-bottom: 4px; }

.chat-card { display: flex; flex-direction: column; min-height: 180px; }
.chat-log { flex: 1; max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.bubble { font-size: 13px; line-height: 1.4; padding: 7px 10px; border-radius: 10px; max-width: 95%; }
.bubble.bot { background: rgba(13,92,86,0.1); color: var(--ink); }
.bubble.user { background: var(--teal); color: #fff; align-self: flex-end; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; }
.understood { font-size: 12px; color: var(--teal-deep); background: var(--teal-soft); padding: 6px 8px; border-radius: 8px; margin-top: 6px; }

.loading {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: #e8efe9; transition: opacity 0.4s;
}
.loading.hide { opacity: 0; pointer-events: none; }
.loading span { color: var(--teal); font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase; }

.dim-layer { position: absolute; inset: 0; pointer-events: none; display: none; }
.dim-layer.on { display: block; }
.dim-label {
  position: absolute; transform: translate(-50%, -50%);
  background: rgba(247,244,239,0.92); border: 1px solid rgba(13,92,86,0.35);
  color: var(--ink); font: 650 11px/1.2 var(--font); padding: 2px 6px; border-radius: 6px; white-space: nowrap;
}
.dim-label.overall { color: var(--teal); font-size: 12px; }
.dim-label.item { color: var(--accent); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 820px) {
  :root { --side-w: 100%; }
  #stage { right: 0; bottom: 46vh; }
  .topbar { right: 0; }
  .side { top: auto; height: 46vh; border-left: none; border-top: 1px solid var(--panel-border); }
  .warnings { right: 12px; bottom: calc(46vh + 50px); }
  .view-bar { bottom: calc(46vh + 8px); }
  .steps button { padding: 5px 7px; font-size: 11px; }
  .brand h1 { font-size: 14px; }
  #btnSample, #btnReset { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .choice .blurb { display: none; }
}

@media print {
  html, body { overflow: auto; height: auto; background: #fff; }
  #app { display: none !important; }
  #printRoot { display: block !important; position: static; padding: 16px; color: #111; font: 12px/1.4 var(--font); }
  #printRoot h1 { font-size: 20px; color: #0d5c56; }
  #printRoot h2 { font-size: 14px; margin-top: 16px; }
  #printRoot table { width: 100%; border-collapse: collapse; }
  #printRoot th, #printRoot td { border: 1px solid #ccc; padding: 3px 5px; }
  .disclaimer { background: #f5e6dc; }
}
