/*!
 * coach.css — AI 教练面板（数竞 / 信竞共用）
 *
 * 约定：
 *   · 类名统一 coach- 前缀，不和 mf-/al-/wd-/cl-/cb-/gf- 混
 *   · 颜色全部走 chat.css 的 CSS 变量（深色主题自动生效），变量缺失时有浅色兜底
 *   · [hidden] 兜底必须带 !important（.dsh-tools/check-hidden-css.mjs 会查）
 *   · 375 宽：页面不横滚；输入框 16px（iOS 小于 16px 会自动放大页面）
 *   · 面板 z-index 76：比公式/画板/错题本那一批（78+）低 ——
 *     从教练里点「看公式」时，公式面板要盖在教练上面，而不是被挡住
 */

/* ── 面板 ─────────────────────────────────────────────────────── */
.coach-panel {
  position: fixed;
  inset: 0;
  z-index: 76;
  display: flex;
  flex-direction: column;
  max-width: 100vw;
  overflow: hidden;
  background: var(--bg, #ffffff);
  color: var(--ink, #1b1e28);
  font-family: var(--font, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif);
  font-size: 15px;
  line-height: 1.55;
  /* 手机软键盘弹出时用 dvh 才不会被顶出屏幕 */
  height: 100dvh;
}
body.coach-open { overflow: hidden; }

/* ⚠️ 2026-10-21 方案 B：原来的 `.coach-entry`（侧边栏那个「🎯 AI 教练」按钮）
   已经删掉了 —— 教练并进了板块聊天，入口在输入框上方那 4 个胶囊
   （见 coach-chat-buttons.css）。别再加回来。 */

/* 欢迎区的入口卡（index.html 里静态写的那两张，按板块显隐） */
.coach-board-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 32px);
  max-width: 560px;
  margin: 18px auto 0;
  padding: 12px 14px;
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 16px;
  background: var(--bg-side, #f7f8fa);
  color: var(--ink, #1b1e28);
  text-align: left;
  cursor: pointer;
}
.coach-board-entry:hover { border-color: var(--brand, #4d6bfe); }
.coach-board-entry:active { background: var(--bg-hover, #eceef2); }
.coach-board-entry + .coach-board-entry { margin-top: 10px; }
.coach-board-entry-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--bubble-user, #eff3ff);
  font-size: 21px;
}
.coach-board-entry-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.coach-board-entry-text b { font-size: 15px; font-weight: 800; color: var(--ink, #1b1e28); }
.coach-board-entry-text small { font-size: 12px; color: var(--muted, #8b93a7); line-height: 1.4; }
.coach-board-entry-arrow { flex: 0 0 auto; color: var(--muted, #8b93a7); font-size: 22px; line-height: 1; }

/* ── 顶栏 ─────────────────────────────────────────────────────── */
.coach-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--bg-side, #f7f8fa);
  border-bottom: 1px solid var(--line, #e6e8ee);
}
.coach-icon-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-hover, #eceef2);
  color: var(--ink-soft, #4a5163);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.coach-icon-btn:active { filter: brightness(.94); }
.coach-titles { flex: 1 1 auto; min-width: 0; }
.coach-title {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coach-sub {
  font-size: 12px;
  color: var(--muted, #8b93a7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 3000 小时进度条（常驻） ───────────────────────────────────── */
.coach-hours {
  flex: 0 0 auto;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--line, #e6e8ee);
  background: var(--bg, #fff);
}
.coach-hours-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.coach-hours-invested { font-size: 15px; font-weight: 800; color: var(--ink, #1b1e28); }
.coach-hours-goal { color: var(--muted, #8b93a7); font-size: 12px; }
.coach-hours-pct {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand, #4d6bfe);
}
.coach-bar {
  height: 7px;
  margin: 7px 0 6px;
  border-radius: 99px;
  background: var(--bg-hover, #eceef2);
  overflow: hidden;
}
.coach-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand, #4d6bfe), #7c92ff);
  transition: width .3s ease;
}
.coach-hours-meta {
  font-size: 11.5px;
  color: var(--muted, #8b93a7);
  line-height: 1.45;
}

/* ── tab ──────────────────────────────────────────────────────── */
.coach-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line, #e6e8ee);
  background: var(--bg, #fff);
}
.coach-tab-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft, #4a5163);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.coach-tab-btn:hover { background: var(--bg-hover, #eceef2); }
.coach-tab-btn.is-on {
  background: var(--bubble-user, #eff3ff);
  color: var(--brand, #4d6bfe);
}

/* ── 主体 ─────────────────────────────────────────────────────── */
.coach-body { flex: 1 1 auto; min-height: 0; display: flex; }
.coach-tabpane {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.coach-tabpane[data-tab="plan"],
.coach-tabpane[data-tab="weak"] { padding: 12px; gap: 12px; }
.coach-tabpane[data-tab="chat"] { padding: 0; overflow: hidden; }

/* ── 对话 ─────────────────────────────────────────────────────── */
.coach-msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.coach-msg { display: flex; flex-direction: column; max-width: 100%; }
.coach-msg.is-user { align-items: flex-end; }
.coach-msg.is-ai { align-items: flex-start; }
.coach-bubble {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--bg-side, #f7f8fa);
  color: var(--ink, #1b1e28);
  font-size: 15px;
  line-height: 1.62;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.coach-msg.is-user .coach-bubble {
  background: var(--bubble-user, #eff3ff);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.coach-msg.is-ai .coach-bubble { border-bottom-left-radius: 4px; }
/* AI 回答里的 markdown 元素（和聊天页保持同一套观感，但更紧凑） */
.coach-bubble p { margin: 0 0 .55em; }
.coach-bubble p:last-child { margin-bottom: 0; }
.coach-bubble ul, .coach-bubble ol { margin: .2em 0 .6em; padding-left: 1.35em; }
.coach-bubble li { margin: .15em 0; }
.coach-bubble pre {
  margin: .5em 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--code-bg, #f6f7f9);
  overflow-x: auto;
  font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: 12.5px;
  line-height: 1.5;
}
.coach-bubble code {
  font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace);
  font-size: .93em;
  background: var(--code-bg, #f6f7f9);
  padding: 1px 4px;
  border-radius: 4px;
}
.coach-bubble pre code { background: transparent; padding: 0; }
/* 公式超宽时自己滚，不把气泡撑破 */
.coach-bubble .katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; }

.coach-msg.is-feedback .coach-bubble { background: var(--bg, #fff); border: 1px dashed var(--line, #e6e8ee); }
.coach-verdict {
  margin-top: 6px;
  max-width: 88%;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
}
.coach-verdict.is-right { background: #e8f7ee; color: #14693a; }
.coach-verdict.is-wrong { background: #fdecea; color: #b3261e; }
.coach-verdict.is-unknown { background: #fff6e5; color: #8a5a00; }

/* 讲完追问的两颗按钮：把"你懂了吗"变成必须回答的一步 */
.coach-followup { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

/* 打字中的三个点 */
.coach-typing { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.coach-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted, #8b93a7);
  animation: coach-blin 1.1s infinite ease-in-out;
}
.coach-typing i:nth-child(2) { animation-delay: .15s; }
.coach-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes coach-blin { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .coach-typing i { animation: none; }
  .coach-bar-fill { transition: none; }
}
.coach-error { background: #fdecea !important; color: #b3261e !important; }

/* 快捷按钮 */
.coach-quick {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.coach-quick::-webkit-scrollbar { display: none; }
.coach-chip {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 99px;
  background: var(--bg, #fff);
  color: var(--ink-soft, #4a5163);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.coach-chip:hover { border-color: var(--brand, #4d6bfe); color: var(--brand, #4d6bfe); }
.coach-chip.is-primary { background: var(--bubble-user, #eff3ff); border-color: var(--brand, #4d6bfe); color: var(--brand, #4d6bfe); }

/* 输入区 */
.coach-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line, #e6e8ee);
  background: var(--bg, #fff);
}
.coach-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 132px;
  padding: 10px 12px;
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 12px;
  background: var(--bg-side, #f7f8fa);
  color: var(--ink, #1b1e28);
  /* 16px：iOS 上小于 16px 会在聚焦时整页放大 */
  font-size: 16px;
  line-height: 1.45;
  font-family: inherit;
  resize: none;
  outline: none;
}
.coach-input:focus { border-color: var(--brand, #4d6bfe); background: var(--bg, #fff); }
.coach-send {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--brand, #4d6bfe);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.coach-send:active { filter: brightness(.94); }
.coach-send:disabled { opacity: .5; }

/* ── 今日推荐 ─────────────────────────────────────────────────── */
.coach-hint {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted, #8b93a7);
  background: var(--bg-side, #f7f8fa);
  border-radius: 10px;
  padding: 9px 11px;
}
.coach-focus {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink, #1b1e28);
}
.coach-focus-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand, #4d6bfe);
  background: var(--bubble-user, #eff3ff);
  padding: 2px 8px;
  border-radius: 99px;
}
.coach-muted { color: var(--muted, #8b93a7); font-size: 12.5px; }

.coach-recs { display: flex; flex-direction: column; gap: 10px; }
.coach-rec {
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--bg, #fff);
}
.coach-rec-top { display: flex; gap: 8px; align-items: flex-start; }
.coach-rec-num {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand, #4d6bfe);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.coach-rec-title { font-size: 14.5px; line-height: 1.5; font-weight: 700; }
.coach-rec-why { margin-top: 6px; font-size: 12.5px; line-height: 1.55; color: var(--ink-soft, #4a5163); }
.coach-rec-foot {
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.coach-btn {
  padding: 7px 13px;
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 10px;
  background: var(--bg, #fff);
  color: var(--ink-soft, #4a5163);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.coach-btn:hover { border-color: var(--brand, #4d6bfe); }
.coach-btn.is-primary {
  background: var(--brand, #4d6bfe);
  border-color: var(--brand, #4d6bfe);
  color: #fff;
}
.coach-btn:disabled { opacity: .55; cursor: default; }

.coach-card {
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 14px;
  padding: 12px;
  background: var(--bg, #fff);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.coach-card-title { font-size: 14px; font-weight: 800; }
.coach-card-sub { font-size: 12px; color: var(--muted, #8b93a7); }
.coach-empty {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted, #8b93a7);
  border: 1px dashed var(--line, #e6e8ee);
  border-radius: 12px;
  padding: 12px;
}
.coach-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.coach-stat {
  border-radius: 12px;
  background: var(--bg-side, #f7f8fa);
  padding: 9px 10px;
}
.coach-stat-label { font-size: 11.5px; color: var(--muted, #8b93a7); }
.coach-stat-value { font-size: 17px; font-weight: 800; color: var(--ink, #1b1e28); }
.coach-stat-sub { font-size: 11px; color: var(--muted, #8b93a7); line-height: 1.4; }

/* 最近 7 天（7 根小柱子，不做动画） */
.coach-days { display: flex; align-items: flex-end; gap: 6px; height: 62px; }
.coach-day { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.coach-day-bar {
  display: block;
  width: 100%;
  max-width: 26px;
  border-radius: 5px 5px 2px 2px;
  background: var(--brand, #4d6bfe);
  opacity: .75;
}
.coach-day-label { font-size: 10px; color: var(--muted, #8b93a7); }

.coach-timerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coach-num, .coach-input-line {
  padding: 7px 10px;
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 10px;
  background: var(--bg-side, #f7f8fa);
  color: var(--ink, #1b1e28);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}
.coach-num { width: 88px; }
.coach-input-line { width: 100%; font-size: 14px; }

/* 画像表单 */
.coach-field { display: flex; flex-direction: column; gap: 4px; }
.coach-field.is-inline { flex-direction: row; align-items: center; gap: 8px; }
.coach-field-label { font-size: 12px; color: var(--muted, #8b93a7); }
.coach-done { font-size: 13px; font-weight: 700; color: #14693a; }
.coach-base {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft, #4a5163);
  background: var(--bg-side, #f7f8fa);
  border-radius: 10px;
  padding: 9px 11px;
}

/* 徽章 */
.coach-badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.coach-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--bg-side, #f7f8fa);
  opacity: .38;
  filter: grayscale(1);
}
.coach-badge.is-got { opacity: 1; filter: none; background: var(--bubble-user, #eff3ff); }
.coach-badge-icon { font-size: 19px; line-height: 1; }
.coach-badge-name { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.3; }

/* ── 我的弱点 ─────────────────────────────────────────────────── */
.coach-radar-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0 0;
}
.coach-radar { display: block; max-width: 100%; }
.coach-weak-list { display: flex; flex-direction: column; gap: 8px; }
.coach-weak {
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 12px;
  padding: 10px 11px;
  background: var(--bg, #fff);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.coach-weak.is-mastered { opacity: .72; background: var(--bg-side, #f7f8fa); }
.coach-weak-main { min-width: 0; }
.coach-weak-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.coach-weak-name { font-size: 14.5px; }
.coach-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-side, #f7f8fa);
  color: var(--muted, #8b93a7);
}
.coach-tag.is-warn { background: #fff6e5; color: #8a5a00; }
.coach-weak-sub { margin-top: 3px; font-size: 12.5px; color: var(--muted, #8b93a7); line-height: 1.5; }
.coach-weak-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.coach-addweak { display: flex; flex-direction: column; gap: 8px; }
.coach-addrow { display: flex; gap: 8px; }
.coach-select {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line, #e6e8ee);
  border-radius: 10px;
  background: var(--bg-side, #f7f8fa);
  color: var(--ink, #1b1e28);
  font-size: 16px;   /* iOS 防放大 */
  font-family: inherit;
  outline: none;
}

/* ── 宽屏（电脑） ─────────────────────────────────────────────── */
@media (min-width: 760px) {
  .coach-panel {
    /* 电脑上不铺满整屏：留出边距，能看出它是"从侧边栏点开的一层" */
    inset: 24px 0 24px 50%;
    transform: translateX(-50%);
    width: min(760px, calc(100vw - 48px));
    border-radius: 18px;
    border: 1px solid var(--line, #e6e8ee);
    box-shadow: 0 18px 60px rgba(20, 26, 46, .18);
    height: auto;
    max-height: calc(100dvh - 48px);
  }
  .coach-msgs { padding: 16px 18px 6px; }
  .coach-quick, .coach-composer { padding-left: 18px; padding-right: 18px; }
  .coach-tabpane[data-tab="plan"], .coach-tabpane[data-tab="weak"] { padding: 16px 18px; }
  .coach-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .coach-bubble { max-width: 78%; }
}

/* ── 窄屏微调（375） ──────────────────────────────────────────── */
@media (max-width: 420px) {
  .coach-head { padding-left: 10px; padding-right: 10px; }
  .coach-tab-btn { font-size: 13.5px; }
  .coach-bubble { max-width: 92%; }
  .coach-hours-meta { font-size: 11px; }
  .coach-send { padding: 0 13px; }
}

/* [hidden] 兜底：作者样式的 display:flex/grid 会覆盖浏览器默认规则 */
[hidden] { display: none !important; }
