/* ==========================================================================
   數運機緣 Fate Mechanics - Bazi Tool CSS (重構整合版 - 階段 1)
   - 包含 0. 全域設定、1. 共用元件、2. 基礎輸入區
   - 已將底部的按鈕補丁、輸入框重疊補丁移回正確分類，完全未刪減屬性
========================================================================== */

/* =========================================
   0. 全域設定與核心變數
========================================= */
html, body {
    margin: 0;
    padding: 0;
}
.bazi-app {
    /* 優先使用系統原生英/俄文字體，找不到中文字才會往後套用 iansui */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, 'iansui', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif !important;
    -webkit-font-smoothing: antialiased;
    width: 100%; 
    max-width: 960px; 
    margin: 0 auto; 
    padding: 10px; 
    box-sizing: border-box !important;
}

/*
.bazi-app {
    font-family: 'iansui', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif !important;
    -webkit-font-smoothing: antialiased;
    width: 100%; 
    max-width: 960px; 
    margin: 0 auto; 
    padding: 10px; 
    box-sizing: border-box !important;
}
*/
.bazi-app * { box-sizing: border-box !important; }

:root {
    --primary-rgb: 181, 146, 82; 
    --primary-color: #b59252;
    --primary-hover: #cfa864; 
    --jade-border: rgba(181, 146, 82, 0.3); 
    --glass-bg: rgba(255, 255, 255, 0.5); 
    --glass-border: rgba(181, 146, 82, 0.3);
    --block-bg: rgba(255, 255, 255, 0.5);
    --badge-low-bg: #78909c;
    --transition: all 0.3s ease;
}

body.dark-theme {
    --primary-rgb: 212, 185, 140; 
    --primary-color: #d4b98c;
    --glass-bg: rgba(20, 20, 20, 0.85); 
    --glass-border: rgba(212, 185, 140, 0.25);
    --block-bg: rgba(0, 0, 0, 0.4);
}

.ui-warning-text { color: #e67e22; }

/* 🌟 隱藏匯出專用畫布 (絕對不可影響排版) */
#calendar-download-container,
#card-download-container {
    position: fixed !important; 
    top: 0; left: -9999px !important;   
    opacity: 1 !important;      
    z-index: -9999 !important;
    pointer-events: none !important;
    display: block !important;  
    visibility: visible !important;
}

/* =========================================
   1. 共用元件 (按鈕、提示、彈窗、提示框)
========================================= */
/* --- 頂部標題 --- */
.header-row { text-align: center; margin-bottom: 20px; }
.bazi-app .header-row .site-header { margin-top: -30px; margin-bottom: 15px !important; }
.bazi-app .logo-wrapper, .bazi-app .site-logo { width: 65px !important; height: 65px !important; }
.bazi-app .logo-wrapper { margin-bottom: -15px !important; }
.bazi-app .main-brand-title { font-size: 1.8rem !important; }
.bazi-app .main-brand-sub { font-size: 0.95rem !important; margin-top: 5px !important; }

/* --- 提示標籤 (電視廣告與大師解鎖) --- */
.ad-hint-tag {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    max-width: 95%; white-space: normal; word-break: break-word; text-align: center;
    line-height: 1.4; font-size: 0.85rem; color: var(--text-muted);
    background: rgba(var(--primary-rgb), 0.05); border: 1px dashed rgba(var(--primary-rgb), 0.3);
    padding: 8px 16px; border-radius: 20px;
}
.ad-hint-tag span { white-space: normal; word-break: break-word; }
.ad-hint-tag.master-hint { padding: 4px 10px; background: transparent; border: none; margin-top: 10px; }

/* --- Tooltip 輔助問號 --- */
.help-tip {
    display: inline-flex; justify-content: center; align-items: center; width: 16px; height: 16px; border-radius: 50%;
    background: var(--primary-color); color: var(--btn-text-color); font-size: 11px; font-weight: bold; cursor: help;
    margin-left: 6px; position: relative; opacity: 0.8; transition: 0.2s;
}
.help-tip:hover { opacity: 1; }
.help-tip::after {
    content: attr(data-tip); position: absolute; bottom: 150%; left: 50%; transform: translateX(-50%);
    background: rgba(20, 25, 30, 0.95); color: #fff; padding: 10px 12px; border-radius: 6px; font-size: 0.85rem;
    font-weight: normal; white-space: pre-wrap; width: 220px; z-index: 100; pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); border: 1px solid var(--primary-color); text-align: left; line-height: 1.5;
    opacity: 0; visibility: hidden; transition: 0.2s ease-in-out;
}
.help-tip::before {
    content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    border-width: 6px; border-style: solid; border-color: var(--primary-color) transparent transparent transparent;
    opacity: 0; visibility: hidden; transition: 0.2s ease-in-out;
}
.help-tip:hover::after, .help-tip:hover::before { opacity: 1; visibility: visible; }
/* --- 十二長生專用：點擊式說明按鈕 --- */
.stage-help-btn {
    display: inline-block; 
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--primary-color); color: var(--btn-text-color); 
    font-size: 10px; font-weight: bold; cursor: pointer;
    margin-left: 4px; line-height: 14px; text-align: center;
    vertical-align: middle; opacity: 0.8; transition: 0.2s;
}
.stage-help-btn:hover, .stage-help-btn:active {
    opacity: 1; transform: scale(1.1);
}
/* --- 通用按鈕 (已整合底部補丁) --- */
.bazi-app .btn-outline-primary {
    background: transparent; color: var(--primary-color); border: 1px solid var(--primary-color);
    border-radius: 25px; padding: 10px 24px; font-size: 1rem; cursor: pointer; font-weight: bold;
    transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.bazi-app .btn-outline-primary:hover { background: rgba(var(--primary-rgb), 0.1); box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2); transform: translateY(-2px); }
.bazi-app .btn-outline-primary:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.1); }

.bazi-app .btn-unlock, 
.bazi-app .giant-btn, 
.bazi-app .btn-confirm {
    background: var(--primary-color); 
    color: var(--btn-text-color); 
    border: none; 
    border-radius: 50px; 
    cursor: pointer; 
    font-weight: bold; 
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.3);
    transition: transform 0.2s; 
    white-space: nowrap;
}
.bazi-app .btn-unlock { padding: 10px 20px; }
.bazi-app .btn-unlock:hover { transform: scale(1.05); }

/* --- 彈窗 (Modal) --- */
.fate-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); display: none; justify-content: center; align-items: center; z-index: 10000; }
.fate-modal-overlay.show { display: flex; }
.fate-modal { background: #fff; padding: 20px; border-radius: 8px; border: 1px solid #b59252; text-align: center; max-width: 300px; }
/* =========================================
   FateUI Toast 浮動提示樣式
========================================= */
.fate-toast {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: rgba(20, 25, 30, 0.95);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 1px solid var(--primary-color);
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    
    /* 確保中文字完美換行 */
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    max-width: 90vw;
    text-align: left;
}

.fate-toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
    visibility: visible;
}
/* 干支選擇彈窗 */
.fate-modal.gz-modal { max-width: 340px; padding: 20px; }
.gz-modal-title { margin-top: 0; color: var(--primary-color); border-bottom: 1px dashed var(--jade-border); padding-bottom: 10px; font-size: 1.1rem; }
.gz-section { margin-bottom: 15px; text-align: left; }
.gz-section.large-margin { margin-bottom: 25px; }
.gz-label { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 8px; font-weight: bold; }
.gz-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gz-grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.gz-item { padding: 8px 0; border: 1px solid var(--jade-border); border-radius: 6px; text-align: center; cursor: pointer; color: var(--text-main); font-weight: bold; transition: 0.2s; }
.gz-action-row { display: flex; gap: 10px; justify-content: space-between; }
.gz-action-row button { flex: 1; padding: 10px 5px; font-size: 0.9rem; }


