/**
 * JexHRAI 統一 UI 服務樣式 (JexHRAI Unified UI Service Styles)
 *
 * 此檔案包含所有模組共用的 UI 樣式元件，經過現代化重構與分組管理。
 *
 * 目錄結構 (Table of Contents):
 * 1.  變數定義 (Variables)
 * 2.  基礎樣式 (Base Styles)
 * 3.  佈局與容器 (Layout & Containers)
 * 4.  Hero 橫幅系統 (Hero System)
 * 5.  對話與訊息系統 (Message System)
 * 6.  輸入區域系統 (Input System)
 * 7.  按鈕與控制項 (Buttons & Controls)
 * 8.  狀態與通知系統 (Status & Notifications)
 * 9.  回饋系統 (Feedback System)
 * 10. 附件系統 (Attachment System)
 * 11. 動畫系統 (Animation System)
 * 12. 響應式設計 (Responsive Design)
 *
 * @since 9.3.0
 * @version 8.82.1 (Refactored)
 */

/* ==========================================
 * 1. 變數定義 (Variables)
 * ========================================== */
/* 變數已移至 variables.css 統一管理 */

/* ==========================================
 * 2. 基礎樣式 (Base Styles)
 * ========================================== */

/* 統一段落樣式 - 僅限 JexHRAI 範圍，避免污染網站主題 */
.jexhrai-chat-wrapper p,
.jexhrai-coach-wrapper p,
.jexhrai-writing-wrapper p,
.jexhrai-option-wrapper p,
.jexhrai-conversation-wrapper p,
.jexhrai-button-wrapper p,
.jexhrai-flashcard-wrapper p,
.jexhrai-main-content-container p,
.jexhrai-cover-container p,
.jexhrai-login-cover p,
.jexhrai-user-dashboard-container p,
.jexhrai-user-settings-container p,
.jexhrai-auth-wrapper p {
    margin-top: 0em;
    margin-bottom: 0em;
}

.jexhrai-main-content-container {
    padding: 0rem;

}


/* ==========================================
 * 3. 佈局與容器 (Layout & Containers)
 * ========================================== */

/* 模組通用容器外觀 - 所有 AI 模組的統一外層樣式 */
.jexhrai-chat-wrapper,
.jexhrai-coach-wrapper,
.jexhrai-writing-wrapper,
.jexhrai-option-wrapper,
.jexhrai-conversation-wrapper,
.jexhrai-button-wrapper,
.jexhrai-flashcard-wrapper {
    border-radius: 0;
    padding: 3rem 2rem 4rem 2rem;
    margin: 0;
    box-sizing: border-box;
    /* 
     * 說明：改為 overflow: visible 以完整顯示載入動畫陰影
     */
    overflow: visible;
    border: 0px solid var(--md-sys-color-outline-variant);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 統一對話歷史容器 - 所有模組共用 */
.jexhrai-ai-talk {
    /*
     * 說明：統一採用 Clean White 對話區設計
     * - 寬度跟隨容器，並在內容較寬時限制最大寬度 800px 以提升閱讀性
     * - 背景維持純白，不額外加邊框與陰影，讓對話泡泡本身成為視覺主角
     */

    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0.5rem;
    flex-grow: 1;
    overflow-y: auto;
    border: 0;
    background-color: var(--jexhrai-bg-white);
    gap: 20px;
}

/* 滾動條樣式 */
.jexhrai-ai-talk::-webkit-scrollbar {
    width: 8px;
}

.jexhrai-ai-talk::-webkit-scrollbar-track {
    background: transparent;
    border-radius: var(--md-sys-shape-corner-small);
}

.jexhrai-ai-talk::-webkit-scrollbar-thumb {
    background-color: var(--jexhrai-scrollbar-track);
    border-radius: var(--md-sys-shape-corner-small);
    border: 2px solid transparent;
    background-clip: content-box;
}

.jexhrai-ai-talk::-webkit-scrollbar-thumb:hover {
    background-color: var(--jexhrai-scrollbar-thumb);
}

/* 統一回應容器樣式 */
.jexhrai-response-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 空容器自動隱藏，避免初始狀態產生多餘間距 */
.jexhrai-response-wrapper:empty,
.jexhrai-option-choices:empty {
    display: none;
}

/* 表格樣式 (僅限 jexhrai-main-content-container 內的表格) */
.jexhrai-main-content-container table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    background-color: var(--jexhrai-bg-white);
}

.jexhrai-main-content-container th,
.jexhrai-main-content-container td {
    border: 1px solid var(--jexhrai-border);
    padding: 12px 15px;
    text-align: left;
}

.jexhrai-main-content-container th {
    background-color: var(--jexhrai-bg-light);
    font-weight: bold;
    color: var(--jexhrai-text-main);
}

.jexhrai-main-content-container tr:nth-child(even) {
    background-color: var(--md-sys-color-surface-container-low);
}

.jexhrai-main-content-container tr:hover {
    background-color: var(--md-sys-color-surface-container);
}

.jexhrai-main-content-container strong {
    font-weight: bold;
}

/* ==========================================
 * 4. Hero 橫幅系統 (Hero System - Material Design 3)
 * ========================================== */

.jexhrai-hero {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 8fr) minmax(0, 2fr);
    /* 8:2 比例，優先留給左側資訊區 */
    gap: 0px;
    align-items: center;
    padding: 1rem;
    /* 增加內距 */
    box-sizing: border-box;
    border-radius: var(--jexhrai-radius-lg);
    /* Material 3 Surface Container Low + Magic Flow */
    background: linear-gradient(270deg, var(--md-sys-color-surface-container-low), var(--md-sys-color-surface-container), var(--md-sys-color-surface-container-low));
    background-size: 200% 100%;
    min-height: 120px;
    /* 保持高度下限 */
    overflow: hidden;
    /* 確保圖案不超出容器 */
    position: relative;
    border: none;
    /* 扁平化，無邊框 */
    animation: heroFlow 8s ease-in-out infinite;
    box-shadow: none;
    /* 扁平化，無陰影 */
    transition: box-shadow 0.3s ease;
    /* 為光暈效果準備 */
}

/* Hero 焦點光暈效果 (封面關閉後觸發) */
.jexhrai-hero.jexhrai-hero-glow-focus {
    animation: heroFlow 2s ease-in-out infinite, jexhraiHeroGlow 1s ease-out forwards;
    z-index: 10;
    /* 確保在最上層顯示光暈 */
    overflow: visible;
    /* 暫時允許溢出以顯示陰影 */
}

@keyframes jexhraiHeroGlow {
    0% {
        box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-sys-color-primary), transparent 50%), 0 0 2px color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    100% {
        box-shadow: 0 0 0 20px color-mix(in srgb, var(--md-sys-color-primary), transparent 100%), 0 0 20px color-mix(in srgb, var(--md-sys-color-primary), transparent 100%);
    }
}

/* 魔幻線條背景層 */
.jexhrai-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 10% 50%, color-mix(in srgb, var(--md-sys-color-primary), transparent 92%) 0%, transparent 20%),
        radial-gradient(circle at 90% 50%, color-mix(in srgb, var(--md-sys-color-primary), transparent 92%) 0%, transparent 20%);
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

/* 背景流動動畫 */
@keyframes heroFlow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* 左側內容區 */
.jexhrai-hero__left {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    width: 100%;
    position: relative;
    z-index: 2;
}

.jexhrai-hero__title {
    margin: 0;
    font-size: 2rem;
    /* 稍微調整大小以適應 120px */
    font-weight: 900;
    color: var(--jexhrai-text-main);
    line-height: 1.2;
    word-break: break-word;
    /* 長標題可自然換行 */
}

