/* Drafting-set look: cool drafting-film paper, ink hairlines, condensed technical
   lettering, DeckWise orange reserved for markup (selection, totals, actions). */
:root {
    --paper: #e9edef;        /* drafting film behind the drawing */
    --sheet: #fafbfb;        /* panels */
    --ink: #1b2830;          /* linework and text */
    --ink-soft: #52626c;     /* secondary text */
    --ink-faint: #8796a0;    /* captions, units */
    --rule: #c3ced4;         /* hairline borders */
    --rule-soft: #dde4e8;    /* inner dividers, grid */
    --accent: #ff6600;       /* DeckWise orange, markup only */
    --accent-ink: #c94f00;   /* orange text on light ground */
    --accent-wash: rgba(255, 102, 0, 0.07);
    --ok: #2f7d4f;
    --bad: #b3261e;

    /* Bebas Neue for headings and buttons; Barlow for everything else. */
    --font-display: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
    --font-label: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
    --font-data: 'Barlow', 'Helvetica Neue', Arial, sans-serif;

    /* Older names still used by inline styles in the scripts. */
    --orange: var(--accent);
    --orange-dark: var(--accent-ink);
    --orange-light: var(--accent);
    --secondary: var(--ink);
    --secondary-light: var(--ink-soft);
    --dark: var(--ink);
    --dark2: var(--ink);
    --gray: var(--ink-soft);
    --gray-light: var(--ink-faint);
    --light: var(--paper);
    --white: var(--sheet);
    --green: var(--ok);
    --red: var(--bad);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    font-size: 14px;
}

