/* OPC PWA · 学员端样式（手机优先 ≥375px，桌面 ≥768px 自适应） */
:root {
  --navy: #0E1B2E;
  --navy2: #16273f;
  --gold: #C9A24B;
  --gold2: #e0bd6f;
  --bg: #f5f7fa;
  --card: #ffffff;
  --line: #e3e8ef;
  --muted: #6b7686;
  --ok: #2e9e6b;
  --warn: #d98a2b;
  --bad: #d9534f;
  --info: #2e6bd9;
  --shadow: 0 2px 10px rgba(14, 27, 46, 0.08);
  --shadow-lg: 0 8px 30px rgba(14, 27, 46, 0.15);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(76px + var(--safe-bottom));  /* 给底部 nav 留位 */
}
a { color: inherit; text-decoration: none; }

/* ============== 顶部 header（手机紧凑） ============== */
.app-header {
  background: linear-gradient(120deg, var(--navy), var(--navy2));
  color: #fff;
  padding: calc(10px + var(--safe-top)) 16px 14px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow-lg);
}
.app-header .row { display: flex; align-items: center; gap: 10px; }
.app-header .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: var(--navy); display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
}
.app-header h1 { margin: 0; font-size: 17px; font-weight: 700; }
.app-header .sub { font-size: 11px; opacity: .8; margin-top: 2px; }
.app-header .picker { margin-top: 8px; display: flex; gap: 8px; }
.app-header select {
  flex: 1; padding: 7px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08); color: #fff;
  font-size: 12px;
}
.app-header select option { color: var(--navy); background: #fff; }

/* ============== Main ============== */
main { padding: 12px 14px; }
.page-title { font-size: 20px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -.3px; }
.page-sub { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }

/* ============== Tab bar bottom-nav ============== */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 30; padding-bottom: var(--safe-bottom);
}
.tab-bar a {
  flex: 1; padding: 10px 0 8px; text-align: center; font-size: 11px;
  color: var(--muted); font-weight: 600;
}
.tab-bar a.active { color: var(--navy); }
.tab-bar a.active::before { content: ""; display: block; width: 24px; height: 3px; background: var(--gold); border-radius: 2px; margin: -7px auto 4px; }
.tab-bar svg { display: block; margin: 0 auto 4px; }

/* ============== User chip top right ============== */
.user-chip {
  position: fixed; top: calc(8px + var(--safe-top)); right: 12px; z-index: 25;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.16); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
  padding: 4px 10px 4px 4px; border-radius: 24px;
  color: #fff; font-size: 12px;
  cursor: pointer;
}
.user-chip .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--gold); color: var(--navy);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 11px;
}
.user-chip-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--card); color: var(--navy);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; min-width: 160px; box-shadow: var(--shadow-lg);
  display: none;
}
.user-chip-menu.open { display: block; }
.user-chip-menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--navy); font-size: 13px; }
.user-chip-menu a:hover { background: var(--bg); }

