/* ==========================================================================
   辉哥工具合集 · 明暗主题（自动 / 浅色 / 深色）
   由 js/theme.js 在 <html> 上设置 data-theme="light|dark"（自动模式已解析成实际值）
   本文件放在各页面自有样式之后加载，用于：
   1) 提供右上角主题切换器的样式
   2) 提供深色模式的设计令牌与遗留页面补丁
   ========================================================================== */

/* ---------- 切换器（所有页面统一，固定在右上角） ---------- */
html[data-theme="light"]{
  --sw-bg: rgba(255,255,255,.94);
  --sw-line: #e2e8f3;
  --sw-txt: #5b6b82;
  --sw-hover: #eef2fb;
  --sw-on-1: #4f46e5;
  --sw-on-2: #0ea5e9;
  color-scheme: light;
}
html[data-theme="dark"]{
  --sw-bg: rgba(17,26,44,.92);
  --sw-line: #2b3a55;
  --sw-txt: #9fb0c9;
  --sw-hover: #1b2740;
  --sw-on-1: #6366f1;
  --sw-on-2: #38bdf8;
  color-scheme: dark;
}

.theme-switch{
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 900;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--sw-line);
  background: var(--sw-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}
.theme-switch button{
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--sw-txt);
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
}
.theme-switch button:hover{ background: var(--sw-hover); color: var(--sw-on-1); }
.theme-switch button[aria-pressed="true"]{
  background: linear-gradient(135deg, var(--sw-on-1), var(--sw-on-2));
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, .28);
}
@media (max-width: 520px){
  .theme-switch{ top: 8px; right: 8px; }
  .theme-switch button{ padding: 5px 8px; font-size: 11.5px; }
}

/* ==========================================================================
   深色令牌（作用于使用共享设计系统的页面 body.ds、截图页 body.page-detail、
   物性库 body.page-pq；放在 body 上，避免影响自带令牌的新首页）
   ========================================================================== */
html[data-theme="dark"] body.ds,
html[data-theme="dark"] body.page-detail,
html[data-theme="dark"] body.page-pq{
  --bg: #0b1020;
  --panel: #121b2d;
  --ink: #e6edf7;
  --ink-2: #eef4ff;
  --muted: #93a4bd;
  --line: #243049;
  --line-strong: #2e3d58;
  --brand-1: #8b9cff;
  --brand-2: #a78bfa;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --shadow-1: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .5);
  --shadow-brand: 0 10px 30px rgba(99, 102, 241, .35);
  color: var(--ink);
}

