/* ============================================================
   Agentrace 主题层：深色模式 + 主题切换控件
   默认 light；可选 dark / auto（跟随系统）
   由 assets/theme.js 写入 html[data-mode] 与 html[data-theme]
   ============================================================ */
html{color-scheme:light}
html[data-theme="dark"]{color-scheme:dark}

/* 主题切换的同一帧内冻结过渡（theme.js 在两个 rAF 后移除） */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after{transition:none!important;animation:none!important}

/* ---------- 深色令牌（覆盖 site.css / index 内联的 :root） ---------- */
html[data-theme="dark"]{
  --bg:#0B0D11;
  --surface:#12151A;
  --surface-2:#171B21;
  --card:#14181E;
  --line:#252A33;
  --line-strong:#343C48;
  --ink:#E7EAF0;
  --ink-2:#B1B8C4;
  --ink-3:#868F9C;
  --brand:#8C93FF;
  --brand-hover:#A6ACFF;
  --brand-soft:#1C2150;
  --brand-rgb:140,147,255; --brand-wash:var(--brand-wash);
  --brand-tint:var(--brand-tint); --brand-line:var(--brand-line); --brand-line-strong:var(--brand-line-strong);
  --brand-ink:var(--brand-ink); --brand-ink-soft:var(--brand-ink); --brand-on-dark:var(--brand-ink);
  --on-brand:#0B0D11;
  --green:#3ECF8E;
  --green-soft:#102A21;
  --amber:#FFA53D;
  --inverse-bg:#E7EAF0; --inverse-bg-hover:#D3D8E2; --inverse-ink:#0B0D11;
  --shadow-s:0 1px 2px rgba(0,0,0,.42);
  --shadow:0 4px 16px rgba(0,0,0,.46);
  --shadow-l:0 12px 32px rgba(0,0,0,.52);
}