/* ============== Desktop nav (>=768) ============== */
body.lg .app-header { position: relative; }
body.lg .user-chip { top: 14px; }
body.lg .tab-bar { display: none; }
body.lg .desktop-nav { display: flex; }
.desktop-nav {
  display: none; position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding: 10px 18px; gap: 4px;
}
.desktop-nav a {
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  font-weight: 600; color: var(--muted); cursor: pointer;
}
.desktop-nav a.active { background: var(--navy); color: #fff; }
body.lg main { max-width: 720px; margin: 0 auto; }

/* ============== FAB ============== */
.fab-coach {
  position: fixed; right: 18px; bottom: calc(82px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: var(--navy); display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  box-shadow: var(--shadow-lg); cursor: pointer; z-index: 25;
  border: 2px solid #fff;
}

/* ============== CHAT V3 (DeepSeek 真打) ============== */
.chat {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 420px;
}
.chat-stream {
  display: flex; flex-direction: column; gap: 12px;
  flex: 1; overflow-y: auto; padding: 12px;
  background: linear-gradient(180deg, var(--bg) 0%, #eef2f7 100%);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.bubble {
  max-width: 88%; padding: 12px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.6; word-wrap: break-word;
  position: relative; box-shadow: var(--shadow);
}
.bubble.me {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%);
  color: var(--navy); margin-left: auto;
  border-bottom-right-radius: 4px;
}
.bubble.ai {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfd 100%);
  color: var(--navy);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  border-left: 3px solid var(--gold);
}
/* AI 内嵌元素 */
.bubble.ai strong { color: var(--navy); font-weight: 700; }
.bubble.ai code { background: rgba(14,27,46,.06); padding: 2px 6px; border-radius: 4px; font-size: 13px; color: var(--navy2); }

/* AI 模型徽章 + 延迟 */
.llm-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 2px 8px;
  background: rgba(46, 107, 217, .12); color: var(--info);
  border-radius: 8px; font-weight: 700;
  margin-left: 6px; vertical-align: middle;
}
.llm-badge.error { background: rgba(217, 83, 79, .12); color: var(--bad); }
.llm-badge .latency { color: var(--muted); font-weight: 500; }

/* RAG 引用来源卡片 */
.rag-sources {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}
.rag-sources .src-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  cursor: pointer; user-select: none;
  margin-bottom: 4px;
}
.rag-sources .src-title::before {
  content: "📎"; font-size: 11px;
}
.rag-sources .src-title .count {
  background: var(--gold); color: var(--navy);
  padding: 1px 6px; border-radius: 8px; font-size: 10px;
  font-weight: 800;
}
.rag-sources .src-title .toggle {
  margin-left: auto; color: var(--muted); transition: transform .2s;
}
.rag-sources.open .src-title .toggle { transform: rotate(180deg); }
.rag-sources .src-list {
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
}
.rag-sources.open .src-list { max-height: 600px; overflow-y: auto; }
.rag-sources .src-item {
  background: var(--bg); border-left: 2px solid var(--gold);
  padding: 8px 10px; margin-bottom: 6px;
  border-radius: 6px; font-size: 12px; line-height: 1.55;
}
.rag-sources .src-item .src-label {
  display: inline-block; background: var(--navy); color: var(--gold);
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  margin-bottom: 4px; font-weight: 700;
}
.rag-sources .src-item .src-text { color: var(--navy); font-weight: 400; }

.bubble .src {
  display: block; font-size: 11px; color: var(--muted);
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
}

/* 输入区 */
.chat-input {
  display: flex; gap: 8px; margin-top: 8px;
  align-items: stretch;
}
.chat-input input {
  flex: 1; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 24px; font-size: 15px; outline: none;
  background: #fff; transition: border-color .15s;
}
.chat-input input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201,162,75,.12); }
.chat-input button {
  padding: 0 22px; border: none; border-radius: 24px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .15s;
}
.chat-input button:hover:not(:disabled) { transform: scale(1.04); }
.chat-input button:disabled { opacity: .5; cursor: not-allowed; }

/* 快捷提问 chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: #fff;
  border-radius: 18px; padding: 7px 12px;
  font-size: 12px; cursor: pointer; color: var(--navy);
  transition: all .15s;
}
.chips button:hover { border-color: var(--gold); background: #fffbf0; transform: translateY(-1px); }

/* 历史侧边浮层 */
.history-trigger {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255,255,255,.2); color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 4px 10px; border-radius: 16px;
  font-size: 11px; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}
