/* === 爱奇围棋 · 深色模式专属修复层 2026-09-12 ===
   背景：此前全仓不存在任何 html[data-theme="dark"] 规则，深色外观完全由 styles.css 与
   ui-refinement.css 两个「无作用域」的 body:not(.auth-mode) 基座叠加决定（后者加载在后并
   覆盖前者），因此「没被点名覆盖」的遗留值会在深色下原样生效。

   本文件由 index.html 在 theme-controls.css 之后加载（最后一位），用于压过前述两层的
   !important 声明。**全部规则以 html[data-theme=dark] 起头**，该选择器在浅色模式下永不匹配，
   因此本文件对浅色模式零影响。只调整颜色、边框、阴影与可见性，不改动任何功能逻辑或 DOM。 */

@media screen {

/* ── 1. 修复两处「未定义变量」（原声明在计算值阶段整体失效） ───────────── */
html[data-theme=dark] body:not(.auth-mode){
  --jade: #8ecab2;          /* styles.css:3169/3170 引用，全仓原无定义 */
  --mint: #9fd3bc;          /* styles.css:8029 引用，全仓原无定义 */
  /* 评级色七级中两级在深色下不达 AA：极恶 #9b1996=2.50:1、恶手 #d01013=3.16:1 */
  --g-terrible: #c470c0;
  --g-blunder: #ff6f72;
}

/* ── 2. var(--paper) 被当作文字色 ─────────────────────────────────────────
   深色下 ui-refinement.css 把 --paper 重绑为面板底色 #0c1d17，于是这些文字变成「深字压深底」。 */
html[data-theme=dark] body:not(.auth-mode) .form-group select option{
  background:#0a1a14!important; color:var(--ink)!important;
}
html[data-theme=dark] body:not(.auth-mode) .captcha-row input{ color:var(--ink)!important; }
/* 内联 color:var(--paper)（index.html:1324/1329、app.js:305/334）CSS 无法覆盖内联，改为按 id/类定向 */
html[data-theme=dark] #sgf-import-file,
html[data-theme=dark] #sgf-import-text,
html[data-theme=dark] .prompt-input{ color:var(--ink)!important; }

/* ── 3. 低透明度文字统一提到 AA 以上 ─────────────────────────────────────
   原 alpha 0.28–0.54，实测对比度 2.31–4.49；AA 达标线在 alpha≈0.55。
   以下四组按原色相分别提亮，保留原有层级关系。 */

/* 3a. 薄荷白系 (226,239,232)/(222,237,230)/(231,242,236) → 0.62（实测 5.90–6.61） */
html[data-theme=dark] body:not(.auth-mode) :is(
  .voice-review-link-field, .voice-review-import-card > p, .voice-review-game-row small,
  .voice-review-list-empty, .voice-review-current > span, .voice-review-playback label,
  .voice-review-status, .voice-review-empty p, .voice-review-metrics small,
  .voice-review-candidates small, .voice-review-narrative footer, .voice-review-command-strip > span,
  .dynamic-source-divider, .dynamic-panel-title small, .dynamic-source-summary span,
  .dynamic-fixed-rule small, .dynamic-gif-results span, .dynamic-local-note,
  .institution-panel-title small, .institution-preview-head small, .institution-history-item span,
  .institution-history-item small, .institution-empty-small, .institution-section-head small,
  .institution-template-group span, .institution-source-actions span,
  .institution-analysis-chooser>div:first-child span, .institution-analysis-products button small,
  .institution-pending-imports header span, .institution-pending-imports article small,
  .institution-sample small, .institution-share-box span, .institution-share-box>small,
  .institution-analysis-dialog > span, .institution-public-toolbar span, .rv-analysis-pdf:disabled
){ color:rgba(226,239,232,.62)!important; }

/* 3b. 暖沙系 (216,201,168) → 0.66（实测 4.94–5.59；0.62 在语音面板底上仅 4.51，故略高） */
html[data-theme=dark] body:not(.auth-mode) :is(
  .game-btn.future, .chat-input::placeholder, .form-group input::placeholder,
  .room-tool-btn.future, .moves-empty,
  .rv-analysis-head > span, .rv-panel-empty, .rv-dual-mini small, .rv-report-score small,
  .rv-report-source, .rv-metric-grid small, .rv-phase-row small, .rv-report-footnote,
  .rv-story-grid span, .rv-fp-mode-grid article > small, .rv-fp-score-card p,
  .rv-fp-result-head span, .rv-fp-metrics small, .rv-fp-deep-summary small,
  .rv-fp-distribution small, .rv-fp-exclusions span, .rv-fp-evidence button span,
  .rv-fp-evidence p, .rv-fp-verification span, .rv-fp-dimension p, .az-compact-metrics small
){ color:rgba(216,201,168,.66)!important; }

/* 3c. 暖金系 (200,180,140) → 0.78（该基准色本身偏暗，0.66 仍有 4.14 不达标） */
html[data-theme=dark] body:not(.auth-mode) :is(
  .rv-move-num, .rv-chartbar-title, .rv-sum-ph-score small, .rv-grade-legend,
  #lizzie-settings-modal .lz-hint, .az-wr-source
){ color:rgba(200,180,140,.78)!important; }

/* 3d. 冷白系 (232,244,238) → 0.62 */
html[data-theme=dark] body:not(.auth-mode) :is(
  .software-publisher, .admin-software-form-grid small, .room-player-card .seat-clock-card em,
  .room-captures, .live-game-players em, .live-game-players small, .live-games-empty
){ color:rgba(232,244,238,.62)!important; }

/* 3e. 青色与危险色两处特例 */
html[data-theme=dark] body:not(.auth-mode) .voice-review-result-head small{ color:rgba(116,240,210,.68)!important; }
html[data-theme=dark] body:not(.auth-mode) .engine-error-code{ color:rgba(255,194,182,.72)!important; }

/* 3f. 登录页（body.auth-mode，不被上面 body:not(.auth-mode) 覆盖）。该页深色为固定硬编码，
   与主题选择无关；此处仅提高占位符与说明文字的对比度。 */
html[data-theme=dark] .form-group input::placeholder{ color:rgba(200,185,155,.70)!important; }
html[data-theme=dark] .auth-dev-note{ color:rgba(200,185,155,.70)!important; }

/* ── 4. 紫靛财务面板内的两档灰字 ─────────────────────────────────────────
   #5F5E5A 实测 2.22:1（#26215C 上）/2.78:1（#14142a 上）、#888780 为 4.00:1，均不达 AA。 */
html[data-theme=dark] body:not(.auth-mode) :is(
  .aiqi-balance-num small, .aiqi-balance-meta, .aiqi-tab, .aiqi-contact-tip,
  .aiqi-pkg-label, .aiqi-bill-time, .aiqi-bill-loading, .aiqi-bill-empty,
  .recharge-input-row span, .admin-tx-time, .aiqi-tips, .aiqi-bill-bal, .admin-tx-bal
){ color:#a9c0b5!important; }

/* ── 5. 深色母体中的「浅色块」 ───────────────────────────────────────────
   结论区：白方/和棋结论原为整块高亮纸面（对页底 15.97 / 16.63，刺眼），黑方结论则与页底
   几乎同色（1.07，看不出是框）。统一为同族半透明底 + 描边，保留黑白石语义。 */
html[data-theme=dark] body:not(.auth-mode) .conclude-black{
  background:#1a1a1a; color:#f0ede6; border:1px solid rgba(217,170,63,.60);
}
html[data-theme=dark] body:not(.auth-mode) .conclude-white{
  background:rgba(240,237,230,.16); color:#f3efe4; border:1px solid rgba(240,237,230,.55);
}
html[data-theme=dark] body:not(.auth-mode) .conclude-draw{
  background:rgba(232,245,236,.14); color:#bfe6c9; border:1px solid rgba(232,245,236,.55);
}
/* 个人棋谱「进行中」徽章：全仓唯一在深色下变亮的徽章（浅青底，对页底 15.1） */
html[data-theme=dark] body:not(.auth-mode) .kifu-ongoing{
  background:rgba(209,236,241,.15); color:#c2e6ec; border:1px solid rgba(209,236,241,.55);
}

/* ── 6. 危险操作悬停态 ───────────────────────────────────────────────────
   .admin-action-btn.del:hover 的 #fde8e8 是浅色值，深色下文字被压到 2.23:1。 */
html[data-theme=dark] body:not(.auth-mode) .admin-action-btn.del:hover{
  background:rgba(199,83,69,.24)!important; border-color:rgba(255,117,106,.62)!important; color:#ffb2aa!important;
}

/* ── 7. 未通用化的弹窗标题栏 ─────────────────────────────────────────────
   .modal-head 全仓只有 1 条规则且限定 .my-profile-modal；ui-refinement.css 仅设 border-color
   （无宽度＝空操作）。下两个弹窗的标题与关闭按钮因此塌成两行。 */
html[data-theme=dark] :is(#voice-review-help-modal, #lizzie-settings-modal) .modal-head{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:16px 22px; border-bottom:1px solid var(--ui-line);
}
html[data-theme=dark] :is(#voice-review-help-modal, #lizzie-settings-modal) .modal-head .modal-title{ margin:0; }

/* ── 8. AI 鉴定头部按钮 ──────────────────────────────────────────────────
   原底 rgba(16,48,38,.9) 与头部底 rgba(4,27,21,.94) 反差仅 1.23，按钮几乎不可见。 */
html[data-theme=dark] .fairplay-workspace-header button{
  background:rgba(217,170,63,.10)!important; border-color:rgba(217,170,63,.65)!important; color:#f0ca69!important;
}
html[data-theme=dark] .fairplay-workspace-header button:hover{
  background:rgba(217,170,63,.20)!important; border-color:rgba(217,170,63,.85)!important;
}

/* ── 9. 对局邀请（#invite-modal）改用浅色模式的横版双列布局 ───────────────
   浅色侧该布局定义在 theme-brand-green.css:689-711（双列 grid、标题与按钮条通栏、取消粘性定位）；
   深色基座（styles.css:1577-1601）仍是 460px 单列 + 粘性标题/按钮条 + 内部滚动。
   此处把深色对齐到浅色的横版形态；颜色仍取深色体系（标题保留暖金、分隔线用 --ui-line）。
   说明：浅色版用 overflow:visible，内容超出一屏时会被裁切；深色改用 overflow-y:auto，
   内容放得下时外观完全一致，放不下时可滚动，避免溢出。 */
html[data-theme=dark] #invite-modal .invite-modal-panel{
  width:min(680px,94vw);
  max-height:calc(100dvh - 24px);
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px 14px;
  overflow-y:auto;
  padding:20px 22px;
}
html[data-theme=dark] #invite-modal .invite-modal-panel > .modal-title,
html[data-theme=dark] #invite-modal .invite-modal-panel > .modal-actions,
html[data-theme=dark] #invite-modal .invite-modal-panel > #inv-color-group{ grid-column:1 / -1; }
html[data-theme=dark] #invite-modal .invite-modal-panel > .modal-title{
  position:static;
  margin:0;
  padding:0 0 8px;
  background:transparent;
  border-bottom:1px solid var(--ui-line);
}
html[data-theme=dark] #invite-modal .invite-modal-panel > .form-group{ min-width:0; margin:0; }
html[data-theme=dark] #invite-modal .invite-modal-panel > .form-group :is(select,input){ min-height:38px; }
html[data-theme=dark] #invite-modal .invite-modal-panel > .modal-actions{
  position:static;
  margin:0;
  padding:10px 0 0;
  background:transparent;
  border-top:1px solid var(--ui-line);
}
@media (max-width:620px){
  html[data-theme=dark] #invite-modal .invite-modal-panel{ gap:8px 10px; padding:16px; }
}

/* 弹窗打开时保留当前页面，只做轻度压暗。 */
html[data-theme=dark] .modal-overlay,
html[data-theme=dark] .institution-analysis-overlay{
  background:rgba(0,8,6,.38)!important;
  background-color:rgba(0,8,6,.38)!important;
  backdrop-filter:none!important;
}
html[data-theme=dark] .dynamic-result-dialog::backdrop{
  background:rgba(0,8,6,.38)!important;
}

}