/* ---------- 结构件在深色下的针对性修正 ---------- */
html[data-theme="dark"] .nav{background:rgba(11,13,17,.82)}
html[data-theme="dark"] .to-top{background:rgba(20,24,30,.92);box-shadow:0 6px 20px rgba(0,0,0,.45)}
html[data-theme="dark"] .section-ink,
html[data-theme="dark"] .cta-band{background:#11151B}
html[data-theme="dark"] .card.ink{background:#171B22;border-color:#252A33}
html[data-theme="dark"] .card.ink p{color:#B1B8C4}
html[data-theme="dark"] footer{background:#080A0D}
html[data-theme="dark"] .foot-privacy{color:#767E8B}

/* 黑底主按钮在深色主题里会变成「黑底黑字」，改用浅底反白 */
html[data-theme="dark"] .btn-dark{background:var(--inverse-bg);border-color:var(--inverse-bg);color:var(--inverse-ink)}
html[data-theme="dark"] .btn-dark:hover{background:#FFFFFF;border-color:#FFFFFF;color:#0B0D11}

/* 内容图与渐变 */
html[data-theme="dark"] .hero::before,
html[data-theme="dark"] .page-hero::before{background:radial-gradient(circle,rgba(var(--brand-rgb),.16) 0%,rgba(var(--brand-rgb),0) 62%)}
html[data-theme="dark"] .hero h1 em,
html[data-theme="dark"] .page-hero h1 em{background-image:linear-gradient(rgba(var(--brand-rgb),.22),rgba(var(--brand-rgb),.22))}
html[data-theme="dark"] .feature-post .fp-visual{background:linear-gradient(135deg,#141B29 0%,#11151D 55%,#151D2B 100%)}
html[data-theme="dark"] .fp-chart .row .bar{background:rgba(255,255,255,.10)}
html[data-theme="dark"] .hp-row .bar i{background:linear-gradient(90deg,var(--brand),var(--brand))}

/* 表格 / 勾选 / 标签的浅色底 */
html[data-theme="dark"] table.tbl thead th.us{background:var(--brand-wash)}
html[data-theme="dark"] table.tbl tbody td.us{background:rgba(var(--brand-rgb),.08)}
html[data-theme="dark"] .compare .row div:nth-child(3){background:rgba(var(--brand-rgb),.09)}
html[data-theme="dark"] .bt td.pro{background:rgba(var(--brand-rgb),.09)}
html[data-theme="dark"] .check-list li::before{border-color:var(--brand-line)}
html[data-theme="dark"] .chip.brand{border-color:var(--brand-tint)}
html[data-theme="dark"] .model-chip:hover{border-color:var(--brand-line-strong)}

/* 语义色（错误 / 折扣）在深色下重配 */
html[data-theme="dark"] .mark-bad{background:rgba(255,92,72,.16);border-bottom-color:rgba(255,92,72,.55)}
html[data-theme="dark"] .serp-row b{color:var(--brand-ink)}
html[data-theme="dark"] .serp-row .u{color:#8F99AA}
html[data-theme="dark"] .cmp-card.is-ai{background:#121722;border-color:var(--brand-tint)}
html[data-theme="dark"] .ev-waffle i{background:#212734}
html[data-theme="dark"] .ev-waffle i.on{background:var(--brand)}
html[data-theme="dark"] .ev-num i{color:#4B5462}
html[data-theme="dark"] .ai-src i{background:#3B4350}
html[data-theme="dark"] .plan-more>summary{color:var(--brand-ink)}
html[data-theme="dark"] .billing-off{color:#FF8574;background:rgba(255,92,72,.14);border-color:rgba(255,92,72,.32)}
html[data-theme="dark"] .plan .save{color:#FF8574;background:rgba(255,92,72,.14)}

/* 表单卡片在深色下与深色底带区分开 */
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .apply-card{border:1px solid var(--line);box-shadow:0 16px 48px rgba(0,0,0,.5)}

/* 表单 */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{color:var(--ink);background:var(--card)}
html[data-theme="dark"] .partner-search input::placeholder{color:var(--ink-3)}

/* 页头标识：深色墨标在深底上反白 */
html[data-theme="dark"] .nav-inner .logo-mark{filter:brightness(0) invert(1)}
html[data-theme="dark"] .nav-menu-m>summary svg{stroke:var(--ink)}

/* 客户/模型标志的白色底片保留（原图按浅底设计），仅收敛边框与亮度 */
html[data-theme="dark"] .case-logo{background:var(--surface-2);border-color:var(--line)}
html[data-theme="dark"] .case-evidence figure{background:var(--card);border-color:var(--line)}
html[data-theme="dark"] .hp-ico{background:#fff}

/* 实心品牌按钮在深色下不再换成另一支蓝：#8C93FF 配 --on-brand(#0B0D11) 对比 6.9:1，
   与浅色模式共用 --brand / --brand-hover，品牌色只改一处（E22 守护） */
/* 定价页：代理商深色带不能用 --ink（深色下 --ink 是浅色文字色） */
html[data-theme="dark"] .pr-agency{background:#171B21;border:1px solid var(--line)}
html[data-theme="dark"] .pr-billing .off{background:rgba(var(--brand-rgb),.14);border-color:rgba(var(--brand-rgb),.34);color:var(--brand-ink)}

/* 页脚生态标签 */
html[data-theme="dark"] .foot-eco .eco-label{color:#8A94A6}

/* ============================================================
   主题切换控件（浅色 / 深色 / 跟随系统）
   ============================================================ */
.theme-menu{position:relative;flex-shrink:0;margin-left:6px}
.theme-menu>summary{list-style:none;cursor:pointer;display:flex;align-items:center;justify-content:center;width:34px;height:34px;border:1px solid var(--line-strong);border-radius:100px;color:var(--ink-2);transition:color var(--dur-1) var(--ease),border-color var(--dur-1) var(--ease),background-color var(--dur-1) var(--ease)}
.theme-menu>summary::-webkit-details-marker{display:none}
.theme-menu>summary:hover{color:var(--brand);border-color:var(--brand)}
.theme-menu>summary:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.theme-menu>summary svg{width:15px;height:15px;display:none}
html[data-mode="light"] .theme-menu .i-light,
html[data-mode="dark"] .theme-menu .i-dark,
html[data-mode="auto"] .theme-menu .i-auto{display:block}
html:not([data-mode]) .theme-menu .i-light{display:block}

.theme-panel{position:absolute;top:calc(100% + 10px);right:0;z-index:70;min-width:172px;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-l);padding:6px;display:flex;flex-direction:column;gap:2px}
.theme-panel [data-theme-set]{display:flex;align-items:center;gap:8px;width:100%;padding:8px 10px;border-radius:8px;font-size:13px;line-height:1.4;color:var(--ink-2);text-align:left;transition:background-color var(--dur-1) var(--ease),color var(--dur-1) var(--ease)}
.theme-panel [data-theme-set]:hover{background:var(--surface);color:var(--ink)}
.theme-panel [data-theme-set][aria-checked="true"]{color:var(--ink);font-weight:600}
.theme-panel [data-theme-set] .tk{margin-left:auto;font-size:12px;color:var(--brand)}
.theme-panel .tk{visibility:hidden}
.theme-panel [data-theme-set][aria-checked="true"] .tk{visibility:visible}

@media (max-width:620px){
  .theme-menu{margin-left:4px}
  .theme-menu>summary{width:32px;height:32px}
}
/* 窄屏让出横向空间，保证顶栏不溢出（语言胶囊 + 主题按钮 + 汉堡） */
@media (max-width:400px){
  .nav-inner{padding:0 12px;gap:8px}
  .lang-switch{margin-left:2px;padding:1px}
  .lang-switch a{font-size:11px;padding:2px 6px}
  .theme-menu{margin-left:2px}
  .theme-menu>summary{width:30px;height:30px}
}
