
        /* =====================================================================
           黑色主調
           ===================================================================== */
        *, *::before, *::after {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            -webkit-tap-highlight-color: transparent;
        }

        :root {
            --bg:        #000000;
            --bg-1:      #1c1c1e;
            --bg-2:      #2c2c2e;
            --bg-3:      #3a3a3c;
            --sep:       rgba(84, 84, 88, .65);
            --label:     #ffffff;
            --label-2:   rgba(235, 235, 245, .60);
            --label-3:   rgba(235, 235, 245, .30);
            --green:     #30d158;
            --red:       #ff453a;
            --blue:      #0a84ff;
            --purple:    #bf5af2;
            --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
                    "PingFang TC", "PingFang SC", "Helvetica Neue", "Microsoft JhengHei",
                    system-ui, sans-serif;

            /* 手機模式影片 / 聊天 的預設比例（4 : 3） */
            --video-flex: 4;
            --chat-flex:  3;
        }

        html {
            -webkit-text-size-adjust: 100%;
            color-scheme: dark;
        }

        body {
            background: var(--bg);
            color: var(--label);
            font-family: var(--font);
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            font-size: clamp(12px, 1vw, 16px);
            display: flex;
            flex-direction: column;
            height: 100vh;
            height: 100dvh;
            overflow-x: hidden;
        }

        ::selection { background: rgba(48, 209, 88, .35); }

        /* ---------------- 頂欄 ---------------- */
        #top-bar {
            position: relative;
            z-index: 100;
            display: flex;
            align-items: center;
            min-height: 60px;
            padding: .6em 1em;
            background: rgba(20, 20, 22, .78);
            -webkit-backdrop-filter: saturate(180%) blur(24px);
            backdrop-filter: blur(24px);
            border-bottom: .5px solid var(--sep);
            overflow: hidden;
            contain: layout paint;
        }

        .top-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            flex-wrap: nowrap;
            gap: .625em;
        }

        /* ---------------- 頻道列 ---------------- */
        #lists {
            display: flex;
            flex-wrap: nowrap;
            align-items: center;
            gap: .5em;
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            overflow-y: hidden;
            white-space: nowrap;
            padding: .35em 0 .5em;
            cursor: grab;
            scrollbar-width: thin;
            scrollbar-color: rgba(235, 235, 245, .22) transparent;
            -webkit-overflow-scrolling: touch;
        }
        #lists:active { cursor: grabbing; }

        #lists::-webkit-scrollbar { height: 6px; background: transparent; }
        #lists::-webkit-scrollbar-track { background: transparent; }
        #lists::-webkit-scrollbar-thumb {
            background: rgba(235, 235, 245, .22);
            border-radius: 3px;
        }
        #lists::-webkit-scrollbar-thumb:hover { background: rgba(235, 235, 245, .4); }
        #lists::-webkit-scrollbar-thumb:active { background: var(--green); }

        @media (max-width: 768px) {
            #lists { display: none; }
        }
		@media (hover: none) {
    .reply-btn-group {
        display: flex;
    }
    .reply-btn2 {
        display: none !important;
    }
}

        /* ---------------- 通用按鈕 ---------------- */
        button {
            font-family: inherit;
            font-size: clamp(12px, .9vw, 14px);
            font-weight: 500;
            color: var(--label);
            background: var(--bg-1);
            border: none;
            border-radius: 10px;
            padding: 0 14px;
            height: 36px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            cursor: pointer;
            white-space: nowrap;
            user-select: none;
            -webkit-user-select: none;
            touch-action: manipulation;
            transition: background-color .18s ease, transform .12s ease, opacity .18s ease;
        }
        button:hover  { background: var(--bg-2); }
        button:active { transform: scale(.955); }

        #mobile-menu-btn {
            display: none;
            background: var(--bg-1);
            color: #fff;
        }
        #mobile-menu-btn:hover { background: var(--bg-1); }

        .button-wrapper {
            position: relative;
            display: inline-flex;
            flex-shrink: 0;
        }

        /* ---------------- 頻道狀態按鈕 ---------------- */
        .status-button {
          padding: 0px 7.3px;
background-color: rgba(14, 14, 14, 0);
line-height: 31px;
height: 35px;
font-size: 13px;
border: 1px solid #454545;
display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
font-family: 'Noto Sans TC', sans-serif, Meiryo, arial, helvetica, sans-serif;
        }
        .status-button:hover { background: var(--bg-2); }

        .live, .unknown2 {
          background-color: #1e9e4f !important;
          box-shadow: 0 0 0 1px rgba(46, 204, 113, .6);
		  border: 1px solid #454545;
        }
        .not-live {
            color: var(--red) !important;
            background: rgba(255, 69, 58, .15) !important;
            border: 1px solid #454545;
        }
        .unknown {
            color: var(--label-2) !important;
            background: var(--bg-1) !important;
            border: 1px solid #454545;
        }

        /* ---------------- iOS 開關 ---------------- */
        .toggle-switch {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            user-select: none;
            -webkit-user-select: none;
            background: var(--bg-1);
            padding: 0 12px;
            border-radius: 10px;
            height: 36px;
            font-size: .82rem;
            white-space: nowrap;
            transition: background-color .18s ease;
        }
        .toggle-switch:active { background: var(--bg-2); }

        .toggle-switch .slider {
            position: relative;
            display: inline-block;
            width: 51px;
            height: 31px;
            background-color: #39393d;
            border-radius: 100px;
            flex-shrink: 0;
            transition: background-color .3s cubic-bezier(.25, .1, .25, 1);
        }
        .toggle-switch .slider::before {
            content: "";
            position: absolute;
            width: 27px;
            height: 27px;
            left: 2px;
            top: 2px;
            background-color: #fff;
            border-radius: 50%;
            box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
            transition: transform .3s cubic-bezier(.25, .1, .25, 1);
        }
        .toggle-switch input { display: none; }
        .toggle-switch input:checked + .slider { background-color: var(--green); }
        .toggle-switch input:checked + .slider::before { transform: translateX(20px); }
        .purple-toggle input:checked + .slider { background-color: var(--purple); }
        .toggle-label { color: var(--label); font-weight: 500; }

        /* ---------------- 右側控制區 ---------------- */
        #input-container {
            display: flex;
            align-items: center;
            gap: .5em;
            flex-wrap: nowrap;
            overflow: hidden;
            white-space: nowrap;
            flex-shrink: 0;
            margin-left: auto;
            padding-left: .5em;
        }

        /* ---------------- 表單元素 ---------------- */
        input, select {
            font-family: inherit;
            font-size: .95rem;
            color: var(--label);
            background: var(--bg-2);
            border: none;
            border-radius: 10px;
            padding: 9px 12px;
            min-width: 0;
            transition: box-shadow .2s ease, background-color .2s ease;
        }

        input::placeholder { color: var(--label-3); }

        input:focus, select:focus {
            outline: none;
            background: var(--bg-3);
            box-shadow: 0 0 0 3px rgba(10, 132, 255, .35);
        }

        select {
            -webkit-appearance: none;
            appearance: none;
            padding-right: 34px;
            background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ebebf5' fill-opacity='0.6' d='M6 8.6 1.4 4h9.2z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            cursor: pointer;
        }

        /* ---------------- 播放區 ---------------- */
        #multi-stream-container-wrapper {
            display: flex;
            gap: .9375em;
            padding: .9375em;
            flex-grow: 1;
            min-height: 70vh;
            contain: layout;
        }

       .video-wrapper, .chat {
    background: #000;
    border-radius: 14px;
    border: .5px solid rgba(255, 255, 255, .10);
    min-height: 0;           /* ← 改成 0 */
    overflow: hidden;
    contain: layout paint;
}

        .video-wrapper {
            flex: 3;
            display: flex;
            flex-direction: column;
        }
        .chat { flex: 1; }

        iframe, video { contain: layout paint; }

        .video, .video1, .full-screen-video {
            width: 100%;
            height: 100%;
            border: none;
        }

        /* ---------------- Kick 縮放容器 ---------------- */
        .kick-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            overflow: hidden;
            border-radius: inherit;
        }
        .kick-iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
           /* transform: scale(0.454545);
            transform-origin: top left; */
            border: none;
            border-radius: inherit;
        }

        /* Kick 看更台音量控制：隔離全站 button 樣式，避免被通用 button CSS 放大 */