/* =========================================
   2. 基礎輸入區與大師面板
========================================= */
/* 核心佈局與容器防呆設定 (已整合底部補丁) */
.basic-input-zone { padding: 20px; border-bottom: 1px dashed var(--jade-border); }
.action-zone { padding: 30px; text-align: center; }
.input-section { padding: 20px; }
.input-section-inner { width: 100%; display: block; clear: both; }

/* 輸入框美化 */
.bazi-app .custom-input, .bazi-app .custom-select {
    padding: 12px 16px; border: 1px solid var(--glass-border); border-radius: 12px;
    background: rgba(var(--primary-rgb), 0.03); color: var(--text-main); font-size: 1rem;
    outline: none; transition: var(--transition); box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); color-scheme: light; 
}
body.dark-theme .bazi-app .custom-input, body.dark-theme .bazi-app .custom-select {
    background: rgba(0,0,0,0.2); box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    border-color: rgba(212, 185, 140, 0.2); color-scheme: dark; 
}
.bazi-app .custom-input:focus, .bazi-app .custom-select:focus { 
    border-color: var(--primary-color); background: var(--glass-bg);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15), inset 0 1px 2px rgba(0,0,0,0.05); transform: translateY(-1px); 
}

/* 頂部引導與選單 */
.onboarding-notice { background: rgba(var(--primary-rgb), 0.05); border-left: 3px solid var(--primary-color); padding: 12px 15px; border-radius: 0 8px 8px 0; margin-bottom: 20px; display: block; }
.onboarding-notice .guide-main { margin: 0 0 5px 0; color: var(--text-main); font-size: 0.95rem; line-height: 1.5; }
.onboarding-notice .guide-sub { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.zone-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed rgba(var(--primary-rgb), 0.4); padding-bottom: 10px; margin-bottom: 15px; }
.zone-header h3 { margin: 0; color: var(--text-main); font-size: 1.1rem; display: inline-flex; align-items: center; gap: 8px; }
.profile-select { max-width: 220px; font-size: 0.85rem; padding: 4px 8px; background: rgba(var(--primary-rgb), 0.1); border: 1px solid var(--primary-color); }

/* 欄位配置 (已整合底部補丁：解決姓名與日期重疊) */
.input-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.input-group { display: flex; flex-direction: column; flex: 1; min-width: 80px; }
.input-group label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; display: block; font-weight: bold;}
.input-group .custom-input, .input-group .custom-select { padding: 8px; width: 100%; box-sizing: border-box; }
.input-group.field-name { flex: 1; min-width: 100px; }
.input-group.field-date { flex: 2; min-width: 150px; }
.input-group.field-hour { flex: 1.5; min-width: 120px; }
.input-group.field-gender { flex: 0.8; min-width: 70px; }

/* 存檔與大師解鎖區 */
.save-section { margin-bottom: 15px; border-bottom: 1px dashed rgba(var(--primary-rgb), 0.4); padding-bottom: 10px; }
.save-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.85rem; color: var(--text-main); }
.save-checkbox { width: 14px; height: 14px; accent-color: var(--primary-color); }
.btn-real-save { padding: 6px 15px; font-size: 0.85rem; background: rgba(var(--primary-rgb), 0.1); border: 1px solid var(--primary-color); color: var(--text-main); border-radius: 6px; cursor: pointer; margin-top: 8px; }

/* 大師解鎖 Banner 桌機版基礎排版 (已整合底部補丁) */
.master-unlock-banner {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 15px 20px; 
    background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.05), rgba(var(--primary-rgb), 0.15));
    border-bottom: 1px solid var(--jade-border); 
    margin-top: 10px;
}
.banner-text h4 { margin: 0 0 5px 0; color: var(--primary-color); }
.banner-text p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

.timeline-section-wrapper.master-unlock-zone { margin: 25px auto 20px auto; }
.timeline-desc.master-desc { margin-bottom: 12px; font-size: 0.85rem; }
.btn-timeline-expand.master-btn { margin: 0 10px; }

/* 大師設定面板 */
.master-settings-panel { padding: 12px; background: rgba(0,0,0,0.1); border-radius: 8px; margin-bottom: 15px; }
body.dark-theme .master-settings-panel { background: rgba(255,255,255,0.02); }
.master-warning-text { font-size: 0.85rem; color: var(--text-muted); margin-top: 0; margin-bottom: 15px; line-height: 1.6; }
.master-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.master-col { flex: 1; min-width: 140px; }
.master-label { font-size: 0.75rem; color: var(--text-main); margin-bottom: 2px; display: block; }
.master-lon-group { display: flex; gap: 5px; align-items: center; }
.master-select { flex: 1; padding: 6px; font-size: 0.85rem; }
.master-exact-time { padding: 5px; font-size: 0.85rem; border: 1px solid var(--ui-warning); }
.master-custom-lon { width: 100%; margin-top: 4px; padding: 6px; font-size: 0.85rem; box-sizing: border-box; }
.master-custom-pillars-zone { margin-bottom: 10px; border-top: 1px dashed var(--jade-border); padding-top: 10px; }
.pillar-buttons-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.gz-picker-btn { padding: 5px; font-size: 0.85rem; color: var(--text-muted); border: 1px solid var(--primary-color); border-radius: 8px; background: var(--glass-bg); cursor: pointer; }
.gz-picker-btn:hover { background: rgba(var(--primary-rgb), 0.1); }
.master-favorable-zone { display: flex; gap: 12px; flex-wrap: wrap; }
.master-favorable-label { color: var(--text-main); font-size: 0.85rem; }

/* AI 相關基礎佈局 (已整合底部補丁) */
.bazi-app .giant-btn { width: 100%; max-width: 400px; font-size: 1.3rem; padding: 18px; }
#question-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; margin-bottom: 20px; }
#ai-action-area { grid-column: 1 / -1; width: 100%; }
/* =========================================
   3. 命盤圖表與核心分析
========================================= */
/* 共用標題 */
.section-title { font-size: 1.1rem; border-left: 4px solid var(--primary-color); padding-left: 10px; margin: 25px 0 15px 0; font-weight: bold; color: var(--text-main); }
.section-title-sub { color: var(--text-muted); font-size: 0.8rem; font-weight: normal; margin-left: 8px; }

/* 頂部看版 */
.dashboard-top { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; margin-bottom: 20px;}
.bazi-app .identity-card, .bazi-app .charts-container {
    background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-main) 100%);
    border: 1px solid var(--jade-border); border-top: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 8px 25px rgba(var(--primary-rgb), 0.08), inset 0 2px 5px rgba(255,255,255,0.4); border-radius: 16px;
}
body.dark-theme .bazi-app .identity-card, body.dark-theme .bazi-app .charts-container {
    border-top: 1px solid rgba(212, 185, 140, 0.3); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.05);
}

