:root {
  --bg: #1c1714;
  --panel: #262019;
  --panel2: #2f281f;
  --line: #3d342a;
  --text: #f2ebe2;
  --muted: #b3a594;
  --accent: #c8853a;
  --accent2: #e0a45a;
  --brand-green: #8aa783;          /* the "Envy" green in the DrawerEnvy logo */
  --ok: #6fbf73;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .3px; }
header h1 span { color: var(--brand-green); font-weight: 700; }   /* match the logo wordmark */
header .tag {
  margin-left: auto; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px; padding: 3px 10px;
}

/* =================== Phase 3 buyer-flow shell =================== */
/* autosave chip in the header */
.save-status { margin-left: auto; font-size: 12px; min-width: 60px;
  text-align: right; color: var(--muted); }
.save-status.saving { color: var(--accent2); }
.save-status.saved { color: var(--ok); }
header .tag { margin-left: 12px; }   /* sits just right of the save chip */

/* step bar */
#step-indicator {
  display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto;
  border-bottom: 1px solid var(--line); background: var(--panel2);
}
#step-indicator .step {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  font-size: 13px; padding: 6px 13px; border-radius: 20px; cursor: pointer;
  white-space: nowrap;
}
#step-indicator .step b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 700;
  background: var(--line); color: var(--text);
}
#step-indicator .step:hover { color: var(--text); }
#step-indicator .step.active { color: var(--text); border-color: var(--accent); }
#step-indicator .step.active b { background: var(--accent); color: #fff; }

/* screen router: one screen visible at a time, filling the space below the bar */
#flow-root { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { display: none; min-height: 0; }
.screen.is-active { display: block; flex: 1; }
#screen-design.is-active { display: flex; flex-direction: column; }

/* stub screens (Landing / Capture / Confirm / Review until each is built) */
.screen-stub.is-active { display: flex; align-items: center; justify-content: center; padding: 24px; }
.stub-card {
  max-width: 460px; text-align: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px 26px;
}
.stub-card h2 { margin: 0 0 10px; font-size: 20px; }
.stub-card p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 18px; }
.stub-card em { color: var(--accent2); font-style: normal; }
.stub-go {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.stub-go:hover { background: var(--accent2); }

main { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }

/* ---- form panel ---- */
#panel { background: var(--panel); border-right: 1px solid var(--line);
         overflow-y: auto; padding: 18px; }
#panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px;
            color: var(--muted); margin: 20px 0 10px; }
.fields { display: grid; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { margin-bottom: 6px; }
.field label { font-size: 13px; color: var(--text); }
.field label small { color: var(--muted); font-weight: 400; }
.field .help { font-size: 11px; color: var(--muted); }
.field .row { display: flex; align-items: center; gap: 8px; }
.field input[type="text"], .field input[type="number"], .field select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; width: 100%;
}
.field .unit { font-size: 12px; color: var(--muted); min-width: 26px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
/* ▲▼ 1/8" steppers on the drawer-size fields */
.dim-spin { display: inline-flex; flex-direction: column; flex: 0 0 auto; }
.dim-btn { background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  width: 28px; height: 17px; line-height: 1; font-size: 9px; padding: 0; cursor: pointer; }
.dim-btn[data-dir="1"] { border-radius: 6px 6px 0 0; }
.dim-btn[data-dir="-1"] { border-radius: 0 0 6px 6px; border-top: none; }
.dim-btn:hover { color: var(--text); border-color: var(--accent); background: var(--line); }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

details#advanced { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 8px; }
details#advanced summary { cursor: pointer; font-size: 13px; color: var(--accent2);
  text-transform: uppercase; letter-spacing: .6px; padding: 8px 0; }
details#advanced[open] .fields { margin-top: 8px; }

#generate-btn {
  margin-top: 20px; width: 100%; padding: 12px; font-size: 15px; font-weight: 600;
  color: #fff; background: var(--accent); border: none; border-radius: 10px;
  cursor: pointer;
}
#generate-btn:hover { background: var(--accent2); }
#generate-btn:disabled { opacity: .55; cursor: default; }

#save-btn {
  margin-top: 10px; width: 100%; padding: 10px; font-size: 14px; font-weight: 600;
  color: var(--accent2); background: transparent; border: 1px solid var(--accent);
  border-radius: 10px; cursor: pointer;
}
#save-btn:hover { background: rgba(200,133,58,0.14); }
#save-btn:disabled { opacity: .55; cursor: default; }

.save-new { margin-top: 6px; font-size: 11px; color: var(--muted); text-align: center; }
.save-new a { color: var(--accent2); text-decoration: none; }
.save-new a:hover { text-decoration: underline; }
.save-new.hidden { display: none; }

/* ---- box library (Phase 2): thumbnail gallery under the 3D ---- */
.library {
  border-top: 1px solid var(--line); background: var(--panel);
  padding: 8px 20px 10px;
}
.library.hidden { display: none; }
.lib-head { font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin-bottom: 6px; }
.lib-cards { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.lib-card {
  flex: 0 0 auto; width: 150px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.lib-card img, .lib-thumb-empty {
  width: 100%; height: 96px; object-fit: cover; display: block;
  background: #20180f; cursor: pointer; border: none;
}
.lib-card .lib-name {
  font-size: 12px; font-weight: 600; padding: 6px 8px 0; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-card .lib-meta { font-size: 10.5px; color: var(--muted); padding: 1px 8px 4px; }
.lib-card .lib-actions { display: flex; gap: 2px; padding: 0 4px 6px; }
.lib-actions button {
  flex: 1; background: transparent; border: none; color: var(--accent2);
  font-size: 10.5px; cursor: pointer; padding: 3px 2px; border-radius: 6px;
}
.lib-actions button:hover { background: rgba(224,164,90,0.12); }
.lib-actions button.danger { color: #d9433a; }

/* ---- stage ---- */
#stage { display: flex; flex-direction: column; min-height: 0; }
#viewer { flex: 1; min-height: 0; position: relative; }
/* canvas fills its container regardless of buffer/DPR (three.js renders with
   updateStyle=false, so without this the canvas displays at buffer size and
   overflows on high-DPR / mobile) */
#viewer canvas { display: block; width: 100% !important; height: 100% !important; }
#dim-toggle {
  position: absolute; top: 12px; right: 14px; z-index: 5;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text);
  background: rgba(20,16,12,0.72); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; user-select: none;
}
#dim-toggle input { accent-color: var(--accent); cursor: pointer; }

/* Box <-> assembled Drawer view toggle (Phase 3) */
#view-toggle {
  position: absolute; top: 12px; left: 14px; z-index: 5;
  display: inline-flex; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: rgba(20,16,12,0.72);
}
#view-toggle button {
  border: none; background: transparent; color: var(--muted);
  font-size: 12px; padding: 5px 14px; cursor: pointer;
}
#view-toggle button.active { background: var(--accent); color: #fff; }
#view-toggle button:not(.active):hover { color: var(--text); }

