:root {
    --tblr-font-sans-serif: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --tblr-primary: #385b88;
    --tblr-primary-rgb: 56, 91, 136;
    --tblr-body-bg: #f4f5f7;
    --tblr-body-color: #253448;
    --tblr-border-color: #e1e5eb;
    --tblr-secondary: #657386;
    --tblr-border-radius: .5rem;
    --tblr-body-font-size: .875rem;
    --tblr-font-size-sm: .75rem;
    --designer-font-size: .875rem;
    --designer-font-size-small: .75rem;
    --designer-muted: #5c6b7e;
}

* { box-sizing: border-box; }
/* Keep native text rasterisation rather than forcing Tabler's lighter grayscale rendering. */
body { margin: 0; font-family: var(--tblr-font-sans-serif); font-size: var(--designer-font-size); line-height: 1.6; -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #ae792f !important; outline-offset: 3px; }
.app-container { width: min(1536px, calc(100% - 64px)); margin-inline: auto; }
.app-header { background: #fff; border-bottom: 1px solid var(--tblr-border-color); }
.header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 24px; min-height: 138px; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 13px; color: #263a54; text-decoration: none; }
.brand:hover { color: #385b88; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 45px; height: 45px; flex-shrink: 0; border-radius: 10px; background: #385b88; color: white; }
.brand-mark .icon { width: 29px; height: 29px; }
.catalogue-browse { padding: 0 16px; font-size: var(--designer-font-size-small); }
.public-catalogue { padding-top: 32px; padding-bottom: 48px; }
.public-catalogue nav { margin-bottom: 24px; }
.public-product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.public-product { align-items: center; padding: 20px; text-align: center; color: inherit; }
.public-product img, .product-detail > img { object-fit: contain; max-width: 100%; background: white; }
.public-product h3 { margin-top: 16px; overflow-wrap: anywhere; }
.product-detail { display: flex; flex-direction: row; gap: 32px; padding: 32px; align-items: flex-start; }
.product-detail > div { min-width: 0; }
.product-detail h1 { overflow-wrap: anywhere; }
@media (max-width: 640px) { .product-detail { flex-direction: column; padding: 20px; } .product-detail > img { align-self: center; } }
.brand strong { font-size: 18px; letter-spacing: -.5px; }
.brand small { display: block; font-size: var(--designer-font-size-small); letter-spacing: 1.6px; margin-top: 3px; color: var(--designer-muted); }
.company-logo-link { display: block; justify-self: center; border-radius: 6px; }
.company-logo { display: block; width: 142px; height: auto; }
.header-quote { justify-self: end; font-size: var(--designer-font-size); border-color: #d7dfe8; }
.page-intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-block: 34px 28px; }
.page-pretitle, .eyebrow { color: var(--designer-muted); font-size: var(--designer-font-size-small); font-weight: 700; letter-spacing: 1.3px; }
.page-intro h1 { font-size: clamp(25px, 2.3vw, 34px); line-height: 1.25; letter-spacing: -1.1px; font-weight: 600; margin: 8px 0; }
.page-intro p { color: #657386; margin: 0; font-size: var(--designer-font-size); }
.intro-note { display: flex; align-items: center; gap: 12px; font-size: var(--designer-font-size-small); line-height: 1.7; color: var(--designer-muted); }
.intro-note > .icon { width: 33px; height: 33px; padding: 6px; border: 1px solid #dbe1e9; border-radius: 8px; }
.intro-note strong { font-weight: 500; color: #506077; }
.designer { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.catalogue, .workspace, .design-details, .card { min-width: 0; }
.card { border: 1px solid var(--tblr-border-color); box-shadow: 0 2px 5px #23374c03; border-radius: 10px; overflow: hidden; }
.card-header { gap: 12px; min-height: 80px; padding: 20px 24px; border-bottom: 1px solid #e9edf2; }
.card-title { font-size: var(--designer-font-size); font-weight: 600; letter-spacing: normal; margin: 3px 0 0; }
.step-number { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #dce4ee; border-radius: 9px; color: #526e90; background: #f6f8fb; font-size: var(--designer-font-size-small); font-weight: 600; }
.catalogue { position: sticky; top: 20px; }
.catalogue .card-header { padding-inline: 20px; }
.catalogue-controls { padding: 20px 16px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; }
.form-label { display: flex; flex-direction: column; gap: 7px; margin: 0; min-width: 0; color: #4d5c70; font-size: var(--designer-font-size); font-weight: 500; }
.form-select, .form-control { font-size: var(--designer-font-size); min-height: 42px; border-color: #dce2ea; border-radius: 6px; color: #34445b; background-color: #fff; }
.form-control::placeholder { color: var(--designer-muted); opacity: 1; }
.form-select { --tblr-form-select-bg-img: var(--designer-select-arrow); }
.catalogue-filters { display: grid; grid-template-columns: minmax(0, 1fr) 100px; gap: 10px; }
.catalogue-filters .form-select { padding-left: 10px; padding-right: 28px; background-position: right 8px center; }
.product-search { position: relative; display: block; margin-top: 14px; }
.product-search .icon { position: absolute; left: 11px; top: 13px; width: 17px; height: 17px; color: var(--designer-muted); pointer-events: none; }
.product-search input { padding-left: 35px; font-size: var(--designer-font-size); }
.catalogue-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-size: var(--designer-font-size-small); color: var(--designer-muted); }
#product-count { font-weight: 600; color: #586b83; }
#products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: 568px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d0d8e3 transparent; padding: 14px 16px 18px; align-content: start; }
.product { position: relative; display: flex; align-items: stretch; flex-direction: column; min-width: 0; padding: 10px 8px; background: white; border: 1px solid #e6eaf0; border-radius: 7px; color: #33445b; cursor: pointer; text-align: center; transition: border-color .15s, box-shadow .15s; }
.product:hover { border-color: #9bafc8; box-shadow: 0 3px 8px #385b8810; }
.product-image { height: 138px; display: flex; align-items: center; justify-content: center; background: white; border-radius: 4px; margin-bottom: 9px; }
.product img { height: 130px; max-width: 100%; object-fit: contain; }
.product-name { font-size: var(--designer-font-size); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.product small { margin-top: 4px; font-size: var(--designer-font-size-small); color: var(--designer-muted); overflow-wrap: anywhere; }
.product[aria-pressed=true] { border-color: #385b88; box-shadow: 0 0 0 1px #385b88; background: #f1f5fa; }
.product[aria-pressed=true]::after { content: "✓"; position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #385b88; color: #fff; font-size: var(--designer-font-size-small); }
.selection-summary { display: flex; align-items: baseline; gap: 9px; background: #f7f9fc; border-top: 1px solid #e6eaf0; padding: 14px 16px; }
.selection-dot, .preview-badge > span { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: #6b88ab; }
.selection-summary p { margin: 0; color: var(--designer-muted); font-size: var(--designer-font-size); line-height: 1.6; }
.empty-search { padding: 25px 20px; margin: 0; color: var(--designer-muted); font-size: var(--designer-font-size); }
.preview-badge { display: flex; align-items: center; gap: 6px; margin-left: auto; color: #3e6957; font-size: var(--designer-font-size-small); font-weight: 500; }
.preview-badge > span { background: #679b82; box-shadow: 0 0 0 3px #eef5f1; }
.scene-controls { padding: 18px 24px; background: #fafbfd; border-bottom: 1px solid #edf0f4; }
.scene-controls label { flex: 1; max-width: 200px; }
.auto-newel-notice { display: flex; align-items: flex-start; gap: 10px; padding: 16px 24px; background: #f0f5fb; border-bottom: 1px solid #dfe8f3; color: #526b8b; font-size: var(--designer-font-size); line-height: 1.7; }
.auto-newel-notice > .icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; }
.auto-newel-notice p { margin: 0 0 7px; }
#auto-newel-message { font-weight: 600; }
.auto-newel-notice .btn { margin-top: 3px; }
.canvas-scroll { overflow: auto; padding: 28px 20px 12px; background: #fff; scrollbar-width: thin; }
#staircase { position: relative; width: 607px; overflow: hidden; background-repeat: no-repeat; margin-inline: auto; flex-shrink: 0; }
.landing { height: 385px; }
.sloped { height: 638px; }
.scenery { position: absolute; pointer-events: none; background-repeat: no-repeat; }
.slot { position: absolute; width: 40px; height: 290px; border: 0; padding: 0; background: transparent; border-radius: 0; z-index: 4; overflow: visible; cursor: pointer; }
.slot::before { content: ""; position: absolute; inset: 0; border: 1px dashed #687e7380; pointer-events: none; }
.slot:hover { background: #b0c5e14d; }
.slot.newel { width: 45px; height: 324px; z-index: 13; }
/* Scene images use fixed geometry; Tabler's responsive max-width would shrink panels. */
.slot img { position: absolute; top: 0; left: 0; width: 40px; max-width: none; height: 290px; pointer-events: none; }
.slot.newel img { width: 45px; height: 324px; }
.slot.panel img { width: 100px; left: -30px; }
.slot.occupied::before { border-color: transparent; }
.slot.selected-slot { outline: 3px solid #ae792f; outline-offset: 2px; }
.preview-caption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 8px 24px 22px; color: var(--designer-muted); font-size: var(--designer-font-size-small); }
.preview-caption > :first-child { letter-spacing: 1px; }
.editor-tools { padding: 18px 24px; background: #fafbfd; border-top: 1px solid #e9edf2; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font-size: var(--designer-font-size); min-height: 42px; gap: 7px; font-weight: 500; box-shadow: none; }
.btn .icon { width: 16px; height: 16px; margin: 0; }
.btn-primary { --tblr-btn-bg: #385b88; --tblr-btn-border-color: #385b88; --tblr-btn-hover-bg: #2d4c75; --tblr-btn-hover-border-color: #2d4c75; --tblr-btn-active-bg: #263f61; }
.btn-outline-primary { --tblr-btn-color: #385b88; --tblr-btn-border-color: #b8c7d9; --tblr-btn-hover-bg: #385b88; --tblr-btn-hover-border-color: #385b88; }
#clear { margin-left: auto; }
.confirm-dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; margin: auto; overflow: auto; color: var(--tblr-body-color); background: white; border: 1px solid #dce2ea; border-radius: 14px; box-shadow: 0 24px 80px #17283e40; }
.confirm-dialog::backdrop { background: #17283e80; backdrop-filter: blur(3px); }
.dialog-body { padding: 28px; }
.dialog-icon { display: grid; place-items: center; width: 44px; height: 44px; color: #ad3838; background: #fbeeee; border: 1px solid #f1d6d6; border-radius: 12px; margin-bottom: 18px; }
.dialog-body h2 { font-size: 22px; letter-spacing: -.5px; margin: 0 0 12px; }
.dialog-body p { color: #657386; font-size: var(--designer-font-size); line-height: 1.8; margin: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 18px 28px; background: #fafbfd; border-top: 1px solid #e9edf2; }
.dialog-actions .btn { min-height: 40px; padding-inline: 15px; }
#design-status { font-size: var(--designer-font-size); color: var(--designer-muted); margin: 14px 0 0; line-height: 1.6; }
.design-help { margin-top: 8px; font-size: var(--designer-font-size); color: var(--designer-muted); }
.design-help summary { cursor: pointer; width: fit-content; color: #4e6788; }
.design-help p { max-width: 700px; margin: 10px 0 0; line-height: 1.8; }
.design-details { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 24px; margin-top: 24px; align-items: start; }
.parts-card .card-header { gap: 10px; padding-inline: 20px; }
.parts-card .card-header > .icon { width: 18px; height: 18px; color: #73869e; }
.parts-count { margin-left: auto; white-space: nowrap; background: #f0f3f7; color: #50647e; font-size: var(--designer-font-size-small); font-weight: 500; }
.table { margin-bottom: 0; font-size: var(--designer-font-size); }
.table thead th { background: #fafbfd; color: var(--designer-muted); font-size: var(--designer-font-size-small); letter-spacing: .5px; padding: 12px; }
.table td { padding: 14px 12px; overflow-wrap: anywhere; color: #56677d; }
.table td:first-child, .table th:first-child { padding-left: 20px; }
.table td:not(:first-child) { white-space: nowrap; }
.quantity, .table td:last-child:not([colspan]) { text-align: right; padding-right: 20px; }
.table td[colspan] { text-align: center; padding: 35px 20px; color: var(--designer-muted); }
.parts-footer { padding: 20px; border-top: 1px solid #e9edf2; }
.parts-footer > .btn { width: 100%; }
.parts-footer > p { text-align: center; margin: 10px 0 20px; font-size: var(--designer-font-size-small); color: var(--designer-muted); }
.notice { display: flex; gap: 8px; border-top: 1px solid #edf0f4; padding-top: 16px; color: var(--designer-muted); font-size: var(--designer-font-size-small); line-height: 1.7; }
.notice .icon { flex-shrink: 0; width: 15px; height: 15px; margin-top: 2px; }
.quote-card { scroll-margin-top: 24px; }
.quote-card .card-body { padding: 20px 24px 24px; }
.quote-intro { color: var(--designer-muted); font-size: var(--designer-font-size); line-height: 1.8; margin-bottom: 20px; }
.quote-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 16px; }
.comments-field { margin-top: 16px; }
.comments-field textarea { resize: vertical; min-height: 88px; }
.privacy-note { color: var(--designer-muted); font-size: var(--designer-font-size-small); line-height: 1.7; margin: 16px 0; }
.activity-consent { display: flex; align-items: flex-start; gap: 10px; }
.activity-consent input { flex: 0 0 auto; margin-top: 4px; }
.quote-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
#send-quote { min-height: 40px; padding-inline: 14px; }
#send-quote .icon:last-child { margin-left: 15px; }
#quote-status { font-size: var(--designer-font-size); line-height: 1.8; color: #4d6789; overflow-wrap: anywhere; margin: 12px 0 0; }
#quote-status:empty { margin: 0; }
.app-footer { display: flex; justify-content: space-between; gap: 20px; padding-block: 26px 32px; color: var(--designer-muted); font-size: var(--designer-font-size-small); }
.footer-dot { padding-inline: 6px; }
.skip-link { position: absolute; top: -100px; left: 20px; z-index: 100; padding: 12px 18px; background: #fff; color: #385b88; border: 1px solid #385b88; border-radius: 6px; }
.skip-link:focus { top: 12px; }

@media (min-width: 1600px) {
    .designer { grid-template-columns: 320px minmax(0, 1fr); }
}
@media (max-width: 1199px) {
    .app-container { width: calc(100% - 40px); }
    .designer { grid-template-columns: 260px minmax(0, 1fr); gap: 20px; }
    .design-details { grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 20px; }
    .parts-footer > .btn { width: auto; }
    .parts-footer > p { text-align: left; }
    .intro-note { display: none; }
    #clear { margin-left: 0; }
}
@media (max-width: 900px) {
    .header-inner { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding-block: 18px; }
    .company-logo-link { grid-column: 1 / -1; grid-row: 2; }
    .company-logo { width: 128px; }
    .brand strong { font-size: 16px; }
    .designer { grid-template-columns: minmax(0, 1fr); }
    .catalogue { position: static; }
    #products { grid-template-columns: repeat(4, minmax(0, 1fr)); max-height: 245px; }
    .catalogue-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .catalogue-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
    .product-search { align-self: end; margin-top: 0; }
    .catalogue-meta { grid-column: 1 / -1; margin-top: 0; }
    .app-footer { flex-direction: column; gap: 6px; }
}
@media (max-width: 540px) {
    .app-container { width: calc(100% - 24px); }
    .header-inner { gap: 18px 8px; }
    .brand { gap: 9px; }
    .brand-mark { width: 34px; height: 38px; border-radius: 7px; }
    .brand strong { display: block; max-width: 170px; font-size: var(--designer-font-size); line-height: 1.4; }
    .brand small { letter-spacing: .7px; }
    .header-quote { padding: 8px; }
    .header-quote .icon { display: none; }
    .company-logo { width: 116px; }
    .page-intro { padding-block: 24px; }
    .page-intro h1 { font-size: 25px; letter-spacing: -.8px; }
    .page-intro p { line-height: 1.8; }
    .card-header { padding: 18px 16px; }
    .catalogue-controls { display: block; }
    .product-search { margin-top: 12px; }
    .catalogue-meta { margin-top: 14px; }
    #products { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 270px; gap: 8px; }
    .product-image { height: 114px; }
    .product img { height: 108px; }
    .scene-controls { padding: 16px; gap: 10px; }
    .auto-newel-notice { padding: 16px; }
    .scene-controls label { flex: 1 1 calc(50% - 5px); max-width: none; }
    .scene-controls label:first-child { flex-basis: 100%; }
    .scene-controls .form-select { padding-left: 9px; padding-right: 26px; background-position: right 7px center; }
    .canvas-scroll { padding: 20px 12px 12px; }
    .preview-caption { padding-inline: 16px; }
    .editor-tools { padding: 16px; }
    .actions { display: grid; grid-template-columns: minmax(0, 1fr); }
    .actions .btn { padding-inline: 10px; }
    .quote-card .card-body { padding: 18px 16px; }
    .quote-fields { gap: 14px 12px; }
}
@media (max-width: 359px) {
    .header-quote { max-width: 80px; white-space: normal; }
    .quote-fields { grid-template-columns: minmax(0, 1fr); }
    #products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