/* 核心資料卡 (Identity Card) */
.identity-card.glass-panel { flex: 1; min-width: 280px; margin: 0; display: flex; flex-direction: column; }
.id-header { background: linear-gradient(90deg, transparent, rgba(var(--primary-rgb), 0.15), transparent); text-align: center; color: var(--primary-color); border-bottom: 1px solid var(--jade-border); font-size: 1.1rem; font-weight: bold; padding: 12px 0; }
.id-body { padding: 10px 0; display: flex; flex-direction: column; }
.id-row { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed var(--jade-border); padding: 14px 24px; transition: var(--transition); }
.id-row:last-child { border-bottom: none; }
.id-row:hover { background: rgba(var(--primary-rgb), 0.04); }
.id-row.stacked { flex-direction: column; align-items: flex-start; gap: 8px; }
.id-label { color: var(--text-muted); font-weight: bold; font-size: 0.95rem; }
.id-row-col { display: flex; flex-direction: column; }
.id-row-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.empty-placeholder { color: var(--text-muted); font-size: 0.9rem; }

/* 標籤徽章 */
.id-value { font-weight: normal; display: flex; align-items: center; }
.value-badge {
    display: inline-block; padding: 4px 14px; border-radius: 8px; font-size: 1.05rem; font-weight: bold;
    background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color); border: 1px solid rgba(var(--primary-rgb), 0.2); box-shadow: inset 0 1px 3px rgba(255,255,255,0.6);
}
body.dark-theme .value-badge { box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); }
.badge-struct { background: rgba(var(--primary-rgb), 0.15); border-color: var(--primary-color); color: var(--primary-hover); }
.badge-strength { background: rgba(120, 144, 156, 0.1); border-color: #78909c; color: #546e7a; }
body.dark-theme .badge-strength { color: #b0bec5; }
.badge-kw { background: transparent; border: 1px dashed #e74c3c; color: #e74c3c; font-size: 0.95rem; }
.combo-tags-container { display: flex; flex-wrap: wrap; gap: 6px; }
.kongwang-text { font-size: 0.9rem; }

/* 雷達圖區塊 */
.charts-container.glass-panel { flex: 1.5; min-width: 320px; margin: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 15px;}
.chart-header { padding: 15px 15px 5px 15px; text-align: center; }
.chart-header h5 { color: var(--primary-color); margin: 0; font-size: 1.05rem; display: flex; align-items: center; justify-content: center; gap: 6px; }
.chart-box { flex: 1; min-height: 260px; width: 100%; padding: 5px 10px; position: relative; }
.chart-legend { display: flex; justify-content: center; gap: 20px; font-size: 0.85rem; padding: 5px 15px 15px 15px; }
.legend-item { color: var(--text-main); }
.legend-line-outer { display: inline-block; width: 16px; border-top: 2px dashed var(--primary-color); vertical-align: middle; margin-right: 4px; }
.legend-line-inner { display: inline-block; width: 16px; border-top: 2px solid var(--ui-info, #17a2b8); vertical-align: middle; margin-right: 4px; }
.radar-guide-ui { padding: 15px; background: rgba(0,0,0,0.1); border-top: 1px dashed var(--jade-border); border-radius: 0 0 8px 8px; }
.radar-guide-box { background: rgba(var(--primary-rgb), 0.08); padding: 12px 15px; border-radius: 6px; font-size: 0.9rem; color: var(--text-main); line-height: 1.6; border-left: 3px solid var(--primary-color); }

/* =========================================
   4. 四柱干支 (Pillars)
========================================= */
.pillars-container { 
    display: flex; gap: 10px; overflow-x: auto; 
    padding-top: 80px; /* 🌟 關鍵 1：上方預留足夠空間，讓對話框有地方彈出來不被捲動軸吃掉 */
    padding-bottom: 10px; 
    -ms-overflow-style: none; scrollbar-width: none; 
}
.pillars-container::-webkit-scrollbar { display: none; }

.bazi-app .pillar-card { 
    flex: 1; min-width: 95px; display: flex; flex-direction: column; 
    overflow: visible; /* 🌟 關鍵 2：解開限制，允許對話框突破卡片邊界 */
    border-top: 5px solid var(--primary-color); border-radius: 8px 8px 16px 16px; 
    background: linear-gradient(180deg, rgba(var(--primary-rgb), 0.05) 0%, var(--glass-bg) 100%);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.bazi-app .pillar-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(var(--primary-rgb), 0.2); }
.pillar-header { 
    background: rgba(var(--primary-rgb), 0.1); color: var(--primary-color); 
    text-align: center; padding: 10px 0; font-weight: bold; letter-spacing: 2px; 
    border-bottom: 1px solid var(--jade-border); 
    border-radius: 3px 3px 0 0; /* 🌟 關鍵 3：卡片解開 overflow 後，要在這裡補上圓角，不然 header 的底色會刺破卡片頂端 */
}
.pillar-header-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; font-weight: normal; letter-spacing: 0; }
.pillar-header-sub.highlight { color: var(--primary-color); }
.pillar-body { padding: 12px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 300px; }

/* 干支字塊 */
.char-block { 
    display: flex; flex-direction: column; align-items: center; padding: 15px 4px; margin-bottom: 5px;
    border: 1px solid rgba(var(--primary-rgb), 0.25); border-radius: 8px; transition: var(--transition); 
    background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.05) 100%);
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.6), 0 4px 10px rgba(0,0,0,0.03); 
}
body.dark-theme .char-block {
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.2) 100%);
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.05), 0 4px 10px rgba(0,0,0,0.3);
}
.char-block:hover { transform: translateY(-2px); border-color: var(--primary-color); box-shadow: inset 0 2px 5px rgba(var(--primary-rgb), 0.2), 0 6px 15px rgba(0,0,0,0.08); }
.char-block.empty-block { justify-content: center; color: var(--text-muted); }

.big-char { font-size: 2.8rem; font-weight: bold; line-height: 1.1; margin: 6px 0; font-family: 'PMingLiU', 'MingLiU', 'STZhongsong', serif; }
.god-label { font-size: 0.8rem; font-weight: bold; color: var(--text-muted); margin-bottom: 2px; }
.pct-badge { font-size: 0.7rem; opacity: 0.8; margin-left: 4px; font-weight: normal; }
.muted-particle .big-char { opacity: 0.4; }
.muted-tag { opacity: 0.3; }

/* 藏干與化合 */
.hidden-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 8px; width: 100%; }
.hidden-item { display: flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; transition: 0.3s; border: 1px solid rgba(0,0,0,0.15); background: rgba(0,0,0,0.02); }
body.dark-theme .hidden-item { border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.02); }
.hidden-item .hidden-char { font-weight: bold; }
.hidden-item .hidden-god { font-size: 0.75rem; color: var(--text-muted); }
.hidden-item .hidden-god small { opacity: 0.8; }
.hidden-item.muted-tag { border: 1px solid rgba(0,0,0,0.08); background: transparent; opacity: 0.45; transform: scale(0.92); }
body.dark-theme .hidden-item.muted-tag { border: 1px solid rgba(255,255,255,0.08); }

