
        .fab-home {
            /* ลบ touch-action: none ออกเพื่อให้คลิกได้ปกติ */
            cursor: pointer;
            user-select: none;
            position: fixed;
            z-index: 2200;
            /* เพิ่ม pointer-events เพื่อบังคับให้รับการกดแน่นอน */
            display: flex !important;
            align-items: center;
            justify-content: center;
            top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
            left: 50% !important;
            right: auto !important;
            bottom: auto !important;
            min-height: 38px;
            border-radius: 999px;
            touch-action: none;
            opacity: 0;
            pointer-events: none !important; 
            transform: translate(-50%, -130%) !important;
        }
        .fab-home.show {
            opacity: 1;
            pointer-events: auto !important;
            transform: translate(-50%, 0) !important;
        }
        .fab-home.show:hover {
            transform: translate(-50%, 0) !important;
        }
        .fab-home.is-dragged,
        .fab-home.is-dragged.show,
        .fab-home.is-dragged.show:hover {
            transform: none !important;
        }
        body.home-fab-dragging .app-iframe {
            pointer-events: none !important;
        }
        .portal-scroll-down-btn {
            position: fixed;
            right: calc(env(safe-area-inset-right, 0px) + 14px);
            bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
            width: 46px;
            height: 46px;
            border: 0;
            border-radius: 50%;
            display: none;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #22d3ee, #0ea5e9);
            color: #fff;
            box-shadow: 0 14px 32px rgba(14, 165, 233, .35);
            z-index: 2185;
            opacity: 0;
            pointer-events: none;
            transform: translateY(16px);
            transition: opacity .18s ease, transform .18s ease;
        }
        .portal-scroll-down-btn i {
            font-size: 1.25rem;
            line-height: 1;
        }
        .portal-scroll-down-btn.show {
            display: flex;
            opacity: 1;
            pointer-events: auto;
            transform: none;
        }
        body.login-mode .portal-scroll-down-btn,
        body.viewer-mode .portal-scroll-down-btn {
            display: none !important;
        }
        @media (max-width: 1024px) {
            .fab-home {
                width: 42px !important;
                height: 42px !important;
                min-width: 42px !important;
                min-height: 42px !important;
                padding: 0 !important;
                gap: 0 !important;
                border-radius: 50% !important;
                font-size: 1rem !important;
            }
            .fab-home .fab-label,
            .fab-home .bi-arrow-left {
                display: none !important;
            }
            .fab-home .bi-house-door-fill {
                margin: 0 !important;
                font-size: 1.18rem;
            }
        }
        @media (max-width: 767px) {
            .fab-home:not(.is-dragged) {
                top: auto !important;
                right: auto !important;
                bottom: calc(env(safe-area-inset-bottom, 0px) + 14px) !important;
                left: calc(env(safe-area-inset-left, 0px) + 14px) !important;
                transform: translateY(140%) !important;
            }
            .fab-home.show:not(.is-dragged),
            .fab-home.show:not(.is-dragged):hover {
                transform: none !important;
            }
        }
        #viewer-screen.active {
            padding-top: 58px;
        }
        @media (max-width: 767px) {
            #viewer-screen,
            #viewer-screen.active {
                padding-top: 8px !important;
                padding-top: max(env(safe-area-inset-top, 0px), 8px) !important;
                padding-left: 0 !important;
                padding-right: 0 !important;
            }
            #viewer-screen .app-iframe {
                border-radius: 0;
            }
        }
        .portal-home-ai-widget {
            position: fixed;
            left: calc(env(safe-area-inset-left, 0px) + 18px);
            bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
            z-index: 2190;
            font-family: var(--portal-font);
        }
        .portal-home-ai-sidebar-panel {
            position: sticky !important;
            left: auto !important;
            right: auto !important;
            top: auto !important;
            bottom: 10px !important;
            width: 100%;
            margin-top: auto;
            padding-top: 10px;
            z-index: 18;
        }
        body.portal-home-ai-active .portal-dashboard-v2 .portal-sidebar,
        body.portal-home-ai-active .portal-dashboard-v2 .portal-nav-rail {
            position: relative;
            z-index: 50070 !important;
            overflow: visible !important;
        }
        body.portal-home-ai-active .portal-dashboard-v2 .portal-shell {
            overflow: visible !important;
        }
        body.portal-home-ai-active .portal-home-ai-sidebar-panel,
        .portal-home-ai-sidebar-panel.is-open,
        .portal-home-ai-sidebar-panel.dial-open {
            z-index: 50080 !important;
        }
        .portal-home-ai-sidebar-panel::before {
            content: "";
            display: block;
            height: 1px;
            margin-bottom: 10px;
            background: linear-gradient(90deg, transparent, rgba(125, 211, 252, .35), transparent);
        }
        .portal-home-ai-fab-text,
        .portal-home-ai-fab-caret {
            display: none;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab {
            width: 100%;
            height: 58px;
            border-radius: 16px;
            padding: 8px 10px;
            justify-content: flex-start;
            gap: 10px;
            cursor: pointer;
            overflow: hidden;
            touch-action: manipulation;
            box-shadow: 0 12px 28px rgba(2, 6, 23, .30), inset 0 1px 0 rgba(255,255,255,.20);
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab::before {
            inset: -24px;
            border-radius: 22px;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab::after {
            inset: -20px;
            border-radius: 22px;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab-icon {
            width: 42px;
            height: 42px;
            flex: 0 0 auto;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab-text {
            position: relative;
            z-index: 3;
            min-width: 0;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            line-height: 1.15;
            color: #fff;
            text-align: left;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab-text b {
            font-size: .9rem;
            font-weight: 900;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab-text small {
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            color: rgba(224, 242, 254, .82);
            font-size: .66rem;
            font-weight: 800;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-fab-caret {
            position: relative;
            z-index: 3;
            display: inline-flex;
            margin-left: auto;
            color: rgba(224, 242, 254, .92);
            transition: transform .18s ease;
        }
        .portal-home-ai-sidebar-panel.dial-open .portal-home-ai-fab-caret,
        .portal-home-ai-sidebar-panel.is-open .portal-home-ai-fab-caret {
            transform: rotate(180deg);
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-dial {
            left: 0;
            right: 0;
            width: 100%;
            max-height: min(46vh, 320px);
            padding: 0 0 8px;
        }
        .portal-home-ai-sidebar-panel.dial-up .portal-home-ai-dial {
            bottom: calc(100% + 8px);
        }
        .portal-home-ai-sidebar-panel.dial-down .portal-home-ai-dial {
            top: auto;
            bottom: calc(100% + 8px);
            flex-direction: column-reverse;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-dial-item {
            width: 100%;
            max-width: none;
            justify-content: flex-start;
            border-radius: 14px;
        }
        .portal-home-ai-sidebar-panel .portal-home-ai-panel {
            position: fixed;
            left: max(18px, env(safe-area-inset-left, 0px));
            bottom: max(92px, calc(env(safe-area-inset-bottom, 0px) + 92px));
            width: min(430px, calc(100vw - 36px));
            height: min(590px, calc(100vh - 132px));
            transform-origin: left bottom;
            z-index: 50090;
        }
        .portal-dashboard-v2 .portal-shell.sidebar-collapsed .portal-home-ai-sidebar-panel {
            display: none;
        }
        @media (max-width: 1024px) {
            .portal-home-ai-sidebar-panel {
                position: fixed !important;
                left: calc(env(safe-area-inset-left, 0px) + 18px) !important;
                right: auto !important;
                top: auto !important;
                bottom: calc(env(safe-area-inset-bottom, 0px) + 18px) !important;
                width: auto !important;
                margin: 0 !important;
                padding: 0 !important;
                z-index: 2190;
            }
            .portal-home-ai-sidebar-panel::before {
                display: none;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab {
                width: 60px;
                height: 60px;
                border-radius: 50%;
                padding: 0;
                justify-content: center;
                gap: 0;
                cursor: grab;
                overflow: visible;
                touch-action: none;
                box-shadow: 0 14px 36px rgba(2,6,23,.38), 0 0 0 4px rgba(99,102,241,.14);
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab::before {
                inset: -3px;
                border-radius: 50%;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab::after {
                inset: -7px;
                border-radius: 50%;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab-icon {
                width: 50px;
                height: 50px;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab-text,
            .portal-home-ai-sidebar-panel .portal-home-ai-fab-caret {
                display: none;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-dial {
                width: auto;
                left: 0;
                right: auto;
                max-height: min(60vh, 420px);
                padding: 4px;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-dial-item {
                width: auto;
                max-width: min(64vw, 240px);
                border-radius: 999px;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-panel {
                position: fixed;
                left: calc(env(safe-area-inset-left, 0px) + 12px);
                right: calc(env(safe-area-inset-right, 0px) + 12px);
                top: calc(env(safe-area-inset-top, 0px) + 12px);
                bottom: auto;
                width: auto;
                height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
                height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
                max-height: none;
                transform-origin: center top;
            }
            .portal-dashboard-v2 .portal-shell.sidebar-collapsed .portal-home-ai-sidebar-panel {
                display: block;
            }
        }
        body.portal-home-ai-fullscreen-open {
            overflow: hidden;
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-widget {
            position: fixed !important;
            inset: 0 !important;
            left: 0 !important;
            right: 0 !important;
            top: 0 !important;
            bottom: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            height: 100dvh !important;
            z-index: 999999 !important;
            pointer-events: auto !important;
            display: flex !important;
            align-items: stretch !important;
            justify-content: center !important;
            padding: 18px !important;
            background: rgba(2,6,23,.55) !important;
            -webkit-backdrop-filter: blur(3px);
            backdrop-filter: blur(3px);
            box-sizing: border-box !important;
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-fab {
            display: none !important;
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-panel {
            position: relative !important;
            inset: auto !important;
            left: auto !important;
            right: auto !important;
            top: auto !important;
            bottom: auto !important;
            width: min(1280px, calc(100vw - 36px)) !important;
            height: calc(100vh - 36px) !important;
            height: calc(100dvh - 36px) !important;
            min-height: 0 !important;
            max-height: none !important;
            display: flex !important;
            flex-direction: column !important;
            opacity: 1 !important;
            visibility: visible !important;
            transform: none !important;
            pointer-events: auto !important;
            z-index: 999999 !important;
            background: rgba(15,23,42,.98) !important;
            border: 1px solid rgba(56,189,248,.28) !important;
            border-radius: 18px !important;
            box-shadow: 0 30px 80px rgba(2,6,23,.62) !important;
            box-sizing: border-box;
            overflow: hidden !important;
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-head,
        body.portal-home-ai-fullscreen-open .portal-home-ai-compose {
            flex: 0 0 auto;
            min-height: 0;
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-compose {
            padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-compose input[type="text"],
        body.portal-home-ai-fullscreen-open .portal-home-ai-compose textarea {
            max-height: 96px;
        }
        body.portal-home-ai-fullscreen-open .portal-home-ai-stream {
            flex: 1 1 auto;
            min-height: 0;
            max-height: none;
            overflow-y: auto;
        }
        body.login-mode .portal-home-ai-widget,
        body.viewer-mode .portal-home-ai-widget,
        #viewer-screen.active ~ .portal-home-ai-widget {
            display: none !important;
        }
        .portal-home-ai-fab {
            position: relative;
            width: 60px;
            height: 60px;
            border-radius: 50%;
            border: none;
            padding: 0;
            background: linear-gradient(135deg, #0ea5e9, #6366f1 55%, #a855f7);
            color: #fff;
            box-shadow: 0 14px 36px rgba(2,6,23,.38), 0 0 0 4px rgba(99,102,241,.14);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: grab;
            overflow: visible;
            touch-action: none;
            -webkit-user-select: none;
            user-select: none;
            transition: transform .18s ease, box-shadow .18s ease;
        }
        .portal-home-ai-fab:active { cursor: grabbing; }
        .portal-home-ai-widget.is-dragging .portal-home-ai-fab {
            transition: none;
            cursor: grabbing;
            transform: scale(1.06);
        }
        /* วงแสงหมุนรอบ ๆ ให้ดูเหมือน AI */
        .portal-home-ai-fab::before {
            content: "";
            position: absolute;
            inset: -3px;
            border-radius: 50%;
            background: conic-gradient(from 0deg, #38bdf8, #a855f7, #22d3ee, #6366f1, #38bdf8);
            filter: blur(2px);
            opacity: .85;
            z-index: 0;
            animation: portalAiSpin 3.6s linear infinite;
        }
        /* รัศมีเรืองแสงกระเพื่อม */
        .portal-home-ai-fab::after {
            content: "";
            position: absolute;
            inset: -7px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(99,102,241,.55), rgba(56,189,248,0) 70%);
            z-index: -1;
            animation: portalAiPulse 2.4s ease-in-out infinite;
        }
        .portal-home-ai-fab-icon {
            position: relative;
            z-index: 2;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            object-fit: cover;
            background: #0f172a;
            box-shadow: 0 2px 8px rgba(2,6,23,.45);
            pointer-events: none;
        }
        /* ประกายดาวระยิบระยับ */
        .portal-home-ai-spark {
            position: absolute;
            z-index: 3;
            background: #fff;
            clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
            filter: drop-shadow(0 0 4px rgba(147,197,253,.95));
            opacity: 0;
            pointer-events: none;
            animation: portalAiTwinkle 2.6s ease-in-out infinite;
        }
        .portal-home-ai-spark.s1 { top: -5px; right: -3px; width: 13px; height: 13px; animation-delay: .1s; }
        .portal-home-ai-spark.s2 { bottom: -3px; left: -5px; width: 10px; height: 10px; animation-delay: .9s; }
        .portal-home-ai-spark.s3 { top: 46%; right: -9px; width: 8px; height: 8px; animation-delay: 1.7s; }
        .portal-home-ai-fab:hover {
            transform: translateY(-2px) scale(1.04);
            box-shadow: 0 18px 42px rgba(2,6,23,.44), 0 0 0 6px rgba(99,102,241,.18);
        }
        @keyframes portalAiSpin { to { transform: rotate(360deg); } }
        @keyframes portalAiPulse {
            0%, 100% { transform: scale(1); opacity: .55; }
            50% { transform: scale(1.2); opacity: .12; }
        }
        @keyframes portalAiTwinkle {
            0%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); }
            50% { opacity: 1; transform: scale(1) rotate(90deg); }
        }
        @media (prefers-reduced-motion: reduce) {
            .portal-home-ai-fab::before,
            .portal-home-ai-fab::after,
            .portal-home-ai-spark { animation: none; }
        }
        /* 🤖 เมนูย่อย (speed-dial) ของปุ่มลอย AI — กาง เลขา AI + AI พนักงานที่ตั้งค่าใน Virtual Office */
        .portal-home-ai-dial {
            position: absolute;
            left: 0;
            display: none;
            flex-direction: column;
            gap: 8px;
            padding: 4px;
            max-height: min(60vh, 420px);
            overflow-y: auto;
            scrollbar-width: none;
            -ms-overflow-style: none;
            z-index: 3;
        }
        .portal-home-ai-dial::-webkit-scrollbar { width: 0; height: 0; display: none; }
        .portal-home-ai-widget.dial-open .portal-home-ai-dial { display: flex; }
        .portal-home-ai-widget.dial-up .portal-home-ai-dial { bottom: calc(100% + 12px); flex-direction: column-reverse; }
        .portal-home-ai-widget.dial-down .portal-home-ai-dial { top: calc(100% + 12px); flex-direction: column; }
        .portal-home-ai-widget.dial-align-right .portal-home-ai-dial { left: auto; right: 0; align-items: flex-end; }
        .portal-home-ai-widget.dial-align-left .portal-home-ai-dial { left: 0; right: auto; align-items: flex-start; }
        .portal-home-ai-widget.dial-open .portal-home-ai-fab { box-shadow: 0 18px 42px rgba(2,6,23,.5), 0 0 0 6px rgba(99,102,241,.22); }
        .portal-home-ai-dial-item {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            max-width: min(64vw, 240px);
            height: 42px;
            padding: 0 14px;
            border-radius: 999px;
            border: 1px solid rgba(125, 211, 252, .40);
            background: rgba(15, 23, 42, .96);
            color: #e0f2fe;
            font-family: var(--portal-font);
            font-size: .82rem;
            font-weight: 700;
            white-space: nowrap;
            cursor: pointer;
            box-shadow: 0 12px 28px rgba(2, 6, 23, .34);
            transition: transform .12s ease, background .12s ease, color .12s ease, filter .12s ease;
            animation: portalHomeAiDialIn .18s ease both;
        }
        .portal-home-ai-dial-item > span {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .portal-home-ai-dial-item > i { font-size: 1rem; flex: 0 0 auto; }
        .portal-home-ai-dial-item.secretary {
            border-color: rgba(168, 85, 247, .55);
            background: linear-gradient(135deg, rgba(124,58,237,.96), rgba(6,182,212,.92));
            color: #fff;
        }
        .portal-home-ai-dial-item:hover { background: rgba(14,165,233,.94); color: #fff; }
        .portal-home-ai-dial-item.secretary:hover { background: linear-gradient(135deg, rgba(124,58,237,1), rgba(6,182,212,1)); filter: brightness(1.06); }
        .portal-home-ai-dial-empty { color:#94a3b8; font-size:.76rem; padding:8px 12px; }
        @keyframes portalHomeAiDialIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

        /* 🤖 Modal แชท AI พนักงาน (หน้า Home) */
        .portal-ai-agent-modal {
            position: fixed;
            inset: 0;
            z-index: 2300;
            display: none;
            align-items: flex-end;
            justify-content: flex-start;
            padding: 18px;
            background: rgba(2,6,23,.55);
            -webkit-backdrop-filter: blur(3px);
            backdrop-filter: blur(3px);
        }
        .portal-ai-agent-modal.show { display: flex; }
        .portal-ai-agent-card {
            width: min(520px, calc(100vw - 28px));
            height: min(80vh, 660px);
            display: flex;
            flex-direction: column;
            background: rgba(15,23,42,.98);
            border: 1px solid rgba(148,163,184,.18);
            border-radius: 20px;
            box-shadow: 0 30px 80px rgba(2,6,23,.62);
            overflow: hidden;
            font-family: var(--portal-font);
            animation: portalHomeAiDialIn .18s ease both;
        }
        .portal-ai-agent-modal.is-fullscreen {
            align-items: stretch;
            justify-content: center;
            padding: 18px;
            z-index: 2400;
        }
        .portal-ai-agent-modal.is-fullscreen .portal-ai-agent-card {
            width: min(1280px, calc(100vw - 36px));
            height: calc(100vh - 36px);
            height: calc(100dvh - 36px);
            border-radius: 18px;
            border: 1px solid rgba(56,189,248,.28);
        }
        .portal-ai-agent-card .portal-home-ai-stream { flex: 1 1 auto; min-height: 0; }
        .portal-ai-agent-card .portal-home-ai-compose {
            grid-template-columns: 1fr 44px 44px 44px;
        }
        @media (max-width: 640px) {
            .portal-ai-agent-modal { padding: 0; align-items: stretch; justify-content: stretch; }
            .portal-ai-agent-card { width: 100%; height: 100%; border-radius: 0; }
            .portal-ai-agent-modal.is-fullscreen { padding: 0; }
            .portal-ai-agent-modal.is-fullscreen .portal-ai-agent-card { width: 100%; height: 100dvh; border-radius: 0; }
            body.portal-home-ai-fullscreen-open .portal-home-ai-widget,
            .portal-home-ai-widget.is-fullscreen {
                padding: 0 !important;
            }
            body.portal-home-ai-fullscreen-open .portal-home-ai-panel,
            .portal-home-ai-widget.is-fullscreen .portal-home-ai-panel {
                width: 100vw !important;
                height: 100dvh !important;
                border-radius: 0 !important;
                border: 0 !important;
            }
        }
        @media (max-width: 1199px) {
            body:not(.portal-home-ai-fullscreen-open) .portal-home-ai-widget:not(.is-fullscreen) {
                display: none !important;
            }
            body.portal-home-ai-fullscreen-open .portal-home-ai-widget.is-fullscreen {
                display: flex !important;
            }
        }

        /* 📦 Modal คลัง AI (AI job vault) */
        .portal-ai-vault {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 100050;
            align-items: stretch;
            justify-content: center;
            padding: 18px;
            background: rgba(2,6,23,.66);
            color: #e9d5ff;
            -webkit-backdrop-filter: blur(12px);
            backdrop-filter: blur(12px);
            box-sizing: border-box;
        }
        .portal-ai-vault.show { display: flex; }
        .portal-ai-vault-card {
            width: min(1040px, 100%);
            min-height: 0;
            display: flex;
            flex-direction: column;
            border: 1px solid rgba(168,85,247,.42);
            border-radius: 18px;
            background: rgba(15,23,42,.97);
            box-shadow: 0 28px 72px rgba(2,6,23,.54);
            overflow: hidden;
            font-family: var(--portal-font);
        }
        .portal-ai-vault-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 14px 16px;
            border-bottom: 1px solid rgba(148,163,184,.22);
            font-size: .9rem;
            font-weight: 900;
            color: #f5f3ff;
        }
        .portal-ai-vault-head small { color: #c4b5fd; font-size: .68rem; }
        .portal-ai-vault-close {
            width: 34px; height: 34px; border: 0; border-radius: 12px;
            background: #ef4444; color: #fff; cursor: pointer;
            display: inline-flex; align-items: center; justify-content: center;
        }
        .portal-ai-vault-actions {
            display: flex; gap: 8px; flex-wrap: wrap;
            padding: 12px 16px; border-bottom: 1px solid rgba(148,163,184,.14);
        }
        .portal-ai-vault-jobs {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
            gap: 8px;
            padding: 12px 16px;
            border-bottom: 1px solid rgba(148,163,184,.14);
            max-height: 170px;
            overflow: auto;
        }
        .portal-ai-vault-job {
            display: grid;
            grid-template-columns: 22px 30px 1fr 30px;
            align-items: center;
            gap: 8px;
            min-width: 0;
            border: 1px solid rgba(148,163,184,.18);
            border-radius: 12px;
            background: rgba(15,23,42,.62);
            color: #e9d5ff;
            padding: 9px;
        }
        .portal-ai-vault-job.is-focused { border-color: rgba(56,189,248,.5); background: rgba(14,165,233,.12); }
        .portal-ai-vault-job input { width: 18px; height: 18px; accent-color: #8b5cf6; }
        .portal-ai-vault-job-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; font-weight: 900; }
        .portal-ai-vault-job small { display: block; color: #a5b4fc; font-size: .65rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .portal-ai-vault-job-open,
        .portal-ai-vault-job-delete {
            width: 30px; height: 30px; border: 0; border-radius: 10px;
            display: inline-flex; align-items: center; justify-content: center;
            color: #fff; cursor: pointer;
        }
        .portal-ai-vault-job-open { background: rgba(14,165,233,.24); color: #bae6fd; }
        .portal-ai-vault-job-delete { background: rgba(239,68,68,.22); color: #fecaca; }
        .portal-ai-vault-btn {
            border: 1px solid rgba(196,181,253,.34);
            border-radius: 10px;
            background: rgba(124,58,237,.28);
            color: #f5f3ff;
            padding: 8px 10px;
            font-family: var(--portal-font);
            font-size: .74rem; font-weight: 900;
            cursor: pointer;
            display: inline-flex; align-items: center; gap: 5px;
        }
        .portal-ai-vault-btn:hover { background: rgba(124,58,237,.56); }
        .portal-ai-vault-editor {
            display: none;
            grid-template-columns: minmax(0, 1fr);
            gap: 8px; padding: 12px 16px;
            border-bottom: 1px solid rgba(148,163,184,.14);
        }
        .portal-ai-vault-editor.show { display: grid; }
        .portal-ai-vault-editor input,
        .portal-ai-vault-editor textarea {
            width: 100%; box-sizing: border-box;
            border-radius: 10px; border: 1px solid rgba(148,163,184,.32);
            background: rgba(15,23,42,.68); color: #f8fafc;
            padding: 9px 10px; font-family: var(--portal-font);
            font-size: .8rem; font-weight: 800; outline: none;
        }
        .portal-ai-vault-editor textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
        .portal-ai-vault-editor-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
        .portal-ai-vault-wrap { flex: 1 1 auto; min-height: 0; padding: 14px 16px 16px; overflow: auto; }
        .portal-ai-vault-items {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
            gap: 12px;
        }
        .portal-ai-vault-item {
            min-width: 0;
            border: 1px solid rgba(148,163,184,.22);
            border-radius: 12px;
            background: rgba(30,41,59,.78);
            padding: 10px;
            display: grid;
            grid-template-rows: auto minmax(0, 1fr) auto;
            gap: 7px; min-height: 142px;
            font-size: .72rem; text-align: center;
        }
        .portal-ai-vault-item-icon {
            width: 46px; height: 46px; margin: 0 auto;
            border-radius: 14px; background: rgba(14,165,233,.16); color: #93c5fd;
            display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem;
            overflow: hidden;
        }
        .portal-ai-vault-item-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
        .portal-ai-vault-item.note .portal-ai-vault-item-icon { background: rgba(168,85,247,.18); color: #d8b4fe; }
        .portal-ai-vault-item.image .portal-ai-vault-item-icon { background: rgba(16,185,129,.16); color: #86efac; }
        .portal-ai-vault-item-title {
            overflow: hidden; text-overflow: ellipsis;
            display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
            font-weight: 900; color: #f8fafc; line-height: 1.25;
        }
        .portal-ai-vault-item small { color: #c4b5fd; font-size: .62rem; }
        .portal-ai-vault-item-actions { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
        .portal-ai-vault-item-action {
            border: 1px solid rgba(148,163,184,.26);
            background: rgba(15,23,42,.58); color: #e0f2fe;
            border-radius: 9px; min-width: 30px; height: 28px;
            display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
        }
        .portal-ai-vault-item-action.danger { color: #fecaca; border-color: rgba(248,113,113,.38); }
        .portal-ai-vault-empty {
            grid-column: 1 / -1; min-height: 200px;
            border: 2px dashed rgba(196,181,253,.28); border-radius: 16px;
            display: flex; align-items: center; justify-content: center;
            color: #c4b5fd; font-size: .82rem; font-weight: 900; text-align: center; padding: 20px;
        }
        .portal-home-ai-panel {
            position: absolute;
            left: 0;
            bottom: 76px;
            width: min(520px, calc(100vw - 36px));
            height: min(680px, calc(100vh - 128px));
            background: rgba(15,23,42,.94);
            border: 1px solid rgba(148,163,184,.22);
            border-radius: 18px;
            box-shadow: 0 22px 60px rgba(2,6,23,.52);
            backdrop-filter: blur(18px);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            opacity: 0;
            pointer-events: none;
            transform: translateY(10px) scale(.98);
            transform-origin: left bottom;
            transition: opacity .18s ease, transform .18s ease;
        }
        .portal-home-ai-widget.is-open .portal-home-ai-panel {
            opacity: 1;
            pointer-events: auto;
            transform: translateY(0) scale(1);
        }
        .portal-home-ai-widget.is-fullscreen {
            left: 0 !important;
            right: 0 !important;
            top: 0 !important;
            bottom: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            height: 100dvh !important;
            z-index: 99999;
            pointer-events: auto;
            display: flex !important;
            align-items: stretch !important;
            justify-content: center !important;
            padding: 18px !important;
            background: rgba(2,6,23,.55) !important;
            box-sizing: border-box !important;
        }
        .portal-home-ai-widget.is-fullscreen .portal-home-ai-fab {
            display: none;
        }
        .portal-home-ai-widget.is-fullscreen .portal-home-ai-panel {
            position: relative !important;
            inset: auto !important;
            left: auto !important;
            right: auto !important;
            top: auto !important;
            bottom: auto !important;
            width: min(1280px, calc(100vw - 36px)) !important;
            height: calc(100vh - 36px) !important;
            height: calc(100dvh - 36px) !important;
            min-height: 0;
            max-height: none;
            border-radius: 18px;
            border: 1px solid rgba(56,189,248,.28);
            transform-origin: center center;
            pointer-events: auto;
            display: flex !important;
            flex-direction: column !important;
            overflow: hidden !important;
            box-sizing: border-box;
        }
        .portal-home-ai-widget.is-fullscreen .portal-home-ai-stream {
            flex: 1 1 auto;
            min-height: 0;
            overflow-y: auto;
            padding: 24px;
        }
        .portal-home-ai-widget.is-fullscreen .portal-home-ai-empty {
            width: min(760px, 92vw);
            margin-left: auto;
            margin-right: auto;
        }
        .portal-home-ai-widget.is-fullscreen .portal-home-ai-quick {
            max-width: min(560px, 86vw);
        }
        .portal-home-ai-widget.is-fullscreen .portal-home-ai-msg {
            max-width: min(900px, 92%);
        }
        .portal-home-ai-head {
            flex: 0 0 auto;
            padding: 14px 16px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            border-bottom: 1px solid rgba(148,163,184,.16);
            background: rgba(30,41,59,.88);
        }
        .portal-home-ai-title {
            display: flex;
            align-items: center;
            gap: 12px;
            min-width: 0;
            color: #f8fafc;
        }
        .portal-home-ai-title > span {
            width: 44px;
            height: 44px;
            border-radius: 14px;
            background: linear-gradient(135deg, #38bdf8, #22c55e);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            flex: 0 0 auto;
        }
        .portal-home-ai-title b {
            display: block;
            font-size: 1.05rem;
            line-height: 1.15;
        }
        .portal-home-ai-title small {
            display: block;
            color: #94a3b8;
            font-size: .78rem;
            font-weight: 800;
        }
        .portal-home-ai-actions {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .portal-home-ai-actions button {
            width: 38px;
            height: 38px;
            border-radius: 12px;
            border: 1px solid rgba(148,163,184,.22);
            background: rgba(15,23,42,.66);
            color: #cbd5e1;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }
        .portal-home-ai-stream {
            flex: 1 1 auto;
            min-height: 0;
            overflow-y: auto;
            padding: 18px 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        .portal-home-ai-empty {
            margin: auto 0;
            color: #cbd5e1;
            text-align: center;
            font-size: .96rem;
            line-height: 1.65;
            padding: 22px 12px;
        }
        .portal-home-ai-empty i {
            display: inline-flex;
            width: 60px;
            height: 60px;
            border-radius: 50%;
            align-items: center;
            justify-content: center;
            background: rgba(56,189,248,.18);
            color: #38bdf8;
            font-size: 1.65rem;
            margin-bottom: 10px;
        }
        .portal-home-ai-quick {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 6px;
            margin-top: 10px;
            max-width: 320px;
            margin-left: auto;
            margin-right: auto;
        }
        .portal-home-ai-quick button {
            border: 1px solid rgba(168,85,247,.42);
            border-radius: 999px;
            background: rgba(88,28,135,.22);
            color: #f5d0fe;
            padding: 6px 10px;
            font-family: var(--portal-font);
            font-size: .78rem;
            line-height: 1.2;
            font-weight: 900;
            cursor: pointer;
            text-align: center;
            width: auto;
            min-width: 0;
            white-space: nowrap;
        }
        .portal-home-ai-quick button:hover { background: rgba(168,85,247,.32); color: #fff; }
        .portal-home-ai-suggestions button {
            border: 1px solid rgba(168,85,247,.38);
            border-radius: 999px;
            background: rgba(88,28,135,.28);
            color: #f5d0fe;
            padding: 6px 10px;
            font-family: var(--portal-font);
            font-size: .72rem;
            font-weight: 900;
            cursor: pointer;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .portal-home-ai-suggestions button:hover { background: rgba(168,85,247,.42); color: #fff; }
        .portal-home-ai-empty-avatar {
            width: 64px;
            height: 64px;
            margin: 0 auto 8px;
            border-radius: 22px;
            object-fit: cover;
            background: rgba(168,85,247,.22);
            border: 1px solid rgba(216,180,254,.36);
            box-shadow: 0 14px 32px rgba(88,28,135,.28);
            display: block;
        }
        .portal-home-ai-empty-avatar + .portal-home-ai-avatar-fallback {
            width: 64px;
            height: 64px;
            margin: 0 auto 8px;
            border-radius: 22px;
            font-size: 1.55rem;
        }
        .portal-home-ai-avatar-mini {
            width: 24px;
            height: 24px;
            border-radius: 9px;
            object-fit: cover;
            background: rgba(168,85,247,.22);
            border: 1px solid rgba(216,180,254,.32);
            flex: 0 0 auto;
        }
        .portal-home-ai-avatar-fallback {
            width: 24px;
            height: 24px;
            border-radius: 9px;
            display: none;
            align-items: center;
            justify-content: center;
            background: rgba(168,85,247,.24);
            color: #f5d0fe;
            border: 1px solid rgba(216,180,254,.32);
            font-size: .8rem;
            flex: 0 0 auto;
        }
        .portal-home-ai-avatar-fallback i {
            display: inline;
            width: auto;
            height: auto;
            border-radius: 0;
            margin: 0;
            background: transparent;
            color: inherit;
            font-size: inherit;
        }
        .portal-home-ai-msg {
            max-width: 90%;
            display: flex;
            flex-direction: column;
            gap: 5px;
            align-self: flex-start;
        }
        .portal-home-ai-msg.mine {
            align-self: flex-end;
            align-items: flex-end;
        }
        .portal-home-ai-sender {
            color: #c4b5fd;
            font-size: .72rem;
            font-weight: 900;
            display: flex;
            align-items: center;
            gap: 7px;
            margin: 0 8px 4px;
        }
        .portal-home-ai-bubble {
            padding: 12px 14px;
            border-radius: 16px;
            background: rgba(88,28,135,.34);
            border: 1px solid rgba(216,180,254,.22);
            color: #f5e8ff;
            font-size: .95rem;
            line-height: 1.72;
            word-break: break-word;
        }
        .portal-home-ai-msg.mine .portal-home-ai-bubble {
            background: linear-gradient(135deg, #0ea5e9, #2563eb);
            border-color: rgba(125,211,252,.32);
            color: #fff;
        }
        .portal-home-ai-bubble a {
            color: #7dd3fc;
            text-decoration: underline;
        }
        .portal-home-ai-bubble .portal-ai-open-link {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin: 3px 2px;
            padding: 6px 10px;
            border-radius: 12px;
            background: rgba(14,165,233,.16);
            border: 1px solid rgba(125,211,252,.35);
            color: #bae6fd;
            text-decoration: none;
            font-weight: 800;
        }
        .portal-home-ai-bubble .portal-ai-open-link:hover {
            background: rgba(14,165,233,.26);
            color: #fff;
        }
        .portal-home-ai-generated {
            display: grid;
            gap: 9px;
            width: min(390px, 100%);
        }
        .portal-home-ai-generated img {
            width: 100%;
            max-height: 390px;
            object-fit: contain;
            border-radius: 14px;
            border: 1px solid rgba(125,211,252,.25);
            background: rgba(15,23,42,.42);
            display: block;
        }
        .portal-home-ai-generated-caption {
            font-size: .82rem;
            line-height: 1.5;
            font-weight: 800;
            opacity: .9;
        }
        .portal-home-ai-generated-actions {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }
        .portal-home-ai-generated-actions a {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            min-height: 34px;
            padding: 0 11px;
            border-radius: 12px;
            border: 1px solid rgba(125,211,252,.35);
            background: rgba(14,165,233,.16);
            color: #bae6fd;
            text-decoration: none;
            font-size: .76rem;
            font-weight: 900;
        }
        .portal-home-ai-generated-actions a:hover {
            background: rgba(14,165,233,.26);
            color: #fff;
        }
        .portal-ai-copy-row {
            display: flex;
            justify-content: flex-end;
            margin-top: 8px;
        }
        .portal-ai-copy-btn {
            border: 1px solid rgba(255,255,255,.22);
            border-radius: 999px;
            background: rgba(255,255,255,.08);
            color: #e2e8f0;
            padding: 6px 11px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-family: var(--portal-font);
            font-size: .72rem;
            font-weight: 900;
            cursor: pointer;
        }
        .portal-ai-copy-btn:hover {
            background: rgba(14,165,233,.18);
            border-color: rgba(125,211,252,.38);
            color: #fff;
        }
        .portal-ai-doc-summary {
            display: block;
            margin-bottom: 8px;
            font-weight: 900;
            line-height: 1.5;
        }
        .portal-ai-doc-more {
            width: 100%;
            margin-top: 8px;
            border: 1px solid rgba(56,189,248,.42);
            border-radius: 14px;
            background: rgba(14,165,233,.18);
            color: #e0f2fe;
            min-height: 38px;
            font-family: var(--portal-font);
            font-weight: 900;
            cursor: pointer;
        }
        .portal-ai-doc-more:hover { background: rgba(14,165,233,.34); color: #fff; }
        .portal-ai-table-wrap {
            width: 100%;
            overflow-x: auto;
            margin: 8px 0;
            border-radius: 14px;
            border: 1px solid rgba(216,180,254,.28);
            background: rgba(15,23,42,.22);
        }
        .portal-ai-table {
            width: 100%;
            border-collapse: collapse;
            min-width: 280px;
            color: inherit;
            font-family: var(--portal-font);
            font-size: .82rem;
            line-height: 1.45;
            white-space: normal;
        }
        .portal-ai-table th,
        .portal-ai-table td {
            padding: 9px 10px;
            vertical-align: top;
            border-bottom: 1px solid rgba(216,180,254,.18);
            text-align: left;
        }
        .portal-ai-table th {
            background: rgba(168,85,247,.28);
            color: #f5e8ff;
            font-weight: 900;
            white-space: nowrap;
        }
        .portal-ai-table .portal-ai-file-cell {
            width: 64px;
            text-align: center;
            white-space: nowrap;
        }
        .portal-ai-table tr:nth-child(odd) td { background: rgba(255,255,255,.035); }
        .portal-ai-table tr:nth-child(even) td { background: rgba(14,165,233,.055); }
        .portal-ai-table tr:last-child td { border-bottom: 0; }
        .portal-ai-pdf-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 34px;
            height: 34px;
            margin: 4px 2px;
            border-radius: 12px;
            background: #ef4444;
            color: #fff !important;
            text-decoration: none;
            box-shadow: 0 8px 18px rgba(239,68,68,.28);
            vertical-align: middle;
        }
        .portal-ai-pdf-link:hover { background: #dc2626; color: #fff !important; transform: translateY(-1px); }
        .portal-home-ai-msg.mine .portal-home-ai-bubble a {
            color: #fff;
        }
        .portal-home-ai-thinking {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            min-width: 92px;
            min-height: 22px;
        }
        .portal-home-ai-thinking-word {
            color: inherit;
            font-weight: 900;
            opacity: .86;
        }
        .portal-home-ai-thinking-dots {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }
        .portal-home-ai-thinking-dots span {
            width: 6px;
            height: 6px;
            border-radius: 999px;
            background: currentColor;
            opacity: .38;
            transform: translateY(0);
            animation: portalHomeAiDot 1s infinite ease-in-out;
        }
        .portal-home-ai-thinking-dots span:nth-child(2) { animation-delay: .16s; }
        .portal-home-ai-thinking-dots span:nth-child(3) { animation-delay: .32s; }
        @keyframes portalHomeAiDot {
            0%, 80%, 100% { opacity: .35; transform: translateY(0) scale(.9); }
            40% { opacity: 1; transform: translateY(-5px) scale(1.12); }
        }
        .portal-home-ai-compose {
            position: relative;
            flex: 0 0 auto;
            display: grid;
            grid-template-columns: 1fr 44px 44px;
            gap: 9px;
            padding: 12px;
            border-top: 1px solid rgba(148,163,184,.16);
            background: rgba(15,23,42,.96);
        }
        .portal-home-ai-image-chip {
            grid-column: 1 / -1;
            display: none;
            align-items: center;
            gap: 8px;
            min-width: 0;
            padding: 8px 10px;
            border-radius: 12px;
            border: 1px solid rgba(34,197,94,.28);
            background: rgba(34,197,94,.12);
            color: #bbf7d0;
            font-size: .78rem;
            font-weight: 900;
        }
        .portal-home-ai-image-chip.show { display: flex; }
        .portal-home-ai-image-chip img {
            width: 34px;
            height: 34px;
            border-radius: 9px;
            object-fit: cover;
            background: rgba(15,23,42,.7);
            flex: 0 0 auto;
        }
        .portal-home-ai-image-chip span {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .portal-home-ai-image-chip button {
            width: 28px;
            height: 28px;
            margin-left: auto;
            border: 0;
            border-radius: 9px;
            background: rgba(15,23,42,.38);
            color: #fff;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }
        .portal-home-ai-compose input[type="text"],
        .portal-home-ai-compose textarea {
            min-width: 0;
            border: 1px solid rgba(148,163,184,.22);
            border-radius: 14px;
            background: rgba(30,41,59,.86);
            color: #f8fafc;
            padding: 12px 14px;
            font-size: .95rem;
            font-family: var(--portal-font);
            resize: none;
            line-height: 1.42;
            max-height: 150px;
            overflow: auto;
        }
        .portal-home-ai-compose input[type="text"]:focus,
        .portal-home-ai-compose textarea:focus {
            outline: none;
            border-color: #38bdf8;
            box-shadow: 0 0 0 3px rgba(56,189,248,.15);
        }
        .portal-home-ai-attach,
        .portal-home-ai-send {
            border: 0;
            border-radius: 14px;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 1.05rem;
        }
        .portal-home-ai-attach {
            background: rgba(148,163,184,.22);
            color: #cbd5e1;
        }
        .portal-home-ai-send {
            background: linear-gradient(135deg, #0ea5e9, #2563eb);
        }
        .portal-home-ai-compose button:disabled,
        .portal-home-ai-compose input:disabled,
        .portal-home-ai-compose textarea:disabled {
            opacity: .62;
            cursor: wait;
        }
        .portal-home-ai-suggestions {
            position: absolute;
            left: 12px;
            right: 102px;
            bottom: 68px;
            display: none;
            flex-wrap: wrap;
            gap: 8px;
            padding: 10px;
            background: rgba(15,23,42,.98);
            border: 1px solid rgba(56,189,248,.22);
            border-radius: 14px;
            box-shadow: 0 14px 34px rgba(2,6,23,.38);
            max-height: 170px;
            overflow-y: auto;
        }
        .portal-home-ai-suggestions.show {
            display: flex;
        }
        [data-theme="light"] .portal-home-ai-panel {
            background: rgba(255,255,255,.96);
            border-color: #dbeafe;
            box-shadow: 0 20px 54px rgba(15,23,42,.2);
        }
        [data-theme="light"] .portal-ai-agent-card {
            background: rgba(255,255,255,.98);
            border-color: #dbeafe;
            box-shadow: 0 24px 64px rgba(15,23,42,.24);
        }
        [data-theme="light"] .portal-home-ai-head,
        [data-theme="light"] .portal-home-ai-compose {
            background: #f8fafc;
            border-color: #e2e8f0;
        }
        [data-theme="light"] .portal-home-ai-title,
        [data-theme="light"] .portal-home-ai-empty {
            color: #0f172a;
        }
        [data-theme="light"] .portal-home-ai-msg.other .portal-home-ai-bubble {
            background: #f3e8ff;
            color: #3b0764;
            border-color: #d8b4fe;
        }
        [data-theme="light"] .portal-home-ai-msg.mine .portal-home-ai-bubble {
            background: linear-gradient(135deg, #0ea5e9, #2563eb);
            border-color: rgba(125,211,252,.32);
            color: #fff;
        }
        [data-theme="light"] .portal-home-ai-generated img {
            background: #ffffff;
            border-color: #dbeafe;
        }
        [data-theme="light"] .portal-home-ai-generated-actions a {
            background: #e0f2fe;
            color: #075985;
            border-color: #bae6fd;
        }
        [data-theme="light"] .portal-ai-table-wrap {
            background: #ffffff;
            border-color: #ddd6fe;
        }
        [data-theme="light"] .portal-ai-table th {
            background: #ede9fe;
            color: #312e81;
        }
        [data-theme="light"] .portal-ai-table td {
            border-bottom-color: #e9d5ff;
        }
        [data-theme="light"] .portal-ai-table tr:nth-child(odd) td { background: #ffffff; }
        [data-theme="light"] .portal-ai-table tr:nth-child(even) td { background: #f8fafc; }
        [data-theme="light"] .portal-ai-doc-more {
            background: #e0f2fe;
            color: #075985;
            border-color: #bae6fd;
        }
        [data-theme="light"] .portal-home-ai-quick button {
            background: #f5f3ff;
            color: #5b21b6;
            border-color: #c4b5fd;
        }
        [data-theme="light"] .portal-home-ai-compose input[type="text"] {
            background: #ffffff;
            border-color: #cbd5e1;
            color: #0f172a;
        }
        [data-theme="light"] .portal-home-ai-actions button,
        [data-theme="light"] .portal-home-ai-suggestions {
            background: #ffffff;
            border-color: #dbeafe;
            color: #0f172a;
        }
        [data-theme="light"] .portal-home-ai-image-chip {
            background: #ecfdf5;
            border-color: #bbf7d0;
            color: #166534;
        }
        @media (max-width: 575px) {
            .portal-home-ai-widget {
                left: calc(env(safe-area-inset-left, 0px) + 12px);
                bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
            }
            .portal-home-ai-sidebar-panel {
                left: calc(env(safe-area-inset-left, 0px) + 12px) !important;
                bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
            }
            .portal-home-ai-fab {
                width: 54px;
                height: 54px;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab {
                width: 54px;
                height: 54px;
            }
            .portal-home-ai-fab-icon {
                width: 45px;
                height: 45px;
            }
            .portal-home-ai-sidebar-panel .portal-home-ai-fab-icon {
                width: 45px;
                height: 45px;
            }
            .portal-home-ai-stream {
                padding: 14px 12px;
            }
            .portal-home-ai-bubble {
                font-size: .9rem;
                line-height: 1.65;
            }
            .portal-home-ai-compose {
                grid-template-columns: 1fr 42px 42px;
            }
        }
        @media (max-width: 1024px) {
            .portal-home-ai-widget.is-open:not(.is-fullscreen) .portal-home-ai-fab {
                opacity: 0;
                visibility: hidden;
                pointer-events: none;
                z-index: -1;
            }
            .portal-home-ai-panel {
                position: fixed;
                left: calc(env(safe-area-inset-left, 0px) + 12px);
                right: calc(env(safe-area-inset-right, 0px) + 12px);
                top: calc(env(safe-area-inset-top, 0px) + 12px);
                bottom: auto;
                width: auto;
                /* ใช้ความสูงที่ชัดเจน (definite height) ด้วย dvh เพื่อให้ .portal-home-ai-stream เลื่อน (scroll) ได้จริงบนมือถือ
                   แทนการใช้ top+bottom+height:auto ที่บาง mobile browser มองเป็นความสูงไม่ชัดเจน ทำให้เนื้อหาโดนตัดและเลื่อนไม่ได้ */
                height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
                height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
                max-height: none;
                transform-origin: center top;
            }
            .portal-home-ai-widget.is-fullscreen .portal-home-ai-panel {
                inset: 0 !important;
                width: 100vw !important;
                height: 100vh !important;
                height: 100dvh !important;
                min-height: 100dvh;
                border-radius: 0;
            }
            .portal-home-ai-head {
                position: sticky;
                top: 0;
                z-index: 3;
            }
            .portal-home-ai-stream {
                flex: 1 1 auto;
                min-height: 0;
                overflow-y: auto;
                overscroll-behavior: contain;
                -webkit-overflow-scrolling: touch;
            }
            .portal-home-ai-sidebar-panel.dial-up .portal-home-ai-dial {
                top: auto !important;
                bottom: calc(100% + 12px) !important;
                flex-direction: column-reverse !important;
            }
            .portal-home-ai-sidebar-panel.dial-down .portal-home-ai-dial {
                top: calc(100% + 12px) !important;
                bottom: auto !important;
                flex-direction: column !important;
            }
            .portal-home-ai-sidebar-panel.dial-align-right .portal-home-ai-dial {
                left: auto !important;
                right: 0 !important;
                align-items: flex-end !important;
            }
            .portal-home-ai-sidebar-panel.dial-align-left .portal-home-ai-dial {
                left: 0 !important;
                right: auto !important;
                align-items: flex-start !important;
            }
        }
        #quickApptModal input[type="date"]::-webkit-calendar-picker-indicator,
        #quickApptModal input[type="time"]::-webkit-calendar-picker-indicator {
            -webkit-filter: brightness(0) invert(1) !important;
            filter: brightness(0) invert(1) !important;
            opacity: 1 !important;
            cursor: pointer;
        }
        #quickApptModal input[type="date"],
        #quickApptModal input[type="time"] {
            color-scheme: dark !important;
        }
        #quickApptModal .form-select {
            min-height: 48px;
            height: 48px;
            padding: 0 42px 0 12px;
            line-height: 46px;
        }
        [data-theme="light"] #quickApptModal input[type="date"]::-webkit-calendar-picker-indicator,
        [data-theme="light"] #quickApptModal input[type="time"]::-webkit-calendar-picker-indicator {
            -webkit-filter: none !important;
            filter: none !important;
            opacity: .7 !important;
        }
        [data-theme="light"] #quickApptModal input[type="date"],
        [data-theme="light"] #quickApptModal input[type="time"] {
            color-scheme: light !important;
        }
    