.history-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 88%; max-width: 340px;
  background: var(--card); z-index: 50;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  box-shadow: -8px 0 30px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
}
.history-drawer.open { transform: translateX(0); }
.history-drawer .head {
  background: var(--navy); color: var(--gold);
  padding: 18px 16px 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.history-drawer .close { cursor: pointer; font-size: 20px; }
.history-drawer .body { flex: 1; overflow-y: auto; padding: 10px; }
.history-drawer .item {
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg); margin-bottom: 8px;
  cursor: pointer; font-size: 13px;
}
.history-drawer .item:hover { background: #e8eef5; }
.history-drawer .item .q { font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.history-drawer .item .a { color: var(--muted); font-size: 12px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.history-drawer .empty { text-align: center; color: var(--muted); padding: 40px 0; }
.history-drawer .backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40;
  display: none;
}
.history-drawer.open + .backdrop { display: block; }

/* 流式输出 + typing dots */
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 6px; height: 6px; background: var(--gold); border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* V4 SSE 流式光标：教练"正在说"的金色竖条 */
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  background: var(--gold);
  vertical-align: -2px;
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(201, 162, 75, .55);
  animation: caretBlink 0.85s steps(1, end) infinite;
}
@keyframes caretBlink {
  0%, 50%   { opacity: 1; }
  51%, 100% { opacity: 0; }
}
/* 流式结束后整段保留色调：最后一个字自然消失后 caret 自动移除，无残留 */
.caret-done { animation: none; opacity: 0; transition: opacity .25s ease; }

/* ============== V5 主动 push 角标 + 模态框 ============== */
.push-bell {
  position: relative;
  margin-left: auto;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  padding: 6px 10px 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.push-bell:hover { background: rgba(201, 162, 75, .25); border-color: var(--gold); }
.push-bell .bell-icon { font-size: 16px; }
.push-bell .bell-count {
  background: #ff4757;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(14, 27, 46, 1);
}
.push-bell.bell-pulse {
  animation: bellShake 0.5s ease-in-out 3;
}
@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-15deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(5deg); }
}

.push-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.push-modal-mask {
  position: absolute; inset: 0;
  background: rgba(14, 27, 46, .55);
  backdrop-filter: blur(6px);
  animation: fadeIn .25s ease;
}
.push-modal-card {
  position: relative;
  width: 100%; max-width: 480px;
  max-height: 80vh;
  background: linear-gradient(180deg, #fff 0%, #fdfaf2 100%);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(14, 27, 46, .25);
  display: flex; flex-direction: column;
  animation: slideUp .35s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--safe-bottom);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.push-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 800; color: var(--navy);
}
.push-modal-head::before {
  content: ""; display: inline-block;
  width: 3px; height: 14px;
  background: linear-gradient(180deg, var(--gold), var(--gold2));
  margin-right: 8px; border-radius: 2px;
}
.push-modal-close {
  background: var(--bg); border: none; border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 14px; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.push-modal-body {
  flex: 1; overflow-y: auto;
  padding: 18px 18px 12px;
  font-size: 14px; line-height: 1.85;
  color: var(--navy);
}
.push-streaming {
  white-space: pre-wrap;
  word-break: break-word;
}
.push-modal-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end;
}
.push-modal-read {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: var(--navy);
  border: none; border-radius: 999px;
  padding: 10px 24px;
  font-size: 13px; font-weight: 800; letter-spacing: .5px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(201, 162, 75, .35);
  transition: transform .15s ease;
}
.push-modal-read:hover { transform: translateY(-1px); }
.push-modal-read:active { transform: translateY(0); }

