/*
  内部培训助手 · 样式
  只保留本产品用到的类。改结构时请同步 index.html / chat/render.js。
*/
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --ink: #1a1e2c;
  --ink-2: #585f76;
  --ink-3: #8a90a6;
  --line: #e4e7f2;
  --brand: #3b4ba8;
  --brand-deep: #2c3a8c;
  --brand-soft: #eceffb;
  --accent: #c9762a;
  --accent-soft: #fdf2e6;
  --warn: #b45309;
  --warn-soft: #fef6e7;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(26, 30, 44, 0.06), 0 6px 18px rgba(26, 30, 44, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 撑满视口、内部滚动（不能用 #app：index.html 里是 class） */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
}
/* 顶栏下沿的品牌渐变细线，替代提招助手的绿 */
.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, #3b4ba8 0%, #6a76d6 48%, #c9762a 100%);
  opacity: 0.9;
}
.brand-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.brand { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
  background: #f2f3fa;
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: #c9cde0; flex: 0 0 auto; }
.dot.ok { background: var(--brand); box-shadow: 0 0 0 3px rgba(59, 75, 168, 0.14); }
.dot.warn { background: var(--accent); box-shadow: 0 0 0 3px rgba(201, 118, 42, 0.16); }

/* ---------- 消息流 ---------- */
.stream {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 10px;
  overscroll-behavior: contain;
}

.msg { display: flex; margin-bottom: 14px; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }

.bubble {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.user .bubble {
  background: linear-gradient(135deg, #4454b4 0%, #2f3d92 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(59, 75, 168, 0.22);
}

.blocks { display: flex; flex-direction: column; gap: 10px; max-width: 92%; min-width: 0; }
/* 助手侧卡片要撑满可用宽度，否则卡片会缩到内容宽度、右边留一大片空 */
.msg.assistant .blocks { flex: 1 1 auto; }

.block-text { white-space: pre-wrap; word-break: break-word; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-head {
  padding: 12px 14px 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.card-title { font-weight: 600; font-size: 15px; flex: 1; line-height: 1.4; }
.card-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-weight: 400; line-height: 1.45; }
.card-body { padding: 0 14px 12px; font-size: 14px; color: var(--ink-2); }
.card-body p { margin: 0 0 8px; }
.card-body p:last-child { margin-bottom: 0; }
.card-foot {
  padding: 0 14px 12px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

/* 提示条 */
.notice {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.55;
}

/* 追问 chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.chip:active { background: #eef1f4; }
.chip.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- 知识卡 ---------- */
.kb { padding: 12px 14px; border-top: 1px solid var(--line); }
.kb:first-of-type { border-top: none; }
.kb.compact { padding: 10px 0 4px; border-top: none; }
.kb-head { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.kb-cat {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  line-height: 1.7;
}
.kb-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.kb-body { margin-top: 6px; }
.kb-body p { margin: 0 0 5px; font-size: 13px; color: var(--ink-2); line-height: 1.68; white-space: pre-wrap; }
.kb-body p:last-child { margin-bottom: 0; }
.kb-foot { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 7px; font-size: 11px; color: var(--ink-3); }
.kb-fold { border-top: 1px solid var(--line); }
.kb-fold summary {
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1.5;
}
.kb-fold[open] summary { color: var(--brand); }
.kb-fold .kb { padding: 0 14px 10px; }

/* ---------- 分类总览 ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px 14px 14px;
}
.cat-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
}
.cat-cell:active { background: var(--brand-soft); border-color: #c3cae8; }
.cat-cell .n { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.cat-cell .c { flex: 0 0 auto; font-size: 11.5px; color: var(--ink-3); }
.cat-cell.empty { border-style: dashed; background: #fff; }
.cat-cell.empty .n { color: var(--ink-3); font-weight: 500; }
.cat-cell.empty .c { color: #c2c6d8; }
/* 分类数是奇数时，最后一格跨两列，避免右下角空一块 */
.cat-grid > .cat-cell:last-child:nth-child(odd) { grid-column: span 2; }

/* ---------- 培训框架树 ---------- */
.frame { padding: 2px 0 12px; }
.frame-mod { border-top: 1px solid var(--line); }
.frame-mod:first-child { border-top: none; }
.frame-mod > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}
.frame-mod > summary::-webkit-details-marker { display: none; }
.frame-mod > summary::before {
  content: '▸';
  color: var(--ink-3);
  font-size: 10px;
}
.frame-mod[open] > summary::before { content: '▾'; }
.frame-mod .sum { flex: 1; min-width: 0; line-height: 1.45; }
.frame-mod .note {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 2px;
}
.frame-mod .badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.frame-mod .badge.todo { background: var(--accent-soft); color: var(--accent); }
.frame-list { padding: 0 16px 8px 34px; }
.frame-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 0;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  line-height: 1.55;
}
.frame-item:first-child { border-top: none; }
.frame-item .t { flex: 1; min-width: 0; color: var(--ink-2); }
.frame-item.has .t { color: var(--ink); }
.frame-item .st { flex: 0 0 auto; font-size: 11px; color: var(--ink-3); }
.frame-item.has .st { color: var(--brand); }
.frame-empty { padding: 4px 14px 10px; font-size: 12px; color: var(--ink-3); }

/* ---------- 云端库结果（专业数据 / 考纲） ---------- */
.lookup { display: flex; flex-direction: column; gap: 10px; }

.mj-list { padding: 0 0 2px; }
.mj { padding: 10px 14px; border-top: 1px solid var(--line); }
.mj:first-child { border-top: none; }
.mj-top { display: flex; align-items: baseline; gap: 6px; }
.mj-name { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.mj-college { font-size: 12px; color: var(--brand); margin-top: 2px; font-weight: 600; }
.mj-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-2);
}
.mj-meta .hot { color: var(--accent); font-weight: 700; }
.mj-meta.dim { color: var(--ink-3); font-size: 11.5px; margin-top: 3px; }

.kg2 { padding: 10px 14px; border-top: 1px solid var(--line); }
.kg2:first-of-type { border-top: none; }
.kg2-name { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.kg2-info {
  margin-top: 5px;
  font-size: 12px;
  color: var(--ink-2);
  background: #f5f6fc;
  border-radius: 8px;
  padding: 7px 9px;
  line-height: 1.55;
}
.kg2-sec { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.kg2-sec b { color: var(--ink-3); font-weight: 500; }

/* ---------- 输入栏 ---------- */
.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: 96px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f7f9fa;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.45;
}
.composer textarea:focus { border-color: var(--brand); background: #fff; }
.composer .send {
  width: 58px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #4454b4 0%, #2f3d92 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex: 0 0 auto;
}
.composer .send:disabled { opacity: 0.4; }

/* 语音按钮 */
.mic {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f7f8fd;
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.mic:active { background: var(--brand-soft); }
.mic.on {
  background: #b42318;
  border-color: #b42318;
  color: #fff;
  animation: micpulse 1.1s infinite;
}
@keyframes micpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(180, 35, 24, 0); }
}

/* ---------- 加载点 ---------- */
.typing { display: inline-flex; gap: 3px; align-items: center; height: 18px; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3);
  animation: bounce 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.empty-tip { text-align: center; color: var(--ink-3); font-size: 13px; padding: 24px 16px; line-height: 1.7; }

@media (max-width: 360px) {
  .cat-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
