body {
    background-color: skyblue;
}

/* -------------------------------------------------------------------------
   Interactive 3D box viewer
   ------------------------------------------------------------------------- */
.box-viewer {
    position: relative;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 10%, #ffffff 0%, #eef2f9 45%, #cfd9ec 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -30px 60px -30px rgba(32, 54, 107, 0.18),
        0 1px 2px rgba(32, 54, 107, 0.06);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.box-viewer__stage {
    position: absolute;
    inset: 0;
    display: block;
}

.box-viewer__stage canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    outline: none;
}

.box-viewer__fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.box-viewer__fallback[hidden] {
    display: none;
}

.box-viewer__fallback svg {
    width: 100%;
    height: 100%;
}

.box-viewer__toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 2;
}

.box-viewer__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(32, 54, 107, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    color: #2b4691;
    cursor: pointer;
    transition: background-color 120ms ease, transform 120ms ease, color 120ms ease;
}

.box-viewer__btn:hover {
    background: #ffffff;
    color: #1b2e5c;
}

.box-viewer__btn:active {
    transform: scale(0.96);
}

.box-viewer__btn:focus-visible {
    outline: 2px solid #4f73d6;
    outline-offset: 2px;
}

.box-viewer__btn--toggle.is-on {
    background: #4f73d6;
    border-color: #355cb8;
    color: #ffffff;
}

.box-viewer__dims {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 5px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #1b2e5c;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(32, 54, 107, 0.15);
    border-radius: 8px;
    pointer-events: none;
    z-index: 2;
}

.box-viewer__dims-sep {
    color: rgba(32, 54, 107, 0.45);
    font-weight: 400;
}

.box-viewer__dims-unit {
    margin-left: 4px;
    font-size: 10px;
    font-weight: 500;
    color: rgba(32, 54, 107, 0.6);
    text-transform: uppercase;
}

.box-viewer__hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(32, 54, 107, 0.7);
    background: rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    pointer-events: none;
    opacity: 0.9;
    z-index: 1;
}

.box-viewer__status {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    margin: 0;
    padding: 6px 10px;
    font-size: 12px;
    color: #8a4b00;
    background: #fff4d6;
    border: 1px solid #f5d890;
    border-radius: 6px;
    z-index: 3;
}

@media (hover: none) {
    .box-viewer__hint::after {
        content: " · Touch to rotate";
    }
}

/* -------------------------------------------------------------------------
   Toast notifications (window.toast)
   ------------------------------------------------------------------------- */
.app-toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1080;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 32px));
}

.app-toast {
    pointer-events: auto;
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    line-height: 1.3;
    box-shadow: 0 6px 16px rgba(32, 54, 107, 0.22);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
    cursor: pointer;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.app-toast.is-leaving {
    opacity: 0;
    transform: translateY(10px);
}

.app-toast--success { background: #1f9254; }
.app-toast--warning { background: #c58a15; color: #241a00; }
.app-toast--error   { background: #c93131; }

/* -------------------------------------------------------------------------
   Designer dashboard
   ------------------------------------------------------------------------- */
.designer-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 767.98px) {
    .designer-stats { grid-template-columns: 1fr; }
}

.designer-stat-card {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 8px 20px rgba(32, 54, 107, 0.10);
}

.designer-stat-card__label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #556487;
    margin: 0 0 4px;
}

.designer-stat-card__value {
    font-size: 28px;
    font-weight: 700;
    color: #20366b;
    margin: 0;
    line-height: 1.1;
}

.designer-stat-card__hint {
    margin-top: 2px;
    font-size: 12px;
    color: #6a7999;
}

.designer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.designer-view-toggle {
    display: inline-flex;
    border: 1px solid #d4dbea;
    border-radius: 999px;
    padding: 2px;
    background: #fff;
}

.designer-view-toggle button {
    border: 0;
    background: transparent;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    color: #556487;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.designer-view-toggle button.is-active {
    background: #4f73d6;
    color: #fff;
}

.designer-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

@media (max-width: 991.98px) { .designer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .designer-grid { grid-template-columns: 1fr; } }

.designer-grid.is-list {
    grid-template-columns: 1fr;
}

.designer-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(32, 54, 107, 0.08);
    transition: box-shadow 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.designer-card:hover {
    box-shadow: 0 10px 24px rgba(32, 54, 107, 0.14);
    transform: translateY(-1px);
}

.designer-card.is-removing {
    opacity: 0;
    transform: scale(0.96);
}

.designer-card__thumb {
    aspect-ratio: 4 / 3;
    background: linear-gradient(135deg, #cfd9ec 0%, #eef2f9 100%);
    position: relative;
    overflow: hidden;
}

.designer-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.designer-card__thumb-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(32, 54, 107, 0.12);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #20366b;
}

.designer-card__warning {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff1cc;
    border: 1px solid #f0c96f;
    color: #8a4b00;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.designer-card__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px 10px;
    flex: 1;
}

.designer-card__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1b2e5c;
}

.designer-card__title a { color: inherit; text-decoration: none; }
.designer-card__title a:hover { text-decoration: underline; }

.designer-card__dims {
    font-size: 13px;
    color: #556487;
}

.designer-card__tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.designer-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #edf1f8;
    color: #405079;
    text-transform: capitalize;
}

