/* =========================================================================
   Hardwood Guys Stair Designer: styles.
   Uses only the site's design tokens (/design/tokens.*.css) plus a few wood
   tones for the drawings. Mobile first: viewer on top, questions below. At
   1024px the questions move to a 420px column on the left and the viewer
   sticks on the right.
   ========================================================================= */

.sd {
  --sd-ink: var(--navy);
  --sd-iron: #262626;
  --sd-primed: #f3f0ea;
  --sd-wood-1: #dcb27a;
  --sd-wood-2: #b97d3f;
  --sd-wood-3: #7a4a22;
  --sd-card: var(--white);
  --sd-line: #d7d1c6;
  --sd-cream: #f7f3ec;
  --sd-pink: #e0457b;
  --sd-viewer-h: clamp(300px, 62vw, 460px);
  position: relative;
  color: var(--color-text-body);
}
.sd *, .sd *::before, .sd *::after { box-sizing: border-box; }
.sd button { cursor: pointer; }

/* ---------- keyboard focus: one clear ring on everything you can reach with Tab ---------- */
.sd :is(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--color-focus-ring); outline-offset: 2px; }
.sd .sd-card:focus-visible, .sd .sd-seg button:focus-visible, .sd .sd-chip:focus-visible, .sd .sd-slot:focus-visible, .sd .sd-zone:focus-visible, .sd .sd-toggle:focus-visible { outline-offset: 3px; }
.sd .sd-fullbar button:focus-visible, .sd .sd-modal__close:focus-visible { outline-color: #fff; background: var(--navy); color: #fff; }
.sd .sd-modal__close:focus-visible { outline-color: var(--color-focus-ring); }
#sd-panel-body:focus { outline: none; } /* the heading target after Next, not a control */
.sd-car__track:focus-visible { border-radius: var(--radius-base); }
.sd .sd-ic { display: block; width: 100%; height: 100%; }

/* ---------- page header (compact) ---------- */
.sd-hero .hero__content { padding-block: var(--space-6) var(--space-5); }
.sd-hero .hero__eyebrow { margin-bottom: var(--space-2); }
.sd-hero .hero__title { font-size: clamp(1.7rem, 3vw + 0.6rem, 2.5rem); margin-bottom: var(--space-2); }
.sd-hero .hero__subtitle { margin-bottom: var(--space-3); font-size: var(--text-base); line-height: 1.55; }
.sd-trust { font-size: var(--text-sm); color: var(--white); opacity: .92; margin: 0; }
.sd-tool-section { padding-block: var(--space-6) var(--space-10); background: var(--color-bg-page-alt); }

/* ---------- layout ---------- */
.sd__grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.sd__viewer { order: 1; min-width: 0; }
.sd__panel { order: 2; min-width: 0; }
@media (min-width: 1024px) {
  .sd__grid { grid-template-columns: 420px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
  .sd__panel { order: 1; }
  .sd__viewer { order: 2; position: sticky; top: 112px; }
  .sd { --sd-viewer-h: clamp(420px, calc(100vh - 250px), 640px); }
}

/* ---------- step bar ---------- */
.sd-steps { background: var(--sd-card); border: 1px solid var(--sd-line); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-2) var(--space-2); }
.sd-steps ol { display: grid; grid-template-columns: repeat(6, 1fr); }
.sd-step { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; padding: 4px 2px; min-height: 44px; font-size: 11.5px; line-height: 1.1; color: var(--color-text-muted); font-weight: var(--weight-medium); width: 100%; }
.sd-step__n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: var(--white); font-weight: var(--weight-bold); font-size: 14px; border: 3px solid transparent; transition: border-color .15s; }
.sd-step.is-current { color: var(--navy); font-weight: var(--weight-bold); }
.sd-step.is-current .sd-step__n { border-color: var(--gold); box-shadow: 0 0 0 2px var(--navy) inset; }
.sd-step.is-done .sd-step__n { background: var(--blue); }
.sd-step.is-done .sd-ic--check { width: 16px; height: 16px; }
.sd-step[disabled] { cursor: default; opacity: .8; }
.sd-step:not([disabled]):hover .sd-step__n { border-color: var(--gold); }
@media (min-width: 480px) { .sd-step { font-size: 12.5px; } }
.sd-tools { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.sd-tool-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--sd-card); border: 1px solid var(--navy); border-radius: var(--radius-full); padding: 6px 14px; min-height: 36px; font-size: 13.5px; font-weight: var(--weight-semibold); color: var(--navy); }
.sd-tool-btn:hover { background: var(--navy); color: var(--white); }