.jexhrai-hero__subtitle {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--jexhrai-text-secondary);
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jexhrai-hero__actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.jexhrai-hero__actions .jexhrai-hero__primary-button {
    height: 36px;
    /* 稍微縮小按鈕以適應高度 */
    padding: 0 20px;
    border-radius: var(--jexhrai-radius-btn);
    background-color: var(--jexhrai-primary);
    color: var(--jexhrai-text-main);
    font-weight: 700;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jexhrai-hero__actions .jexhrai-hero__primary-button:hover {
    background-color: var(--jexhrai-primary-hover);
    transform: translateY(-1px);
}

/* 右側動畫容器 */
.jexhrai-hero__right {
    padding: 0;
    display: flex;
    justify-content: center;
    /* 改為置中 */
    align-items: center;
    align-self: stretch;
    position: relative;
    z-index: 1;
    height: 100%;
}

/* ==========================================
 * 創意動畫圖示 (Creative Animated Icons)
 * ========================================== */

.hero-anim-container {
    width: 100px;
    height: 80px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Chat Animation (Bubbles) --- */
.hero-anim-chat .chat-bubble {
    position: absolute;
    border-radius: 50%;
    opacity: 0.8;
}

.hero-anim-chat .b1 {
    width: 30px;
    height: 30px;
    background: var(--jexhrai-info);
    bottom: 10px;
    left: 20px;
    animation: chatFloat 3s ease-in-out infinite;
}

.hero-anim-chat .b2 {
    width: 45px;
    height: 45px;
    background: var(--jexhrai-primary);
    top: 10px;
    right: 15px;
    animation: chatFloat 4s ease-in-out infinite 0.5s;
}

.hero-anim-chat .b3 {
    width: 20px;
    height: 20px;
    background: var(--jexhrai-gray-200);
    bottom: 25px;
    right: 30px;
    animation: chatFloat 2.5s ease-in-out infinite 1s;
}

@keyframes chatFloat {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.05);
    }
}

/* --- Coach Animation (Breathing Bubble) --- */
.hero-anim-coach .coach-bubble-main {
    width: 60px;
    height: 45px;
    background: var(--jexhrai-bg-white);
    border: 2px solid var(--jexhrai-primary);
    border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: coachBreath 3s ease-in-out infinite;
    box-shadow: var(--md-sys-elevation-2);
}

.hero-anim-coach .coach-eye {
    width: 8px;
    height: 8px;
    background: var(--jexhrai-text-secondary);
    border-radius: 50%;
    position: relative;
    box-shadow: 15px 0 0 var(--jexhrai-text-secondary);
    left: -7px;
    animation: coachBlink 4s infinite;
}

.hero-anim-coach .coach-bubble-small {
    width: 12px;
    height: 12px;
    background: var(--jexhrai-primary);
    border-radius: 50%;
    position: absolute;
    bottom: 10px;
    left: 15px;
    opacity: 0.6;
}

@keyframes coachBreath {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    50% {
        transform: scale(1.05) rotate(2deg);
    }
}

@keyframes coachBlink {

    0%,
    48%,
    52%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.1);
    }
}

/* --- Button Animation (Pulse & Sparkle) --- */
.hero-anim-button .magic-btn {
    width: 50px;
    height: 50px;
    background: var(--jexhrai-primary);
    border-radius: 50%;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
}

.hero-anim-button .btn-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--jexhrai-primary);
    opacity: 0;
    animation: btnPulseRing 2s infinite;
}

.hero-anim-button .magic-sparkle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--jexhrai-primary-hover);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    z-index: 1;
}

.hero-anim-button .s1 {
    top: 0;
    left: 10px;
    animation: sparkleSpin 3s infinite;
}

.hero-anim-button .s2 {
    bottom: 5px;
    right: 5px;
    animation: sparkleSpin 2.5s infinite reverse;
}

@keyframes btnPulseRing {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

@keyframes sparkleSpin {
    0% {
        transform: rotate(0deg) scale(0.8);
        opacity: 0.6;
    }

    50% {
        transform: rotate(180deg) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: rotate(360deg) scale(0.8);
        opacity: 0.6;
    }
}

/* --- Writing Animation (Pen & Paper) --- */
.hero-anim-writing .writing-paper {
    width: 50px;
    height: 65px;
    background: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-extra-small);
    position: relative;
    box-shadow: var(--md-sys-elevation-1);
    overflow: hidden;
    transform: rotate(-5deg);
}

.hero-anim-writing .paper-line {
    height: 4px;
    background: var(--jexhrai-gray-200);
    margin: 8px auto;
    border-radius: var(--md-sys-shape-corner-extra-small);
    width: 70%;
}

.hero-anim-writing .l1 {
    width: 60%;
    animation: lineAppear 2s infinite;
}

.hero-anim-writing .l2 {
    width: 80%;
    animation: lineAppear 2s infinite 0.3s;
}

.hero-anim-writing .writing-pen {
    width: 6px;
    height: 40px;
    background: var(--jexhrai-text-secondary);
    position: absolute;
    right: 20px;
    top: -10px;
    transform-origin: bottom center;
    animation: writeMove 1s infinite ease-in-out;
}

.hero-anim-writing .writing-pen::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid var(--jexhrai-text-secondary);
}

@keyframes writeMove {

    0%,
    100% {
        transform: rotate(15deg) translateY(0);
    }

    50% {
        transform: rotate(-5deg) translateY(2px);
    }
}

@keyframes lineAppear {

    0%,
    100% {
        width: 20%;
        opacity: 0.3;
    }

    50% {
        width: 70%;
        opacity: 1;
    }
}

/* --- Flashcard Animation (Flip) --- */
.hero-anim-flashcard {
    perspective: 400px;
}

.hero-anim-flashcard .flash-card {
    width: 50px;
    height: 70px;
    position: absolute;
    border-radius: var(--md-sys-shape-corner-small);
    backface-visibility: hidden;
    box-shadow: var(--md-sys-elevation-2);
}

.hero-anim-flashcard .back {
    background: var(--jexhrai-primary);
    transform: rotateY(0deg);
    animation: cardFlipBack 4s infinite ease-in-out;
}

.hero-anim-flashcard .front {
    background: var(--jexhrai-bg-white);
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cardFlipFront 4s infinite ease-in-out;
}

.hero-anim-flashcard .flash-content {
    width: 60%;
    height: 4px;
    background: var(--jexhrai-gray-300);
    border-radius: var(--md-sys-shape-corner-extra-small);
}

@keyframes cardFlipBack {

    0%,
    20% {
        transform: rotateY(0deg);
    }

    50%,
    70% {
        transform: rotateY(180deg);
    }

    100% {
        transform: rotateY(360deg);
    }
}

@keyframes cardFlipFront {

    0%,
    20% {
        transform: rotateY(180deg);
    }

    50%,
    70% {
        transform: rotateY(360deg);
    }

    100% {
        transform: rotateY(540deg);
    }
}

/* --- Option Animation (List Check) --- */
.hero-anim-option .option-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 70px;
}

.hero-anim-option .opt-item {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateX(10px);
    animation: optSlideIn 2s infinite;
}

.hero-anim-option .i1 {
    animation-delay: 0s;
}

.hero-anim-option .i2 {
    animation-delay: 0.5s;
}

.hero-anim-option .i3 {
    animation-delay: 1s;
}

.hero-anim-option .opt-check {
    width: 12px;
    height: 12px;
    border: 2px solid var(--jexhrai-primary);
    border-radius: var(--md-sys-shape-corner-extra-small);
    position: relative;
}

.hero-anim-option .opt-check::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 3px;
    width: 3px;
    height: 6px;
    border: solid var(--color-success);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    animation: checkMark 2s infinite;
}

.hero-anim-option .opt-line {
    height: 4px;
    background: var(--jexhrai-gray-200);
    border-radius: var(--md-sys-shape-corner-extra-small);
    flex-grow: 1;
}

