/* ==================== 全局 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
    /* 主色：天青（青瓷灰绿） + 古铜金 */
    --primary: #4f9484;
    --primary-deep: #3f8071;
    --primary-soft: #6fae9f;
    --gold: #b0905a;
    --gold-deep: #96774a;

    --bg-top: #eef3f1;
    --bg-bottom: #e2eae6;
    --card: #ffffff;
    --card-soft: #f1f6f3;
    --field: #e7eeea;

    --text: #2a3a34;
    --text-sub: #5f726b;
    --text-muted: #93a39c;
    --line: #dde8e2;
    --line-strong: #c6dad0;

    --shadow-sm: 0 2px 10px rgba(40, 90, 78, 0.06);
    --shadow: 0 8px 28px rgba(40, 90, 78, 0.1);
    --shadow-lg: 0 14px 40px rgba(40, 90, 78, 0.16);

    /* 五行配色（天青底适配；土=赭、金=古铜，明显区分） */
    --wx-mu: #2f9e6a;
    --wx-huo: #d9614a;
    --wx-tu: #8a6a30;
    --wx-jin: #bf9636;
    --wx-shui: #3a8fbf;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    background:
        radial-gradient(900px 420px at 50% -160px, rgba(79, 148, 132, 0.15), transparent 70%),
        radial-gradient(600px 500px at 100% 8%, rgba(176, 144, 90, 0.08), transparent 60%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    background-attachment: fixed;
}

.serif { font-family: 'Noto Serif SC', 'KaiTi', serif; }

/* ==================== 头部 ==================== */
.header {
    position: relative;
    text-align: center;
    padding: 46px 24px 40px;
    color: #fff;
    background: linear-gradient(135deg, #3d7d72 0%, #549285 55%, #6aa597 100%);
    border-radius: 0 0 30px 30px;
    box-shadow: 0 12px 34px rgba(40, 90, 78, 0.28);
    overflow: hidden;
}
.header::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(420px 200px at 80% -40%, rgba(255, 255, 255, 0.28), transparent 60%);
    pointer-events: none;
}
.header h1 {
    font-family: 'Noto Serif SC', serif;
    font-size: 2.1em; font-weight: 700; letter-spacing: 10px; text-indent: 10px;
    text-shadow: 0 3px 16px rgba(20, 55, 47, 0.35);
}
.header .subtitle {
    margin-top: 12px; font-size: 0.85em; letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.82);
}
.header .subtitle em {
    font-style: normal; font-weight: 700;
    color: #ffe7a6;
}

.container { max-width: 1480px; margin: 0 auto; padding: 18px 16px 50px; }

/* 输入表单：两行布局 */
.input-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
    padding: 8px 20px; border: 1.5px solid var(--line); background: var(--field);
    border-radius: 999px; color: var(--text-sub); font-family: inherit; font-size: 0.9em;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(79, 148, 132, 0.3);
}

#bazi-form .form-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
#bazi-form .form-row:last-of-type { margin-bottom: 0; }
#bazi-form .form-group { flex: 1 1 0; min-width: 120px; margin-bottom: 0; }
#bazi-form .gender-group { padding-top: 0; }
.form-row-actions { align-items: flex-end; }
#bazi-form .form-row-actions .gender-wrap { flex: 0 1 360px; }
#bazi-form .form-row-actions .btn-submit { flex: 0 0 auto; width: auto; margin-top: 0; margin-left: auto; padding: 13px 52px; }
.gz-select { font-family: 'Noto Serif SC', serif; font-weight: 700; }

.bazi-hint { margin-top: 12px; font-size: 0.82em; color: var(--text-muted); line-height: 1.6; }
.time-hm { display: flex; align-items: center; gap: 6px; }
.time-hm span { color: var(--text-muted); font-weight: 700; }
.time-hm select { flex: 1; }
.solar-hint { color: var(--wx-shui); font-weight: 600; }
.form-msg {
    margin-top: 12px; padding: 10px 14px; border-radius: 12px; font-size: 0.88em;
    background: rgba(232, 81, 58, 0.08); border: 1px solid rgba(232, 81, 58, 0.22); color: var(--wx-huo);
}
.form-msg.ok { background: rgba(37, 163, 90, 0.09); border-color: rgba(37, 163, 90, 0.28); color: var(--wx-mu); }

@media (max-width: 560px) {
    #bazi-form .form-group { flex: 1 1 calc(50% - 7px); min-width: 0; }
    .form-row-actions .btn-submit { flex: 1 1 100%; }
}