.kick-wrapper button.kick-mute-toggle,
.kick-wrapper .kick-mute-toggle {
    all: unset;
    box-sizing: border-box;
    position: absolute;
    z-index: 20;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
   
    margin: 0;
    padding: 0;
    border: 0px solid rgba(255,255,255,.3);
    border-radius: 2px;
    background: rgba(15, 15, 15, .82);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 19px;
    font-weight: normal;
    line-height: 1;
    letter-spacing: normal;
    text-align: center;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
    -webkit-tap-highlight-color: transparent;
}
.kick-wrapper button.kick-mute-toggle:hover,
.kick-wrapper button.kick-mute-toggle:focus-visible {
    background: rgba(45, 45, 45, .96);
    outline: 0px solid rgba(255,255,255,.7);
    outline-offset: 0px;
}
.kick-wrapper button.kick-mute-toggle.is-muted {
  /*  background: rgba(150, 35, 35, .9);*/
}
.kick-wrapper button.kick-mute-toggle:active {
    transform: scale(.96);
}

                .kick-iframe:fullscreen,
        .kick-iframe:-webkit-full-screen,
        .kick-iframe:-moz-full-screen {
            width: 100% !important;
            height: 100% !important;
            transform: none !important;
        }

        #multi-stream-container {
            display: grid;
            grid-template-columns: 1fr;
            grid-template-rows: 1fr;
            gap: .625em;
            height: 100%;
            width: 100%;
            overflow: hidden;
        }

        .hls-video-element {
            width: 100%;
            height: 100%;
            object-fit: contain;
            background: #000;
            border-radius: 10px;
        }

        /* ---------------- 手機頻道全屏選單 ---------------- */
        #channel-menu {
            display: none;
            position: fixed;
            inset: 0;
            background: #000;
            z-index: 1000;
            overflow: hidden;
            contain: strict;
        }

        #channel-menu-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem 1.15rem;
            background: rgba(20, 20, 22, .82);
            -webkit-backdrop-filter: saturate(180%) blur(20px);
            backdrop-filter:  blur(20px);
            border-bottom: .5px solid var(--sep);
            position: sticky;
            top: 0;
            z-index: 1001;
        }
        #channel-menu-header h3 {
            font-size: 1.05rem !important;
            font-weight: 700 !important;
            letter-spacing: -.01em;
        }

        #menu-channel-list {
            display: flex;
            flex-direction: column;
            gap: .5em;
            padding: .9375em 1.15em calc(1.15em + env(safe-area-inset-bottom));
            height: calc(100% - 4.5em);
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }

        .menu-status-button {
            width: 100%;
            justify-content: flex-start;
            text-align: left;
            min-height: 48px;
            padding: .75em 1em;
            border-radius: 12px;
            font-size: clamp(13px, 1vw, 15px);
            font-weight: 500;
        }

        .status-indicator {
            display: inline-block;
            width: 9px;
            height: 9px;
            border-radius: 50%;
            margin-right: .55em;
            flex-shrink: 0;
        }
        .status-live     { background-color: var(--green); box-shadow: 0 0 8px rgba(48, 209, 88, .6); }
        .status-not-live { background-color: var(--red); }
        .status-unknown  { background-color: #636366; }

        /* ---------------- 模態視窗 ---------------- */
        .modal-mask {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .82);
            z-index: 2000;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 16px;
            visibility: hidden;
            opacity: 0;
            transition: visibility 0.1s, opacity 0.1s;
            contain: strict;
        }
        .modal-mask.active { visibility: visible; opacity: 1; }

        .modal-panel {
            background: #1c1c1e;
            border: .5px solid rgba(255, 255, 255, .12);
            border-radius: 20px;
            width: 100%;
            max-width: 520px;
            padding: 1.5rem 1.4rem;
            box-shadow: 0 24px 70px rgba(0, 0, 0, .85);
            transform: scale(.94) translateY(10px);
            opacity: 0;
            
            contain: layout paint;
           
        }
        .modal-mask.active .modal-panel {
            transform: scale(1) translateY(0);
            opacity: 1;
        }

        .modal-panel h3 {
            font-size: 1.05rem;
            font-weight: 700;
            letter-spacing: -.01em;
            line-height: 1.4;
            color: var(--label);
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 1.15rem;
        }

        .modal-panel input[type="text"],
        .modal-panel select { width: 100%; }

        .delete-channel-list {
            max-height: 55vh;
            overflow-y: auto;
            margin: 1rem 0;
            background: #0b0b0d;
            border-radius: 14px;
            padding: .6rem;
            -webkit-overflow-scrolling: touch;
        }

        .channel-item-delete {
            display: flex;
            align-items: center;
            padding: 10px 12px;
            margin-bottom: 6px;
            background: var(--bg-1);
            border-radius: 12px;
            gap: 12px;
            transition: background-color .15s;
        }
        .channel-item-delete:last-child { margin-bottom: 0; }
        .channel-item-delete:hover { background: var(--bg-2); }

        .channel-item-delete input {
            width: 20px;
            height: 20px;
            min-width: 20px;
            padding: 0;
            cursor: pointer;
            accent-color: var(--green);
            flex-shrink: 0;
        }

        .channel-info {
            flex: 1;
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            min-width: 0;
        }
        .del-status-bullet {
            width: 9px;
            height: 9px;
            border-radius: 50%;
            display: inline-block;
            flex-shrink: 0;
        }
        .del-channel-name { font-weight: 500; font-size: .92rem; }
        .del-channel-meta {
            font-size: .68rem;
            color: var(--label-2);
            background: rgba(120, 120, 128, .24);
            padding: 2px 8px;
            border-radius: 20px;
        }

        .form-group { margin-bottom: 1.1rem; }
        .form-group label {
            display: block;
            font-size: .8rem;
            font-weight: 500;
            color: var(--label-2);
            margin-bottom: .45rem;
        }

        .modal-buttons {
            display: flex;
            gap: 12px;
            margin-top: 18px;
        }
        .modal-buttons button {
            flex: 1;
            height: 46px;
            border-radius: 12px;
            font-weight: 600;
            font-size: 1rem;
            justify-content: center;
        }
        .btn-confirm { background: var(--red); color: #fff; }
        .btn-confirm:hover { background: #ff5f55; }
        .btn-cancel {
            background: var(--bg-2);
            color: var(--label);
            border: none;
        }
        .btn-cancel:hover { background: var(--bg-3); }

        .select-all-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 0 12px 0;
            border-bottom: .5px solid var(--sep);
            margin-bottom: 4px;
        }
        .select-all-label {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            font-size: .85rem;
        }
        .select-all-label input {
            width: 20px;
            height: 20px;
            min-width: 20px;
            padding: 0;
            accent-color: var(--green);
            cursor: pointer;
        }

        /* ---------------- 看更台浮動面板 ---------------- */
        #channel-selection {
            display: none;
            position: fixed;
            top: 72px;
            right: 18px;
            z-index: 1000;
            width: 320px;
            max-height: 74vh;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
            padding: 18px;
            color: var(--label);
            background: #1c1c1e;
            border: .5px solid rgba(255, 255, 255, .12);
            border-radius: 20px;
            box-shadow: 0 24px 60px rgba(0, 0, 0, .8);
            contain: layout paint;
        }

        #channel-selection h3 {
            font-size: .95rem;
            font-weight: 700;
            margin-bottom: .8rem;
            letter-spacing: -.01em;
        }

        /* ============ 九宮格頻道選擇 ============ */
        #channel-options {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
            gap: 8px;
            margin-bottom: 6px;
        }

        .channel-option-cell {
            position: relative;
            min-width: 0;
        }

        #channel-options input[type="checkbox"] {
            position: absolute;
            width: 1px;
            height: 1px;
            opacity: 0;
            margin: 0;
            padding: 0;
            pointer-events: none;
        }

        #channel-options .channel-option-label {
            position: relative;
            display: flex;

            align-items: center;
            justify-content: center;
            gap: 3px;
            padding: 10px 6px;
            min-height: 64px;
            border-radius: 12px;
            background: var(--bg-1) !important;
            color: var(--label);
            font-size: .72rem;
            font-weight: 500;
            line-height: 1.15;
            text-align: center;
            cursor: pointer;
            overflow: hidden;
            user-select: none;
            -webkit-user-select: none;
            touch-action: manipulation;
            transition: background-color .16s ease, box-shadow .16s ease, transform .12s ease;
        }

        #channel-options .channel-option-label:active {
            transform: scale(.955);
        }

        #channel-options .channel-option-label.live,
        #channel-options .channel-option-label.unknown2 { color: var(--green) !important; }
        #channel-options .channel-option-label.not-live { color: var(--red) !important; }
        #channel-options .channel-option-label.unknown  { color: var(--label-2) !important; }

        #channel-options input:checked + .channel-option-label {
            background: rgba(10, 132, 255, .22) !important;
            box-shadow: inset 0 0 0 1.5px var(--blue);
            color: var(--label) !important;
        }

        #channel-options input:checked + .channel-option-label::after {
            content: "✓";
            position: absolute;
            top: 4px;
            right: 7px;
            font-size: .6rem;
            font-weight: 800;
            color: var(--blue);
            line-height: 1;
        }

        .channel-option-icon {
            font-size: 1.05rem;
            line-height: 1;
        }

        .channel-option-name {
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            letter-spacing: -.01em;
        }

        #channel-selection button {
            width: 100%;
            margin-top: 8px;
            justify-content: center;
        }

        /* ---------------- 手機適配 ---------------- */
        @media (max-width: 768px) {
            body { font-size: 14px; }

            #multi-stream-container-wrapper {
                flex-direction: column;
                padding: .625em;
                gap: 0;               /* 間距交給分隔條處理 */
                flex: 1;
                min-height: 0;
            }
             .chat {
        flex: var(--chat-flex, 3) 1 0;
        display: flex;
        flex-direction: column;
        min-height: 0 !important;   /* ★ 強制覆蓋 400px */
    }
            .chat iframe#chat_embed {
                flex: 1;
                width: 100%;
                height: 100%;
                border-radius: inherit;
            }
             .video-wrapper {
        flex: var(--video-flex, 4) 1 0;
        min-height: 0 !important;   /* ★ 強制覆蓋 400px */
        display: flex;
        flex-direction: column;
    }
            #multi-stream-container { flex: 1; min-height: 0; }

            #input-container {
                flex-wrap: nowrap;
                overflow-x: auto;
                padding-bottom: .3em;
                margin-top: 0;
                width: 100%;
                justify-content: flex-start;
                scrollbar-width: none;
            }
            #input-container::-webkit-scrollbar { display: none; }

            #mobile-menu-btn { display: inline-flex; }
            .top-container { flex-direction: column; align-items: stretch; gap: .5em; }
            #top-bar { padding: .5em; min-height: auto; }

            .modal-panel { padding: 1.2rem 1rem; width: 100%; }
            .delete-channel-list { max-height: 50vh; }

            #channel-selection {
                top: auto;
                bottom: 12px;
                left: 12px;
                right: 12px;
                width: auto;
                max-height: 62vh;
            }

            #channel-options {
                grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
                gap: 7px;
            }
        }

        @media (min-width: 769px) {
            #mobile-menu-btn { display: none !important; }
            #lists { display: flex; }
        }

        /* ---------------- 全域滾動條 ---------------- */
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb {
            background: rgba(235, 235, 245, .22);
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover { background: rgba(235, 235, 245, .4); }

        /* =====================================================================
           手機模式：影片 / 聊天 可拖曳分隔條
           ===================================================================== */
        #mobile-resizer { display: none; }

        @media (max-width: 768px) {
           #mobile-resizer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;        /* 從 22px 改成 36px */
    height: 36px;
    cursor: row-resize;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
            #mobile-resizer::before {
                content: "";
                width: 46px;
                height: 5px;
                border-radius: 999px;
                background: rgba(235, 235, 245, .25);
                transition: background-color .18s ease, transform .18s ease;
            }
            #mobile-resizer:active::before,
            #mobile-resizer.dragging::before {
                background: var(--green);
                transform: scaleY(1.4);
            }

            /* ★ 拖曳時提高層級，避免被 #top-bar 蓋住 */
            #mobile-resizer.dragging {
                z-index: 200;
            }

            /* 拖曳期間避免 iframe 搶事件 */
            #multi-stream-container-wrapper.resizing { cursor: row-resize; }
            #multi-stream-container-wrapper.resizing iframe,
            #multi-stream-container-wrapper.resizing video {
                pointer-events: none;
            }
        }

        /* ============ iOS 風格通知系統（輕量版） ============ */

        .modal-overlay {
            display: flex;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 20000;
            justify-content: center;
            align-items: center;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: opacity 0.22s ease, visibility 0.22s ease;
        }
        .modal-overlay.active {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .admin-panel {
            background: #1c1c1e;
            color: #ffffff;
            padding: 22px 20px 20px;
            border-radius: 18px;
            width: 90%;
            max-width: 360px;
            border: 0.5px solid rgba(255, 255, 255, 0.08);
            box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
            transform: scale(0.96);
            transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
            will-change: transform;
        }
        .modal-overlay.active .admin-panel {
            transform: scale(1);
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 14px;
            padding-bottom: 0;
            border-bottom: none;
        }
        .modal-header h2 {
            margin: 0;
            font-size: 17px;
            font-weight: 600;
            letter-spacing: -0.3px;
            color: #ffffff;
        }
        #close-admin-btn {
            font-size: 22px;
            line-height: 1;
            cursor: pointer;
            color: rgba(235, 235, 245, 0.6);
            padding: 0 6px;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
            transition: color 0.15s;
        }
        #close-admin-btn:hover { color: #ffffff; }

        #notice-input {
            width: 100%;
            height: 110px;
            margin: 0 0 16px 0;
            padding: 12px 14px;
            box-sizing: border-box;
            background: rgba(118, 118, 128, 0.24);
            border: none;
            color: #ffffff;
            border-radius: 12px;
            resize: none;
            font-family: inherit;
            font-size: 15px;
            line-height: 1.4;
            outline: none;
            transition: background-color 0.15s ease;
        }
        #notice-input::placeholder { color: rgba(235, 235, 245, 0.5); }
        #notice-input:focus { background: rgba(118, 118, 128, 0.34); }

        #send-btn {
            width: 100%;
            padding: 13px;
            background: #007aff;
            color: #ffffff;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            font-family: inherit;
            font-weight: 600;
            font-size: 16px;
            letter-spacing: -0.2px;
            transition: background-color 0.15s, transform 0.1s;
            -webkit-tap-highlight-color: transparent;
        }
        #send-btn:hover  { background: #0a84ff; }
        #send-btn:active { background: #0062c4; transform: scale(0.985); }

        /* ====== 右上角通知橫幅 ====== */
        #notification-pannel {
            position: fixed;
            top: 14px;
            right: 14px;
            width: 320px;
            max-width: calc(100% - 28px);
            background: rgba(28, 28, 30, 0.97);
            color: #ffffff;
            border-radius: 16px;
            padding: 14px 16px 12px;
            border: 0.5px solid rgba(255, 255, 255, 0.08);
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
            z-index: 30000;

            transform: translate3d(calc(100% + 20px), 0, 0);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1),
                        opacity   0.28s ease,
                        visibility 0.32s ease;
            will-change: transform, opacity;
        }
        #notification-pannel.show {
            transform: translate3d(0, 0, 0);
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .notice-header {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            font-weight: 600;
            color: rgba(235, 235, 245, 0.65);
            letter-spacing: -0.1px;
            margin-bottom: 6px;
        }
        #notice-content {
            font-size: 14px;
            line-height: 1.5;
            color: #ffffff;
            margin-bottom: 12px;
            word-wrap: break-word;
            white-space: pre-wrap;
        }

        .close-notice-btn {
            float: right;
            background: rgba(255, 255, 255, 0.12);
            border: none;
            color: #ffffff;
            padding: 6px 14px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            border-radius: 10px;
            font-family: inherit;
            transition: background-color 0.15s;
            -webkit-tap-highlight-color: transparent;
        }
        .close-notice-btn:hover  { background: rgba(255, 255, 255, 0.2); }
        .close-notice-btn:active { background: rgba(255, 255, 255, 0.3); }
		
		@media (max-width: 768px) {
    /* 解鎖 #multi-stream-container 的高度束縛 */
    #multi-stream-container {
        height: auto !important;
        min-height: 0 !important;
    }
    /* 兩個 pane 都不准有最小高度 */
    #multi-stream-container,
    #chat_embed,
    .video-wrapper,
    .chat {
        min-height: 0 !important;
        max-height: none !important;
    }
}

        /* =====================================================================
           平台圖片圖標樣式
           ===================================================================== */
        .platform-icon-img {
            width: 20pxem;
            height: 20pxem;
            vertical-align: middle;
            object-fit: contain;
            display: inline-block;
            margin-right: 0.25em;
        }
        .channel-option-icon .platform-icon-img {
            width: 1.2em;
            height: 1.2em;
            margin-right: 0;
        }
        .del-channel-name .platform-icon-img {
            width: 1em;
            height: 1em;
            margin-right: 0.3em;
        }
        .status-button .platform-icon-img,
        .menu-status-button .platform-icon-img {
            width: 20px;
            height:20px;
            margin-right: 0.3em;
        }
    