/* ---------- panel ---------- */
.sd-panel { background: var(--sd-card); border: 1px solid var(--sd-line); border-radius: var(--radius-lg); margin-top: var(--space-3); display: flex; flex-direction: column; min-height: 320px; }
.sd-panel__body { padding: var(--space-5); }
@media (min-width: 1024px) {
  .sd-panel { max-height: calc(100vh - 250px); min-height: 420px; }
  .sd-panel__body { overflow-y: auto; flex: 1 1 auto; scroll-padding-bottom: 80px; }
}
.sd-panel__head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.sd-badge { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-base); background: var(--gold); color: var(--navy); font-weight: var(--weight-bold); }
.sd-panel__head h2 { font-size: var(--text-lg); margin: 0; }
.sd-q { font-family: var(--font-heading); font-size: 1.08rem; font-weight: var(--weight-semibold); color: var(--navy); margin: var(--space-6) 0 var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.sd-q:first-of-type { margin-top: var(--space-2); }
.sd-q__t { min-width: 0; }
.sd-help { font-size: var(--text-sm); color: var(--color-text-muted); margin: var(--space-3) 0 var(--space-3); line-height: 1.45; }
.sd-q + .sd-help { margin-top: calc(var(--space-2) * -1); }
.sd-grid + .sd-field, .sd-car + .sd-field, .sd-seg + .sd-field { margin-top: var(--space-3); }
.sd-note { font-size: var(--text-sm); background: var(--sd-cream); border-left: 4px solid var(--gold); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); margin: var(--space-4) 0; line-height: 1.5; color: var(--color-text-body); }
.sd-note--pink { border-left-color: var(--sd-pink); }
.sd-note a { color: var(--blue); text-decoration: underline; }