.fusion-row { margin-top: 8px; width: 100%; }
.fusion-tag { display: block; font-size: 0.75rem; padding: 4px 6px; border-radius: 4px; margin-bottom: 4px; text-align: center; background: transparent; box-shadow: none !important; }
.fusion-tag.is-broken { border: 1px dashed #A53F3F; color: #A53F3F; opacity: 0.85; }
.fusion-tag.is-defended { border: 1px dashed #777777; color: #777777; opacity: 0.85; }
.fusion-tag.is-success { border: 1px dashed currentColor; font-weight: bold; opacity: 0.85; letter-spacing: 0.5px; }
.fusion-tag.stem-fusion { margin: 8px auto 0; width: 90%; }

/* 本命局勢與神煞標籤 */
.combo-tag { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 0.85rem; font-weight: bold; letter-spacing: 1px; }
.tag-he { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border: 1px solid #2ecc71; }
.tag-chong { background: rgba(231, 76, 60, 0.15); color: #e74c3c; border: 1px solid #e74c3c; }
.tag-xing { background: rgba(243, 156, 18, 0.15); color: #f39c12; border: 1px solid #f39c12; }
.tag-none { background: rgba(var(--primary-rgb), 0.1); color: var(--text-muted); border: 1px solid var(--jade-border); }

.life-stage-stamp { margin: 12px auto 6px; font-size: 0.9rem; font-weight: bold; color: var(--text-muted); border: 1px solid var(--glass-border, rgba(128,128,128,0.3)); padding: 3px 10px; border-radius: 4px; display: inline-block; letter-spacing: 2px; background: transparent; }
.shensha-tag-group { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin-top: 6px; }
.shensha-tag { font-size: 0.75rem; color: #666; border: 1px solid #E0E0E0; padding: 2px 6px; border-radius: 4px; background: #FAFAFA; }
body.dark-theme .shensha-tag { color: #AAA; border-color: #444; background: #1A1A1A; }

/* 書卷批註與大運展開 (已整併底部補丁，解決排版問題) */
.master-annotation-box { 
    display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin: 30px auto 40px auto; padding: 20px 25px; 
    background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.08) 0%, transparent 100%); 
    border-left: 3px solid var(--primary-color); border-radius: 0 8px 8px 0; transition: var(--transition); 
    flex-direction: column !important; /* 強制改為垂直排列 */
}
.annotation-content h4 { color: var(--text-main); font-size: 1.1rem; margin: 0 0 8px 0; letter-spacing: 1px; }
.annotation-content p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin: 0; }
.btn-outline-elegant { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border: 1px solid var(--primary-color); color: var(--primary-color); background: transparent; border-radius: 30px; font-size: 0.95rem; font-weight: bold; text-decoration: none; transition: var(--transition); }
.btn-outline-elegant:hover { background: var(--primary-color); color: var(--btn-text-color); transform: translateX(3px); box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2); }

.timeline-section-wrapper { 
    margin: 40px auto 50px auto; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 100%; 
    /* 🌟 修復 1：把 hidden 改成 visible，避免按鈕或陰影被切斷 */
    overflow: visible; 
    /* 🌟 修復 2：加上底部 padding，把父容器的底框往下撐開 */
    padding-bottom: 20px; 
}
.timeline-desc { font-size: 0.9rem; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 16px; text-align: center; position: relative; padding: 0 25px; line-height: 1.6; word-wrap: break-word; }
.timeline-desc::before, .timeline-desc::after { content: '✦'; color: var(--primary-color); opacity: 0.6; font-size: 0.7rem; position: absolute; top: 50%; transform: translateY(-50%); }
.timeline-desc::before { left: -5px; }
.timeline-desc::after { right: -5px; }
.timeline-divider-wrapper { display: flex; align-items: center; width: 100%; }
.timeline-divider-wrapper::before, .timeline-divider-wrapper::after { content: ''; flex: 1; border-bottom: 1px dashed rgba(var(--primary-rgb), 0.4) !important; }
.btn-timeline-expand { margin: 0 20px; padding: 10px 24px; background: transparent; border: 1px solid rgba(var(--primary-rgb), 0.4) !important; color: var(--text-main); opacity: 0.85; border-radius: 30px; font-size: 0.95rem; letter-spacing: 2px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 8px; }
.expand-icon { opacity: 0.7; }
.expand-arrow { font-size: 0.7rem; margin-left: 4px; transition: transform 0.3s; }
.btn-timeline-expand.is-open .expand-arrow { transform: rotate(180deg); }

/* =========================================
   5. 大運與流年 (Timeline)
========================================= */
.dayun-liunian-section { opacity: 0; transition: opacity 0.5s ease; }
.dayun-section { padding: 15px; }
.dayun-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px dashed rgba(var(--primary-rgb), 0.4); }
.dayun-info-text { color: var(--text-main); font-weight: bold; }
.dayun-instruction { color: var(--text-muted); font-size: 0.85rem; }

/* 大運手風琴 */
.accordion-item { margin-bottom: 12px; border: 1px solid var(--jade-border); border-radius: 8px; overflow: hidden; background: var(--glass-bg); }
.accordion-header { background: rgba(var(--primary-rgb), 0.05); padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: all 0.3s ease; border-bottom: 1px solid transparent; }
.accordion-header:hover { background: rgba(var(--primary-rgb), 0.15); }
.accordion-item.is-current-decade .accordion-header { background: rgba(var(--primary-rgb), 0.1); border-left: 4px solid var(--primary-color); }
.acc-title-left { display: flex; align-items: center; gap: 15px; }
.acc-age-badge { background: var(--primary-color); color: var(--btn-text-color); padding: 2px 8px; border-radius: 4px; font-size: 0.85rem; font-weight: bold; }
.acc-gz { font-size: 1.2rem; font-weight: bold; letter-spacing: 2px; }
.acc-years { color: var(--text-main); opacity: 0.7; font-size: 0.85rem; letter-spacing: 1px; }
.acc-icon { color: var(--text-muted); font-weight: bold; font-family: monospace; font-size: 1.2rem; transition: transform 0.3s; }
.accordion-item.open .accordion-header { background: rgba(var(--primary-rgb), 0.2); border-bottom: 1px solid var(--primary-color); }
.accordion-item.open .acc-icon { color: var(--primary-color); }
.accordion-content { background: rgba(var(--primary-rgb), 0.02); padding: 20px; display: none; }
.dy-summary-bar { text-align: center; padding: 10px; margin-bottom: 20px; background: rgba(var(--primary-rgb), 0.05); border: 1px dashed var(--jade-border); border-radius: 6px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.dy-summary-title { font-size: 0.9rem; color: var(--text-muted); font-weight: bold; }

/* 流年網格與卡片 (整合 auto-fit 動態適應欄數) */
.bazi-app .liunian-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important; 
    column-gap: 12px; row-gap: 28px; align-items: stretch; margin: 20px 0 !important; overflow: visible !important; 
}
.bazi-app .liunian-card { 
    position: relative; z-index: 1; height: auto !important; min-height: 200px; display: flex; flex-direction: column; 
    padding: 12px 8px 15px 8px !important; margin-bottom: 5px; border: 1px solid var(--glass-border); border-radius: 8px; 
    background: var(--glass-bg); transition: transform 0.2s; 
}
.bazi-app .liunian-card:hover { transform: translateY(-3px); border-color: var(--primary-color); z-index: 50; }
.bazi-app .liunian-card > div:last-child { margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }

.bazi-app .current-year-card { border: 2px solid var(--primary-color); background: rgba(var(--primary-rgb), 0.05); box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.25); position: relative; transform: translateY(-2px); z-index: 5; }
.bazi-app .current-year-card::before { content: "🌟 今年"; position: absolute; top: -12px; right: -10px; background: var(--primary-color); color: var(--btn-text-color); font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 10; }

.bazi-app .liunian-card.is-critical { border: 2px solid #e74c3c !important; outline: none; background: linear-gradient(to bottom, rgba(192, 57, 43, 0.08), var(--glass-bg)) !important; }
.bazi-app .liunian-card.is-lucky { border: 2px solid #d4af37 !important; outline: none; background: linear-gradient(to bottom, rgba(212, 175, 55, 0.1), var(--glass-bg)) !important; }
body.dark-theme .bazi-app .liunian-card.is-lucky { border-color: #f1c40f !important; background: linear-gradient(to bottom, rgba(241, 196, 15, 0.15), var(--glass-bg)) !important; }
body.dark-theme .bazi-app .liunian-card.is-critical { border-color: #ff4d4f !important; background: linear-gradient(to bottom, rgba(231, 76, 60, 0.15), var(--glass-bg)) !important; }

.ln-head { display: flex; justify-content: center; align-items: center; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.kw-badge-common { white-space: nowrap; font-size: 0.7rem; padding: 1px 4px; background: rgba(127, 140, 141, 0.2); color: var(--text-muted); border-radius: 3px; flex-shrink: 0; }
.ln-tags-container { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 6px 0; min-height: 20px; }

/* 🚨 終極防爆框補丁：針對流年卡片內的標籤與按鈕 (法文印尼文救星) */
.bazi-app .ln-title-badge.pulse-btn,
.bazi-app .ln-event-tag { 
    width: 95%; margin: 2px auto; font-size: 0.82rem; border-radius: 4px; text-align: center; 
    font-weight: bold; position: relative; z-index: 2; border: 1px solid var(--glass-border); box-shadow: 0 1px 3px rgba(0,0,0,0.05); letter-spacing: 0.5px;
    
    white-space: normal !important;
    overflow-wrap: anywhere !important; 
    word-break: break-word !important;
    hyphens: auto !important;
    padding: 4px !important;  
    line-height: 1.3 !important;
}
.bazi-app .ln-event-tag:hover { z-index: 100; }
.bazi-app .ln-event-tag small { opacity: 0.7; font-size: 0.75rem; font-weight: normal; margin-left: 2px; }

/* 標籤色彩配置 */
.bazi-app .ln-event-tag.tag-he, .bazi-app .ln-event-tag.tag-lucky { border-left: 4px solid #27ae60; background: rgba(46, 204, 113, 0.08) !important; color: #1e8449 !important; border-color: rgba(46, 204, 113, 0.2) !important; }
body.dark-theme .bazi-app .ln-event-tag.tag-he, body.dark-theme .bazi-app .ln-event-tag.tag-lucky { color: #2ecc71 !important; background: rgba(46, 204, 113, 0.25) !important; border-left-color: #2ecc71 !important; }

.bazi-app .ln-event-tag.tag-chong, .bazi-app .ln-event-tag.tag-critical { border-left: 4px solid #e74c3c; background: rgba(231, 76, 60, 0.08) !important; color: #b03a2e !important; border-color: rgba(231, 76, 60, 0.2) !important; }
body.dark-theme .bazi-app .ln-event-tag.tag-chong, body.dark-theme .bazi-app .ln-event-tag.tag-critical { color: #ff4d4f !important; background: rgba(231, 76, 60, 0.25) !important; border-left-color: #e74c3c !important; }

.bazi-app .ln-event-tag.tag-xing, .bazi-app .ln-event-tag.tag-warn, .bazi-app .ln-event-tag.tag-warning { border-left: 4px solid #f39c12; background: rgba(243, 156, 18, 0.08) !important; color: #b9770e !important; border-color: rgba(243, 156, 18, 0.2) !important; }
body.dark-theme .bazi-app .ln-event-tag.tag-xing, body.dark-theme .bazi-app .ln-event-tag.tag-warn { color: #f1c40f !important; background: rgba(243, 156, 18, 0.25) !important; border-left-color: #f1c40f !important; }

.bazi-app .ln-event-tag.tag-none { border-left: 4px solid #95a5a6; background: rgba(149, 165, 166, 0.08); color: #555555; border-color: rgba(149, 165, 166, 0.2); }
body.dark-theme .bazi-app .ln-event-tag.tag-none { color: #aaaaaa; background: rgba(149, 165, 166, 0.2) !important; border-left-color: #95a5a6; }

/* 呼叫脈衝按鈕 (Pulse Button) */
.ln-title-badge.pulse-btn { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; border-radius: 6px 6px 0 0; font-size: 0.95rem; font-weight: bold; letter-spacing: 1px; transition: all 0.3s ease; cursor: pointer; z-index: 10; }
.ln-title-badge.pulse-btn:hover { filter: brightness(1.15); transform: translateY(-2px); }
.ln-title-badge .cta-text { font-size: 0.75rem; opacity: 0.9; font-weight: normal; letter-spacing: 0.5px; background: rgba(255, 255, 255, 0.2); padding: 2px 6px; border-radius: 4px; margin-top: 4px; }
body.dark-theme .ln-title-badge .cta-text { background: rgba(0, 0, 0, 0.2); }

@keyframes luckyPulse { 0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4); } 70% { box-shadow: 0 0 0 6px rgba(212, 175, 55, 0); } 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); } }
@keyframes criticalPulse { 0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); } 70% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); } 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); } }
.ln-title-badge.lucky.pulse-btn { animation: luckyPulse 2s infinite; }
.ln-title-badge.critical.pulse-btn { animation: criticalPulse 2s infinite; }
/* =========================================
   6. AI 策略顧問區 (Phase 1, 2, 3)
========================================= */
.ai-section-main { padding: 20px; margin-top: 40px; min-height: 400px; }
.ai-intro-text { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 30px; text-align: justify; }

.step-phase-label { font-family: 'Georgia', serif; font-size: 0.75rem; letter-spacing: 4px; color: var(--primary-color); opacity: 0.5; margin-bottom: 5px; text-transform: uppercase; }
.step-main-title { color: var(--text-main); font-size: 1.15rem; font-weight: bold; margin: 0 0 25px 0; padding-bottom: 10px; border-bottom: 1px solid rgba(var(--primary-rgb), 0.2); letter-spacing: 1px; }

/* 步驟卡片容器 */
.step-card-container {
    position: relative; overflow: hidden; padding: 0 !important; display: flex; align-items: center;
    border-radius: 16px; margin-bottom: 45px; background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.08) 0%, rgba(var(--primary-rgb), 0.02) 100%);
    border: 1px solid rgba(var(--primary-rgb), 0.4); box-shadow: 0 8px 30px rgba(0,0,0,0.05); 
}
.step-card-container:hover { animation-play-state: paused; border-color: var(--primary-color); box-shadow: 0 12px 30px rgba(var(--primary-rgb), 0.15); transform: translateY(-2px); }
.step-inner-content { position: relative; z-index: 1; display: flex; flex-direction: row; justify-content: center; align-items: center; gap: clamp(20px, 5vw, 45px); padding: 35px 25px; width: 100%; }
.step-icon-wrapper { flex: 0 0 auto; width: clamp(130px, 25vw, 180px); display: flex; justify-content: center; align-items: center; }
.step-icon-wrapper img { width: 100%; height: auto; filter: drop-shadow(0 10px 15px rgba(0,0,0,0.2)); transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.step-text-block { flex: 0 1 auto; display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
.step-card-title { color: var(--primary-color); font-size: 1.3rem; font-weight: bold; margin: 0 0 10px 0 !important; }
.step-card-desc { color: var(--text-main); font-size: 0.95rem; line-height: 1.6; margin: 0 0 20px 0 !important; max-width: 400px; opacity: 0.85; }

.step-bg-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; z-index: 0; transition: opacity 0.3s ease; }
.step-one-bg { background-image: url('/public/Images/bg-totem.webp'); opacity: 0.12; mix-blend-mode: multiply; }
.step-two-bg { background-image: url('/public/Images/bg-Time.webp'); opacity: 0.12; mix-blend-mode: multiply; }
body.dark-theme .step-bg-layer { opacity: 0.2; mix-blend-mode: screen; }

/* 年份與按鈕區 */
.step-action-group { display: flex; flex-direction: column; gap: 15px; width: 100%; }
.target-year-selector-box { display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(var(--primary-rgb), 0.1); padding: 12px 20px; border-radius: 12px; border: 1px solid var(--jade-border); }
.target-year-label { color: var(--text-main); font-weight: bold; font-size: 0.95rem; }
.target-year-input-lg { width: 130px; text-align: center; font-size: 1.1rem; font-weight: bold; padding: 8px; color: var(--primary-color); }
.target-year-input-sm { width: 110px; text-align: center; font-size: 1.1rem; color: var(--primary-color); font-weight: bold; padding: 5px; }
.step3-target-year-box { display: flex; justify-content: center; align-items: center; margin-bottom: 25px !important; background: transparent; border: none; padding: 0; }

.custom-phoenix-btn { display: inline-flex; align-items: center; gap: 10px; padding: 10px 25px 10px 15px; border: 1px solid rgba(var(--primary-rgb), 0.5); border-radius: 30px; color: var(--primary-color); font-weight: bold; background: rgba(var(--primary-rgb), 0.08); cursor: pointer; transition: all 0.3s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.custom-phoenix-btn:hover { background: rgba(var(--primary-rgb), 0.15); border-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 6px 15px rgba(var(--primary-rgb), 0.2); }

/* PHASE 03: 頁籤與問題儀表板 */
.ai-tabs-header, #ai-tabs-header { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 20px; border-bottom: 2px solid rgba(var(--primary-rgb), 0.2); padding-bottom: 12px; }
.ai-tab-custom { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 15px; font-size: 1rem; color: var(--text-muted); background: transparent; border: 1px solid rgba(var(--primary-rgb), 0.3); border-radius: 50px; cursor: pointer; transition: all 0.3s ease; outline: none; box-sizing: border-box; }
.ai-tab-custom span { position: relative; z-index: 2; letter-spacing: 1px; color: var(--text-main); white-space: normal; word-break: keep-all; line-height: 1.2; text-align: center; }
.ai-tab-custom::before, .ai-tab-custom::after { content: ""; display: block; width: 1.3em; height: 1.3em; background-image: var(--btn-icon); background-size: contain; background-repeat: no-repeat; background-position: center; pointer-events: none; flex-shrink: 0; }
.ai-tab-custom::after { transform: scaleX(-1); }
.ai-tab-custom.active { background: rgba(var(--primary-rgb), 0.05); border-color: var(--primary-color); box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3); }
.ai-tab-custom.active span { color: var(--primary-color) !important; font-weight: 900; }
.ai-tab-custom:hover:not(.active) { border-color: var(--primary-color); background: rgba(var(--primary-rgb), 0.1); }

.ai-master-dashboard-single { display: flex; flex-direction: column; width: 100%; max-width: 800px; margin: 0 auto; padding-bottom: 30px; }
#ai-tabs-content { min-height: 480px; transition: min-height 0.3s ease; position: relative; }
#ai-tabs-content::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: contain; background-repeat: no-repeat; background-position: right top; opacity: 0.15; z-index: -1; transition: background-image 0.5s ease-in-out; pointer-events: none; }
#ai-tabs-content[data-tab="love"]::before { background-image: url('/public/Images/Love-Sakura.webp'); }
#ai-tabs-content[data-tab="career"]::before { background-image: url('/public/Images/career-bamboo.webp'); }
#ai-tabs-content[data-tab="wealth"]::before { background-image: url('/public/Images/wealth-Gui.webp'); }
#ai-tabs-content[data-tab="health"]::before { background-image: url('/public/Images/health-plum.webp'); }
body.dark-theme #ai-tabs-content::before { opacity: 0.25; mix-blend-mode: screen; }

.ai-question-group-title { font-size: 0.9rem; color: var(--text-main); margin: 15px 0 10px 0; border-left: 3px solid var(--primary-color); padding-left: 8px; font-weight: bold; letter-spacing: 2px; display: flex; align-items: center; gap: 6px; }
.ai-question-group-title::before { content: "❖"; font-size: 0.8em; }
.ai-question-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 25px; }

.btn-ai-question { display: flex !important; flex-direction: row !important; align-items: center !important; text-align: left; gap: 12px; padding: 16px 20px !important; background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(var(--primary-rgb), 0.3); border-left: 4px solid transparent; border-radius: 12px; color: var(--text-main); font-size: 1.05rem; cursor: pointer; transition: all 0.3s ease; width: 100%; }
.btn-ai-question img { width: 1.8em; height: 1.8em; flex-shrink: 0; filter: grayscale(0.5) opacity(0.7); transition: all 0.3s ease; }
.btn-ai-question:hover { background: rgba(255, 255, 255, 0.9); border-color: rgba(var(--primary-rgb), 0.6); border-left-color: var(--primary-color); transform: translateX(6px); box-shadow: -4px 4px 15px rgba(var(--primary-rgb), 0.1); }
.btn-ai-question:hover img { filter: grayscale(0) opacity(1); }
.btn-ai-question.selected { background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(var(--primary-rgb), 0.1) 100%); border-color: var(--primary-color); border-left: 4px solid var(--primary-color); box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.15); transform: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; font-weight: bold; }
.btn-ai-question.selected img { filter: grayscale(0) opacity(1) drop-shadow(0 0 5px rgba(var(--primary-rgb), 0.3)); }