button, input, select, textarea { font-family: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Header: drawing title block ---------- */
header {
    background: var(--sheet);
    color: var(--ink);
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    flex-wrap: wrap;
    border-bottom: 1.5px solid var(--ink);
}
.logo {
    font-family: var(--font-label);
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    padding: 12px 20px;
    line-height: 1.1;
}
.logo span { color: var(--accent); }
.logo sup { font-size: 0.55em; font-weight: 400; }
.logo small {
    font-family: var(--font-data);
    font-size: 0.66rem;
    color: var(--ink-faint);
    font-weight: 400;
    display: block;
    letter-spacing: 2px;
    margin-top: 3px;
}
.header-right { display: flex; align-items: stretch; flex-wrap: wrap; }
.header-right > * { border-left: 1px solid var(--rule); }
.version-chip {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-family: var(--font-data);
    font-size: 0.7rem;
    color: var(--ink-faint);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.icon-btn {
    background: transparent;
    border: none;
    border-left: 1px solid var(--rule);
    padding: 0 18px;
    cursor: pointer;
    font-family: var(--font-label);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.total-display {
    display: flex;
    align-items: center;
    padding: 0 22px;
    font-family: var(--font-data);
    font-weight: 500;
    font-size: 1.2rem;
    color: var(--accent-ink);
    font-variant-numeric: tabular-nums;
    position: relative;
    min-height: 58px;
}
.total-display::before {
    content: 'DECKWISE TOTAL';
    position: absolute;
    top: 7px;
    left: 22px;
    font-family: var(--font-label);
    font-size: 0.58rem;
    letter-spacing: 1.5px;
    color: var(--ink-faint);
}
.total-display { padding-top: 12px; }

/* ---------- Buy Now bar ---------- */
.buy-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 20px;
    background: var(--sheet);
    border-bottom: 1px solid var(--rule);
    flex-wrap: wrap;
}
.buy-bar-label {
    font-family: var(--font-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--ink-faint);
    letter-spacing: 2px;
    flex-shrink: 0;
}
.buy-bar-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.buy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 14px;
    border: 1px solid var(--ink);
    border-radius: 2px;
    text-decoration: none;
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--sheet);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.buy-btn:hover { background: var(--ink); color: var(--sheet); }
.buy-btn-icon { display: none; }
.buy-btn-deckwise { background: var(--ink); color: var(--sheet); }
.buy-btn-deckwise:hover { background: var(--accent); border-color: var(--accent); }
.buy-btn-homedepot::before, .buy-btn-amazon::before {
    content: '';
    width: 8px; height: 8px;
    background: #f96302;
}
.buy-btn-amazon::before { background: #ff9900; }

@media (max-width: 700px) {
    .buy-bar { padding: 8px 14px; gap: 8px; }
    .buy-btn { padding: 6px 10px; font-size: 0.75rem; }
}

/* ---------- Layout ---------- */
.app-layout {
    display: grid;
    /* Sidebars narrow on smaller screens so plan stays in the middle; stack only on phones. */
    grid-template-columns: clamp(220px, 24vw, 320px) minmax(0, 1fr) clamp(220px, 24vw, 320px);
    min-height: calc(100vh - 110px);
}
.panel-left, .panel-right {
    background: var(--sheet);
    overflow-y: auto;
    max-height: calc(100vh - 110px);
}
.panel-left  { border-right: 1px solid var(--rule); }
.panel-right { border-left:  1px solid var(--rule); }

.panel-section {
    padding: 18px 20px;
    border-bottom: 1px solid var(--rule);
}
/* Section headings as drawing detail callouts: number in a circle, label on a rule. */
.panel-section h3 {
    font-family: var(--font-label);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.6px;
    color: var(--ink);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.panel-section h3::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rule);
}
/* Steps fold to their heading; the heading opens and closes them. */
.panel-section h3[role="button"] { cursor: pointer; user-select: none; -webkit-user-select: none; }
.panel-section h3[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.panel-section h3::after { order: 1; }
.panel-section h3 .chev {
    order: 2; flex-shrink: 0; width: 8px; height: 8px; margin: 0 4px 3px 2px;
    border-right: 1.75px solid var(--ink); border-bottom: 1.75px solid var(--ink);
    transform: rotate(45deg); transition: transform 0.15s;
}
.panel-section.collapsed h3 .chev { transform: rotate(-45deg); margin-bottom: 0; }
.panel-section.collapsed { padding-top: 14px; padding-bottom: 14px; }
.panel-section.collapsed h3 { margin-bottom: 0; }
.panel-section.collapsed > :not(h3) { display: none !important; }
.panel-section h3[role="button"]:hover .icon { background: var(--accent); border-color: var(--accent); color: #fff; }
.panel-section h3 .icon {
    width: 24px; height: 24px;
    border: 1.5px solid var(--ink);
    border-radius: 50%;
    color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-data);
    font-size: 0.7rem;
    font-weight: 500;
    flex-shrink: 0;
}

/* ---------- Inputs ---------- */
.input-group, .slider-group { margin-bottom: 14px; }
.input-group label, .slider-group label {
    display: block;
    font-family: var(--font-label);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.slider-group label { display: flex; justify-content: space-between; align-items: baseline; }
.slider-group label .val {
    font-family: var(--font-data);
    color: var(--ink);
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0;
    text-transform: none;
    font-variant-numeric: tabular-nums;
}
.input-group input, .input-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-bottom-color: var(--ink-soft);
    border-radius: 2px;
    font-family: var(--font-data);
    font-size: 0.86rem;
    background: var(--sheet);
}
.input-group input:focus, .input-group select:focus { outline: none; border-color: var(--accent); }

/* Slider drawn as a scale rule with tick marks. */
input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    background:
        linear-gradient(var(--ink-soft), var(--ink-soft)) center / 100% 1px no-repeat,
        repeating-linear-gradient(90deg, var(--ink-faint) 0 1px, transparent 1px 10%) center / 100% 7px no-repeat;
    outline: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 16px;
    background: var(--accent);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 12px; height: 16px;
    background: var(--accent);
    clip-path: polygon(50% 100%, 0 0, 100% 0);
    border: none;
    border-radius: 0;
    cursor: pointer;
}

/* ---------- Wood / fastener tiles ---------- */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
/* Decking groups: tabs over the swatches of the open group. */
.mat-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); margin-bottom: 8px; }
.mat-tab {
    position: relative; background: var(--sheet); color: var(--ink-soft); border: 0; border-right: 1px solid var(--ink-faint, #8796a0);
    border-bottom: 1px solid var(--ink-faint, #8796a0); padding: 7px 4px; cursor: pointer;
    font-family: var(--font-label); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.mat-tab:nth-child(2n) { border-right: 0; }
.mat-tab:nth-last-child(-n+2) { border-bottom: 0; }
.mat-tab:hover { color: var(--ink); }
.mat-tab.on { background: var(--ink); color: var(--sheet); }
/* Compact rows: a small wood chip beside the name. */
#woodGrid .tile { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 0.8rem; line-height: 1.2; }
#woodGrid .wood-swatch { width: 26px; height: 18px; flex: none; margin-bottom: 0; }
.mat-dot { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.tile {
    padding: 8px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
    font-family: var(--font-label);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.4px;
    background: var(--sheet);
}
.tile:hover { border-color: var(--ink-soft); }
.tile.selected { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
/* Material swatch with a hatch, like a material legend on a drawing. */
.wood-swatch {
    width: 100%; height: 20px;
    border: 1px solid var(--ink);
    margin-bottom: 6px;
    background-blend-mode: multiply;
    background-image: repeating-linear-gradient(0deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 4px) !important;
}
.fastener-list { display: grid; gap: 6px; }
.fastener-row {
    padding: 9px 10px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    background: var(--sheet);
}
.fastener-row:hover { border-color: var(--ink-soft); }
.fastener-row.selected { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.fastener-row .f-icon {
    width: 40px; height: 26px;
    border: 1px solid var(--ink);
    color: var(--ink);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-data);
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.fastener-row.selected .f-icon { background: var(--accent); border-color: var(--accent); color: #fff; }
.fastener-row .f-name { font-family: var(--font-label); font-size: 0.86rem; font-weight: 500; color: var(--ink); }
.fastener-row .f-desc { font-family: var(--font-data); font-size: 0.66rem; color: var(--ink-faint); margin-top: 2px; }

/* ---------- Shape picker ---------- */
.shape-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.shape-tile {
    padding: 8px 4px 6px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    cursor: pointer;
    text-align: center;
    background: var(--sheet);
    font-family: var(--font-label);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--ink-soft);
    transition: border-color 0.15s, background 0.15s;
}
.shape-tile svg { width: 100%; height: 30px; color: var(--ink-faint); display: block; margin-bottom: 4px; }
.shape-tile svg * { fill: none !important; stroke: currentColor; stroke-width: 1.5px; }
.shape-tile svg .dot { fill: currentColor !important; stroke: none; }
.shape-tile:hover { border-color: var(--ink-soft); }
.shape-tile:hover svg { color: var(--ink); }
.shape-tile.selected { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.shape-tile.selected svg { color: var(--accent); }

.cutout-box {
    border: 1px dashed var(--ink-faint);
    background: transparent;
    border-radius: 0;
    padding: 10px;
    margin-bottom: 14px;
}

/* ---------- Custom outline ---------- */
.custom-box {
    border: 1px dashed var(--accent);
    padding: 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.custom-note { font-size: 0.8rem; line-height: 1.45; color: var(--ink); }
.custom-note strong { font-family: var(--font-label); font-weight: 600; letter-spacing: 0.4px; }
.custom-tips { font-size: 0.74rem; line-height: 1.45; color: var(--ink-soft); padding-left: 16px; display: grid; gap: 3px; }
.custom-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.custom-actions .btn, .custom-wide { padding: 8px; font-size: 0.76rem; }
.custom-wide { width: 100%; }
.custom-summary { display: grid; gap: 4px; }
.custom-summary div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--rule); padding-bottom: 4px; }
.custom-summary dt { font-family: var(--font-label); font-size: 0.7rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); }
.custom-summary dd { font-family: var(--font-data); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: 0.4; cursor: default; }
.link-btn {
    background: none;
    border: none;
    font-family: var(--font-label);
    font-size: 0.74rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
    text-decoration: underline;
    cursor: pointer;
    align-self: center;
}
.link-btn:hover { color: var(--ink); }

/* ---------- House attachment ---------- */
.seg-toggle { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); }
.seg {
    padding: 8px 6px;
    background: var(--sheet);
    border: none;
    cursor: pointer;
    font-family: var(--font-label);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ink);
}
.seg + .seg { border-left: 1px solid var(--ink); }
.seg:hover { background: var(--paper); }
.seg.selected { background: var(--ink); color: var(--sheet); }
.house-box {
    border: 1px solid var(--rule);
    border-left: 3px solid var(--ink);
    padding: 10px 12px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.house-color-label {
    font-family: var(--font-label);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.house-colors, .swatch-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.swatch-row { margin-top: 6px; }
.swatch-label {
    margin-top: 10px;
    font-family: var(--font-label);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.house-color, .swatch {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: var(--sheet);
    cursor: pointer;
    font-family: var(--font-label);
    font-size: 0.74rem;
    color: var(--ink);
    text-align: left;
}
.house-color:hover, .swatch:hover { border-color: var(--ink-soft); }
.house-color.selected, .swatch.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-wash); }
.swatch .chip-clear { background: repeating-linear-gradient(45deg, var(--sheet) 0 3px, var(--rule) 3px 4px); }
.house-color .chip, .swatch .chip { width: 16px; height: 12px; border: 1px solid var(--ink); flex-shrink: 0; }
.custom-tips-plain { font-size: 0.74rem; line-height: 1.45; color: var(--ink-soft); }

/* ---------- Feature buttons (Add Stairs/Door) ---------- */
.feature-add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.feature-add-btn {
    padding: 8px 4px;
    border: 1px solid var(--ink);
    border-radius: 2px;
    cursor: pointer;
    background: var(--sheet);
    font-family: var(--font-label);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--ink);
    transition: background 0.15s, color 0.15s;
}
.feature-add-btn:hover { background: var(--paper); }
.feature-add-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: var(--sheet);
    margin-bottom: 5px;
}
.feature-item .feature-type-stair,
.feature-item .feature-type-door,
.feature-item .feature-type-wall {
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--ink);
    color: var(--ink);
    background: transparent;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.feature-info { flex: 1; font-size: 0.78rem; line-height: 1.3; min-width: 0; }
.feature-info strong { font-family: var(--font-label); font-weight: 600; letter-spacing: 0.4px; }
.feature-info small { display: block; font-family: var(--font-data); color: var(--ink-faint); font-size: 0.68rem; }
.feature-del {
    background: transparent;
    border: none;
    color: var(--bad);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
}
.feature-del:hover { color: var(--ink); }

.feature-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.feature-action-row .btn { padding: 7px; font-size: 0.78rem; }

/* ---------- Cable railing ---------- */
.rail-note { margin-top: 6px; font-size: 0.74rem; line-height: 1.45; color: var(--ink-soft); }
.rail-note:empty { display: none; }
.rail-link { margin-top: 6px; display: inline-block; }
.rod-row { display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; }
.rod-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px dashed var(--accent);
    background: var(--accent-wash);
    font-family: var(--font-label);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ink);
    cursor: grab;
    user-select: none;
}
.rod-chip:active { cursor: grabbing; }
.rod-mode { padding: 6px 10px; font-size: 0.72rem; }