@keyframes optSlideIn {
    0% {
        opacity: 0;
        transform: translateX(10px);
    }

    20%,
    80% {
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-5px);
    }
}

@keyframes checkMark {

    0%,
    30% {
        opacity: 0;
    }

    40%,
    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* 移除舊的插圖樣式 */
/* ... (舊代碼被覆蓋) ... */

/* ==========================================
 * 5. 對話與訊息系統 (Message System)
 * ========================================== */

/* AI 訊息容器 */
.jexhrai-ai-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    padding: 1rem;
    margin: 0rem 0;
    border-radius: var(--jexhrai-radius-lg);
    background-color: var(--jexhrai-bg-light);
    border: 0px solid transparent;
    box-sizing: border-box;
    /* 聚焦與捲動時預留 120px 安全距離，避免被固定橫幅遮擋 */
    scroll-margin-top: 120px !important;
}

/* ======== Chat Async 等待狀態：卡片外框（橘色）======== */
/* 說明：
 * - 需求：送出後不要顯示獨立的思考容器；改為在回應卡片內顯示點點。
 * - 這裡用 M3 擴充 warning token 作為橘色外框，避免硬編碼色碼。
 */
.jexhrai-ai-container.jexhrai-streaming {
    border: 2px solid var(--md-sys-color-warning);
}

/* 移除 AI 卡片聚焦時的瀏覽器預設黑框（改用動畫與背景區分可視狀態） */
.jexhrai-ai-container:focus,
.jexhrai-ai-talk,
.jexhrai-input-area-container,
.jexhrai-ai-container:focus-visible {
    outline: none;
    box-shadow: none;
}

/* AI 卡片進場動畫：向下推入並淡入，確保新回應清晰可見 */
.jexhrai-ai-card-animate {
    opacity: 0;
    transform: translateY(-14px);
    animation: jexhraiAiCardPushIn 0.42s cubic-bezier(0.2, 0.9, 0.22, 1.06) forwards;
    will-change: transform, opacity;
}

@keyframes jexhraiAiCardPushIn {
    0% {
        opacity: 0;
        transform: translateY(-14px);
    }

    60% {
        opacity: 1;
        transform: translateY(6px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 對話氣泡基礎樣式 */
.message-bubble {
    /*
     * 說明：統一對話泡泡內距與行高，貼齊設計稿的閱讀體驗
     */
    padding: 1rem;
    border-radius: var(--md-sys-shape-corner-large);
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: none;
    line-height: 1.6;
    font-size: 1rem;
    color: var(--jexhrai-text-main);
    position: relative;
    /* 移除瀏覽器預設的焦點外框（無障礙黑框） */
    outline: none;
}

/* 對話氣泡焦點狀態 - 移除瀏覽器預設黑框（無障礙 outline） */
.message-bubble:focus,
.message-bubble:focus-visible,
.message-bubble-wrapper:focus,
.message-bubble-wrapper:focus-visible {
    outline: none;
    box-shadow: none;
}

/* 對話泡泡外層包裝器 */
.message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    /*
     * 說明：加入淡入上移動畫，模擬對話逐條出現的效果
     */
    opacity: 0;
    transform: translateY(0);
    animation: fadeIn 0.4s ease-out forwards;
}

.message-bubble-wrapper.ai {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble-wrapper.user {
    align-self: flex-end;
    align-items: flex-end;
}

/* 對話泡泡出場動畫延遲（前幾則訊息略微錯開時間） */
.jexhrai-ai-talk .message-bubble-wrapper:nth-child(1) {
    animation-delay: 0s;
}

.jexhrai-ai-talk .message-bubble-wrapper:nth-child(2) {
    animation-delay: 0.15s;
}

.jexhrai-ai-talk .message-bubble-wrapper:nth-child(3) {
    animation-delay: 0.3s;
}

/* 用戶訊息泡泡 */
.message-bubble.user {
    align-self: flex-end;
    /*
     * 說明：使用品牌黃為底色，右側圓角、左下略收斂
     */
    background-color: var(--jexhrai-primary);
    color: var(--jexhrai-text-main);
    border: 0px solid transparent;
    box-shadow: none;
    border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-large);
}

.message-bubble.user .message-content strong {
    color: inherit;
}

/* AI 訊息泡泡 */
.message-bubble.ai {
    align-self: flex-start;
    /*
     * 說明：改用暖灰底色，在純白背景上創造層次感
     */
    background-color: var(--jexhrai-bg-ai-bubble);
    color: var(--jexhrai-text-main);
    border: 0px solid transparent;
    box-shadow: none;
    border-radius: var(--md-sys-shape-corner-extra-small) var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large);
}

/* AI 頭像與標題 */
.message-avatar.ai-avatar {
    /*
     * 說明：頭像放大為 32px，移除邊框與陰影，貼近 Clean White 樣式
     */
    width: 30px;
    height: 30px;
    border-radius: var(--md-sys-shape-corner-small);
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    margin-bottom: 6px;
    margin-left: 4px;
    /* 說明：改為由外層裁切，讓頭像圖片緊貼容器，對齊範本的 Clean White 頭像效果 */
    overflow: hidden;
}

.message-avatar.ai-avatar .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 1;
    color: var(--jexhrai-wp-primary);
}

.message-avatar.ai-avatar .ai-avatar-image {
    width: 100%;
    height: 100%;
    /* 說明：交由外層 .message-avatar 裁切圓角，圖片本身不再額外套用圓角 */
    border-radius: 0;
    object-fit: cover;
    display: block;
}

.ai-header-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ai-header-text {
    font-size: 0.9rem;
    color: var(--jexhrai-text-secondary);
}



/* 通用訊息樣式 */
.user-message {
    margin-bottom: 0rem;
    font-size: 1.2rem;
    color: var(--jexhrai-text-secondary);
    border-bottom: 1px solid var(--jexhrai-border-light);
    padding-bottom: 0.5rem;
}

.user-message strong {
    color: var(--jexhrai-text-main);
    font-weight: 700;
    display: inline;
    margin-bottom: 0;
}

.ai-message {
    margin-bottom: 0;
    font-size: 0.95rem;
    color: inherit;
}

/* ======== AI 回應卡片（jexhrai-ai-container）內文排版（Markdown/Rich Text）========
 * 說明：
 * - 這裡的 AI 回應內容會直接注入 `.ai-message`（可能包含 <p>/<blockquote>/<ol>... 等標籤）
 * - 若主題樣式在外掛 CSS 之後載入，主題的段落預設 margin 可能覆蓋掉專案的 wrapper reset
 * - 因此採用更高選擇器權重，僅在 AI 卡片內收斂段落間距並統一行高為 1.5
 * ======================================================================== */
.jexhrai-ai-container .ai-message {
    line-height: 1.5;
}

.jexhrai-ai-container .ai-message p {
    margin-top: 0;
    margin-bottom: 0.5em;
    line-height: inherit;
}

.jexhrai-ai-container .ai-message p:last-child {
    margin-bottom: 0;
}

/* ==========================================
 * Thinking 容器（Markdown blockquote）60px 摺疊/展開
 * 說明：
 * - 串流與歷史記錄都會透過 markdown-it 把 `>` 引用轉成 <blockquote>
 * - WordPress 主題常會對 blockquote 套用預設樣式（邊框/縮排/字體），造成視覺不一致
 * - 統一策略：將 blockquote 包裝成可摺疊容器，預設顯示 60px，高度不足則不影響閱讀
 * ========================================== */
.jexhrai-thinking-block {
    position: relative;
    margin: 10px 0;
    padding: 10px;
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-surface-container-low);
    box-sizing: border-box;
    cursor: pointer;
}

