/* 奇门统一页面 */
/* 主题变量：默认浅色（即原配色）；<html data-theme="dark"> 时覆盖为深色 */
:root {
  --qm-bg: #071c3c; --qm-card: #fff; --qm-text: #1f2933; --qm-muted: #6b7280; --qm-faint: #9ca3af;
  --qm-line: #9ca3af; --qm-grid-frame: #FFF; --qm-center: #f9fafb; --qm-sub: #374151; --qm-split: #f0f1f3;
  --qm-tag-bg: #f3f4f6; --qm-input-bg: #fff; --qm-input-line: #d1d5db;
  --qm-god: #6b2a08; --qm-star: #1a5e40; --qm-door: #1a3e6e; --qm-hidden: #535353; --qm-earth: #4b5563; --qm-timege: #dc2626; --qm-ge-good: #16a34a;
  --qm-mark-ring: #fff; --qm-shadow: rgba(0,0,0,.08);
}
[data-theme="dark"] {
  --qm-bg: #0f172a; --qm-card: #1e293b; --qm-text: #e2e8f0; --qm-muted: #94a3b8; --qm-faint: #64748b;
  --qm-line: #475569; --qm-grid-frame: #1e293b; --qm-center: #172033; --qm-sub: #cbd5e1; --qm-split: #334155;
  --qm-tag-bg: #334155; --qm-input-bg: #0f172a; --qm-input-line: #475569;
  --qm-god: #f0a46b; --qm-star: #5fd3a0; --qm-door: #7fb0ff; --qm-hidden: #a3a3a3; --qm-earth: #cbd5e1; --qm-timege: #f87171; --qm-ge-good: #4ade80;
  --qm-mark-ring: #1e293b; --qm-shadow: rgba(0,0,0,.4);
  color-scheme: dark;
}
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--qm-bg); color: var(--qm-text); }
/* 两栏：电脑端（≥1010px，与 v1/qimen.php 同断点）左 35% 时间·排盘·信息·记录，右 65% 分析设置·AI 对话；窄屏上下排、左栏在前 */
.qm-wrap { max-width: 1100px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 0 16px; box-sizing: border-box; }
.qm-left, .qm-right { min-width: 0; }
@media (min-width: 1010px) {
  .qm-wrap { flex-direction: row; align-items: flex-start; }
  .qm-left { flex: 0 0 calc(41% - 8px); }
  .qm-right { flex: 1 1 0; position: sticky; top: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
  .qm-right.qm-chat-on #chatPanel { flex: 1 1 auto; min-height: 420px; display: flex; flex-direction: column; margin-bottom: 14px; }
  .qm-right.qm-chat-on #chatPanel .ai-chat-panel-wrapper { flex: 1 1 auto; min-height: 0; }
  .qm-right.qm-chat-on #chatPanel .chat-messages-container { flex: 1 1 auto; height: 0; max-height: none; min-height: 370px; }
  /* 左栏约 385px：九宫收紧 */
  .qm-left .qm-cell { min-height: 104px; font-size: 13px; padding: 12px 4px 4px; line-height: 1.5; }
  .qm-left .qm-heaven, .qm-left .qm-earth { font-size: 14px; }
  .qm-left .qm-hidden, .qm-left .qm-pillars, .qm-left .qm-name { font-size: 11px; }
  .qm-left .qm-zhi { margin-left: 2px; font-size: 11px; }
  .qm-left .qm-timege { font-size: 12px; }
  .qm-left .qm-tag, .qm-left .qm-badge { font-size: 10px; padding: 0 3px; line-height: 15px; }
  .qm-left .qm-legend { gap: 4px; }
}
#chatPanel { margin-bottom: 14px; }
#chatPanel .ai-chat-panel-wrapper { box-shadow: 0 1px 3px var(--qm-shadow); }
.qm-card { background: var(--qm-card); border-radius: 8px; padding: 14px; margin-bottom: 14px; box-shadow: 0 1px 3px var(--qm-shadow); }
.qm-form-card { position: relative; padding-right: 52px; }
.qm-theme-btn { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--qm-input-line); background: var(--qm-card); color: var(--qm-text); font-size: 16px; line-height: 1; cursor: pointer; }
.qm-theme-btn:hover { border-color: #2563eb; }

/* 表单：电脑端两个按钮一行两列，手机端各占一行 */
.qm-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.qm-field { display: flex; align-items: center; gap: 6px; }
.qm-form label { font-size: 14px; white-space: nowrap; } .qm-form select, .qm-form input { padding: 6px 8px; font-size: 14px; background: var(--qm-input-bg); color: var(--qm-text); border: 1px solid var(--qm-input-line); border-radius: 4px; }
.qm-actions { display: grid; grid-template-columns: repeat(2, auto); gap: 8px; width: 99%}
.qm-btn { padding: 7px 16px; border: 0; border-radius: 6px; background: #2563eb; color: #fff; font-size: 14px; cursor: pointer; }
.qm-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.qm-error { color: #b91c1c; font-size: 14px; min-height: 20px; }
/* 排法或时间改了还没重新排盘：开始排盘下面的提示条 + 按钮高亮呼吸 */
.qm-stale { margin-top: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.5; color: #92400e; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 6px; }
.qm-stale[hidden] { display: none; }
.qm-btn.qm-btn-stale { background: #ea580c; animation: qm-stale-pulse 1.6s ease-in-out infinite; }
@keyframes qm-stale-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(234,88,12,.5); } 60% { box-shadow: 0 0 0 6px rgba(234,88,12,0); } }
@media (prefers-reduced-motion: reduce) { .qm-btn.qm-btn-stale { animation: none; } }
[data-theme="dark"] .qm-stale { color: #fde68a; background: #3a2e0c; border-color: #a16207; }
#qm-info { font-size: 14px; line-height: 1.8; }
/* 排盘信息 / 排盘记录 tab 卡片：默认「排盘信息」；.qm-folded 时只留 tab 栏（手机端默认折叠，电脑端默认展开） */
.qm-tabs-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--qm-split); margin: -4px 0 0; }
.qm-tabs { display: flex; gap: 4px; }
.qm-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px 8px; margin-bottom: -1px; font-size: 14px; font-weight: 600; color: var(--qm-muted); cursor: pointer; }
.qm-tab:hover { color: var(--qm-text); }
.qm-tab[aria-selected="true"] { color: #2563eb; border-bottom-color: #2563eb; }
[data-theme="dark"] .qm-tab[aria-selected="true"] { color: #93c5fd; border-bottom-color: #60a5fa; }
.qm-tabs-fold { flex: none; background: none; border: 0; padding: 4px 6px; cursor: pointer; }
.qm-fold-arrow { font-size: 11px; color: var(--qm-faint); }
.qm-tabs-body { padding-top: 10px; }
.qm-tab-panel[hidden] { display: none; }
.qm-tabs-card.qm-folded .qm-tabs-body { display: none; }
.qm-tabs-card.qm-folded .qm-tabs-bar { border-bottom-color: transparent; }
.qm-h-count { font-weight: normal; color: var(--qm-faint); }
.qm-h-note-row { margin: 0 0 6px; }
.qm-h-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.qm-h-no { flex: none; min-width: 20px; height: 20px; padding: 0 4px; box-sizing: border-box; border-radius: 10px; background: var(--qm-tag-bg); color: var(--qm-sub); font-size: 11px; line-height: 20px; text-align: center; font-weight: 600; }
@media (max-width: 1009px) {
  .qm-tabs-card.qm-folded { padding-top: 10px; padding-bottom: 6px; }
  #chatPanel .chat-messages-container { min-height: 370px; } /* 窄屏对话区最低 300px */
}
.qm-ai-edit-tip { margin: 6px 0 4px; padding: 6px 10px; font-size: 12px; line-height: 1.6; color: #92400e; background: #fffbeb; border: 1px solid #fcd34d; border-radius: 6px; }
.qm-ai-edit-tip[hidden] { display: none; }
[data-theme="dark"] .qm-ai-edit-tip { color: #fde68a; background: #3a2e0c; border-color: #a16207; }

/* 九宫格 */
.qm-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid var(--qm-grid-frame); margin-top: 10px; }
.qm-cell { border: 1px solid var(--qm-line); min-height: 118px; padding: 12px 6px 6px; font-size: 15px; line-height: 1.6; position: relative;
           display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; column-gap: 4px; }
.qm-cell.qm-center { background: var(--qm-center); }
.qm-center-info { width: 100%; text-align: center; line-height: 1.5; }
.qm-pillars { font-size: 12px; color: var(--qm-sub); letter-spacing: 1px; }
.qm-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 4px; flex-wrap: wrap; }
.qm-name { font-size: 12px; color: var(--qm-muted); }
.qm-tags { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.qm-tag { font-size: 11px; line-height: 16px; padding: 0 4px; border-radius: 4px; background: var(--qm-tag-bg); color: var(--qm-sub); }

/* 左侧：神、星、门，左对齐 */
.qm-l { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 16px;}
.qm-god { color: var(--qm-god); } .qm-star { color: var(--qm-star); } .qm-door { color: var(--qm-door); }

/* 右侧：暗干在上，天盘干、地盘干在右下 */
.qm-r { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; text-align: right; }
.qm-hidden { color: var(--qm-hidden); font-size: 12px; } /* 暗干 */
.qm-timege { color: var(--qm-timege); } /* 日时关系格局：红色粗体 */
/* 中宫左栏：日时神煞小字，吉灰凶红；左栏原本为空，放这里不改格子高度 */
.qm-timesha-box { align-items: flex-start; justify-content: flex-end; gap: 1px; font-size: 12px; line-height: 1.4; }
.qm-timesha { color: var(--qm-muted); white-space: nowrap; }
.qm-timesha-bad { color: var(--qm-timege); }
.qm-left .qm-timesha-box { font-size: 11px; }
.qm-heaven { font-weight: 600; font-size: 16px;} .qm-earth { color: var(--qm-earth); font-size: 16px;}

/* 四害、空亡：直接给门、天盘干、宫名铺小圆角底色，白字 */
.qm-hl { display: inline-block; padding: 0 3px; border-radius: 4px; color: #fff !important; font-weight: 600;}
.qm-h-po { background: #e74c3c; } .qm-h-xing { background: #e67e22; } .qm-h-mu { background: #7f8c8d; } .qm-h-muxing { background: #9b59b6; }
.qm-heaven .qm-sr + .qm-hl, .qm-earth .qm-sr + .qm-hl { margin-left: 2px; }
.qm-earth .qm-hl { font-weight: normal; line-height: 19px;} /* 地盘干不加粗 */
.qm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* 只给读屏 */
.qm-zhi { margin-left: 4px; font-size: 12px; color: var(--qm-faint); }
/* 空亡、马星：宫名行右侧小标签，白字 */
.qm-badge { display: inline-block; padding: 0 5px; border-radius: 4px; font-size: 12px; line-height: 18px; font-weight: 700; color: #fff; }
.qm-b-ma { background: #dc2626; } .qm-b-kong { background: #e2385e; }
.qm-foot { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.qm-legend { font-size: 12px; color: var(--qm-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qm-btn-sm { flex: none; padding: 3px 9px; border: 1px solid #2563eb; border-radius: 5px; background: var(--qm-card); color: #2563eb; font-size: 12px; cursor: pointer; }
[data-theme="dark"] .qm-btn-sm { color: #93c5fd; border-color: #60a5fa; }
[data-theme="dark"] .qm-h-del { color: #f87171; border-color: #f87171; }
.qm-btn-sm:disabled { border-color: #d1d5db; color: #9ca3af; cursor: not-allowed; }
.qm-foot-ops { flex: none; display: flex; gap: 6px; }
/* 「旺衰」开关：按下（aria-pressed=true）为实心 */
.qm-state-toggle[aria-pressed="true"] { background: #2563eb; color: #fff; }
[data-theme="dark"] .qm-state-toggle[aria-pressed="true"] { background: #2563eb; color: #fff; border-color: #2563eb; }

/* 旺衰标签（干的十二长生、星门的月令旺衰）：灰色小字，绝对定位浮在文字旁边，不挤占格子；开关关闭时隐藏 */
.qm-st { display: none; position: absolute; flex-direction: row; align-items: center; font-size: 10px; line-height: 11px; font-weight: normal; color:#e2385e; pointer-events: auto; white-space: nowrap; }
.qm-show-state .qm-st { display: flex; z-index: 3;
            text-shadow: 
                -1px -1px 0 white,
                1px -1px 0 white,
                -1px 1px 0 white,
                1px 1px 0 white;
        }
.qm-stem { position: relative; display: inline-block; line-height: 1.3; } /* 盒子贴字：标签紧贴字的上下，不按行距留白定位；父行行高不变（去掉会让地盘标签掉出格子底边） */
.qm-earth .qm-stem, .qm-heaven .qm-stem {
    margin-left: 3px;
}
.qm-heaven, .qm-earth { position: relative; }
.qm-st-up { left: 50%; bottom: 100%; transform: translateX(-50%); } /* 天盘：浮在上方 */
.qm-st-down { left: 50%; top: calc(100% - 2px); transform: translateX(-50%); } /* 地盘：浮在下方；减去 .qm-stem 行高 1.3 带来的下方留白（约 2px），贴住字而不是行盒，不压格子底边 */
/* 地盘干是格子最底一行，字下方只剩约 8px（格子内边距）：标签行高收成 8px，正好放下、不压格线；
   有四害底色时底色块比字高约 2px（.qm-earth .qm-hl 行高 19px），标签相应上提 */
.qm-st-down { line-height: 8px; }
.qm-hl ~ .qm-st-down { top: calc(100% - 3px); } /* 有四害底色时底色块（行高 19px）再高约 1px */
/* 一行两个干（有寄干）：两字标签（如「死-墓」约 24px）比干宽，居中会互相压住；第一个干的标签向左展开、寄干的向右展开 */
.qm-stem:first-child:not(:last-child) > .qm-st { left: auto; right: 0; transform: none; }
.qm-stem + .qm-stem > .qm-st { left: 0; transform: none; }
.qm-star, .qm-door { position: relative; }

/* 宫位格局（开关「格局」）：格子底部单独一行、横跨两栏，一行两列小字；关闭时不占位，格子高度与原来一样 */
.qm-ge { display: none; grid-column: 1 / -1; grid-template-columns: 1fr 1fr; column-gap: 4px; margin-top: 3px; padding-top: 2px;
         border-top: 1px dashed var(--qm-line); font-size: 11px; line-height: 1.35; color: var(--qm-muted); }
.qm-show-ge .qm-ge { display: grid; }
.qm-show-ge.qm-show-state .qm-ge { margin-top: 9px; } /* 旺衰同开：给地盘干下方的旺衰标签留位 */
.qm-ge-item { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qm-ge-good { color: var(--qm-ge-good); } .qm-ge-bad { color: var(--qm-timege); }
.qm-left .qm-ge { font-size: 10px; }
.qm-st-star, .qm-st-door { right: 100%; top: 50%; transform: translateY(-50%); margin-right: 2px; } /* 星、门：浮在左侧 */

/* 排盘记录（本机） */
.qm-h-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; } .qm-h-note { font-size: 12px; font-weight: normal; color: var(--qm-faint); margin-left: 6px; }
.qm-h-list { list-style: none; margin: 0; padding: 0; }
.qm-h-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--qm-split); font-size: 13px; }
.qm-h-item:first-child { border-top: 0; }
.qm-h-text { color: var(--qm-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qm-h-ops { flex: none; display: flex; gap: 6px; }
.qm-h-del { border-color: #dc2626; color: #dc2626; }
.qm-h-empty { font-size: 13px; color: var(--qm-faint); padding: 4px 0; }
.qm-legend .qm-hl, .qm-legend .qm-badge { font-size: 11px; line-height: 16px; }

/* 日干、时干所在宫：格子上边框正中 */
.qm-marks { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; z-index: 1; }
.qm-mark { width: 20px; height: 20px; border-radius: 50%; font-size: 12px; line-height: 20px; text-align: center; font-weight: 700; color: #fff; box-shadow: 0 0 0 2px var(--qm-mark-ring); }
.qm-mark-ri { background: #9a6b00; } .qm-mark-shi { background: #0f766e; }

/* 访客卡 AI 解盘（qimen-guest.js 注入）：弹窗固定浅色，不随页面主题 */
.qmg-overlay { position: fixed; inset: 0; z-index: 10003; background: rgba(0,0,0,.55); display: flex; justify-content: center; align-items: center; padding: 12px; box-sizing: border-box; }
.qmg-box { background: #fff; color: #1e293b; border-radius: 10px; width: 100%; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.qmg-box-sm { max-width: 400px; } .qmg-box-chat { max-width: 720px; height: 85vh; max-height: 760px; }
.qmg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #1e3a8a; color: #fff; font-weight: 700; font-size: 15px; }
.qmg-head-chat { background: #546e7a; }
.qmg-x { background: none; border: 0; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.qmg-body { padding: 18px 16px 6px; } .qmg-label { font-size: 14px; font-weight: 700; }
.qmg-input { width: 100%; box-sizing: border-box; margin-top: 8px; padding: 10px; font-size: 15px; border: 1px solid #cbd5e1; border-radius: 6px; }
.qmg-error { color: #b91c1c; font-size: 13px; min-height: 20px; margin-top: 6px; }
.qmg-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 16px; }
.qmg-buy { color: #e67e22; font-size: 13px; text-decoration: none; }
.qmg-sub { font-size: 12px; color: #64748b; padding: 6px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.qmg-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; background: #f0f2f5; }
.qmg-msg { margin-bottom: 14px; display: flex; flex-direction: column; }
.qmg-time { text-align: center; font-size: 11px; color: #94a3b8; margin-bottom: 6px; }
.qmg-content { max-width: 82%; padding: 10px 14px; border-radius: 6px; font-size: 14px; line-height: 1.7; word-break: break-word; }
.qmg-ai .qmg-content { align-self: flex-start; background: #fff; border: 1px solid #e2e8f0; }
.qmg-user .qmg-content { align-self: flex-end; background: #95ec69; border: 1px solid #84d95b; white-space: pre-wrap; }
.qmg-hint { font-size: 12px; color: #888; margin-top: 6px; }
.qmg-sep { text-align: center; font-size: 12px; color: #94a3b8; margin: 4px 0 14px; }
.qmg-link { background: none; border: 0; color: #576B95; font-size: 13px; cursor: pointer; }
.qmg-input-bar { display: flex; gap: 8px; align-items: stretch; padding: 10px 12px; border-top: 1px solid #e2e8f0; flex-wrap: wrap; }
.qmg-select { padding: 6px; font-size: 13px; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; color: #1e293b; }
.qmg-textarea { flex: 1 1 240px; min-height: 42px; padding: 8px; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 4px; resize: vertical; }

/* 右栏：分析设置（照 v1/qimen.php 的 AI 设置区） */
.qm-ai-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.qm-ai-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--qm-sub); }
.qm-ai-summary-row[hidden] { display: none; }
.qm-ai-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#qm-ai-body[hidden] { display: none; }
.qm-ai-q-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.qm-ai-q-label-row label { font-size: 13px; color: var(--qm-sub); }
.qm-ai-logout { font-size: 12px; color: #dc2626; text-decoration: none; white-space: nowrap; }
.qm-ai-logout:hover { text-decoration: underline; }
.qm-ai-question { width: 100%; min-height: 76px; margin-top: 6px; padding: 8px 10px; box-sizing: border-box; font-size: 14px; font-family: inherit; resize: vertical;
                  border: 1px solid var(--qm-input-line); border-radius: 6px; background: var(--qm-input-bg); color: var(--qm-text); }
.qm-ai-box { margin-top: 10px; padding: 10px; background: var(--qm-center); border: 1px solid var(--qm-split); border-radius: 8px; }
.qm-ai-master-trigger { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 2px; }
.qm-ai-avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; border: 2px solid var(--qm-split); opacity: .5; filter: grayscale(70%); transition: opacity .3s, filter .3s, border-color .3s; }
.qm-ai-avatar img { width: 100%; height: 100%; object-fit: cover; }
.qm-ai-avatar.qm-ai-avatar-half { opacity: .9; filter: grayscale(20%); }
.qm-ai-avatar.qm-ai-avatar-on { opacity: 1; filter: none; border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
.qm-ai-master-text { flex: 1; font-size: 13px; color: var(--qm-sub); }
.qm-ai-master-hint { font-size: 11px; color: var(--qm-faint); } .qm-ai-master-hint.qm-ai-cancel { color: #dc2626; }
.qm-ai-recommend { flex: none; padding: 4px 10px; font-size: 12px; border-radius: 20px; border: 1px solid #7c3aed; background: var(--qm-card); color: #7c3aed; cursor: pointer; }
.qm-ai-master-panel { max-height: 0; opacity: 0; overflow: hidden; transition: max-height .35s ease, opacity .3s ease; }
.qm-ai-row { display: flex; gap: 8px; margin: 8px 0 4px; }
.qm-ai-row .qm-ai-select { flex: 1; min-width: 0; }
.qm-ai-token-hint { font-size: 11px; color: var(--qm-faint); margin: 0 2px 6px; }
.qm-ai-methods { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; background: var(--qm-tag-bg); border: 1px solid var(--qm-split); border-radius: 6px; }
.qm-ai-pill { padding: 3px 10px; border-radius: 12px; font-size: 12px; border: 1px solid #cbd5e1; background: var(--qm-card); color: var(--qm-sub); cursor: pointer; }
.qm-ai-pill.qm-ai-pill-on { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }
.qm-ai-pill:disabled { opacity: .45; cursor: not-allowed; }
.qm-ai-more { margin-top: 6px; border-top: 1px dashed var(--qm-input-line); padding-top: 6px; }
.qm-ai-more-toggle { display: block; width: 100%; background: none; border: 0; color: var(--qm-faint); font-size: 12px; cursor: pointer; padding: 2px 0; }
.qm-ai-more-panel { display: flex; gap: 8px; padding-top: 8px; }
.qm-ai-more-panel[hidden] { display: none; }
.qm-ai-more-panel .qm-ai-select { flex: 1; min-width: 0; }
.qm-ai-select { padding: 6px 8px; font-size: 13px; border: 1px solid var(--qm-input-line); border-radius: 5px; background: var(--qm-input-bg); color: var(--qm-text); }
.qm-ai-select:disabled { opacity: .55; cursor: not-allowed; }
.qm-ai-mode { margin-top: 10px; padding: 8px; background: var(--qm-center); border-radius: 6px; text-align: center; font-size: 14px; }
.qm-ai-mode-radios { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.qm-ai-mode-radios label { cursor: pointer; }
.qm-ai-mode-tip { font-size: 12px; color: var(--qm-muted); margin: 4px 0 2px; }
.qm-ai-teach { width: 100%; margin-top: 6px; border-color: #f59e0b; }
.qm-ai-selects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.qm-ai-selects .qm-ai-select { flex: 1 1 90px; min-width: 0; }
.qm-ai-start { width: 100%; margin-top: 10px; padding: 9px 16px; font-size: 15px; background: #1e3a8a; }
.qm-ai-guest-box { margin-top: 10px; padding: 12px; background: var(--qm-center); border: 1px solid var(--qm-split); border-radius: 8px; text-align: center; }
.qm-ai-guest-tip { font-size: 13px; color: var(--qm-muted); margin-bottom: 10px; }
.qm-ai-guest-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.qm-ai-guest-actions .qm-btn { flex: 1 1 160px; text-decoration: none; text-align: center; box-sizing: border-box; }
.qm-ai-guest { background: #fff; color: #0284c7; border: 1px solid #0ea5e9; }
.qm-ai-login { background: #1e3a8a; }
.qm-ai-buy { display: inline-block; margin-top: 10px; font-size: 13px; color: #e67e22; text-decoration: none; }
/* 聊天区：系统提示（灰色居中、无按钮）、只读输入框 */
.qm-sys-msg { text-align: center; font-size: 12px; color: #9ca3af; margin: 10px auto; padding: 2px 8px; }
#chat-input.qm-ai-locked { background: #f0f0f0; color: #999; }
/* 页面 toast */
.qm-toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(0,0,0,.75); color: #fff; padding: 8px 18px; border-radius: 20px; font-size: 13px; z-index: 10010; opacity: 0; pointer-events: none; transition: opacity .3s; }
.qm-toast.show { opacity: 1; }

/* 深色主题：平台聊天组件本身写死浅色，这里按 #chatPanel 作用域覆盖 */
[data-theme="dark"] .qm-ai-pill { border-color: #475569; }
[data-theme="dark"] .qm-ai-guest { background: #1e293b; color: #7dd3fc; border-color: #0ea5e9; }
[data-theme="dark"] .qm-ai-recommend { color: #c4b5fd; border-color: #8b5cf6; }
[data-theme="dark"] #chatPanel .ai-chat-panel-wrapper { background: #1e293b !important; }
[data-theme="dark"] #chatPanel .ai-chat-header { background: #0b1220 !important; }
[data-theme="dark"] #chatPanel .chat-messages-container { background: #0f172a !important; }
[data-theme="dark"] #chatPanel .message-bubble.ai .message-content { background: #1e293b !important; color: #e2e8f0 !important; box-shadow: none !important; }
[data-theme="dark"] #chatPanel .message-bubble.ai .message-content h1, [data-theme="dark"] #chatPanel .message-bubble.ai .message-content h2,
[data-theme="dark"] #chatPanel .message-bubble.ai .message-content h3 { color: #93c5fd !important; }
[data-theme="dark"] #chatPanel .message-bubble.ai .message-content strong { color: #fbbf24 !important; }
[data-theme="dark"] #chatPanel .message-bubble.user .message-content { background: #2f6f3e !important; color: #f0fdf4 !important; }
[data-theme="dark"] #chatPanel .ai-msg-actions { border-top-color: #334155 !important; }
[data-theme="dark"] #chatPanel .ai-action-btn { color: #cbd5e1 !important; border-color: #475569 !important; background: transparent !important; }
[data-theme="dark"] #chatPanel .ai-action-btn:hover { background: #334155 !important; }
[data-theme="dark"] #chatPanel .rating-popup { background: #1e293b !important; border-color: #475569 !important; }
[data-theme="dark"] #chatPanel .rate-opt-btn { color: #e2e8f0 !important; border-color: #475569 !important; }
[data-theme="dark"] #chatPanel .chat-footer { background: #1e293b !important; border-top-color: #334155 !important; }
[data-theme="dark"] #chatPanel .chat-input, [data-theme="dark"] #chatPanel #chat-input { background: #0f172a !important; color: #e2e8f0 !important; border-color: #475569 !important; }
[data-theme="dark"] #chatPanel #chat-input.qm-ai-locked { background: #273449 !important; color: #94a3b8 !important; }
[data-theme="dark"] #chatPanel .ai-chat-disclaimer { background: #1e293b !important; color: #94a3b8 !important; }
[data-theme="dark"] #chatPanel .loading-timer-text, [data-theme="dark"] #chatPanel .message-content div[style*="color:#888"] { color: #94a3b8 !important; }
[data-theme="dark"] #chatPanel .user-points-badge { background: #334155 !important; color: #fde68a !important; }
[data-theme="dark"] .qm-sys-msg { color: #64748b; }
[data-theme="dark"] .preset-q-modal { background: #1e293b !important; color: #e2e8f0; }
[data-theme="dark"] .preset-q-cats, [data-theme="dark"] .preset-q-modal-footer { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .preset-q-cat-chip { background: #334155 !important; color: #e2e8f0 !important; border-color: #475569 !important; }
[data-theme="dark"] .preset-q-cat-chip.active { background: #1e3a8a !important; border-color: #3b82f6 !important; }
[data-theme="dark"] .preset-q-item { background: #172033 !important; border-color: #334155 !important; }
[data-theme="dark"] .preset-q-item-title { color: #e2e8f0 !important; }
[data-theme="dark"] .preset-q-modal-close { color: #93c5fd !important; }

@media (max-width: 640px) {
  .qm-ai-selects .qm-ai-select { flex: 1 1 calc(50% - 6px); }
  .qm-wrap { padding: 8px; }
  .qm-field, .qm-actions { width: 100%; }
  .qm-field select, .qm-field input { flex: 1; min-width: 0; text-align: center;}
  .qm-actions { grid-template-columns: 1fr; }
  .qm-btn { padding: 9px 16px; }
  .qm-cell { min-height: 100px; font-size: 13px; padding: 12px 4px 4px; }
  .qm-badge { font-size: 10px; padding: 0 3px; }
}
