
        /* ===========================================
    THEME: "Taxonomy Grid" - กระดาษกราฟ + หมึกน้ำเงินเข้ม
    ปรับสีทั้งชุดได้ที่ตัวแปรด้านล่าง
    =========================================== */
        :root {
            --paper: #f6f4ec;
            /* พื้นกระดาษ */
            --ink: #14203c;
            /* หมึกเข้ม (ตัวอักษรหลัก, เส้นกรอบ) */
            --cobalt: #1F49C7;
            /* สีเน้นหลัก + โดเมนพุทธิพิสัย */
            --red: #E8555A;
            /* โดเมนจิตพิสัย */
            --green: #1E9E6A;
            /* โดเมนทักษะพิสัย */
            --muted: #5a6377;
            /* ตัวอักษรรอง */
            --card: #ffffff;
            /* พื้นการ์ด */
            --grid-line: rgba(31, 73, 199, 0.07);
            --grid-line-major: rgba(31, 73, 199, 0.16);
            --stage-bg: #d9d5c9;
            /* พื้นนอก stage (letterbox) */
            --slide-bg: #f6f4ec;

            --font-display: 'Bai Jamjuree', sans-serif;
            --font-body: 'IBM Plex Sans Thai', sans-serif;
            --font-mono: 'JetBrains Mono', monospace;

            --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
            --ease: cubic-bezier(0.16, 1, 0.3, 1);
            --duration-normal: 0.6s;

            /* ── โทเคนเสริม ใช้กับชุดควบคุมสองโหมด แถบหมวด และผู้ช่วยถาม-ตอบ ── */
            --cobalt-deep: #17389a;
            --green-deep: #146f4b;
            /* เฉดเข้มของสีเน้นหลัก ใช้เฉพาะสถานะ hover ของปุ่มลอย */
            --stone: var(--paper);
            --stone-card: #fbfaf4;
            --stone-line: rgba(20, 32, 60, 0.22);
            --ink-soft: var(--muted);
            --ink-faint: #7a8296;
            --bronze: var(--cobalt);
            --bronze-deep: var(--cobalt-deep);
            --bronze-soft: rgba(31, 73, 199, 0.10);
            --bronze-line: rgba(31, 73, 199, 0.38);
            --patina: var(--cobalt-deep);
            --danger: #c02428;

            /* ── ชุดควบคุมสองโหมด ── */
            --gutter-x: 0px;
            --gutter-y: 0px;
            --dock-bottom: 8px;
            --chrome-btn: 42px;
        }

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

        /* ===========================================
   FIXED 16:9 STAGE: MANDATORY BASE STYLES
   (viewport-base.css ฉบับเต็ม)
   =========================================== */
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0;
            overflow: hidden;
            background: var(--stage-bg, #000);
        }

        .deck-viewport {
            position: fixed;
            inset: 0;
            overflow: hidden;
            background: var(--stage-bg, #000);
        }

        .deck-stage {
            position: absolute;
            left: 0;
            top: 0;
            width: 1920px;
            height: 1080px;
            overflow: hidden;
            transform-origin: 0 0;
            background: var(--slide-bg, #fff);
        }

        .slide {
            position: absolute;
            inset: 0;
            width: 1920px;
            height: 1080px;
            overflow: hidden;
            display: block;
            visibility: hidden;
            opacity: 0;
            pointer-events: none;
            background: var(--slide-bg, #fff);
        }

        .slide.active,
        .slide.visible {
            visibility: visible;
            opacity: 1;
            pointer-events: auto;
            z-index: 1;
        }

        img,
        video,
        canvas,
        svg {
            max-width: 100%;
            max-height: 100%;
        }

        /* ===========================================
   สีประจำหมวดโดเมน ตั้งค่า --act ที่ระดับ .slide แล้วทุกชิ้นในหน้าสืบทอด
   สีเดียวกันหมายถึงโดเมนเดียวกันเสมอในทุกหน้า
   หน้าที่ไม่ได้อยู่โดเมนใดโดเมนหนึ่ง คงสีเน้นหลัก (cobalt) ไว้
   =========================================== */
        .slide {
            --act: var(--cobalt);
        }

        .slide[data-act="cognitive"] {
            --act: var(--cobalt);
        }

        .slide[data-act="affective"] {
            --act: var(--red);
        }

        .slide[data-act="psychomotor"] {
            --act: var(--green);
        }

        @media print {

            html,
            body {
                width: 1920px;
                height: auto;
                overflow: visible;
                background: #fff;
            }

            .deck-viewport {
                position: static;
                overflow: visible;
                background: #fff;
            }

            .deck-stage {
                position: static;
                width: auto;
                height: auto;
                transform: none !important;
                background: none;
            }

            .slide {
                position: relative;
                display: block !important;
                visibility: visible !important;
                opacity: 1 !important;
                pointer-events: auto !important;
                width: 1920px;
                height: 1080px;
                break-after: page;
                page-break-after: always;
            }

            .slide:last-child {
                break-after: auto;
                page-break-after: auto;
            }

            .reveal,
            .reveal-pop {
                opacity: 1 !important;
                transform: none !important;
            }

            .deck-chrome,
            .progress-track,
            .key-hint,
            .edit-hotzone,
            .edit-toggle,
            .fab-settings,
            .fab-chat,
            .chat-panel,
            .setup-overlay,
            .api-modal-overlay {
                display: none !important;
            }
        }

        @media (prefers-reduced-motion: reduce) {

            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                transition-duration: 0.2s !important;
            }
        }

        /* ===========================================
   SLIDE BACKGROUND: กระดาษกราฟ (ตาราง 40px, เส้นหลัก 200px)
   =========================================== */
        .slide::before {
            content: "";
            position: absolute;
            inset: 0;
            pointer-events: none;
            background:
                linear-gradient(var(--grid-line) 1px, transparent 1px),
                linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
                linear-gradient(var(--grid-line-major) 1.5px, transparent 1.5px),
                linear-gradient(90deg, var(--grid-line-major) 1.5px, transparent 1.5px);
            background-size: 40px 40px, 40px 40px, 200px 200px, 200px 200px;
        }

        /* ===========================================
   SLIDE CHROME: แถบบน / แถบล่าง (อยู่ในทุกสไลด์)
   =========================================== */
        .bar-top {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 72px;
            z-index: 3;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 64px;
            border-bottom: 3px solid var(--ink);
            background: rgba(246, 244, 236, 0.92);
            font-family: var(--font-mono);
            font-size: 20px;
            letter-spacing: 0.1em;
            color: var(--ink);
        }

        .bar-top .dot {
            display: inline-block;
            width: 13px;
            height: 13px;
            border-radius: 50%;
            background: var(--cobalt);
            margin-right: 13px;
            vertical-align: middle;
        }

        .bar-bot {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 62px;
            z-index: 3;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 124px;
            border-top: 3px solid var(--ink);
            background: rgba(246, 244, 236, 0.92);
            font-family: var(--font-body);
            font-size: 21px;
            color: var(--muted);
        }

        .bar-bot .pg {
            font-family: var(--font-mono);
        }

        /* ── แถบบอกโดเมนปัจจุบัน อยู่ในแถบบนของทุกสไลด์ ── */
        .act-strip {
            display: inline-flex;
            gap: 8px;
            margin-left: 18px;
            vertical-align: middle;
        }

        .act-strip span {
            font-family: var(--font-mono);
            font-size: 17px;
            font-weight: 700;
            padding: 3px 11px;
            border: 2px solid var(--ink);
            background: var(--card);
            color: var(--muted);
            letter-spacing: 0.04em;
        }

        .act-strip span.on {
            background: var(--act);
            border-color: var(--act);
            color: #fff;
        }

        /* ===========================================
   TYPOGRAPHY + COMPONENTS
   =========================================== */
        .slide-pad {
            position: absolute;
            inset: 72px 100px 62px;
            z-index: 2;
        }

        .kicker {
            display: inline-flex;
            align-items: center;
            gap: 14px;
            font-family: var(--font-mono);
            font-size: 19px;
            font-weight: 700;
            letter-spacing: 0.2em;
            text-transform: uppercase;
            color: var(--cobalt);
            border: 2px solid var(--cobalt);
            background: var(--card);
            padding: 9px 22px;
            box-shadow: 5px 5px 0 rgba(31, 73, 199, 0.22);
        }

        .kicker.demo {
            color: var(--card);
            background: var(--ink);
            border-color: var(--ink);
            box-shadow: 5px 5px 0 rgba(20, 32, 60, 0.28);
        }

        .kicker.demo .live {
            color: #7fd4ab;
        }

        h1 {
            font-family: var(--font-display);
            font-weight: 700;
            font-size: 122px;
            line-height: 1.02;
            letter-spacing: -0.01em;
            color: var(--ink);
        }

        h2 {
            font-family: var(--font-display);
            font-weight: 700;
            font-size: 60px;
            line-height: 1.12;
            color: var(--ink);
            margin-top: 26px;
        }

        h2 .accent {
            color: var(--cobalt);
        }

        .lede {
            font-family: var(--font-body);
            font-weight: 300;
            font-size: 29px;
            line-height: 1.55;
            color: var(--muted);
            margin-top: 18px;
            max-width: 1500px;
        }

        .lede strong {
            font-weight: 600;
            color: var(--ink);
        }

        /* การ์ดมาตรฐาน: ขาว กรอบหมึก เงา offset */
        .card {
            background: var(--card);
            border: 2.5px solid var(--ink);
            box-shadow: 8px 8px 0 var(--ink);
            padding: 28px 32px;
        }

        .card.flat {
            box-shadow: 6px 6px 0 rgba(20, 32, 60, 0.18);
        }

        /* สีประจำโดเมน */
        .sw {
            display: inline-block;
            width: 22px;
            height: 22px;
            border: 2px solid var(--ink);
            vertical-align: -3px;
        }

        .sw.c {
            background: var(--cobalt);
        }

        .sw.a {
            background: var(--red);
        }

        .sw.p {
            background: var(--green);
        }

        .dom-c {
            color: var(--cobalt);
        }

        .dom-a {
            color: var(--red);
        }

        .dom-p {
            color: var(--green);
        }

        /* ตาราง */
        table.tbl {
            border-collapse: collapse;
            width: 100%;
            background: var(--card);
        }

        table.tbl th,
        table.tbl td {
            border: 2px solid var(--ink);
            padding: 14px 20px;
            font-family: var(--font-body);
            font-size: 24px;
            line-height: 1.45;
            color: var(--ink);
            text-align: left;
            vertical-align: top;
        }

        table.tbl th {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 24px;
            background: var(--ink);
            color: var(--paper);
        }

        /* ===========================================
   ANIMATIONS - trigger ผ่าน .visible บนสไลด์ active
   =========================================== */
        .reveal {
            opacity: 0;
            transform: translateY(28px);
            transition: opacity var(--duration-normal) var(--ease-out-expo),
                transform var(--duration-normal) var(--ease-out-expo);
        }

        .slide.visible .reveal {
            opacity: 1;
            transform: translateY(0);
        }

        .reveal.d1 {
            transition-delay: 0.1s;
        }

        .reveal.d2 {
            transition-delay: 0.22s;
        }

        .reveal.d3 {
            transition-delay: 0.34s;
        }

        .reveal.d4 {
            transition-delay: 0.46s;
        }

        .reveal.d5 {
            transition-delay: 0.58s;
        }

        .reveal.d6 {
            transition-delay: 0.7s;
        }

        .reveal-pop {
            opacity: 0;
            transform: scale(0.88);
            transition: opacity 0.5s var(--ease-out-expo), transform 0.5s var(--ease-out-expo);
        }

        .slide.visible .reveal-pop {
            opacity: 1;
            transform: scale(1);
        }

        /* ===========================================
   AI DEMO COMPONENTS
   =========================================== */
        .demo-grid {
            display: grid;
            grid-template-columns: 1fr 1.1fr;
            gap: 44px;
            margin-top: 30px;
            align-items: start;
        }

        .demo-input-label {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 23px;
            color: var(--ink);
            display: block;
            margin-bottom: 10px;
        }

        .demo-field {
            width: 100%;
            font-family: var(--font-body);
            font-size: 22px;
            line-height: 1.5;
            padding: 14px 18px;
            border: 2.5px solid var(--ink);
            background: var(--card);
            outline: none;
            color: var(--ink);
            resize: none;
        }

        .demo-field:focus {
            border-color: var(--cobalt);
            box-shadow: 4px 4px 0 rgba(31, 73, 199, 0.25);
        }

        select.demo-field {
            cursor: pointer;
        }

        .ai-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            background: var(--cobalt);
            color: #fff;
            border: 2.5px solid var(--ink);
            box-shadow: 6px 6px 0 var(--ink);
            padding: 16px 30px;
            min-height: 62px;
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 24px;
            cursor: pointer;
            transition: transform 0.15s, box-shadow 0.15s;
        }

        .ai-btn:hover {
            transform: translate(2px, 2px);
            box-shadow: 4px 4px 0 var(--ink);
        }

        .ai-btn:disabled {
            opacity: 0.55;
            cursor: not-allowed;
            transform: none;
        }

        .ai-btn svg {
            width: 24px;
            height: 24px;
            flex: none;
        }

        .ai-btn.secondary {
            background: var(--card);
            color: var(--ink);
        }

        .ai-output {
            background: var(--card);
            border: 2.5px solid var(--ink);
            box-shadow: 8px 8px 0 rgba(20, 32, 60, 0.18);
            padding: 26px 30px;
            overflow-y: auto;
            font-family: var(--font-body);
            font-size: 21px;
            line-height: 1.7;
            color: var(--ink);
        }

        .ai-output::-webkit-scrollbar {
            width: 8px;
        }

        .ai-output::-webkit-scrollbar-thumb {
            background: var(--cobalt);
        }

        .ai-output .placeholder {
            color: #9aa2b5;
            text-align: center;
            padding-top: 120px;
            font-size: 1.05em;
        }

        .ai-error {
            color: #c02428;
            font-weight: 600;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        .ai-spinner {
            display: inline-block;
            animation: spin 1s linear infinite;
        }

        /* ชิปตัวเลือกใน Demo เปรียบเทียบ */
        .change-chip {
            display: block;
            width: 100%;
            text-align: left;
            background: var(--card);
            border: 2.5px solid var(--ink);
            box-shadow: 5px 5px 0 rgba(20, 32, 60, 0.18);
            padding: 16px 22px;
            min-height: 58px;
            cursor: pointer;
            font-family: var(--font-body);
            font-size: 22px;
            color: var(--ink);
            transition: transform 0.15s, background 0.15s;
        }

        .change-chip:hover {
            transform: translate(2px, 2px);
        }

        .change-chip.selected {
            background: var(--cobalt);
            color: #fff;
        }

        .change-chip.selected small {
            color: rgba(255, 255, 255, 0.8);
        }

        .change-chip strong {
            font-family: var(--font-display);
            font-weight: 600;
        }

        .change-chip small {
            display: block;
            font-size: 18px;
            color: var(--muted);
            margin-top: 4px;
        }

        /* ปุ่มตัวเลือกข้อสอบ (Quiz Demo) */
        .quiz-opt {
            display: block;
            width: 100%;
            text-align: left;
            background: var(--paper);
            border: 2px solid var(--ink);
            padding: 13px 18px;
            min-height: 52px;
            cursor: pointer;
            font-family: var(--font-body);
            font-size: 0.95em;
            color: var(--ink);
            transition: background 0.15s;
        }

        .quiz-opt:hover {
            background: #e9edfb;
        }

        .quiz-opt.correct {
            background: #d9f2e6;
            border-color: var(--green);
            font-weight: 600;
        }

        .quiz-opt.wrong {
            background: #fbe3e4;
            border-color: var(--red);
        }

        .quiz-opt:disabled {
            cursor: default;
        }

        /* ===========================================
   ชุดควบคุมที่รู้ตำแหน่งเวที (DESIGN.md ส่วนที่ 8)
   โหมด gutter เมื่อขอบว่างข้างกว้างพอ ปุ่มย้ายออกนอกกระดาษสไลด์
   โหมด dock เมื่อไม่มีขอบว่าง ยุบเป็นแถบเดียวกลางขอบล่าง
   ห้ามใส่ transform ให้กล่องที่ครอบปุ่ม position:fixed ในโหมด gutter
   =========================================== */
        .progress-track {
            position: fixed;
            left: 0;
            right: 0;
            bottom: 0;
            height: 5px;
            background: rgba(20, 32, 60, 0.15);
            z-index: 1200;
        }

        .progress-fill {
            height: 100%;
            width: 0;
            background: var(--cobalt);
            transition: width 0.35s var(--ease);
        }

        .deck-chrome {
            position: fixed;
            z-index: 1200;
            left: 50%;
            bottom: var(--dock-bottom);
            transform: translateX(-50%);
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 10px;
            padding: 5px 10px;
            background: rgba(246, 244, 236, 0.94);
            border: 2px solid var(--ink);
            box-shadow: 3px 3px 0 rgba(20, 32, 60, 0.16);
            transition: opacity 0.35s ease, visibility 0.35s ease;
        }

        .deck-chrome.idle {
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }

        .chrome-div {
            flex: none;
            width: 2px;
            align-self: stretch;
            background: rgba(20, 32, 60, 0.18);
        }

        .nav-btns,
        .font-controls {
            position: static;
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 8px;
        }

        .nav-btn {
            width: var(--chrome-btn);
            height: var(--chrome-btn);
            min-width: 44px;
            min-height: 44px;
            border: 2px solid var(--ink);
            background: rgba(246, 244, 236, 0.95);
            color: var(--ink);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
            transition: background 0.15s, border-color 0.15s;
        }

        .nav-btn:hover {
            background: #fff;
            border-color: var(--cobalt);
        }

        .nav-btn:disabled {
            opacity: .35;
            cursor: not-allowed;
        }

        .nav-btn svg {
            width: 22px;
            height: 22px;
        }

        .nav-counter {
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            font-size: 15px;
            font-weight: 700;
            color: var(--ink);
            letter-spacing: .06em;
            min-width: 62px;
            text-align: center;
        }

        .font-controls .fs-label {
            font-family: var(--font-mono);
            font-size: 14px;
            font-weight: 700;
            color: var(--ink);
            letter-spacing: 0.04em;
        }

        .font-controls .fs-pct {
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            font-size: 14px;
            font-weight: 700;
            color: var(--ink);
            min-width: 62px;
            width: auto;
            padding: 0 10px;
            text-align: center;
        }

        /* ── โหมด gutter ── */
        body.chrome-gutter {
            --chrome-btn: 46px;
        }

        body.chrome-gutter .deck-chrome {
            left: auto;
            right: calc((var(--gutter-x) - var(--chrome-btn)) / 2);
            top: 0;
            bottom: 0;
            transform: none;
            flex-direction: column;
            justify-content: center;
            gap: 12px;
            padding: 0;
            background: none;
            border: none;
            box-shadow: none;
        }

        body.chrome-gutter .chrome-div {
            width: 100%;
            height: 2px;
            align-self: auto;
        }

        body.chrome-gutter .font-controls {
            flex-direction: column-reverse;
        }

        body.chrome-gutter .nav-btns {
            flex-direction: column;
        }

        body.chrome-gutter .font-controls .fs-pct {
            min-width: 0;
            width: var(--chrome-btn);
            padding: 0;
        }

        body.chrome-gutter .nav-counter {
            min-width: 0;
            width: var(--chrome-btn);
            font-size: 13px;
        }

        body.chrome-gutter .fab-settings {
            left: calc((var(--gutter-x) - 54px) / 2);
            top: calc(50% - 40px);
            bottom: auto;
        }

        body.chrome-gutter .fab-chat {
            right: auto;
            left: calc((var(--gutter-x) - 54px) / 2);
            top: calc(50% + 26px);
            bottom: auto;
        }

        /* หน้าต่างแชทเปิดข้างปุ่มของตัวเองเสมอ เมื่อปุ่มย้ายไปขอบว่างซ้าย */
        body.chrome-gutter .chat-panel {
            right: auto;
            left: calc(var(--gutter-x) + 16px);
            bottom: 24px;
        }

        /* ── คำใบ้คีย์ลัด แสดงครั้งเดียวต่อเครื่อง ── */
        .key-hint {
            position: fixed;
            left: 50%;
            bottom: 84px;
            transform: translateX(-50%);
            z-index: 1300;
            background: var(--ink);
            color: var(--paper);
            font-family: var(--font-body);
            font-size: 16px;
            letter-spacing: .02em;
            padding: 12px 22px;
            border: 2px solid var(--ink);
            box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
            opacity: 0;
            visibility: hidden;
            transition: opacity .4s ease, visibility .4s ease;
        }

        .key-hint.show {
            opacity: 1;
            visibility: visible;
        }

        .key-hint kbd {
            font-family: var(--font-mono);
            font-size: 14px;
            font-weight: 700;
            background: rgba(246, 244, 236, .17);
            border: 1px solid rgba(246, 244, 236, .32);
            padding: 2px 7px;
            margin: 0 2px;
        }

        /* ===========================================
   โหมดแก้ข้อความหน้างาน ชี้มุมบนซ้ายหรือกด E
   =========================================== */
        .edit-hotzone {
            position: fixed;
            left: 0;
            top: 0;
            width: 90px;
            height: 90px;
            z-index: 1150;
        }

        .edit-toggle {
            position: fixed;
            left: 16px;
            top: 16px;
            z-index: 1250;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            min-height: 44px;
            padding: 10px 16px;
            font-family: var(--font-body);
            font-size: 15px;
            font-weight: 600;
            color: var(--ink);
            background: rgba(246, 244, 236, 0.96);
            border: 2px solid var(--ink);
            cursor: pointer;
            opacity: 0;
            visibility: hidden;
            transition: opacity .25s ease, visibility .25s ease;
        }

        .edit-toggle svg {
            width: 18px;
            height: 18px;
        }

        .edit-hotzone:hover+.edit-toggle,
        .edit-toggle:hover,
        .edit-toggle:focus-visible,
        body.editing .edit-toggle {
            opacity: 1;
            visibility: visible;
        }

        body.editing .edit-toggle {
            background: var(--ink);
            color: var(--paper);
            border-color: var(--ink);
        }

        body.editing [data-editable] {
            outline: 2px dashed rgba(31, 73, 199, 0.5);
            outline-offset: 3px;
            cursor: text;
        }

        /* ===========================================
   หน้าสาธิต AI แบบโต้ตอบสด (DESIGN.md ส่วนที่ 11)
   กฎเหล็กสามข้อ: min-height:0 ทุกระดับ, flex 1 1 0 สำหรับกล่องที่ยอมหด,
   ห้ามใช้ความสูงพิกเซลตายตัวกับกล่องผลลัพธ์
   =========================================== */
        .slide-pad.demo-pad {
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* หัวเรื่องและคำโปรยไม่ยอมหด กล่องที่ยอมหดคือตารางสาธิตเท่านั้น */
        .slide-pad.demo-pad>* {
            flex: 0 0 auto;
        }

        /* ป้าย kicker ยังคงกว้างเท่าข้อความเหมือนหน้าอื่น ไม่ยืดเต็มแถว */
        .slide-pad.demo-pad>.kicker {
            align-self: flex-start;
        }

        .demo-grid.fill {
            flex: 1 1 auto;
            min-height: 0;
            align-items: stretch;
        }

        .demo-grid>* {
            min-width: 0;
            min-height: 0;
        }

        /* คอลัมน์ของหน้าสาธิตห้ามเลื่อนขึ้นตอนปรากฏ เพราะ transform จะไปเพิ่ม
           ขอบเขตการเลื่อนของกล่องแม่จนถูกนับเป็นเนื้อหาล้น ให้ค่อยๆ ปรากฏด้วยความทึบแสงอย่างเดียว */
        .slide-pad.demo-pad .reveal {
            transform: none;
        }

        .demo-col {
            display: flex;
            flex-direction: column;
            min-height: 0;
        }

        .demo-col>* {
            flex: 0 0 auto;
        }

        .demo-col>.flex-fill {
            flex: 1 1 auto;
            min-height: 0;
            display: flex;
            flex-direction: column;
        }

        .demo-col>.demo-field-wrap {
            flex: 0 0 auto;
        }

        .demo-col>.demo-field-wrap>.demo-field {
            height: 150px;
            min-height: 96px;
            overflow-y: auto;
        }

        /* กล่องผลลัพธ์ AI ยืดเต็มคอลัมน์ และเลื่อนอ่านในตัวเอง ไม่ดันเลย์เอาต์ */
        .demo-col>.ai-output {
            flex: 1 1 0;
            min-height: 0;
            overflow-y: auto;
        }

        /* ===========================================
   API SETTINGS: FAB + MODAL + SETUP OVERLAY
   =========================================== */
        .fab-settings {
            position: fixed;
            bottom: 84px;
            left: 20px;
            z-index: 8000;
            width: 54px;
            height: 54px;
            border-radius: 50%;
            background: var(--ink);
            color: #fff;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 14px rgba(20, 32, 60, 0.35);
            transition: transform 0.2s, background 0.2s;
        }

        .fab-settings:hover {
            transform: scale(1.08);
            background: var(--cobalt);
        }

        .fab-settings svg {
            width: 26px;
            height: 26px;
        }

        .api-modal-overlay {
            display: none;
            position: fixed;
            z-index: 9000;
            inset: 0;
            background: rgba(0, 0, 0, 0.65);
            backdrop-filter: blur(4px);
            opacity: 0;
            transition: opacity 0.3s ease;
            align-items: center;
            justify-content: center;
        }

        .api-modal-overlay.show {
            display: flex;
            opacity: 1;
        }

        .api-modal-box {
            background: #fff;
            border: 3px solid var(--ink);
            box-shadow: 10px 10px 0 var(--ink);
            padding: 2rem;
            width: 90%;
            max-width: 500px;
            max-height: 90vh;
            overflow-y: auto;
            transform: scale(0.94);
            transition: transform 0.3s ease;
            font-family: var(--font-body);
        }

        .api-modal-overlay.show .api-modal-box {
            transform: scale(1);
        }

        .setup-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(20, 32, 60, 0.92);
            z-index: 9999;
            align-items: center;
            justify-content: center;
        }

        .setup-overlay.show {
            display: flex;
        }

        .setup-card {
            background: #fff;
            border: 3px solid var(--ink);
            box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.4);
            padding: 2.5rem;
            max-width: 420px;
            width: 90%;
            text-align: center;
            font-family: var(--font-body);
        }

        .api-field {
            margin-bottom: 1rem;
        }

        .api-field label {
            display: block;
            font-size: 0.85rem;
            font-weight: 600;
            color: #374151;
            margin-bottom: 0.35rem;
        }

        .api-field input,
        .api-field select {
            width: 100%;
            border: 2px solid var(--ink);
            padding: 0.55rem 0.75rem;
            font-size: 0.95rem;
            outline: none;
            box-sizing: border-box;
            font-family: var(--font-body);
            background: #fff;
        }

        .api-field input:focus,
        .api-field select:focus {
            border-color: var(--cobalt);
            box-shadow: 3px 3px 0 rgba(31, 73, 199, 0.2);
        }

        .api-save-btn {
            width: 100%;
            background: var(--green);
            color: #fff;
            border: 2px solid var(--ink);
            box-shadow: 4px 4px 0 var(--ink);
            padding: 0.7rem;
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            margin-top: 0.5rem;
            font-family: var(--font-body);
        }

        .api-save-btn:hover {
            transform: translate(1px, 1px);
            box-shadow: 3px 3px 0 var(--ink);
        }

        .api-status {
            text-align: center;
            font-size: 0.85rem;
            color: var(--green);
            margin-top: 0.5rem;
            min-height: 1.2rem;
        }

        .preset-btn {
            background: #f1f5f9;
            border: 1.5px solid var(--ink);
            padding: 0.35rem 0.6rem;
            font-size: 0.8rem;
            cursor: pointer;
            text-align: left;
            font-family: var(--font-body);
            transition: background 0.15s;
        }

        .preset-btn:hover {
            background: #e2e8f0;
        }

        .setup-go-btn {
            background: var(--cobalt);
            color: #fff;
            border: 2px solid var(--ink);
            box-shadow: 4px 4px 0 var(--ink);
            padding: 0.75rem 1.5rem;
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            width: 100%;
            font-family: var(--font-body);
        }

        /* ===========================================
   AI Q&A CHATBOT มุมล่างขวา
   ใช้ callLLM() และ API key ชุดเดียวกับ AI Demo (API_PREFIX เดิม)
   =========================================== */
        .fab-chat {
            position: fixed;
            bottom: 84px;
            /* ยกให้พ้นแถบท้ายสไลด์และแถบควบคุมโหมด dock */
            right: 20px;
            z-index: 8000;
            width: 54px;
            height: 54px;
            border-radius: 50%;
            background: var(--cobalt);
            color: #fff;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 14px rgba(20, 32, 60, 0.35);
            transition: transform .2s, background .2s;
        }

        .fab-chat:hover {
            transform: scale(1.08);
            background: var(--cobalt-deep);
        }

        .fab-chat svg {
            width: 26px;
            height: 26px;
        }

        .chat-panel {
            position: fixed;
            bottom: 152px;
            right: 20px;
            z-index: 7999;
            width: min(400px, calc(100vw - 32px));
            height: min(560px, calc(100vh - 200px));
            background: var(--stone-card);
            border: 2px solid var(--ink);
            box-shadow: 8px 8px 0 rgba(20, 32, 60, 0.22);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            opacity: 0;
            transform: translateY(16px) scale(.97);
            pointer-events: none;
            transition: opacity .25s var(--ease), transform .25s var(--ease);
        }

        .chat-panel.show {
            opacity: 1;
            transform: translateY(0) scale(1);
            pointer-events: auto;
        }

        .chat-panel-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            padding: 16px 16px 13px;
            border-bottom: 2px solid var(--ink);
            background: var(--ink);
            color: var(--paper);
            flex-shrink: 0;
        }

        .chat-panel-title {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 17px;
        }

        .chat-panel-sub {
            font-family: var(--font-body);
            font-size: 12px;
            color: rgba(246, 244, 236, 0.72);
            margin-top: 3px;
        }

        .chat-panel-actions {
            display: flex;
            gap: 4px;
            align-items: center;
            flex-shrink: 0;
        }

        .chat-header-btn {
            background: none;
            border: none;
            color: rgba(246, 244, 236, 0.72);
            cursor: pointer;
            padding: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color .2s, background .2s;
        }

        .chat-header-btn:hover {
            color: var(--paper);
            background: rgba(255, 255, 255, .12);
        }

        .chat-header-btn svg {
            width: 17px;
            height: 17px;
        }

        .chat-panel-close {
            background: none;
            border: none;
            color: var(--paper);
            font-size: 22px;
            cursor: pointer;
            line-height: 1;
            padding: 2px 6px;
        }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            font-family: var(--font-body);
            font-size: 14.5px;
            line-height: 1.55;
        }

        .chat-msg {
            max-width: 88%;
            padding: 10px 13px;
            white-space: pre-wrap;
        }

        .chat-msg.bot {
            align-self: flex-start;
            background: var(--bronze-soft);
            color: var(--ink);
            border-left: 3px solid var(--cobalt);
        }

        .chat-msg.user {
            align-self: flex-end;
            background: var(--ink);
            color: var(--paper);
        }

        .chat-msg.error {
            align-self: flex-start;
            background: rgba(232, 85, 90, .14);
            color: var(--danger);
            border-left: 3px solid var(--red);
        }

        .chat-input-row {
            display: flex;
            gap: 8px;
            padding: 12px;
            border-top: 2px solid var(--ink);
            background: var(--stone-card);
            flex-shrink: 0;
        }

        .chat-input {
            flex: 1;
            resize: none;
            max-height: 90px;
            padding: 10px 12px;
            border: 2px solid var(--ink);
            font-family: var(--font-body);
            font-size: 14px;
            color: var(--ink);
            background: #fff;
            outline: none;
        }

        .chat-input:focus {
            border-color: var(--cobalt);
        }

        .chat-input:disabled {
            opacity: .6;
            cursor: not-allowed;
        }

        .chat-send-btn {
            width: 44px;
            height: 44px;
            border: 2px solid var(--ink);
            background: var(--cobalt);
            color: #fff;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: background .2s;
        }

        .chat-send-btn:hover {
            background: var(--cobalt-deep);
        }

        .chat-send-btn:disabled {
            opacity: .5;
            cursor: not-allowed;
        }

        .chat-send-btn svg {
            width: 18px;
            height: 18px;
        }

        /* ── Markdown ในบับเบิลบอท ── */
        .chat-msg.bot p {
            margin: 0 0 8px;
        }

        .chat-msg.bot p:last-child {
            margin-bottom: 0;
        }

        .chat-msg.bot ul,
        .chat-msg.bot ol {
            margin: 0 0 8px 20px;
        }

        .chat-msg.bot ul:last-child,
        .chat-msg.bot ol:last-child {
            margin-bottom: 0;
        }

        .chat-msg.bot li {
            margin-bottom: 4px;
        }

        .chat-msg.bot h4 {
            font-family: var(--font-display);
            font-size: 15px;
            font-weight: 600;
            margin: 2px 0 6px;
            color: var(--cobalt-deep);
        }

        .chat-msg.bot blockquote {
            border-left: 3px solid var(--bronze-line);
            padding-left: 10px;
            color: var(--ink-soft);
            margin: 0 0 8px;
            font-style: italic;
        }

        .chat-msg.bot hr {
            border: none;
            border-top: 1px solid var(--stone-line);
            margin: 10px 0;
        }

        .chat-msg.bot a {
            color: var(--cobalt-deep);
            text-decoration: underline;
            text-underline-offset: 2px;
        }

        .chat-msg.bot .chat-code-inline {
            background: rgba(20, 32, 60, .08);
            padding: 1px 5px;
            font-family: var(--font-mono);
            font-size: 13px;
        }

        .chat-msg.bot .chat-code-block {
            background: var(--ink);
            color: var(--paper);
            padding: 10px 12px;
            overflow-x: auto;
            font-size: 12.5px;
            margin: 0 0 8px;
        }

        .chat-msg.bot .chat-code-block code {
            font-family: var(--font-mono);
            white-space: pre;
        }

        /* ── เคอร์เซอร์ระหว่างสตรีม และจุดกำลังพิมพ์ ── */
        .stream-cursor {
            display: inline-block;
            width: 2px;
            height: 1em;
            background: var(--ink);
            margin-left: 2px;
            vertical-align: text-bottom;
            animation: chatBlink 1s step-start infinite;
        }

        @keyframes chatBlink {
            50% {
                opacity: 0;
            }
        }

        .typing-dots {
            display: inline-flex;
            gap: 4px;
            padding: 3px 2px;
        }

        .typing-dots span {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--ink-faint);
            animation: chatTypingBounce 1.2s infinite ease-in-out;
        }

        .typing-dots span:nth-child(2) {
            animation-delay: .15s;
        }

        .typing-dots span:nth-child(3) {
            animation-delay: .3s;
        }

        @keyframes chatTypingBounce {

            0%,
            60%,
            100% {
                transform: translateY(0);
                opacity: .5;
            }

            30% {
                transform: translateY(-4px);
                opacity: 1;
            }
        }

        /* ── ปุ่มคัดลอก ถามใหม่ และหมายเหตุเมื่อหยุด ── */
        .chat-msg-actions {
            display: flex;
            gap: 6px;
            margin-top: 8px;
        }

        .chat-copy-btn {
            background: none;
            border: none;
            cursor: pointer;
            color: var(--ink-faint);
            font-family: var(--font-body);
            font-size: 11px;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px 6px;
            transition: color .2s, background .2s;
        }

        .chat-copy-btn:hover {
            color: var(--cobalt-deep);
            background: var(--bronze-soft);
        }

        .chat-copy-btn svg {
            width: 12px;
            height: 12px;
        }

        .chat-regenerate-row {
            display: flex;
            justify-content: flex-start;
            align-self: flex-start;
        }

        .chat-regenerate-btn {
            background: none;
            border: 1.5px solid var(--stone-line);
            color: var(--ink-soft);
            font-family: var(--font-body);
            font-size: 12px;
            padding: 5px 12px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            transition: border-color .2s, color .2s;
        }

        .chat-regenerate-btn:hover {
            border-color: var(--bronze-line);
            color: var(--cobalt-deep);
        }

        .chat-regenerate-btn svg {
            width: 13px;
            height: 13px;
        }

        .chat-stopped-note {
            font-size: 11px;
            color: var(--ink-faint);
            margin-top: 6px;
            font-style: italic;
        }

        /* ── ชิปคำถามชวนเริ่ม ── */
        .chat-chips {
            display: flex;
            flex-direction: column;
            gap: 6px;
            align-self: flex-start;
            max-width: 92%;
        }

        .chat-chip {
            text-align: left;
            background: var(--paper);
            border: 1.5px solid var(--stone-line);
            color: var(--ink);
            font-family: var(--font-body);
            font-size: 13px;
            padding: 9px 13px;
            cursor: pointer;
            transition: border-color .2s, background .2s;
        }

        .chat-chip:hover {
            border-color: var(--bronze-line);
            background: var(--bronze-soft);
        }

        @media (max-width: 480px) {
            .chat-panel {
                right: 16px;
                bottom: 148px;
            }

            .fab-chat {
                right: 16px;
                bottom: 80px;
            }
        }

        /* ═══════════════════════════════════════════════════════════════
       UNIFIED SIDE CHROME v3  ชุดควบคุมขวาและปุ่มลอยซ้าย
       บล็อกนี้อยู่ท้ายสุดของ style จึงชนะทุกกฎก่อนหน้า
       ยกเว้นกฎในโหมดพิมพ์ซึ่งใช้ !important
       ═══════════════════════════════════════════════════════════════ */
        :root {
            --chrome-btn: 42px;
            --fab-size: 52px;
        }

        body.chrome-gutter {
            --chrome-btn: 46px;
        }

        /* ── ตัวนับหน้าในแถบข้าง ถูกยกเลิก เลขหน้าอยู่ที่แถบล่างของสไลด์แล้ว ── */
        .nav-counter {
            display: none !important;
        }

        /* ── กล่องชุดควบคุม โหมด dock ── */
        .deck-chrome {
            gap: 10px;
            padding: 5px 10px;
            background: rgba(246, 244, 236, 0.94);
            border: 2px solid var(--ink);
            border-radius: 0;
            box-shadow: 3px 3px 0 rgba(20, 32, 60, 0.16);
        }

        .nav-btns,
        .font-controls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .chrome-div {
            background: rgba(20, 32, 60, 0.20);
        }

        /* ── ปุ่มในชุดควบคุม เหลี่ยมตามไวยากรณ์หมึกหนา ── */
        .nav-btn {
            width: var(--chrome-btn);
            height: var(--chrome-btn);
            min-width: 44px;
            min-height: 44px;
            padding: 0;
            border: 2px solid var(--ink);
            border-radius: 0;
            background: rgba(246, 244, 236, 0.95);
            color: var(--ink);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            text-decoration: none;
            transition: background 0.15s ease, border-color 0.15s ease;
        }

        .nav-btn:hover {
            background: #fff;
            border-color: var(--cobalt);
        }

        .nav-btn:disabled {
            opacity: .35;
            cursor: not-allowed;
        }

        .nav-btn svg {
            width: 22px;
            height: 22px;
        }

        /* ── ตัวเลขเปอร์เซ็นต์ขนาดอักษร เป็นปุ่มกดรีเซ็ตได้ ── */
        .font-controls .fs-pct {
            font-family: var(--font-mono);
            font-variant-numeric: tabular-nums;
            font-size: 14px;
            font-weight: 700;
            letter-spacing: 0;
            color: var(--ink);
            width: auto;
            min-width: 58px;
            padding: 0 8px;
            text-align: center;
        }

        /* ── โหมด gutter แถบตั้งด้านขวา ── */
        body.chrome-gutter .deck-chrome {
            left: auto;
            right: calc((var(--gutter-x) - var(--chrome-btn)) / 2);
            top: 0;
            bottom: 0;
            transform: none;
            flex-direction: column;
            justify-content: center;
            gap: 12px;
            padding: 0;
            background: none;
            border: none;
            border-radius: 0;
            box-shadow: none;
        }

        body.chrome-gutter .chrome-div {
            width: 100%;
            height: 2px;
            align-self: auto;
        }

        body.chrome-gutter .font-controls {
            flex-direction: column-reverse;
        }

        body.chrome-gutter .nav-btns {
            flex-direction: column;
        }

        body.chrome-gutter .font-controls .fs-pct {
            width: var(--chrome-btn);
            min-width: 0;
            padding: 0;
            font-size: 13px;
        }

        /* ── ปุ่มลอยด้านซ้าย ทรงกลม ── */
        .fab-settings,
        .fab-chat {
            position: fixed;
            z-index: 8000;
            width: var(--fab-size);
            height: var(--fab-size);
            padding: 0;
            border-radius: 50%;
            border: 2.5px solid var(--ink);
            box-shadow: 3px 3px 0 rgba(20, 32, 60, 0.28);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 0;
            transform: none;
            transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
        }

        .fab-settings {
            left: 24px;
            right: auto;
            bottom: 24px;
            top: auto;
            background: var(--ink);
            color: var(--paper);
        }

        .fab-chat {
            left: auto;
            right: 24px;
            bottom: 24px;
            top: auto;
            background: var(--cobalt);
            color: #fff;
        }

        .fab-settings:hover,
        .fab-chat:hover {
            transform: translate(-1px, -1px);
            box-shadow: 5px 5px 0 rgba(20, 32, 60, 0.28);
            background: var(--cobalt-deep);
        }

        .fab-settings:focus-visible,
        .fab-chat:focus-visible {
            outline: 3px solid var(--cobalt);
            outline-offset: 3px;
        }

        .fab-settings svg,
        .fab-chat svg {
            width: 24px;
            height: 24px;
            display: block;
        }

        /* ── ปุ่มลอยในโหมด gutter เรียงตั้งกลางแถบซ้าย ── */
        body.chrome-gutter .fab-settings {
            left: calc((var(--gutter-x) - var(--fab-size)) / 2);
            right: auto;
            bottom: auto;
            top: calc(50% - var(--fab-size) - 6px);
            transform: none;
        }

        body.chrome-gutter .fab-chat {
            left: calc((var(--gutter-x) - var(--fab-size)) / 2);
            right: auto;
            bottom: auto;
            top: calc(50% + 6px);
            transform: none;
        }

        body.chrome-gutter .fab-settings:hover,
        body.chrome-gutter .fab-chat:hover {
            transform: translate(-1px, -1px);
        }


        /* ═══════════════════════════════════════════════════════════════
       UNIFIED API SETTINGS MODAL v3
       ผิวเดียวกันทั้ง 4 เด็ค กรอบหมึกหนา เงาทึบ ไม่มีมุมโค้ง
       แตะเฉพาะเปลือกและ CSS ไม่แตะ id ฟังก์ชัน หรือ API_PREFIX
       ═══════════════════════════════════════════════════════════════ */
        .api-modal-overlay {
            background: rgba(20, 32, 60, 0.68);
            backdrop-filter: blur(4px);
        }

        .api-modal-box {
            background: #fff;
            border: 3px solid var(--ink);
            border-radius: 0;
            box-shadow: 10px 10px 0 var(--ink);
            padding: 2rem;
            width: 90%;
            max-width: 500px;
            max-height: 90vh;
            overflow-y: auto;
            font-family: var(--font-body);
        }

        .api-modal-box h2 {
            font-family: var(--font-body);
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--ink);
            margin: 0;
        }

        .api-modal-close {
            background: none;
            border: none;
            border-radius: 0;
            font-size: 1.5rem;
            line-height: 1;
            color: var(--muted);
            cursor: pointer;
            width: auto;
            height: auto;
            padding: 0 4px;
        }

        .api-modal-close:hover {
            color: var(--ink);
        }

        .api-field {
            margin-bottom: 1rem;
        }

        .api-field label {
            display: block;
            font-size: 0.85rem;
            font-weight: 600;
            color: #374151;
            margin-bottom: 0.35rem;
        }

        .api-field input,
        .api-field select {
            width: 100%;
            border: 2px solid var(--ink);
            border-radius: 0;
            padding: 0.55rem 0.75rem;
            font-size: 0.95rem;
            outline: none;
            box-sizing: border-box;
            font-family: var(--font-body);
            background: #fff;
            color: var(--ink);
            box-shadow: none;
        }

        .api-field input:focus,
        .api-field select:focus {
            border-color: var(--cobalt);
            box-shadow: 3px 3px 0 rgba(31, 73, 199, 0.20);
        }

        .api-save-btn {
            width: 100%;
            background: var(--green-deep);
            color: #fff;
            border: 2px solid var(--ink);
            border-radius: 0;
            box-shadow: 4px 4px 0 var(--ink);
            padding: 0.7rem;
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            margin-top: 0.5rem;
            font-family: var(--font-body);
            transition: transform 0.15s ease, box-shadow 0.15s ease;
        }

        .api-save-btn:hover {
            background: var(--green-deep);
            transform: translate(1px, 1px);
            box-shadow: 3px 3px 0 var(--ink);
        }

        .api-status {
            text-align: center;
            font-size: 0.85rem;
            color: var(--green-deep);
            margin-top: 0.5rem;
            min-height: 1.2rem;
        }

        .preset-btn {
            background: #eef1f6;
            border: 1.5px solid var(--ink);
            border-radius: 0;
            padding: 0.35rem 0.6rem;
            font-size: 0.8rem;
            cursor: pointer;
            text-align: left;
            font-family: var(--font-body);
            color: var(--ink);
            transition: background 0.15s ease;
        }

        .preset-btn:hover {
            background: #dde3ec;
        }

        /* ── หน้าต่างชวนตั้งค่าครั้งแรก มีเฉพาะบางเด็ค ── */
        .setup-overlay {
            background: rgba(20, 32, 60, 0.92);
        }

        .setup-card {
            background: #fff;
            border: 3px solid var(--ink);
            border-radius: 0;
            box-shadow: 10px 10px 0 rgba(20, 32, 60, 0.35);
            padding: 2.5rem;
            max-width: 420px;
            width: 90%;
            text-align: center;
            font-family: var(--font-body);
        }

        .setup-card h2 {
            font-family: var(--font-body);
            font-size: 1.2rem;
            font-weight: 700;
            color: var(--ink);
        }

        .setup-card p {
            color: var(--muted);
        }

        .setup-icon {
            color: var(--cobalt);
        }

        .setup-btn,
        .setup-go-btn {
            background: var(--cobalt);
            color: #fff;
            border: 2px solid var(--ink);
            border-radius: 0;
            box-shadow: 4px 4px 0 var(--ink);
            padding: 0.75rem 1.5rem;
            font-size: 1rem;
            font-weight: 700;
            cursor: pointer;
            width: 100%;
            font-family: var(--font-body);
        }



        /* ===========================================
       ผู้ช่วยถาม-ตอบประจำเด็ค สเปกกลาง (DESIGN.md v2.2 ส่วนที่ 12)
       บล็อกนี้เหมือนกันทุกตัวอักษรในทุกชุดสไลด์ของคลัง
       วางไว้ท้ายสุดของบล็อกสไตล์เสมอ เพื่อเขียนทับกฎเดิมของแต่ละชุดด้วยลำดับที่มาทีหลัง
       ใช้เฉพาะโทเคนที่มีครบทุกชุด จึงย้ายข้ามเด็คได้โดยไม่ต้องแก้อะไร
       =========================================== */

        /* ── ปุ่มแชตตรึงมุมล่างขวาเสมอ ──
       เดิมโหมด gutter ย้ายปุ่มลอยทั้งสองไปเรียงกลางขอบว่างฝั่งซ้าย
       แต่หน้าต่างแชตยึดมุมล่างขวา ปุ่มกับหน้าต่างจึงแยกกันคนละฝั่งจอ
       จึงตรึงเฉพาะปุ่มแชตไว้ที่เดิม ส่วนปุ่มฟันเฟืองยังย้ายไปซ้ายตาม DESIGN.md
       และถูกจัดกึ่งกลางแนวตั้งใหม่ เพราะไม่มีปุ่มแชตมาต่อท้ายให้เว้นที่อีกแล้ว */
        body.chrome-gutter .fab-chat {
            left: auto;
            right: calc(var(--gutter-x) + 24px);
            top: auto;
            bottom: 24px;
            transform: none;
        }

        body.chrome-gutter .fab-chat:hover {
            transform: translate(-1px, -1px);
        }

        body.chrome-gutter .fab-settings {
            top: calc(50% - (var(--fab-size) / 2));
        }

        /* ── ตัวหน้าต่าง ── */
        .chat-panel {
            position: fixed;
            left: auto;
            top: auto;
            right: calc(var(--gutter-x) + 24px);
            bottom: 88px;
            /* ขอบขวาวัดจากขอบกระดาษสไลด์ ไม่ใช่ขอบจอ ในโหมด dock ค่า --gutter-x เป็น 0
         จึงเท่ากับ 24px ตามปกติ ส่วนโหมด gutter จะถอยเข้ามาให้พ้นคอลัมน์ชุดควบคุม
         ที่ไปเรียงอยู่ในขอบว่างฝั่งขวา ปุ่มแชตถอยตามด้วยระยะเดียวกัน จึงยังอยู่ติดกันเสมอ
         ระยะล่าง 88 = 24 ขอบล่าง บวก 52 ความสูงปุ่มลอย บวก 12 ช่องไฟ */
            z-index: 7999;
            width: min(440px, calc(100vw - 48px));
            height: min(620px, calc(100vh - 112px));
            background: var(--stone-card);
            border: 2px solid var(--ink);
            border-radius: 0;
            box-shadow: 8px 8px 0 rgba(20, 32, 60, 0.22);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            opacity: 0;
            transform: translateY(16px) scale(.97);
            pointer-events: none;
            transition: opacity .25s var(--ease), transform .25s var(--ease);
        }

        body.chrome-gutter .chat-panel {
            left: auto;
            right: calc(var(--gutter-x) + 24px);
            bottom: 88px;
        }

        .chat-panel.show {
            opacity: 1;
            transform: translateY(0) scale(1);
            pointer-events: auto;
        }

        /* ── แถบหัวหน้าต่าง พื้นหมึก ตัวอักษรสีกระดาษ ── */
        .chat-panel-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 10px;
            padding: 16px 16px 13px;
            border-bottom: 2px solid var(--ink);
            background: var(--ink);
            color: var(--paper);
            flex-shrink: 0;
        }

        .chat-panel-title {
            font-family: var(--font-display);
            font-weight: 600;
            font-size: 17px;
            line-height: 1.3;
            color: var(--paper);
        }

        /* สองกฎนี้คือจุดที่เคยพลาด เดิมสองชุดใช้ var(--stone-line) ซึ่งเป็นหมึกโปร่งแสง
       วางบนพื้นหมึกจึงกลายเป็นล่องหน ต้องใช้สีกระดาษโปร่งแสงเท่านั้น */
        .chat-panel-sub {
            font-family: var(--font-body);
            font-size: 12px;
            color: rgba(246, 244, 236, 0.72);
            margin-top: 3px;
        }

        .chat-header-btn {
            background: none;
            border: none;
            color: rgba(246, 244, 236, 0.72);
            cursor: pointer;
            padding: 5px;
            border-radius: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color .2s, background .2s;
        }

        .chat-header-btn:hover {
            color: var(--paper);
            background: rgba(246, 244, 236, .14);
        }

        .chat-header-btn svg {
            width: 17px;
            height: 17px;
        }

        .chat-panel-actions {
            display: flex;
            gap: 4px;
            align-items: center;
            flex-shrink: 0;
        }

        .chat-panel-close {
            background: none;
            border: none;
            color: var(--paper);
            font-size: 22px;
            line-height: 1;
            cursor: pointer;
            padding: 2px 6px;
            border-radius: 0;
        }

        .chat-panel-close:hover {
            background: rgba(246, 244, 236, .14);
        }

        /* ── พื้นที่ข้อความ ── */
        .chat-messages {
            flex: 1;
            min-height: 0;
            overflow-y: auto;
            padding: 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            font-family: var(--font-body);
            font-size: 14.5px;
            line-height: 1.55;
        }

        .chat-msg {
            max-width: 88%;
            padding: 10px 13px;
            border-radius: 0;
            white-space: pre-wrap;
        }

        .chat-msg.bot {
            align-self: flex-start;
            background: rgba(31, 73, 199, 0.10);
            color: var(--ink);
            border-left: 3px solid var(--cobalt);
        }

        .chat-msg.user {
            align-self: flex-end;
            background: var(--ink);
            color: var(--paper);
            border-left: none;
        }

        .chat-msg.error {
            align-self: flex-start;
            background: rgba(232, 85, 90, .14);
            color: var(--danger);
            border-left: 3px solid #E8555A;
            border-bottom-left-radius: 0;
        }

        /* ── ชิปคำถามชวนเริ่ม ── */
        .chat-chips {
            display: flex;
            flex-direction: column;
            gap: 6px;
            align-self: flex-start;
            max-width: 92%;
        }

        .chat-chip {
            text-align: left;
            background: var(--paper);
            border: 1.5px solid var(--stone-line);
            border-radius: 0;
            color: var(--ink);
            font-family: var(--font-body);
            font-size: 13px;
            padding: 9px 13px;
            cursor: pointer;
            transition: border-color .2s, background .2s;
        }

        .chat-chip:hover {
            border-color: var(--cobalt);
            background: rgba(31, 73, 199, 0.10);
        }

        /* ── ปุ่มคัดลอกและถามใหม่ ── */
        .chat-copy-btn,
        .chat-regenerate-btn {
            border-radius: 0;
            font-family: var(--font-body);
        }

        .chat-regenerate-btn {
            border: 1.5px solid var(--stone-line);
        }

        .chat-regenerate-btn:hover {
            border-color: var(--cobalt);
            color: var(--cobalt-deep);
        }

        /* ── แถวช่องพิมพ์ ── */
        .chat-input-row {
            display: flex;
            gap: 8px;
            padding: 12px;
            border-top: 2px solid var(--ink);
            background: var(--stone-card);
            flex-shrink: 0;
        }

        .chat-input {
            flex: 1;
            resize: none;
            max-height: 90px;
            padding: 10px 12px;
            border: 2px solid var(--ink);
            border-radius: 0;
            font-family: var(--font-body);
            font-size: 14px;
            color: var(--ink);
            background: #fff;
            outline: none;
        }

        .chat-input:focus {
            border-color: var(--cobalt);
            box-shadow: 3px 3px 0 rgba(31, 73, 199, 0.20);
        }

        .chat-send-btn {
            width: 44px;
            height: 44px;
            border: 2px solid var(--ink);
            border-radius: 0;
            background: var(--cobalt);
            color: #fff;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: background .2s;
        }

        .chat-send-btn:hover {
            background: var(--cobalt-deep);
        }

        .chat-send-btn:disabled {
            opacity: .5;
            cursor: not-allowed;
        }

        /* ── จอแคบ ── */
        @media (max-width: 560px) {

            .chat-panel,
            body.chrome-gutter .chat-panel {
                right: 12px;
                bottom: 80px;
                width: calc(100vw - 24px);
                height: min(620px, calc(100vh - 104px));
            }

            body.chrome-gutter .fab-chat {
                right: 12px;
                bottom: 12px;
            }
        }
    
        /* ===========================================
   แถบเลือกขอบเขตของผู้ช่วยถามตอบ (context scope)
   ใช้มุมฉากและโทเคนของธีมตามปรัชญา Taxonomy Grid
   ใช้เฉพาะโทเคนที่มีครบทุกชุดสไลด์ จึงคัดลอกข้ามเด็คได้
   =========================================== */
        .chat-ctx-row {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-wrap: wrap;
            padding: 10px 16px;
            background: var(--stone-card);
            border-bottom: 1.5px solid var(--stone-line);
            flex-shrink: 0;
        }

        .chat-ctx-btn {
            font-family: var(--font-body);
            font-size: 12.5px;
            font-weight: 600;
            line-height: 1.2;
            padding: 6px 12px;
            border: 1.5px solid var(--bronze-line);
            border-radius: 0;
            background: transparent;
            color: var(--ink-soft);
            cursor: pointer;
            transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
        }

        .chat-ctx-btn:hover {
            background: var(--bronze-soft);
            color: var(--bronze-deep);
        }

        .chat-ctx-btn.on {
            background: var(--bronze);
            border-color: var(--bronze);
            color: var(--paper);
        }

        .chat-ctx-btn:focus-visible {
            outline: 2px solid var(--bronze-deep);
            outline-offset: 2px;
        }

        .chat-ctx-here {
            font-family: var(--font-mono);
            font-size: 11.5px;
            color: var(--ink-faint);
            letter-spacing: 0.02em;
            flex: 1 1 100%;
        }

    