body.dark-theme .btn-ai-question { background: rgba(20, 20, 20, 0.5); border-color: rgba(var(--primary-rgb), 0.2); }
body.dark-theme .btn-ai-question:hover { background: rgba(var(--primary-rgb), 0.1); border-color: rgba(var(--primary-rgb), 0.5); box-shadow: -4px 4px 15px rgba(0, 0, 0, 0.2); }
body.dark-theme .btn-ai-question.selected { background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.15) 0%, rgba(20, 20, 20, 0.8) 100%); box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.2); }
body.dark-theme .btn-ai-question.selected img { filter: grayscale(0) opacity(1) drop-shadow(0 0 5px rgba(var(--primary-rgb), 0.8)); }

.action-console-inline { display: flex; flex-direction: column; gap: 25px; margin-top: -12px; margin-bottom: 20px; padding: 25px 20px; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--primary-color); border-top: none; border-radius: 0 0 12px 12px; box-shadow: 0 10px 25px rgba(var(--primary-rgb), 0.15); animation: slideDownFade 0.3s ease-out forwards; width: 100%; grid-column: 1 / -1; }
body.dark-theme .action-console-inline { background: rgba(20, 20, 20, 0.85); border-color: var(--primary-color); box-shadow: 0 10px 25px rgba(0,0,0,0.4); }
@keyframes slideDownFade { from { opacity: 0; transform: translateY(-15px); } to { opacity: 1; transform: translateY(0); } }

