/*
 * Baltic Stairbuilder — floating-panel layout (v2.14.0 panel redesign)
 *
 * Two viewport-fixed panels flank a relative canvas-container:
 *   • Configure (#stairbuild, left)  — cream panel, flex column:
 *       fixed header · contained scroll (accordion) · fixed footer (price + CTA)
 *   • Measurements (.mm_breakout, right) — dark panel, full height figures
 * The quote/.breakout box is gone: price + "Get free quote" now live in the
 * Configure footer, so removing it hands the whole right side to Measurements.
 *
 * Palette + anatomy take their cues from the design mockup. Brand-colour
 * CSS vars (injected from admin settings in the main plugin file) still win
 * over the mockup defaults below, so a configured box keeps its own colours.
 *
 * All panel selectors scoped under .bd-stairbuilder-layout. The whole wrapper
 * is hoisted to <body> on init (layout.js) so page-builder ancestors with
 * transform/filter can't hijack the fixed-positioning containing block.
 */

.bd-stairbuilder-layout {
  --bd-form-width: 384px;
  --bd-side-width: 344px;
  --bd-pad: 24px;
  --bd-radius: 12px;
  /* PRIMARY CTA (Get free quote button + mobile Configure bar). Driven by the
   * admin "Quote" Brand Colour — that box moved into the footer, so its colour
   * picker now themes the action. Olive-gold fallback when unset. */
  --bd-cta-bg: var(--bd-quote-bg, #8F7A34);
  --bd-cta-text: var(--bd-quote-text, #FFF9E9);
  /* Stacking tier for the whole plugin UI (panels, launcher bars, handles).
   * Host themes run sticky/fixed headers well above our old 100–120 range —
   * SPD's `handmade` theme paints its mobile header at 997 (child theme
   * sticky override 999 !important, slide-out nav 9999), which buried the
   * sheet's close control. One tier above any plausible theme chrome but
   * below the WP admin bar (99999), which the panels already offset for. */
  --bd-z-panel: 99980;
  --bd-line: #E3DCCB;            /* hairline on the light panel */
  --bd-line-dark: rgba(239, 232, 216, 0.14);
  --bd-muted: #7A7062;           /* secondary text on light */
  --bd-panel-shadow: 0 4px 24px rgba(43, 37, 34, 0.14);
  --bd-transition: 350ms cubic-bezier(0.32, 0.72, 0.24, 1);

  position: relative;
  font-family: inherit;
}

/* ------------ Canvas container (in document flow, centred) ------------
 * NOT scoped to .bd-stairbuilder-layout: layout.js lifts #canvas-container
 * out of the wrapper (the wrapper is hoisted to <body>; the canvas stays in
 * flow). */
#canvas-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: min(70vh, 700px);
  min-height: 360px;
  margin: 40px auto;
}
#canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============ SHARED PANEL ANATOMY ============ */
.bd-stairbuilder-layout #stairbuild,
.bd-stairbuilder-layout .mm_breakout {
  position: fixed;
  z-index: var(--bd-z-panel);
  top: var(--wp-admin-bar-height, 0px);
  bottom: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  box-sizing: border-box;
  box-shadow: var(--bd-panel-shadow);
  transition: transform var(--bd-transition);
}

/* Panel header — fixed top bar */
.bd-stairbuilder-layout .bd-panel-head {
  flex: none;
  margin: 0;                     /* <header> — keep theme element rules off it */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--bd-pad);
  border-bottom: 1px solid var(--bd-line);
}
.bd-stairbuilder-layout .bd-panel-head--dark {
  border-bottom-color: var(--bd-line-dark);
}
.bd-stairbuilder-layout .bd-panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  /* The title is an <h2>, so it was only *inheriting* the panel colour — and
   * inheritance loses to any element-level `h2 { color }` in the host theme's
   * main stylesheet, which painted it black on the dark Measurements panel.
   * Declaring `inherit` explicitly wins at (0,2,0) and keeps one rule for both
   * panels: each title follows its own panel's brand colour (Configure Panel —
   * Text on the left, Measurements Panel — Text on the right). */
  color: inherit;
}
.bd-stairbuilder-layout .bd-panel-head-spacer { flex: 1; }