/* ---------- Stair sizes ---------- */
.stair-sizes { border-top: 1px dashed var(--rule); margin-top: 10px; padding-top: 10px; }
.stair-size-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stair-size-row .input-group { margin-bottom: 6px; min-width: 0; }
.stair-size-row input:invalid { border-color: var(--bad); }
.stair-summary { font-family: var(--font-data); font-size: 0.74rem; color: var(--ink); line-height: 1.5; }
.stair-warn { display: block; margin-top: 4px; font-family: var(--font-body); color: var(--bad); }

/* ---------- Toggle ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.toggle-row span { font-family: var(--font-label); font-size: 0.86rem; font-weight: 500; color: var(--ink); }
.toggle {
    width: 40px; height: 20px;
    border: 1px solid var(--ink);
    background: var(--sheet);
    border-radius: 0;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle::after {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    background: var(--ink);
    top: 2px; left: 2px;
    transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(20px); background: #fff; }

/* ---------- Railing sub-section ---------- */
.rail-type-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.rail-type-row .tile { padding: 8px 6px; font-size: 0.75rem; }
.cable-options { padding-left: 10px; border-left: 1px solid var(--accent); margin-left: 2px; }

/* ---------- Canvas area: drawing sheet on a drafting grid ---------- */
.canvas-area {
    background-color: var(--paper);
    background-image:
        linear-gradient(var(--rule) 1px, transparent 1px),
        linear-gradient(90deg, var(--rule) 1px, transparent 1px),
        linear-gradient(var(--rule-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    position: relative;
    overflow: hidden;
    min-width: 0;
}
/* Crop marks at the sheet corners. */
.canvas-area::before {
    content: '';
    position: absolute;
    inset: 10px;
    pointer-events: none;
    background:
        linear-gradient(var(--ink), var(--ink)) top left / 18px 1px no-repeat,
        linear-gradient(var(--ink), var(--ink)) top left / 1px 18px no-repeat,
        linear-gradient(var(--ink), var(--ink)) top right / 18px 1px no-repeat,
        linear-gradient(var(--ink), var(--ink)) top right / 1px 18px no-repeat,
        linear-gradient(var(--ink), var(--ink)) bottom left / 18px 1px no-repeat,
        linear-gradient(var(--ink), var(--ink)) bottom left / 1px 18px no-repeat,
        linear-gradient(var(--ink), var(--ink)) bottom right / 18px 1px no-repeat,
        linear-gradient(var(--ink), var(--ink)) bottom right / 1px 18px no-repeat;
}
#deckCanvas, #threeCanvas { position: relative; z-index: 5; background: transparent; }
/* Fingers on the drawing move things on it, never scroll, select or zoom the page. */
#deckCanvas, #threeCanvas { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.canvas-area { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#threeCanvas { display: none; border: 1px solid var(--ink); }
.canvas-area.is-3d { background-image: none; }
.view-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    z-index: 10;
    border: 1px solid var(--ink);
    background: var(--sheet);
}
.view-btn, .secondary-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--ink);
    cursor: pointer;
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 0.78rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink);
}
.view-btn:first-child { border-left: none; }
.view-btn:hover, .secondary-btn:hover { background: var(--paper); }
.view-btn.active { background: var(--ink); color: var(--sheet); }
.canvas-actions { position: absolute; top: 20px; right: 20px; display: flex; gap: 6px; align-items: center; z-index: 10; }
.deck-label {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--ink);
    padding: 5px 12px;
    font-family: var(--font-data);
    font-size: 0.78rem;
    z-index: 10;
}
.animate-bar {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: none;
    gap: 10px;
    align-items: center;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--ink);
    padding: 6px 10px;
    font-family: var(--font-label);
    z-index: 10;
}
.animate-bar.on { display: flex; }
.animate-bar button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 5px 14px;
    border-radius: 0;
    cursor: pointer;
    font-family: var(--font-label);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.75rem;
}
/* Fixed widths so the buttons never shift as the label and button text change. */
.animate-bar #animateBtn { width: 92px; }
.animate-bar button.anim-stop { width: 72px; background: var(--sheet); color: var(--ink); border: 1px solid var(--ink); }
.animate-bar button.anim-stop:disabled { opacity: 0.35; cursor: default; }

/* ---------- Zoom controls ---------- */
.zoom-controls {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ink);
    background: var(--sheet);
    z-index: 10;
}
.zoom-controls button {
    width: 38px;
    height: 34px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-data);
    font-size: 1.05rem;
    color: var(--ink);
}
.zoom-controls button + button { border-top: 1px solid var(--ink); }
.zoom-controls button:hover { background: var(--paper); }
/* The hand (move) button only applies to the 3D view. */
.zoom-controls #moveMode { display: none; align-items: center; justify-content: center; }
.canvas-area.is-3d .zoom-controls #moveMode { display: flex; }
/* 3D measurements: the On/Off button at the top of the 3D view, and the orange figures. */
.measure-btn {
    position: absolute; top: 20px; right: 20px; z-index: 11; display: none;
    background: var(--sheet); color: var(--ink); border: 1px solid var(--ink); border-radius: 999px;
    padding: 7px 16px 6px; cursor: pointer; font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.06em;
    box-shadow: 0 6px 18px rgba(13, 15, 17, 0.12);
}
.measure-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.measure-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.canvas-area.is-3d .measure-btn { display: block; }
.canvas-area.anim-on .measure-btn { top: calc(var(--strip-h, 30px) + 14px); }
.m3d-layer { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.m3d-label {
    position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform;
    font-family: var(--font-body); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.01em; color: #ff7a1a;
    font-variant-numeric: tabular-nums;
    /* No box: a thin dark outline keeps the orange readable over boards, grass and sky. */
    text-shadow: -1px -1px 0 #1b1b1b, 1px -1px 0 #1b1b1b, -1px 1px 0 #1b1b1b, 1px 1px 0 #1b1b1b, 0 0 3px rgba(0, 0, 0, 0.6);
}
.m3d-label.m3d-note { font-size: 0.74rem; }
/* Measurements toggle: the plan only. */
.zoom-controls #dimToggle { font-family: var(--font-label); font-size: 0.68rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.zoom-controls #dimToggle[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.canvas-area.is-3d .zoom-controls #dimToggle { display: none; }
.zoom-controls #moveMode[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
#threeCanvas.move-mode { cursor: grab; }
#threeCanvas.move-mode.grabbing { cursor: grabbing; }
.zoom-controls #zoomFit {
    font-family: var(--font-label);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---------- Animation step strip (one line along the top of the view) ----------
   Step number, step name and a progress line. The explanation opens below the line on
   hover, on a tap, or while paused. The view buttons step down out of its way. */
.anim-strip {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 12;
    display: none;
    background: color-mix(in srgb, var(--sheet) 92%, transparent);
    color: var(--ink);
    border-bottom: 1px solid var(--line, rgba(13, 15, 17, 0.15));
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.anim-strip.on { display: block; }
.anim-strip-row {
    display: flex; align-items: center; gap: 10px;
    width: 100%; height: 30px; padding: 0 14px;
    background: none; border: none; color: inherit; cursor: pointer; text-align: left;
    font-family: var(--font-body); font-size: 0.82rem;
}
.anim-strip-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.anim-step {
    flex: none; font-family: var(--font-label); font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-ink, var(--accent));
    font-variant-numeric: tabular-nums;
}
.anim-step:empty { display: none; }
.anim-title { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anim-more {
    flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1px solid currentColor;
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-body); font-size: 0.7rem; font-weight: 700; font-style: italic; opacity: 0.55;
}
.anim-strip.no-desc .anim-more { display: none; }
.anim-strip-desc {
    display: none; padding: 0 14px 8px; font-size: 0.8rem; line-height: 1.4; color: var(--ink-soft);
}
.anim-strip.open .anim-strip-desc:not(:empty) { display: block; }
@media (hover: hover) { .anim-strip:hover .anim-strip-desc:not(:empty) { display: block; } }
.anim-strip.paused .anim-step::after { content: ' \00b7  Paused'; }
.anim-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; }
.anim-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
@media (prefers-reduced-motion: reduce) { .anim-progress span { transition: none; } }
.canvas-area.anim-on .view-controls { top: calc(var(--strip-h, 30px) + 14px); }
.canvas-area.anim-on .edit-hint { top: calc(var(--strip-h, 30px) + 58px); }