/* 结果区：默认单栏，宽屏时三栏（大运 | 排盘 | 聊天） */
.result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}
.result-col { min-width: 0; }

/* 模块切换标签：窄屏（手机/平板竖屏）一次只显示一个模块，点标签切换 */
.result-tabs {
    display: flex; gap: 7px; margin-bottom: 16px;
    position: sticky; top: 0; z-index: 20;
    padding: 8px 0; background: var(--bg-grad, var(--card-soft));
    background: linear-gradient(var(--card-soft), var(--card-soft));
}
.rtab {
    flex: 1; padding: 11px 4px; border: 1.5px solid var(--line); background: var(--field);
    border-radius: 12px; color: var(--text-sub); font-family: inherit; font-size: 0.9em;
    font-weight: 600; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.rtab:hover { color: var(--text); }
.rtab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(79, 148, 132, 0.3);
}

@media (max-width: 1099px) {
    /* 标签页模式：仅显示当前激活的模块栏 */
    .result-col { display: none; }
    .result-col.col-active { display: block; animation: fadeIn 0.3s ease; }
}

@media (min-width: 1100px) {
    .result-tabs { display: none; }   /* 宽屏三栏并排，无需标签 */
    /* 宽屏 PC 还原改版前布局：排盘合并到中栏一张表（四柱+所选运程），左栏只保留大运选择，故隐藏左栏运程表 */
    #yun-chart-card { display: none; }
    /* 中栏放排盘合并表（最多 9 列）略宽；左右栏均衡铺开，不再拥挤 */
    .result-grid { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.3fr) minmax(0, 1fr); }
    /* 三栏各自内部滚动并固定，互不影响，避免任一栏过高导致其它栏留白 */
    .result-col {
        position: sticky;
        top: 16px;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .result-col > *:last-child { margin-bottom: 0; }
}

/* 通用卡片 */
.form-section, .bazi-chart, .dayun-section, .ai-section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

/* 区块标题 */
.form-section h2, .bazi-chart h2, .ai-section h2,
.dayun-section h3 {
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex; align-items: center; gap: 8px;
}
.form-section h2, .bazi-chart h2, .ai-section h2 { font-size: 1.12em; margin-bottom: 18px; }
.dayun-section h3 { font-size: 1.02em; margin-bottom: 14px; }