/* ============== V3 学员档案 Banner + Pill ============== */
.ctx-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #fff 0%, var(--accent-soft, rgba(201,162,75,.10)) 100%);
  border: 1.5px solid var(--gold);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 8px 0 12px;
  box-shadow: 0 2px 12px rgba(201,162,75,.18);
}
.ctx-banner-icon {
  font-size: 28px; line-height: 1; flex: 0 0 auto;
  filter: drop-shadow(0 2px 4px rgba(201,162,75,.3));
}
.ctx-banner-content { flex: 1; min-width: 0; }
.ctx-banner-title {
  font-size: 11px; font-weight: 800; letter-spacing: .5px;
  color: var(--navy2, #16273f); text-transform: uppercase;
  margin-bottom: 4px;
}
.ctx-banner-sub {
  font-size: 13px; color: var(--navy); font-weight: 600; line-height: 1.5;
}
.ctx-banner-sub b { color: var(--gold); font-weight: 800; }

/* AI 气泡内嵌档案 chips */
.ctx-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.ctx-pill {
  display: inline-flex; align-items: center;
  background: var(--navy); color: var(--gold);
  font-size: 10px; font-weight: 800;
  padding: 2px 8px; border-radius: 10px;
  letter-spacing: .4px;
}
.ctx-pill-gold { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: var(--navy); }
.ctx-pill-blue { background: #2E6BD9; color: #fff; }
.ctx-pill-ok { background: var(--ok, #2e9e6b); color: #fff; }
.ctx-meta {
  font-size: 10px; color: var(--muted); font-weight: 500;
  margin-left: 4px;
}

/* ============== 证书 ============== */
.cert-card {
  background: linear-gradient(135deg, #fff 0%, #fcf9f1 100%);
  border: 2px solid var(--gold); border-radius: 16px;
  padding: 22px 18px; text-align: center;
  position: relative; box-shadow: var(--shadow-lg);
  margin-bottom: 14px;
}
.cert-card::before, .cert-card::after {
  content: ""; position: absolute; width: 24px; height: 24px;
  border: 2px solid var(--gold);
}
.cert-card::before { top: 8px; left: 8px; border-right: 0; border-bottom: 0; }
.cert-card::after { bottom: 8px; right: 8px; border-left: 0; border-top: 0; }

.cert-name { font-size: 22px; font-weight: 800; color: var(--navy); margin: 12px 0 6px; }
.cert-meta { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.cert-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.cert-stats .stat { padding: 8px 6px; background: var(--bg); border-radius: 8px; }
.cert-stats .num { font-size: 18px; font-weight: 800; color: var(--gold); }
.cert-stats .lbl { font-size: 10px; color: var(--muted); }

/* ============== 进度环 ============== */
.progress-ring { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 10; }
.progress-ring .track { stroke: var(--line); }
.progress-ring .bar {
  stroke: var(--gold); stroke-linecap: round;
  transition: stroke-dashoffset .8s cubic-bezier(.4,0,.2,1);
}
.progress-ring .num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800; color: var(--navy);
  flex-direction: column; line-height: 1;
}
.progress-ring .pct { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; letter-spacing: 1px; }

/* ============== 任务 ============== */
.task-day {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}
.task-day .day-no {
  flex: 0 0 50px; text-align: center; background: var(--navy); color: var(--gold);
  border-radius: 10px; padding: 8px 6px;
}
.task-day .day-no .n { font-size: 18px; font-weight: 800; line-height: 1; }
.task-day .day-no .lbl { font-size: 9px; opacity: .8; margin-top: 2px; }
.task-day .info { flex: 1; }
.task-day .info h3 { margin: 0; font-size: 14px; font-weight: 700; }
.task-day .info p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.task-day .status {
  flex: 0 0 auto; padding: 4px 10px; border-radius: 8px;
  font-size: 11px; font-weight: 700;
}
.task-day .status.done { background: rgba(46,158,107,.15); color: var(--ok); }
.task-day .status.doing { background: rgba(217,138,43,.15); color: var(--warn); }
.task-day .status.todo { background: var(--bg); color: var(--muted); }

/* ============== 工具 ============== */
.spacer { height: 80px; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 40px 0; color: var(--muted); }

/* 4 节点 timeline */
.timeline {
  display: flex; justify-content: space-between; position: relative;
  margin: 20px 0;
}
.timeline::before {
  content: ""; position: absolute; top: 12px; left: 6%; right: 6%;
  height: 2px; background: var(--line); z-index: 0;
}
.timeline .node { position: relative; z-index: 1; text-align: center; flex: 1; }
.timeline .node .dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--line);
  margin: 0 auto 6px;
}
.timeline .node.done .dot { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 0 4px rgba(46,158,107,.18); }
.timeline .node.doing .dot { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 4px rgba(201,162,75,.18); }
.timeline .node .name { font-size: 11px; font-weight: 700; }
.timeline .node .n { font-size: 9px; color: var(--muted); }