/* Support line under the CONFIGURE heading (Stairbuilder Pricing → General).
 * `flex: none` keeps it out of the scroll region's flex growth, so it holds
 * position while the sections scroll beneath it. Hidden entirely when the
 * setting is blank — the element isn't rendered at all. */
/* Support/phone line under the CONFIGURE heading. A filled band rather than a
   footnote — it's the "talk to a human" escape hatch and has to compete with the
   sections below it. Colours come from Brand Colours (Help Line Background /
   Text) and the size from General; the fallbacks here are the shipped look. */
.bd-stairbuilder-layout .bd-panel-help {
  flex: none;
  margin: 0;
  padding: 12px var(--bd-pad);
  border-bottom: 1px solid var(--bd-line);
  font-size: var(--bd-help-size, 15px);
  line-height: 1.4;
  font-weight: 500;
  background: var(--bd-help-bg, #8F7A34);
  color: var(--bd-help-text, #FFFFFF);
}
/* The auto-generated tel: link must not fall back to the panel link colour —
   on the filled band it would be unreadable. */
.bd-stairbuilder-layout .bd-panel-help a {
  color: inherit;
  text-decoration: underline;
}
.bd-stairbuilder-layout .bd-panel-util {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--bd-muted);
  padding: 4px 8px;
  border-radius: 6px;
}
.bd-stairbuilder-layout .bd-panel-util:hover {
  background: rgba(43, 37, 34, 0.06);
  color: inherit;
}
.bd-stairbuilder-layout .bd-panel-collapse {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  border-radius: 8px;
}
.bd-stairbuilder-layout .bd-panel-collapse:hover { background: rgba(43, 37, 34, 0.07); }
.bd-stairbuilder-layout .bd-panel-head--dark .bd-panel-collapse:hover { background: rgba(239, 232, 216, 0.1); }
.bd-stairbuilder-layout .bd-panel-collapse svg { display: block; }

/* Scroll body + top/bottom fade masks. The scrollbar lives HERE, contained
 * within the accordion region, so header + footer never scroll. */
.bd-stairbuilder-layout .bd-scrollwrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.bd-stairbuilder-layout .bd-scrollwrap::before,
.bd-stairbuilder-layout .bd-scrollwrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 8px;
  height: 20px;
  z-index: 2;
  pointer-events: none;
}
.bd-stairbuilder-layout .bd-scrollwrap::before {
  top: 0;
  background: linear-gradient(var(--bd-form-bg, #FBF9F4), transparent);
}
.bd-stairbuilder-layout .bd-scrollwrap::after {
  bottom: 0;
  background: linear-gradient(transparent, var(--bd-form-bg, #FBF9F4));
}
.bd-stairbuilder-layout .bd-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #C7BCA4 transparent;
}
.bd-stairbuilder-layout .bd-scroll::-webkit-scrollbar { width: 6px; }
.bd-stairbuilder-layout .bd-scroll::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.bd-stairbuilder-layout .bd-scroll::-webkit-scrollbar-thumb { background: #C7BCA4; border-radius: 3px; }

/* ============ LEFT — CONFIGURE (#stairbuild) ============ */
.bd-stairbuilder-layout #stairbuild {
  left: 0;
  right: auto;
  width: var(--bd-form-width);
  background: var(--bd-form-bg, #FBF9F4);
  color: var(--bd-form-text, #2B2522);
  border-radius: 0 var(--bd-radius) var(--bd-radius) 0;
  transform: translateX(0);
  padding: 0;
}
.bd-stairbuilder-layout #stairbuild a { color: var(--bd-form-link, #8F7A34); }
.bd-stairbuilder-layout.is-form-collapsed #stairbuild { transform: translateX(-102%); }

/* ------------ Accordion sections ------------ */
.bd-stairbuilder-layout .form-tabs {
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
}
.bd-stairbuilder-layout .form-tab {
  width: 100%;
  border-bottom: 1px solid var(--bd-line);
  /* Override builder.css `.form-tab { color: var(--bd-tab-text, #fff) }` so
   * section heads follow Form Box Text (dark on the cream panel), matching
   * the price total row. */
  color: var(--bd-form-text, #2B2522);
}
.bd-stairbuilder-layout .sec-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px var(--bd-pad);
  text-align: left;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
}
.bd-stairbuilder-layout .sec-head:hover { background: rgba(43, 37, 34, 0.03); }
.bd-stairbuilder-layout .form-tab.is-open .sec-head {
  border-left-color: var(--bd-form-text, #2B2522);
  background: var(--bd-section-open-bg, #F4F0E4);
}
.bd-stairbuilder-layout .sec-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}
.bd-stairbuilder-layout .sec-sub {
  display: -webkit-box;
  -webkit-line-clamp: 2;      /* up to two comfortable lines, then ellipsis */
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--bd-muted);
}
.bd-stairbuilder-layout .sec-sub:empty { display: none; }
.bd-stairbuilder-layout .sec-chev {
  flex: none;
  color: var(--bd-muted);
  transition: transform 0.25s var(--bd-transition);
}
.bd-stairbuilder-layout .form-tab.is-open .sec-chev { transform: rotate(90deg); }

/* completion tick */
.bd-stairbuilder-layout .sec-status {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid #C7BCA4;
  display: grid;
  place-items: center;
  color: transparent;
}
.bd-stairbuilder-layout .form-tab.is-done .sec-status {
  background: var(--bd-form-text, #2B2522);
  border-color: var(--bd-form-text, #2B2522);
  color: var(--bd-form-bg, #FBF9F4);
}
.bd-stairbuilder-layout .sec-status svg { display: block; }

/* section body — collapsible (max-height animation, generous cap so tall
 * sections like Posts & Balustrades never clip) */
.bd-stairbuilder-layout .tab-content {
  max-height: 0;
  overflow: hidden;
  padding: 0 var(--bd-pad);
  background: var(--bd-section-open-bg, #F4F0E4);
  border-left: 3px solid var(--bd-form-text, #2B2522);
  transition: max-height 0.3s var(--bd-transition);
}
.bd-stairbuilder-layout .form-tab.is-open .tab-content {
  max-height: 4000px;
  padding: 4px var(--bd-pad) var(--bd-pad);
}

/* Price on application. The breakdown has nothing to break down, so the cost
 * and VAT rows go and "Submit for Quote" takes the total's place — sized down
 * from the 26px figure, which is set for a currency amount, not a sentence. */
.bd-stairbuilder-layout .bd-panel-foot.is-poa .price-breakdown li:not(.price-total-row) { display: none; }
.bd-stairbuilder-layout .bd-panel-foot.is-poa .price-total-row {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.bd-stairbuilder-layout .bd-panel-foot.is-poa .price-total-row .price-label { display: none; }
.bd-stairbuilder-layout .bd-panel-foot.is-poa .price-total-row .price { font-size: 19px; }

/* ------------ Footer — the money bar ------------ */
.bd-stairbuilder-layout .bd-panel-foot {
  flex: none;
  /* The element is a <footer>, so theme element rules land on it — SPD's
   * handmade theme ships `footer { margin-top: 60px }`, which pushed white
   * space under the sheet footer. Claim the margin explicitly. */
  margin: 0;
  border-top: 1px solid var(--bd-line);
  padding: 14px var(--bd-pad) var(--bd-pad);
  background: var(--bd-form-bg, #FBF9F4);
  border-radius: 0 0 var(--bd-radius) 0;
}
.bd-stairbuilder-layout .bd-panel-foot .price-breakdown {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.bd-stairbuilder-layout .price-breakdown li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  font-size: 13px;
  color: var(--bd-muted);
}
.bd-stairbuilder-layout .price-breakdown .price-sub {
  font-size: 0.85em;
  opacity: 0.8;
}
.bd-stairbuilder-layout .price-breakdown .price { white-space: nowrap; }
.bd-stairbuilder-layout .price-breakdown .price-total-row {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--bd-line);
  color: var(--bd-form-text, #2B2522);
  font-weight: 600;
}
.bd-stairbuilder-layout .price-breakdown .price-total-row .price-label { font-size: 13px; }
.bd-stairbuilder-layout .price-breakdown .price-total-row .price {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.bd-stairbuilder-layout .sb-buynow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--bd-cta-text);
  background: var(--bd-cta-bg);
  transition: background 0.15s;
}
.bd-stairbuilder-layout .sb-buynow:hover { filter: brightness(0.92); }
.bd-stairbuilder-layout .bd-foot-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--bd-muted);
  text-align: center;
}
.bd-stairbuilder-layout .sb-submit-error {
  margin: 10px 0 0;
  color: #b3261e;
  font-size: 13px;
  text-align: center;
}

/* ============ RIGHT — MEASUREMENTS (.mm_breakout) ============ */
.bd-stairbuilder-layout .mm_breakout {
  right: 0;
  left: auto;
  width: var(--bd-side-width);
  background: var(--bd-mm-bg, #2B2522);
  color: var(--bd-mm-text, #EFE8D8);
  border-radius: var(--bd-radius) 0 0 var(--bd-radius);
  transform: translateX(0);
}
.bd-stairbuilder-layout .mm_breakout a { color: var(--bd-mm-link, #EFE8D8); }
.bd-stairbuilder-layout.is-measurements-collapsed .mm_breakout { transform: translateX(105%); }

.bd-stairbuilder-layout .bd-figs {
  flex: 1;
  align-content: center;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px 16px;
  padding: 24px var(--bd-pad);
  overflow-y: auto;
}
/* Standing note at the foot of the Measurements panel (v2.25.0). flex:none so
 * it keeps its natural height and .bd-figs absorbs the slack instead — the
 * figures are the thing that should compress, not the note. Scrolls inside
 * itself rather than pushing the panel if an admin pastes something long. */
.bd-stairbuilder-layout .bd-meas-note {
  flex: 0 0 auto;
  max-height: 40%;
  overflow-y: auto;
  padding: 16px var(--bd-pad) 20px;
  border-top: 1px solid var(--bd-mm-rule, rgba(239, 232, 216, 0.18));
  font-size: 12px;
  line-height: 1.5;
  color: var(--bd-mm-text, #EFE8D8);
  opacity: 0.85;
}

.bd-stairbuilder-layout .bd-fig-lab {
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  /* Was a hard-coded 55%-alpha cream, which isn't brand-controlled and went
   * near-illegible once Measurements Panel — Background was set to a mid grey.
   * Takes Measurements Panel — Text at full strength now; hierarchy against
   * the figures comes from size and weight, and the parenthetical .mm-sub
   * keeps its own dimming below. */
  color: var(--bd-mm-text, #EFE8D8);
  line-height: 1.3;
}
.bd-stairbuilder-layout .bd-fig-lab .mm-sub {
  display: block;
  font-size: 0.9em;
  letter-spacing: 0.04em;
  opacity: 0.8;
  text-transform: none;
}
.bd-stairbuilder-layout .bd-fig-val {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.bd-stairbuilder-layout .bd-fig-val .msmnt { color: var(--bd-mm-text, #EFE8D8); }

/* ============ DESKTOP PULL TABS (handles) ============ */
.bd-stairbuilder-layout .bd-handle {
  position: fixed;
  z-index: calc(var(--bd-z-panel) + 10);
  display: flex;
  align-items: center;
  gap: 8px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 16px 9px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: var(--bd-mm-bg, #2B2522);
  color: var(--bd-mm-text, #EFE8D8);
  box-shadow: var(--bd-panel-shadow);
  transition: left var(--bd-transition), right var(--bd-transition), background 0.15s;
}
.bd-stairbuilder-layout .bd-handle:hover { filter: brightness(1.15); }
.bd-stairbuilder-layout .bd-handle::after {
  content: "\276F";
  writing-mode: horizontal-tb;
  font-size: 12px;
  transition: transform var(--bd-transition);
}
.bd-stairbuilder-layout .bd-handle--form {
  left: var(--bd-form-width);
  top: calc(var(--wp-admin-bar-height, 0px) + 96px);
  border-radius: 0 8px 8px 0;
}
.bd-stairbuilder-layout .bd-handle--form::after { transform: rotate(-180deg); }
.bd-stairbuilder-layout.is-form-collapsed .bd-handle--form { left: 0; }
.bd-stairbuilder-layout.is-form-collapsed .bd-handle--form::after { transform: rotate(0deg); }

.bd-stairbuilder-layout .bd-handle--measurements {
  right: var(--bd-side-width);
  top: calc(var(--wp-admin-bar-height, 0px) + 96px);
  border-radius: 8px 0 0 8px;
}
.bd-stairbuilder-layout .bd-handle--measurements::after { transform: rotate(0deg); }
.bd-stairbuilder-layout.is-measurements-collapsed .bd-handle--measurements { right: 0; }
.bd-stairbuilder-layout.is-measurements-collapsed .bd-handle--measurements::after { transform: rotate(-180deg); }

/* ============ MOBILE FABs (hidden on desktop) ============ */
.bd-stairbuilder-layout .bd-fab {
  display: none;
  position: fixed;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--bd-mm-bg, #2B2522);
  color: var(--bd-mm-text, #EFE8D8);
  font-size: 20px;
  line-height: 56px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--bd-panel-shadow);
  z-index: calc(var(--bd-z-panel) + 10);
}
.bd-stairbuilder-layout .bd-fab--form         { left: 16px;  bottom: 16px; }
.bd-stairbuilder-layout .bd-fab--measurements { right: 16px; bottom: 16px; }

/* WordPress admin bar height — exposed so panels offset beneath it. */
body.admin-bar { --wp-admin-bar-height: 32px; }
@media screen and (max-width: 782px) {
  body.admin-bar { --wp-admin-bar-height: 46px; }
}

/* Two fields on one line — one decision made once per side (featured step
   Left/Right). Stacked, they read as two unrelated questions.
   Grid, not flex: `minmax(0, 1fr)` keeps both columns exactly equal whatever the
   option text is, where flex would let the longer list widen its own column. The
   panel is a fixed 384px at every breakpoint (--bd-form-width), so there's no
   width at which this needs to fall back to stacked. */
.bd-stairbuilder-layout #stairbuild .bd-field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.bd-stairbuilder-layout #stairbuild .bd-field-pair .bd-field {
  display: flex;
  flex-direction: column;
  min-width: 0;                     /* let the column shrink; selects clip natively */
}
/* .form-row select is already width:100%; restate it against the narrower
   column so a long option can't set the track width. */
.bd-stairbuilder-layout #stairbuild .bd-field-pair select { width: 100%; }

/* Form-row labels: full-width, capitalised. */
.bd-stairbuilder-layout #stairbuild .form-row label {
  width: 100%;
  text-transform: capitalize;
  vertical-align: middle;
}
/* Unit hint on the label's own line, e.g. "Floor Height (mm)". Labels are
   `text-transform: capitalize`, which would render this as "(Mm)" — CSS
   capitalises the first letter of the word regardless of the bracket. */
.bd-stairbuilder-layout #stairbuild .form-row label .form-unit {
  text-transform: none;
  font-weight: 400;
}
.bd-stairbuilder-layout #stairbuild .form-row label .form-sub {
  display: block;
  font-size: 0.75em;
  font-weight: 400;
  text-transform: none;
  opacity: 0.75;
}
/* Regime helper line under the Building Regs select. It's a standalone <p>, not
   a label sub-line, so it doesn't inherit .form-sub — size it to match. */
.bd-stairbuilder-layout #stairbuild .form-row .bd-regs-desc {
  margin: 4px 0 0;
  font-size: 0.75em;
  font-weight: 400;
  text-transform: none;
  opacity: 0.75;
  line-height: 1.35;
}
/* Landing inclusion note (v2.26.0). Stands where the treads-in-turn control was
   on the landing configs, so it sits directly in the section rather than inside
   a .form-row and needs its own spacing. Sized like .bd-regs-desc — it is a
   statement of what is included, not a field label. */
.bd-stairbuilder-layout #stairbuild .bd-landing-note {
  margin: 0 0 14px;
  padding-left: 10px;
  border-left: 2px solid var(--bd-form-text, #2B2522);
  font-size: 0.8em;
  font-weight: 400;
  text-transform: none;
  line-height: 1.4;
  opacity: 0.8;
}

/* Additional notes (v2.25.0) — textarea plus its character counter. The
   textarea has to be sized here because .form-row's control rules target
   input/select only. */
.bd-stairbuilder-layout #stairbuild .form-row textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 72px;
  font: inherit;
}
.bd-stairbuilder-layout #stairbuild .form-row .bd-notes-count {
  margin: 4px 0 0;
  font-size: 0.75em;
  text-align: right;
  opacity: 0.6;
}
.bd-stairbuilder-layout #stairbuild .form-row .bd-notes-count .is-at-limit {
  font-weight: 700;
  opacity: 1;
}

/* Form controls — selects, number/text inputs.
 * `color` set on #stairbuild doesn't reach a <select> once a theme styles the
 * element directly, and WooCommerce-flavoured themes commonly ship
 * `.woocommerce form .form-row select { color: <grey> }` (0,2,1), which was
 * winning and rendering the option text near-illegible. Claiming the controls
 * here at (1,1,1) — the id outranks any all-class theme rule — keeps the
 * plugin readable on any host theme without
 * !important, and ties them to Configure Panel — Text & Ticks so the colour
 * stays brand-controlled rather than theme-controlled. */
.bd-stairbuilder-layout #stairbuild select,
.bd-stairbuilder-layout #stairbuild input[type="number"],
.bd-stairbuilder-layout #stairbuild input[type="text"] {
  color: var(--bd-form-text, #2B2522);
  background-color: var(--bd-field-bg, #FFFFFF);
  /* The theme was also backgrounding selects and inputs differently from each
   * other (grey selects, white inputs). Claim both from Configure — Field
   * Background, and give the field its own hairline border so it still reads
   * as a field when that background is close to the panel's. */
  border: 1px solid var(--bd-line);
  font: inherit;
  line-height: 1.4;
}
/* Native dropdown list: Firefox (and Windows Chrome in dark mode) paints the
   popup from the <option>, not the <select>. */
.bd-stairbuilder-layout #stairbuild select option {
  color: var(--bd-form-text, #2B2522);
}
/* Unfilled required field after a submit attempt.
   The bare `.is-invalid` form is (1,2,0), which loses to the typed-input rule
   above at (1,2,1) — that's why name/postcode (input[type="text"]) stayed
   un-highlighted while email/tel (untyped by that rule) and select (1,1,1) went
   red. The second selector re-states the attribute to reach (1,3,1) and take the
   border back without !important. */
.bd-stairbuilder-layout #stairbuild .is-invalid,
.bd-stairbuilder-layout #stairbuild input[type].is-invalid {
  border: 1px solid #B3261E;
  box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.16);
}

/* Locked/derived fields stay deliberately muted so they still read as
   non-editable — the rule above would otherwise paint them full-strength.
   (Readonly tread-count inputs carry their own inline colour and are unaffected.) */
.bd-stairbuilder-layout #stairbuild select:disabled,
.bd-stairbuilder-layout #stairbuild input:disabled {
  color: var(--bd-muted);
}

.bd-stairbuilder-layout h5 { margin-bottom: 5px; }

/* Newel spec block, hidden when no newel post is priced (formLogic.js). */
.bd-stairbuilder-layout #stairbuild .bd-newel-fields.is-hidden { display: none; }

/* Three-column custom-section (newel post pickers). */
.bd-stairbuilder-layout #custom .form-col {
  display: flex;
  flex-direction: column;
  width: 33.33%;
  box-sizing: border-box;
  padding: 5px;
  border: 1px solid #E3DCCB;
}
.bd-stairbuilder-layout #custom .form-col label {
  font-size: 0.8em;
  display: block;
  text-align: left;
  text-transform: capitalize;
  line-height: 1.2;
}
.bd-stairbuilder-layout #custom .form-row { flex-direction: row; }
.bd-stairbuilder-layout #custom .form-row input[type="checkbox"] {
  width: 14px;
  margin-top: 5px;
}

/* ============ MOBILE (< 768px) ============
 * Two stacked launcher bars pinned to the bottom (Measurements above
 * Configure). Each bar IS a panel's collapsed state and its tap target;
 * tapping expands that panel upward as a sheet. One sheet open at a time
 * (enforced in layout.js), Configure open by default. Closing the active
 * sheet drops it back to its bar, revealing the stairs. */
@media (max-width: 767px) {
  .bd-stairbuilder-layout { overflow: hidden; }
  .bd-stairbuilder-layout .bd-handle { display: none; }

  /* layout.js sets this on <body> while a sheet is expanded (mobile only).
   * Locks the page beneath — auto-hiding theme headers re-appear on scroll,
   * which is how they end up over the sheet mid-interaction. Also the public
   * hook for a host theme to hide its own chrome while a sheet is open, e.g.
   *   body.bd-sb-sheet-open .site-header { display: none; }
   * Theme-specific selectors belong in the child theme, not here. */
  body.bd-sb-sheet-open { overflow: hidden; }

  /* --- Compact sheet chrome (BRIEF-06 P2) — every fixed band around the
   * accordion is trimmed so the scroll region gets the pixels back. Numbers
   * are mobile-only; desktop keeps the roomier shared anatomy. --- */

  /* Panel head: 14px → 10px pad. The safe-area term is notch/dynamic-island
   * clearance for the × — only bites when the page is viewport-fit=cover,
   * inert otherwise. */
  .bd-stairbuilder-layout .bd-panel-head {
    padding: 10px var(--bd-pad);
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  /* Help band stays (deliberately prominent "talk to a human" line) but
   * tighter; overrides the admin size var on this breakpoint only. Two-line
   * wrap is acceptable. */
  .bd-stairbuilder-layout .bd-panel-help {
    padding: 8px var(--bd-pad);
    font-size: 13px;
    line-height: 1.3;
  }

  /* Section heads: shallower, and summaries clamp to one line — doesn't grow
   * the scroll region but fits ~2 more section heads inside it. */
  .bd-stairbuilder-layout .sec-head { padding: 12px var(--bd-pad); }
  .bd-stairbuilder-layout .sec-sub {
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  /* Slimmer bottom fade so it stops reading as a dead zone above the price. */
  .bd-stairbuilder-layout .bd-scrollwrap::after { height: 12px; }

  /* Footer breakdown: three rows fold into total-first + one 12px component
   * sub-line ("£581.47 + £116.29 VAT"). DOM unchanged — the two component
   * <li>s reflow under the total via flex order; their labels hide and the
   * joining text comes from pseudo-elements. POA keeps working: the shared
   * .is-poa rules outrank these and still remove the component rows. */
  .bd-stairbuilder-layout .bd-panel-foot .price-breakdown {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    margin: 0 0 8px;
  }
  .bd-stairbuilder-layout .price-breakdown .price-total-row {
    order: 1;
    flex: 0 0 100%;
    margin-top: 0;
    padding: 0;
    border-top: none;
  }
  .bd-stairbuilder-layout .price-breakdown li:not(.price-total-row) {
    order: 2;
    display: inline-flex;
    gap: 0;                        /* shared li gap would split the "+ … VAT"
                                      pseudo-element joiners apart */
    padding: 0;
    font-size: 12px;
  }
  .bd-stairbuilder-layout .price-breakdown li:not(.price-total-row) .price-label { display: none; }
  .bd-stairbuilder-layout .price-breakdown li:nth-child(2)::before { content: "\00A0+\00A0"; }
  .bd-stairbuilder-layout .price-breakdown li:nth-child(2)::after  { content: "\00A0VAT"; }

  /* Footer button + note + padding trims. */
  .bd-stairbuilder-layout .bd-panel-foot { padding: 10px var(--bd-pad) 12px; }
  .bd-stairbuilder-layout .sb-buynow { height: 44px; }
  .bd-stairbuilder-layout .bd-foot-note {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.35;
  }

  /* --- Bottom launcher bars (44px tall — trimmed from 52px, BRIEF-06 P2;
   * the bar stays pinned under the open sheet by decision, so it pays rent
   * in as few pixels as it can) --- */
  .bd-stairbuilder-layout .bd-fab {
    display: none;                 /* shown per-panel below, only when collapsed */
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    height: 44px;
    padding: 0 20px;
    border: none;
    border-radius: 0;
    text-align: left;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 44px;
    cursor: pointer;
    box-shadow: 0 -6px 20px rgba(43, 37, 34, 0.18);
    z-index: calc(var(--bd-z-panel) + 10);
  }
  .bd-stairbuilder-layout .bd-fab::after {
    content: "\2303";              /* up chevron — hints the bar expands upward */
    float: right;
    font-size: 20px;
    line-height: 44px;
  }
  /* Configure bar — primary (gold), bottom-most. */
  .bd-stairbuilder-layout .bd-fab--form {
    bottom: 0;
    background: var(--bd-cta-bg);
    color: var(--bd-cta-text);
  }
  .bd-stairbuilder-layout.is-form-collapsed .bd-fab--form { display: block; }
  /* Measurements bar — dark, sits above the Configure bar when both show. */
  .bd-stairbuilder-layout .bd-fab--measurements {
    bottom: 0;
    background: var(--bd-mm-bg, #2B2522);
    color: var(--bd-mm-text, #EFE8D8);
  }
  .bd-stairbuilder-layout.is-measurements-collapsed .bd-fab--measurements { display: block; }
  .bd-stairbuilder-layout.is-form-collapsed.is-measurements-collapsed .bd-fab--measurements {
    bottom: 44px;                  /* stack above the Configure bar */
  }

  /* --- Panels expand upward as sheets above the single visible bar --- */
  .bd-stairbuilder-layout #stairbuild,
  .bd-stairbuilder-layout .mm_breakout {
    top: var(--wp-admin-bar-height, 0px);
    left: 0;
    right: 0;
    bottom: 44px;                  /* clear the one bar left at the bottom */
    width: 100%;
    border-radius: 16px 16px 0 0;
    transform: translateY(0);
  }
  .bd-stairbuilder-layout.is-form-collapsed #stairbuild { transform: translateY(102%); }
  .bd-stairbuilder-layout.is-measurements-collapsed .mm_breakout { transform: translateY(102%); }
  .bd-stairbuilder-layout .bd-panel-foot { border-radius: 0; }

  /* The header collapse control is a directional chevron on desktop; on a
   * bottom sheet a plain "×" close reads clearer. */
  .bd-stairbuilder-layout .bd-panel-collapse svg { display: none; }
  .bd-stairbuilder-layout .bd-panel-collapse::after {
    content: "\00D7";
    font-size: 24px;
    line-height: 1;
  }
}

/* Availability stated-line (v2.16.0 Phase 2). A single valid option renders as a
 * stated line, not an interactive one-option select. Functional rules only —
 * visual treatment is intentionally minimal and left to the design pass. */
.bd-stairbuilder-layout .bd-avail-collapsed { display: none; }
.bd-stairbuilder-layout .bd-avail-stated { display: none; }
.bd-stairbuilder-layout .bd-avail-stated.is-shown { display: block; }

@media (prefers-reduced-motion: reduce) {
  .bd-stairbuilder-layout #stairbuild,
  .bd-stairbuilder-layout .mm_breakout,
  .bd-stairbuilder-layout .bd-handle,
  .bd-stairbuilder-layout .tab-content,
  .bd-stairbuilder-layout .sec-chev {
    transition: none !important;
  }
}