.jexhrai-thinking-block:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 25%, transparent);
}

.jexhrai-thinking-block .jexhrai-thinking-body {
    max-height: none;
    overflow: visible;
    position: relative;
}



.jexhrai-thinking-block .jexhrai-thinking-body {
    /* ======== 細捲軸（M3 風格，僅限 thinking 容器）======== */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color:
        color-mix(in srgb, var(--md-sys-color-outline) 35%, transparent)
        transparent;
}

.jexhrai-thinking-block .jexhrai-thinking-body::-webkit-scrollbar {
    width: 6px;
}

.jexhrai-thinking-block .jexhrai-thinking-body::-webkit-scrollbar-track {
    background: transparent;
    border-radius: var(--md-sys-shape-corner-small);
}

.jexhrai-thinking-block .jexhrai-thinking-body::-webkit-scrollbar-thumb {
    background-color: color-mix(in srgb, var(--md-sys-color-outline) 30%, transparent);
    border-radius: var(--md-sys-shape-corner-small);
    border: 2px solid transparent;
    background-clip: content-box;
}

.jexhrai-thinking-block .jexhrai-thinking-body::-webkit-scrollbar-thumb:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-outline) 55%, transparent);
}

.jexhrai-thinking-block .jexhrai-thinking-body blockquote {
    /* 覆蓋主題/WP 預設 blockquote 樣式，避免縮排與字體不一致 */
    margin: 0;
    padding: 12px;
    border-left: 4px solid color-mix(in srgb, var(--md-sys-color-primary), transparent 20%);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
}

.jexhrai-thinking-block .jexhrai-thinking-body blockquote p:last-child {
    margin-bottom: 0;
}

/* 訊息文字段落間距優化 */
.jexhrai-ai-talk .message-text p {
    margin-top: 0;
    margin-bottom: 0.5em;
    /* 保持適當閱讀間距，但不宜過大 */
    line-height: 1.4;
}

.jexhrai-ai-talk .message-text p:last-child {
    margin-bottom: 0;
}

/* 訊息中的圖片 */
.message-bubble.ai .message-content img {
    display: block;
    margin-top: 10px;
    margin-bottom: 10px;
    max-width: 100%;
    height: auto;
    border-radius: var(--md-sys-shape-corner-small);
    object-fit: contain;
}

.message-image-generated {
    max-width: 100%;
    height: auto;
    border-radius: var(--md-sys-shape-corner-small);
    margin: 10px 0;
    display: block;
}

/* ==========================================
 * 6. 輸入區域系統 (Input System)
 * ========================================== */

/* 統一輸入容器基礎樣式 */
.jexhrai-input-container {
    padding: 0px;
    display: flex;
    flex-direction: column;
    margin-top: 0rem;
    border-radius: var(--jexhrai-radius-lg);
    transition: border 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    position: relative;
}

/* 輸入容器禁用時的灰色罩層 */
.jexhrai-input-container.jexhrai-disabled::after {
    /*
     * 說明：
     * - 原本的 ::after 半透明遮罩會與內層 .jexhrai-input-inner.jexhrai-disabled 的底色疊加，
     *   導致視覺上出現「兩層不一致灰階」。
     * - 統一策略：禁用狀態只由內層容器（.jexhrai-input-inner.jexhrai-disabled）負責呈現，
     *   這裡不再生成遮罩層，避免重疊色票。
     */
    content: none;
}

/* 統一輸入內層樣式 */
.jexhrai-input-inner {
    display: flex;
    flex-direction: column;
    background-color: var(--jexhrai-bg-white);
    border-radius: var(--jexhrai-radius-lg);
    padding: 0;
    border: 1px solid var(--jexhrai-border);
    box-shadow: inset 0 0 0 0 transparent;
    transition: border 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

/* 輸入容器互動效果 */
.jexhrai-input-inner:hover {
    border-color: var(--jexhrai-primary);
}

.jexhrai-input-inner:focus-within {
    border-color: var(--jexhrai-primary) !important;
    box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary), transparent 65%) !important;
}

.jexhrai-input-container.jexhrai-drag-over .jexhrai-input-inner {
    border: 5px solid var(--jexhrai-primary);
    box-sizing: border-box;
}

/* 統一輸入框樣式 */
.jexhrai-textarea {
    flex-grow: 1;
    background-color: transparent;
    border: none;
    border-bottom: 0px solid var(--jexhrai-border-light);
    color: var(--jexhrai-text-main);
    font-size: 1rem;
    line-height: 1.2;
    resize: none;
    outline: none;
    padding: 15px 15px 0px 15px;
    box-shadow: none;
    margin: 0;
    height: 53px;
    /* 統一標準高度 (Conversation Module) */
    min-height: 53px;
    max-height: 200px;
    overflow-y: auto;
}

.jexhrai-textarea::placeholder {
    color: var(--jexhrai-text-placeholder);
}

.jexhrai-textarea:focus {
    outline: none;
    box-shadow: none;
}

/* 禁用輸入區域樣式 */
.jexhrai-input-inner.jexhrai-disabled {
    /*
     * 說明：
     * - 禁用底色需一致（單一色票），避免 textarea/按鈕列各自上色造成分層。
     * - 透過 M3 token 的 surface-variant 作為禁用底色單一事實來源。
     */
    opacity: 1;
    pointer-events: none;
    background-color: var(--md-sys-color-surface-variant);
    border-color: var(--md-sys-color-outline-variant);
}

.jexhrai-input-inner.jexhrai-disabled .jexhrai-textarea {
    background-color: transparent;
    color: var(--md-sys-color-outline);
    cursor: not-allowed;
}

.jexhrai-input-inner.jexhrai-disabled .jexhrai-button-row {
    background-color: transparent;
}

.jexhrai-input-inner.jexhrai-disabled .jexhrai-button-row button {
    background-color: transparent;
    color: var(--md-sys-color-outline);
    cursor: not-allowed;
    border-color: transparent;
}

.jexhrai-input-inner.jexhrai-disabled .jexhrai-send-button {
    background-color: transparent !important;
    color: var(--md-sys-color-outline) !important;
    cursor: not-allowed !important;
    border: 1px solid var(--md-sys-color-outline-variant) !important;
}

/* 語音輸入按鈕 */
.jexhrai-voice-input {
    position: relative;
    transition: all 0.3s ease;
}

.jexhrai-voice-input.is-recording {
    background-color: var(--md-sys-color-error) !important;
    color: var(--md-sys-color-on-error) !important;
    animation: pulse 1.5s infinite;
}

.jexhrai-voice-input:hover:not(.is-recording) {
    background-color: var(--md-sys-color-surface-variant);
    transform: scale(1.05);
}

.jexhrai-voice-input:active {
    transform: scale(0.95);
}

/* 語音狀態提示 */
.jexhrai-voice-status {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 4px 8px;
    border-radius: var(--md-sys-shape-corner-extra-small);
    font-size: 12px;
    white-space: nowrap;
}

.jexhrai-voice-status::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--md-sys-color-inverse-surface);
}

/* ==========================================
 * 7. 按鈕與控制項 (Buttons & Controls)
 * ========================================== */

/* ======== 通用按鈕系統（M3 / 前台共用）========
 * 說明：
 * - 目的：統一專案前台的按鈕外觀與互動（避免各頁自行發明 btn-save/btn-primary 等命名）
 * - 規範：僅使用 M3 tokens（禁止新增 --jexhrai-* legacy keys、禁止 var fallback）
 * ======================================================================== */
.jexhrai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: var(--md-sys-shape-corner-full);
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font: var(--md-sys-typescale-label-large);
    transition: background-color 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s, transform 0.08s;
}

.jexhrai-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 25%, transparent);
}

.jexhrai-btn:active {
    transform: translateY(1px);
}