/* "Make photorealistic" button — only shown on the Photo tab */
#photoreal-btn {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  border: none; border-radius: 8px; padding: 7px 16px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #2a1c08;
  background: linear-gradient(180deg, #ffd479, #e0a45a);
  box-shadow: 0 3px 12px rgba(0,0,0,0.4);
}
#photoreal-btn:hover { background: linear-gradient(180deg, #ffdf94, #e8b06a); }
#photoreal-btn:disabled { opacity: .7; cursor: default; }
#photoreal-btn.hidden { display: none; }

/* full-viewer overlay that shows the returned photorealistic image */
#photoreal-overlay {
  position: absolute; inset: 0; z-index: 7; background: #15110e;
  display: flex; align-items: center; justify-content: center;
}
#photoreal-overlay.hidden { display: none; }
#photoreal-overlay img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
#photoreal-overlay .pr-back, #photoreal-overlay .pr-dl {
  position: absolute; top: 12px; z-index: 8;
  font-size: 12px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(20,16,12,0.82); color: var(--text);
  text-decoration: none;
}
#photoreal-overlay .pr-back { left: 14px; }
#photoreal-overlay .pr-dl { right: 14px; color: var(--accent2); }
#photoreal-overlay .pr-back:hover, #photoreal-overlay .pr-dl:hover { border-color: var(--accent); }

/* on-screen camera controls for the assembled views */
#nav-pad {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  user-select: none;
}
#nav-pad.hidden { display: none; }
#nav-pad .nav-row { display: flex; gap: 4px; }
#nav-pad button {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(20,16,12,0.78);
  color: var(--text); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
#nav-pad button:hover { background: rgba(200,133,58,0.35); }
#nav-pad button:active { background: var(--accent); }