.designer-tag--vented {
    background: #dbeefe;
    color: #0b4e8c;
    font-weight: 600;
}

.designer-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.designer-badge--success { background: #d7f0e0; color: #106a34; }
.designer-badge--warning { background: #fff1cc; color: #8a4b00; }
.designer-badge--danger  { background: #fbdcdc; color: #a12525; }

.designer-card__meta {
    font-size: 12px;
    color: #6a7999;
}

.designer-card__advisory {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1.3;
}

.designer-card__advisory--warning {
    background: #fff4d6;
    color: #7a4b00;
    border: 1px solid #f3d581;
}

.designer-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px 14px;
    border-top: 1px solid #eef1f7;
    background: #fbfcfe;
}

.designer-card__actions .btn { font-size: 12px; padding: 4px 10px; }

.designer-card__confirm {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fdecec;
    color: #7a1d1d;
    font-size: 12px;
}

/* List view — horizontal row layout */
.designer-grid.is-list .designer-card {
    flex-direction: row;
    align-items: stretch;
}

.designer-grid.is-list .designer-card__thumb {
    flex: 0 0 160px;
    aspect-ratio: auto;
    height: auto;
}

.designer-grid.is-list .designer-card__body {
    flex: 1;
    padding: 12px 14px;
}

.designer-grid.is-list .designer-card__actions {
    border-top: 0;
    border-left: 1px solid #eef1f7;
    background: transparent;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    padding: 12px 14px;
    flex: 0 0 auto;
}

@media (max-width: 575.98px) {
    .designer-grid.is-list .designer-card { flex-direction: column; }
    .designer-grid.is-list .designer-card__thumb { flex-basis: auto; }
    .designer-grid.is-list .designer-card__actions { flex-direction: row; border-left: 0; border-top: 1px solid #eef1f7; }
}

/* Bed warning in editor */
.bed-warning {
    font-size: 12px;
    color: #8a4b00;
    background: #fff4d6;
    border: 1px solid #f5d890;
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 8px;
}

.bed-warning[hidden] { display: none; }

/* -------------------------------------------------------------------------
   Editor layout — sticky viewer + scrollable specs panel
   ------------------------------------------------------------------------- */
:root {
    --editor-gap: 1.5rem;
    --viewer-sticky-top: 1.25rem;
    --viewer-height: calc(100vh - 2.5rem);
}

/* Dashboard has a fixed topnav (3.625rem tall) — offset sticky top accordingly */
body.nav-fixed {
    --viewer-sticky-top: calc(3.625rem + 1rem);
    --viewer-height: calc(100vh - 3.625rem - 2rem);
}

.editor-layout {
    display: flex;
    align-items: flex-start; /* required for sticky to work in flex */
    gap: var(--editor-gap);
}

.editor-specs-panel {
    flex: 0 0 42%;
    min-width: 0;
}

.editor-viewer-panel {
    flex: 0 0 calc(58% - var(--editor-gap));
    min-width: 0;
    position: sticky;
    top: var(--viewer-sticky-top);
    height: var(--viewer-height);
    min-height: 400px;
}

/* Make the card fill the sticky panel */
.editor-viewer-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-viewer-body {
    flex: 1;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
}

/* Fluid viewer fills its container fully */
.box-viewer--fluid {
    width: 100%;
    height: 100%;
    aspect-ratio: unset;
    border-radius: 0;
    box-shadow: none;
}

/* Tablet: equal split, still sticky */
@media (max-width: 1199.98px) {
    .editor-specs-panel  { flex-basis: 45%; }
    .editor-viewer-panel { flex-basis: calc(55% - var(--editor-gap)); }
}

/* Mobile: stack vertically, viewer first, no sticky */
@media (max-width: 991.98px) {
    .editor-layout {
        flex-direction: column;
        gap: 1rem;
    }

    .editor-specs-panel,
    .editor-viewer-panel {
        flex: none;
        width: 100%;
    }

    .editor-viewer-panel {
        position: relative;
        top: auto;
        height: 50vh;
        min-height: 350px;
        order: -1; /* viewer above specs on mobile */
    }
}

/* Duplicate-scale popover */
.designer-scale-popover {
    background: #fff;
    border: 1px solid #d4dbea;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(32, 54, 107, 0.14);
    padding: 14px;
    min-width: 260px;
}

.designer-scale-popover[hidden] { display: none; }

/* Surface fillet selector — used by the live editor */
.surface-fillets {
    --surface-num-color: #475569;
    --surface-num-active: #2563eb;
}

.surface-fillets__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.surface-fillets__title {
    font-weight: 600;
}

.corner-mode-selector .btn {
    flex: 1;
    min-width: 70px;
}

.corner-mode-selector .btn.active {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.surface-fillets__summary {
    margin-top: 0.5rem;
}

.surface-fillets__advanced[hidden] { display: none; }
.surface-fillets__summary[hidden] { display: none; }

.surface-fillets__layout {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    flex-wrap: wrap;
}

.surface-fillets__diagram {
    flex: 0 0 140px;
    width: 140px;
    height: auto;
    align-self: flex-start;
}

.surface-fillets__dot {
    cursor: pointer;
    transition: transform 120ms ease;
}

.surface-fillets__dot:hover {
    transform: translate(-1px, -1px);
}

.surface-fillets__dot circle[fill="#3b82f6"] + text,
.surface-fillets__dot circle[data-active="1"] + text {
    fill: #fff;
}

.surface-fillets__controls {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.surface-fillets__item {
    display: grid;
    grid-template-columns: 22px 1fr 110px;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.35rem;
    border: 1px solid transparent;
    border-radius: 6px;
    transition: background-color 200ms ease, border-color 200ms ease;
}

.surface-fillets__item--highlighted {
    background: #eef4ff;
    border-color: #93c5fd;
}

.surface-fillets__item--coming-soon { opacity: 0.6; }
.surface-fillets__item--coming-soon .surface-fillets__label { color: #94a3b8; }
.surface-fillets__item--coming-soon .surface-fillets__num {
    background: #e2e8f0;
    color: #94a3b8;
}
.surface-fillets__item--coming-soon .surface-fillets__input .form-control,
.surface-fillets__item--coming-soon .surface-fillets__input .input-group-text {
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}
.surface-fillets__coming-soon-badge {
    margin-left: 0.4rem;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
    padding: 0.18rem 0.4rem;
}

.surface-fillets__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--surface-num-color);
    font-size: 0.75rem;
    font-weight: 700;
}

.surface-fillets__item[data-active="1"] .surface-fillets__num {
    background: var(--surface-num-active);
    color: #fff;
}

.surface-fillets__label {
    font-size: 0.85rem;
    color: #334155;
}

.surface-fillets__input { width: 110px; }
.surface-fillets__input .form-control { font-size: 0.8rem; }
.surface-fillets__input .input-group-text { font-size: 0.75rem; }

.surface-fillets__cap-warning { font-size: 0.75rem; }