.jexhrai-btn:disabled,
.jexhrai-btn[aria-disabled="true"] {
    cursor: not-allowed;
    pointer-events: none;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-outline);
    border-color: transparent;
    box-shadow: none;
    transform: none;
}

.jexhrai-btn--block {
    width: 100%;
}

/* Filled */
.jexhrai-btn--filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.jexhrai-btn--filled:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 92%, var(--md-sys-color-on-primary));
    box-shadow: var(--md-sys-elevation-2);
}

/* Tonal */
.jexhrai-btn--tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.jexhrai-btn--tonal:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-secondary-container) 92%, var(--md-sys-color-on-secondary-container));
    box-shadow: var(--md-sys-elevation-1);
}

/* Outlined */
.jexhrai-btn--outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-outline);
}

.jexhrai-btn--outlined:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
    border-color: var(--md-sys-color-primary);
}

/* Text */
.jexhrai-btn--text {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border-color: transparent;
    padding: 0 12px;
}

.jexhrai-btn--text:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent);
}

/* Danger variants */
.jexhrai-btn--danger {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}

.jexhrai-btn--danger:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-error) 92%, var(--md-sys-color-on-error));
    box-shadow: var(--md-sys-elevation-2);
}

.jexhrai-btn--text-danger {
    background-color: transparent;
    color: var(--md-sys-color-error);
    border-color: transparent;
    padding: 0 12px;
}

.jexhrai-btn--text-danger:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-error) 10%, transparent);
}

/* Success variants */
.jexhrai-btn--success {
    background-color: var(--md-sys-color-success);
    color: var(--md-sys-color-on-success);
}

.jexhrai-btn--success:hover:not(:disabled):not([aria-disabled="true"]) {
    background-color: color-mix(in srgb, var(--md-sys-color-success) 92%, var(--md-sys-color-on-success));
    box-shadow: var(--md-sys-elevation-2);
}

/* 通用按鈕容器樣式 */
.jexhrai-button-row {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0;
    padding: 0px 10px 10px 10px;
}

/* 圖示按鈕通用樣式 */
.jexhrai-button-row .icon-button {
    background-color: transparent;
    border: none;
    color: var(--jexhrai-text-muted);
    padding: 0px;
    margin: 0;
    width: 30px;
    height: 30px;
    border-radius: var(--md-sys-shape-corner-small);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.jexhrai-button-row .icon-button .dashicons {
    font-size: 20px;
    width: auto;
    height: auto;
}

.jexhrai-button-row .icon-button:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--jexhrai-text-main);
}

/* 統一送出按鈕樣式 */
.jexhrai-button-row .jexhrai-send-button {
    height: 35px;
    width: 35px;
    min-width: 35px;
    padding: 0;
    background-color: var(--jexhrai-primary);
    color: var(--jexhrai-text-main);
    font-weight: 400;
    border: none;
    border-radius: var(--jexhrai-radius-btn);
    cursor: pointer;
    transition: background-color 0.2s ease, width 0.2s, min-width 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.jexhrai-button-row .jexhrai-send-button .dashicons {
    font-size: 20px;
    width: auto;
    height: auto;
}

.jexhrai-button-row .jexhrai-send-button.limit-reached {
    width: auto;
    min-width: 80px;
    padding: 0 1em;
    justify-content: center;
}

.jexhrai-button-row .jexhrai-send-button:hover {
    background-color: var(--jexhrai-primary-hover);
}

.jexhrai-button-row .jexhrai-send-button:active {
    background-color: var(--jexhrai-primary-active);
    transform: translateY(1px);
}

/* 送出按鈕冷卻狀態 */
.is-counting-down {
    font-size: 16px;
    font-weight: bold;
    color: var(--jexhrai-text-main);
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
}

.jexhrai-button-row .jexhrai-send-button:disabled.is-counting-down {
    width: 30px;
    min-width: 30px;
    padding: 0;
}

.jexhrai-button-row .jexhrai-send-button[data-cooldown-seconds]:not([data-cooldown-seconds=""])::after {
    content: attr(data-cooldown-seconds) "s";
    position: absolute;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--jexhrai-text-secondary);
}

/* ==========================================
 * 8. 狀態與通知系統 (Status & Notifications)
 * ========================================== */

/* ======== 通用 Toast（前台共用）======== */
.jexhrai-toast {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%) translateY(18px);
    opacity: 0;
    pointer-events: none;
    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 12px 20px;
    border-radius: var(--md-sys-shape-corner-small);
    box-shadow: var(--md-sys-elevation-3);
    z-index: 10000;
    font: var(--md-sys-typescale-body-medium);
    transition: opacity 0.2s, transform 0.2s;
}

.jexhrai-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ======== 通用內嵌錯誤/提示（前台共用）======== */
.jexhrai-inline-error {
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    border: 1px solid var(--md-sys-color-error);
    font: var(--md-sys-typescale-body-medium);
}

.jexhrai-inline-info {
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    font: var(--md-sys-typescale-body-medium);
}

.jexhrai-loading-placeholder {
    padding: 4rem;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-body-medium);
}

/* 統一狀態列樣式 */
.jexhrai-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 13px 5px 13px;
    background-color: var(--jexhrai-bg-light);
    border: 0px solid var(--jexhrai-bg-light);
    border-radius: var(--jexhrai-radius-lg);
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.jexhrai-status .jexhrai-status-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.jexhrai-status .jexhrai-status-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jexhrai-status .jexhrai-clear.icon-button {
    background-color: transparent;
    border: none;
    color: var(--jexhrai-text-muted);
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    border-radius: var(--md-sys-shape-corner-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.jexhrai-status .jexhrai-clear.icon-button .dashicons {
    font-size: 20px;
    width: auto;
    height: auto;
}

.jexhrai-status .jexhrai-clear.icon-button:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--jexhrai-text-main);
}

.jexhrai-status-text {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.jexhrai-clear.reset-timer-disabled,
.jexhrai-clear.reset-timer-disabled:hover {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--md-sys-color-surface-variant);
}

/* 錯誤訊息樣式 */
.jexhrai-ui-error-message {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: var(--md-sys-shape-corner-large);
    color: var(--jexhrai-error);
    background-color: var(--jexhrai-error-bg);
    border: 1px solid var(--jexhrai-error-border);
    box-sizing: border-box;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* 成功訊息樣式 */
.jexhrai-ui-success-message {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: var(--md-sys-shape-corner-large);
    color: var(--jexhrai-success);
    background-color: var(--jexhrai-success-bg);
    border: 1px solid var(--jexhrai-success-border);
    box-sizing: border-box;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* 配額已滿提醒橫幅 */
.jexhrai-quota-banner {
    width: 100%;
    max-height: 150px;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-corner-medium);
    background: linear-gradient(180deg,
            color-mix(in srgb, var(--md-sys-color-warning-container), var(--md-sys-color-surface) 45%),
            var(--md-sys-color-warning-container));
    border: 1px solid color-mix(in srgb, var(--md-sys-color-warning), transparent 75%);
    box-shadow: var(--md-sys-elevation-1);
    box-sizing: border-box;
    margin: 0 0 8px 0;
}

.jexhrai-quota-banner .qb-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: var(--md-sys-shape-corner-small);
    background: var(--md-sys-color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-warning);
    border: 1px solid color-mix(in srgb, var(--md-sys-color-outline), transparent 85%);
}

.jexhrai-quota-banner .qb-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.jexhrai-quota-banner .qb-title {
    font-weight: 700;
    color: var(--md-sys-color-on-warning-container);
    font-size: 0.95rem;
    line-height: 1.2;
    margin: 0;
}

.jexhrai-quota-banner .qb-desc {
    color: var(--md-sys-color-on-warning-container);
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}