/* ==================== 表单 ==================== */
.form-section { padding: 22px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.form-group { flex: 1; min-width: 130px; }
.form-group label { display: block; color: var(--text-sub); font-size: 0.8em; margin-bottom: 6px; font-weight: 600; }
.form-group input, .form-group select {
    width: 100%; padding: 12px 14px; background: var(--field);
    border: 1.5px solid transparent; border-radius: 13px; color: var(--text);
    font-family: inherit; font-size: 0.95em; transition: all 0.2s;
    appearance: none; -webkit-appearance: none;
}
.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2393a39c' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
.form-group input:focus, .form-group select:focus {
    outline: none; background: #fff; border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 148, 132, 0.12);
}
.gender-group { display: flex; gap: 10px; padding-top: 4px; }
.gender-btn {
    flex: 1; padding: 12px 14px; background: var(--field);
    border: 1.5px solid transparent; border-radius: 13px; color: var(--text-sub);
    font-family: inherit; font-size: 0.95em; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s;
}
.gender-btn .gender-icon { font-size: 1.15em; }
.gender-btn:hover { color: var(--text); }
.gender-btn.active {
    color: #fff; border-color: transparent;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    box-shadow: 0 6px 16px rgba(79, 148, 132, 0.32);
}

.btn-submit {
    width: 100%; padding: 15px;
    background: linear-gradient(135deg, var(--primary-deep), var(--primary-soft));
    border: none; border-radius: 15px; color: #fff; font-family: inherit;
    font-size: 1.08em; font-weight: 700; letter-spacing: 4px; text-indent: 4px;
    cursor: pointer; margin-top: 10px; transition: transform 0.18s, box-shadow 0.18s;
    box-shadow: 0 10px 24px rgba(79, 148, 132, 0.3);
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(79, 148, 132, 0.4); }
.btn-submit:active { transform: translateY(0); }

.result-section { display: none; }
.result-section.visible { display: block; animation: fadeIn 0.45s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== 八字排盘（专业表） ==================== */
.bazi-chart { padding: 20px 12px; }
.bazi-chart h2 { justify-content: center; }

.paipan-scroll { overflow-x: auto; margin: 0 -4px; }
.paipan {
    display: grid;
    grid-template-columns: 36px repeat(var(--pp-cols, 7), minmax(0, 1fr));
    min-width: calc(36px + var(--pp-cols, 7) * 52px);
    border-radius: 14px; overflow: hidden;
    border: 1px solid var(--line);
}
.pp-cell {
    padding: 7px 2px; text-align: center;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-bottom: 1px solid var(--line);
}
.pp-rowlabel { color: var(--text-muted); font-size: 0.72em; font-weight: 600; background: var(--field); }
.pp-head { font-size: 0.78em; font-weight: 700; color: var(--text-sub); padding: 9px 2px; background: var(--field); }
.pp-head-sub { display: block; font-size: 0.82em; font-weight: 600; opacity: 0.85; margin-top: 2px; }

/* 大字：天干 / 地支 */
.pp-r-gan .gz, .pp-r-zhi .gz {
    font-family: 'Noto Serif SC', 'KaiTi', serif; font-size: 1.85em; font-weight: 700; line-height: 1.05;
}
.pp-r-star { font-size: 0.8em; }
.pp-star { font-weight: 700; }
.pp-daymaster {
    color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    border-radius: 7px; padding: 1px 8px; font-size: 0.92em;
}
.pp-r-cang { padding: 6px 1px; }
.pp-cang-line { display: flex; align-items: center; gap: 2px; font-size: 0.7em; line-height: 1.7; white-space: nowrap; }
.pp-cang-line .gz { font-family: 'Noto Serif SC', serif; font-weight: 700; font-size: 1.15em; }
.pp-cang-ss { color: var(--text-sub); }
.pp-r-cs .pp-cs { font-size: 0.78em; color: var(--text-sub); }

/* 列高亮：日柱 / 运程列 / 分隔 */
.pp-col-day { background: rgba(79, 148, 132, 0.07); }
.pp-head.pp-col-day { background: rgba(79, 148, 132, 0.14); color: var(--primary-deep); }
.pp-col-accent { background: rgba(176, 144, 90, 0.05); }
.pp-head.pp-col-accent { background: rgba(176, 144, 90, 0.12); color: var(--gold-deep); }
.pp-sep { box-shadow: inset 1px 0 0 var(--line-strong); }

/* 神煞行：每柱纵向堆叠多个神煞名（参考专业排盘） */
.pp-r-ss .pp-cell { justify-content: flex-start; padding: 6px 1px; gap: 1px; }
.pp-ss-line { font-size: 0.66em; line-height: 1.5; color: var(--text-sub); white-space: nowrap; }
.pp-ss-none { font-size: 0.7em; color: var(--line-strong); }

/* 结果区返回栏（输入↔结果单屏切换）+ 运程提示 */
.result-topbar { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.btn-back, .btn-print {
    padding: 8px 16px; border: 1.5px solid var(--line); background: var(--card);
    border-radius: 999px; color: var(--text-sub); font-family: inherit; font-size: 0.85em;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-back:hover, .btn-print:hover { color: var(--primary-deep); border-color: var(--primary); }
.btn-print { margin-left: auto; }   /* 推到右侧 */

/* ===== 导出 / 打印（浏览器打印或另存为 PDF）：只留排盘+大运+分析，三栏铺平、去交互控件 ===== */
@media print {
    .user-bar, #history-panel, #input-section, .result-tabs, .result-topbar,
    .btn-analyze, .btn-save, .btn-close-detail, .save-action, .fortune-action,
    #hepan-panel, .followup-input-row, .progress-section, #token-counter,
    .ai-action, .ai-intro, .fortune-hint, .yun-hint, .hepan-hint,
    .error-msg, .save-msg { display: none !important; }

    html, body { background: #fff !important; color: #000 !important; }
    .container { max-width: none !important; margin: 0 !important; padding: 0 !important; }
    .result-section { display: block !important; }
    .result-grid { display: block !important; }            /* 三栏改纵向铺开 */
    .result-col {
        display: block !important; position: static !important;
        max-height: none !important; overflow: visible !important; width: 100% !important;
    }
    #yun-chart-card { display: block !important; }          /* 宽屏被隐藏的运程表，打印时也带上 */
    .paipan-scroll { overflow: visible !important; }
    .bazi-chart, .dayun-section, .ai-section, .final-analysis, .followup-section {
        box-shadow: none !important; background: #fff !important; border: 1px solid #ddd !important;
    }
    .bazi-chart { break-inside: avoid; }                    /* 排盘表尽量不跨页断开 */
    a { color: #000 !important; text-decoration: none !important; }
}
.yun-hint { font-size: 0.76em; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }

.bazi-quick-info {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
    margin-top: 16px; padding: 13px 16px; background: var(--field);
    border-radius: 14px; font-size: 0.9em;
}
.bazi-quick-info strong { color: var(--primary-deep); font-size: 1.05em; }

.wx-bars { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wx-bars span { font-size: 0.8em; padding: 3px 9px; border-radius: 8px; font-weight: 700; }
.wx-mu { background: rgba(37, 163, 90, 0.13); color: var(--wx-mu); }
.wx-huo { background: rgba(232, 81, 58, 0.13); color: var(--wx-huo); }
.wx-tu { background: rgba(122, 74, 30, 0.13); color: var(--wx-tu); }
.wx-jin { background: rgba(224, 168, 0, 0.16); color: var(--wx-jin); }
.wx-shui { background: rgba(47, 127, 224, 0.13); color: var(--wx-shui); }

/* 五行配色 — 干支单字 */
.gz-mu { color: var(--wx-mu); }
.gz-huo { color: var(--wx-huo); }
.gz-tu { color: var(--wx-tu); }
.gz-jin { color: var(--wx-jin); }
.gz-shui { color: var(--wx-shui); }
.muted { color: var(--text-muted); font-size: 0.8em; font-weight: 400; }

/* ==================== 大运 / 流年 ==================== */
.dayun-section { padding: 18px; }
.dayun-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin: 6px 0; }
.dayun-item {
    background: var(--card-soft); border: 1px solid var(--line); border-radius: 11px;
    padding: 8px 4px; text-align: center; cursor: pointer; transition: all 0.18s;
}
.dayun-item:hover { border-color: var(--primary-soft); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.dayun-item.current {
    border-color: transparent; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-soft));
    box-shadow: 0 8px 18px rgba(79, 148, 132, 0.32);
}
.dayun-item.current .gz, .dayun-item.current .dayun-age { color: #fff !important; }
.dayun-item .dayun-ganzhi { font-family: 'Noto Serif SC', serif; font-size: 1.2em; font-weight: 700; line-height: 1.16; }
.dayun-item .dayun-ganzhi .gz { display: block; }
.dayun-item .dayun-age { font-size: 0.72em; color: var(--text-muted); margin-top: 5px; }

.dayun-detail {
    display: none; margin-top: 12px; padding: 16px; background: var(--field);
    border-radius: 16px;
}
.dayun-detail.visible { display: block; animation: fadeIn 0.3s ease; }
.dayun-detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.dayun-detail-header span { color: var(--primary-deep); font-size: 0.95em; font-weight: 700; }
.btn-close-detail { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1em; padding: 2px 8px; border-radius: 8px; }
.btn-close-detail:hover { color: var(--text); background: rgba(79, 148, 132, 0.1); }

.dayun-years { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.dayun-year-item {
    padding: 7px 4px; text-align: center; font-size: 0.78em; border-radius: 10px;
    background: #fff; border: 1px solid var(--line); cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.dayun-year-item:hover { border-color: var(--primary-soft); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.dayun-year-item .dy-year { display: block; color: var(--text-muted); font-size: 0.82em; margin-bottom: 3px; }
.dy-gz { display: block; }
.dy-gz .gz { display: block; font-family: 'Noto Serif SC', serif; font-size: 1.05em; font-weight: 700; line-height: 1.16; }
.dayun-year-item.highlight { background: linear-gradient(135deg, rgba(79, 148, 132, 0.12), rgba(176, 144, 90, 0.1)); border-color: var(--line-strong); }
/* 选中态（驱动排盘表的格子） */
.dayun-year-item.sel { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 148, 132, 0.28); }
.dayun-item.sel { box-shadow: 0 0 0 2px var(--primary); }

/* 流日：按日常月历排（周日…周六 7 列，公历日号 + 干支） */
/* 用 #liuri-list（ID 高优先级）锁死 7 列——否则下方 .liuri-grid 的 auto-fill 规则会盖掉它、
   导致日号与周几表头错位（星期对不上）。#liushi-list(流时12时辰) 仍走 .liuri-grid 的 auto-fill。 */
#liuri-list { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.liuri-grid .liuri-wk { text-align: center; font-size: 0.72em; font-weight: 700; color: var(--text-muted); padding: 2px 0 3px; }
.liuri-grid .liuri-pad { visibility: hidden; }
.liuri-cell { padding: 5px 2px; }
.liuri-cell .dy-year { color: var(--text); font-size: 0.92em; font-weight: 700; margin-bottom: 1px; }
.liuri-cell .dy-gz .gz { font-size: 0.9em; line-height: 1.1; }
/* 跨节气月（月柱切换）当天：顶部加色条 + 小标签「交X月」 */
.liuri-cell.jie-day { box-shadow: inset 0 2px 0 var(--primary); }
.liuri-cell .liuri-jie { display: block; margin-top: 2px; font-size: 0.6em; line-height: 1.2; white-space: nowrap;
    color: #fff; background: var(--primary); border-radius: 3px; padding: 0 2px; }

/* 下钻：流年 → 流月 → 流日 */
.drill-level { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.drill-title { font-size: 0.85em; color: var(--primary-deep); font-weight: 700; margin-bottom: 10px; }
.liuri-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }

.liunian-info {
    display: flex; gap: 10px; flex-wrap: wrap; padding: 14px; background: var(--field);
    border-radius: 14px; margin-top: 10px;
}
.liunian-item { flex: 1; min-width: 84px; text-align: center; font-size: 0.82em; }
.liunian-item .label { color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.liunian-item .value { font-family: 'Noto Serif SC', serif; font-size: 1.18em; color: var(--primary-deep); font-weight: 700; }

/* ==================== AI 区 ==================== */
.ai-section { padding: 24px 22px; text-align: center; }
.ai-section h2 { justify-content: center; }
.api-config { display: none !important; }

.ai-intro {
    color: var(--text-sub); font-size: 0.88em; line-height: 1.7;
    max-width: 360px; margin: 0 auto 20px;
}
.ai-action { text-align: center; }

.btn-analyze {
    padding: 15px 56px;
    background: linear-gradient(135deg, var(--primary-deep), var(--primary-soft));
    border: none; border-radius: 999px; color: #fff; font-family: inherit;
    font-size: 1.08em; font-weight: 700; letter-spacing: 3px; cursor: pointer;
    box-shadow: 0 10px 26px rgba(79, 148, 132, 0.36); transition: transform 0.18s, box-shadow 0.18s;
}
.btn-analyze:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(79, 148, 132, 0.46); }
.btn-analyze:active:not(:disabled) { transform: translateY(0); }
.btn-analyze:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* token 计数 */
.token-counter {
    display: none; margin: 16px auto 0; width: fit-content; max-width: 100%;
    font-size: 0.8em; color: var(--text-sub);
    background: var(--field); border-radius: 999px; padding: 7px 16px;
}
.token-counter.visible { display: block; animation: fadeIn 0.3s ease; }
.token-counter strong { color: var(--primary-deep); font-size: 1.05em; }
.token-counter .tk-sub { color: var(--text-muted); }

/* 进度条 */
.progress-section { display: none; margin: 18px 0 4px; }
.progress-section.visible { display: block; }
.progress-bar-bg { height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-bar-fill {
    height: 100%; width: 5%; border-radius: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-soft));
    transition: width 0.5s ease;
}
.progress-text { font-size: 0.82em; color: var(--text-sub); text-align: center; margin-top: 9px; }
.progress-actions { text-align: center; margin-top: 8px; }
.cancel-analyze-btn {
    display: none; cursor: pointer;
    font-size: 0.8em; color: var(--text-sub);
    background: transparent; border: 1px solid var(--line);
    border-radius: 6px; padding: 4px 14px;
    transition: color 0.15s, border-color 0.15s;
}
.cancel-analyze-btn.visible { display: inline-block; }
.cancel-analyze-btn:hover { color: #c0392b; border-color: #c0392b; }

/* 报告 */
.final-analysis {
    display: none; margin-top: 18px; padding: 22px; text-align: left;
    background: var(--card-soft); border: 1px solid var(--line); border-radius: 16px;
}
.final-analysis.visible { display: block; animation: fadeIn 0.45s ease; }
.final-analysis h3 { color: var(--primary-deep); font-size: 1.1em; margin-bottom: 16px; text-align: center; font-weight: 700; letter-spacing: 1px; }
.analysis-content { font-size: 0.92em; line-height: 1.95; color: var(--text); }
.analysis-content strong { color: var(--primary-deep); font-weight: 700; }
.analysis-content h4 {
    color: var(--text); font-size: 1.04em; margin: 18px 0 8px; font-weight: 700;
    padding-left: 11px; border-left: 4px solid var(--primary); border-radius: 2px;
}
.analysis-content hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.analysis-content table {
    width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.86em;
    border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.analysis-content th { background: linear-gradient(135deg, var(--primary), var(--primary-soft)); color: #fff; padding: 9px 11px; text-align: left; font-weight: 600; }
.analysis-content td { padding: 8px 11px; border-bottom: 1px solid var(--line); background: #fff; }
.analysis-content tr:last-child td { border-bottom: none; }
.analysis-content tr:hover td { background: var(--card-soft); }

/* 追问 */
.followup-section { display: none; margin-top: 18px; text-align: left; }
.followup-section.visible { display: block; animation: fadeIn 0.4s ease; }
.followup-section h3 { color: var(--text); font-size: 1em; margin-bottom: 12px; font-weight: 700; }
.followup-list { margin-bottom: 12px; }
.followup-qa { border: 1px solid var(--line); border-radius: 15px; margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.followup-question {
    padding: 13px 16px; background: linear-gradient(135deg, rgba(79, 148, 132, 0.1), rgba(176, 144, 90, 0.08));
    font-size: 0.9em; color: var(--primary-deep); font-weight: 700;
}
.followup-answer { padding: 14px 16px; font-size: 0.9em; line-height: 1.9; color: var(--text); background: #fff; }
.followup-answer strong { color: var(--primary-deep); }
.followup-pending { display: flex; align-items: center; gap: 10px; color: var(--text-sub); font-size: 0.92em; }
.fu-err { color: var(--wx-huo); }
.spinner {
    width: 16px; height: 16px; flex: none;
    border: 2px solid var(--line-strong); border-top-color: var(--primary);
    border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.followup-input-row { display: flex; gap: 10px; align-items: stretch; }
.followup-input-row input {
    flex: 1 1 auto; min-width: 0; padding: 13px 16px; background: var(--field); border: 1.5px solid transparent;
    border-radius: 999px; color: var(--text); font-family: inherit; font-size: 0.92em; transition: all 0.2s;
}
.followup-input-row input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 148, 132, 0.12); }
.followup-input-row .btn-analyze { flex: 0 0 auto; padding: 13px 28px; font-size: 0.95em; letter-spacing: 1px; white-space: nowrap; }

.error-msg {
    padding: 12px 16px; background: rgba(232, 81, 58, 0.08);
    border: 1px solid rgba(232, 81, 58, 0.22); border-radius: 13px;
    color: var(--wx-huo); margin: 12px 0; display: none; font-size: 0.88em;
}
.error-msg.visible { display: block; animation: fadeIn 0.25s ease; }

/* 调试日志 */
.debug-log { display: none; margin-top: 16px; padding: 16px; background: #f4f1fb; border: 1px solid var(--line); border-radius: 14px; text-align: left; }
.debug-log.visible { display: block; }
.debug-log-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.debug-log-header h3 { color: var(--text-muted); font-size: 0.86em; font-weight: 600; }
.btn-copy-log {
    padding: 6px 13px; background: #fff; border: 1px solid var(--line); border-radius: 9px;
    color: var(--text-sub); font-family: inherit; font-size: 0.78em; cursor: pointer; transition: all 0.18s;
}
.btn-copy-log:hover { border-color: var(--primary); color: var(--primary); }
.debug-log-content {
    max-height: 380px; overflow-y: auto; font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.72em; line-height: 1.5; color: var(--text-sub); white-space: pre-wrap;
    padding: 12px; background: #fff; border-radius: 10px;
}

footer { color: var(--text-muted); }

/* ==================== 用户栏 / 历史命盘 / 登录弹窗 ==================== */
.user-bar {
    position: absolute; top: 14px; right: 18px; z-index: 30;
    display: flex; align-items: center; gap: 8px;
}
.ub-btn {
    padding: 7px 14px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.14);
    border-radius: 999px; color: #fff; font-family: inherit; font-size: 0.82em; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
}
.ub-btn:hover { background: rgba(255, 255, 255, 0.26); }
.ub-btn.primary { background: rgba(255, 255, 255, 0.92); color: var(--primary-deep); border-color: transparent; }
.ub-btn.primary:hover { background: #fff; }
.ub-balance {
    padding: 7px 14px; background: rgba(0, 0, 0, 0.18); border-radius: 999px;
    color: #ffe7a6; font-size: 0.82em; font-weight: 700;
}
.ub-menu-wrap { position: relative; }
.ub-menu {
    /* fixed：脱离 .header 的 overflow:hidden 裁剪（同 history-panel），否则下方菜单项(退出登录等)被圆角头部裁掉 */
    position: fixed; right: 18px; top: 54px; min-width: 130px;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden; z-index: 96;
}
.ub-menu button {
    padding: 10px 16px; border: none; background: none; color: var(--text);
    font-family: inherit; font-size: 0.88em; text-align: left; cursor: pointer;
}
.ub-menu button:hover { background: var(--field); }

.history-panel {
    /* fixed：脱离 header 的 overflow:hidden 裁剪，并压过三栏 sticky 列；高度封顶，超出内部滚动 */
    position: fixed; top: 64px; right: 18px; z-index: 95;
    width: 340px; max-width: calc(100vw - 36px);
    max-height: min(62vh, 560px); overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff; border: 1px solid var(--line); border-radius: 16px;
    box-shadow: var(--shadow-lg); padding: 8px; text-align: left;
}
.hist-item {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    border-radius: 10px; cursor: pointer; color: var(--text);
}
.hist-item:hover { background: var(--field); }
.hist-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hist-title { font-size: 0.86em; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-sub { font-size: 0.72em; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-title .hist-na { color: var(--text-muted); font-style: normal; font-weight: 400; }
.hist-date { font-size: 0.72em; color: var(--text-muted); }
.hist-del {
    border: none; background: none; color: var(--text-muted); cursor: pointer;
    font-size: 0.85em; padding: 3px 7px; border-radius: 7px;
}
.hist-del:hover { color: var(--wx-huo); background: rgba(232, 81, 58, 0.1); }
.hist-empty { padding: 18px 14px; color: var(--text-muted); font-size: 0.85em; text-align: center; }

.modal-mask {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(30, 22, 60, 0.45); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
    position: relative; width: 380px; max-width: 100%;
    background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg);
    padding: 28px 26px 24px; animation: fadeIn 0.25s ease;
}
.modal-close {
    position: absolute; top: 12px; right: 14px; border: none; background: none;
    color: var(--text-muted); font-size: 1.1em; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: var(--field); }
.modal h3 { color: var(--text); font-size: 1.15em; margin-bottom: 16px; text-align: center; }
.af { margin-bottom: 12px; }
.af label { display: block; color: var(--text-sub); font-size: 0.8em; font-weight: 600; margin-bottom: 5px; }
.af input {
    width: 100%; padding: 11px 14px; background: var(--field); border: 1.5px solid transparent;
    border-radius: 12px; color: var(--text); font-family: inherit; font-size: 0.95em; transition: all 0.2s;
}
.af input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 148, 132, 0.12); }
.af-tip { font-size: 0.82em; color: var(--text-sub); margin-bottom: 12px; line-height: 1.6; }
.cap-row { display: flex; gap: 8px; align-items: center; }
.cap-row input { flex: 1; min-width: 0; }
.cap-img {
    flex: none; width: 160px; height: 48px; border: 1.5px solid var(--field);
    border-radius: 12px; cursor: pointer; background: #f7f3e9; user-select: none;
}
.cap-img:hover { border-color: var(--primary); }
.af-msg {
    margin: 10px 0; padding: 9px 13px; border-radius: 11px; font-size: 0.84em;
    background: rgba(232, 81, 58, 0.08); border: 1px solid rgba(232, 81, 58, 0.22); color: var(--wx-huo);
}
.af-msg.ok { background: rgba(37, 163, 90, 0.09); border-color: rgba(37, 163, 90, 0.28); color: var(--wx-mu); }
.af-submit { width: 100%; margin-top: 4px; }
.af-links { display: flex; justify-content: space-between; margin-top: 14px; }
.af-links a { color: var(--primary); font-size: 0.84em; text-decoration: none; }
.af-links a:hover { text-decoration: underline; }
.af-links a:only-child { margin-left: auto; }

@media (max-width: 540px) {
    .user-bar { position: static; justify-content: flex-end; margin-bottom: 10px; }
    .history-panel { right: 8px; top: 64px; max-height: min(62vh, 480px); }
    .ub-menu { right: 8px; top: 54px; }
    .followup-input-row { gap: 8px; }
    .followup-input-row .btn-analyze { padding: 13px 18px; letter-spacing: 0; }
}

/* ==================== AI 免责声明（追加在每段分析结果末尾） ==================== */
.ai-disclaimer {
    margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line);
    font-size: 0.74em; line-height: 1.6; color: var(--text-muted);
}
.ai-disclaimer::before { content: 'ⓘ '; }

/* ==================== 合盘（与指定八字两盘互参） ==================== */
.hepan-panel {
    margin-top: 12px; padding: 14px; background: var(--card-soft);
    border: 1px dashed var(--line-strong); border-radius: 14px;
    display: flex; flex-direction: column; gap: 10px; text-align: left;
}
.hepan-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hepan-row label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.8em; color: var(--text-sub); font-weight: 600;
}
.hepan-row select {
    padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px;
    font-family: inherit; font-size: 0.95em; color: var(--text); background: #fff; cursor: pointer;
}
.hepan-row select:focus { outline: none; border-color: var(--primary); }
#hepan-btn { padding: 9px 22px; font-size: 0.88em; }
.hepan-hint { font-size: 0.74em; color: var(--text-muted); }

/* ==================== 保存命盘（备注 + 按钮） ==================== */
.save-action {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.save-action input {
    flex: 1 1 200px; min-width: 0; padding: 9px 13px; background: var(--field);
    border: 1.5px solid transparent; border-radius: 11px; color: var(--text);
    font-family: inherit; font-size: 0.85em; transition: all 0.2s;
}
.save-action input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79, 148, 132, 0.12); }
.btn-save {
    padding: 9px 18px; border: 1px solid var(--line-strong); background: #fff;
    border-radius: 11px; color: var(--primary-deep); font-family: inherit; font-size: 0.86em;
    font-weight: 600; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-save:hover { border-color: var(--primary); background: var(--card-soft); }
.btn-save:disabled { opacity: 0.55; cursor: default; }
.save-msg { flex: 1 1 100%; font-size: 0.78em; color: var(--wx-huo); min-height: 1em; }
.save-msg.ok { color: var(--wx-mu); }

/* ==================== 六十甲子点击表（八字输入模式） ==================== */
.gz-picker { margin-bottom: 14px; }
.gzp-tabs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.gzp-tab {
    padding: 7px 14px; border: 1.5px solid var(--line); background: var(--field);
    border-radius: 10px; color: var(--text-sub); font-family: inherit; font-size: 0.86em;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.gzp-tab b { font-family: 'Noto Serif SC', serif; font-size: 1.05em; margin-left: 2px; color: var(--text); }
.gzp-tab.active {
    border-color: var(--primary); background: rgba(79, 148, 132, 0.1); color: var(--primary-deep);
}
.gzp-hint { font-size: 0.78em; color: var(--text-muted); margin-left: 4px; }
.gz-table {
    display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px;
}
.gz-cell {
    text-align: center; padding: 8px 2px; background: var(--field);
    border: 1.5px solid transparent; border-radius: 9px; cursor: pointer;
    font-family: 'Noto Serif SC', serif; font-weight: 700; font-size: 0.95em;
    letter-spacing: 1px; transition: all 0.15s; user-select: none;
}
.gz-cell:hover { border-color: var(--primary-soft); background: #fff; }
.gz-cell.sel { border-color: var(--primary); background: rgba(79, 148, 132, 0.12); box-shadow: 0 0 0 3px rgba(79, 148, 132, 0.1); }
.gz-cell.dis { opacity: 0.22; cursor: default; pointer-events: none; }
.gzp-foot { display: flex; align-items: flex-end; gap: 12px; margin-top: 12px; }
@media (max-width: 700px) {
    .gz-table { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ==================== 推运（按排盘表所选运程层层分析） ==================== */
.fortune-action {
    display: flex; gap: 8px; justify-content: center; align-items: center;
    margin-top: 12px; flex-wrap: wrap;
}
.fortune-action select {
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
    font-family: inherit; font-size: 0.85em; color: var(--text); background: var(--field);
    cursor: pointer;
}
.fortune-action select:focus { outline: none; border-color: var(--primary); }
#fortune-btn { padding: 9px 20px; font-size: 0.9em; }
.fortune-hint { width: 100%; text-align: center; color: var(--text-muted); font-size: 0.74em; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(79, 148, 132, 0.28); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(79, 148, 132, 0.48); }

/* 响应式 */
@media (max-width: 540px) {
    .header { padding: 38px 20px 32px; border-radius: 0 0 24px 24px; }
    .header h1 { font-size: 1.7em; letter-spacing: 6px; }
    .container { padding: 14px 12px 40px; }
    .form-section, .bazi-chart, .dayun-section, .ai-section { padding: 18px; }
    .form-group { min-width: calc(50% - 6px); }
    .bazi-grid { gap: 7px; }
    .bazi-pillar { padding: 12px 4px; }
    .pillar-ganzhi { font-size: 1.7em; }
    .btn-analyze { padding: 14px 44px; }
}