/* ---------- 共享设计系统页面（style.css）深色补丁 ---------- */
html[data-theme="dark"] body.ds{
  background:
    radial-gradient(1100px 520px at 15% -10%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(900px 460px at 90% 0%, rgba(14, 165, 233, .12), transparent 58%),
    #0b1020;
}
html[data-theme="dark"] body.ds .container{ box-shadow: 0 12px 36px rgba(0, 0, 0, .45); }
html[data-theme="dark"] body.ds .back-link{ background: #1a2440; color: #a5b4fc; }
html[data-theme="dark"] body.ds .back-link:hover{ background: var(--brand-grad); color: #fff; }
html[data-theme="dark"] body.ds label{ color: #c3cfe0; }
html[data-theme="dark"] body.ds input[type="number"],
html[data-theme="dark"] body.ds input[type="text"],
html[data-theme="dark"] body.ds input[type="password"],
html[data-theme="dark"] body.ds input[type="search"],
html[data-theme="dark"] body.ds select,
html[data-theme="dark"] body.ds textarea{
  background: #0f1728;
  color: var(--ink);
  border-color: var(--line-strong);
}
html[data-theme="dark"] body.ds input::placeholder,
html[data-theme="dark"] body.ds textarea::placeholder{ color: #6f8099; }
html[data-theme="dark"] body.ds input[readonly]{ background: #162033; color: #c7d2e5; }
html[data-theme="dark"] body.ds tbody tr:hover{ background: #172238; }
html[data-theme="dark"] body.ds tbody tr:nth-child(even){ background: #0f1728; }
html[data-theme="dark"] body.ds tbody tr:nth-child(even):hover{ background: #1b2740; }
html[data-theme="dark"] body.ds .cas-number{ color: #c7d2e5; }
html[data-theme="dark"] body.ds .properties-panel{ background: var(--panel); }
html[data-theme="dark"] body.ds .property-item{ background: #0f1728; border-color: var(--line); }
html[data-theme="dark"] body.ds .result{ background: var(--panel); }
html[data-theme="dark"] body.ds .ichemistry-property-item{ border-bottom-color: #1d2941; }
html[data-theme="dark"] body.ds .ichemistry-property-item:hover{ background-color: #172238; }
html[data-theme="dark"] body.ds .ichemistry-property-label{ color: #8fa0b8; }
html[data-theme="dark"] body.ds .ichemistry-property-link{
  background: linear-gradient(135deg, #162033 0%, #101a2c 100%);
}
html[data-theme="dark"] body.ds .ichemistry-property-link a{ color: #7dd3fc; }
html[data-theme="dark"] body.ds .status-success{ background: #0f2f1e; color: #6ee7b7; border-color: #14532d; }
html[data-theme="dark"] body.ds .status-error{ background: #3a1418; color: #fca5a5; border-color: #5c1f26; }
html[data-theme="dark"] body.ds .status-warning{ background: #33260c; color: #fcd34d; border-color: #57420f; }
html[data-theme="dark"] body.ds .status-info{ background: #0d2a3a; color: #7dd3fc; border-color: #164e63; }
html[data-theme="dark"] body.ds .tab:hover,
html[data-theme="dark"] body.ds .tab.active{ color: #a5b4fc; }
html[data-theme="dark"] body.ds .tab.active{ border-bottom-color: #a5b4fc; }
html[data-theme="dark"] body.ds .btn-secondary{ background: #475569; }
html[data-theme="dark"] body.ds .btn-ghost{ color: var(--ink); }

@media (max-width: 768px){
  html[data-theme="dark"] body.ds td:first-child{ background: #121b2d; }
  html[data-theme="dark"] body.ds tbody tr:nth-child(even) td:first-child{ background: #0f1728; }
  html[data-theme="dark"] body.ds tbody tr:hover td:first-child{ background: #172238; }
}

/* ---------- 截图页（software_detail.html，body.page-detail） ---------- */
html[data-theme="dark"] body.page-detail{
  background:
    radial-gradient(1000px 460px at 20% -10%, rgba(99, 102, 241, .18), transparent 60%),
    #0b1020;
  color: var(--ink);
}
html[data-theme="dark"] body.page-detail .back-btn{ background: #1a2440; color: #a5b4fc; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
html[data-theme="dark"] body.page-detail .back-btn:hover{ background: var(--brand-grad); color: #fff; }
html[data-theme="dark"] body.page-detail .gallery-item{ background: #121b2d; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
html[data-theme="dark"] body.page-detail .gallery-item .caption{ color: var(--muted); }
html[data-theme="dark"] body.page-detail .no-images{ color: #8fa0b8; }
html[data-theme="dark"] body.page-detail .header{
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
  box-shadow: 0 12px 34px rgba(67, 56, 202, .35);
}

/* ---------- 石化物性库（chemical-property-query，body.page-pq） ---------- */
html[data-theme="dark"] body.page-pq{
  --bg: #0b1020;
  --panel: #121b2d;
  --ink: #e6edf7;
  --muted: #93a4bd;
  --line: #243049;
  --accent: #7dd3fc;
  --accent2: #6ee7b7;
  --warn: #fbbf24;
  --chip: #172238;
  --chipb: #1f3350;
  --good: #34d399;
  background: #0b1020;
  color: var(--ink);
}
html[data-theme="dark"] body.page-pq select{ background: #0f1728; color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] body.page-pq .btn.ghost{ background: transparent; color: var(--accent); border-color: var(--accent); }
html[data-theme="dark"] body.page-pq .listhead,
html[data-theme="dark"] body.page-pq .pager{ background: #0f1728; }
html[data-theme="dark"] body.page-pq .item{ border-bottom-color: #1d2941; }
html[data-theme="dark"] body.page-pq .item:hover{ background: #162033; }
html[data-theme="dark"] body.page-pq .item.active{ background: #1b2c47; }
html[data-theme="dark"] body.page-pq .tag{ background: #172238; border-color: var(--line); }
html[data-theme="dark"] body.page-pq table{ background: #0f1728; border-color: var(--line); }
html[data-theme="dark"] body.page-pq th{ background: #162033; color: #a9b8cd; }
html[data-theme="dark"] body.page-pq th,
html[data-theme="dark"] body.page-pq td{ border-bottom-color: #1d2941; }
html[data-theme="dark"] body.page-pq .kv .card,
html[data-theme="dark"] body.page-pq .calc{ background: #121b2d; border-color: var(--line); }
html[data-theme="dark"] body.page-pq .dhead .formula{ background: #0f1728; }
html[data-theme="dark"] body.page-pq .search input[type=text]{ background: #0f1728; color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] body.page-pq .tag.api{ background: #10233d; border-color: #1e3a5f; color: #7dd3fc; }
html[data-theme="dark"] body.page-pq .tag.dip{ background: #0f2f26; border-color: #1c4d3d; color: #6ee7b7; }
html[data-theme="dark"] body.page-pq .tag.d9{ background: #33260c; border-color: #57420f; color: #fbbf24; }

/* ==========================================================================
   深色专题页（plan-helper-show / tray-show，body.page-showcase）
   这两个页面本身是深色设计；切到浅色时只换“纸张”，插图/图纸区保持深色
   ========================================================================== */
html[data-theme="light"] body.page-showcase{
  --bg: #f4f7fc;
  --bg2: #ffffff;
  --card: #ffffff;
  --line: #e2e8f3;
  --txt: #101a2c;
  --mut: #5b6b82;
  --acc: #2563eb;
  background:
    radial-gradient(1100px 480px at 70% -80px, #e8eeff 0%, transparent 62%),
    #f4f7fc;
  color: var(--txt);
}
html[data-theme="light"] body.page-showcase nav.top{
  background: rgba(255, 255, 255, .86);
  border-bottom-color: var(--line);
}
html[data-theme="light"] body.page-showcase nav.top b{ color: var(--txt); }
html[data-theme="light"] body.page-showcase nav.top a{ color: var(--mut); }
html[data-theme="light"] body.page-showcase nav.top a:hover{ color: var(--acc); }
html[data-theme="light"] body.page-showcase .kicker{ background: #eef4ff; border-color: #c7d7f5; color: #2563eb; }
html[data-theme="light"] body.page-showcase .pill{ background: #eef2fb; border-color: var(--line); color: #334155; }
html[data-theme="light"] body.page-showcase .step,
html[data-theme="light"] body.page-showcase .card,
html[data-theme="light"] body.page-showcase .mod .side,
html[data-theme="light"] body.page-showcase ul.feat li,
html[data-theme="light"] body.page-showcase .chip,
html[data-theme="light"] body.page-showcase .stat{ background: #fff; border-color: var(--line); }
html[data-theme="light"] body.page-showcase .step h4,
html[data-theme="light"] body.page-showcase .card h4,
html[data-theme="light"] body.page-showcase .shot .cap b{ color: #0f172a; }
html[data-theme="light"] body.page-showcase .step p,
html[data-theme="light"] body.page-showcase .card p,
html[data-theme="light"] body.page-showcase .mod .side p,
html[data-theme="light"] body.page-showcase .mod ul li{ color: var(--mut); }
html[data-theme="light"] body.page-showcase .chip{ color: #1e3a5f; }
html[data-theme="light"] body.page-showcase .shot{ background: #0f1728; border-color: #1f2a44; }
html[data-theme="light"] body.page-showcase .shot .cap{ color: #b6c2d6; }
html[data-theme="light"] body.page-showcase footer{ color: #7c8ba1; border-top-color: var(--line); }
html[data-theme="light"] body.page-showcase .stage{ box-shadow: 0 10px 30px rgba(15,23,42,.10); }
html[data-theme="light"] body.page-showcase .thr span{ background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* 顶部带通栏头部的页面：给右上角切换器让位 */
body.page-pq header{ padding-right: 190px; flex-wrap: wrap; }
body.page-pq header .stat{ flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px){
  body.page-pq header{ padding-right: 130px; }
}

/* 浅色专题页：深色插图卡里的说明文字保持浅色 */
html[data-theme="light"] body.page-showcase .stage .hint{ color: #b6c2d6; }

/* SULCOL 页：分节标题 / 拖拽高亮跟随主题（预览区保持白纸，模拟 Word） */
html[data-theme="dark"] body.ds .section-title{ background: #1b2740; }
html[data-theme="dark"] body.ds textarea.drag-over{ background-color: #172238; }
html[data-theme="dark"] body.ds .drag-hint{ color: #8fa0b8; }

/* ---------- 各工具页的零散硬编码色 ---------- */
html[data-theme="dark"] body.ds .best-velocity{ background: #1b2740; color: #c7d2e5; }
html[data-theme="dark"] body.ds .hint{ background: #162033; color: #b6c2d6; }
html[data-theme="dark"] body.ds .sort-button{ background: #0f1728; color: #a5b4fc; border-color: #3b4a6b; }
html[data-theme="dark"] body.ds .sort-button:hover{ background: #1b2740; }
html[data-theme="dark"] body.ds .stat-card{ background: var(--panel); border-color: var(--line); }

/* ---------- 数据管理页（compare / merge 面板） ---------- */
html[data-theme="dark"] body.ds .compare-panel,
html[data-theme="dark"] body.ds .compare-list,
html[data-theme="dark"] body.ds .modal-box{ background: #121b2d; }
html[data-theme="dark"] body.ds .merge-group-head{ background: #162033; }
html[data-theme="dark"] body.ds .merge-head-row{ background: #162033; }
html[data-theme="dark"] body.ds .compare-row,
html[data-theme="dark"] body.ds .merge-row{ border-bottom-color: #1d2941; }
html[data-theme="dark"] body.ds .compare-row .cas,
html[data-theme="dark"] body.ds .merge-row .cas{ color: #c7d2e5; }
html[data-theme="dark"] body.ds .push-hint code{ background: #1b2740; color: #c7d2e5; }
html[data-theme="dark"] body.ds td.editable:focus{ background: #162033; }
html[data-theme="dark"] body.ds .highlight{ background-color: #4a3a10 !important; color: #fde68a; }
html[data-theme="dark"] body.ds .merge-row input[type="text"]:disabled{ background: #162033; }
html[data-theme="dark"] body.ds .modal-overlay{ background: rgba(3, 7, 18, .72); }

/* 专题页导航给右上角切换器让位（窄屏时链接换行，不压在切换器上） */
body.page-showcase nav.top .in{ padding-right: 150px; }
@media (max-width: 560px){
  body.page-showcase nav.top .in{ padding-right: 122px; }
  .theme-switch button{ padding: 4px 7px; font-size: 11px; }
}
