
        :root {
            --primary-color: #2563eb;
            --bg-color: #f8fafc;
            --panel-bg: #ffffff;
            --text-color: #1e293b;
            --border-color: #e2e8f0;
        }
        * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
        body { display: flex; height: 100vh; background-color: var(--bg-color); color: var(--text-color); overflow: hidden; position: relative; }
        
        /* 側邊欄抽屜式設計 */
        #sidebar { 
            position: fixed; top: 0; left: 0; width: 280px; height: 100%;
            background: #0f172a; color: white; display: flex; flex-direction: column; 
            padding: 15px; z-index: 2000; transform: translateX(-100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
            box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        }
        #sidebar.open { transform: translateX(0); }
        
        .sidebar-header { font-size: 1.2rem; font-weight: bold; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
        .btn { padding: 10px; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; transition: all 0.2s; width: 100%; text-align: center; }
        .btn-primary { background: var(--primary-color); color: white; }
        .btn-primary:hover { background: #1d4ed8; }
        .btn-danger { background: #ef4444; color: white; }
        .btn-danger:hover { background: #dc2626; }
        .btn-secondary { background: #64748b; color: white; margin-top: auto; }
        
        #session-list { flex: 1; overflow-y: auto; margin-top: 15px; }
        .session-item { padding: 12px; border-radius: 6px; background: #1e293b; margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; transition: background 0.2s; }
        .session-item:hover { background: #334155; }
        .session-item.active { background: var(--primary-color); }
        
        .delete-session { color: #94a3b8; cursor: pointer; padding: 4px 6px; font-size: 1rem; border-radius: 4px; transition: all 0.2s; }
        .delete-session:hover { color: #ef4444; background: rgba(239, 68, 68, 0.15); }

        /* 全畫面遮罩 */
        #sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1999; backdrop-filter: blur(2px); }

        /* 主畫面 */
        #main-content { flex: 1; display: flex; flex-direction: column; background: var(--bg-color); height: 100vh; position: relative; width: 100%; overflow: hidden; }
        #top-bar { height: 60px; min-height: 60px; background: var(--panel-bg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 20px; gap: 15px; z-index: 10; }
        
        .menu-toggle-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-color); cursor: pointer; padding: 5px; display: flex; align-items: center; justify-content: center; transition: opacity 0.2s; }
        .menu-toggle-btn:hover { opacity: 0.7; }
        
        select { padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border-color); font-size: 0.95rem; background: white; outline: none; min-width: 220px; }
        select optgroup { font-weight: bold; color: #1e293b; }
        select option[disabled] { font-weight: bold; color: #64748b; background-color: #f8fafc; }
        
        #chat-box { flex: 1; overflow-y: auto; padding: 25px; display: flex; flex-direction: column; gap: 20px; }
        
        /* 🎨 增強版聊天氣泡 */
        .message { max-width: 85%; padding: 14px 18px; border-radius: 12px; line-height: 1.6; font-size: 1rem; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
        .user-message { background: #dbeafe; color: #1e40af; align-self: flex-end; border-bottom-right-radius: 2px; white-space: pre-wrap; }
		.ai-message ol{padding-left:3%!important;}
        .ai-message { background: var(--panel-bg); color: var(--text-color); align-self: flex-start; border-bottom-left-radius: 2px; border: 1px solid var(--border-color); }
        
        .ai-message p { margin-bottom: 10px; }
        .ai-message p:last-child { margin-bottom: 0; }
        .ai-message img { max-width: 100%; border-radius: 8px; margin: 10px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
        .ai-message pre { background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
        .ai-message code { font-family: monospace; background: #f1f5f9; padding: 2px 4px; border-radius: 4px; color: #ef4444; }
        .ai-message pre code { background: transparent; padding: 0; color: inherit; }
        
        .welcome-message { text-align: center; color: #64748b; margin-top: 40px; font-size: 1.1rem; align-self: center; background: transparent; box-shadow: none; border: none; padding: 0 10px; }
        .error-message { background: #fee2e2; color: #dc2626; border: 1px solid #f87171; text-align: center; font-weight: bold; }

        /* 底部輸入區域結構 */
        #input-container { display: flex; flex-direction: column; background: var(--panel-bg); border-top: 1px solid var(--border-color); z-index: 10; }
        #preview-area { display: none; padding: 10px 20px 0 20px; gap: 10px; overflow-x: auto; }
        .preview-item { position: relative; width: 60px; height: 60px; border-radius: 8px; border: 1px solid var(--border-color); overflow: hidden; background: #f8fafc; flex-shrink: 0; }
        .preview-item img { width: 100%; height: 100%; object-fit: cover; }
        .preview-item .file-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #64748b; }
        .remove-preview { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; }

        #input-area { padding: 15px 20px; display: flex; gap: 15px; align-items: center; min-height: 80px; }
        .input-wrapper { flex: 1; display: flex; align-items: center; background: white; border: 1px solid var(--border-color); border-radius: 8px; padding-left: 10px; position: relative; height: 50px; }
        .upload-trigger-btn { background: none; border: none; font-size: 1.4rem; color: #64748b; cursor: pointer; padding: 5px; display: flex; align-items: center; justify-content: center; transition: color 0.2s; user-select: none; }
        .upload-trigger-btn:hover { color: var(--primary-color); }
        #user-input { flex: 1; padding: 12px 10px; border: none; background: transparent; height: 100%; font-size: 1rem; outline: none; line-height: 1.4; resize: none; }
        #send-btn { width: 100px; height: 50px; font-size: 1rem; display: flex; justify-content: center; align-items: center; }

        /* 彈窗樣式 */
        .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 10000; }
        .modal-content { background: white; padding: 30px; border-radius: 12px; width: 90%; max-width: 400px; display: flex; flex-direction: column; gap: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
        .modal-content h3 { font-size: 1.25rem; margin-bottom: 5px; text-align: center; }
        .modal-content input { padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 1rem; outline: none; }
        .modal-content .btn { margin-top: 5px; padding: 12px; }
        #user-status-text { text-align: center; font-weight: bold; padding: 10px; background: #f1f5f9; border-radius: 6px; color: #475569; }

        /* 會員方案在小螢幕上改為可上下滑動的自適應彈窗 */
        #upgrade-modal {
            padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
            overflow-y: auto;
            overscroll-behavior: contain;
            -webkit-overflow-scrolling: touch;
        }
        #upgrade-modal .modal-content {
            width: min(600px, 100%);
            max-width: 600px;
            max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
            overflow-y: auto;
            overscroll-behavior-y: contain;
            -webkit-overflow-scrolling: touch;
            touch-action: pan-y;
            padding: clamp(18px, 4vw, 30px);
        }

        /* 📱 完美還原您最原始的手機版自適應樣式，只影響 768px 以下的手機，不會影響 iPad (1024px) */
        @media (max-width: 768px) {
            #top-bar { padding: 0 10px; gap: 6px; height: 55px; min-height: 55px; }
            select { min-width: 0; flex: 1; font-size: 0.8rem; padding: 6px 4px; }
            #chat-box { padding: 15px 10px 100px 10px; gap: 12px; }
            .message { max-width: 92%; padding: 10px 12px; font-size: 0.95rem; }
			.message ol{padding-left:20px!important;}
            #input-container { position: fixed; bottom: 0; left: 0; width: 100%; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); }
            #input-area { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) 12px; gap: 8px; min-height: 65px; }
            .input-wrapper { height: 44px; padding-left: 8px; border-radius: 22px; background: #f1f5f9; }
            .upload-trigger-btn { font-size: 1.5rem; padding: 0 4px; }
            #user-input { padding: 10px 6px; font-size: 0.95rem; }
            #send-btn { width: 65px; height: 44px; font-size: 0.9rem; border-radius: 22px; }
        }
		/gemini go/
			@media only screen 
      and (min-width: 768px) 
      and (max-width: 1366px)
      and (orientation: landscape) {
      
      /* 1. 修正 Safari 高度 Bug：確保整個網頁動態貼齊螢幕，不超出底部 */
      body, #main-content {
          height: 100dvh !important;
          max-height: -webkit-fill-available !important;
          overflow: hidden !important;
      }

      /* 2. 頂部選單：微調縮小並給予「防壓扁」保護 */
      #top-bar { 
          height: 45px !important; 
          min-height: 45px !important; 
          padding: 0 15px !important; 
          flex-shrink: 0 !important; 
      }
      select { font-size: 0.85rem !important; padding: 4px 8px !important; }

      /* 3. 底部發問框：給予「防擠出」保護，確保永遠貼死在底部 */
      #input-container { 
          flex-shrink: 0 !important; 
          padding-bottom: env(safe-area-inset-bottom) !important; 
      }
      #input-area { 
          padding: 10px 15px !important; 
          min-height: 50px !important; 
          gap: 10px !important; 
      }
      .input-wrapper { height: 40px !important; }
      #user-input { padding: 10px !important; font-size: 0.95rem !important; }
      #send-btn { height: 40px !important; font-size: 0.95rem !important; width: 80px !important; }

      /* 4. 聊天區關鍵魔法：強制其高度為 0，完全交由 Flex 彈性拉伸，絕不往外擠！ */
      #chat-box { 
          height: 0 !important; 
          flex-grow: 1 !important; 
          flex-shrink: 1 !important; 
          padding: 15px !important; 
          overflow-y: auto !important;
      }
      .message { padding: 10px 14px !important; font-size: 0.95rem !important; line-height: 1.4 !important; }
    }   
	/gemini stop/
		  /* 📱 不刪除舊代碼的「橫向模式與鍵盤彈出」強力補丁 */
		@media screen and (orientation: landscape) and (max-height: 600px),
			screen and (max-width: 950px) and (orientation: landscape) {
        
			/* 1. 強制保護頂部欄，絕對不允許被壓縮或擠出螢幕 */
			#top-bar { 
            flex-shrink: 0 !important;
            height: 50px !important; 
            min-height: 50px !important; 
            padding: 0 10px !important;
			}
        select { font-size: 0.8rem !important; padding: 4px !important; }
        
			/* 2. 核心修正：當鍵盤彈出（高度 < 600px）時，強制覆蓋原本的 70%，恢復彈性空間 */
			#chat-box { 
            height: auto !important; 
            flex: 1 !important; 
            padding: 10px 10px 20px 10px !important; 
			}
        
			/* 3. 壓縮底部輸入區，適應橫向極窄的高度 */
			#input-container { flex-shrink: 0 !important; }
			#input-area { 
            padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) 10px !important; 
            min-height: 55px !important; 
            gap: 8px !important; 
			}
			.input-wrapper { height: 40px !important; }
			#user-input { padding: 8px 6px !important; font-size: 0.95rem !important; }
			.upload-trigger-btn { font-size: 1.4rem !important; }
			#send-btn { width: 60px !important; height: 40px !important; font-size: 0.9rem !important; border-radius: 20px !important; }
		}
		/* --- 橫向選單消失修復補丁 (加在最底端) --- */
    #top-bar {
        /* 給予頂部選單最高保護，絕對不允許瀏覽器將其高度壓縮 */
        flex-shrink: 0 !important;
    }
    
    #input-container {
        /* 同樣保護底部輸入框不變形 */
        flex-shrink: 0 !important;
    }

    @media only screen and (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
        /* 在橫向模式下，強迫聊天區塊恢復「彈性」，不要硬撐 70% 導致把選單擠出去 */
        #chat-box {
            height: auto !important;
            flex: 1 !important;
        }
    }
        }
    

        :root {
            --primary-color: #2563eb;
            --bg-color: #f8fafc;
            --panel-bg: #ffffff;
            --text-color: #1e293b;
            --border-color: #e2e8f0;
        }
        * { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
        body { display: flex; height: 100vh; background-color: var(--bg-color); color: var(--text-color); overflow: hidden; position: relative; }
        
        #sidebar { 
            position: fixed; top: 0; left: 0; width: 280px; height: 100%;
            background: #0f172a; color: white; display: flex; flex-direction: column; 
            padding: 15px; z-index: 2000; transform: translateX(-100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
            box-shadow: 4px 0 20px rgba(0,0,0,0.3);
        }
        #sidebar.open { transform: translateX(0); }
        
        .sidebar-header { font-size: 1.2rem; font-weight: bold; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
        .btn { padding: 10px; border: none; border-radius: 6px; cursor: pointer; font-weight: 500; transition: all 0.2s; width: 100%; text-align: center; }
        .btn-primary { background: var(--primary-color); color: white; }
        .btn-primary:hover { background: #1d4ed8; }
        .btn-danger { background: #ef4444; color: white; }
        .btn-danger:hover { background: #dc2626; }
        .btn-secondary { background: #64748b; color: white; }
        .btn-upgrade { background: linear-gradient(135deg, #10b981, #059669); color: white; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
        .btn-upgrade:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4); }
        
        #session-list { flex: 1; overflow-y: auto; margin-top: 15px; margin-bottom: 15px; }
        .session-item { padding: 12px; border-radius: 6px; background: #1e293b; margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; transition: background 0.2s; }
        .session-item:hover { background: #334155; }
        .session-item.active { background: var(--primary-color); }
        
        .delete-session { color: #94a3b8; cursor: pointer; padding: 4px 6px; font-size: 1rem; border-radius: 4px; transition: all 0.2s; }
        .delete-session:hover { color: #ef4444; background: rgba(239, 68, 68, 0.15); }

        #sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1999; backdrop-filter: blur(2px); }

        #main-content { flex: 1; display: flex; flex-direction: column; background: var(--bg-color); height: 100vh; position: relative; width: 100%; overflow: hidden; }
        #top-bar { height: 60px; min-height: 60px; background: var(--panel-bg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 20px; gap: 15px; z-index: 10; }
        
        .menu-toggle-btn { background: none; border: none; font-size: 1.5rem; color: var(--text-color); cursor: pointer; padding: 5px; display: flex; align-items: center; justify-content: center; transition: opacity 0.2s; }
        .menu-toggle-btn:hover { opacity: 0.7; }
        
        select { padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border-color); font-size: 0.95rem; background: white; outline: none; min-width: 220px; }
        select optgroup { font-weight: bold; color: #1e293b; }
        select option[disabled] { font-weight: bold; color: #64748b; background-color: #f8fafc; }
        
        #chat-box { flex: 1; overflow-y: auto; padding: 25px; display: flex; flex-direction: column; gap: 20px; }
        
        .message { max-width: 85%; padding: 14px 18px; border-radius: 12px; line-height: 1.6; font-size: 1rem; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
        .user-message { background: #dbeafe; color: #1e40af; align-self: flex-end; border-bottom-right-radius: 2px; white-space: pre-wrap; }
        .ai-message ol { padding-left: 3% !important; }
        
        .ai-message { position: relative; padding-right: 75px; background: var(--panel-bg); color: var(--text-color); align-self: flex-start; border-bottom-left-radius: 2px; border: 1px solid var(--border-color); min-height:auto!important; }
        
        .ai-message p { margin-bottom: 10px; }
        .ai-message p:last-child { margin-bottom: 0; }
        .ai-message img { max-width: 100%; border-radius: 8px; margin: 10px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
        .ai-message pre { background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
        .ai-message code { font-family: monospace; background: #f1f5f9; padding: 2px 4px; border-radius: 4px; color: #ef4444; }
        .ai-message pre code { background: transparent; padding: 0; color: inherit; }
        
        .welcome-message { text-align: center; color: #64748b; margin-top: 40px; font-size: 1.1rem; align-self: center; background: transparent; box-shadow: none; border: none; padding: 0 10px; }

        #input-container { display: flex; flex-direction: column; background: var(--panel-bg); border-top: 1px solid var(--border-color); z-index: 10; }
        #preview-area { display: none; padding: 10px 20px 0 20px; gap: 10px; overflow-x: auto; }
        .preview-item { position: relative; width: 60px; height: 60px; border-radius: 8px; border: 1px solid var(--border-color); overflow: hidden; background: #f8fafc; flex-shrink: 0; }
        .preview-item img { width: 100%; height: 100%; object-fit: cover; }
        .preview-item .file-icon { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #64748b; }
        .remove-preview { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: white; border-radius: 50%; width: 18px; height: 18px; font-size: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; }

        #input-area { padding: 15px 20px; display: flex; gap: 15px; align-items: center; min-height: 80px; }
        .input-wrapper { flex: 1; display: flex; align-items: center; background: white; border: 1px solid var(--border-color); border-radius: 8px; padding-left: 10px; position: relative; height: 50px; }
        .upload-trigger-btn { background: none; border: none; font-size: 1.4rem; color: #64748b; cursor: pointer; padding: 5px; display: flex; align-items: center; justify-content: center; transition: color 0.2s; user-select: none; }
        .upload-trigger-btn:hover { color: var(--primary-color); }
        #user-input { flex: 1; padding: 12px 10px; border: none; background: transparent; height: 100%; font-size: 1rem; outline: none; line-height: 1.4; resize: none; }
        
        #mic-btn { width: 100px; height: 50px; font-size: 1.5rem; border-radius: 25px; display: flex; justify-content: center; align-items: center; transition: all 0.2s; background: var(--primary-color); color: white; border: none; cursor: pointer; }
        #mic-btn:hover { background: #1d4ed8; transform: scale(1.05); }
        #send-btn { width: 100px; height: 50px; font-size: 1rem; display: flex; justify-content: center; align-items: center; border-radius: 25px; }

        .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 10000; }
        .modal-content { background: white; padding: 30px; border-radius: 12px; width: 90%; max-width: 400px; display: flex; flex-direction: column; gap: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
        .modal-content h3 { font-size: 1.25rem; margin-bottom: 5px; text-align: center; }
        .modal-content input { padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 1rem; outline: none; }
        .modal-content .btn { margin-top: 5px; padding: 12px; }
        #user-status-text { text-align: center; font-weight: bold; padding: 10px; background: #f1f5f9; border-radius: 6px; color: #475569; }

        .msg-tts-controls { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 5; background: rgba(255, 255, 255, 0.9); padding: 4px; border-radius: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
        .msg-tts-btn { width: 28px; height: 28px; border-radius: 50%; background: #f8fafc; border: 1px solid #e2e8f0; display: flex; justify-content: center; align-items: center; cursor: pointer; color: #2563eb; font-size: 0.85rem; transition: all 0.2s; }
        .msg-tts-btn:hover { transform: scale(1.1); background: white; }
        .stop-icon { width: 10px; height: 10px; background-color: #ef4444; border-radius: 2px; }

        @keyframes voice-ping { 0% { transform: scale(0.8); opacity: 0.8; } 100% { transform: scale(1.8); opacity: 0; } }
        .voice-wave-circle { position: absolute; width: 100%; height: 100%; background: #3b82f6; border-radius: 50%; opacity: 0.5; animation: voice-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite; }
        .voice-action-btn { width: 70px; height: 70px; border-radius: 50%; border: none; color: white; font-size: 1.8rem; cursor: pointer; display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 15px rgba(0,0,0,0.3); transition: all 0.2s; z-index: 10; }
        .voice-action-btn:hover { transform: scale(1.1); }
        .voice-action-btn-main { width: 85px; height: 85px; font-size: 2.5rem; background: #ef4444; }
        .voice-action-row { display: flex; gap: 35px; justify-content: center; align-items: center; width: 100%; position: relative; z-index: 10; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
        #voice-modal { height: 100vh; height: 100dvh; }
        #voice-subtitles-container { display: none; width: 90%; max-width: 600px; margin-top: 25px; background: rgba(0, 0, 0, 0.5); border-radius: 16px; padding: 20px; max-height: 220px; overflow-y: auto; box-shadow: inset 0 0 20px rgba(0,0,0,0.5); z-index: 10; }
        #voice-video-preview { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; opacity: 0.35; filter: blur(2px); }

        @media (max-width: 768px) {
            body, #main-content { height: 100dvh; min-height: 0; }
            #top-bar { padding: 0 10px; gap: 6px; height: 55px; min-height: 55px; }
            select { min-width: 0; flex: 1; font-size: 0.8rem; padding: 6px 4px; }
            #chat-box { min-height: 0; padding: 15px 10px calc(var(--mobile-input-height, 80px) + 35px + env(safe-area-inset-bottom)) 10px; gap: 12px; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; scroll-padding-bottom: calc(var(--mobile-input-height, 80px) + 35px + env(safe-area-inset-bottom)); }
            .message { max-width: 92%; padding: 10px 12px; font-size: 0.95rem; min-height:auto!important; flex-shrink: 0; }
			.message ol { padding-left: 20px !important; }
            .ai-message { padding-right: 12px; }
            .ai-message .msg-tts-controls { position: static; width: fit-content; margin-top: 10px; }
            #input-container { position: fixed; bottom: 0; left: 0; width: 100%; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); }
            #input-area { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) 12px; gap: 8px; min-height: 65px; }
            .input-wrapper { height: 44px; padding-left: 8px; border-radius: 22px; background: #f1f5f9; }
            .upload-trigger-btn { font-size: 1.5rem; padding: 0 4px; }
            #user-input { padding: 10px 6px; font-size: 0.95rem; }
            #mic-btn, #send-btn { width: 65px !important; height: 44px !important; font-size: 1.2rem !important; border-radius: 22px !important; }
            .voice-action-btn { width: 55px; height: 55px; font-size: 1.5rem; }
            .voice-action-btn-main { width: 70px; height: 70px; font-size: 2rem; }
            .voice-action-row { gap: 20px; padding-bottom: calc(25px + env(safe-area-inset-bottom)); }
            #upgrade-modal { align-items: flex-start; }
            #upgrade-modal .modal-content {
                width: 100%;
                max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
                margin: 8px 0;
                padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
            }
            #upgrade-modal .modal-content > div[style*="display: flex"] { gap: 12px !important; }
            #upgrade-modal .modal-content > div[style*="display: flex"] > div {
                min-width: 0 !important;
                width: 100%;
                flex: 1 1 100% !important;
            }
        }

        @media only screen and (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
            body, #main-content { height: 100dvh !important; max-height: -webkit-fill-available !important; overflow: hidden !important; }
            #top-bar { height: 45px !important; min-height: 45px !important; padding: 0 15px !important; flex-shrink: 0 !important; }
            select { font-size: 0.85rem !important; padding: 4px 8px !important; }
            #input-container { flex-shrink: 0 !important; padding-bottom: env(safe-area-inset-bottom) !important; }
            #input-area { padding: 10px 15px !important; min-height: 50px !important; gap: 10px !important; }
            .input-wrapper { height: 40px !important; }
            #user-input { padding: 10px !important; font-size: 0.95rem !important; }
            #send-btn, #mic-btn { height: 40px !important; font-size: 0.95rem !important; width: 80px !important; border-radius: 20px !important; }
            #chat-box { height: auto !important; flex-grow: 1 !important; flex-shrink: 1 !important; padding: 15px !important; overflow-y: auto !important; }
            .message { padding: 10px 14px !important; font-size: 0.95rem !important; line-height: 1.4 !important; }
        }   
        
        @media screen and (orientation: landscape) and (max-height: 600px), screen and (max-width: 950px) and (orientation: landscape) {
            #top-bar { flex-shrink: 0 !important; height: 50px !important; min-height: 50px !important; padding: 0 10px !important; }
            select { font-size: 0.8rem !important; padding: 4px !important; }
            #chat-box { height: auto !important; flex: 1 !important; padding: 10px 10px 20px 10px !important; }
            #input-container { flex-shrink: 0 !important; }
            #input-area { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) 10px !important; min-height: 55px !important; gap: 8px !important; }
            .input-wrapper { height: 40px !important; }
            #user-input { padding: 8px 6px !important; font-size: 0.95rem !important; }
            .upload-trigger-btn { font-size: 1.4rem !important; }
            #send-btn, #mic-btn { width: 60px !important; height: 40px !important; font-size: 1rem !important; border-radius: 20px !important; }
            .voice-action-row { padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
        }
		#chat-box ul{padding:0px;margin:0px;}
		#chat-box ul li{margin-left:30px;}
    

        :root {
            color-scheme: light;
            --primary-color: #2563eb;
            --primary-strong: #1d4ed8;
            --accent-color: #15b889;
            --bg-color: #f4f6f8;
            --panel-bg: #ffffff;
            --panel-soft: #eef1f4;
            --text-color: #17191d;
            --muted-color: #737983;
            --border-color: #dce1e7;
            --sidebar-bg: #17191d;
            --sidebar-soft: #24272d;
            --user-bubble: #25282e;
            --user-text: #ffffff;
            --assistant-bubble: #ffffff;
            --shadow-soft: 0 10px 30px rgba(20, 24, 32, 0.08);
        }

        html[data-theme="dark"] {
            color-scheme: dark;
            --primary-color: #8ea5ff;
            --primary-strong: #a8b8ff;
            --accent-color: #31d3a2;
            --bg-color: #181a1f;
            --panel-bg: #202228;
            --panel-soft: #2a2d34;
            --text-color: #f4f5f7;
            --muted-color: #a8adb7;
            --border-color: #363a43;
            --sidebar-bg: #111317;
            --sidebar-soft: #202329;
            --user-bubble: #343840;
            --user-text: #ffffff;
            --assistant-bubble: #24272d;
            --shadow-soft: 0 12px 34px rgba(0, 0, 0, 0.24);
        }

        html, body { width: 100%; height: 100%; background: var(--bg-color); }
        body { color: var(--text-color); }
        button, input, textarea, select { letter-spacing: 0; }
        button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
            outline: 3px solid color-mix(in srgb, var(--primary-color) 30%, transparent);
            outline-offset: 2px;
        }

        #main-content { height: 100dvh; background: var(--bg-color); }
        #top-bar {
            min-height: 68px;
            height: 68px;
            padding: 0 clamp(14px, 3vw, 34px);
            background: color-mix(in srgb, var(--panel-bg) 92%, transparent);
            border-color: var(--border-color);
            backdrop-filter: blur(16px);
            gap: 12px;
        }
        .menu-toggle-btn {
            width: 42px;
            height: 42px;
            flex: 0 0 42px;
            border-radius: 50%;
            color: var(--text-color);
            font-size: 0;
        }
        .menu-toggle-btn::before { content: "☰"; font-size: 1.35rem; }
        .top-brand { min-width: 0; display: flex; flex-direction: column; gap: 2px; margin-right: auto; }
        .top-brand strong { font-size: 0.98rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .top-brand span { color: var(--muted-color); font-size: 0.76rem; white-space: nowrap; }
        .top-actions { display: flex; align-items: center; gap: 8px; }
        .theme-picker { position: relative; flex: 0 0 auto; }
        .theme-symbols { position: absolute; pointer-events: none; }
        .theme-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
        #theme-menu { position: absolute; top: calc(100% + 8px); right: 0; display: flex; gap: 5px; padding: 7px; border: 1px solid var(--border-color); border-radius: 14px; background: var(--panel-bg); box-shadow: 0 8px 24px rgba(0,0,0,0.18); z-index: 1200; }
        #theme-menu[hidden] { display: none; }
        #theme-menu button { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-color); cursor: pointer; }
        #theme-menu button:hover { background: var(--panel-soft); }
        #theme-menu button[aria-checked="true"] { border-color: var(--accent-color, #3b82f6); background: var(--panel-soft); }
        #theme-menu button:focus-visible, #theme-toggle-btn:focus-visible { outline: 2px solid var(--accent-color, #3b82f6); outline-offset: 2px; }
        .icon-btn {
            width: 40px;
            height: 40px;
            border: 1px solid var(--border-color);
            border-radius: 50%;
            background: var(--panel-bg);
            color: var(--text-color);
            cursor: pointer;
            font-size: 1rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .icon-btn:hover { background: var(--panel-soft); }

        #sidebar {
            width: min(320px, calc(100vw - 28px));
            height: calc(100dvh - 20px);
            top: 10px;
            left: 10px;
            padding: 16px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 18px;
            background: var(--sidebar-bg);
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
        }
        .sidebar-header { min-height: 44px; margin-bottom: 10px; }
        .sidebar-header-copy { display: flex; flex-direction: column; gap: 2px; }
        .sidebar-header-copy strong { font-size: 1rem; }
        .sidebar-header-copy span { color: #9299a6; font-size: 0.74rem; font-weight: 400; }
        #sidebar .menu-toggle-btn { color: white !important; border: 1px solid rgba(255,255,255,.12); }
        #sidebar .menu-toggle-btn::before { content: "×"; font-size: 1.45rem; }
        #sidebar .btn { min-height: 44px; border-radius: 12px; }
        #sidebar .btn-primary { background: #f3f4f6; color: #17191d; }
        #sidebar .btn-primary:hover { background: #ffffff; }
        #sidebar .btn-secondary { background: var(--sidebar-soft); }
        #session-list { margin: 12px -4px 12px; padding: 0 4px; }
        .session-item { min-height: 46px; padding: 11px 12px; border-radius: 12px; background: transparent; color: #d8dbe1; }
        .session-item:hover { background: var(--sidebar-soft); }
        .session-item.active { background: #2b2f36; box-shadow: inset 3px 0 0 var(--primary-color); }
        .session-item > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        #sidebar-user-info { border-radius: 12px !important; border: 0 !important; background: var(--sidebar-soft) !important; padding: 10px !important; }
        #sidebar-overlay { background: rgba(10, 12, 16, 0.58); backdrop-filter: blur(5px); }

        #chat-box {
            width: min(920px, 100%);
            margin: 0 auto;
            padding: clamp(24px, 5vh, 54px) clamp(16px, 4vw, 42px) 32px;
            gap: 22px;
            scroll-behavior: smooth;
            overscroll-behavior-y: contain;
            -webkit-overflow-scrolling: touch;
        }
        .message {
            max-width: min(78%, 720px);
            padding: 15px 18px;
            border-radius: 20px !important;
            box-shadow: none;
            line-height: 1.62;
        }
        .user-message {
            background: var(--user-bubble);
            color: var(--user-text);
            border: 1px solid color-mix(in srgb, var(--user-bubble) 80%, #ffffff 20%);
            white-space: pre-wrap;
        }
        .ai-message {
            padding-right: 18px;
            background: var(--assistant-bubble);
            color: var(--text-color);
            border: 1px solid var(--border-color);
            box-shadow: var(--shadow-soft);
        }
        .ai-message pre { border-radius: 14px; }
        .ai-message code { background: var(--panel-soft); }
        .ai-message img, .ai-message svg { border-radius: 14px; }
        .welcome-message {
            max-width: 560px;
            margin: auto;
            padding: 26px !important;
            color: var(--text-color);
            background: transparent;
            box-shadow: none;
            font-size: clamp(1rem, 2vw, 1.16rem);
        }
        .msg-tts-controls {
            position: static;
            width: fit-content;
            margin-top: 12px;
            padding: 3px;
            background: var(--panel-soft);
            border: 1px solid var(--border-color);
            box-shadow: none;
        }
        .msg-tts-btn { background: transparent; border: 0; color: var(--primary-color); }

        #input-container {
            width: min(920px, calc(100% - 32px));
            margin: 0 auto max(14px, env(safe-area-inset-bottom));
            border: 0;
            background: transparent;
            z-index: 20;
        }
        #preview-area { padding: 8px 12px; margin-bottom: 8px; border-radius: 16px; background: var(--panel-bg); border: 1px solid var(--border-color); }
        .preview-item { border-radius: 12px; background: var(--panel-soft); }
        #input-area {
            min-height: 70px;
            padding: 8px;
            gap: 8px;
            border: 1px solid var(--border-color);
            border-radius: 26px;
            background: var(--panel-bg);
            box-shadow: 0 16px 38px rgba(23, 25, 29, 0.12);
        }
        .input-wrapper {
            min-width: 0;
            height: auto;
            min-height: 52px;
            padding-left: 4px;
            border: 0;
            border-radius: 20px;
            background: transparent;
        }
        .upload-trigger-btn {
            width: 42px;
            height: 42px;
            flex: 0 0 42px;
            border-radius: 50%;
            color: var(--text-color);
            background: var(--panel-soft);
            font-size: 1.5rem;
        }
        #user-input { min-height: 48px; max-height: 150px; padding: 13px 10px; color: var(--text-color); }
        #user-input::placeholder { color: var(--muted-color); }
        #mic-btn, #send-btn {
            width: 52px !important;
            height: 52px !important;
            flex: 0 0 52px;
            border-radius: 50% !important;
            background: var(--text-color);
            color: var(--bg-color);
            border: 0;
            font-size: 0 !important;
        }
        #mic-btn::before { content: "🎤"; display: block; font-size: 1.55rem; line-height: 1; }
        #mic-btn::after, #mic-btn span { display: none; }
        #send-btn::before { content: "➤"; font-size: 1.15rem; }
        #mic-btn:hover, #send-btn:hover { background: var(--primary-color); transform: none; }
        .composer-controls { display: flex; align-items: center; gap: 6px; margin-left: 6px; }
        .composer-controls:empty { display: none; }
        .model-control-group { display: flex; align-items: stretch; gap: 8px; min-width: 0; padding: 4px; border: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent); border-radius: 18px; background: color-mix(in srgb, var(--panel-bg) 84%, var(--panel-soft) 16%); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
        .model-control { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 0 4px; border-radius: 13px; transition: background 0.2s ease; }
        .model-control.primary { flex: 1 1 260px; }
        .model-control.secondary { flex: 0 0 142px; }
        .model-control:focus-within { background: color-mix(in srgb, var(--primary-color) 9%, transparent); }
        .model-control-label { padding: 2px 10px 0; color: var(--muted-color); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; line-height: 1; text-transform: uppercase; pointer-events: none; }
        .model-control-group #tokens-select { display: block; }
        .model-control-group.is-open #tokens-select { display: block; }
        .model-control-group.is-open #model-select { max-width: 240px; }
        select {
            min-width: 0;
            max-width: 240px;
            height: 42px;
            padding: 0 30px 0 10px;
            border: 1px solid var(--border-color);
            border-radius: 13px;
            background: transparent;
            color: var(--text-color);
            appearance: none;
            -webkit-appearance: none;
            background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
            background-position: calc(100% - 15px) 18px, calc(100% - 10px) 18px;
            background-size: 5px 5px, 5px 5px;
            background-repeat: no-repeat;
            cursor: pointer;
        }
        select:hover { border-color: color-mix(in srgb, var(--primary-color) 55%, var(--border-color)); }
        .model-control.primary select { max-width: none; width: 100%; }
        .model-control.secondary select { max-width: none; width: 100%; }
        .model-control select { flex: 0 0 42px; height: 42px; }
        select optgroup, select option { color: var(--text-color); background: var(--panel-bg); }

        /* 設定視窗的語音選單不能沿用瀏覽器的反白/深色預設，否則部分手機會看起來像空白。 */
        #settings-modal #tts-voice-gender {
            width: 100%;
            min-height: 46px;
            background-color: var(--panel-soft) !important;
            color: var(--text-color) !important;
            border-color: var(--border-color) !important;
            color-scheme: light dark;
            opacity: 1 !important;
        }
        #settings-modal #tts-voice-gender option,
        #settings-modal #tts-voice-gender optgroup {
            background-color: var(--panel-bg) !important;
            color: var(--text-color) !important;
        }

        .modal {
            padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
            background: rgba(12, 14, 18, 0.62);
            backdrop-filter: blur(10px);
            overflow-y: auto;
        }
        .modal-content {
            width: min(430px, 100%);
            max-height: calc(100dvh - 32px);
            overflow-y: auto;
            padding: 26px;
            gap: 14px;
            border: 1px solid var(--border-color);
            border-radius: 20px;
            background: var(--panel-bg);
            color: var(--text-color);
            box-shadow: 0 28px 80px rgba(0,0,0,.28);
        }
        .modal-content input {
            min-height: 48px;
            padding: 12px 14px;
            border-radius: 12px;
            background: var(--panel-soft);
            color: var(--text-color);
        }
        .modal-content .btn { min-height: 48px; border-radius: 12px; }
        .modal-content p { color: var(--muted-color) !important; }
        #user-status-text { background: var(--panel-soft); color: var(--text-color); border-radius: 12px; }
        #settings-modal .modal-content > div[style], #upgrade-modal .modal-content > div > div { background-color: var(--panel-bg); border-radius: 16px !important; }
        #upgrade-modal .modal-content { width: min(760px, 100%); max-width: 760px; }
        #upgrade-modal .modal-content > div[style*="display: flex"] { align-items: stretch; }
        #upgrade-modal .modal-content > div[style*="display: flex"] > div { min-width: 190px !important; padding: 20px !important; }

        /* 方案比較面板 */
        #upgrade-modal .plans-modal-content { width: min(1080px, 100%); max-width: 1080px; padding: 28px; gap: 18px; }
        .plans-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
        .plans-heading h3 { text-align: left; margin: 0; font-size: 1.65rem; }
        .plans-heading p { max-width: 520px; margin: 3px 0 0; font-size: 0.92rem; line-height: 1.55; }
        .region2-banner { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid #b7e4d4; border-radius: 12px; background: #effbf6; color: #116149; font-size: 0.9rem; line-height: 1.45; }
        .region2-banner strong { white-space: nowrap; }
        .plans-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
        .plan-card { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 18px 15px 15px; border: 1px solid var(--border-color); border-radius: 14px; background: var(--panel-bg); box-shadow: 0 7px 22px rgba(15, 23, 42, 0.06); }
        .plan-card.is-featured { border: 2px solid #0d9f78; padding: 17px 14px 14px; box-shadow: 0 12px 30px rgba(13, 159, 120, 0.18); }
        .plan-badge { align-self: flex-start; min-height: 22px; padding: 3px 8px; border-radius: 999px; background: #e8eef7; color: #52647a; font-size: 0.68rem; font-weight: 700; }
        .plan-card.is-featured .plan-badge { background: #d7f5e9; color: #087653; }
        .plan-card h4 { margin: 12px 0 5px; font-size: 1.16rem; }
        .plan-card .plan-price { margin: 0 0 12px; color: var(--text-color); font-size: 1.55rem; font-weight: 800; }
        .plan-price span { color: var(--muted-color); font-size: 0.78rem; font-weight: 500; }
        .plan-card ul { display: grid; gap: 8px; flex: 1; margin: 0 0 16px; padding: 0; list-style: none; color: var(--muted-color); font-size: 0.8rem; line-height: 1.4; }
        .plan-card li::before { content: "✓"; display: inline-block; width: 17px; color: #0d9f78; font-weight: 800; }
        .plan-card .btn { margin-top: auto; min-height: 44px; padding: 9px 8px; font-size: 0.86rem; }
        .plans-footnote { margin: 0; color: var(--muted-color); font-size: 0.76rem; line-height: 1.5; text-align: center; }

        @media (min-width: 769px) and (orientation: landscape) {
            #top-bar > #model-control-group { display: none; }
            .composer-controls .model-control-group { display: flex; }
            .composer-controls .model-control.primary { flex: 0 1 210px; width: min(210px, 22vw); }
            .composer-controls .model-control.secondary { flex-basis: 132px; }
        }

        @media (max-width: 768px), (orientation: portrait) {
            body, #main-content { width: 100%; max-width: 100%; }
            #top-bar {
                min-height: 112px;
                height: auto;
                padding: max(10px, env(safe-area-inset-top)) 12px 10px;
                display: grid;
                grid-template-columns: auto minmax(0, 1fr) auto;
                grid-template-rows: auto auto;
                align-items: center;
                column-gap: 8px;
                row-gap: 10px;
            }
            #top-bar > .menu-toggle-btn { grid-column: 1; grid-row: 1; }
            .top-brand { grid-column: 2; grid-row: 1; margin-right: 0; min-width: 0; }
            .top-brand span { display: none; }
            .top-actions { grid-column: 3; grid-row: 1; margin-left: 0; }
            #top-bar > .model-control-group {
                grid-column: 1 / 4;
                grid-row: 2;
                display: flex;
                width: 100%;
                min-width: 0;
            }
            #top-bar > .top-actions:has(+ .model-control-group) { grid-column: 3; grid-row: 2; }
            #top-bar > .model-control-group #model-select {
                display: block;
                flex: 0 0 42px;
                width: auto;
                max-width: none;
                height: 42px !important;
            }
            #top-bar > .model-control-group #tokens-select {
                display: block;
                flex: 0 0 42px;
                width: 118px;
                max-width: 118px;
                min-width: 118px;
                height: 42px !important;
            }
            .composer-controls { display: none; }
            #chat-box {
                width: 100%;
                max-width: none;
                margin: 0;
                padding: 20px 12px calc(var(--mobile-input-height, 86px) + 38px + env(safe-area-inset-bottom));
                gap: 16px;
                scroll-padding-bottom: calc(var(--mobile-input-height, 86px) + 38px + env(safe-area-inset-bottom));
            }
            .message { max-width: 88%; padding: 13px 15px; border-radius: 18px !important; }
            #input-container {
                position: fixed;
                left: 0;
                right: 0;
                bottom: max(8px, env(safe-area-inset-bottom));
                width: auto;
                margin: 0;
                padding: 0 10px;
                background: var(--bg-color);
                box-shadow: none;
            }
            #input-area { min-height: 64px; padding: 6px; border-radius: 24px; }
            .input-wrapper { min-height: 50px; background: transparent; }
            #mic-btn, #send-btn { width: 50px !important; height: 50px !important; flex-basis: 50px; }
            .modal-content { padding: 22px 18px; border-radius: 18px; }
            #upgrade-modal .plans-modal-content { padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); }
            .plans-heading { display: block; }
            .plans-heading p { margin-top: 7px; }
            .region2-banner { align-items: flex-start; }
            .region2-banner strong { white-space: normal; }
            .plans-grid { grid-template-columns: 1fr; gap: 10px; }
            .plan-card, .plan-card.is-featured { padding: 16px; }
            .plan-card ul { flex: none; margin-bottom: 13px; }
        }

        @media (max-height: 560px) and (orientation: landscape) {
            #top-bar { min-height: 52px !important; height: 52px !important; }
            #chat-box { padding-top: 14px !important; padding-bottom: 14px !important; }
            #input-container { margin-bottom: 6px; }
            #input-area { min-height: 56px !important; }
        }

        /* 現代主義即時語音介面 */
        .voice-modal-modern {
            display: none;
            position: fixed;
            inset: 0;
            padding: 0;
            overflow: hidden;
            flex-direction: column;
            align-items: stretch;
            justify-content: stretch;
            background: #11151b;
            color: #f6f7f9;
            isolation: isolate;
        }
        .voice-modal-modern::before {
            content: "";
            position: absolute;
            inset: 0;
            z-index: -3;
            background: linear-gradient(135deg, #0d1117 0%, #151b23 52%, #0d1218 100%);
        }
        .voice-backdrop-grid {
            position: absolute;
            inset: 0;
            z-index: -2;
            opacity: .16;
            background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
            background-size: 44px 44px;
            mask-image: linear-gradient(to bottom, black, transparent 78%);
        }
        .voice-modal-modern #voice-video-preview {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            z-index: -1;
            opacity: .44;
            filter: saturate(.72) contrast(1.05);
        }
        .voice-topbar {
            display: grid;
            grid-template-columns: 1fr auto 1fr;
            align-items: center;
            gap: 16px;
            width: 100%;
            padding: calc(18px + env(safe-area-inset-top)) clamp(18px, 5vw, 54px) 18px;
            z-index: 2;
        }
        .voice-brand { display: flex; align-items: center; gap: 10px; font-size: .92rem; font-weight: 700; letter-spacing: .02em; }
        .voice-brand-mark { width: 10px; height: 10px; background: #6ee7c0; border-radius: 2px; transform: rotate(45deg); box-shadow: 0 0 18px rgba(110,231,192,.7); }
        .voice-live-status { display: inline-flex; align-items: center; gap: 7px; color: #a8b0bb; font: 700 .65rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .12em; }
        .voice-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #6ee7c0; box-shadow: 0 0 0 4px rgba(110,231,192,.12); }
        .voice-top-actions { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 8px; z-index: 4; }
        .voice-top-btn { min-width: 42px; height: 38px; padding: 0 13px; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; background: rgba(255,255,255,.07); color: #f6f7f9; cursor: pointer; font-size: .78rem; font-weight: 700; transition: background .2s, border-color .2s; }
        .voice-top-btn:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); }
        .voice-stage { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 18px 10px; overflow: hidden; z-index: 1; }
        .voice-stage-label { margin-bottom: clamp(22px, 5vh, 48px); color: #7e8996; font: 700 .62rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .2em; }
        .voice-mic-orbit { --meter-radius: calc(clamp(210px, 42vw, 330px) / 2 - 8px); position: relative; width: clamp(210px, 42vw, 330px); height: clamp(210px, 42vw, 330px); display: flex; align-items: center; justify-content: center; margin-bottom: clamp(18px, 4vh, 34px); }
        .voice-orbit { position: absolute; inset: 0; border: 1px solid rgba(110,231,192,.2); border-radius: 50%; animation: voice-modern-pulse 2.3s ease-out infinite; pointer-events: none; }
        .voice-orbit-two { inset: 15%; border-color: rgba(142,165,255,.28); animation-delay: .75s; }
        .voice-mic-core { --orb-scale: 1; --orb-glow: 18px; --orb-band-blur: 7px; --orb-band-opacity: .78; --orb-band-angle: -2deg; --orb-band-scale: 1; position: relative; z-index: 2; width: 132px; height: 132px; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 50%; clip-path: circle(50% at 50% 50%); -webkit-clip-path: circle(50% at 50% 50%); mask-image: radial-gradient(circle at center, #000 0 70%, transparent 71%); -webkit-mask-image: radial-gradient(circle at center, #000 0 70%, transparent 71%); mask-size: 100% 100%; -webkit-mask-size: 100% 100%; contain: paint; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: radial-gradient(circle at 50% 46%, rgba(255,255,255,.98) 0 7%, rgba(234,239,255,.93) 22%, rgba(153,167,255,.92) 55%, rgba(97,78,246,.98) 100%); border: 1px solid rgba(255,255,255,.54); box-shadow: 0 18px 52px rgba(56,45,190,.3), 0 0 var(--orb-glow) rgba(126,145,255,.44), inset 0 0 25px rgba(255,255,255,.34); transform: translateZ(0) scale(var(--orb-scale)); transition: transform .14s ease-out, box-shadow .18s ease-out; isolation: isolate; }
        .voice-mic-core::before { content: ""; position: absolute; inset: -22%; border-radius: 44% 56% 48% 52%; background: conic-gradient(from 20deg, rgba(74,64,235,.92), rgba(137,163,255,.78), rgba(244,247,255,.9), rgba(105,83,246,.9), rgba(74,64,235,.92)); filter: blur(13px); animation: voice-orb-drift 9s linear infinite; }
        .voice-mic-core::after { content: ""; position: absolute; z-index: 2; left: -12%; right: -12%; top: 39%; height: 26%; border-radius: 50%; background: linear-gradient(to bottom, rgba(255,255,255,.12), rgba(255,255,255,.96) 42%, rgba(240,244,255,.84) 66%, rgba(255,255,255,.08)); filter: blur(var(--orb-band-blur)); opacity: var(--orb-band-opacity); transform: rotate(var(--orb-band-angle)) scaleX(var(--orb-band-scale)); transition: opacity .16s ease, transform .16s ease, filter .16s ease; }
        .voice-orb-sheen { position: absolute; z-index: 3; inset: 7%; border-radius: 50%; background: radial-gradient(circle at 34% 22%, rgba(255,255,255,.72), transparent 31%), radial-gradient(circle at 72% 78%, rgba(100,86,245,.38), transparent 38%); mix-blend-mode: screen; animation: voice-orb-sheen 6.5s ease-in-out infinite alternate; }
        .voice-mic-glyph { position: relative; display: block; width: 23px; height: 34px; border: 4px solid #f6f7f9; border-radius: 14px; }
        .voice-mic-glyph::before { content: ""; position: absolute; left: 50%; bottom: -16px; width: 4px; height: 13px; background: #6ee7c0; transform: translateX(-50%); border-radius: 3px; }
        .voice-mic-glyph::after { content: ""; position: absolute; left: 50%; bottom: -19px; width: 28px; height: 11px; border: 3px solid #f6f7f9; border-top: 0; border-radius: 0 0 14px 14px; transform: translateX(-50%); }
        .voice-status-modern { min-height: 1.4em; color: #f6f7f9; font-size: clamp(1.1rem, 2.5vw, 1.45rem); font-weight: 650; text-align: center; }
        .voice-transcript-modern { min-height: 1.5em; max-width: min(680px, 90vw); margin-top: 10px; color: #aab3bf; font-size: .95rem; line-height: 1.5; text-align: center; overflow-wrap: anywhere; }
        .voice-signal { display: flex; align-items: center; justify-content: center; gap: 4px; height: 24px; margin-top: 13px; opacity: .68; }
        .voice-signal i { width: 3px; height: 8px; border-radius: 4px; background: #6ee7c0; animation: voice-signal-bounce 1s ease-in-out infinite; }
        .voice-signal i:nth-child(2), .voice-signal i:nth-child(6) { animation-delay: .12s; height: 13px; }
        .voice-signal i:nth-child(3), .voice-signal i:nth-child(5) { animation-delay: .24s; height: 18px; }
        .voice-signal i:nth-child(4) { animation-delay: .36s; height: 23px; }
        .voice-subtitles-modern { width: min(700px, 92vw); max-height: min(190px, 24vh); margin-top: 18px; padding: 14px 16px; border: 1px solid rgba(255,255,255,.14); border-radius: 16px; background: rgba(10,14,19,.72); box-shadow: 0 12px 35px rgba(0,0,0,.2); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
        .voice-caption-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; color: #f4f6f8; font-size: .92rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
        .voice-caption-row + .voice-caption-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.1); }
        .voice-caption-label { color: #6ee7c0; font: 700 .65rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; padding-top: 4px; }
        .voice-caption-user { color: #b9c7ff; }
        .voice-action-row { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 34px); width: 100%; padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); z-index: 2; }
        .voice-action-btn { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 58px; border: 1px solid rgba(255,255,255,.16); border-radius: 22px; color: #f6f7f9; background: rgba(255,255,255,.09); box-shadow: 0 10px 22px rgba(0,0,0,.2); cursor: pointer; font-size: 1.2rem; transition: transform .2s, background .2s, border-color .2s; }
        .voice-action-btn:hover { transform: translateY(-2px); background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.32); }
        .voice-action-btn-main { width: 72px; height: 72px; border-radius: 24px; background: #ef6670; border-color: rgba(255,255,255,.24); font-size: 2.2rem; }
        .voice-action-btn-main span { line-height: 1; font-weight: 300; }
        .voice-mic-btn { background: #6b7cff; }
        .voice-mic-btn .voice-mic-glyph { transform: scale(.7); }
        .voice-share-btn { background: rgba(255,255,255,.1); }
        .voice-share-btn.is-active { background: #31d3a2; color: #071411; }
        .voice-share-btn.is-unavailable { opacity: .52; cursor: not-allowed; box-shadow: none; }
        .voice-camera-btn.is-active { background: #31d3a2; color: #071411; }
        .voice-topbar .voice-top-actions .voice-top-btn { flex: 0 0 auto; width: 64px; min-width: 64px; margin-left: 0; padding: 0 8px; white-space: nowrap; overflow: hidden; }
        .voice-subtitle-btn.is-active { background: rgba(110,231,192,.2); border-color: rgba(110,231,192,.5); color: #d9fff3; }
        .voice-camera-switch-btn { display: none; align-items: center; justify-content: center; }
        .voice-camera-switch-icon { position: relative; display: block; width: 24px; height: 16px; border: 2px solid currentColor; border-radius: 5px; }
        .voice-camera-switch-icon::before { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; border: 2px solid currentColor; border-radius: 50%; transform: translate(-50%, -50%); }
        .voice-camera-switch-icon::after { content: ""; position: absolute; left: 3px; top: -7px; width: 9px; height: 5px; border: 2px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; }
        .voice-brand { grid-column: 2; grid-row: 1; justify-self: center; }
        .voice-live-status { grid-column: 1; grid-row: 1; justify-self: start; }
        @keyframes voice-modern-pulse { 0% { transform: scale(.72); opacity: .05; } 22% { opacity: .85; } 100% { transform: scale(1.18); opacity: 0; } }
        @keyframes voice-signal-bounce { 0%, 100% { transform: scaleY(.55); opacity: .45; } 50% { transform: scaleY(1.12); opacity: 1; } }
        @keyframes voice-orb-drift { to { transform: rotate(360deg); } }
        @keyframes voice-orb-sheen { from { transform: translate3d(-3%, -2%, 0) rotate(-5deg); } to { transform: translate3d(4%, 3%, 0) rotate(6deg); } }

        @supports (-webkit-touch-callout: none) {
            .voice-mic-core::before { inset: 0; border-radius: 50%; filter: none; }
            .voice-mic-core::after { left: 0; right: 0; filter: blur(4px); }
        }

        @media (max-width: 600px) {
            .voice-topbar { grid-template-columns: 1fr auto 1fr; padding-left: 16px; padding-right: 16px; }
            .voice-live-status { display: none; }
            .voice-brand { grid-column: 2; }
            .voice-top-actions { top: calc(10px + env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
            .voice-stage { justify-content: flex-start; padding-top: 8vh; }
            .voice-stage-label { margin-bottom: 5vh; }
            .voice-mic-orbit { --meter-radius: 101px; width: 218px; height: 218px; }
            .voice-mic-core { width: 112px; height: 112px; }
            .voice-subtitles-modern { max-height: 23vh; margin-top: 14px; }
            .voice-action-row { gap: 12px; padding-top: 12px; }
        }
        @media (max-height: 620px) {
            .voice-topbar { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 8px; }
            .voice-stage { padding-top: 0; }
            .voice-stage-label { margin-bottom: 10px; }
            .voice-mic-orbit { --meter-radius: 77px; width: 170px; height: 170px; margin-bottom: 10px; }
            .voice-mic-core { width: 88px; height: 88px; }
            .voice-subtitles-modern { max-height: 20vh; margin-top: 8px; }
            .voice-action-row { padding-top: 8px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
        }
    
[hidden] { display:none !important; }
#sync-status { font-size:.8rem; margin:4px 12px; color:#64748b; overflow-wrap:anywhere; }
#sync-status[data-failed="true"] { color:#b91c1c; }
.role-badge { background:#2563eb;padding:2px 6px;border-radius:4px;color:white;font-size:.75rem; }
.retention-notice { font-size:.85rem;line-height:1.5;color:#64748b; }
.owner-records { max-height:45vh;overflow:auto; }
.owner-records pre { white-space:pre-wrap;word-break:break-word;max-height:250px;overflow:auto; }
.ai-message pre { overflow-x:auto; }
.delete-session:focus-visible { outline:2px solid #2563eb; }
.reply-notice { font-size:.85rem; color:#b45309; margin-top:12px; }
[data-theme="dark"] .reply-notice, [data-theme="dark"] #sync-status[data-failed="true"] { color:#fbbf24; }
.retry-answer { display:block; max-width:320px; margin:12px auto; }
#sidebar:not(.open) { transform:translateX(calc(-100% - 20px)); visibility:hidden; }
#sidebar.open { visibility:visible; }

/* Voice entrance and a sound-driven clockwise ring. */
.voice-modal-modern { --voice-level:0; animation:voice-room-enter .55s ease-out both; }
.voice-ambient { position:absolute; inset:0; overflow:hidden; pointer-events:none; z-index:-2; }
.voice-ambient i { position:absolute; width:65vmax; height:65vmax; border-radius:50%; opacity:.19; background:radial-gradient(ellipse, #6958cb, transparent 66%); animation:voice-ambient-reveal 1.3s ease-out both; }
.voice-ambient i:nth-child(1) { left:-24vmax; top:-24vmax; }
.voice-ambient i:nth-child(2) { right:-25vmax; bottom:-25vmax; background:radial-gradient(ellipse, #139582, transparent 66%); animation-delay:.1s; }
.voice-ambient i:nth-child(3) { width:40vmax; height:40vmax; left:35%; top:25%; opacity:.1; animation-delay:.2s; }
.voice-mic-orbit { flex-shrink:0; animation:voice-orb-enter 1s cubic-bezier(.2,.8,.25,1) .12s both; }
.voice-halo { position:absolute; inset:9%; border-radius:50%; background:radial-gradient(circle, transparent 27%, rgba(143,119,255,.22) 48%, transparent 69%); opacity:.7; transition:opacity .4s; }
.voice-sound-ring { position:absolute; inset:-5%; width:110%; height:110%; overflow:visible; pointer-events:none; }
.voice-ring-guide { fill:none; stroke:rgba(166,187,245,.13); stroke-width:1; }
.voice-ring-line { fill:none; stroke:#a6cfed; stroke-width:1.8; stroke-linejoin:round; }
.voice-ring-glow { fill:none; stroke:#998aff; stroke-width:6; opacity:.35; filter:blur(5px); }
.voice-orbit { animation:none; opacity:.12; inset:8%; }
.voice-orbit-two { inset:23%; opacity:.15; }
.voice-topbar { animation:voice-controls-enter .7s ease-out .1s both; }
.voice-stage-label { animation:voice-controls-enter .8s ease-out .2s both; }
.voice-status-modern, .voice-transcript-modern { animation:voice-controls-enter .65s ease-out .4s both; }
.voice-action-row { animation:voice-controls-enter .7s ease-out .45s both; }
.voice-signal i { animation:none; transform:scaleY(.45); opacity:.45; }
.voice-modal-modern[data-state="hearing"] .voice-signal i,
.voice-modal-modern[data-state="speaking"] .voice-signal i { animation:voice-signal-bounce 1s ease-in-out infinite; }
.voice-modal-modern[data-state="thinking"] .voice-signal i { background:#baa5ff; animation:voice-signal-bounce 1.8s ease-in-out infinite; }
.voice-modal-modern[data-state="hearing"] .voice-ring-line { stroke:#a2edda; }
.voice-modal-modern[data-state="speaking"] .voice-ring-line { stroke:#b5baff; }
.voice-modal-modern[data-state="hearing"] .voice-halo, .voice-modal-modern[data-state="speaking"] .voice-halo { opacity:1; }
.voice-modal-modern[data-state="paused"] .voice-mic-orbit, .voice-modal-modern[data-state="error"] .voice-mic-orbit { filter:saturate(.3); }
.voice-modal-modern[data-state="paused"] .voice-live-dot, .voice-modal-modern[data-state="error"] .voice-live-dot { background:#eeb5a6; box-shadow:0 0 0 4px rgba(238,181,166,.1); }
.voice-modal-modern[data-state="connecting"] .voice-live-dot, .voice-modal-modern[data-state="thinking"] .voice-live-dot { background:#b3a5f6; }
.voice-modal-modern[data-state="paused"] .voice-mic-core::before, .voice-modal-modern[data-state="paused"] .voice-orb-sheen,
.voice-modal-modern[data-state="error"] .voice-mic-core::before, .voice-modal-modern[data-state="error"] .voice-orb-sheen { animation-play-state:paused; }
.voice-action-btn:focus-visible { outline:2px solid #b2f8df; outline-offset:3px; }
@keyframes voice-room-enter { from { opacity:0; } to { opacity:1; } }
@keyframes voice-ambient-reveal { from { opacity:0; transform:scale(.75); } to { transform:scale(1); } }
@keyframes voice-orb-enter { 0% { opacity:0; transform:translateY(20px) scale(.62); } 75% { opacity:1; transform:translateY(0) scale(1.04); } 100% { opacity:1; transform:translateY(0) scale(1); } }
@keyframes voice-controls-enter { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@media (max-width:600px) {
  .voice-stage { padding-top:clamp(10px, 4vh, 32px); overflow-y:auto; }
  .voice-stage-label { margin-bottom:clamp(12px, 3vh, 28px); }
}
@media (max-height:620px) {
  .voice-stage { overflow-y:auto; justify-content:flex-start; }
  .voice-stage-label { display:none; }
  .voice-mic-orbit { width:140px; height:140px; margin-bottom:8px; }
  .voice-mic-core { width:80px; height:80px; }
  .voice-signal { display:none; }
}
@media (prefers-reduced-motion:reduce) {
  .voice-modal-modern, .voice-modal-modern *, .voice-modal-modern *::before, .voice-modal-modern *::after { animation:none !important; transition:none !important; }
  .voice-mic-core { transform:none !important; }
  .voice-halo { transform:none !important; }
}

/* Captions have their own row; shrinking the stage cannot hide them. */
#voice-modal { height: var(--voice-viewport-height, 100dvh); bottom: auto; }
#voice-modal, #voice-modal * { box-sizing: border-box; }
#voice-modal .voice-topbar { flex: 0 0 auto; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
#voice-modal .voice-top-actions { position: static; grid-column: 3; grid-row: 1; justify-self: end; flex-direction: row; gap: 6px; }
#voice-modal .voice-stage { flex: 1 1 0; min-height: 0; justify-content: flex-start; overflow-y: auto; padding: 12px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
#voice-modal .voice-stage-label { flex: 0 0 auto; margin: 0 0 12px; }
#voice-modal .voice-mic-orbit { width: clamp(110px, 29dvh, 300px); height: clamp(110px, 29dvh, 300px); margin: 4px 0 14px; }
#voice-modal .voice-mic-core { width: 44%; height: 44%; }
#voice-modal .voice-status-modern { flex: 0 0 auto; width: min(100%, 700px); margin: 0; font-size: clamp(1rem, 2.4vw, 1.35rem); line-height: 1.5; overflow-wrap: anywhere; }
#voice-modal .voice-transcript-modern { flex: 0 0 auto; width: min(100%, 680px); margin: 6px 0 0; }
#voice-modal .voice-transcript-modern:empty { display: none; }
#voice-modal .voice-signal { flex: 0 0 24px; margin-top: 8px; }
#voice-subtitles-container { flex: 0 0 auto; align-self: center; width: min(700px, calc(100% - 32px)); min-height: 86px; max-height: min(240px, 30dvh); margin: 8px 0 0; padding: 12px 14px; overflow-y: auto; scroll-padding: 12px; }
#voice-modal .voice-action-row { flex: 0 0 auto; padding: 12px max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); gap: clamp(10px, 3vw, 30px); }
#voice-modal .voice-action-btn { flex: 0 0 auto; }
#voice-modal .voice-stage, #voice-subtitles-container { scrollbar-width: thin; scrollbar-color: #465360 transparent; }
#voice-modal[data-state="ready"] .voice-mic-btn { background: #6b7cff; box-shadow: 0 0 0 3px rgba(164,175,255,.35); }
@media (max-width: 600px) {
  #voice-modal .voice-topbar { grid-template-columns: auto 1fr; }
  #voice-modal .voice-brand { grid-column: 1; justify-self: start; }
  #voice-modal .voice-top-actions { grid-column: 2; }
}

/* Size the orb from the space remaining after captions, status and controls,
   rather than from the entire device height. No scrolling decorative stage. */
#voice-modal .voice-stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; justify-content: stretch; align-items: stretch; overflow: hidden; padding-top: 4px; gap: 6px; }
#voice-modal .voice-visual { position: relative; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; }
#voice-modal .voice-mic-orbit { width: var(--voice-orb-size, min(28dvh, 260px)); height: var(--voice-orb-size, min(28dvh, 260px)); margin: 0; }
#voice-modal .voice-stage-label { position: absolute; top: 4px; left: 0; width: 100%; text-align: center; margin: 0; }
#voice-modal .voice-signal { position: absolute; bottom: 0; left: 0; width: 100%; margin: 0; }
#voice-modal .voice-visual.is-compact .voice-stage-label, #voice-modal .voice-visual.is-compact .voice-signal { display: none; }
#voice-modal .voice-summary { min-height: 0; max-height: min(180px, 24dvh); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #465360 transparent; }
#voice-modal .voice-status-modern, #voice-modal .voice-transcript-modern { margin-left: auto; margin-right: auto; }
#voice-modal .voice-transcript-modern { max-height: 4.5em; overflow-y: auto; scrollbar-width: thin; }
#voice-subtitles-container { min-height: 0; max-height: min(280px, 32dvh); }
@media (max-height: 650px) {
  #voice-modal .voice-stage-label, #voice-modal .voice-signal { display: none; }
  #voice-modal .voice-stage { padding-top: 4px; }
  #voice-modal .voice-action-btn { width: 48px; height: 48px; border-radius: 16px; }
  #voice-modal .voice-action-btn-main { width: 54px; height: 54px; }
  #voice-modal .voice-action-row { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  #voice-subtitles-container { max-height: 28dvh; min-height: 64px; margin-top: 4px; padding: 8px 12px; }
}