.jexhrai-quota-banner .qb-countdown {
    font-weight: 700;
    color: var(--md-sys-color-warning);
}

.jexhrai-quota-banner .qb-actions {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.jexhrai-quota-banner .qb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--md-sys-shape-corner-small);
    border: 1px solid color-mix(in srgb, var(--md-sys-color-warning), transparent 55%);
    background: var(--md-sys-color-warning);
    color: var(--md-sys-color-on-warning);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.jexhrai-quota-banner .qb-btn.secondary {
    background: var(--md-sys-color-surface);
    border-color: color-mix(in srgb, var(--md-sys-color-warning), transparent 40%);
    color: var(--md-sys-color-on-warning-container);
}

.jexhrai-quota-banner .qb-btn:hover {
    filter: brightness(0.98);
}

.jexhrai-quota-banner .qb-btn:active {
    transform: translateY(1px);
}

/* 任務完成橫幅 */
.jexhrai-task-done-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin: 6px 0;
    border-radius: var(--md-sys-shape-corner-medium);
    background: linear-gradient(180deg,
            color-mix(in srgb, var(--md-sys-color-success-container), var(--md-sys-color-surface) 45%),
            var(--md-sys-color-success-container));
    border: 1px solid color-mix(in srgb, var(--md-sys-color-success), transparent 75%);
    box-shadow: var(--md-sys-elevation-1);
    color: var(--md-sys-color-on-success-container);
    animation: taskBannerIn 220ms ease-out;
}

.jexhrai-task-done-banner .dashicons {
    color: var(--md-sys-color-success);
    font-size: 20px;
}

.jexhrai-task-done-banner .task-done-title {
    font-weight: 800;
}

.jexhrai-task-done-banner .task-done-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* AI 重試狀態 */
.jexhrai-ai-retry-status {
    background: linear-gradient(135deg, var(--md-sys-color-surface) 0%, var(--md-sys-color-surface-variant) 100%);
    border: 2px solid var(--md-sys-color-info);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 20px;
    margin: 15px 0;
    text-align: center;
    box-shadow: var(--md-sys-elevation-1);
    animation: pulse-border 2s infinite;
}

.jexhrai-ai-retry-spinner {
    margin-bottom: 15px;
}

.jexhrai-ai-retry-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--md-sys-color-surface-variant);
    border-top: 4px solid var(--md-sys-color-info);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

.jexhrai-ai-retry-message p {
    margin: 8px 0;
    color: var(--md-sys-color-on-surface-variant);
}

.jexhrai-ai-retry-message p:first-child {
    font-weight: 600;
    color: var(--md-sys-color-info);
    font-size: 1.1em;
}

.jexhrai-ai-retry-message .retry-info {
    font-size: 0.9em;
    color: var(--md-sys-color-on-surface-variant);
    font-style: italic;
}

/* 最終失敗狀態 */
/* 最終失敗狀態 - Material 3 Redesign */
.jexhrai-final-failure {
    width: 100%;
    height: 150px;
    background-color: var(--jexhrai-error-bg);
    border: 1px solid var(--jexhrai-error-border);
    border-radius: var(--jexhrai-radius-lg);
    /* box-shadow removed as requested */
    margin: 1.5rem 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    transition: var(--jexhrai-transition-standard);
}

.jexhrai-final-failure:hover {
    /* box-shadow removed as requested */
    background-color: color-mix(in srgb, var(--md-sys-color-error), transparent 92%);
    /* slight darken on hover instead */

}

.jexhrai-final-failure-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 0 32px;
    gap: 24px;
    box-sizing: border-box;
    text-align: left;
}

.jexhrai-final-failure .failure-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    background-color: var(--jexhrai-bg-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--jexhrai-shadow-sm);
    font-size: 28px;
}

.jexhrai-final-failure .failure-icon img.emoji {
    width: 32px;
    height: 32px;
    margin: 0;
}

.jexhrai-final-failure .failure-message {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.jexhrai-final-failure .failure-message h4 {
    color: var(--jexhrai-error);
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.jexhrai-final-failure .failure-message p {
    color: var(--jexhrai-text-main);
    margin: 0 !important;
    font-size: 0.95rem;
    line-height: 1.4;
    opacity: 0.9;
}

.jexhrai-final-failure .failure-message .failure-hint {
    color: var(--jexhrai-text-secondary);
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Material 3 Filled Button Style */
.jexhrai-manual-retry-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 28px;
    background-color: var(--jexhrai-error);
    color: var(--md-sys-color-on-error);
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--md-sys-elevation-1);
    transition: var(--jexhrai-transition-standard);
    white-space: nowrap;
    flex-shrink: 0;
}

.jexhrai-manual-retry-btn img {
    filter: brightness(0) invert(1);
    width: 18px;
    height: 18px;
    margin: 0;
}

.jexhrai-manual-retry-btn:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-error), var(--md-sys-color-shadow) 45%);
    box-shadow: var(--md-sys-elevation-2);
    transform: translateY(-1px);
}

.jexhrai-manual-retry-btn:active {
    transform: translateY(0);
    box-shadow: var(--md-sys-elevation-1);
}

@media (max-width: 600px) {
    .jexhrai-final-failure-content {
        padding: 0 16px;
        gap: 12px;
    }

    .jexhrai-final-failure .failure-icon {
        width: 40px;
        height: 40px;
    }

    .jexhrai-manual-retry-btn {
        height: 40px;
        padding: 0 16px;
        font-size: 0.9rem;
    }
}

/* 系統錯誤狀態 - 無重試按鈕 */
.jexhrai-system-error {
    width: 100%;
    height: 150px;
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--md-sys-color-warning-container), var(--md-sys-color-surface) 45%) 0%,
            var(--md-sys-color-surface) 100%);
    border: 1px solid color-mix(in srgb, var(--md-sys-color-warning), transparent 70%);
    border-radius: var(--jexhrai-radius-lg);
    margin: 1.5rem 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.jexhrai-system-error-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0 32px;
    gap: 20px;
    box-sizing: border-box;
    text-align: left;
}

.jexhrai-system-error .error-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    background-color: var(--jexhrai-bg-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--jexhrai-shadow-sm);
    font-size: 28px;
}