/* ===== Chat CSS ===== */

        :root { --t-bg: #0e0e10; --t-alt: #18181b; --t-purp: #9147ff; --t-text: #efeff1; --input-bg: #18181b; }
        .chat-app { background: var(--t-bg); color: var(--t-text); font-family: sans-serif; margin: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden;   --bg-base: #09090b;
            --bg-surface: #18181b;
            --bg-surface-hover: #1f1f23;
            --bg-surface-active: #26262c;
            --bg-panel: #18181b; 
            
            --t-purp: #9147ff;
            --t-purp-hover: #a970ff;
            --t-purp-muted: rgba(145, 71, 255, 0.15);
            --t-purp-border: rgba(145, 71, 255, 0.3);
            
            --text-main: #efeff1;
            --text-muted: #adadb8;
            --text-inverse: #09090b;
            
            --danger: #e91916;
            --danger-hover: #c51614;
            --success: #2ea043;
            
            --border-color: rgba(255, 255, 255, 0.08);
            --border-strong: rgba(255, 255, 255, 0.15);
            
            --radius-sm: 6px;
            --radius-md: 8px;
            --radius-lg: 12px;
            --radius-round: 50%;
            
            --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
            
            --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
            --transition-fast: 0.15s ease;
            --transition-normal: 0.25s ease;

            /* === 統一媒體大小設定（可由設定面板調整） === */
            --media-img-max-height: 180px;
            --media-video-max-height: 250px; }
        
        #chat-container::-webkit-scrollbar, #emojiContent::-webkit-scrollbar, #emojiTabs::-webkit-scrollbar, #mention-list::-webkit-scrollbar { width: 8px; height: 8px; }
        #chat-container::-webkit-scrollbar-track, #emojiContent::-webkit-scrollbar-track, #emojiTabs::-webkit-scrollbar-track, #mention-list::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
        #chat-container::-webkit-scrollbar-thumb, #emojiContent::-webkit-scrollbar-thumb, #emojiTabs::-webkit-scrollbar-thumb, #mention-list::-webkit-scrollbar-thumb { background: #444; border-radius: 10px; }
        #chat-container::-webkit-scrollbar-thumb:hover, #emojiContent::-webkit-scrollbar-thumb:hover, #emojiTabs::-webkit-scrollbar-thumb:hover, #mention-list::-webkit-scrollbar-thumb:hover { background: var(--t-purp); }

        /* ================= 統一控制媒體嵌入大小 ================= */
        #chat-container .media-preview,
        #chat-container iframe.media-preview,
        #chat-container iframe[src*="youtube.com"],
        #chat-container iframe[src*="youtube-nocookie.com"],
        #chat-container iframe[src*="youtu.be"],
        #chat-container iframe[src*="facebook.com"],
        #chat-container blockquote.twitter-tweet,
        #chat-container .twitter-tweet-container,
        #chat-container iframe[src*="store.steampowered.com"],
        #chat-container iframe[src*="threads.com"] {
            width: auto !important;
            height: auto !important;
            max-width: 300px !important;
            border-radius: 8px !important;
            border: 0px solid #444 !important;
            margin: 5px 0 !important;
            object-fit: fill !important; 
        }
        #chat-container iframe[src*="youtube.com"],
        #chat-container iframe[src*="youtube-nocookie.com"],
        #chat-container blockquote.twitter-tweet,
        #chat-container iframe[src*="threads.com"],
        #chat-container iframe[src*="store.steampowered.com"] {
            min-height: 400px !important;
            max-height: 400px !important;
        }
        #chat-container iframe[src*="facebook.com"],
        #chat-container iframe[src*="youtu.be"],
        #chat-container .twitter-tweet-container {
            max-height: 450px !important;
        }
        #chat-container iframe[src*="threads.com"] { background: #FFF !important; }
        #chat-container img.media-preview {
            max-height: var(--media-img-max-height) !important;
            min-height: auto !important;
        }
        #chat-container video.media-preview {
            max-height: var(--media-video-max-height) !important;
            min-height: auto !important;
        }

        .header-bar { 
            background: #121214; 
            padding: 3px 5px; 
            display: flex; 
            justify-content: space-between; 
            align-items: center; 
            border-bottom: 1px solid var(--border-color); 
            flex-shrink: 0; 
            z-index: 100;
        }
        #chat-container { flex: 1; overflow-y: auto; padding: 15px; background: #0e0e10; scroll-behavior: smooth; position: relative; word-wrap: break-word; overflow-wrap: break-word; }
        
        .chat-line { 
            position: relative; 
            border-radius: 4px; 
			max-width: 95%;
            line-height: 1.6; 
            word-wrap: break-word; 
            color: var(--t-text); 
            transition: background 0.3s, border 0.3s; 
            padding: 1px 1px 18px 1px; 
            margin-bottom: 5px; 
            border: 1px solid transparent;
            content-visibility: visible !important;
            contain-intrinsic-size: 0 40px; 
			font-family: 'Noto Sans TC', sans-serif, Meiryo, arial, helvetica, sans-serif;
        }

        .chat-line:hover { background: rgba(255,255,255,0.08); }
        .chat-line:has(.quote-box) { border: 1px solid #9147ff; background: rgba(145, 71, 255, 0.1) !important; margin-left: 2px; }
        .self-name { font-weight: bold; }
        .media-preview { max-width: 250px !important; max-height: 250px !important; border-radius: 6px; margin-top: 10px; vertical-align: top; display: block; border: 1px solid #444; }
       .quote-user { color: #adadb8; margin-right: 5px; }
       .mention-self-tag { background-color: #9147ff; color: #ffffff !important; padding: 2px 6px; border-radius: 4px; font-weight: bold; display: inline-block; margin-bottom: 2px; }
        .audio-player { margin-top: 10px; display: block; max-width: 300px; }
        .alt-emoji { max-width: 150px !important; max-height: 150px !important; vertical-align: top; margin: 2px; }
        .badge { width: 18px; height: 18px; margin-right: 4px; display: inline-block; }
       .btn-danger:hover { background: var(--danger); color: white; }
       .btn-primary {
            background: var(--t-purp); color: white; border: none; border-radius: var(--radius-sm);
            padding: 8px 16px; cursor: pointer; font-size: 13px; font-weight: 600; 
            transition: background var(--transition-fast), transform var(--transition-fast);
        }
        .btn-primary:hover { background: var(--t-purp-hover); transform: translateY(-1px); }

        /* ===================== 統一時間戳 (所有主題右下角) ===================== */
        .msg-time {
            position: static !important;
            display: inline !important;
            margin: 0 3px 0 0 !important;
            padding: 0 !important;
            color: #dadada !important;
            font-size: 15px !important;
            line-height: 1.5 !important;
            font-weight: normal !important;
            pointer-events: auto !important;
            user-select: text !important;
            white-space: nowrap;
            opacity: 1 !important;
            bottom: auto !important;
            right: auto !important;
            vertical-align: baseline;
            text-shadow: none;
        }
        .chat-app.hide-timestamps .msg-time { display: none; }
        .chat-app.hide-timestamps .chat-line { padding-bottom: 1px !important; }
        .chat-app.hide-timestamps.theme-discord .chat-line { padding-bottom: 8px !important; }
        .chat-app.hide-timestamps.theme-whatsapp .chat-line { padding-bottom: 6px !important; }
        .chat-app.hide-timestamps.theme-whatsapp-dark .chat-line { padding-bottom: 6px !important; }
        .chat-app.hide-timestamps.theme-sk .chat-line { padding-bottom: 0 !important; margin-bottom: 4px !important; }

@keyframes blink {
    50% { opacity: 0.7; }
}

.control-btn { transition: all 0.3s ease; }
        .reply-btn-group {
            position: absolute;
            right: -30px;
            top: 4px;
            display: flex;
            gap: 2px;
            z-index: 10;
			align-content: center;
            flex-direction: column;
        }
        .reply-btn, .reply-btn2 {
            width: 25px;
            height: 25px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: #fff;
            font-size: 14px;
            background: rgba(0,0,0,0.7);
            border: 1px solid #555;
            transition: all 0.15s;
        }
        .reply-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
        .reply-btn:hover, .reply-btn2:hover { background-color: #9147ff; border-color: #fff; transform: scale(1.05);}
        .chat-line:hover .reply-btn-group { display: flex; }
        .reply-btn-group { display: none; }
		.chat-app.theme-sk .chat-line .chat-line::after{
          
        }
		.chat-line::after {
         content: '';
        position: absolute;
        top: 0;
        right: -35px;          /* 比按鈕的 -30px 再往外 5px 保險 */
         width: 35px;
        height: 100%;
        background: transparent;
        pointer-events: auto;  /* 捕捉滑鼠，維持 .chat-line:hover */
}
        
        .quote-box { 
            color: #adadb8; 
            padding: 6px 8px; 
            border-radius: 8px; 
            margin-bottom: 6px; 
            margin-top: 2px;
            line-height: 1.45; 
            display: block; 
            cursor: pointer; 
            border: 1px solid rgba(255,255,255,0.08);
            background: rgba(0, 0, 0, 0.2);
            transition: all 0.1s ease;
            word-break: break-word;
        }
        .quote-box:hover { background: rgba(145, 71, 255, 0.15); border-color: rgba(145, 71, 255, 0.4); }
        .quote-box .quote-box {
            margin-left: 12px;
            border-left: 3px solid #9147ff;
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;
            background: rgba(20, 20, 30, 0.4);
        }
        
        #scrollToBottomBtn {
            position: absolute;
            bottom: 80px;
            right: 20px;
            width: 40px;
            height: 40px;
            background: rgba(145, 71, 255, 0.8);
            color: white;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 100;
            box-shadow: 0 2px 10px rgba(0,0,0,0.5);
            transition: all 0.3s ease;
            font-size: 20px;
        }
        #scrollToBottomBtn:hover { background: rgba(145, 71, 255, 1); transform: scale(1.1); }
        
        .delete-btn { position: absolute;top: -8px;right: -8px;background: #e91916;color: white;width: 20px;height: 20px;border-radius: 50%;font-size: 12px;line-height: 20px;text-align: center;cursor: pointer;display: none; z-index: 100; border: 1px solid white; box-shadow: 0 0 5px rgba(0,0,0,0.5); }
        .show-del .delete-btn { display: block; }
        .audio-item { cursor:pointer; background:rgba(145,71,255,0.1); border:1px solid #444; border-radius:4px; padding:8px; text-align:center; font-size:11px; position:relative; color: #fff; display:flex; flex-direction:column; align-items:center; gap:4px; min-width:60px; }
        .audio-icon-btn { cursor: pointer; font-size: 20px; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; padding: 5px; background: rgba(145, 71, 255, 0.2); border-radius: 50%; transition: all 0.2s ease; user-select: none; width: 30px; height: 30px; color: var(--t-text); }
        .audio-icon-btn:hover { background: rgba(145, 71, 255, 0.4); }
        .audio-icon-btn.playing { background: #9147ff; color: white; border-color: white; animation: pulse-audio 1.5s infinite; }
        .audio-icon-btn svg { width: 16px; height: 16px; fill: currentColor; display: block; }
        .audio-item svg.audio-item-icon { width: 18px; height: 18px; fill: currentColor; }
        
        @keyframes pulse-audio {
            0% { box-shadow: 0 0 0 0px rgba(145, 71, 255, 0.7); }
            70% { box-shadow: 0 0 0 10px rgba(145, 71, 255, 0); }
            100% { box-shadow: 0 0 0 0px rgba(145, 71, 255, 0); }
        }
        
        .wa-audio-player {
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--bg-surface-active);
            padding: 6px 14px;
            border-radius: 24px;
            max-width: 90%;
            width: 100%;
            box-sizing: border-box;
            vertical-align: middle;
            margin: 4px 0;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
            user-select: none;
            border: 1px solid var(--border-color);
        }
        .wa-play-btn {
            background: none; border: none; cursor: pointer; padding: 0;
            display: flex; align-items: center; justify-content: center;
            color: var(--t-purp); width: 26px; height: 26px; flex-shrink: 0;
        }
        .wa-play-btn svg { width: 24px; height: 24px; fill: currentColor; }
        .wa-duration {
            font-size: 12px; color: var(--text-muted); font-family: monospace;
            flex-shrink: 0; min-width: 34px; text-align: right;
        }
        .wa-waveform {
            flex: 1; 
            min-width: 40px;
            height: 26px; display: flex; align-items: center;
            overflow: hidden; color: var(--t-purp); opacity: 0.5; transition: opacity 0.2s;
        }
        .wa-waveform.playing { opacity: 1; }
        .wave-svg { width: 100%; height: 100%; fill: currentColor; }
        
        #userInfo { display: none; align-items: center; gap: 8px; font-size: 13px; }
        #userInfo img { width: 30px; height: 30px; border-radius: 50%; }
        #logoutBtn { background: #e91916; color: white; border: none; border-radius: 4px; padding: 6px 12px; cursor: pointer; font-size: 12px; font-weight: 600; transition: background-color 0.2s; margin-left: 8px; }
        #logoutBtn:hover { background: #c51614; }
        #loginBtn { background: #9147ff; color: white; border: none; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600; transition: background-color 0.2s; padding: 8px 16px; }
        #loginBtn:hover { background: #772ce8; }
        #status { 
            font-weight: 600; color: var(--t-purp); font-size: 13px; 
            display: none; align-items: center; gap: 8px;
        }
        #status::before {
            content: ''; display: block; width: 8px; height: 8px;
            background-color: var(--t-purp); border-radius: 50%;
            animation: pulse-status 2s infinite; will-change: opacity;
        }
        @keyframes pulse-status {
            0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; }
        }
        
        #mention-list {
            position: absolute; bottom: 100%; left: 0; width: 300px; max-height: 350px;
            background: var(--t-alt); border: 1px solid #333; border-radius: 6px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 9999; display: none;
            overflow-y: auto; padding: 4px 0;
        }
        .mention-item {
            padding: 8px 12px; cursor: pointer; display: flex; align-items: center;
            gap: 8px; transition: background 0.2s; color: var(--t-text); font-size: 14px;
        }
        .mention-item:hover, .mention-item.selected { background: rgba(145, 71, 255, 0.2); }
        .mention-item .user-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
        .mention-item .display-name { font-weight: 600; color: var(--t-purp); }
        .mention-item .login-name { color: #adadb8; font-size: 12px; margin-left: 4px; }
        .mention-header {
            padding: 8px 12px; font-size: 12px; color: #adadb8;
            border-bottom: 1px solid #333; margin-bottom: 4px; background: rgba(0,0,0,0.2);
        }

        .footer { 
            background: #121214; padding: 5px 5px; 
            border-top: 1px solid var(--border-color); position: relative; z-index: 100;
        }
        #reply-indicator { display:none; color:#adadb8; font-size:12px; margin-bottom:8px; padding:8px; background:rgba(145,71,255,0.1); border-radius:4px; border: 1px solid rgba(145,71,255,0.3); }
       .input-section { display: flex; flex-direction: column; gap: 8px; position: relative; }
        
        .tool-bar { display: flex; gap: 1px; align-items: center; padding-left: 4px; height:13px;}
        .tool-link { 
            background: none; border: none; color: var(--text-muted); 
            cursor: pointer; font-size: 13px; padding: 1px; font-weight: 500; 
            transition: all var(--transition-fast); display: flex; align-items: center; gap: 1px;
            border-radius: var(--radius-sm);
        }
        .tool-link:hover { color: var(--text-main); background: var(--bg-surface-active); }
        .tool-link svg { fill: currentColor; width: 16px; height: 16px; }

        .input-box-wrapper { 
            display: flex; align-items: flex-end; 
            background: var(--bg-surface); border: 1px solid var(--border-strong); 
            border-radius: var(--radius-md); padding: 8px 12px; 
            transition: all var(--transition-fast);
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
        }
        .input-box-wrapper:focus-within { border-color: var(--t-purp); background: var(--bg-base); box-shadow: 0 0 0 2px var(--t-purp-muted); }
        
        .chat-badge-carousel {
            display: flex; align-items: center; gap: 4px;
            padding-right: 8px; border-right: 1px solid var(--border-strong);
            margin-right: 8px; margin-bottom: 4px;
        }
        .chat-badge-carousel:empty { display: none; padding: 0; margin: 0; border: none; }
        .chat-badge-carousel img.badge { width: 18px; height: 18px; margin-right: 0; }

        #msginput { 
            flex: 1; background: transparent; border: none; color: var(--text-main); 
            font-size: 15px; outline: none; padding: 4px 0; font-family: inherit; 
            overflow-wrap: break-word; max-height: 150px; overflow: hidden auto;
            white-space: pre-wrap; min-height: 24px; line-height: 1.5;
        }
        #msginput:empty:before { content: attr(placeholder); color: var(--text-muted); pointer-events: none; }
        #msginput:disabled { cursor: not-allowed; opacity: 0.5; }
        #msginput::-webkit-scrollbar {width: 6px;}
        #msginput::-webkit-scrollbar-track {background: transparent;}
        #msginput::-webkit-scrollbar-thumb {background: #888;border-radius: 10px;}
        #msginput::-webkit-scrollbar-thumb:hover {background: #555;}
        .action-bar { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
        
        #voice-btn {
            background: transparent; border: none; font-size: 18px;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            width: 36px; height: 36px; border-radius: var(--radius-round);
            transition: all var(--transition-fast); color: var(--text-muted);
			display:none;
        }
        #voice-btn:hover { background: var(--bg-surface-active); color: var(--text-main); }
        #voice-btn.recording { color: var(--danger); background: rgba(233, 25, 22, 0.1); animation: blink 1s infinite; }
        @keyframes blink { 50% { opacity: 0.4; } }

        #sendbtn { 
            background: var(--t-purp); border: none; color: white; cursor: pointer; 
            padding: 8px 20px; border-radius: var(--radius-md); font-weight: 600; font-size: 14px; 
            transition: all var(--transition-fast);
        }
        #sendbtn:hover:not(:disabled) { background: var(--t-purp-hover); transform: translateY(-1px); }
        #sendbtn:disabled { background: var(--bg-surface-active); color: var(--text-muted); cursor: not-allowed; }

        .setting-btn { 
            cursor: pointer; color: var(--text-muted); padding: 0px; 
            border-radius: var(--radius-sm); display: flex; align-items: center;
            transition: all var(--transition-fast); display:block;
			margin-left:auto;
        }
        .setting-btn:hover { color: var(--t-purp); background: var(--bg-surface-active); }

        #emojiPanel { 
            position: fixed; display: none; width: 350px; height: 400px; 
            background: #1f182e; border: 2px solid #443a5a; border-radius: 12px; 
            z-index: 5000; left: 50%; top: 50%; transform: translate(-50%, -50%); 
            flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            cursor: default;
        }
        #emojiPanel.dragging { cursor: grabbing; }
        .emoji-header { 
            padding: 12px; display: flex; justify-content: space-between; 
            background: #26262c; border-radius: 12px 12px 0 0; align-items: center;
            cursor: grab; user-select: none;
        }
        .emoji-header:active { cursor: grabbing; }
        #emojiTabs {display: flex;flex-wrap: wrap;background: #1f1f23;padding: 8px;gap: 5px;overflow-x auto;border-bottom: 1px solid #26262c;}
        #emojiContent { flex: 1;overflow-y: auto;padding: 10px;background: #18181b;display: flex;flex-wrap: wrap;gap: 5px;align-content: flex-start; }
        .emoji-tab { width: 36px;height: 36px;background: #3a3a3d;border-radius: 4px;cursor: pointer;background-size: cover;background-position: center;flex-shrink: 0;display:flex;align-items:center;justify-content:center;color:#fff; }
        .emoji-tab svg { width: 20px; height: 20px; fill: currentColor; }
        .emoji-item { position: relative;width: 40px;height: 40px;border-radius: 4px;cursor: pointer;}
        .emoji-item img {width: 40px;height: 40px;border-radius: 4px;cursor: pointer;}
        .bttv-input-area, .audio-input-form { width: 100%;display: flex;gap: 6px;margin-bottom: 10px; }
        .custom-input { background: #000; border: 1px solid #444; color: #fff; padding: 8px; border-radius: 4px; }



.emoji-item .bttv-video-preview {
    width: 40px;
    height: 40px;
    object-fit: cover;  /* 裁切填滿，不變形、不 letterbox */
    display: block;
    border-radius: 4px;
    background: #000;
    pointer-events: none; /* 讓點擊事件交給父層 .emoji-item 處理 */
}

/* ===================== 主題：WhatsApp 群組聊天 (淺色) ===================== */
        .chat-app.theme-whatsapp {
            --t-bg: #efeae2;
            --t-alt: #ffffff;
            --t-purp: #00a884;
            --t-purp-hover: #06cf9c;
            --t-purp-muted: rgba(0, 168, 132, 0.15);
            --t-purp-border: rgba(0, 168, 132, 0.35);
            --t-text: #111b21;
            --text-main: #111b21;
            --text-muted: #667781;
            --text-inverse: #ffffff;
            --bg-base: #ffffff;
            --bg-surface: #ffffff;
            --bg-surface-hover: #f0f2f5;
            --bg-surface-active: #e9edef;
            --bg-panel: #ffffff;
            --border-color: rgba(0, 0, 0, 0.1);
            --border-strong: rgba(0, 0, 0, 0.15);
            --danger: #ea4335;
            background: #efeae2;
            color: #111b21;
        }

        .chat-app.theme-whatsapp .header-bar {
            background: #008069;
            border-bottom-color: rgba(0, 0, 0, 0.15);
        }
        .chat-app.theme-whatsapp #status { color: #ffffff; }
        .chat-app.theme-whatsapp #status::before { background-color: #9cf0d5; }
        .chat-app.theme-whatsapp #userName { color: #ffffff; }
        .chat-app.theme-whatsapp #loginBtn { background: #ffffff; color: #008069; }
        .chat-app.theme-whatsapp #loginBtn:hover { background: #f0f2f5; }
        .chat-app.theme-whatsapp #logoutBtn { background: rgba(255, 255, 255, 0.18); }
        .chat-app.theme-whatsapp #logoutBtn:hover { background: rgba(255, 255, 255, 0.3); }

        .chat-app.theme-whatsapp #chat-container {
            background: #efeae2;
            padding: 0;
        }
        .chat-app.theme-whatsapp #messages {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            padding: 10px 12px 10px 12px;
            min-height: 100%;
            box-sizing: border-box;
        }

        .chat-app.theme-whatsapp .chat-line {
            position: relative;
            width: fit-content;
            max-width: 95%;
            background: #ffffff;
            border-radius: 7.5px;
            border-top-left-radius: 0;
            padding: 6px 9px 19px 9px;
            margin-bottom: 2px;
            margin-left: 8px;
            color: #111b21;
            font-size: 14.2px;
            line-height: 19px;
            box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
            overflow: visible;
            border: 1px solid transparent;
        }
        .chat-app.theme-whatsapp .chat-line::before {
            content: '';
            position: absolute;
            top: 0;
            left: -7px;
            width: 8px;
            height: 13px;
            background: #ffffff;
            border-bottom-right-radius: 12px;
            z-index: 1;
        }
        .chat-app.theme-whatsapp .chat-line:hover {
            background: #ffffff;
            box-shadow: 0 2px 4px rgba(11, 20, 26, 0.15);
        }

        .chat-app.theme-whatsapp .chat-line.msg-self {
            background: #d9fdd3;
            align-self: flex-end;
            margin-right: 8px;
            margin-left: 0;
            border-top-left-radius: 7.5px;
            border-top-right-radius: 0;
        }
        .chat-app.theme-whatsapp .chat-line.msg-self::before {
            left: auto;
            right: -7px;
            background: #d9fdd3;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 12px;
        }
        .chat-app.theme-whatsapp .chat-line.msg-self:hover { background: #d9fdd3; }

        .chat-app.theme-whatsapp .chat-line:has(.wa-audio-player) {
            width: 100%;
            max-width: 95%;
        }

        .chat-app.theme-whatsapp .chat-line b:not(.self-name) {
            
            font-size: 13px;
            font-weight: 500;
            margin-bottom: 2px;
            letter-spacing: 0.2px;
        }
        

        .chat-app.theme-whatsapp .msg-time {
            color: rgba(17, 27, 33, 0.45);
            opacity: 1;
            bottom: 3px;
            right: 9px;
        }

        .chat-app.theme-whatsapp .chat-line:has(.quote-box) {
            background: #ffffff !important;
            border: 1px solid transparent !important;
            margin-left: 8px;
        }
        .chat-app.theme-whatsapp .chat-line.msg-self:has(.quote-box) {
            background: #d9fdd3 !important;
        }
        .chat-app.theme-whatsapp .quote-box {
            background: rgba(0, 0, 0, 0.05);
            border: 1px solid rgba(0, 0, 0, 0.06);
            border-left: 3px solid #00a884;
            color: #667781;
        }
        .chat-app.theme-whatsapp .quote-box:hover { background: rgba(0, 0, 0, 0.08); }
        .chat-app.theme-whatsapp .quote-user { color: #00a884; font-weight: 600; }
        .chat-app.theme-whatsapp .quote-box .quote-box {
            border-left: 3px solid #00a884;
            background: rgba(0, 0, 0, 0.04);
        }
        .chat-app.theme-whatsapp .mention-self-tag {
            background-color: #00a884;
            color: #ffffff !important;
        }

        .chat-app.theme-whatsapp #chat-container img.media-preview,
        .chat-app.theme-whatsapp #chat-container video.media-preview {
            border-color: rgba(0, 0, 0, 0.08) !important;
        }

        .chat-app.theme-whatsapp .footer {
            background: #f0f2f5;
            border-top-color: rgba(0, 0, 0, 0.08);
        }
        .chat-app.theme-whatsapp .tool-link { color: #667781; }
        .chat-app.theme-whatsapp .tool-link:hover { color: #008069; background: #e9edef; }
        .chat-app.theme-whatsapp .setting-btn { color: #667781; }
        .chat-app.theme-whatsapp .setting-btn:hover { color: #008069; background: #e9edef; }
        .chat-app.theme-whatsapp .input-box-wrapper {
            background: #ffffff;
            border-color: transparent;
            border-radius: 20px;
            box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
        }
        .chat-app.theme-whatsapp .input-box-wrapper:focus-within {
            border-color: #00a884;
            background: #ffffff;
            box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.2);
        }
        .chat-app.theme-whatsapp #msginput { color: #111b21; }
        .chat-app.theme-whatsapp #msginput:empty:before { color: #667781; }
        .chat-app.theme-whatsapp #sendbtn {
            background: #00a884;
            border-radius: 20px;
            color: #ffffff;
        }
        .chat-app.theme-whatsapp #sendbtn:hover:not(:disabled) { background: #06cf9c; }
        .chat-app.theme-whatsapp #sendbtn:disabled { background: #d1d7db; color: #8696a0; }

        .chat-app.theme-whatsapp #reply-indicator {
            background: rgba(0, 168, 132, 0.08);
            border: 1px solid rgba(0, 168, 132, 0.3);
            color: #667781;
        }
        .chat-app.theme-whatsapp #reply-indicator span { color: #00a884; }

        .chat-app.theme-whatsapp .reply-btn,
        .chat-app.theme-whatsapp .reply-btn2 {
            background: rgba(0, 0, 0, 0.55);
            border-color: rgba(255, 255, 255, 0.5);
        }
        .chat-app.theme-whatsapp .reply-btn:hover,
        .chat-app.theme-whatsapp .reply-btn2:hover { background-color: #00a884; }

        .chat-app.theme-whatsapp #scrollToBottomBtn {
            background: rgba(0, 168, 132, 0.9);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
        }
        .chat-app.theme-whatsapp #scrollToBottomBtn:hover { background: #00a884; }

        .chat-app.theme-whatsapp #mention-list {
            background: #ffffff;
            border-color: rgba(0, 0, 0, 0.1);
            color: #111b21;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        }
        .chat-app.theme-whatsapp .mention-item { color: #111b21; }
        .chat-app.theme-whatsapp .mention-item:hover,
        .chat-app.theme-whatsapp .mention-item.selected { background: rgba(0, 168, 132, 0.15); }
        .chat-app.theme-whatsapp .mention-item .display-name { color: #00a884; }
        .chat-app.theme-whatsapp .mention-item .login-name { color: #667781; }
        .chat-app.theme-whatsapp .mention-header {
            color: #667781;
            border-bottom-color: rgba(0, 0, 0, 0.08);
            background: rgba(0, 0, 0, 0.02);
        }

        .chat-app.theme-whatsapp .wa-audio-player {
            background: #e9edef;
            border-color: rgba(0, 0, 0, 0.08);
        }
        .chat-app.theme-whatsapp .wa-play-btn { color: #00a884; }
        .chat-app.theme-whatsapp .wa-duration { color: #667781; }
        .chat-app.theme-whatsapp .wa-waveform { color: #00a884; }
        .chat-app.theme-whatsapp .audio-icon-btn { background: rgba(0, 168, 132, 0.15); color: #008069; }
        .chat-app.theme-whatsapp .audio-icon-btn.playing { background: #00a884; color: #ffffff; }

        .chat-app.theme-whatsapp #settingsPanel {
            background: #ffffff;
            color: #111b21;
        }

/* ===================== 主題：WhatsApp 群組聊天 (深色) ===================== */
        .chat-app.theme-whatsapp-dark {
            --t-bg: #0b141a;
            --t-alt: #202c33;
            --t-purp: #00a884;
            --t-purp-hover: #06cf9c;
            --t-purp-muted: rgba(0, 168, 132, 0.18);
            --t-purp-border: rgba(0, 168, 132, 0.38);
            --t-text: #e9edef;
            --text-main: #e9edef;
            --text-muted: #8696a0;
            --text-inverse: #0b141a;
            --bg-base: #0b141a;
            --bg-surface: #202c33;
            --bg-surface-hover: #2a3942;
            --bg-surface-active: #2a3942;
            --bg-panel: #111b21;
            --border-color: rgba(255, 255, 255, 0.08);
            --border-strong: rgba(255, 255, 255, 0.16);
            --danger: #f15c6d;
            background: #0b141a;
            color: #e9edef;
        }

        .chat-app.theme-whatsapp-dark .header-bar {
            background: #202c33;
            border-bottom-color: rgba(255, 255, 255, 0.08);
        }
        .chat-app.theme-whatsapp-dark #status { color: #e9edef; }
        .chat-app.theme-whatsapp-dark #status::before { background-color: #00a884; }
        .chat-app.theme-whatsapp-dark #userName { color: #e9edef; }
        .chat-app.theme-whatsapp-dark #loginBtn { background: #00a884; color: #ffffff; }
        .chat-app.theme-whatsapp-dark #loginBtn:hover { background: #06cf9c; }
        .chat-app.theme-whatsapp-dark #logoutBtn { background: rgba(255, 255, 255, 0.12); }
        .chat-app.theme-whatsapp-dark #logoutBtn:hover { background: rgba(255, 255, 255, 0.22); }

        .chat-app.theme-whatsapp-dark #chat-container {
            background: #0b141a;
            padding: 0;
        }
        .chat-app.theme-whatsapp-dark #messages {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            padding: 10px 12px 10px 12px;
            min-height: 100%;
            box-sizing: border-box;
        }

        .chat-app.theme-whatsapp-dark .chat-line {
            position: relative;
            width: fit-content;
            max-width: 95%;
            background: #202c33;
            border-radius: 7.5px;
            border-top-left-radius: 0;
            padding: 6px 9px 19px 9px;
            margin-bottom: 2px;
            margin-left: 8px;
            color: #e9edef;
            font-size: 14.2px;
            line-height: 19px;
            box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.35);
            overflow: visible;
            border: 1px solid transparent;
        }
        .chat-app.theme-whatsapp-dark .chat-line::before {
            content: '';
            position: absolute;
            top: 0;
            left: -7px;
            width: 8px;
            height: 13px;
            background: #202c33;
            border-bottom-right-radius: 12px;
            z-index: 1;
        }
        .chat-app.theme-whatsapp-dark .chat-line:hover {
            background: #2a3942;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
        }

        .chat-app.theme-whatsapp-dark .chat-line.msg-self {
            background: #005c4b;
            align-self: flex-end;
            margin-right: 8px;
            margin-left: 0;
            border-top-left-radius: 7.5px;
            border-top-right-radius: 0;
        }
        .chat-app.theme-whatsapp-dark .chat-line.msg-self::before {
            left: auto;
            right: -7px;
            background: #005c4b;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 12px;
        }
        .chat-app.theme-whatsapp-dark .chat-line.msg-self:hover { background: #005c4b; }

        .chat-app.theme-whatsapp-dark .chat-line:has(.wa-audio-player) {
            width: 100%;
            max-width: 95%;
        }

        .chat-app.theme-whatsapp-dark .chat-line b:not(.self-name) {
            font-size: 13px;
            font-weight: 500;
            margin-bottom: 2px;
            letter-spacing: 0.2px;
        }

        .chat-app.theme-whatsapp-dark .msg-time {
            color: rgba(233, 237, 239, 0.5);
            opacity: 1;
            bottom: 3px;
            right: 9px;
        }

        .chat-app.theme-whatsapp-dark .chat-line:has(.quote-box) {
            background: #202c33 !important;
            border: 1px solid transparent !important;
            margin-left: 8px;
        }
        .chat-app.theme-whatsapp-dark .chat-line.msg-self:has(.quote-box) {
            background: #005c4b !important;
        }
        .chat-app.theme-whatsapp-dark .quote-box {
            background: rgba(0, 0, 0, 0.22);
            border: 1px solid rgba(255, 255, 255, 0.06);
            border-left: 3px solid #00a884;
            color: #8696a0;
        }
        .chat-app.theme-whatsapp-dark .quote-box:hover { background: rgba(0, 0, 0, 0.32); }
        .chat-app.theme-whatsapp-dark .quote-user { color: #00a884; font-weight: 600; }
        .chat-app.theme-whatsapp-dark .quote-box .quote-box {
            border-left: 3px solid #00a884;
            background: rgba(0, 0, 0, 0.18);
        }
        .chat-app.theme-whatsapp-dark .mention-self-tag {
            background-color: #00a884;
            color: #ffffff !important;
        }

        .chat-app.theme-whatsapp-dark #chat-container img.media-preview,
        .chat-app.theme-whatsapp-dark #chat-container video.media-preview {
            border-color: rgba(255, 255, 255, 0.08) !important;
        }

        .chat-app.theme-whatsapp-dark .footer {
            background: #202c33;
            border-top-color: rgba(255, 255, 255, 0.08);
        }
        .chat-app.theme-whatsapp-dark .tool-link { color: #8696a0; }
        .chat-app.theme-whatsapp-dark .tool-link:hover { color: #00a884; background: #2a3942; }
        .chat-app.theme-whatsapp-dark .setting-btn { color: #8696a0; }
        .chat-app.theme-whatsapp-dark .setting-btn:hover { color: #00a884; background: #2a3942; }
        .chat-app.theme-whatsapp-dark .input-box-wrapper {
            background: #2a3942;
            border-color: transparent;
            border-radius: 20px;
            box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.3);
        }
        .chat-app.theme-whatsapp-dark .input-box-wrapper:focus-within {
            border-color: #00a884;
            background: #2a3942;
            box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.22);
        }
        .chat-app.theme-whatsapp-dark #msginput { color: #e9edef; }
        .chat-app.theme-whatsapp-dark #msginput:empty:before { color: #8696a0; }
        .chat-app.theme-whatsapp-dark #sendbtn {
            background: #00a884;
            border-radius: 20px;
            color: #ffffff;
        }
        .chat-app.theme-whatsapp-dark #sendbtn:hover:not(:disabled) { background: #06cf9c; }
        .chat-app.theme-whatsapp-dark #sendbtn:disabled { background: #2a3942; color: #8696a0; }

        .chat-app.theme-whatsapp-dark #reply-indicator {
            background: rgba(0, 168, 132, 0.1);
            border: 1px solid rgba(0, 168, 132, 0.32);
            color: #8696a0;
        }
        .chat-app.theme-whatsapp-dark #reply-indicator span { color: #00a884; }

        .chat-app.theme-whatsapp-dark .reply-btn,
        .chat-app.theme-whatsapp-dark .reply-btn2 {
            background: rgba(0, 0, 0, 0.6);
            border-color: rgba(255, 255, 255, 0.5);
        }
        .chat-app.theme-whatsapp-dark .reply-btn:hover,
        .chat-app.theme-whatsapp-dark .reply-btn2:hover { background-color: #00a884; }

        .chat-app.theme-whatsapp-dark #scrollToBottomBtn {
            background: rgba(0, 168, 132, 0.9);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        }
        .chat-app.theme-whatsapp-dark #scrollToBottomBtn:hover { background: #00a884; }

        .chat-app.theme-whatsapp-dark #mention-list {
            background: #202c33;
            border-color: rgba(255, 255, 255, 0.1);
            color: #e9edef;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
        }
        .chat-app.theme-whatsapp-dark .mention-item { color: #e9edef; }
        .chat-app.theme-whatsapp-dark .mention-item:hover,
        .chat-app.theme-whatsapp-dark .mention-item.selected { background: rgba(0, 168, 132, 0.18); }
        .chat-app.theme-whatsapp-dark .mention-item .display-name { color: #00a884; }
        .chat-app.theme-whatsapp-dark .mention-item .login-name { color: #8696a0; }
        .chat-app.theme-whatsapp-dark .mention-header {
            color: #8696a0;
            border-bottom-color: rgba(255, 255, 255, 0.08);
            background: rgba(0, 0, 0, 0.2);
        }

        .chat-app.theme-whatsapp-dark .wa-audio-player {
            background: #2a3942;
            border-color: rgba(255, 255, 255, 0.08);
        }
        .chat-app.theme-whatsapp-dark .wa-play-btn { color: #00a884; }
        .chat-app.theme-whatsapp-dark .wa-duration { color: #8696a0; }
        .chat-app.theme-whatsapp-dark .wa-waveform { color: #00a884; }
        .chat-app.theme-whatsapp-dark .audio-icon-btn { background: rgba(0, 168, 132, 0.15); color: #00a884; }
        .chat-app.theme-whatsapp-dark .audio-icon-btn.playing { background: #00a884; color: #ffffff; }

        .chat-app.theme-whatsapp-dark #settingsPanel {
            background: #202c33;
            color: #e9edef;
        }

 /* ===================== 主題：LINE 深色 ===================== */
        .chat-app.theme-discord {
            --t-bg: #111111; --t-alt: #1c1c1e; --t-purp: #06c755; --t-purp-hover: #1ed760;
            --t-purp-muted: rgba(6, 199, 85, 0.15); --t-purp-border: rgba(6, 199, 85, 0.35);
            --text-main: #eaeaea; --text-muted: #9a9a9a;
            --bg-base: #111111; --bg-surface: #2a2a2c; --bg-surface-hover: #333336; --bg-surface-active: #3a3a3d;
            --bg-panel: #1c1c1e; --border-color: rgba(255,255,255,0.08); --border-strong: rgba(255,255,255,0.15);
            background: #111111;
        }
        .chat-app.theme-discord .header-bar,
        .chat-app.theme-discord .footer { background: #1c1c1e; border-color: rgba(255,255,255,0.08); }
        .chat-app.theme-discord #chat-container { background: #111111; }
        .chat-app.theme-discord #messages { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
        .chat-app.theme-discord .chat-line {
            width: fit-content; max-width: 95%; background: #2b2b2d; border-radius: 18px;
            padding: 8px 12px 20px 12px; margin-bottom: 6px; border: 1px solid transparent;
            color: #eaeaea; line-height: 1.5;
        }
        .chat-app.theme-discord .chat-line:hover { background: #333336; }
        .chat-app.theme-discord .chat-line.msg-self { background: #2f6b46; }
        .chat-app.theme-discord .chat-line.msg-self:hover { background: #377a51; }
        .chat-app.theme-discord .chat-line:has(.quote-box) { background: #2b2b2d !important; margin-left: 0; }
        .chat-app.theme-discord .chat-line.msg-self:has(.quote-box) { background: #2a5c3d !important; }
        .chat-app.theme-discord .quote-box {
            background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255,255,255,0.08);
            border-left: 3px solid #06c755; color: #a8a8a8;
        }
        .chat-app.theme-discord .quote-box:hover { background: rgba(0, 0, 0, 0.45); border-left-color: #1ed760; }
        .chat-app.theme-discord .quote-user { color: #9a9a9a; }
        .chat-app.theme-discord .mention-self-tag { background-color: #06c755; color: #111111 !important; }
        .chat-app.theme-discord .msg-time { color: #9a9a9a; opacity: 0.75; right: 12px; bottom: 4px; }
        .chat-app.theme-discord .input-box-wrapper { background: #2a2a2c; border-color: transparent; border-radius: 20px; }
        .chat-app.theme-discord .input-box-wrapper:focus-within {
            border-color: #06c755; background: #2a2a2c; box-shadow: 0 0 0 2px rgba(6, 199, 85, 0.2);
        }
        .chat-app.theme-discord #sendbtn { background: #06c755; border-radius: 20px; color: #0b2e14; }
        .chat-app.theme-discord #sendbtn:hover:not(:disabled) { background: #1ed760; }
        .chat-app.theme-discord .mention-item:hover,
        .chat-app.theme-discord .mention-item.selected { background: rgba(6, 199, 85, 0.2); }
        .chat-app.theme-discord .mention-item .display-name { color: #06c755; }
        .chat-app.theme-discord .audio-icon-btn { background: rgba(6, 199, 85, 0.2); }
        .chat-app.theme-discord .audio-icon-btn.playing { background: #06c755; color: #111; }
        .chat-app.theme-discord #scrollToBottomBtn { background: rgba(6, 199, 85, 0.85); }
        .chat-app.theme-discord #scrollToBottomBtn:hover { background: #06c755; }
        .chat-app.theme-discord .reply-btn:hover,
        .chat-app.theme-discord .reply-btn2:hover { background-color: #06c755; }

/* ===================== 主題：Sk ===================== */
        .chat-app.theme-sk {
            --t-bg: #1a1a1c;
            --t-alt: #26262c;
            --t-purp: #9147ff;
            --t-purp-hover: #a970ff;
            --t-purp-muted: rgba(145, 71, 255, 0.15);
            --t-purp-border: rgba(145, 71, 255, 0.3);
            --text-main: #efeff1;
            --text-muted: #9d9d9d;
            --text-inverse: #09090b;
            --bg-base: #1a1a1c;
            --bg-surface: #26262c;
            --bg-surface-hover: #2d2d33;
            --bg-surface-active: #2d2d33;
            --bg-panel: #18181b;
            --border-color: rgba(255, 255, 255, 0.06);
            --border-strong: rgba(255, 255, 255, 0.12);
            --danger: #e91916;
            background: #1a1a1c;
            color: #efeff1;
        }

        .chat-app.theme-sk .header-bar {
            background: #121214;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        }
        .chat-app.theme-sk .footer {
            background: #121214;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
        }

        .chat-app.theme-sk #chat-container {
            background: #1a1a1c;
            padding: 10px 12px;
        }

        .chat-app.theme-sk #messages {
            display: block;
        }

        /* chat-line 保持原有結構，只做視覺覆寫 */
        .chat-app.theme-sk .chat-line {
            display: block;
            width: auto;
            max-width: 95%;
            background: transparent !important;
            border: none !important;
            border-radius: 0;
            padding: 0;
            margin: 0 0 8px 0;
            color: #efeff1;
            font-size: 13px;
            line-height: 1.5;
            box-shadow: none !important;
            word-wrap: break-word;
            overflow-wrap: break-word;
            content-visibility: visible;
        }

        .chat-app.theme-sk .chat-line:hover {
            background: transparent !important;
        }

        .chat-app.theme-sk .chat-line:has(.quote-box) {
            background: transparent !important;
            border: none !important;
            margin-left: 0;
        }

        .chat-app.theme-sk .chat-line.msg-self {
            background: transparent !important;
            align-self: auto;
            margin-right: 0;
            margin-left: 0;
        }

        /* 使用者名稱：粗體 + 陰影，顯示在氣泡外 */
        .chat-app.theme-sk .chat-line > b {
            display: inline;
            font-weight: 700;
            font-size: 16px;
            font-weight: bold;
            text-shadow: -1px -1px 0 #FFF, 1px -1px 0 #FFF, -1px 1px 0 #FFF, 1px 1px 0 #FFF;
            vertical-align: baseline;
        }

      

        .chat-app.theme-sk .chat-line > b .badge {
            width: 18px;
            height: 18px;
            
            margin-right: 4px;
            filter: none;
        }

        /* 訊息內容（最後一個 span）變成氣泡 */
        .chat-app.theme-sk .chat-line > span:last-child {
            display: block;
            width: fit-content;
            max-width: 100%;
            box-sizing: border-box;
            background: #313131;
            border-radius: 1px 7.5px 7.5px;
            padding: 7px 12px 8px 12px;
            color: #e6e6e6;
            font-size: 15px;
            line-height: 1.5;
            word-wrap: break-word;
            overflow-wrap: break-word;
            margin-top: 2px;
			
        }

        .chat-app.theme-sk .chat-line:hover > span:last-child {
            background: #2d2d33;
        }

        /* 時間戳：行內，位於名稱前 */
        .chat-app.theme-sk .msg-time {
            position: static !important;
            display: inline !important;
            margin: 0 1px 0 0 !important;
            padding: 0 !important;
            color: #dadada !important;
            font-size: 15px !important;
            line-height: 1.5 !important;
            font-weight: normal !important;
            pointer-events: auto !important;
            user-select: text !important;
            white-space: nowrap;
            opacity: 1 !important;
            bottom: auto !important;
            right: auto !important;
            vertical-align: baseline;
            text-shadow: none;
        }

        /* 引用框：顯示在氣泡內 */
        .chat-app.theme-sk .chat-line > span:last-child .quote-box {
            margin: 0 0 4px 0;
            padding: 6px 8px;
            background: rgba(255, 255, 255, 0.06);
            border: none;
            border-left: 5px solid #e6d670;
            border-radius: 2px;
            color: #adadb8;
            font-size: 14px;
            display: block;
        }

        .chat-app.theme-sk .chat-line > span:last-child .quote-box:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .chat-app.theme-sk .quote-user {
            color: #adadb8;
        }

        .chat-app.theme-sk .mention-self-tag {
            background-color: #9147ff;
            color: #ffffff !important;
        }

        /* 媒體在氣泡內 */
        .chat-app.theme-sk #chat-container img.media-preview {
            max-width: 100% !important;
            max-height: var(--media-img-max-height) !important;
            min-height: auto !important;
            border-radius: 8px !important;
            border: none !important;
            margin: 4px 0 !important;
            display: block;
        }

        .chat-app.theme-sk #chat-container video.media-preview {
            max-width: 100% !important;
            max-height: var(--media-video-max-height) !important;
            min-height: auto !important;
            border-radius: 8px !important;
            border: none !important;
            margin: 4px 0 !important;
            display: block;
        }

        .chat-app.theme-sk #chat-container iframe.media-preview,
        .chat-app.theme-sk #chat-container iframe[src*="youtube.com"],
        .chat-app.theme-sk #chat-container iframe[src*="youtube-nocookie.com"],
        .chat-app.theme-sk #chat-container iframe[src*="youtu.be"],
        .chat-app.theme-sk #chat-container iframe[src*="facebook.com"],
        .chat-app.theme-sk #chat-container iframe[src*="store.steampowered.com"],
        .chat-app.theme-sk #chat-container iframe[src*="threads.com"] {
            max-width: 100% !important;
            min-height: 240px !important;
            max-height: 260px !important;
            height: 240px !important;
            border-radius: 8px !important;
            border: none !important;
            margin: 4px 0 !important;
        }

        .chat-app.theme-sk .alt-emoji {
            max-width: 150px !important;
            max-height: 150px !important;
            border-radius: 8px;
            vertical-align: top;
            margin: 4px 0;
        }

        .chat-app.theme-sk .reply-btn,
        .chat-app.theme-sk .reply-btn2 {
            background: rgba(0, 0, 0, 0.7);
            border-color: #555;
        }
        .chat-app.theme-sk .reply-btn:hover,
        .chat-app.theme-sk .reply-btn2:hover {
            background-color: #9147ff;
            border-color: #fff;
        }

        .chat-app.theme-sk #scrollToBottomBtn {
            background: rgba(145, 71, 255, 0.8);
        }
        .chat-app.theme-sk #scrollToBottomBtn:hover {
            background: rgba(145, 71, 255, 1);
        }

        .chat-app.theme-sk #mention-list {
            background: #18181b;
            border-color: #333;
            color: #efeff1;
        }
        .chat-app.theme-sk .mention-item {
            color: #efeff1;
        }
        .chat-app.theme-sk .mention-item:hover,
        .chat-app.theme-sk .mention-item.selected {
            background: rgba(145, 71, 255, 0.2);
        }
        .chat-app.theme-sk .mention-item .display-name {
            color: #9147ff;
        }
        .chat-app.theme-sk .mention-item .login-name {
            color: #adadb8;
        }
        .chat-app.theme-sk .mention-header {
            color: #adadb8;
            border-bottom-color: #333;
            background: rgba(0, 0, 0, 0.2);
        }

        .chat-app.theme-sk .wa-audio-player {
            background: #1f1f23;
            border-color: rgba(255, 255, 255, 0.08);
        }
        .chat-app.theme-sk .wa-play-btn { color: #9147ff; }
        .chat-app.theme-sk .wa-duration { color: #9d9d9d; }
        .chat-app.theme-sk .wa-waveform { color: #9147ff; }
        .chat-app.theme-sk .audio-icon-btn { background: rgba(145, 71, 255, 0.15); color: #efeff1; }
        .chat-app.theme-sk .audio-icon-btn.playing { background: #9147ff; color: #fff; }

        .chat-app.theme-sk .input-box-wrapper {
            background: #1f1f23;
            border-color: rgba(255, 255, 255, 0.08);
        }
        .chat-app.theme-sk .input-box-wrapper:focus-within {
            border-color: #9147ff;
            background: #1f1f23;
            box-shadow: 0 0 0 2px rgba(145, 71, 255, 0.2);
        }
        .chat-app.theme-sk #sendbtn {
            background: #9147ff;
        }
        .chat-app.theme-sk #sendbtn:hover:not(:disabled) {
            background: #a970ff;
        }
        .chat-app.theme-sk #sendbtn:disabled {
            background: #2a2a2e;
            color: #9d9d9d;
        }

        .chat-app.theme-sk .tool-link { color: #9d9d9d; }
        .chat-app.theme-sk .tool-link:hover { color: #efeff1; background: #2a2a2e; }
        .chat-app.theme-sk .setting-btn { color: #9d9d9d; }
        .chat-app.theme-sk .setting-btn:hover { color: #9147ff; background: #2a2a2e; }

/* ===================== 用戶資料卡 (Twitch User Card) ===================== */
        #userCard {
            position: fixed;
            width: 300px;
            max-width: calc(100vw - 24px);
            max-height: calc(100vh - 24px);
            overflow-y: auto;
            background: var(--bg-panel, #18181b);
            color: var(--text-main, #efeff1);
            border: 1px solid var(--border-strong, rgba(255,255,255,0.15));
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
            z-index: 10001;
            font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
            font-size: 13px;
            line-height: 1.45;
            animation: ucIn 0.12s ease-out;
        }
        #userCard::-webkit-scrollbar { width: 6px; }
        #userCard::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

        @keyframes ucIn {
            from { opacity: 0; transform: translateY(6px) scale(0.98); }
            to { opacity: 1; transform: none; }
        }

        /* === 右上角關閉按鈕 === */
        #userCard .uc-close {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.55);
            color: #ffffff;
            border: none;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 5;
            padding: 0;
            font-family: inherit;
            transition: background 0.15s ease, transform 0.15s ease;
        }
        #userCard .uc-close:hover {
            background: rgba(233, 25, 22, 0.9);
            transform: scale(1.08);
        }
        #userCard .uc-close:active {
            transform: scale(0.96);
        }

        #userCard .uc-banner { height: 62px; position: relative; border-radius: 10px 10px 0 0; }
        #userCard .uc-banner::after {
            content: ''; position: absolute; inset: 0;
            border-radius: 10px 10px 0 0;
            background: linear-gradient(180deg, rgba(0,0,0,0) 25%, rgba(0,0,0,0.5) 100%);
        }
        #userCard .uc-avatar {
            width: 62px; height: 62px; border-radius: 50%;
            border: 3px solid var(--bg-panel, #18181b);
            background: #000; object-fit: cover; display: block;
            margin: -34px 0 0 14px; position: relative; z-index: 2;
        }
        #userCard .uc-body { padding: 8px 14px 14px; }
        #userCard .uc-name {
            font-size: 16px; font-weight: 700; line-height: 1.3;
            display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
            word-break: break-word;
        }
        #userCard .uc-name img.badge { width: 18px; height: 18px; margin: 0; vertical-align: middle; }
        #userCard .uc-login { color: var(--text-muted, #adadb8); font-size: 12px; margin-top: 2px; }
        #userCard .uc-status { margin-top: 9px; font-size: 12.5px; }
        #userCard .uc-live { color: #eb0400; font-weight: 700; display: inline-flex; align-items: center; }
        #userCard .uc-live .dot {
            display: inline-block; width: 7px; height: 7px; border-radius: 50%;
            background: #eb0400; margin-right: 5px; animation: pulse-status 2s infinite;
        }
        #userCard .uc-status .game { color: var(--text-main, #efeff1); }
        #userCard .uc-status .viewers { color: var(--text-muted, #adadb8); }
        #userCard .uc-offline { color: var(--text-muted, #adadb8); }
        #userCard .uc-desc {
            margin-top: 9px; color: var(--text-muted, #adadb8);
            font-size: 12.5px; white-space: pre-wrap; word-break: break-word;
            max-height: 90px; overflow-y: auto;
        }
        #userCard .uc-stats {
            display: flex; gap: 18px; margin-top: 11px; padding-top: 10px;
            border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
        }
        #userCard .uc-stats > div { display: flex; flex-direction: column; min-width: 0; }
        #userCard .uc-stats b { font-size: 13.5px; font-weight: 700; color: var(--text-main, #efeff1); }
        #userCard .uc-stats span { font-size: 11px; color: var(--text-muted, #adadb8); }
        #userCard .uc-actions { margin-top: 12px; display: flex; gap: 8px; }
        #userCard .uc-actions a,
        #userCard .uc-actions button {
            flex: 1; text-align: center; padding: 7px 10px; border-radius: 6px;
            font-size: 12.5px; font-weight: 600; font-family: inherit;
            text-decoration: none; cursor: pointer; border: none;
            background: var(--t-purp, #9147ff); color: #fff;
            transition: filter 0.15s ease, opacity 0.15s ease;
            white-space: nowrap;
        }
        #userCard .uc-actions a:hover,
        #userCard .uc-actions button:hover { filter: brightness(1.15); }
        #userCard .uc-actions button {
            background: var(--bg-surface-active, #26262c);
            color: var(--text-main, #efeff1);
            flex: 0 0 auto;
        }
        #userCard .uc-loading {
            padding: 28px 16px; text-align: center;
            color: var(--text-muted, #adadb8); font-size: 13px;
        }

        /* 用戶名可點擊 */
        .chat-line > b { cursor: pointer; }
        .chat-line > b:hover { text-decoration: underline; }
    
/* 合併頁面：聊天室樣式限制在聊天室容器內 */
.chat-app { height:100%; min-height:0; width:100%; overflow:hidden; display:flex; flex-direction:column; margin:0; }
.chat-app #chat-container { min-height:0; }

/* ============================================================
   Twitch 官方聊天室風格（保留自製聊天室的回覆、媒體、資源庫等功能）
   套用於設定中的「Twitch」主題，不影響其他主題。
   ============================================================ */
.chat-app.theme-twitch {
    --t-bg: #0e0e10;
    --t-alt: #18181b;
    --t-purp: #9147ff;
    --t-purp-hover: #a970ff;
    --text-main: #efeff1;
    --text-muted: #adadb8;
    --bg-base: #0e0e10;
    --bg-surface: #18181b;
    --bg-surface-hover: #26262c;
    --bg-surface-active: #323239;
    --bg-panel: #18181b;
    --border-color: #303032;
    background: #0e0e10 !important;
    color: #efeff1 !important;
    font-family: Inter, "Roobert", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
}
.chat-app.theme-twitch .header-bar {
    background: #18181b !important;
    border-bottom: 1px solid #303032 !important;
    min-height: 38px;
}
.chat-app.theme-twitch #status,
.chat-app.theme-twitch #userName { color: #efeff1; }
.chat-app.theme-twitch #chat-container {
    background: #0e0e10 !important;
    padding: 8px 0 12px !important;
    scrollbar-color: #53535f #0e0e10;
}
.chat-app.theme-twitch #messages {
    display: block !important;
    width: 100%;
}
.chat-app.theme-twitch .chat-line,
.chat-app.theme-twitch #messages .chat-line {
    display: block !important;
    position: relative;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 4px 10px 5px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #efeff1 !important;
    font-family: Inter, "Roobert", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: 400;
    line-height: 1.5 !important;
    overflow-wrap: anywhere;
    word-break: normal;
    transition: background-color .08s ease;
}
.chat-app.theme-twitch .chat-line:hover,
.chat-app.theme-twitch #messages .chat-line:hover {
    background: #18181b !important;
}
.chat-app.theme-twitch .chat-line:has(.quote-box),
.chat-app.theme-twitch .chat-line.msg-self,
.chat-app.theme-twitch .chat-line.msg-self:has(.quote-box) {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}
.chat-app.theme-twitch .chat-line.msg-self:hover,
.chat-app.theme-twitch .chat-line:has(.quote-box):hover {
    background: #18181b !important;
}
.chat-app.theme-twitch .chat-line > b,
.chat-app.theme-twitch .chat-line > .display-name,
.chat-app.theme-twitch .chat-line > .self-name {
    display: inline;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    cursor: pointer;
}
.chat-app.theme-twitch .chat-line > span,
.chat-app.theme-twitch .chat-line > .message {
    display: inline;
    color: #efeff1;
    font-size: 14px !important;
    line-height: 1.5 !important;
    white-space: normal;
}
.chat-app.theme-twitch .chat-line .badge,
.chat-app.theme-twitch .chat-line img.badge {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    margin: 0 4px 0 0 !important;
    object-fit: contain;
    vertical-align: -4px !important;
}
.chat-app.theme-twitch .chat-line img.emote,
.chat-app.theme-twitch .chat-line img.chat-emote,
.chat-app.theme-twitch .chat-line .emote,
.chat-app.theme-twitch .chat-line img.emoji {
    max-width: 112px;
    max-height: 28px;
    height: 28px;
    width: auto;
    margin: 0 1px;
    vertical-align: middle;
    object-fit: contain;
}
.chat-app.theme-twitch .chat-line img:not(.badge):not(.media-preview):not(.emote):not(.chat-emote):not(.emoji),
.chat-app.theme-twitch .chat-line video.media-preview,
.chat-app.theme-twitch .chat-line iframe.media-preview {
    max-width: min(300px, 95%) !important;
}
.chat-app.theme-twitch .chat-line .msg-time {
    display: inline !important;
    margin-right: 5px !important;
    color: #adadb8 !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    vertical-align: baseline !important;
}
.chat-app.theme-twitch.hide-timestamps .chat-line { padding-bottom: 5px !important; }
.chat-app.theme-twitch .reply-btn-group {
    top: 2px;
    right: 6px;
    display: none;
    gap: 4px;
    padding: 2px;
    border-radius: 4px;
    background: #26262c;
}
.chat-app.theme-twitch .chat-line:hover .reply-btn-group,
.chat-app.theme-twitch .chat-line:focus-within .reply-btn-group { display: flex; }
.chat-app.theme-twitch .reply-btn,
.chat-app.theme-twitch .reply-btn2 {
    width: 23px !important;
    height: 23px !important;
    min-width: 23px;
    min-height: 23px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #3f3f46;
    color: #efeff1;
    cursor: pointer;
}
.chat-app.theme-twitch .reply-btn img { width: 15px; height: 15px; object-fit: contain; }
/* ================= 修正 theme-twitch 的引用樣式 ================= */
/* ================= 終極修正 theme-twitch 的引用樣式 ================= */
.chat-app.theme-twitch .quote-box {
    display: block !important; /* 強制獨佔第一行 */
    margin: 2px 0 4px 0 !important; /* 上下留出適當間距 */
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    color: #87878b !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    cursor: pointer;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* 確保圖標與文字對齊 */
.chat-app.theme-twitch .quote-box svg {
    width: 14px !important;
    height: 14px !important;
    fill: #adadb8 !important;
    vertical-align: -2px !important;
    margin-right: 4px !important;
}

/* @用戶名 顏色 */
.chat-app.theme-twitch .quote-user {
    color: #9c9ca5 !important
    font-weight: normal !important;
    margin-right: 4px !important;
	
}

/* 確保時間戳、名字、內容正常內聯顯示 */
.chat-app.theme-twitch .chat-line > span,
.chat-app.theme-twitch .chat-line > b {
    display: inline !important;
}

/* 微調時間戳在 Twitch 主題的樣式（因為現在緊貼名字，所以 margin 要調整一下） */
.chat-app.theme-twitch .chat-line .msg-time {
    margin-right: 2px !important;
    vertical-align: baseline !important;
}
/* 讓被引用的文字維持灰色，不換行（依照截圖是單行顯示） */
.chat-app.theme-twitch .quote-box .message {
    color: #adadb8 !important;
}
.chat-app.theme-twitch .mention-self-tag {
    padding: 0 3px !important;
    border-radius: 2px !important;
    background: rgba(145,71,255,.22) !important;
    color: #bf94ff !important;
}
.chat-app.theme-twitch #scrollToBottomBtn {
    background: #9147ff !important;
    color: #fff !important;
}
.chat-app.theme-twitch .input-box-wrapper {
    background: #18181b !important;
    border: 1px solid #53535f !important;
    border-radius: 4px !important;
}
.chat-app.theme-twitch .input-box-wrapper:focus-within {
    border-color: #a970ff !important;
    box-shadow: 0 0 0 2px rgba(145,71,255,.22) !important;
}
.chat-app.theme-twitch #msginput { color: #efeff1 !important; font-size: 13px !important; }
.chat-app.theme-twitch #msginput:empty:before { color: #adadb8 !important; }
.chat-app.theme-twitch #sendbtn {
    background: #9147ff !important;
    color: #fff !important;
    border-radius: 4px !important;
}
.chat-app.theme-twitch #sendbtn:hover:not(:disabled) { background: #772ce8 !important; }
.chat-app.theme-twitch .footer { background: #0e0e10 !important; border-color: #303032 !important; }
.chat-app.theme-twitch #mention-list { background: #18181b; border-color: #303032; }
.chat-app.theme-twitch .mention-item:hover,
.chat-app.theme-twitch .mention-item.selected { background: #26262c !important; }
.chat-app.theme-twitch .mention-item .display-name { color: #bf94ff !important; }
.chat-app.theme-twitch #settingsPanel { background: #18181b !important; color: #efeff1 !important; }
.chat-app.theme-twitch .setting-btn { color: #adadb8; }
.chat-app.theme-twitch .setting-btn:hover { color: #efeff1; background: #26262c; }
.chat-app.theme-twitch #chat-container::-webkit-scrollbar-thumb { background: #53535f; }
.chat-app.theme-twitch #chat-container::-webkit-scrollbar-thumb:hover { background: #9147ff; }
@media (max-width: 600px) {
    .chat-app.theme-twitch #chat-container { padding: 5px 0 10px !important; }
    .chat-app.theme-twitch .chat-line,
    .chat-app.theme-twitch #messages .chat-line { padding: 4px 8px 5px !important; }
}
/* Twitch 主題不需要這塊外掛的 hover 熱區 */
.chat-app.theme-twitch .chat-line::after {
    content: none !important;
    display: none !important;
}