/* ---------- Edit-mode overlay ---------- */
.edit-hint {
    position: absolute;
    top: 64px;
    left: 20px;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--accent);
    border-left-width: 4px;
    padding: 8px 12px;
    font-size: 0.8rem;
    z-index: 10;
    display: none;
    max-width: 280px;
    line-height: 1.4;
}
.edit-hint.on { display: block; }
.feature-popover {
    position: absolute;
    background: var(--sheet);
    border: 1px solid var(--ink);
    border-radius: 0;
    padding: 10px;
    box-shadow: 4px 4px 0 rgba(27, 40, 48, 0.15);
    z-index: 25;
    min-width: 200px;
    display: none;
}
.feature-popover.on { display: block; }
.feature-popover label {
    display: block;
    font-family: var(--font-label);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 4px;
}
.feature-popover input, .feature-popover select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    font-family: var(--font-data);
    font-size: 0.82rem;
    margin-bottom: 8px;
}
.feature-popover .ftin { margin: 0 0 8px; }
/* Stair popup: where it lands, its steps, and the landing buttons. */
.feature-popover { max-width: 320px; max-height: calc(100% - 24px); overflow-y: auto; }
.feature-popover .pop-note { font-size: 0.76rem; line-height: 1.4; color: var(--ink-soft); margin: -2px 0 10px; }
.feature-popover .pop-note .warn { display: block; margin-top: 4px; color: var(--bad); }
.feature-popover .pop-note .ok { display: block; margin-top: 4px; color: var(--ink); }
.feature-popover .pop-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 6px; }
.feature-popover .pop-actions .link-btn { text-align: left; }
.feature-popover .pop-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.feature-popover .ftin input, .feature-popover .ftin select { margin-bottom: 0; }
/* Custom shape: one feet-and-inches field per side. */
.side-list { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.side-row { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; align-items: center; }
.side-row .ftin { margin-top: 0; }
.side-name { font-family: var(--font-label); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.feature-popover .row { display: flex; gap: 6px; }
.feature-popover .row button {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-family: var(--font-label);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.75rem;
}
.feature-popover .btn-save   { background: var(--accent); color: #fff; }
.feature-popover .btn-delete { background: var(--bad); color: #fff; }

/* ---------- BOM: drawn as a schedule table ---------- */
.bom-header {
    background: var(--sheet);
    color: var(--ink);
    padding: 16px 18px 12px;
    font-family: var(--font-label);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1.5px solid var(--ink);
}
.bom-section { padding: 12px 18px; border-bottom: 1px solid var(--rule); }
.bom-note { padding: 10px 18px 0; font-size: 0.74rem; line-height: 1.45; color: var(--ink-soft); }
.bom-note.warn { color: var(--accent-ink); }
.rail-note.house-warn { color: var(--accent-ink); }
.bom-section h4 {
    font-family: var(--font-label);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-faint);
    margin-bottom: 6px;
}
.bom-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px dotted var(--rule);
}
.bom-item:last-child { border-bottom: none; }
.bom-item .name { font-size: 0.84rem; min-width: 0; }
.bom-item .qty {
    font-family: var(--font-data);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.bom-item .price { font-family: var(--font-data); font-size: 0.7rem; color: var(--ink-faint); margin-left: 8px; }
.bom-total { padding: 14px 18px; background: var(--sheet); color: var(--ink); border-top: 1.5px solid var(--ink); }
.bom-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.84rem;
}
.bom-total-row span:last-child { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.bom-total-row.grand {
    font-family: var(--font-label);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    border-top: 1px solid var(--ink);
    border-bottom: 3px double var(--ink);
    padding: 8px 0;
    margin-top: 8px;
    align-items: baseline;
}
.bom-total-row.grand span:last-child { font-size: 1.25rem; color: var(--accent-ink); letter-spacing: 0; }
.bom-actions { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 6px; background: var(--sheet); }
.btn {
    padding: 11px;
    border: 1px solid var(--ink);
    border-radius: 2px;
    font-family: var(--font-label);
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-secondary { background: var(--sheet); color: var(--ink); }
.btn-secondary:hover { background: var(--paper); }

/* ---------- Admin modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(27, 40, 48, 0.5);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.on { display: flex; }
.modal {
    background: var(--sheet);
    border: 1.5px solid var(--ink);
    border-radius: 0;
    width: 100%;
    max-width: 920px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 8px 8px 0 rgba(27, 40, 48, 0.18);
}
.modal-header {
    padding: 14px 20px;
    background: var(--sheet);
    color: var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1.5px solid var(--ink);
}
.modal-header h2 { font-family: var(--font-label); font-size: 1rem; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; }
.modal-close { background: transparent; border: none; color: var(--ink); font-size: 1.4rem; cursor: pointer; padding: 0 6px; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--ink); margin-bottom: 16px; flex-wrap: wrap; }
.modal-tab {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-family: var(--font-label);
    font-weight: 500;
    font-size: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.modal-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.admin-field { display: flex; flex-direction: column; gap: 3px; }
.admin-field label {
    font-family: var(--font-label);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.admin-field input, .admin-field select {
    padding: 7px 9px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    font-family: var(--font-data);
    font-size: 0.82rem;
    background: var(--sheet);
}
.admin-field.full { grid-column: 1 / -1; }
.admin-section-title {
    grid-column: 1 / -1;
    font-family: var(--font-label);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: 1.5px;
    margin-top: 10px;
    border-bottom: 1px solid var(--ink);
    padding-bottom: 4px;
}
.modal-footer {
    padding: 12px 22px;
    background: var(--paper);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--ink);
}
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 18px;
    border-radius: 0;
    color: #fff;
    font-family: var(--font-label);
    font-weight: 500;
    letter-spacing: 0.6px;
    font-size: 0.88rem;
    z-index: 200;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--ok); }
.toast.error   { background: var(--bad); }
.toast.info    { background: var(--ink); }

.history-list { list-style: none; border: 1px solid var(--ink); }
.history-list li {
    padding: 9px 14px;
    border-bottom: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.84rem;
}
.history-list li:last-child { border-bottom: none; }
.history-list .meta { color: var(--ink-soft); font-family: var(--font-data); font-size: 0.72rem; }
.history-list .active-tag {
    background: var(--ok);
    color: #fff;
    padding: 2px 8px;
    font-family: var(--font-label);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.66rem;
    margin-left: 6px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .panel-section { padding: 16px 14px; }
    .bom-section, .bom-header, .bom-total { padding-left: 14px; padding-right: 14px; }
    .bom-actions { padding: 0 14px 14px; }
    .canvas-area { padding: 20px 12px; }
    .shape-tile { font-size: 0.64rem; letter-spacing: 0.2px; white-space: nowrap; }
}
.draw-toggle { display: none; }
/* Phones: the drawing comes first and stays pinned to the top of the screen while the
   steps scroll under it. "Hide drawing" folds it to a slim bar for more room. */
@media (max-width: 760px) {
    .app-layout { grid-template-columns: minmax(0, 1fr); }
    .panel-left, .panel-right { max-height: none; overflow: visible; }
    .deck-tabs { position: static; }
    .canvas-area {
        order: -1; position: sticky; top: 0; z-index: 20;
        height: clamp(250px, 46vh, 480px); min-height: 0; padding: 6px;
        border-bottom: 2px solid var(--ink); box-shadow: 0 4px 10px rgba(27, 40, 48, 0.18);
    }
    .canvas-area::before { inset: 4px; }
    .view-controls { top: 8px; left: 8px; }
    .edit-hint { top: 48px; left: 8px; right: 8px; }
    .deck-label { display: none; }   /* the plan's dimension strings say the same */
    .zoom-controls { right: 8px; }
    .animate-bar { bottom: 8px; right: 8px; }
    .anim-strip-row { padding: 0 10px; font-size: 0.78rem; }
    .canvas-area.anim-on .view-controls,
    .canvas-area.anim-on .draw-toggle { top: calc(var(--strip-h, 30px) + 8px); }
    .measure-btn { top: 50px; right: 8px; padding: 5px 12px 4px; font-size: 0.9rem; }
    .canvas-area.anim-on .measure-btn { top: calc(var(--strip-h, 30px) + 50px); }
    .m3d-label { font-size: 0.7rem; }
    .draw-toggle {
        display: block; position: absolute; top: 8px; right: 8px; z-index: 30;
        padding: 6px 10px; border: 1px solid var(--ink); background: var(--sheet); color: var(--ink);
        font-family: var(--font-label); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
    }
    /* Stair, door and side settings open as a sheet along the bottom of the screen, so
       they don't cover the drawing. */
    .feature-popover {
        position: fixed; left: 0 !important; right: 0; top: auto !important; bottom: 0; z-index: 60;
        min-width: 0; max-width: none; max-height: 52vh; overflow-y: auto;
        border-width: 2px 0 0; box-shadow: 0 -6px 16px rgba(27, 40, 48, 0.22);
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }
    body.draw-hidden .canvas-area { height: 46px; }
    body.draw-hidden .canvas-area > :not(.draw-toggle) { display: none !important; }
    body.draw-hidden .canvas-area::before { display: none; }
}
@media (max-width: 600px) {
    .logo { padding: 10px 16px; }
    .header-right { width: 100%; border-top: 1px solid var(--rule); }
    .header-right > *:first-child { border-left: none; }
    .total-display { margin-left: auto; }
    .admin-grid { grid-template-columns: 1fr; }
}

/* ---------- Print ---------- */
.section-lede { font-size: 0.78rem; line-height: 1.45; color: var(--ink-soft); margin: -6px 0 12px; }
.section-lede.install-lede { margin: 8px 0 10px; }

.block-tools .seg { padding: 6px 4px; font-size: 0.7rem; }
.block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.block-actions[hidden] { display: none; }
.block-actions .btn { flex: 1 1 auto; }
.btn.tool-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: default; }
.block-chip { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Deck tabs (left) and Project / deck tabs (materials list) ---------- */
.deck-tabs { position: sticky; top: 0; z-index: 3; background: var(--ink); padding: 10px 12px 8px; }
.deck-tab-row { display: flex; flex-wrap: wrap; gap: 4px; }
.deck-tab {
    background: transparent; color: #c9d3d9; border: 1px solid #52626c; padding: 6px 10px; cursor: pointer;
    font-family: var(--font-label); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.04em;
}
.deck-tab:hover { color: #fff; border-color: #c9d3d9; }
.deck-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.deck-tab.deck-add { border-style: dashed; color: #ffb27f; }
.deck-note { margin: 8px 0 0; padding: 6px 8px; background: var(--accent); color: #fff; font-size: 0.74rem; line-height: 1.35; }
.deck-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.deck-actions .btn { padding: 5px 8px; font-size: 0.68rem; background: transparent; color: #e6ecef; border-color: #52626c; flex: 1 1 auto; }
.deck-actions .btn:hover:not(:disabled) { border-color: #fff; color: #fff; }
.deck-actions .btn.tool-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.snap-row { align-items: center; padding-top: 6px; border-top: 1px dashed #52626c; }
.snap-label { flex: 1 1 100%; font-family: var(--font-label); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: #c9d3d9; }
/* Feet-and-inches field: whole feet, then inches in 1/4" steps. */
.ftin { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.2fr); gap: 6px; align-items: center; margin-top: 6px; }
.ftin span { font-family: var(--font-label); font-size: 0.72rem; color: var(--ink-soft); }
.ftin input, .ftin select { width: 100%; min-width: 0; height: 38px; padding: 6px 8px; border: 1px solid var(--rule); border-radius: 0; background: #fff; color: var(--ink); font-family: var(--font-data); font-size: 0.88rem; }
.ftin input:focus, .ftin select:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.deck-actions input { flex: 1 1 140px; padding: 5px 8px; font-size: 0.8rem; border: 1px solid #52626c; background: #fff; color: var(--ink); }
.bom-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 18px 0; background: #fff; }
.bom-tabs[hidden] { display: none; }
.bom-tab {
    background: #fff; color: var(--ink-soft); border: 1px solid var(--rule); padding: 5px 10px; cursor: pointer;
    font-family: var(--font-label); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
}
.bom-tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.deck-tab.house-tab { color: #e6ecef; }
.deck-tab.house-tab.on { color: #fff; }
.deck-actions[hidden], .panel-section[hidden] { display: none; }
.house-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.house-actions .btn { flex: 1 1 auto; padding: 7px 10px; font-size: 0.74rem; }
.house-sections { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.house-sec { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--rule); background: #fff; }
.house-sec.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-wash); }
.house-sec-name { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font-family: var(--font-label); font-size: 0.78rem; font-weight: 600; color: var(--ink); }
.house-sec label { white-space: nowrap; display: flex; align-items: center; gap: 4px; font-family: var(--font-label); font-size: 0.68rem; letter-spacing: 0.06em; color: var(--ink-soft); }
.house-sec input { width: 100%; min-width: 0; padding: 5px 6px; border: 1px solid var(--rule); background: #fff; font-family: var(--font-data); font-size: 0.82rem; }
#panelHouse .house-color-label { margin-top: 14px; }

/* ---------- Section banding ----------
   Left: sections alternate a light DeckWise-orange wash and white, each with an edge
   stripe, so the steps read as separate blocks. Right: list sections alternate light
   gray and white under a dark header bar. */
:root {
    --band-orange: #fff2e8;
    --band-orange-rule: #fbd9c2;
    --band-gray: #eff3f5;
}
.panel-left, .panel-right { background: #fff; }
.panel-left .panel-section { position: relative; border-bottom: 1px solid var(--band-orange-rule); }
.panel-left .panel-section:nth-child(odd)  { background: var(--band-orange); }
.panel-left .panel-section:nth-child(even) { background: #fff; }
.panel-left .panel-section::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--rule);
}
.panel-left .panel-section:nth-child(odd)::before { background: var(--accent); }
.panel-left .panel-section:empty { display: none; }
/* Section numbers as solid badges; the heading rule starts in orange. */
.panel-section h3 { font-size: 0.84rem; }
.panel-section h3 .icon { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.panel-section h3::after { background: linear-gradient(90deg, var(--accent) 0 36px, var(--rule) 36px); }

.bom-header { background: var(--ink); color: #fff; border-bottom: 3px solid var(--accent); }
#bomSections > .bom-section:nth-of-type(odd)  { background: var(--band-gray); }
#bomSections > .bom-section:nth-of-type(even) { background: #fff; }
.bom-section { border-bottom-color: var(--rule-soft); }
.bom-section h4 { color: var(--ink); display: flex; align-items: center; gap: 7px; }
.bom-section h4::before { content: ''; width: 7px; height: 7px; background: var(--accent); flex: none; }
.bom-item { padding-left: 4px; padding-right: 4px; margin: 0 -4px; transition: background 0.12s; }
.bom-item:hover { background: var(--accent-wash); }
.bom-item.bom-sum { border-top: 1px solid var(--ink-soft); font-weight: 600; }
.bom-total { background: var(--band-gray); }
.bom-actions { background: var(--band-gray); padding-top: 4px; }

@media print {
    header, .panel-left, .canvas-area, .bom-actions, .modal-backdrop, .toast, .buy-bar { display: none !important; }
    .app-layout { display: block; }
    .panel-right { border: none; max-height: none; }
    body { background: white; }
}


/* ==========================================================================
   Makeover: dark header and steps panel, light drawing and materials list.
   Bebas Neue headings and buttons, Barlow copy, pill buttons, motion
   (js/motion.js adds .motion to <html> unless reduced motion is asked for).
   ========================================================================== */
:root {
    --night: #0d0f11;
    --night-2: #14171a;
    --night-3: #1c2024;
    --night-line: #2b3136;
    --paper: #eeece6;          /* warm drafting sheet behind the drawing */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}
body { font-size: 13px; letter-spacing: -0.01em; background: var(--night); }

/* Dark scopes: the same tokens, inverted. */
header, .buy-bar, .panel-left {
    --sheet: var(--night-2);
    --ink: #f3f0e8;
    --ink-soft: #b3babf;
    --ink-faint: #7d868c;
    --rule: var(--night-line);
    --rule-soft: #22272b;
    --accent-ink: #ff8f45;
    --accent-wash: rgba(255, 102, 0, 0.14);
    --band-orange: #18140f;
    --band-orange-rule: #3b2a1c;
    color: var(--ink);
}

/* ---- Header ---- */
header { background: var(--night); border-bottom: 1px solid var(--night-line); }
.logo { font-family: var(--font-display); font-size: 2.1rem; letter-spacing: 0.02em; font-weight: 400; line-height: 1; }
.logo small { font-family: var(--font-body); font-size: 0.6rem; letter-spacing: 0.32em; color: var(--ink-faint); }
.version-chip { font-family: var(--font-body); color: var(--ink-faint); }
.icon-btn { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: 0.08em; color: var(--ink); background: transparent; }
.icon-btn:hover { background: var(--night-3); color: #fff; }
.total-display { font-family: var(--font-display); font-size: 2.3rem; letter-spacing: 0.02em; color: var(--accent); font-weight: 400; }
.total-display::before { font-family: var(--font-body); letter-spacing: 0.24em; color: var(--ink-faint); }

/* ---- Buy bar ---- */
.buy-bar { background: var(--night-2); border-bottom: 1px solid var(--night-line); }
.buy-bar-label { font-family: var(--font-display); font-size: 1.1rem; letter-spacing: 0.14em; color: var(--ink-faint); }
.buy-btn {
    border-radius: 999px; border: 1px solid var(--night-line); background: transparent; color: var(--ink);
    font-family: var(--font-display); font-size: 1.05rem; letter-spacing: 0.08em; padding: 7px 18px 6px;
    transition: background 0.25s var(--ease-out), border-color 0.25s, color 0.25s, box-shadow 0.25s, translate 0.35s var(--ease-out);
}
.buy-btn:hover { background: #fff; color: var(--night); border-color: #fff; }
.buy-btn-deckwise { background: var(--accent); border-color: var(--accent); color: #fff; }
.buy-btn-deckwise:hover { background: #ff7a1f; border-color: #ff7a1f; color: #fff; box-shadow: 0 8px 26px rgba(255, 102, 0, 0.35); }

/* ---- Buttons: sleek pills ---- */
.btn, .view-btn, .bom-tab, .deck-tab, .seg, .feature-add-btn, .animate-bar button, .feature-popover .row button {
    font-family: var(--font-display); font-weight: 400; letter-spacing: 0.08em;
    transition: background 0.25s var(--ease-out), border-color 0.25s, color 0.25s, box-shadow 0.25s, translate 0.35s var(--ease-out);
}
.btn { border-radius: 999px; font-size: 1.05rem; padding: 9px 18px 8px; text-transform: uppercase; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #ff7a1f; border-color: #ff7a1f; box-shadow: 0 10px 28px rgba(255, 102, 0, 0.35); }
.btn-secondary { background: transparent; border: 1px solid var(--rule); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink); background: var(--ink); color: var(--sheet); }
.btn.tool-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.link-btn { font-family: var(--font-body); }

/* ---- Deck tabs ---- */
.deck-tabs { background: var(--night); border-bottom: 1px solid var(--night-line); }
.deck-tab { border-radius: 999px; font-size: 1rem; padding: 6px 14px 5px; border-color: var(--night-line); color: #c9cfd3; }
.deck-tab:hover { border-color: #fff; color: #fff; }
.deck-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.deck-tab.deck-add { border-style: dashed; color: #ffb27f; border-color: #5a4232; }
.deck-actions .btn { border-radius: 999px; font-size: 0.92rem; padding: 6px 10px 5px; border-color: var(--night-line); color: #e6ecef; }
.deck-actions .btn:hover:not(:disabled) { background: #fff; color: var(--night); border-color: #fff; }
.deck-note { border-radius: 10px; font-family: var(--font-body); }
.deck-actions input { background: var(--night-3); color: var(--ink); border-color: var(--night-line); border-radius: 999px; }

/* ---- Steps panel (dark) ---- */
.panel-left { background: var(--night-2); border-right: 1px solid var(--night-line); }
.panel-left .panel-section { border-bottom: 1px solid var(--night-line); }
.panel-left .panel-section:nth-child(odd) { background: var(--night-2); }
.panel-left .panel-section:nth-child(even) { background: #111417; }
.panel-left .panel-section::before { display: none !important; }
.panel-section h3 { font-family: var(--font-display); font-size: 1.55rem; font-weight: 400; letter-spacing: 0.04em; line-height: 1; }
.panel-section h3::after { background: var(--night-line); }
.panel-section h3 .icon {
    background: transparent !important; border: 1px solid var(--accent) !important; color: var(--accent) !important;
    font-family: var(--font-body); font-size: 0.68rem; font-weight: 700;
}
.panel-section h3[role="button"]:hover .icon { background: var(--accent) !important; color: #fff !important; }
.panel-section h3[role="button"]:hover { color: #fff; }
.panel-section h3 .chev { border-color: var(--ink-soft); }
.panel-left label, .panel-left .input-group label, .panel-left .slider-group label { font-family: var(--font-body); font-size: 0.66rem; letter-spacing: 0.12em; color: var(--ink-soft); }
.panel-left select, .panel-left input[type="number"], .panel-left input[type="text"], .panel-left textarea,
.panel-left .ftin input, .panel-left .ftin select, .panel-left .house-sec input {
    background-color: var(--night-3) !important; color: var(--ink) !important; border: 1px solid var(--night-line) !important;
    border-radius: 10px !important; font-family: var(--font-body);
}
.panel-left select:focus, .panel-left input:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px rgba(255, 102, 0, 0.18); outline: none; }
.panel-left .tile, .panel-left .shape-tile, .panel-left .fastener-row, .panel-left .house-color, .panel-left .swatch, .panel-left .house-sec {
    background: var(--night-3); border-color: var(--night-line); color: var(--ink); border-radius: 12px;
    transition: border-color 0.2s, background 0.2s, translate 0.35s var(--ease-out);
}
.panel-left .tile:hover, .panel-left .shape-tile:hover, .panel-left .fastener-row:hover, .panel-left .house-color:hover { border-color: var(--ink-soft); }
.panel-left .tile.selected, .panel-left .shape-tile.selected, .panel-left .fastener-row.selected, .panel-left .house-color.selected,
.panel-left .swatch.selected, .panel-left .house-sec.on {
    border-color: var(--accent); background: rgba(255, 102, 0, 0.12); box-shadow: inset 0 0 0 1px var(--accent);
}
.panel-left .mat-tabs { border: 1px solid var(--night-line); border-radius: 12px; overflow: hidden; }
.panel-left .mat-tab { font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.06em; border-color: var(--night-line); }
.panel-left .mat-tab:not(.on) { background-color: var(--night-3) !important; color: var(--ink-soft); }
.panel-left .mat-tab.on { background: #fff; color: var(--night); }
.panel-left .seg-toggle, .panel-left .block-tools .seg-toggle { border: 1px solid var(--night-line); border-radius: 999px; overflow: hidden; }
.panel-left .seg { background: var(--night-3); color: var(--ink-soft); font-size: 0.95rem; }
.panel-left .seg + .seg { border-left-color: var(--night-line); }
.panel-left .seg:hover { background: #262b30; color: var(--ink); }
.panel-left .seg.selected { background: #fff; color: var(--night); }
.panel-left .feature-add-btn { border-radius: 999px; background: transparent; border-color: var(--night-line); color: var(--ink); font-size: 1rem; }
.panel-left .feature-add-btn:hover { background: #fff; color: var(--night); border-color: #fff; }
.panel-left .feature-add-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.panel-left .toggle { background: var(--night-line); border-color: var(--night-line); border-radius: 999px; }
.panel-left .toggle::after { border-radius: 50%; background: #c9cfd3; }
.panel-left .toggle.on { background: var(--accent); border-color: var(--accent); }
.panel-left .toggle.on::after { background: #fff; }
.panel-left input[type="range"] { accent-color: var(--accent); }
.panel-left .custom-box, .panel-left .cutout-box, .panel-left .house-box, .panel-left .cable-options, .panel-left .block-tools {
    border-color: var(--night-line); background: transparent;
}
.panel-left .rail-note, .panel-left .custom-note, .panel-left .custom-tips-plain, .panel-left .section-lede { color: var(--ink-soft); }
.panel-left .rail-note.house-warn, .panel-left .stair-warn { color: var(--accent-ink); }
.panel-left .rod-chip { border-radius: 999px; }
.side-name { color: var(--ink-soft); }

/* ---- Drawing area (light) ---- */
.canvas-area { background-color: var(--paper); }
.view-controls { border-radius: 999px; overflow: hidden; border: 1px solid var(--ink); box-shadow: 0 6px 18px rgba(13, 15, 17, 0.12); }
.view-btn { font-size: 1.05rem; padding: 7px 18px 6px; }
.view-btn.active { background: var(--night); color: #fff; }
.zoom-controls { border-radius: 14px; overflow: hidden; box-shadow: 0 6px 18px rgba(13, 15, 17, 0.12); }
.zoom-controls button { font-family: var(--font-display); font-size: 1.1rem; }
.deck-label { font-family: var(--font-body); border-radius: 999px; }
.draw-toggle { border-radius: 999px; font-family: var(--font-display) !important; font-size: 1rem !important; letter-spacing: 0.08em; }
.animate-bar { border-radius: 999px; box-shadow: 0 8px 24px rgba(13, 15, 17, 0.14); }
.animate-bar button { border-radius: 999px; font-size: 1.05rem; }
.edit-hint { border-radius: 12px; font-family: var(--font-body); }
.feature-popover { border-radius: 16px; box-shadow: 0 16px 40px rgba(13, 15, 17, 0.22); }
.feature-popover .row button { border-radius: 999px; font-size: 1.05rem; padding: 8px; }

/* ---- Materials list (light) ---- */
.panel-right { background: #fbfaf7; }
.bom-header { background: var(--night); font-family: var(--font-display); font-size: 1.9rem; letter-spacing: 0.04em; font-weight: 400; border-bottom: 3px solid var(--accent); }
.bom-section h4 { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: 0.06em; font-weight: 400; color: var(--ink); }
.bom-section h4::before { border-radius: 50%; }
#bomSections > .bom-section:nth-of-type(odd) { background: #f3f1ec; }
#bomSections > .bom-section:nth-of-type(even) { background: #fbfaf7; }
.bom-tabs { background: #fbfaf7; }
.bom-tab { border-radius: 999px; font-size: 1rem; padding: 5px 14px 4px; }
.bom-tab.on { background: var(--night); border-color: var(--night); color: #fff; }
.bom-total { background: #fbfaf7; }
.bom-total-row.grand span:last-child, .bom-total-row.grand { font-family: var(--font-display); font-size: 1.6rem; letter-spacing: 0.03em; }
.bom-actions .btn { width: 100%; }

/* ---- Admin and dialogs ---- */
.modal, .admin-modal, .modal-box { border-radius: 18px; }
.modal h2, .modal-head h2, .admin-modal h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.04em; font-size: 2rem; }
.modal-tab { font-family: var(--font-display); letter-spacing: 0.06em; font-size: 1.05rem; }
.modal input, .modal select, .modal textarea { border-radius: 10px; }

/* ---- Motion (only when js/motion.js turns it on) ---- */
@keyframes dw-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes dw-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dw-letters { from { opacity: 0; letter-spacing: 0.3em; filter: blur(4px); } to { opacity: 1; filter: none; } }
.motion .intro .logo { animation: dw-letters 0.9s var(--ease-out) both; }
.motion .intro .total-display, .motion .intro .icon-btn, .motion .intro .version-chip { animation: dw-rise 0.7s var(--ease-out) both; animation-delay: 0.15s; }
.motion .intro .buy-bar > * { animation: dw-rise 0.7s var(--ease-out) both; animation-delay: 0.25s; }
.motion .intro .panel-left > .panel-section h3 { animation: dw-rise 0.6s var(--ease-out) both; }
.motion .intro .panel-left > .panel-section:nth-child(2) h3 { animation-delay: 0.30s; }
.motion .intro .panel-left > .panel-section:nth-child(3) h3 { animation-delay: 0.36s; }
.motion .intro .panel-left > .panel-section:nth-child(4) h3 { animation-delay: 0.42s; }
.motion .intro .panel-left > .panel-section:nth-child(5) h3 { animation-delay: 0.48s; }
.motion .intro .panel-left > .panel-section:nth-child(6) h3 { animation-delay: 0.54s; }
.motion .intro .panel-left > .panel-section:nth-child(7) h3 { animation-delay: 0.60s; }
.motion .intro .panel-left > .panel-section:nth-child(8) h3 { animation-delay: 0.66s; }
.motion .intro .canvas-area { animation: dw-fade 0.9s ease both; animation-delay: 0.2s; }
.motion .intro .bom-header { animation: dw-letters 0.9s var(--ease-out) both; animation-delay: 0.35s; }
.motion .panel-section.opening > :not(h3) { animation: dw-rise 0.45s var(--ease-out) both; }
.motion .panel-section.opening > :nth-child(3) { animation-delay: 0.04s; }
.motion .panel-section.opening > :nth-child(4) { animation-delay: 0.08s; }
.motion .panel-section.opening > :nth-child(n+5) { animation-delay: 0.12s; }
/* Materials list sections rise in as they scroll into view (first time only). */
.motion .bom-section.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out); }
.motion .bom-section.reveal.in { opacity: 1; transform: none; }
.motion .bom-section.reveal.seen { opacity: 1; transform: none; transition: none; }
/* Magnetic buttons drift toward the pointer (js/motion.js sets translate). */
.motion .magnetic { transition: translate 0.35s var(--ease-out), background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s; will-change: translate; }
.motion .total-display.bump { animation: dw-bump 0.5s var(--ease-out); }
@keyframes dw-bump { 0% { transform: none; } 30% { transform: translateY(-3px); color: #ff8f45; } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .motion * { animation: none !important; transition: none !important; }
}

/* Printing the materials list: white paper, every section shown (scroll reveals off). */
@media print {
    body { background: #fff !important; }
    .panel-right { background: #fff !important; }
    .bom-section.reveal, .motion .bom-section.reveal { opacity: 1 !important; transform: none !important; }
}

/* Light fields (the stair and door sheet over the drawing): rounded, white. */
.feature-popover input, .feature-popover select, .feature-popover .ftin input, .feature-popover .ftin select {
    background: #fff; color: var(--ink); border: 1px solid var(--rule); border-radius: 10px;
}

/* Phones: a tidy header (logo, then Admin and the total on one row) and an Admin
   footer whose buttons fit on one line each. */
@media (max-width: 600px) {
    .header-right { display: grid; grid-template-columns: auto 1fr; align-items: center; width: 100%; }
    .header-right .version-chip { display: none; }
    .header-right > * { border-left: none; }
    .header-right .icon-btn { padding: 10px 16px; }
    .header-right .total-display { justify-content: flex-end; padding: 22px 16px 8px 0; font-size: 2rem; }
    .header-right .total-display::before { left: auto; right: 16px; top: 8px; white-space: nowrap; }
    .modal-footer .btn { font-size: 0.95rem; padding: 8px 12px 7px; white-space: nowrap; }
}

/* ---- Save dialog ---- */
.modal.modal-save { max-width: 560px; }
.modal-save .modal-body { padding: 20px 24px 24px; }
.save-status { font-family: var(--font-data); font-size: 0.95rem; margin: 0 0 14px; color: var(--ink); }
.save-status.error { color: var(--bad); }
.save-link { display: flex; gap: 8px; align-items: stretch; }
.save-link input { flex: 1; min-width: 0; font-family: var(--font-data); font-size: 0.85rem; padding: 10px 12px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); border-radius: 10px; }
.save-link .btn { white-space: nowrap; }
.save-note { font-family: var(--font-data); font-size: 0.78rem; line-height: 1.5; color: var(--ink-soft); margin: 14px 0 0; }
@media (max-width: 600px) {
    .save-link { flex-direction: column; }
}

/* ---- Materials list: sections fold to their headings ---- */
.bom-fold-bar { display: flex; justify-content: flex-end; padding: 8px 18px 0; }
.bom-fold-all { background: none; border: none; cursor: pointer; font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.bom-fold-all:hover { color: var(--ink); }
.bom-section > h4[role="button"] { cursor: pointer; user-select: none; }
.bom-section > h4[role="button"]::after {
    content: ''; margin-left: 8px; width: 8px; height: 8px; flex: none;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px); transition: transform 0.2s ease;
}
.bom-section.folded > h4[role="button"]::after { transform: rotate(-45deg); }
.bom-section > h4[role="button"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.bom-count { margin-left: auto; white-space: nowrap; font-family: var(--font-data); font-size: 0.72rem; letter-spacing: 0; color: var(--ink-soft); font-weight: 400; }
.bom-section.folded > .bom-body { display: none; }
.bom-section.folded > h4 { margin-bottom: 0; }
.bom-product { display: flex; flex-direction: column; gap: 2px; padding: 7px 0; border-bottom: 1px dotted var(--rule-soft, #ddd); }
.bom-product .name { font-family: var(--font-data); font-size: 0.85rem; font-weight: 700; color: var(--ink); }
.bom-product .note { font-family: var(--font-data); font-size: 0.78rem; line-height: 1.45; color: var(--ink-soft); }
@media print {
    .bom-section.folded > .bom-body { display: block !important; }
    .bom-fold-bar, .bom-count, .bom-section > h4[role="button"]::after { display: none !important; }
}

/* Recommended products: name and estimate on one line, the picks, notes and price. */
.bom-product .acc-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.bom-product .acc-head .qty { font-family: var(--font-data); font-size: 0.8rem; color: var(--ink); text-align: right; }
.bom-product .acc-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.bom-product .acc-pick { font-family: var(--font-data); font-size: 0.78rem; padding: 5px 8px; border: 1px solid var(--rule); border-radius: 8px; background: #fff; color: var(--ink); max-width: 100%; }
.bom-product .note.why { font-style: italic; }
.bom-product .acc-price { align-self: flex-end; font-family: var(--font-data); font-size: 0.8rem; color: var(--ink); }
@media print { .bom-product .acc-pick { border: none; padding: 0; -webkit-appearance: none; appearance: none; } }

.bom-product .acc-qty { font-family: var(--font-data); font-size: 0.85rem; font-weight: 700; color: var(--accent); }

/* Quantity steppers on DeckWise product lines. */
.qty-step { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.qty-step .step {
    width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--ink); background: #fff; color: var(--ink);
    font-family: var(--font-data); font-size: 0.95rem; line-height: 1; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.qty-step .step:hover:not([disabled]) { background: var(--accent); border-color: var(--accent); color: #fff; }
.qty-step .step[disabled] { opacity: 0.35; cursor: default; }
.qty-step .step-val { min-width: 2.2em; text-align: center; }
.step-was { display: block; text-align: right; font-family: var(--font-data); font-size: 0.7rem; color: var(--ink-soft); margin-top: 2px; }
.step-reset { background: none; border: none; padding: 0; margin-left: 4px; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.bom-product .acc-qty .qty-step { margin: 2px 8px 2px 0; }
.bom-product .acc-qty .step-was { display: inline; margin-right: 8px; }
@media (max-width: 600px) { .qty-step .step { width: 30px; height: 30px; } }
@media print { .qty-step .step, .step-reset { display: none !important; } }

/* Product pictures in the materials list. */
.bom-thumb { width: 34px; height: 34px; object-fit: contain; background: #fff; border: 1px solid var(--rule-soft); border-radius: 6px; vertical-align: middle; margin-right: 8px; flex: none; }
.bom-item .name:has(.bom-thumb), .bom-product .name:has(.bom-thumb) { display: flex; align-items: center; }
.bom-product .bom-thumb { width: 44px; height: 44px; }

/* SKU beside a DeckWise item. */
.sku { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--rule); border-radius: 6px; font-family: var(--font-data); font-size: 0.68rem; font-weight: 400; letter-spacing: 0.02em; color: var(--ink-soft); background: #fff; white-space: nowrap; vertical-align: 1px; }