.jexhrai-system-error .error-message {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.jexhrai-system-error .error-message h4 {
    color: var(--md-sys-color-warning);
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.jexhrai-system-error .error-message p {
    color: var(--jexhrai-text-main);
    margin: 0 !important;
    font-size: 0.95rem;
    line-height: 1.4;
    opacity: 0.9;
}

.jexhrai-system-error .error-hint {
    color: var(--jexhrai-text-secondary);
    font-size: 0.85rem;
    opacity: 0.8;
}

@media (max-width: 600px) {
    .jexhrai-system-error-content {
        padding: 0 16px;
        gap: 12px;
    }

    .jexhrai-system-error .error-icon {
        width: 40px;
        height: 40px;
    }
}

/* ==========================================
 * 9. 回饋系統 (Feedback System)
 * ========================================== */

.jexhrai-feedback-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 0px;
    margin-bottom: 0px;
    padding-top: 0px;
    border-top: 0px solid transparent;
    justify-content: flex-end;
    align-items: center;
}

.jexhrai-feedback-btn {
    display: flex;
    align-items: center;
    background-color: var(--md-sys-color-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    padding: 5px 4px 4px 9px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    color: var(--md-sys-color-on-surface-variant);
    outline: none;
    box-shadow: none;
}

.jexhrai-feedback-btn:hover {
    background-color: color-mix(in srgb, var(--jexhrai-primary), transparent 85%);
    border-color: var(--jexhrai-primary);
}

.jexhrai-feedback-btn:active {
    background-color: var(--jexhrai-border);
    transform: translateY(1px);
}

.jexhrai-feedback-btn .feedback-emoji {
    margin-right: 6px;
    font-size: 12px;
}

.jexhrai-feedback-selected {
    background-color: var(--jexhrai-text-muted);
    border-color: var(--jexhrai-text-muted);
    color: var(--jexhrai-text-muted);
}

.jexhrai-feedback-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.jexhrai-feedback-thanks {
    margin-top: 3px;
    color: var(--md-sys-color-success);
    font-size: 12px;
    font-style: italic;
    text-align: center;
}

.jexhrai-feedback-error {
    margin-top: 8px;
    color: var(--md-sys-color-error);
    font-size: 0.8em;
}

.jexhrai-feedback-submitted {
    opacity: 0.9;
}

.jexhrai-feedback-row {
    display: flex;
    align-items: center;
    margin-top: 12px;
    margin-bottom: 0px;
    padding-top: 8px;
    border-top: 0px solid transparent;
}

/* ==========================================
 * 10. 附件系統 (Attachment System)
 * ========================================== */

/* 附件預覽容器 */
.jexhrai-attachment-preview {
    background-color: color-mix(in srgb, var(--md-sys-color-primary), transparent 85%);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 8px;
    margin: 8px 0px 8px 0px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    font-size: 0.9em;
    box-sizing: border-box;
    max-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
}

.jexhrai-attachment-preview .attachment-preview-item {
    position: relative;
    border: 1px solid var(--jexhrai-primary);
    border-radius: var(--md-sys-shape-corner-small);
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background-color: var(--md-sys-color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.jexhrai-attachment-preview .attachment-image-preview {
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: cover;
    display: block;
}

.jexhrai-attachment-preview .attachment-preview-item .attachment-file-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5px;
    font-size: 0.8em;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.2;
}

.jexhrai-attachment-preview .attachment-preview-item .attachment-file-name {
    word-break: break-all;
    max-height: 2.4em;
    overflow: hidden;
}

.jexhrai-attachment-preview .attachment-preview-item .attachment-file-size {
    font-size: 10px;
    color: var(--md-sys-color-on-surface-variant);
    margin-left: 4px;
}

.jexhrai-attachment-preview .jexhrai-remove-attachment,
.jexhrai-attachment-preview .attachment-remove-button {
    position: absolute;
    top: 2px;
    right: 2px;
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    background-color: color-mix(in srgb, var(--md-sys-color-surface), transparent 25%);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 3px;
}

.jexhrai-attachment-preview .jexhrai-remove-attachment:hover,
.jexhrai-attachment-preview .attachment-remove-button:hover {
    color: var(--md-sys-color-on-surface);
    background-color: var(--md-sys-color-surface);
}

.jexhrai-attachment-attach-button.icon-button {
    background-color: transparent;
    border: none;
    color: var(--jexhrai-text-muted);
    padding: 0;
    margin: 0;
    width: 35px;
    height: 35px;
    border-radius: var(--jexhrai-radius-btn);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.jexhrai-attachment-attach-button.icon-button:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--jexhrai-text-main);
}

/* 訊息中的附件 */
.message-attachments-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 8px;
}

.message-image-preview {
    display: block;
    max-width: 80px;
    max-height: 80px;
    height: auto;
    width: auto;
    object-fit: cover;
    border-radius: var(--md-sys-shape-corner-small);
    flex-grow: 0;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-image-preview:hover {
    transform: scale(1.05);
}

.message-file-info {
    font-size: 0.8em;
    padding: 4px 8px 4px 8px;
    background-color: color-mix(in srgb, var(--md-sys-color-surface), transparent 80%);
    border-radius: var(--md-sys-shape-corner-extra-small);
    color: inherit;
}

/* ==========================================
 * 11. 動畫系統 (Animation System)
 * ========================================== */

/* 通用閃爍動畫 */
.flash-animation {
    animation: flash 0.5s ease-in-out;
}

.jexhrai-button-row .jexhrai-send-button.flash-animation {
    animation: buttonFlash 0.5s ease;
}

@keyframes buttonFlash {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-info), transparent 30%);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 5px color-mix(in srgb, var(--md-sys-color-info), transparent 100%);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-info), transparent 100%);
    }
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 初始化載入器 */
.jexhrai-preinit-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
}

.jexhrai-preinit-loader .loader {
    width: 50px;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 8px solid transparent;
    border-right-color: color-mix(in srgb, var(--md-sys-color-primary), transparent 40%);
    position: relative;
    animation: l24 1s infinite linear;
}

.jexhrai-preinit-loader .loader:before,
.jexhrai-preinit-loader .loader:after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: inherit;
    animation: inherit;
    animation-duration: 2s;
}

.jexhrai-preinit-loader .loader:after {
    animation-duration: 4s;
}

@keyframes l24 {
    100% {
        transform: rotate(1turn)
    }
}

/* Summary thinking loader */
.summary-loader-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0px 8px 0px 8px;
}

.summary-loader-wrapper .loader {
    width: 8px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--jexhrai-primary);
    clip-path: inset(-220%);
    animation: l28 2s infinite linear;
}

.thinking-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.thinking-text,
.loading-message {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.95rem;
}

@keyframes l28 {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 80%),
            40px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            -40px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    10% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 80%),
            12px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 40%),
            -40px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    20% {
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary), transparent 60%),
            0px 0 0 0 var(--md-sys-color-primary),
            -40px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    30% {
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-color-primary), transparent 60%),
            0px 0 0 0 var(--md-sys-color-primary),
            -12px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 40%),
            0 40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    40% {
        box-shadow: 0 0 0 8px color-mix(in srgb, var(--md-sys-color-primary), transparent 40%),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0 40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    50% {
        box-shadow: 0 0 0 8px color-mix(in srgb, var(--md-sys-color-primary), transparent 40%),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0 12px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 40%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    60% {
        box-shadow: 0 0 0 12px color-mix(in srgb, var(--md-sys-color-primary), transparent 20%),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }

    70% {
        box-shadow: 0 0 0 12px color-mix(in srgb, var(--md-sys-color-primary), transparent 20%),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0 -12px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 40%);
    }

    80% {
        box-shadow: 0 0 0 16px var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary),
            0px 0 0 0 var(--md-sys-color-primary);
    }

    90%,
    100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 80%),
            40px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            -40px 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%),
            0 -40px 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    }
}

/* 清除動畫 */
.jexhrai-anim-clearing>* {
    animation: jexhrai-clear-fade 360ms ease forwards;
}

.jexhrai-anim-clearing .jexhrai-ai-container,
.jexhrai-anim-clearing .conversation-card,
.jexhrai-anim-clearing .jexhrai-scoring-dashboard,
.jexhrai-anim-clearing .jexhrai-summary-section {
    will-change: opacity, transform, height, margin, padding;
}

@keyframes jexhrai-clear-fade {
    to {
        opacity: 0;
        transform: translateY(-8px);
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* 清除對話「重新開始中」覆蓋層 */
.jexhrai-clear-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 300px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,
            color-mix(in srgb, var(--md-sys-color-surface), transparent 3%) 0%,
            color-mix(in srgb, var(--md-sys-color-surface-variant), transparent 5%) 100%);
    backdrop-filter: blur(8px);
    border-radius: var(--md-sys-shape-corner-large);
    overflow: hidden;
    opacity: 0;
    animation: clearOverlayFadeIn 0.3s ease-out forwards;
}

.jexhrai-clear-progress-overlay.hiding {
    animation: clearOverlayFadeOut 0.4s ease-in forwards;
}

.jexhrai-clear-progress-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(color-mix(in srgb, var(--md-sys-color-primary), transparent 75%) 1px, transparent 1px),
        radial-gradient(color-mix(in srgb, var(--md-sys-color-primary), transparent 92%) 1px, transparent 1px);
    background-size: 12px 12px, 24px 24px;
    background-position: 0 0, 50% 50%;
    opacity: 0.8;
    filter: blur(0.5px);
    transform: translateZ(0);
    animation: particlesMoveA 20s ease-in-out infinite;
}

