/* =====================================================================
   MEDIA WALL DESIGNER — STYLES
   ===================================================================== */
:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1f2226;
  --muted: #6a6f76;
  --line: #e4e0d9;
  --accent: #b8865b;        /* warm brass */
  --accent-ink: #7d5733;
  --accent-soft: #f6eee4;
  --danger: #b04a3c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.05), 0 8px 24px rgba(20, 20, 20, 0.06);
  --topbar: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
h2, h3, h4 { margin: 0; line-height: 1.2; }
h2 { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 26px 0 10px; }
h4 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.lead { color: var(--muted); margin: 6px 0 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.hint a { color: var(--accent-ink); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #2b2e33, #4a4d53);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 8px 7px; border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), #e2c39c);
}
.brand-name { font-weight: 700; display: block; line-height: 1.1; }
.brand-tag { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stepnav { display: flex; gap: 4px; }
.stepnav button {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border: 0; background: none; border-radius: 999px; color: var(--muted);
}
.stepnav button .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; background: #eeeae3; color: var(--muted);
}
.stepnav button.done .num { background: var(--accent-soft); color: var(--accent-ink); }
.stepnav button.active { background: var(--ink); color: #fff; }
.stepnav button.active .num { background: var(--accent); color: #fff; }
.topbar-total { justify-self: end; text-align: right; display: flex; flex-direction: column; line-height: 1.1; }
.topbar-total span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.topbar-total strong { font-size: 18px; }
.topbar-tools { display: none; align-items: center; gap: 6px; justify-self: end; }
.topbar-tools select {
  appearance: none; -webkit-appearance: none; font-size: 13px; padding: 7px 26px 7px 10px; max-width: 150px;
  border-radius: 9px; border: 1px solid var(--line); background: #fbfaf8;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236a6f76' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center;
}
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 18px; line-height: 1; display: grid; place-items: center; }
.topbar-tools .btn.small { padding: 7px 10px; font-size: 12.5px; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; }
.progress span { display: block; height: 100%; width: 20%; background: var(--accent); transition: width 0.35s ease; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: 460px minmax(0, 1fr); gap: 24px;
  max-width: 1440px; margin: 0 auto; padding: 24px;
  align-items: start;
}
.config {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px; position: sticky; top: calc(var(--topbar) + 24px);
  max-height: calc(100vh - var(--topbar) - 48px); overflow: auto;
}
.preview { display: grid; gap: 20px; position: sticky; top: calc(var(--topbar) + 24px); }

/* ---------- steps ---------- */
.step { display: none; animation: fade 0.25s ease; }
.step.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.stepnum {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 14px; flex: none;
}
.step-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- buttons ---------- */
.btn {
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #33373d; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f3f0ea; box-shadow: none; }
.btn.danger { color: var(--danger); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: 1fr; gap: 10px; }
.card {
  display: grid; grid-template-columns: 84px 1fr; grid-template-rows: auto auto; column-gap: 14px; row-gap: 2px;
  text-align: left; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.card:hover { border-color: #cfc8bd; }
.card.selected { border-color: var(--accent); background: var(--accent-soft); }
.card-icon { grid-row: 1 / span 2; align-self: center; }
.card-icon svg { width: 84px; height: auto; display: block; }
.card-title { font-weight: 600; }
.card-title em { font-style: normal; font-weight: 500; color: var(--accent-ink); font-size: 12px; margin-left: 8px; }
.card-blurb { color: var(--muted); font-size: 13px; }
/* card icon colours */
.ic-room { fill: #ddd7cd; }
.ic-wall { fill: #b9a894; }
.ic-return { fill: #b3aa9c; }
.ic-tv { fill: #1c1e22; }
.ic-shelf { fill: #7f705d; }
.ic-fire { fill: #e58a3a; }
.card.selected .ic-wall { fill: var(--accent); }

/* finish cards */
.finish-card { grid-template-columns: 64px 1fr; }
.finish-thumb {
  grid-row: 1 / span 2; width: 64px; height: 64px; border-radius: 10px; align-self: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.finish-plain { background: #ece7de; }
.finish-polished {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.35) 100%),
    radial-gradient(120% 80% at 30% 20%, #d8cfbe, #b8ab94 60%, #cdc2ad);
}
.finish-textured {
  background-color: #b9ab98;
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.16) 1px, transparent 1.4px),
    radial-gradient(rgba(255, 255, 255, 0.25) 1px, transparent 1.4px),
    radial-gradient(rgba(0, 0, 0, 0.1) 1.5px, transparent 2px);
  background-size: 5px 5px, 7px 7px, 11px 11px;
  background-position: 0 0, 2px 3px, 5px 1px;
}

/* ---------- fields ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.field > span:first-child { font-size: 13px; font-weight: 500; color: #3c4046; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; margin: 0; }
.field input[type="number"], .field select, .input-unit {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fbfaf8;
}
.field select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236a6f76' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
.field input:focus, .field select:focus, .input-unit:focus-within { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.input-unit { display: flex; align-items: center; gap: 6px; padding: 0 12px 0 0; }
.input-unit input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 12px; outline: none; -moz-appearance: textfield; }
.input-unit input::-webkit-outer-spin-button, .input-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit em { font-style: normal; color: var(--muted); font-size: 13px; }
input[type="color"] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fbfaf8; }
.stepper button { width: 40px; border: 0; background: #f1ede6; font-size: 18px; }
.stepper button:hover { background: #e8e2d8; }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; background: transparent; padding: 10px 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.side { padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; background: #fcfbf9; }
.side .grid2 .field { margin-bottom: 0; }
.side .niche-fields { margin-top: 12px; }

/* ---------- swatches ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 2px; border-radius: 10px; }
.swatch:hover { background: #f3f0ea; }
.swatch-chip {
  width: 48px; height: 48px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease;
}
.swatch:hover .swatch-chip { transform: scale(1.06); }
.swatch.selected .swatch-chip { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.15); }
.swatch-name { font-size: 12px; color: var(--muted); }
.swatch.selected .swatch-name { color: var(--ink); font-weight: 600; }

/* ---------- preview ---------- */
.preview-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-toolbar .field select { width: auto; padding: 8px 32px 8px 12px; }
.preview-toolbar .check { margin: 0; }
.render { border-radius: 10px; overflow: hidden; background: #ddd; line-height: 0; touch-action: none; }
.render svg { display: block; width: 100%; height: auto; }
.render canvas { display: block; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.toolbar-buttons { display: flex; gap: 8px; }
.version-tag { margin-left: 10px; padding: 1px 7px; border-radius: 999px; background: #eeeae3; font-size: 11px; }
.preview-caption { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.print-only { display: none; }
.preview-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; text-align: center; }
.warnings { display: grid; gap: 6px; margin-top: 10px; }
.warn { background: #fff4e5; color: #8a4b00; border: 1px solid #f5d9b0; border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.warnings:empty { display: none; }

/* ---------- price card ---------- */
.price-card { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 16px 22px; box-shadow: var(--shadow); }
.price-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.price-row .fine { margin: 0; max-width: 220px; text-align: right; }
.price-main { display: flex; flex-direction: column; gap: 2px; }
.price-main .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #b8bcc3; }
.price-main strong { font-size: 32px; line-height: 1.1; letter-spacing: -0.01em; }
.price-main .sub { color: #b8bcc3; font-size: 13px; }
.price-card details summary { cursor: pointer; color: #d9c4a9; font-weight: 600; font-size: 13px; padding: 8px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.price-card details summary::-webkit-details-marker { display: none; }
.price-card details summary::before { content: "▸"; font-size: 11px; transition: transform 0.15s ease; }
.price-card details[open] summary::before { transform: rotate(90deg); }
.price-lines { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; }
.price-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.price-lines .pl-label { display: flex; flex-direction: column; gap: 1px; }
.price-lines .pl-label small { color: #9aa0a8; font-size: 11.5px; }
.price-lines .pl-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-lines .pl-sub { color: #b8bcc3; }
.fine { color: #9aa0a8; font-size: 12px; margin: 12px 0 0; }
.price-card details { margin-top: 6px; }

/* ---------- summary (step 5) ---------- */
.summary { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.summary-heading { margin: 14px 16px 4px; }
.quote-lines { list-style: none; margin: 0; padding: 0 16px 8px; font-size: 14px; }
.quote-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.quote-lines li:last-child { border-bottom: 0; }
.quote-lines .pl-label { display: flex; flex-direction: column; gap: 1px; }
.quote-lines .pl-label small { color: var(--muted); font-size: 12px; }
.quote-lines .pl-amt { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.quote-lines .pl-sub { color: var(--muted); }
.spec { padding: 6px 16px; }
.spec-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.spec-row:last-child { border-bottom: 0; }
.spec-row span { color: var(--muted); flex: none; }
.spec-row strong { font-weight: 500; text-align: right; }
.summary-total { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--accent-soft); }
.summary-total strong { font-size: 24px; }
.quote-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- mobile bottom bar ---------- */
.mobile-bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(20, 20, 20, 0.08);
}
.mobile-bar-price { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.mobile-bar-step { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.mobile-bar-price strong { font-size: 20px; }
.mobile-bar-actions { display: flex; gap: 8px; }
.mobile-bar .btn { padding: 10px 14px; white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 400px minmax(0, 1fr); }
}
@media (max-width: 960px) {
  :root { --topbar: 56px; }
  .topbar { grid-template-columns: auto 1fr; padding: 0 12px; gap: 10px; }
  .brand-tag, .brand-name { display: none; }          /* logo only – the tools take the space */
  .stepnav { display: none; }
  .topbar-total { display: none; }
  .topbar-tools { display: flex; }
  .layout { grid-template-columns: 1fr; padding: 0 0 96px; gap: 0; }
  /* the preview pins under the top bar; the options scroll beneath it */
  .preview { position: sticky; top: var(--topbar); z-index: 15; order: -1; gap: 0; }
  .preview-card { padding: 0; border-radius: 0 0 16px 16px; box-shadow: 0 8px 20px rgba(20, 20, 20, 0.12); position: relative; }
  .preview-toolbar { display: none; }                 /* moved into the top bar */
  .render { border-radius: 0 0 16px 16px; }
  .preview-caption { position: absolute; left: 10px; bottom: 8px; margin: 0; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.85); color: var(--ink); }
  .warnings { margin: 0; padding: 6px 10px 0; }
  .preview-note { display: none; }
  .config { margin: 12px; border-radius: var(--radius); }
  .config { position: static; max-height: none; padding: 18px 16px; }
  .price-card { display: none; }               /* breakdown lives in the Quote step on small screens */
  .preview-caption { font-size: 11px; gap: 8px; }
  #dimsCaption { white-space: nowrap; }
  #viewHint { display: none; }                  /* touch users get the hint from trying it */
  .mobile-bar { display: flex; }
  .step-actions { display: none; }              /* the bottom bar handles Back / Next */
  .step[data-step="5"] .step-actions { display: flex; }
}
@media (max-width: 520px) {
  .grid2 { grid-template-columns: 1fr; }
  .side .grid2, .step .grid2 { grid-template-columns: 1fr 1fr; }   /* paired mm fields stay side by side */
  .card { grid-template-columns: 64px 1fr; }
  .card-icon svg { width: 64px; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .topbar, .preview-toolbar, .step-actions, .quote-actions, .warnings, .preview-note, #renderHost, #viewHint { display: none !important; }
  .print-only { display: block; border-radius: 10px; overflow: hidden; }
  .print-only svg { display: block; width: 100%; height: auto; }
  .layout { display: block; padding: 0; max-width: none; }
  .config { box-shadow: none; padding: 0; position: static; max-height: none; overflow: visible; }
  .step { display: none !important; }
  .step[data-step="5"] { display: block !important; }
  .preview { position: static; display: block; margin-bottom: 20px; }
  .preview-card { box-shadow: none; padding: 0; }
  .price-card { background: #fff; color: #000; border: 1px solid #ccc; margin-top: 16px; }
  .price-card * { color: #000 !important; }
  .price-lines li { border-color: #ddd; }
  .fine { color: #444 !important; }
}