/* manufacturability warning overlaid on the 3D (e.g. divider crowds the handle) */
.warn-banner {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 6;
  background: rgba(150,33,24,0.94); color: #ffe2db;
  border: 1px solid #d9433a; border-radius: 8px;
  padding: 9px 12px; font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.warn-banner.hidden { display: none; }

.readout {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 10px 20px; border-top: 1px solid var(--line);
  background: var(--panel); font-size: 13px; color: var(--muted);
}
.readout b { color: var(--text); font-weight: 600; }

.result {
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel2);
  font-size: 14px; max-height: 34%; overflow-y: auto;
}
.result.hidden { display: none; }
.result h3 { margin: 0 0 8px; font-size: 14px; }
.result .links a {
  display: inline-block; margin-right: 10px; margin-bottom: 6px;
  color: #fff; background: var(--accent); padding: 6px 12px; border-radius: 8px;
  text-decoration: none; font-size: 13px;
}
.result .links a.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); }
.result .meta { color: var(--muted); font-size: 12px; margin-top: 6px; word-break: break-all; }
.result.error { background: #3a201c; color: #ffd9d2; }
.result ul { margin: 6px 0 0; padding-left: 18px; columns: 2; font-size: 12px; color: var(--muted); }

/* ---- per-section divider sizes ---- */
.section-sizes { margin-top: 6px; }
.section-sizes .sizes-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.section-sizes .sizes-row { display: flex; gap: 5px; flex-wrap: wrap; }
.section-sizes .sizes-row input {
  width: 58px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 6px 7px; font-size: 13px;
}
.section-sizes .sizes-row input:focus { outline: none; border-color: var(--accent); }
.section-sizes .sizes-row input.auto {
  color: var(--accent2); border-style: dashed; opacity: .9; cursor: default;
}

/* =============== Screen 1 · Landing hero =============== */
.landing.is-active { display: flex; }
.landing-hero {
  flex: 1; min-height: 0; width: 100%;
  display: grid; grid-template-columns: 1.05fr 0.95fr;
}
.hero-media {
  position: relative; min-height: 0; overflow: hidden;
  /* warm wood-tone placeholder shown until a real photo is dropped in */
  background: linear-gradient(135deg, #3a2a1c 0%, #5a3e26 45%, #241a12 100%);
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; }
.hero-img.missing { display: none; }
.hero-copy {
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  padding: 6vw 5vw; max-width: 640px;
}
.hero-prelaunch { margin: 0; align-self: flex-start; font-size: 12px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; color: var(--accent2);
  background: rgba(224,164,90,0.14); border: 1px solid rgba(224,164,90,0.4);
  border-radius: 20px; padding: 5px 12px; }
.hero-headline { margin: 0; font-weight: 700; letter-spacing: -0.5px;
  font-size: clamp(24px, 3vw, 34px); line-height: 1.12; }
.hero-headline .nowrap { white-space: nowrap; }   /* keep the promise on one line */
.hero-value { margin: 0; color: var(--muted); max-width: 32em;
  font-size: clamp(15px, 1.5vw, 18px); line-height: 1.55; }
.hero-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 6px; }
.hero-cta {
  background: var(--accent); color: #fff; border: none; border-radius: 12px;
  padding: 15px 30px; font-size: 17px; font-weight: 700; cursor: pointer; min-height: 44px;
}
.hero-cta:hover { background: var(--accent2); }
.hero-resume { color: var(--accent2); text-decoration: none; font-size: 14px; }
.hero-resume:hover { text-decoration: underline; }
.hero-resume.hidden { display: none; }
/* "patent pending" note — snap-a-photo design (US provisional 63/991,585) +
   modular magnetic connection (US provisional 64/000,315) */
.hero-learn { margin: 0; }
.hero-learn a { color: var(--accent2); font-weight: 600; font-size: 15px; text-decoration: none;
  border-bottom: 1px solid rgba(224,164,90,0.4); padding-bottom: 1px; }
.hero-learn a:hover { border-bottom-color: var(--accent2); }
.hero-patent { margin: -6px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.hero-patent svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; opacity: .85; }
.hero-patent b { color: var(--text); font-weight: 600; white-space: nowrap; }

/* DrawerEnvy brand logo (mark + wordmark) — sits atop the hero copy */
.brand-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.brand-mark { width: 56px; height: 56px; flex: 0 0 auto; }
.brand-words { line-height: 1.05; }
.brand-name { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 30px; font-weight: 600; color: var(--text); letter-spacing: 0; line-height: 1; }
.brand-name span { color: var(--brand-green); font-weight: 700; }   /* the brand green for "Envy" */
.brand-tag { margin-top: 4px; font-size: 11px; letter-spacing: 1.6px;
  color: var(--muted); text-transform: uppercase; }

/* Screen-1 login / sign-up card (an account is required) */
#hero-go[hidden], #hero-welcome[hidden], #auth-card[hidden] { display: none; }
.auth-card { display: flex; flex-direction: column; gap: 8px; max-width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 16px; }
.auth-tabs { display: flex; gap: 6px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; margin-bottom: 6px; }
.auth-tab { flex: 1; background: transparent; border: none; border-radius: 7px; padding: 9px 8px;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.auth-input { background: #1c1714; border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 12px; color: var(--text); font-size: 15px; }
.auth-input:focus { outline: none; border-color: var(--accent2); }
/* show / hide the password */
.auth-pw-wrap { position: relative; display: flex; }
.auth-pw-wrap .auth-input { flex: 1; min-width: 0; padding-right: 58px; }
.auth-pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--accent2); font: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer; padding: 5px 7px; border-radius: 6px; }
.auth-pw-toggle:hover { text-decoration: underline; }
.auth-hint { font-size: 12px; color: var(--muted); min-height: 0; }
.auth-hint:empty { display: none; }
.auth-err { font-size: 13px; color: #e08a6a; }
.auth-err:empty { display: none; }
.auth-submit { margin-top: 6px; width: 100%; }
.auth-foot { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.hero-welcome { margin: 0; font-size: 14px; color: var(--muted); }
.hero-welcome b { color: var(--text); font-weight: 600; }
.hero-welcome a { color: var(--accent2); text-decoration: none; }
.hero-welcome a:hover { text-decoration: underline; }
/* signed out: the step bar (2–6) isn't reachable until you log in */
body.logged-out #step-indicator { opacity: .45; pointer-events: none; }

/* =============== Responsive breakpoints (FR-PLT-007) =============== */
/* Large desktop: keep the Landing from becoming uncomfortably wide */
@media (min-width: 1441px) {
  .landing-hero { max-width: 1320px; margin: 0 auto; }
}

/* Tablet and below: the Landing stacks (media over copy) */
@media (max-width: 900px) {
  .landing-hero { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .hero-copy { padding: 32px 24px; max-width: none; }
}

/* Mobile (<768): compact chrome + the box editor becomes one scrolling column */
@media (max-width: 767px) {
  header { padding: 10px 14px; gap: 10px; }
  header h1 { font-size: 16px; }
  header .tag { display: none; }
  .save-status { min-width: 46px; }
  #step-indicator { padding: 6px 8px; }
  #step-indicator .step { padding: 5px 9px; font-size: 12px; gap: 6px; }
  #step-indicator .step b { width: 18px; height: 18px; }

  /* the box editor (Screen 4) stacks: form, then the 3D with a real height */
  #screen-design.is-active { display: block; overflow-y: auto; }
  #screen-design > main { display: block; }
  #panel { overflow: visible; border-right: none; border-bottom: 1px solid var(--line); }
  #stage { display: block; }
  #viewer { height: 64vh; min-height: 320px; }

  .landing-hero { grid-template-rows: 38vh 1fr; }
  .hero-headline { font-size: clamp(21px, 6vw, 28px); }
}

/* =============== Screen 2 · Capture & Describe =============== */
.hero-cta:disabled { opacity: .5; cursor: default; }

.capture.is-active { display: block; overflow-y: auto; }
.capture-inner { max-width: 860px; margin: 0 auto; padding: 26px 22px 60px; }
.capture-title { margin: 0 0 6px; font-size: clamp(20px, 3vw, 26px); }
.capture-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* drawer-type selector (required) */
.drawer-type { margin: 0 0 20px; }
.dt-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.dt-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dt-opt { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 10px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  transition: border-color .12s, background .12s; }
.dt-opt:hover { border-color: var(--accent); }
.dt-opt.active { border-color: var(--accent2); background: var(--panel2);
  box-shadow: 0 0 0 2px rgba(224,164,90,0.25); }
.dt-opt .dt-ico { font-size: 16px; }
.dt-opt small { color: var(--muted); }

/* wood picker (sample images) */
.wood-pick { margin: 0 0 20px; }
.wood-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.wood-opt { display: flex; flex-direction: column; align-items: stretch; gap: 7px;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 8px; font: inherit; color: var(--text); cursor: pointer;
  transition: border-color .12s, background .12s; }
.wood-opt:hover { border-color: var(--accent); }
.wood-opt.active { border-color: var(--accent2); background: var(--panel2);
  box-shadow: 0 0 0 2px rgba(224,164,90,0.25); }
.wood-swatch { display: block; aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden;
  background: #2a221b; }
.wood-swatch img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wood-name { font-size: 13px; font-weight: 600; text-align: center; }
@media (max-width: 560px) { .wood-options { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .dt-options { grid-template-columns: repeat(2, 1fr); } }

.measure-guide { margin: 0 0 18px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.measure-svg { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; }
.measure-guide figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.measure-guide b { color: var(--text); }

.unit-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.unit-row-label { font-size: 13px; color: var(--muted); }
.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.unit-btn { border: none; background: transparent; color: var(--muted);
  padding: 7px 16px; font-size: 13px; cursor: pointer; min-height: 36px; }
.unit-btn.active { background: var(--accent); color: #fff; }
.unit-btn:not(.active):hover { color: var(--text); }

.dims-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.err { color: #ef9a8f; font-size: 11.5px; line-height: 1.35; margin-top: 3px; min-height: 0; }
.provisional-note { font-size: 11px; color: var(--muted); font-style: italic; margin: 8px 0 0; }

.intent-field { margin-top: 22px; }
.intent-field textarea {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 14px;
  width: 100%; resize: vertical; min-height: 64px;
}
.intent-field textarea:focus { outline: none; border-color: var(--accent); }

.capture-actions { margin-top: 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.gate-msg { font-size: 12px; color: var(--muted); }

/* Screen 2 two-pane (desktop) → stacked (mobile) */
.capture-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.capture-pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.pane-h { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.pane-h small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.pane-sub { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.capture-pane .unit-row { margin-top: 0; }
@media (max-width: 760px) { .capture-grid { grid-template-columns: 1fr; gap: 16px; } }

/* photo upload */
.photo-drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 18px 14px;
  text-align: center; transition: border-color .15s, background .15s; }
.photo-drop.drag { border-color: var(--accent); background: rgba(200,133,58,0.10); }
.photo-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.photo-btn { background: var(--panel2); border: 1px solid var(--accent); color: var(--accent2);
  border-radius: 9px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 40px; }
.photo-btn:hover { background: rgba(200,133,58,0.14); }
.photo-take { display: none; }                              /* touch devices only */
@media (pointer: coarse) { .photo-take { display: inline-flex; align-items: center; } }
.photo-hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.photo-coverage { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

/* thumbnail strip */
.photo-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-card { width: 84px; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: var(--panel2); }
.photo-card img { width: 100%; height: 64px; object-fit: cover; display: block; }
.photo-card-bar { display: flex; }
.photo-icon { flex: 1; border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 11px; padding: 5px 0; }
.photo-icon:hover:not(:disabled) { background: rgba(200,133,58,0.14); color: var(--text); }
.photo-icon:disabled { opacity: .3; cursor: default; }
.photo-icon.danger { color: #d9433a; }

/* =============== Screen 3 · Confirm & Prioritize =============== */
.confirm-screen.is-active { display: block; overflow-y: auto; }

/* AI assistant panel */
.ai-panel { border: 1px solid var(--accent); border-radius: 12px; padding: 14px;
  margin-bottom: 18px; background: linear-gradient(180deg, rgba(200,133,58,0.10), var(--panel)); }
.ai-panel.hidden { display: none; }
.ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ai-badge { font-size: 12px; font-weight: 700; color: #2a1c08; border-radius: 20px;
  padding: 3px 11px; background: linear-gradient(180deg, #ffd479, #e0a45a); }
.ai-model { font-size: 11px; color: var(--muted); }
.ai-status-note { font-size: 11.5px; color: var(--muted); }
.ai-transcript { display: flex; flex-direction: column; gap: 6px; max-height: 220px;
  overflow-y: auto; margin-bottom: 10px; }
.ai-bubble { font-size: 13px; line-height: 1.45; padding: 8px 11px; border-radius: 10px; max-width: 88%; }
.ai-assistant { background: var(--panel2); border: 1px solid var(--line); color: var(--text); align-self: flex-start; }
.ai-user { background: var(--accent); color: #fff; align-self: flex-end; }
.ai-thinking { color: var(--muted); font-style: italic; }
.ai-form { display: flex; gap: 6px; }
.ai-form #ai-input { flex: 1; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.ai-form #ai-input:focus { outline: none; border-color: var(--accent); }
.ai-form .photo-btn { min-height: 40px; }
.ai-form #ai-input:disabled, .ai-form #ai-send:disabled { opacity: .55; cursor: default; }
.confirm-inner { max-width: 760px; margin: 0 auto; padding: 26px 22px 60px; }
.confirm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 760px) { .confirm-grid { grid-template-columns: 1fr; gap: 16px; } }
.rank-hint { font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 400; float: right; }

/* categorized item picker (tap a chip to select / deselect) */
.item-cat { margin-bottom: 12px; }
.cat-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 6px; }
.item-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.item-chip { background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 16px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; min-height: 34px; }
.item-chip:hover { border-color: var(--accent); }
.item-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.item-chip.has-desc { display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  text-align: left; border-radius: 12px; padding: 7px 12px; font-weight: 400; }
.chip-name { font-size: 12.5px; font-weight: 600; }
.chip-desc { font-size: 10px; color: var(--muted); }
.item-chip.has-desc.active .chip-desc { color: rgba(255,255,255,0.85); }

/* "add your own" form (no quantity) */
.add-help { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.add-help b { color: var(--text); }
.item-add { display: flex; gap: 6px; }
.item-add #item-name { flex: 1; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.item-add input:focus { outline: none; border-color: var(--accent); }
.item-add .photo-btn { min-height: 38px; padding: 8px 16px; }

/* ranked item list */
.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item-row { display: flex; align-items: center; gap: 8px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.item-row.dragging { opacity: .45; }
.item-row.drag-over { border-color: var(--accent); box-shadow: 0 -2px 0 var(--accent) inset; }
.drag-handle { color: var(--muted); cursor: grab; font-size: 15px; line-height: 1; }
.item-rank { width: 18px; height: 18px; flex: 0 0 auto; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; }
.item-name { flex: 1; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row-actions { display: flex; gap: 1px; }
.item-icon { border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 4px 6px; border-radius: 6px; min-width: 26px; }
.item-icon:hover:not(:disabled) { background: rgba(200,133,58,0.14); color: var(--text); }
.item-icon:disabled { opacity: .3; cursor: default; }
.item-icon.danger { color: #d9433a; }
.item-empty { font-size: 12.5px; color: var(--muted); margin: 4px 2px; }
.manual-note { font-size: 11px; color: var(--muted); font-style: italic; margin: 12px 0 0; }

/* =============== Screen 4 · Design (three selectable variants) =============== */
#screen-design.is-active { display: block; overflow-y: auto; }
.design-view { max-width: 1040px; margin: 0 auto; padding: 24px 22px 56px; }
.design-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.design-head h2 { margin: 0; font-size: 20px; }
.design-dims { font-size: 12px; color: var(--muted); }
.design-note { margin-top: 16px; font-size: 12px; color: var(--muted); font-style: italic; }
.design-msg { padding: 48px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.design-excluded { margin: 0 0 14px; font-size: 12px; color: #ef9a8f; }
/* the three design categories (Grid / Asymmetrical / Pinwheel), 3 designs each */
.design-cat { margin: 22px 0 6px; }
.design-cat-head { border-bottom: 1px solid var(--line); padding-bottom: 7px; margin-bottom: 14px; }
.design-cat-head h3 { margin: 0; font-size: 16px; color: var(--text); }
.design-cat-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.design-reply { margin: 0 0 16px; padding: 11px 14px; font-size: 13px; line-height: 1.45;
  color: var(--text); background: var(--panel2); border: 1px solid var(--accent);
  border-radius: 10px; }

/* accumulating numbered design cards */
.design-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.design-card {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 14px;
}
.dc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dc-num { font-size: 14px; font-weight: 700; color: var(--accent2); white-space: nowrap; }
.dc-sum { font-size: 11px; color: var(--muted); text-align: right; line-height: 1.35; }
.dc-plan { background: #221c16; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.dc-plan svg { display: block; height: auto; }
.dc-info { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.dc-info li { font-size: 10.5px; color: var(--muted); line-height: 1.35; }
.dc-info li b { color: var(--text); font-weight: 600; }
.dc-exc { font-size: 11px; color: #ef9a8f; }
.dc-choose { align-self: flex-start; margin-top: 2px; }

.primary-cta { background: var(--accent); color: #fff; border: none; border-radius: 24px;
  padding: 12px 30px; font-size: 15px; font-weight: 600; cursor: pointer; }
.primary-cta:hover { background: var(--accent2); }
.primary-cta.sm { padding: 8px 18px; font-size: 13px; }

/* the "generate 3 more" panel */
.design-regen { margin-top: 24px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.design-regen label { font-size: 13px; color: var(--text); }
.design-regen textarea { width: 100%; resize: vertical; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit; font-size: 13px; }
.design-regen textarea:focus { outline: none; border-color: var(--accent); }
#regen-btn { align-self: flex-start; background: var(--accent); color: #fff; border: none;
  border-radius: 22px; padding: 10px 22px; font-size: 14px; font-weight: 600; cursor: pointer; }
#regen-btn:hover:not(:disabled) { background: var(--accent2); }
#regen-btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 860px) { .design-list { grid-template-columns: 1fr; } }

/* =============== "Thinking" transition (Screen 3 → 4) =============== */
.thinking-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 38%, var(--panel) 0%, var(--bg) 72%);
  animation: thinkFade .25s ease;
}
.thinking-overlay.hidden { display: none; }
.thinking-inner { text-align: center; padding: 24px; animation: thinkPulse 2.6s ease-in-out infinite; }
.thinking-art { width: 188px; height: auto; display: block; margin: 0 auto; }
.td-ring { transform-box: fill-box; transform-origin: center; animation: thinkSpin 3.4s linear infinite; }
.td-box { animation: thinkGlow 2.6s ease-in-out infinite; }
.td-div { fill: none; stroke: var(--accent2); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 100; animation: thinkDraw 1.9s ease-in-out infinite; }
.td-item { fill: var(--accent); opacity: 0; transform-box: fill-box; transform-origin: center;
  animation: thinkPop 1.9s ease-in-out infinite; }
.thinking-title { margin-top: 20px; font-size: 18px; font-weight: 700; color: var(--text);
  letter-spacing: .2px; }
.thinking-status { margin-top: 6px; font-size: 13px; color: var(--accent2); min-height: 18px;
  animation: thinkBlink 1.4s ease-in-out infinite; }
@keyframes thinkSpin { to { transform: rotate(360deg); } }
@keyframes thinkDraw { 0% { stroke-dashoffset: 100; } 35% { stroke-dashoffset: 0; }
  70% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -100; } }
@keyframes thinkPop { 0%, 22% { opacity: 0; transform: scale(.2); }
  44% { opacity: 1; transform: scale(1); } 82% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }
@keyframes thinkPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes thinkGlow { 0%, 100% { opacity: .82; } 50% { opacity: 1; } }
@keyframes thinkBlink { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
@keyframes thinkFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .td-ring, .td-div, .td-item, .thinking-inner, .thinking-status { animation: none; }
  .td-item { opacity: 1; }
}

/* =============== Screen 5 · Refine (chosen design + tap-to-edit) =============== */
#screen-refine.is-active { display: block; overflow-y: auto; }
.refine-mode .box-editor-host { display: none; }              /* editor hidden until a box is tapped */
.refine-view { max-width: 820px; margin: 0 auto; padding: 22px 22px 56px; }
.refine-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.refine-head h2 { margin: 0 0 2px; font-size: 19px; }
.refine-actions { display: flex; gap: 8px; }
/* shared top-right stage navigation across Screens 2–6 (Gil: consistent flow) */
.stage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.stage-head > div:first-child { min-width: 0; }
.stage-nav { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.stage-nav .primary-cta[disabled], .primary-cta.sm[disabled] { opacity: .45; cursor: not-allowed; }
.design-card.chosen { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(224,164,90,0.32); }
.design-card.chosen .dc-plan { outline: 1px solid var(--accent2); outline-offset: -1px; }
.ghost-btn { background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 22px; padding: 8px 16px; font-size: 13px; cursor: pointer; }
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.refine-canvas { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; align-items: center; }
.refine-canvas svg { height: auto; display: block; max-width: 100%; overflow: visible; }
.refine-front { margin-top: 6px; font-size: 11px; color: var(--muted); letter-spacing: .4px; }
.refine-draghint { margin-top: 8px; font-size: 11px; color: var(--accent); opacity: .85; letter-spacing: .2px; }
/* Screen-5 divider-style chooser (Straight vs Angled, with previews) */
.refine-divstyle { margin: 16px 0 0; }
.rds-head { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.ds-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 420px; }
.ds-card { display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 8px 10px 9px; color: var(--text); text-align: center; cursor: pointer; font: inherit; }
.ds-card.active { border-color: var(--accent2); background: var(--panel2);
  box-shadow: 0 0 0 2px rgba(224,164,90,0.25); }
.ds-card:not(.active) { opacity: .6; }     /* the current style stands out; tap either to set the drawer */
.ds-card:hover { opacity: 1; border-color: var(--accent); }
.ds-img { width: 100%; height: auto; background: #1c1714; border-radius: 6px; padding: 4px; }
.ds-name { font-size: 13px; font-weight: 700; margin-top: 4px; }
.ds-desc { font-size: 11px; color: var(--muted); }
.rds-mixed { font-size: 12px; font-weight: 400; color: var(--muted); }
.rds-note { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
.rds-note b { color: var(--text); font-weight: 600; }
/* draggable wall grips: invisible until hovered, sit exactly on the plan's walls */
.wall-grip { fill: transparent; pointer-events: all; transition: fill .1s ease; }
.wall-grip.wall-v { cursor: ew-resize; }
.wall-grip.wall-h { cursor: ns-resize; }
.wall-grip:hover { fill: rgba(224, 164, 90, 0.34); }
body.wall-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
body.wall-dragging .wall-grip:hover { fill: rgba(224, 164, 90, 0.5); }
/* interior slot/row divider grips — same drag feel as walls, lighter highlight */
.div-grip { fill: transparent; pointer-events: all; transition: fill .1s ease; }
.div-grip.div-v { cursor: ew-resize; }
.div-grip.div-h { cursor: ns-resize; }
.div-grip:hover, body.wall-dragging .div-grip:hover { fill: rgba(240, 220, 150, 0.45); }
@media (hover: none) { .wall-grip, .div-grip { pointer-events: none; } .refine-draghint { display: none; } }
/* ✎ edit button beside each number badge in the plan */
.plan-edit-btn { cursor: pointer; }
.plan-edit-btn circle { transition: fill .1s ease; }
.plan-edit-btn:hover circle, .plan-edit-btn:focus circle { fill: #3a2c1d; }
.plan-edit-btn:focus { outline: none; }
.plan-edit-btn:focus circle { stroke-width: 2; }
/* locked Width/Length fields in the box editor (footprint owned by the layout) */
.field.locked input { opacity: .55; cursor: not-allowed; }
.field.locked label { opacity: .7; }
.lock-note { margin-top: 3px; font-size: 11px; color: var(--accent); opacity: .85; }
/* Screen-5 "edit by asking" assistant */
.refine-assist { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 14px; }
.ra-head { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ra-sub { font-size: 11px; font-weight: 400; color: var(--muted); }
.ra-chat { max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.ra-hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.ra-msg { font-size: 12.5px; line-height: 1.4; padding: 7px 10px; border-radius: 10px; max-width: 88%; }
.ra-you { align-self: flex-end; background: var(--accent); color: #1c1714; border-bottom-right-radius: 3px; }
.ra-ai { align-self: flex-start; background: #2a221b; color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.ra-form { display: flex; gap: 8px; }
.ra-form input { flex: 1; min-width: 0; background: #1c1714; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font-size: 13px; }
.ra-form input:focus { outline: none; border-color: var(--accent); }
.ra-form input:disabled { opacity: .6; }
.ra-form button:disabled { opacity: .5; cursor: default; }
/* numbered, stacked container list (each section matches a numbered box above) */
.refine-listhead { margin: 18px 0 10px; font-size: 12px; color: var(--muted); }
.refine-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.refine-item { display: flex; align-items: flex-start; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.ri-num { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: #1c1714; border: 1.3px solid var(--accent2); color: var(--text);
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.ri-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ri-title { font-size: 14px; font-weight: 700; }
.ri-size { font-size: 12px; color: var(--accent2); }
.ri-comp { font-size: 12px; color: var(--muted); line-height: 1.4; }
.ri-items { font-size: 12px; color: var(--text); line-height: 1.4; }
.ri-items b { color: var(--muted); font-weight: 600; }
.ri-edit { flex: 0 0 auto; align-self: center; }
/* per-container resize steppers (move shared walls) */
.ri-resize { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.ri-rl { font-size: 11px; color: var(--muted); margin-left: 4px; }
.ri-rl:first-child { margin-left: 0; }
.ri-rv { font-size: 12px; color: var(--text); min-width: 42px; text-align: center; }
.ri-step { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 15px; line-height: 1; cursor: pointer; padding: 0; }
.ri-step:hover { border-color: var(--accent2); color: var(--accent2); }
/* per-box "add a handle" toggle (marked on the 2D plan when on) */
.ri-handlerow { margin-top: 8px; }
.ri-handle { background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 16px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.ri-handle:hover { border-color: var(--accent2); color: var(--text); }
.ri-handle.on { background: rgba(224,164,90,0.18); border-color: var(--accent2); color: var(--accent2); font-weight: 600; }

/* editing mode: the reused box editor fills the screen, plan hidden */
#screen-refine.is-active.editing { display: flex; flex-direction: column; overflow: hidden; }
.refine-mode.editing .refine-view { display: none; }
.refine-mode.editing .box-editor-host { display: grid; flex: 1; min-height: 0; }
.refine-edit-bar { display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel2); }
.refine-edit-bar .reb-title { font-size: 13px; color: var(--muted); }
.refine-edit-bar .reb-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
/* hide the library/dev chrome of the reused editor inside the buyer flow
   (the buyer doesn't generate laser files or save to the dev library here) */
#screen-refine #view-toggle, #screen-refine #library,
#screen-refine #save-btn, #screen-refine #save-new-link,
#screen-refine #generate-btn { display: none; }

/* "See assembled drawer in 3D" button, just above the 2D plan */
.refine-viewbar { display: flex; justify-content: center; margin-bottom: 12px; }

/* assembled mode: the 3D host fills the screen (no single-box form), with a
   library strip of every box below it */
#screen-refine.is-active.assembled { display: flex; flex-direction: column; overflow: hidden; }
.refine-mode.assembled .refine-view { display: none; }
/* minmax(0,1fr) + min-width:0 let the 3D column shrink below the canvas's intrinsic
   width (else the grid track grows to the canvas buffer size and overflows on mobile) */
.refine-mode.assembled .box-editor-host { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; min-height: 0; }
.refine-mode.assembled #stage { min-width: 0; }
.refine-mode.assembled #panel { display: none; }            /* no single-box form in the assembled view */
/* the editor's single-box chrome describes one box — hide it in the whole-drawer view */
.refine-mode.assembled #dim-toggle, .refine-mode.assembled #readout { display: none; }
.refine-library { flex: 0 0 auto; background: var(--panel2); border-top: 1px solid var(--line); padding: 10px 14px; }
.rl-head { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.rl-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.rl-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; min-width: 130px; text-align: left; }
.rl-chip:hover { border-color: var(--accent); }
.rl-num { width: 22px; height: 22px; border-radius: 50%; background: #1c1714; border: 1.3px solid var(--accent2);
  color: var(--text); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rl-name { font-size: 13px; font-weight: 700; color: var(--text); }
.rl-size { font-size: 11px; color: var(--accent2); }

/* ---- Screen-5 3D pages on phones. The single-box editor AND the assembled
   whole-drawer 3D both live inside #screen-refine now (the old mobile collapse
   only targeted Screen 4). Without this the 360px form fills the viewport and the
   3D sits off-screen — Gil saw only the left panel. Collapse the 360px/1fr editor
   grid to one scrolling column (form, then the 3D at a real height via the global
   #viewer/#panel/#stage mobile rules), and pin the Cancel/Apply (and assembled
   "← Back") bar so it stays reachable while scrolling. ---- */
@media (max-width: 767px) {
  #screen-refine.is-active.editing,
  #screen-refine.is-active.assembled { display: block; overflow-y: auto; }
  .refine-mode.editing .box-editor-host,
  .refine-mode.assembled .box-editor-host { display: block; }
  #screen-refine .refine-edit-bar { position: sticky; top: 0; z-index: 6; }
}

/* =============== Screen 6 · Review & Buy =============== */
#screen-review.is-active { overflow-y: auto; }
.review-view { max-width: 1000px; margin: 0 auto; padding: 22px 22px 64px; }
.review-msg { color: var(--muted); padding: 40px 6px; font-size: 15px; }
.review-msg a { color: var(--accent2); text-decoration: none; }
.review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.review-head h2 { margin: 0 0 3px; font-size: 20px; }
.review-dims { font-size: 13px; color: var(--accent2); }
.review-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 820px) { .review-grid { grid-template-columns: 1fr; } }
/* preview: a grid of tiles (2D plan from Screen 5 + photoreal views); tap to expand */
.rv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rv-tile { display: flex; flex-direction: column; gap: 6px; padding: 0; background: none;
  border: none; cursor: pointer; text-align: center; font: inherit; }
.rv-tile-img { position: relative; aspect-ratio: 3 / 2; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; }
.rv-tile:hover .rv-tile-img, .rv-tile:focus-visible .rv-tile-img { border-color: var(--accent2); }
.rv-tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-tile.rv-seed .rv-tile-img img { opacity: 0.8; }              /* still the 3D render */
.rv-tile-img .rv-fit { width: 100%; height: 100%; padding: 8px; box-sizing: border-box; }
/* let the SVG's own viewBox + preserveAspectRatio letterbox it — robust in Safari,
   which collapses an intrinsic-sized SVG to 0 height inside a flex tile */
.rv-tile-img .rv-fit svg { width: 100%; height: 100%; display: block; }
.rv-tile-wait { font-size: 12px; color: var(--muted); }
.rv-tile-cap { font-size: 12px; color: var(--muted); font-weight: 600; }
/* interactive "spin in 3D" tile badge */
.rv-3d-badge { position: absolute; left: 8px; bottom: 8px; background: rgba(20,20,22,0.8); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .2px; padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.rv-tile-interactive:hover .rv-tile-img { border-color: var(--accent2); box-shadow: 0 0 0 2px rgba(224,164,90,0.25); }
/* lightbox — full-screen expand; click anywhere to shrink back to the grid */
.rv-lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.86);
  display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.rv-lightbox.hidden { display: none; }
.rv-lb-inner { position: relative; max-width: 94vw; max-height: 92vh; }
.rv-lb-inner img { max-width: 94vw; max-height: 88vh; object-fit: contain; border-radius: 10px; display: block; }
.rv-lb-plan { background: var(--panel); padding: 16px; border-radius: 10px; }
.rv-lb-plan svg { width: min(88vw, 920px); max-height: 84vh; height: auto; display: block; }
.rv-lb-cap { position: absolute; left: 0; right: 0; bottom: -26px; text-align: center; color: #eee; font-size: 12.5px; }
.rv-prnote { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.rv-disclaimer { margin: 12px 2px 0; font-size: 11px; line-height: 1.5; color: var(--muted); opacity: .8; text-align: center; }
/* side column: spec, boxes, buy */
.review-side { display: flex; flex-direction: column; gap: 16px; }
.review-spec, .review-boxes, .review-buy { background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; }
.review-side h3 { margin: 0 0 10px; font-size: 14px; }
.rv-spec { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rv-spec li { font-size: 13px; color: var(--muted); line-height: 1.5; padding-left: 18px; position: relative; }
.rv-spec li::before { content: '✓'; position: absolute; left: 0; color: var(--accent2); }
.rv-spec b { color: var(--text); font-weight: 600; }
.rv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rv-row { display: flex; gap: 10px; align-items: flex-start; }
.rv-n { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: #1c1714;
  border: 1.3px solid var(--accent2); color: var(--text); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; }
.rv-rbody { flex: 1 1 auto; min-width: 0; }
.rv-rtitle { font-size: 13px; font-weight: 700; }
.rv-rsize { font-weight: 400; color: var(--accent2); font-size: 12px; }
.rv-rsub { font-size: 12px; color: var(--muted); line-height: 1.4; }
/* buy box */
.review-buy { text-align: center; }
/* .rv-price/.rv-pamt/.rv-pest retired — no buyer-facing price for now (Gil) */
.rv-pfine { margin: 6px 0 14px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.rv-cart { width: 100%; }
.rv-guarantee { margin: 12px 0 0; font-size: 12px; color: var(--accent2); }
.rv-thanks { text-align: center; padding: 6px 4px; }
.rv-check { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; }
.rv-thanks h3 { margin: 0 0 8px; }
.rv-ordernum { color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rv-thanks p { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 16px; }
.rv-order-err { color: #c0392b; }

/* =============== "My Designs" library (hub between Landing and Capture) ====== */
.library.is-active { overflow-y: auto; }
.library-view { max-width: 1000px; margin: 0 auto; padding: 26px 22px 64px; }
.library-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.library-head h2 { margin: 0 0 4px; font-size: 22px; }
.library-sub { margin: 0; color: var(--muted); font-size: 14px; max-width: 60ch; line-height: 1.5; }
.library-loading { color: var(--muted); padding: 30px 4px; grid-column: 1 / -1; }
.library-empty { color: var(--muted); padding: 18px; border: 1px dashed var(--line);
  border-radius: 12px; grid-column: 1 / -1; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }

.lib-card { display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lib-card.is-bought { border-color: var(--accent2); }
.lib-thumb { background: var(--bg); padding: 10px; display: flex; align-items: center; justify-content: center; }
.lib-thumb svg { width: 100%; height: auto; display: block; }
.lib-body { padding: 12px 14px 6px; flex: 1; }
.lib-eyebrow { margin-bottom: 6px; }
.lib-name { font-size: 15px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.lib-badge { display: inline-block; font-size: 11px; color: var(--accent2);
  border: 1px solid var(--accent2); border-radius: 20px; padding: 2px 8px; white-space: nowrap; }
.lib-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.lib-items { font-size: 12.5px; color: var(--text); margin-top: 5px; line-height: 1.4; }
.lib-date { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.lib-date.is-bought { color: var(--accent2); font-weight: 600; }
.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px 14px; }
.lib-btn { flex: 1 1 auto; min-width: 64px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; cursor: pointer; }
.lib-btn:hover { border-color: var(--accent); }
.lib-btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
.lib-btn.primary:hover { filter: brightness(1.06); }
.lib-btn.danger { color: #d98a7a; flex: 0 0 auto; min-width: 0; }
.lib-btn.danger:hover { border-color: #d98a7a; }
.lib-btn:disabled { opacity: .5; cursor: default; }

/* the "+ Start a new design" card */
.lib-new { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 190px; background: var(--panel2); border: 1.5px dashed var(--accent2);
  border-radius: 14px; color: var(--accent2); cursor: pointer; font: inherit; }
.lib-new:hover { background: #241d16; }
.lib-plus { font-size: 34px; line-height: 1; }
.lib-new-label { font-size: 14px; font-weight: 600; }

/* the hub is a home page, not a numbered step → hide the step bar there */
body.on-hub #step-indicator { display: none; }
/* phones: trim the chrome so each design thumbnail uses most of the screen width */
@media (max-width: 767px) {
  .library-view { padding: 20px 12px 56px; }
  .library-grid { grid-template-columns: 1fr; gap: 16px; }
  .lib-thumb { padding: 6px; }
}

.library-head-actions { display: flex; gap: 8px; align-items: center; }

/* =============== Admin console (admin accounts only) =============== */
.admin-screen.is-active { overflow-y: auto; }
.admin-view { max-width: 1040px; margin: 0 auto; padding: 26px 22px 64px; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-head h2 { margin: 0 0 4px; font-size: 22px; }
.admin-sub { margin: 0; color: var(--muted); font-size: 14px; max-width: 62ch; line-height: 1.5; }
.admin-loading, .admin-empty { color: var(--muted); padding: 22px 4px; }
.admin-empty { border: 1px dashed var(--line); border-radius: 12px; padding: 18px; }
.admin-empty code { color: var(--accent2); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table thead th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.admin-table th.num, .admin-table td.num { text-align: right; }
.admin-table tbody tr { border-bottom: 1px solid var(--line); cursor: pointer; }
.admin-table tbody tr:hover { background: var(--panel); }
.admin-table td { padding: 11px 12px; color: var(--text); }
.admin-email { font-weight: 600; overflow-wrap: anywhere; }
.admin-open { color: var(--accent2); text-align: right; white-space: nowrap; }

.admin-detail { margin-top: 26px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 18px 8px; }
.admin-detail-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-detail h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.admin-detail-sub { color: var(--muted); font-size: 13px; }

.admin-designs { display: flex; flex-direction: column; gap: 10px; }
.admin-design { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; }
.admin-design:hover { border-color: var(--accent); }
.admin-design-main { display: flex; flex-direction: column; gap: 3px; }
.admin-design-name { font-size: 15px; font-weight: 700; }
.admin-design-meta { font-size: 12.5px; color: var(--muted); }
.admin-design-meta em { color: var(--accent2); font-style: normal; }
.admin-design-date { font-size: 12px; color: var(--muted); }
.admin-bought { color: var(--accent2); font-weight: 600; }
.admin-design-open { margin-top: 8px; font-size: 12.5px; color: var(--accent2); }

.admin-spec { margin-top: 12px; }
.admin-spec-note { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }
.admin-spec-bar { margin-bottom: 8px; }
.admin-json { background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-size: 12px; line-height: 1.5; color: var(--text);
  max-height: 360px; overflow: auto; white-space: pre; }

@media (max-width: 767px) {
  .admin-view { padding: 20px 12px 56px; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr { padding: 8px 2px; }
  .admin-table td { padding: 2px 2px; }
  .admin-table td.num { text-align: left; }
  .admin-table td.num::before { content: attr(data-label); color: var(--muted); }
  .admin-open { text-align: left; }
}

/* Screen 2 · required "Name this design" field */
.design-name-field { margin-bottom: 16px; }
.design-name-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.design-name-field label small { font-weight: 400; color: var(--muted); }
.design-name-field input { width: 100%; box-sizing: border-box; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; }
.design-name-field input:focus { outline: none; border-color: var(--accent); }