.jexhrai-clear-progress-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(120deg,
            transparent 0%,
            color-mix(in srgb, var(--md-sys-color-primary), transparent 88%) 40%,
            transparent 70%);
    mix-blend-mode: screen;
    opacity: 0.85;
    transform: translateZ(0);
    animation: particlesShimmer 6s ease-in-out infinite;
}

.jexhrai-clear-progress-content {
    position: relative;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 30px;
    text-align: center;
}

.jexhrai-clear-progress-spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--md-sys-color-primary), transparent 70%);
    border-top-color: color-mix(in srgb, var(--md-sys-color-primary), transparent 10%);
    animation: clearSpinnerRotate 1s linear infinite, clearSpinnerPulse 2s ease-in-out infinite;
}

.jexhrai-clear-progress-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-sys-color-on-surface-variant);
    letter-spacing: 0.5px;
    animation: clearTextPulse 1.5s ease-in-out infinite;
}

@keyframes clearOverlayFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes clearOverlayFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(1.05);
    }
}

@keyframes clearSpinnerRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes clearSpinnerPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-primary), transparent 60%);
    }

    50% {
        box-shadow: 0 0 0 10px color-mix(in srgb, var(--md-sys-color-primary), transparent 100%);
    }
}

@keyframes clearTextPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes particlesMoveA {

    0%,
    100% {
        background-position: 0 0, 50% 50%;
    }

    50% {
        background-position: 100% 100%, 0% 0%;
    }
}

@keyframes particlesShimmer {

    0%,
    100% {
        transform: translateX(-50%);
        opacity: 0.85;
    }

    50% {
        transform: translateX(50%);
        opacity: 1;
    }
}

/* AI 思考狀態 */
.jexhrai-ai-thinking {
    width: 100%;
    display: block;
    padding: 0.75rem;
    border-radius: var(--jexhrai-radius-btn);
    background-color: var(--jexhrai-bg-light);
    border: 2px solid color-mix(in srgb, var(--md-sys-color-warning), transparent 25%);
    box-sizing: border-box;
    animation: techyPulse 2s infinite ease-in-out;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.95rem;
}

.jexhrai-ai-thinking2 {
    /* 僅作為「回應中」狀態的視覺提示：不得覆蓋容器佈局（避免串流中/完成後間距漂移） */
    border: 2px solid color-mix(in srgb, var(--md-sys-color-warning), transparent 25%);
    box-sizing: border-box;
    animation: techyPulse 2s infinite ease-in-out;
    border-radius: var(--jexhrai-radius-lg);
}

@keyframes techyPulse {
    0% {
        border-color: color-mix(in srgb, var(--md-sys-color-warning), transparent 25%);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-warning), transparent 60%);
    }

    50% {
        border-color: color-mix(in srgb, var(--md-sys-color-primary), transparent 20%);
        box-shadow: 0 0 0 8px color-mix(in srgb, var(--md-sys-color-primary), transparent 100%);
    }

    100% {
        border-color: color-mix(in srgb, var(--md-sys-color-warning), transparent 25%);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-warning), transparent 100%);
    }
}

/* 語音錄音動畫 */
@keyframes pulse-recording {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error), transparent 30%);
    }

    70% {
        box-shadow: 0 0 0 8px color-mix(in srgb, var(--md-sys-color-error), transparent 100%);
    }

    100% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error), transparent 100%);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error), transparent 30%);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px color-mix(in srgb, var(--md-sys-color-error), transparent 100%);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error), transparent 100%);
    }
}

@keyframes taskBannerIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-border {

    0%,
    100% {
        border-color: var(--md-sys-color-info);
    }

    50% {
        border-color: color-mix(in srgb, var(--md-sys-color-info), var(--md-sys-color-shadow) 45%);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 打字指示器動畫 */
.typing-indicator {
    display: inline-block;
}

.typing-indicator .dots {
    display: inline-block;
    animation: dotFade 1.5s infinite ease-in-out;
    margin-left: 2px;
    position: relative;
    top: -1px;
}

.ai-typing-indicator {
    display: flex;
    align-items: center;
    min-height: calc(8px + 10px * 2);
}

.ai-typing-indicator .dots {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: var(--md-sys-color-outline);
    border-radius: 50%;
    animation: dotFade 1.5s infinite ease-in-out;
}

.ai-typing-indicator .dots:nth-child(1) {
    animation-delay: 0s;
}

.ai-typing-indicator .dots:nth-child(2) {
    animation-delay: 0.2s;
}

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

@keyframes dotFade {

    0%,
    80%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes typingLine {
    0% {
        opacity: 0;
        transform: scaleX(0);
    }

    50% {
        opacity: 1;
        transform: scaleX(1);
    }

    100% {
        opacity: 0;
        transform: scaleX(1);
    }
}

/* AI 思考中文字 */
.response-thinking {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ==========================================
 * 12. 響應式設計 (Responsive Design)
 * ========================================== */

@media (max-width: 900px) {
    .jexhrai-main-content-container {
        padding: 0;
    
    }

    /* Hero Mobile: 1 column, hide illustration, keep background */
    .jexhrai-hero {
        grid-template-columns: 1fr;
        padding: 1.5rem;
        gap: 10px;
        height: auto;
        min-height: 120px;
        /* 保持最小高度 */
        max-height: none;
        /* 手機版允許自適應高度 */
        overflow: hidden;
        /* 保持背景裁切 */
    }

    .jexhrai-hero__right {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .jexhrai-feedback-buttons {
        flex-direction: row;
        justify-content: center;
    }

    .jexhrai-feedback-btn {
        padding: 4px 8px;
        font-size: 0.85em;
    }

    .jexhrai-feedback-btn .feedback-emoji {
        margin-right: 4px;
    }

    .jexhrai-voice-status {
        font-size: 11px;
        padding: 3px 6px;
    }

    .jexhrai-ai-retry-status,
    .jexhrai-final-failure {
        padding: 15px;
        margin: 10px 0;
    }
}

@media (max-width: 480px) {
    .jexhrai-feedback-buttons {
        gap: 6px;
    }

    .jexhrai-feedback-btn {
        padding: 3px 6px;
        font-size: 0.8em;
    }
}

/* ======== 通用：限制訊息（供各模組共用） ======== */
.jexhrai-limit-message {
    margin: 10px 0;
}

/* ==========================================
 * 15. YouTube 內嵌影片系統 (Video Embed System)
 * ========================================== */

/* 影片容器 - 響應式 16:9 比例 */
.jexhrai-video-embed {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 1.5rem 0;
    padding: 0;
    border-radius: var(--md-sys-shape-corner-medium);
    overflow: hidden;
    background-color: var(--md-sys-color-surface-container);
    box-shadow: var(--md-sys-elevation-1);
}

.jexhrai-video-embed iframe {
    display: block;
    width: 100%;
    height: 400px;
    border: none;
    border-radius: var(--md-sys-shape-corner-medium) var(--md-sys-shape-corner-medium) 0 0;
}

.jexhrai-video-embed figcaption {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    background-color: var(--md-sys-color-surface-container-low);
    text-align: center;
}

.jexhrai-video-description {
    margin: 0.5rem 0 1rem 0;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    background-color: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-sys-shape-corner-small);
    border-left: 3px solid var(--md-sys-color-primary);
}

/* 響應式調整 */
@media (max-width: 768px) {
    .jexhrai-video-embed iframe {
        height: 280px;
    }
    
    .jexhrai-video-embed figcaption {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .jexhrai-video-embed iframe {
        height: 200px;
    }
}