/* ---------- nav (back / next) ---------- */
.sd-nav { position: relative; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5) var(--space-4); border-top: 1px solid var(--sd-line); background: var(--sd-card); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@media (min-width: 1024px) { .sd-nav { position: sticky; bottom: 0; } }
.sd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 22px; border-radius: var(--radius-full); border: 2px solid transparent; font-weight: var(--weight-semibold); font-size: var(--text-base); transition: background-color .15s, color .15s, box-shadow .15s; }
.sd-btn--dark { background: var(--navy); color: var(--white); margin-left: auto; }
.sd-btn--dark:hover { background: #1b1e34; box-shadow: var(--shadow-md); }
.sd-btn--back { background: var(--gold); color: var(--navy); }
.sd-btn--back:hover { box-shadow: var(--shadow-md); }
.sd-btn--out { background: var(--white); color: var(--navy); border-color: var(--navy); }
.sd-btn--out:hover { background: var(--navy); color: var(--white); }
.sd-btn--red { background: var(--color-cta-bg); color: var(--color-cta-text); }
.sd-btn--red:hover { background: var(--color-cta-bg-hover); box-shadow: var(--shadow-md); }
.sd-btn--sm { min-height: 40px; padding: 8px 16px; font-size: var(--text-sm); }
.sd-btn--block { width: 100%; }
.sd-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- cards ---------- */
.sd-grid { display: grid; gap: var(--space-3); }
.sd-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sd-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sd-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .sd-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .sd-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .sd-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sd-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 12px 8px 10px; background: var(--sd-card); border: 2px solid var(--sd-line); border-radius: var(--radius-base); min-height: 44px; color: var(--navy); transition: border-color .15s, box-shadow .15s, background-color .15s; }
.sd-card:hover { border-color: var(--blue); }
.sd-card.is-on { border-color: var(--blue); background: #f2f8fc; box-shadow: 0 0 0 1px var(--blue) inset; }
.sd-card[disabled] { opacity: .45; cursor: not-allowed; }
.sd-card[draggable="true"] { cursor: grab; }
.sd-card[draggable="true"]:active { cursor: grabbing; }
.sd-card[disabled]:hover { border-color: var(--sd-line); }
.sd-card__img { width: 100%; height: 64px; display: grid; place-items: center; }
.sd-card__img .sd-ic { max-height: 64px; width: auto; max-width: 100%; }
.sd-card__img .sd-ic--tall { height: 72px; width: auto; }
.sd-card__img .sd-ic--swatch { width: 100%; height: 56px; border-radius: 4px; }
.sd-card--stairtype .sd-card__img { height: 78px; }
.sd-card__t { font-weight: var(--weight-semibold); font-size: 14.5px; line-height: 1.2; }
.sd-card__s { font-size: 12.5px; line-height: 1.35; color: var(--color-text-muted); }
.sd-card__code { display: inline-block; background: var(--gold); color: var(--navy); font-size: 11px; font-weight: var(--weight-bold); padding: 1px 7px; border-radius: 4px; letter-spacing: .02em; }
.sd-card__tick { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: var(--white); display: none; place-items: center; padding: 4px; }
.sd-card.is-on .sd-card__tick { display: grid; }
.sd-card--wide { flex-direction: row; text-align: left; align-items: center; gap: 12px; padding: 10px 14px; }
.sd-card--wide .sd-card__img { width: 64px; height: 48px; flex: none; }
.sd-card--wide .sd-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* segmented yes/no */
.sd-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-3); }
.sd-seg button { min-height: 46px; padding: 8px 12px; border: 2px solid var(--sd-line); border-radius: var(--radius-full); background: var(--sd-card); color: var(--navy); font-weight: var(--weight-semibold); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sd-seg button:hover { border-color: var(--blue); }
.sd-seg button.is-on { border-color: var(--blue); background: #f2f8fc; box-shadow: 0 0 0 1px var(--blue) inset; }
.sd-seg button .sd-ic--check { width: 16px; height: 16px; color: var(--blue); display: none; }
.sd-seg button.is-on .sd-ic--check { display: block; }

/* chips */
.sd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sd-chip { min-height: 38px; padding: 6px 14px; border-radius: var(--radius-full); border: 2px solid var(--sd-line); background: var(--sd-card); font-weight: var(--weight-semibold); font-size: 14px; color: var(--navy); }
.sd-chip:hover { border-color: var(--blue); }
.sd-chip.is-on { border-color: var(--blue); background: #f2f8fc; }

/* carousel */
.sd-car { position: relative; margin: 0 -4px; }
.sd-car__track { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px 4px 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.sd-car__track::-webkit-scrollbar { display: none; }
.sd-car__track > .sd-card { flex: 0 0 104px; scroll-snap-align: start; }
.sd-car__nav { position: absolute; top: 40%; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--color-cta-bg); color: var(--white); font-size: 20px; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow-md); }
.sd-car__nav--prev { left: -6px; }
.sd-car__nav--next { right: -6px; }
.sd-car__nav[disabled] { opacity: .35; }
.sd-dots { display: flex; justify-content: center; gap: 8px; margin-top: 2px; }
.sd-dots span { width: 9px; height: 9px; border-radius: 50%; background: #d2cbbd; }
.sd-dots span.is-on { background: var(--color-cta-bg); }

/* stepper & fields */
.sd-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.sd-field label, .sd-label { font-weight: var(--weight-semibold); font-size: 14.5px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.sd-field input[type="text"], .sd-field input[type="number"], .sd-field select, .sd-field textarea { width: 100%; min-height: 46px; padding: 8px 12px; border: 2px solid var(--color-border-input); border-radius: var(--radius-base); background: var(--white); font-size: 16px; color: var(--ink); }
.sd-field input:focus-visible, .sd-field select:focus-visible, .sd-field textarea:focus-visible { outline: 3px solid var(--color-focus-ring); outline-offset: 1px; border-color: var(--blue); }
.sd-field input[aria-invalid="true"] { border-color: var(--color-border-input-error); }
.sd-field .sd-err { font-size: 13px; color: var(--color-text-error); min-height: 0; }
.sd-lt { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--gold); color: var(--navy); font-weight: var(--weight-bold); font-size: 13px; }
.sd-measure.is-hl .sd-lt { background: var(--sd-pink); color: var(--white); }
.sd-measure.is-hl label { color: var(--sd-pink); }
.sd-measure.is-hl input { border-color: var(--sd-pink); }
.sd-stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; max-width: 260px; }
.sd-stepper button { min-height: 46px; border: 2px solid var(--navy); border-radius: var(--radius-base); background: var(--white); color: var(--navy); font-size: 22px; font-weight: var(--weight-bold); line-height: 1; }
.sd-stepper button:hover { background: var(--navy); color: var(--white); }
.sd-stepper input { text-align: center; min-height: 46px; border: 2px solid var(--color-border-input); border-radius: var(--radius-base); font-size: 18px; font-weight: var(--weight-bold); width: 100%; background: var(--white); color: var(--ink); }
.sd-check { display: flex; gap: 10px; align-items: center; font-size: 15px; margin-top: var(--space-4); }
.sd-check input { width: 22px; height: 22px; accent-color: var(--navy); flex: none; }
.sd-counter { font-size: 12.5px; color: var(--color-text-muted); text-align: right; }
.sd-chipstat { display: inline-block; margin-top: var(--space-3); background: var(--sd-cream); border: 1px solid var(--sd-line); border-radius: var(--radius-full); padding: 6px 14px; font-size: 14px; color: var(--navy); font-weight: var(--weight-semibold); }

/* info button */
.sd-info { position: relative; width: 28px; height: 28px; border-radius: 50%; border: 0; background: none; color: var(--blue); padding: 2px; flex: none; }
.sd-info::after { content: ""; position: absolute; inset: -9px; } /* a 46px tap target around the 28px icon */
.sd-info:hover { color: var(--navy); }
.sd-checkrow { display: flex; align-items: center; gap: 4px; margin-top: var(--space-4); flex-wrap: wrap; }
.sd-checkrow .sd-check { margin-top: 0; }
.sd-check.is-disabled { color: var(--color-text-muted); }
.sd-check.is-disabled input { cursor: not-allowed; }

/* toggles (risers) */
.sd-toggle { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 2px solid var(--sd-line); border-radius: var(--radius-base); background: var(--white); width: 100%; text-align: left; margin-bottom: 8px; color: var(--navy); }
.sd-toggle.is-on { border-color: var(--blue); background: #f2f8fc; }
.sd-toggle__sw { flex: none; width: 42px; height: 24px; border-radius: 999px; background: #c9c3b6; position: relative; transition: background .15s; }
.sd-toggle__sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); transition: transform .15s; }
.sd-toggle.is-on .sd-toggle__sw { background: var(--blue); }
.sd-toggle.is-on .sd-toggle__sw::after { transform: translateX(18px); }
.sd-toggle__t { font-weight: var(--weight-semibold); font-size: 15px; display: block; }
.sd-toggle__s { font-size: 12.5px; color: var(--color-text-muted); display: block; }
.sd-toggle__thick { margin-left: auto; font-size: 11.5px; font-weight: var(--weight-bold); background: var(--gold); color: var(--navy); padding: 2px 8px; border-radius: 4px; white-space: nowrap; }

/* design a tread */
.sd-slots { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--space-3); }
.sd-slot { width: 52px; height: 92px; border: 2px solid var(--sd-line); border-radius: var(--radius-base); background: var(--white); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 4px 4px 4px; font-weight: var(--weight-bold); color: var(--navy); font-size: 14px; }
.sd-slot .sd-ic { height: 60px; width: auto; }
.sd-slot.is-on { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; background: #f2f8fc; }
.sd-treadprev { flex: 1 1 150px; min-width: 150px; max-width: 220px; border: 2px dashed #d0a35c; border-radius: var(--radius-base); padding: 6px; background: #fffaf2; }
.sd-treadprev figcaption { text-align: center; font-size: 12.5px; font-weight: var(--weight-semibold); color: var(--navy); }
.sd-treadprev svg { width: 100%; height: auto; }

/* ---------- viewer ---------- */
.sd-viewer { background: var(--sd-card); border: 1px solid var(--sd-line); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.sd-viewer__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--sd-cream); border-bottom: 1px solid var(--sd-line); }
.sd-tabs { display: inline-flex; background: #ece4d6; border-radius: var(--radius-full); padding: 3px; }
.sd-tabs button { border: 0; background: none; padding: 7px 16px; min-height: 36px; border-radius: var(--radius-full); font-weight: var(--weight-semibold); font-size: 14px; color: var(--color-text-muted); }
.sd-tabs button[aria-selected="true"] { background: var(--navy); color: var(--white); }
.sd-vtools { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sd-vbtn { border: 1px solid var(--sd-line); background: var(--white); border-radius: 8px; min-width: 36px; min-height: 36px; padding: 0 10px; font-weight: var(--weight-semibold); font-size: 13.5px; color: var(--navy); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sd-vbtn:hover { background: var(--navy); color: var(--white); border-color: var(--navy); }
.sd-vbtn[aria-pressed="true"] { background: var(--navy); color: var(--white); border-color: var(--navy); }
.sd-vbtn svg { width: 18px; height: 18px; }
.sd-stage { position: relative; height: var(--sd-viewer-h); background: linear-gradient(#efe6d6, #e4d8c3); overflow: hidden; touch-action: pan-y; }
.sd-stage--3d { touch-action: none; }
.sd-stage > .sd-view { position: absolute; inset: 0; display: none; }
.sd-stage > .sd-view.is-on { display: block; }
.sd-view--svg { display: none; padding: 8px; }
.sd-view--svg.is-on { display: grid; place-items: center; }
.sd-view--svg .sd-zoomwrap { width: 100%; height: 100%; transition: transform .15s; transform-origin: center; }
.sd-view--svg svg { width: 100%; height: 100%; }
.sd-canvas { display: block; width: 100%; height: 100%; }
.sd-hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(40, 44, 72, .88); color: var(--white); border-radius: var(--radius-full); padding: 6px 14px; font-size: 13px; font-weight: var(--weight-semibold); pointer-events: none; display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }
.sd-presets[hidden], .sd-hint[hidden] { display: none !important; }
.sd-presets { position: absolute; left: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 20px); z-index: 3; }
.sd-presets .sd-vbtn { min-height: 32px; font-size: 12.5px; padding: 0 10px; background: rgba(255,255,255,.92); }
.sd-presets .sd-vbtn:hover, .sd-presets .sd-vbtn[aria-pressed="true"] { background: var(--navy); color: var(--white); border-color: var(--navy); }
.sd-empty { position: absolute; inset: 0; display: none; padding: 14px; overflow: auto; background: linear-gradient(#efe6d6, #e4d8c3); }
.sd-empty.is-on { display: block; }
.sd-empty h3 { text-align: center; font-size: 1.15rem; margin-bottom: 10px; }
.sd-empty .sd-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 768px) { .sd-empty .sd-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sd-error3d { position: absolute; inset: 0; display: none; place-items: center; text-align: center; padding: 20px; background: #efe6d6; font-size: 15px; }
.sd-error3d.is-on { display: grid; }
.sd-loading { position: absolute; inset: 0; display: none; place-items: center; background: #efe6d6; font-weight: var(--weight-semibold); color: var(--navy); }
.sd-loading.is-on { display: grid; }

/* the red box: the tread being designed or placed on */
.sd-redbox { fill: rgba(214, 40, 57, .08); stroke: #d62839; stroke-width: 1.8; pointer-events: none; }
.sd-redtext { fill: #d62839; font-weight: 800; font-family: var(--font-body); pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 2.4px; stroke-linejoin: round; }

/* ---------- placing balusters by hand ("Add them one by one") ----------
   On desktop the board sits under the picture, inside the viewer (.sd-dock). On a phone the viewer is
   above the questions, so the same board is drawn inside step 4, right above the list of balusters. */
.sd-dock { background: var(--sd-cream); border-top: 1px solid var(--sd-line); padding: 10px 12px 12px; }
.sd-dock[hidden] { display: none; }
@media (min-width: 1024px) { .sd-viewer.has-dock .sd-stage { height: max(240px, calc(var(--sd-viewer-h) - 262px)); } }
.sd-place { display: grid; gap: 8px; }
.sd-place__top { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.sd-place__nav { display: inline-flex; align-items: center; gap: 8px; }
.sd-place__step { min-width: 96px; text-align: center; color: var(--navy); font-size: 14.5px; }
.sd-place__scope { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.sd-place .sd-vbtn.is-on { background: var(--navy); color: var(--white); border-color: var(--navy); }
.sd-place .sd-vbtn[disabled] { opacity: .4; cursor: not-allowed; }
.sd-place__box { border: 3px solid #d62839; border-radius: 10px; background: #fffaf2; padding: 8px 12px 0; display: grid; justify-items: center; }
.sd-place__rail { width: 100%; height: 10px; border-radius: 5px; background: var(--sd-wood-3); }
.sd-place__zones { display: flex; justify-content: center; gap: 14px; margin-top: 4px; flex-wrap: nowrap; max-width: 100%; }
.sd-zone { position: relative; flex: 0 1 116px; min-width: 70px; min-height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; border: 2px dashed #b9ad98; border-radius: 8px; background: transparent; padding: 20px 4px 4px; color: var(--navy); }
.sd-zone:hover { border-color: var(--blue); }
.sd-zone__ic { display: block; height: 62px; }
.sd-zone__ic .sd-ic { height: 62px; width: auto; }
.sd-zone__t { font-size: 11.5px; font-weight: var(--weight-semibold); line-height: 1.1; text-align: center; }
.sd-zone__n { position: absolute; top: 3px; left: 5px; width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: var(--white); font-size: 12px; font-weight: var(--weight-bold); display: grid; place-items: center; }
.sd-zone.is-on { border: 2px solid var(--blue); background: #f2f8fc; box-shadow: 0 0 0 1px var(--blue) inset; }
.is-dragging .sd-zone { border-color: #d62839; }
.sd-zone.is-over { border-color: #d62839; background: #fff1f2; box-shadow: 0 0 0 2px #d62839 inset; }
.sd-zone.is-hand::after { content: "by hand"; position: absolute; top: 3px; right: 4px; font-size: 10px; font-weight: var(--weight-bold); background: var(--gold); color: var(--navy); border-radius: 4px; padding: 0 5px; }
.sd-place__tread { width: 100%; height: 16px; border-radius: 6px 6px 0 0; background: var(--sd-wood-1); border: 1.5px solid var(--navy); border-bottom: 0; }
.sd-place__bottom { display: flex; gap: 8px 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sd-place__hint { flex: 1 1 220px; margin: 0; font-size: 13px; color: var(--color-text-muted); line-height: 1.35; }
.sd-place__bottom .sd-btn { flex: none; min-height: 38px; }
.sd-panel__body .sd-place { background: var(--sd-cream); border: 1px solid var(--sd-line); border-radius: 10px; padding: 10px; margin: 12px 0; }

/* plan / side drawing colors */
.sd-floor { fill: #f3ecdf; }
.sd-upper { fill: #ead9bd; stroke: #bfa57c; stroke-width: .6; stroke-dasharray: 3 2; }
.sd-tread { fill: var(--sd-wood-1); stroke: var(--sd-ink); stroke-width: .9; }
.sd-winder { fill: #cf9d63; stroke: var(--sd-ink); stroke-width: .9; }
.sd-landing { fill: var(--sd-wood-2); stroke: var(--sd-ink); stroke-width: 1.1; }
.sd-pole { fill: var(--sd-ink); }
.sd-spiral-edge { fill: none; stroke: var(--sd-ink); stroke-width: 1.4; }
.sd-wall { stroke: var(--sd-ink); stroke-width: 4; stroke-linecap: square; opacity: .85; }
.sd-rail { fill: none; stroke: var(--sd-wood-3); stroke-width: 2.6; stroke-dasharray: .1 4.2; stroke-linecap: round; stroke-linejoin: round; }
.sd-rail--balcony { stroke: var(--sd-wood-3); }
.sd-wallrail { stroke: var(--sd-wood-2); stroke-width: 1.6; opacity: .9; }
.sd-newel { fill: var(--sd-wood-3); stroke: var(--sd-ink); stroke-width: .5; }
.sd-up line { stroke: var(--sd-ink); stroke-width: 1.6; }
.sd-up polygon { fill: var(--sd-ink); }
.sd-up text, .sd-uptext { fill: var(--sd-ink); font-weight: 800; letter-spacing: .06em; font-family: var(--font-body); }
.sd-dim line { stroke: #7d776a; stroke-width: .9; }
.sd-dim polygon { fill: #7d776a; }
.sd-dim text { fill: #5d584d; font-family: var(--font-body); font-weight: 700; }
.sd-dim.is-hl line { stroke: var(--sd-pink); stroke-width: 1.8; }
.sd-dim.is-hl polygon { fill: var(--sd-pink); }
.sd-dim.is-hl text { fill: var(--sd-pink); }
.sd-ground { stroke: #8a7f6a; stroke-width: 1; }
.sd-profile { fill: #ead9bd; }
.sd-profile-line { fill: none; stroke: var(--sd-ink); stroke-width: 1.3; stroke-linejoin: round; }
.sd-bal { stroke: var(--sd-iron); stroke-width: .8; }
.sd-rail-side { stroke: var(--sd-wood-3); stroke-width: 2.6; stroke-linecap: round; }
.sd-note { fill: #5d584d; font-family: var(--font-body); }

/* stats strip */
.sd-stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--sd-cream); border-top: 1px solid var(--sd-line); }
.sd-stat { padding: 10px 6px; text-align: center; border-left: 1px solid var(--sd-line); min-width: 0; }
.sd-stat:first-child { border-left: 0; }
.sd-stat__v { display: block; font-family: var(--font-heading); font-weight: var(--weight-bold); font-size: clamp(1.05rem, 3.4vw, 1.5rem); color: var(--navy); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sd-stat__l { display: block; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); font-weight: var(--weight-semibold); }
@media (min-width: 480px) { .sd-stat { padding: 12px 14px; text-align: left; } .sd-stat__l { font-size: 11.5px; } }
.sd-warn { margin: 0; padding: 8px 12px; font-size: 13px; background: #fff6e0; color: #5a4300; border-top: 1px solid #ecd9a4; display: none; }
.sd-warn.is-on { display: block; }

/* full screen */
.sd-viewer.is-full { position: fixed; inset: 0; z-index: 400; border-radius: 0; border: 0; height: 100%; width: 100%; background: var(--sd-card); }
.sd-viewer.is-full .sd-stage { height: auto; flex: 1 1 auto; }
.sd-viewer:fullscreen { border-radius: 0; border: 0; background: var(--sd-card); }
.sd-viewer:fullscreen .sd-stage { height: auto; flex: 1 1 auto; }
.sd-fullbar { display: none; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--navy); color: var(--white); }
.sd-viewer.is-full .sd-fullbar, .sd-viewer:fullscreen .sd-fullbar { display: flex; }
.sd-fullbar button { background: none; border: 0; color: var(--white); font-weight: var(--weight-semibold); display: inline-flex; gap: 8px; align-items: center; min-height: 40px; padding: 0 8px; }
.sd-fullbar button:hover { text-decoration: underline; }
body.sd-lock { overflow: hidden; }

/* toast */
.sd-toast { position: fixed; left: 50%; top: 92px; transform: translate(-50%, -16px); max-width: min(92vw, 560px); background: var(--navy); color: var(--white); padding: 12px 18px; border-radius: var(--radius-base); box-shadow: var(--shadow-lg); font-weight: var(--weight-semibold); font-size: 15px; z-index: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; border-left: 5px solid var(--gold); }
.sd-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1024px) { .sd-toast { top: 126px; } }

/* modal */
.sd-modal { border: 0; border-radius: var(--radius-lg); padding: 0; max-width: min(92vw, 460px); width: 100%; box-shadow: var(--shadow-lg); color: var(--color-text-body); }
.sd-modal::backdrop { background: rgba(13, 13, 13, .55); }
.sd-modal__in { padding: var(--space-6); }
.sd-modal h3 { font-size: var(--text-lg); margin-bottom: var(--space-3); padding-right: 36px; }
.sd-modal__close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--sd-cream); color: var(--navy); font-size: 20px; line-height: 1; }
.sd-modal__img { display: grid; place-items: center; background: var(--sd-cream); border-radius: var(--radius-base); padding: var(--space-4); margin-bottom: var(--space-3); }
.sd-modal__img .sd-ic { max-height: 150px; width: auto; }
.sd-modal__row { display: flex; gap: 10px; align-items: center; }
.sd-modal__row input { flex: 1 1 auto; min-height: 56px; font-size: 26px; font-weight: var(--weight-bold); padding: 6px 14px; border: 2px solid var(--color-border-input); border-radius: var(--radius-base); width: 100%; }
.sd-modal .sd-btn { margin-top: var(--space-4); width: 100%; }

.sd-modal--video { max-width: min(94vw, 860px); }
.sd-video { position: relative; aspect-ratio: 16 / 9; background: #0d0d0d; border-radius: var(--radius-base); overflow: hidden; margin-bottom: var(--space-3); }
.sd-video__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sd-video__cap { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0 0 var(--space-2); font-weight: var(--weight-semibold); }
.sd-modal__img .sd-ic.sd-ic--info { width: 100%; max-width: 400px; height: auto; max-height: none; aspect-ratio: 240 / 130; }
.sd-modal__img .sd-ic.sd-ic--info text { font-family: var(--font-body); }

/* ---------- list (step 6) ---------- */
.sd-done { background: var(--sd-cream); border: 1px solid var(--sd-line); border-radius: var(--radius-base); padding: var(--space-5); margin-bottom: var(--space-4); }
.sd-done h2 { font-size: var(--text-lg); margin: 0 0 var(--space-2); }
.sd-done p { margin: 0 0 var(--space-4); }
.sd-done__btns { display: grid; gap: 10px; }
@media (min-width: 420px) { .sd-done__btns--2 { grid-template-columns: 1fr 1fr; } }
.sd-list h2 { font-size: var(--text-xl); margin: 0 0 4px; }
.sd-summary { color: var(--color-text-muted); margin: 0 0 var(--space-4); font-size: 15px; line-height: 1.5; }
.sd-measure-box { background: #fff8e8; border: 2px solid var(--gold); border-radius: var(--radius-base); padding: var(--space-5); margin-bottom: var(--space-5); }
.sd-measure-box h3 { font-size: 1.15rem; margin: 0 0 8px; }
.sd-measure-box p { margin: 0 0 var(--space-4); font-size: 15px; }
.sd-group h3 { font-size: 1.05rem; color: var(--sd-wood-2); border-bottom: 2px solid #e3d3b8; padding-bottom: 4px; margin: var(--space-5) 0 var(--space-2); text-transform: none; }
.sd-item { display: grid; grid-template-columns: 62px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid #ece5d8; }
.sd-item__q { text-align: center; line-height: 1; }
.sd-item__q b { display: block; font-family: var(--font-heading); font-size: 1.7rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.sd-item__q small { display: block; margin-top: 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); font-weight: var(--weight-semibold); }
.sd-item__n { font-weight: var(--weight-semibold); color: var(--navy); }
.sd-item__code { margin-left: 8px; }
.sd-item__spec { font-size: 14px; color: var(--color-text-body); margin-top: 2px; }
.sd-item__why { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.sd-quote { background: var(--sd-cream); border: 1px dashed var(--sd-wood-2); border-radius: var(--radius-base); padding: var(--space-5); margin: var(--space-4) 0; }
.sd-disc { font-size: 13.5px; color: var(--color-text-muted); line-height: 1.5; margin-top: var(--space-5); }
.sd-disc li { list-style: disc; margin-left: 18px; margin-bottom: 6px; }
.sd-sendbar { display: grid; gap: 10px; margin: var(--space-4) 0; }
@media (min-width: 420px) { .sd-sendbar { grid-template-columns: 1fr 1fr; } }
.sd-warrant { font-weight: var(--weight-semibold); color: var(--navy); margin: 0 0 var(--space-3); }

/* the page below the tool */
.sd-copy { padding-block: var(--space-12); }
.sd-copy .prose { max-width: 74ch; }
.sd-copy .prose p + p { margin-top: var(--space-4); }
.sd-copy .prose h3 { margin-top: var(--space-8); }

/* ---------- phones ---------- */
@media (max-width: 1023px) {
  /* Back / Next stays in reach while the questions are in view. The site's own Call / Text / Free Estimate bar is fixed to the bottom of
     the screen on phones (about 62px, see .has-mobile-cta-bar in components.css), so this sits just above it. */
  .sd-nav { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -6px 14px rgba(13, 13, 13, .08); }
  /* ...and neither bar hides what you tabbed to or scrolled to (64px bar + about 66px of Back / Next) */
  .sd :is(button, input, select, textarea, a, [tabindex]) { scroll-margin-block: 92px 150px; }
  .sd-chip { min-height: 44px; }
  .sd-vbtn { min-height: 40px; }
  .sd-presets .sd-vbtn { min-height: 36px; }
  .sd-car__nav { width: 40px; height: 40px; top: 36%; }
  .sd-tools { justify-content: flex-start; }
  .sd-tool-btn { min-height: 44px; }
  .sd-place__scope { width: 100%; }
  .sd-place__scope .sd-vbtn { flex: 1 1 auto; white-space: normal; line-height: 1.15; padding-block: 6px; }
}
/* a phone turned sideways: keep the picture inside the screen */
@media (max-height: 520px) and (orientation: landscape) { .sd { --sd-viewer-h: max(220px, calc(100vh - 150px)); } }

@media (prefers-reduced-motion: reduce) {
  .sd *, .sd-toast { transition: none !important; }
}

/* ---------- the photo path (photo.js, photoui.js) ---------- */
.sd-tabs button[hidden] { display: none; }
@media (max-width: 480px) { .sd-tabs button { padding: 7px 12px; } }
.sd-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--blue); text-decoration: underline; font: inherit; font-weight: var(--weight-semibold); cursor: pointer; }
.sd-link:hover { color: var(--navy); }
.sd-startline { margin: var(--space-3) 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.sd-photo { margin-bottom: var(--space-3); }
.sd-photo__btns { display: flex; flex-wrap: wrap; gap: 10px; margin: var(--space-3) 0; }
.sd-photo__btns .sd-btn { margin-left: 0; }
.sd-photo__prev { margin: 0 0 var(--space-3); border: 2px solid var(--sd-line); border-radius: var(--radius-base); background: var(--sd-cream); padding: 6px; display: grid; place-items: center; }
.sd-photo__prev img { display: block; max-width: 100%; max-height: 260px; width: auto; height: auto; border-radius: 4px; }
.sd-note--ok { border-left-color: #1f8a4c; background: #f1f9f4; }
.sd-note--warn { border-left-color: var(--sd-pink); }
.sd-photo__busy { display: flex; align-items: center; gap: 10px; }
.sd-spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--sd-line); border-top-color: var(--navy); animation: sd-spin .9s linear infinite; flex: none; display: inline-block; }
@keyframes sd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sd-spin { animation-duration: 3s !important; } }

/* the Photo tab in the viewer */
.sd-view--photo { display: none; background: #1f2238; }
.sd-view--photo.is-on { display: block; }
.sd-photo__canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; touch-action: pan-y; }
.sd-photo__canvas.is-marking { touch-action: none; cursor: crosshair; }
.sd-photo__msg { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: calc(100% - 24px); background: rgba(40, 44, 72, .92); color: var(--white); border-radius: var(--radius-full); padding: 7px 16px; font-size: 13.5px; font-weight: var(--weight-semibold); text-align: center; pointer-events: none; display: none; }
.sd-photo__msg.is-on { display: block; }
.sd-photo__busyover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(31, 34, 56, .72); color: var(--white); font-weight: var(--weight-semibold); font-size: 1.05rem; text-align: center; padding: 20px; }
.sd-photo__busyover[hidden] { display: none; }
.sd-photo__busyover .sd-spin { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.sd-photobar { padding: 10px 12px 12px; background: var(--sd-cream); border-top: 1px solid var(--sd-line); display: grid; gap: 8px; }
.sd-photobar[hidden] { display: none; }
.sd-photobar__row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.sd-photobar__modes { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.sd-photobar .sd-btn { margin-left: 0; }
.sd-photobar__warn { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: #fff6e0; color: #5a4300; border: 1px solid #ecd9a4; font-size: 13.5px; }
.sd-photobar__warn[hidden] { display: none; }
.sd-photobar__how { margin: 0; font-size: 14px; color: var(--navy); }
.sd-photobar__note { margin: 0; font-size: 12.5px; color: var(--color-text-muted); }
.sd-photobar__ctl { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.sd-range { display: grid; gap: 4px; font-size: 13px; font-weight: var(--weight-semibold); color: var(--navy); }
.sd-range input { width: 100%; accent-color: var(--navy); }
.sd-photobar__paint { margin-top: 0; font-size: 14px; }
.sd-photobar__ctl .sd-btn { justify-self: end; }
@media (max-width: 480px) { .sd-photobar__paint, .sd-photobar__ctl .sd-btn { grid-column: 1 / -1; justify-self: start; } }
.sd-share { margin: var(--space-3) 0; }
.sd-share .sd-btn { margin-left: 0; width: 100%; }
@media (min-width: 420px) { .sd-share .sd-btn { width: auto; } }

/* the saved-design page (/stairs/estimate/<id>) */
.sd-est__grid { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .sd-est__grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
  .sd-est .sd__viewer { position: sticky; top: 112px; }
}
.sd-est .sd__viewer { order: 0; }
.sd-est .sd-list { background: var(--sd-card); border: 1px solid var(--sd-line); border-radius: var(--radius-lg); padding: var(--space-5); }
.sd-vbtn[hidden] { display: none; }