/* 強制啟動分析區塊橫跨所有網格，避免被擠在小格子裡 (整合補丁) */
#ai-action-area { grid-column: 1 / -1; width: 100%; }

.final-question-display { margin-bottom: 15px; font-weight: bold; color: var(--primary-color); font-size: 1.1rem; line-height: 1.5; text-align: center; }
.ai-response-area { padding: 20px; margin-top: 20px; line-height: 1.8; color: var(--text-main); }
.error-log-box { color: var(--ui-danger); font-size: 0.8rem; margin-top: 10px; }

/* 算命與重試按鈕 */
.calc-action-zone { text-align: center; margin: 40px auto 20px auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loading-text-wrapper { font-size: 1.1rem; color: var(--text-main); }
.loading-countdown-number { color: var(--ui-warning, #e67e22); font-weight: bold; font-size: 1.4rem; }

.btn-custom-icon { display: inline-flex !important; align-items: center; justify-content: center; gap: 0.8em; padding: 0.6em 1.8em; font-size: 1.15rem; font-weight: bold; border-radius: 50px; cursor: pointer; transition: all 0.3s ease; background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 235, 225, 0.95) 100%); border: 1px solid rgba(var(--primary-rgb), 0.5); color: #333333 !important; max-width: 100%; height: auto; box-sizing: border-box; }
.btn-custom-icon span { white-space: normal !important; word-break: keep-all; line-height: 1.3; position: relative; z-index: 2; }
.btn-custom-icon::before, .btn-custom-icon::after { content: ""; display: block; flex-shrink: 0; width: 1.5em; height: 2em; background-image: var(--btn-icon); background-size: contain; background-repeat: no-repeat; background-position: center; }
.btn-custom-icon::after { transform: scaleX(-1); }
.btn-custom-icon:hover { background: linear-gradient(135deg, #ffffff 0%, rgba(var(--primary-rgb), 0.1) 100%); border-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.15); }
.btn-custom-icon:active { transform: translateY(1px); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); }

/* --- 每日運勢氣泡框 (毛玻璃特效) (整合補丁) --- */
.ai-text-bubble {
    background: var(--glass-bg); border: 1px solid var(--primary-color); border-radius: 12px; padding: 20px;
    color: var(--text-main); box-shadow: 0 10px 25px rgba(0,0,0,0.3), inset 0 0 15px rgba(var(--primary-rgb), 0.05);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.ai-text-bubble h3 { color: var(--primary-color); font-size: 1.05rem; margin-top: 15px; margin-bottom: 8px; border-bottom: 1px dashed var(--jade-border); padding-bottom: 5px; }
.ai-text-bubble h3:first-child { margin-top: 0; }

/* =========================================
   7. 📜 暗黑燙金羊皮紙畫布 (Parchment)
========================================= */
.bazi-app .parchment-canvas-wrapper { width: 100%; max-width: 360px; height: 520px; margin: 0 auto; position: relative; perspective: 1200px; transition: max-width 0.8s cubic-bezier(0.25, 1, 0.5, 1), height 0.8s ease; }
.bazi-app .parchment-canvas-wrapper.is-expanded, .bazi-app .parchment-canvas-wrapper.is-expanded .card-inner, .bazi-app .parchment-canvas-wrapper.is-expanded .card-side.card-front { max-width: 100%; height: auto; min-height: 100%; cursor: default; }
.bazi-app .parchment-canvas-wrapper.is-expanded { margin-bottom: 50px; }
.bazi-app .parchment-canvas-wrapper.is-expanded .card-side { position: relative; overflow: visible; }
.bazi-app .parchment-canvas-wrapper.is-expanded .card-front { overflow: hidden; }
.bazi-app .parchment-canvas-wrapper.is-expanded .card-back { display: none; }

.bazi-app .card-inner { position: relative; width: 100%; height: 100%; transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-style: preserve-3d; }
.bazi-app .card-inner.is-flipped { transform: rotateY(180deg); }
.bazi-app .parchment-canvas-wrapper .card-side { position: absolute; top: 0; left: 0; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.8), inset 0 0 40px rgba(181, 146, 82, 0.15); background: #111111; border: 2px solid #b59252; overflow: hidden; color: #e0e0e0; }
.bazi-app .card-back { transform: rotateY(0deg); display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.bazi-app .card-front { transform: rotateY(180deg); display: flex; flex-direction: column; }

.bazi-app .btn-reveal-scroll { color: #b59252; font-size: 1.05rem; letter-spacing: 4px; border: 1px solid #b59252; padding: 12px 25px; border-radius: 4px; background: rgba(181, 146, 82, 0.1); font-weight: bold; display: inline-block; transition: 0.3s; }
.bazi-app .parchment-canvas-wrapper:hover .btn-reveal-scroll { background: rgba(181, 146, 82, 0.2); }

.bazi-app .parchment-hero { position: relative; width: 100%; border-bottom: 2px solid #b59252; background: #000; }
.bazi-app .parchment-hero img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: center top; display: block; }
.bazi-app .parchment-body { padding: 25px; background: #111111; }
.bazi-app .goddess-title { color: #b59252; font-size: 1.5rem; text-align: center; letter-spacing: 3px; margin: 0 0 25px 0; font-weight: bold; text-shadow: 0 0 15px rgba(181, 146, 82, 0.4); }
.bazi-app .destiny-info-box { display: flex; justify-content: space-around; background: rgba(181, 146, 82, 0.1); border: 1px dashed rgba(181, 146, 82, 0.4); padding: 12px; border-radius: 8px; margin-bottom: 25px; }
.bazi-app .info-item { color: #b59252; font-weight: bold; font-size: 0.95rem; letter-spacing: 1px; }
.bazi-app .info-icon { opacity: 0.8; margin-right: 4px; }
.bazi-app .section-badge { display: inline-block; background: #b59252; color: #000; padding: 4px 12px; border-radius: 4px; font-size: 0.9rem; font-weight: bold; margin-bottom: 15px; }
.bazi-app .outline-badge { background: transparent; color: #b59252; border: 1px solid #b59252; }
.bazi-app .msg-text { font-size: 1.1rem; line-height: 1.7; color: #eee; text-align: justify; margin-bottom: 15px; }
.bazi-app .lore-accordion summary { cursor: pointer; color: #888; font-size: 0.85rem; outline: none; border-bottom: 1px dashed #555; padding-bottom: 5px; display: inline-block; transition: 0.2s; }
.bazi-app .lore-accordion summary:hover { color: #b59252; border-color: #b59252; }
.bazi-app .lore-text { font-size: 0.9rem; color: #aaa; margin-top: 12px; line-height: 1.6; padding: 12px; background: rgba(0,0,0,0.4); border-radius: 6px; border: 1px solid rgba(255,255,255,0.05); }

.bazi-app .ai-text-container { color: #ddd; font-size: 1rem; line-height: 1.7; }
.bazi-app .ai-text-container h3, .ai-text-container h3 { color: var(--primary-color); font-size: 1.15rem; margin: 15px 0 8px 0; border-bottom: 1px dashed rgba(var(--primary-rgb), 0.3); padding-bottom: 5px; }
.bazi-app .ai-text-container h3:first-child { margin-top: 0; }
.bazi-app .parchment-footer { text-align: center; margin-top: 30px; font-size: 0.95rem; letter-spacing: 4px; color: #d4b98c; font-weight: bold; border-top: 1px solid rgba(181, 146, 82, 0.4); padding-top: 20px; }

/* 每日運勢與保存按鈕 */
.daily-luck-zone.dynamic { margin-bottom: 35px; flex-direction: column; align-items: center; width: 100%; }
.goddess-hero-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; object-position: center top; display: block; }
.parchment-section-center { width: 100%; text-align: center; }
.lore-summary { cursor: pointer; color: #b59252; font-size: 0.9rem; border-bottom: 1px dashed #b59252; padding-bottom: 5px; display: inline-block; }
.lore-text-box { font-size: 0.9rem; color: #aaa; margin-top: 12px; line-height: 1.6; padding: 12px; background: rgba(0,0,0,0.4); border-radius: 6px; border: 1px solid rgba(255,255,255,0.05); text-align: left; }
.daily-result-area { width: 100%; text-align: center; margin-top: 25px; position: relative; z-index: 10; }

.bazi-app .parchment-btn-primary, .bazi-app .parchment-btn-secondary { cursor: pointer; }
.bazi-app #daily-result-area .btn-calc { background: var(--primary-color); color: var(--btn-text-color); border: none; border-radius: 25px; box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3); font-weight: bold; transition: all 0.3s ease; }
.bazi-app #daily-result-area .btn-calc:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.5); }
.bazi-app .parchment-btn-secondary { background: var(--glass-bg); color: var(--text-main); border: 1px solid var(--glass-border); font-weight: bold; border-radius: 25px; transition: all 0.3s ease; }
.bazi-app .parchment-btn-secondary:hover { background: rgba(var(--primary-rgb), 0.15); border-color: var(--primary-color); color: var(--primary-color); }

/* =========================================
   8. 頁底大師箴言 (SEO 區塊)
========================================= */
.ai-disclaimer-box {
    max-width: 960px; width: 95%; margin: 60px auto 40px auto; padding: 35px 40px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.05) 0%, rgba(var(--primary-rgb), 0.01) 100%);
    border: 1px solid rgba(var(--primary-rgb), 0.15); border-top: 3px solid var(--primary-color);
    border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.02); display: flex; flex-direction: column; gap: 30px;
}
body.dark-theme .ai-disclaimer-box { background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(0,0,0,0.2) 100%); border: 1px solid rgba(255,255,255,0.05); border-top: 3px solid var(--primary-color); box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.ai-disclaimer-box h3 { text-align: center; color: var(--primary-color); font-size: 1.25rem; letter-spacing: 2px; margin-top: 0; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px dashed rgba(var(--primary-rgb), 0.3); }
.ai-explain-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 25px; }
.ai-disclaimer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; }
.seo-desc, .ai-explain-item span, .ai-disclaimer-item span { display: block; color: var(--text-muted); font-size: 0.95rem; line-height: 1.7; text-align: justify; }
.seo-desc { margin-bottom: 20px; text-align: center; }
.ai-explain-item strong, .ai-disclaimer-item strong { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text-main); font-size: 1.05rem; margin-bottom: 10px; }
.ai-divider { border: 0; border-top: 1px dashed rgba(var(--primary-rgb), 0.3); margin: 0; width: 100%; }

/* ==========================================================================
   9. 📱 響應式設計 (RWD 統一管理區)
========================================================================== */

/* --- 平板與小筆電 (Max Width: 768px) --- */
@media (max-width: 768px) {
    .ai-disclaimer-box { padding: 25px 20px; }
    .ai-explain-grid, .ai-disclaimer-grid { grid-template-columns: 1fr; gap: 20px; }
    
    .step-inner-content { flex-direction: column; text-align: center; padding: 30px 20px; }
    .step-text-block, .step-action-group { align-items: center; text-align: center; }
    .step-icon-wrapper { width: 140px; margin-bottom: 10px; }

    #ai-tabs-header { gap: 8px; }
    .ai-tab-custom { width: calc(50% - 6px); padding: 8px 4px; font-size: 0.85rem; gap: 4px; }
    .ai-tab-custom::before, .ai-tab-custom::after { width: 1.1em; height: 1.1em; }
}

/* --- 大型手機 (Max Width: 650px) --- */
@media (max-width: 650px) {
    .master-annotation-box { flex-direction: column; align-items: flex-start; background: rgba(var(--primary-rgb), 0.04); border-left: none; border-top: 3px solid var(--primary-color); border-radius: 0 0 8px 8px; }
    .btn-outline-elegant { width: 100%; justify-content: center; margin-top: 10px; }
}

/* --- 標準手機版 (Max Width: 600px) --- */
@media (max-width: 600px) {
    .id-label .help-tip::after { left: 0; transform: translateX(0); width: 220px; }
    .id-label .help-tip::before { left: 50%; transform: translateX(-50%); }

    .master-unlock-banner { flex-direction: column; text-align: center; gap: 15px; }
    .pillar-buttons { flex-wrap: wrap; }
    .gz-picker-btn { min-width: 45%; }
    
    .bazi-app .liunian-grid { grid-template-columns: repeat(2, 1fr) !important; row-gap: 20px !important; }

    .ai-tabs-header { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; overflow-x: visible; padding-bottom: 15px; }
    .ai-tab-btn { width: 100%; justify-content: center; padding: 10px 5px; }
    .ai-question-grid { grid-template-columns: 1fr; }
    .btn-ai-question { height: auto; padding: 15px !important; }
    
    #step3-btn-box { padding: 20px 15px !important; }
    #ai-tabs-content { min-height: 580px; }

    .btn-custom-icon { font-size: 1rem; padding: 12px 16px; width: 100%; }
    .btn-custom-icon::before, .btn-custom-icon::after { width: 1.2em; height: 1.5em; }
}