        @font-face {
            font-family: 'NinoMtavruli';
            src: url('/fonts/bpg_nino_mtavruli_bold.ttf') format('truetype');
            font-weight: bold;
            font-style: normal;
        }

        :root {
            --bg-dark: #0b1922;
            --bg-panel: #112634;
            --bg-card: #173245;
            --bg-input: #08131a;
            --border: #254b63;
            --cyan: #00e5ff;
            --gold: #c8ab65;
            --text-light: #f1f5f9;
            --text-dim: #94a3b8;
            --ok: #10b981;
            --warn: #f59e0b;
            --err: #ef4444;
        }

        * { box-sizing: border-box; }
        
        body, input, select, button, textarea, text, tspan {
            font-family: 'NinoMtavruli', sans-serif !important;
        }

        body {
            margin: 0;
            padding: 12px 12px 0 12px;
            background: linear-gradient(160deg, #07131a 0%, #102a3a 100%);
            color: var(--text-light);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .app-shell {
            max-width: 1780px;
            width: 100%;
            margin: 0 auto;
            display: grid;
            grid-template-columns: 480px 1fr;
            gap: 18px;
            align-items: start;
        }

        @media (max-width: 1260px) {
            .app-shell { grid-template-columns: 1fr; }
        }

        .panel {
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 16px;
            box-shadow: 0 12px 35px rgba(0,0,0,0.55);
        }

        .app-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border);
            padding-bottom: 12px;
            margin-bottom: 12px;
        }
        .app-header h2 {
            margin: 0;
            font-size: 1.15rem;
            color: var(--cyan);
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 700;
        }
        .badge-sx {
            background: linear-gradient(135deg, var(--gold), #a3843b);
            color: #000;
            font-weight: 800;
            font-size: 0.72rem;
            padding: 4px 9px;
            border-radius: 4px;
            letter-spacing: 0.5px;
        }

        /* 15 Stair Type Visual Selector Grid */
        .type-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 6px;
            margin-bottom: 14px;
            max-height: 255px;
            overflow-y: auto;
            padding-right: 4px;
        }
        .type-grid::-webkit-scrollbar { width: 5px; }
        .type-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

        .type-btn {
            background: var(--bg-input);
            border: 1px solid var(--border);
            color: var(--text-dim);
            padding: 7px 5px;
            border-radius: 7px;
            cursor: pointer;
            text-align: center;
            font-size: 0.68rem;
            font-weight: 500;
            transition: 0.2s;
            user-select: none;
            line-height: 1.25;
        }
        .type-btn strong {
            display: block;
            font-size: 0.82rem;
            color: var(--cyan);
            margin-bottom: 2px;
            font-weight: 700;
        }
        .type-btn:hover {
            border-color: rgba(0, 229, 255, 0.5);
        }
        .type-btn.active {
            background: rgba(0, 229, 255, 0.16);
            border-color: var(--cyan);
            color: #fff;
            box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
        }

        .form-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
        }
        .full-w { grid-column: 1 / -1; }

        .group-title {
            grid-column: 1 / -1;
            font-size: 0.74rem;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: var(--gold);
            font-weight: 700;
            margin-top: 6px;
            padding-top: 8px;
            border-top: 1px dashed var(--border);
        }

        .field label {
            display: block;
            font-size: 0.72rem;
            color: var(--text-dim);
            margin-bottom: 4px;
            font-weight: 500;
        }
        .field input, .field select {
            width: 100%;
            background: var(--bg-input);
            border: 1px solid var(--border);
            color: var(--text-light);
            padding: 8px 10px;
            border-radius: 6px;
            font-size: 0.86rem;
            outline: none;
            transition: border-color 0.2s;
        }
        .field input:focus, .field select:focus {
            border-color: var(--cyan);
        }

        .calc-btn-wrap {
            grid-column: 1 / -1;
            margin-top: 8px;
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 8px;
        }
        .calc-btn {
            background: linear-gradient(135deg, var(--cyan), #0284c7);
            color: #000;
            border: none;
            padding: 12px;
            border-radius: 8px;
            font-weight: 800;
            font-size: 0.95rem;
            cursor: pointer;
            transition: filter 0.2s;
            box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
        }
        .calc-btn:hover { filter: brightness(1.1); }
        
        .print-btn {
            background: var(--bg-card);
            color: var(--gold);
            border: 1px solid var(--gold);
            padding: 12px 14px;
            border-radius: 8px;
            font-weight: 700;
            font-size: 0.88rem;
            cursor: pointer;
            transition: 0.2s;
        }
        .print-btn:hover {
            background: var(--gold);
            color: #000;
        }

        .mode-tabs {
            display: flex;
            gap: 8px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }
        .mode-tab {
            flex: 1;
            min-width: 150px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-light);
            padding: 10px 12px;
            border-radius: 8px;
            font-weight: 600;
            font-size: 0.82rem;
            cursor: pointer;
            text-align: center;
            transition: 0.2s;
        }
        .mode-tab.active {
            background: linear-gradient(135deg, var(--cyan), #0284c7);
            color: #000;
            border-color: var(--cyan);
            font-weight: 700;
        }

        .stage-box {
            position: relative;
            width: 100%;
            height: 560px;
            background: radial-gradient(circle at center, #16364b 0%, #07121a 100%);
            border: 1px solid var(--border);
            border-radius: 10px;
            overflow: hidden;
            margin-bottom: 16px;
        }

        #view3D, #view2D, #viewStringer, #viewWinder {
            width: 100%;
            height: 100%;
        }
        #view2D, #viewStringer, #viewWinder {
            display: none;
            padding: 12px;
            overflow: auto;
            background: #08151f;
        }

        .cam-bar {
            position: absolute;
            top: 10px;
            left: 10px;
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            z-index: 10;
        }
        .cam-btn {
            background: rgba(8, 19, 26, 0.85);
            border: 1px solid var(--border);
            color: var(--text-light);
            padding: 6px 10px;
            border-radius: 6px;
            font-size: 0.75rem;
            cursor: pointer;
            font-weight: 500;
            transition: 0.2s;
        }
        .cam-btn:hover, .cam-btn.active {
            border-color: var(--cyan);
            color: var(--cyan);
        }

        .watermark-3d {
            position: absolute;
            bottom: 10px;
            right: 14px;
            font-size: 0.75rem;
            color: rgba(255, 255, 255, 0.35);
            pointer-events: none;
            z-index: 10;
            letter-spacing: 0.8px;
        }

        .ergo-alert {
            padding: 11px 14px;
            border-radius: 8px;
            font-size: 0.86rem;
            font-weight: 500;
            margin-bottom: 14px;
        }
        .ergo-ok { background: rgba(16, 185, 129, 0.14); border: 1px solid var(--ok); color: var(--ok); }
        .ergo-warn { background: rgba(245, 158, 11, 0.14); border: 1px solid var(--warn); color: var(--warn); }
        .ergo-err { background: rgba(239, 68, 68, 0.14); border: 1px solid var(--err); color: var(--err); }

        .kpi-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
            gap: 10px;
            margin-bottom: 16px;
        }
        .kpi-box {
            background: var(--bg-card);
            border: 1px solid var(--border);
            padding: 10px;
            border-radius: 8px;
            text-align: center;
        }
        .kpi-box small {
            display: block;
            font-size: 0.68rem;
            color: var(--text-dim);
            text-transform: uppercase;
            margin-bottom: 3px;
            font-weight: 500;
        }
        .kpi-box strong {
            font-size: 1.12rem;
            color: var(--cyan);
            font-weight: 700;
        }

        .tables-row {
            display: grid;
            grid-template-columns: 1.15fr 0.85fr;
            gap: 16px;
        }
        @media (max-width: 950px) {
            .tables-row { grid-template-columns: 1fr; }
        }

        .info-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 14px;
        }
        .info-card h3 {
            margin: 0 0 10px 0;
            font-size: 0.92rem;
            color: var(--gold);
            border-bottom: 1px solid var(--border);
            padding-bottom: 7px;
            font-weight: 600;
        }
        .spec-ul {
            list-style: none;
            margin: 0;
            padding: 0;
            font-size: 0.84rem;
            line-height: 1.65;
        }
        .spec-ul li {
            padding: 6px 0;
            border-bottom: 1px solid rgba(255,255,255,0.05);
        }
        .spec-ul li:last-child { border-bottom: none; }

        .tag-c {
            background: rgba(0, 229, 255, 0.15);
            color: var(--cyan);
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: 600;
        }
        .tag-g {
            background: rgba(200, 171, 101, 0.2);
            color: var(--gold);
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: 600;
        }

        /* ================= FOOTER STYLES ================= */
        .app-footer {
            max-width: 1780px;
            width: 100%;
            margin: 24px auto 12px auto;
            background: var(--bg-panel);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px 24px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        }
        .footer-grid {
            display: grid;
            grid-template-columns: 1.4fr 1fr 1fr;
            gap: 20px;
            padding-bottom: 16px;
            border-bottom: 1px solid var(--border);
        }
        @media (max-width: 900px) {
            .footer-grid { grid-template-columns: 1fr; }
        }
        .footer-col h4 {
            margin: 0 0 8px 0;
            color: var(--cyan);
            font-size: 0.95rem;
        }
        .footer-col p {
            margin: 0;
            font-size: 0.8rem;
            color: var(--text-dim);
            line-height: 1.6;
        }
        .footer-links {
            list-style: none;
            padding: 0;
            margin: 0;
            font-size: 0.82rem;
            line-height: 1.8;
        }
        .footer-links li { color: var(--text-light); }
        .footer-links a {
            color: var(--gold);
            text-decoration: none;
        }
        .footer-links a:hover { text-decoration: underline; }
        .footer-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 14px;
            font-size: 0.78rem;
            color: var(--text-dim);
            flex-wrap: wrap;
            gap: 10px;
        }
        .copyright-badge {
            background: rgba(200, 171, 101, 0.15);
            border: 1px solid var(--gold);
            color: var(--gold);
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 0.75rem;
        }

        @media print {
            body { background: #fff; color: #000; }
            .cam-bar, .calc-btn-wrap, .mode-tabs { display: none !important; }
            .app-shell { grid-template-columns: 1fr; }
        }

        .cad-drawing-stack{display:grid;grid-template-columns:1fr;gap:12px;padding:12px;max-height:560px;overflow:auto}
        .cad-drawing-stack section{border:1px solid #254b63;border-radius:9px;background:#08131a;min-width:0}
        .cad-spec-table{width:100%;border-collapse:collapse;font-size:12px;min-width:620px}
        .cad-spec-table th,.cad-spec-table td{padding:7px;border-bottom:1px solid #254b63;text-align:left}
        .cad-spec-table th{color:#00e5ff}
        .cad-tread-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:12px;max-height:440px;overflow:auto}
        .cad-tread-card{padding:9px;background:#0b202b;border:1px solid #254b63;border-radius:8px}
        .cad-tread-card h4{font-size:12px;color:#c8ab65;margin:0 0 6px}
        .cad-tread-card p{font-size:11px;line-height:1.5;overflow-wrap:anywhere}
        @media print{
          *{-webkit-print-color-adjust:exact;print-color-adjust:exact}
          .app-shell{display:block!important;max-width:none}
          .app-shell>.panel:first-child,.mode-tabs,.cam-bar,.kpi-row,.tables-row,.app-footer,.footer-grid,.footer-bottom,#ergoBox{display:none!important}
          .app-shell>.panel:nth-child(2){border:0;box-shadow:none;padding:0}
          .stage-box{height:auto!important;max-height:none!important;overflow:visible!important;border:0}
          #view3D,#viewStringer,#viewWinder,.watermark-3d{display:none!important}
          #view2D{display:block!important;height:auto!important;overflow:visible!important}
          .cad-drawing-stack{max-height:none!important;overflow:visible!important;padding:0;gap:15px}
          .cad-drawing-stack section{break-inside:avoid;page-break-inside:avoid;background:#08131a}
        }


/* Category menu stage 1: 9 top-level groups, 35 clearly illustrated variants. */
.cad-category-nav{margin:0 0 18px;border:1px solid #2a5367;border-radius:12px;background:#0c1e2a;padding:12px}
.cad-menu-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
.cad-menu-head h3{font-size:1rem;color:#00dced;margin:0 0 4px}
.cad-menu-head p{font-size:.7rem;color:#9db6c3;margin:0}
.cad-menu-back{padding:8px 12px;flex-shrink:0;border:1px solid #416781;border-radius:8px;background:#183748;color:#d4f4ff;cursor:pointer}
.cad-category-cards{display:grid;grid-template-columns:1fr;gap:7px;max-height:440px;overflow-y:auto;padding-right:4px}
.cad-nav-card{width:100%;display:flex;align-items:center;gap:10px;text-align:left;min-height:82px;padding:7px;background:#142d3b;color:#e2eff5;border:1px solid #315264;border-radius:9px;cursor:pointer;transition:background .15s,border-color .15s}
.cad-nav-card:hover,.cad-nav-card:focus-visible{background:#1c4052;border-color:#13d8eb;outline:none}
.cad-nav-card.cad-selected{border-color:#00e5ff;background:#153b4f}
.cad-nav-card img{width:86px;height:68px;object-fit:contain;border-radius:7px;flex-shrink:0}
.cad-card-copy{display:flex;flex:1;min-width:0;flex-direction:column;gap:3px}
.cad-card-copy strong{font-size:.82rem;line-height:1.25;color:#ecf7fa}
.cad-card-en{font-family:Arial,sans-serif!important;color:#96c8d4;font-size:.69rem;line-height:1.25}
.cad-card-note{color:#d4ae6e;font-size:.66rem}
.cad-nav-card.cad-pending{border-style:dashed}
.cad-nav-card.cad-pending .cad-card-note{color:#f3c06d}
.cad-card-arrow{font-family:Arial,sans-serif!important;color:#15d3e8;font-size:27px;line-height:1;padding:0 4px}
.cad-choice-status{margin-top:10px;border-top:1px solid #2a5367;padding:11px 5px 2px;color:#bcd3dd;font-size:.76rem;line-height:1.5}
.cad-lock-note{display:block;color:#a9bfcd;font-size:.65rem;margin-bottom:5px}
#cadParentCards[hidden],#cadSubCards[hidden],#cadMenuBack[hidden]{display:none!important}
.cad-mobile-viewer:empty{display:none}
@media(max-width:1260px){
 .cad-mobile-viewer:not(:empty){display:block;max-width:1780px;width:100%;margin:0 auto 12px;padding:0;border:1px solid #254b63;border-radius:12px;background:#112634}
 .cad-mobile-viewer .mode-tabs{margin:10px;padding:0;gap:5px}
 .cad-mobile-viewer .mode-tab{font-size:.7rem;min-width:0;flex:1 1 45%;padding:7px 3px}
 .cad-mobile-viewer .stage-box{margin-bottom:0;border:0;border-radius:0;height:360px}
 .cad-category-cards{max-height:440px}
}
@media(max-width:620px){
 .cad-nav-card img{width:74px;height:60px}
 .cad-nav-card{min-height:73px;padding:6px;gap:8px}
 .cad-card-copy strong{font-size:.77rem}
 .cad-card-en{font-size:.63rem}
 .cad-mobile-viewer .stage-box{height:300px}
}

/* Category 1 screenshot reference calculator. Scoped styles do not change the 9-category menu. */
#cat1Fields[hidden], #cat1LegacyFields[hidden], .c1-field[hidden]{display:none!important}
.c1-fields{padding:14px 12px 20px;border:1px solid #245264;border-radius:12px;margin-top:12px;background:#112d3b;color:#eaf3f6}
.c1-head h3{font-size:1.03rem;margin:0 0 5px;color:#5ee0ee}
.c1-head p,.c1-soft{font-size:.77rem;line-height:1.5;color:#abc4d1}
.c1-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:14px 0}
.c1-field{display:flex;flex-direction:column;gap:6px;font-size:.78rem;color:#cbdce5}
.c1-field input,.c1-field select{border:1px solid #416779;border-radius:7px;min-width:0;width:100%;padding:9px 7px;background:#eaf4f7;color:#193745;font-size:.87rem}
.c1-field:focus-within{color:#7df3ff}
.c1-error{margin:10px 0;color:#ffc1a4;font-weight:600}
.c1-fields #cat1Results{border-top:1px solid #2c5a6a;margin-top:16px;padding-top:14px}
.c1-fields h4{font-size:.88rem;margin:13px 0 6px;color:#b7e8f5}
.c1-table{border-collapse:collapse;width:100%;margin:6px 0 14px;font-size:.79rem;table-layout:auto;color:#d8e8ef}
.c1-table td,.c1-table th{border-bottom:1px solid #3a5e6b;padding:6px;text-align:left;vertical-align:top;overflow-wrap:anywhere}
.c1-actions{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.c1-actions button{background:#2d6880;color:white;border:1px solid #57899e;border-radius:8px;padding:9px;cursor:pointer}
.c1-drawing{background:#e2f0f4;color:#334a58;border-radius:9px;padding:10px;margin:12px 0;overflow:auto}
.c1-drawing h3,.c1-drawing h4{color:#284a5a;margin:4px 0 10px}
.c1-drawing p{color:#425e6e;font-size:.75rem}
.c1-drawing svg{display:block;width:100%;max-height:480px}
.c1-drawing .c1-table{color:#2e4c5a}
.c1-drawing .c1-table td,.c1-drawing .c1-table th{border-color:#abc1c9}
@media(max-width:620px){.c1-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.c1-field{font-size:.7rem}.c1-field input,.c1-field select{font-size:.78rem;padding:8px 5px}}


/* FIX 2026-11: the 3D stage is a normal vertical layout on phones.
   Controls must never obscure canvas, parameter fields, or other buttons. */
@media(max-width:1260px){
 .cad-mobile-viewer{min-width:0;box-sizing:border-box;}
 .cad-mobile-viewer .stage-box{display:flex;flex-direction:column;position:relative;height:auto!important;min-height:0!important;overflow:hidden;}
 .cad-mobile-viewer #view3D{order:1;height:clamp(280px,52vh,470px)!important;min-height:280px;flex:0 0 auto;touch-action:pan-y;}
 .cad-mobile-viewer #view2D,.cad-mobile-viewer #viewStringer,.cad-mobile-viewer #viewWinder{order:1;height:clamp(280px,52vh,470px)!important;flex:0 0 auto;}
 .cad-mobile-viewer .cam-bar{order:2;position:static!important;inset:auto!important;display:flex;flex-wrap:wrap;gap:7px;padding:10px;background:#0c2230;z-index:2;}
 .cad-mobile-viewer .cam-btn{flex:1 0 100px;min-height:40px;}
 .cad-mobile-viewer .watermark-3d{top:46px;bottom:auto;right:8px;left:auto;font-size:.57rem;z-index:1;}
 .cad-mobile-viewer .mode-tab{min-height:44px;}
 .cad-mobile-viewer *{box-sizing:border-box;}
}
@media(max-width:390px){
 .cad-mobile-viewer .cam-btn{font-size:.71rem;padding:8px 4px;}
 .c1-grid{grid-template-columns:minmax(0,1fr)!important;}
}

/* Category 1 physical corner-shape buttons */
.c1-turn-shape-switch{display:grid;grid-template-columns:1fr 1fr;gap:6px;width:100%}
.c1-turn-shape-switch button{min-height:43px;border:1px solid #477489;border-radius:8px;background:#163d51;color:#e3f1f6;font-size:.75rem;padding:6px 5px;cursor:pointer}
.c1-turn-shape-switch button[aria-pressed="true"]{color:#05212e;background:#5eddeb;border-color:#79f0fe;font-weight:700}

/* Unified 11-shape picker: shape, turn mode, and support are separate controls. */
.cad-shape-grid{max-height:470px}
.cad-shape-grid .cad-nav-card[aria-pressed="true"]{border-color:#00e5ff;background:#153b4f;box-shadow:0 0 0 1px #00e5ff inset}
.cad-shape-grid .cad-shape-pending{border-style:dashed}
.cad-shape-grid .cad-shape-pending .cad-card-note{color:#f3c06d}
.cad-pending-sketch{width:86px;height:68px;flex:0 0 86px;display:grid;place-items:center;border:1px dashed #7890a0;border-radius:7px;color:#f3c06d;font-size:2.1rem;background:#10232f}
.cad-shape-options{display:grid;grid-template-columns:1fr;gap:8px;margin:10px 0}
.cad-shape-options label{display:grid;gap:5px;color:#b7d6e4;font-size:.78rem;font-weight:650}
.cad-shape-options select{width:100%;min-height:40px;border:1px solid #3b6378;border-radius:7px;background:#0d2330;color:#eaf5fa;padding:7px 9px}
.cad-shape-options select:disabled{opacity:.62}
@media(min-width:900px){.cad-shape-grid{grid-template-columns:1fr 1fr}.cad-shape-grid .cad-nav-card{min-height:84px}.cad-shape-grid .cad-nav-card img,.cad-pending-sketch{width:66px;height:56px;flex-basis:66px}}
@media(max-width:520px){.cad-shape-grid{grid-template-columns:1fr}.cad-shape-grid .cad-nav-card img,.cad-pending-sketch{width:74px;height:60px;flex-basis:74px}}
