/* 倪海厦中医课程学习站 —— 浅色典籍风 */
:root {
  --bg: #faf7f2;
  --bg-soft: #f3eee5;
  --panel: #ffffff;
  --ink: #2b2724;
  --ink-2: #5c534b;
  --ink-3: #8b8178;
  --line: #e6ded1;
  --line-soft: #f0e9dd;
  --accent: #9c4a32;
  --accent-soft: #f6e8e2;
  --accent-2: #3d6b5c;
  --accent-2-soft: #e6f0eb;
  --warn: #b06820;
  --warn-soft: #fdf2e3;
  --danger: #a33;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 45, 30, .05), 0 6px 20px rgba(60, 45, 30, .05);
  --shadow-lg: 0 8px 40px rgba(60, 45, 30, .12);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: linear-gradient(180deg, #fdfbf7 0%, #f7f2e9 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  overflow-y: auto;
}

.brand { display: flex; gap: 11px; align-items: center; padding: 0 6px 18px; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 9px;
  background: linear-gradient(145deg, #a8543a, #8a3d28);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 21px;
  box-shadow: 0 2px 8px rgba(140, 62, 40, .28);
}
.brand-text h1 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .3px;
  font-family: var(--serif);
}
.brand-text p { margin: 1px 0 0; font-size: 11px; color: var(--ink-3); letter-spacing: .4px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.nav-item .ni { font-size: 13px; color: var(--ink-3); width: 14px; text-align: center; }
.nav-item:hover { background: rgba(160, 120, 80, .07); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active .ni { color: var(--accent); }

.side-stats {
  margin-top: auto;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 12px 6px;
  border-top: 1px solid var(--line-soft);
}
.stat-cell { }
.stat-cell b {
  display: block; font-size: 17px; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -.3px;
}
.stat-cell span { font-size: 10.5px; color: var(--ink-3); letter-spacing: .2px; }

.side-note {
  margin: 6px 4px 0;
  padding: 11px 12px;
  background: var(--warn-soft);
  border: 1px solid #f0dfc4;
  border-radius: 9px;
  font-size: 11px;
  line-height: 1.65;
  color: #7a5524;
}
.side-note strong { display: block; font-size: 11.5px; margin-bottom: 3px; color: var(--warn); }
.side-note p { margin: 0; }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; gap: 10px; align-items: center;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(10px);
  flex: 0 0 auto;
}
.icon-btn {
  display: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); cursor: pointer; font-size: 15px; color: var(--ink-2);
}
.searchbox { display: flex; gap: 8px; flex: 1; max-width: 780px; }
.searchbox input {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  font: inherit; font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.searchbox input::placeholder { color: #b3a99d; }
.searchbox input:focus {
  border-color: #d8b8a8;
  box-shadow: 0 0 0 3px rgba(156, 74, 50, .08);
}

.btn {
  height: 38px;
  padding: 0 17px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .14s;
}
.btn:hover { border-color: #d5c9b8; color: var(--ink); }
.btn.primary {
  background: linear-gradient(145deg, #a8553b, #8e4230);
  border-color: #8e4230;
  color: #fff;
  font-weight: 550;
  box-shadow: 0 1px 4px rgba(140, 62, 40, .22);
}
.btn.primary:hover { background: linear-gradient(145deg, #b25c40, #974735); }
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.view { display: none; flex: 1; overflow-y: auto; padding: 26px 30px 60px; }
.view.active { display: block; }
.view#view-ask.active { display: flex; padding: 0; overflow: hidden; }

/* ---------- hero ---------- */
.hero { max-width: 860px; margin: 12px 0 30px; }
.hero h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 27px; font-weight: 600; letter-spacing: .5px;
}
.hero p { margin: 0 0 16px; color: var(--ink-3); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: all .14s;
}
.chip:hover { border-color: #d8b8a8; background: var(--accent-soft); color: var(--accent); }

/* ---------- 结果 ---------- */
.res-head {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.res-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.kind-tag {
  padding: 2px 9px; border-radius: 20px;
  background: var(--accent-2-soft); color: var(--accent-2);
  font-size: 11.5px; font-weight: 550;
}
.kind-tag.risk { background: var(--warn-soft); color: var(--warn); }
.res-count { color: var(--ink-3); font-size: 12.5px; margin-left: auto; }

.safety-bar {
  display: flex; gap: 9px;
  padding: 11px 14px;
  margin-bottom: 16px;
  background: var(--warn-soft);
  border: 1px solid #f0dfc4;
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  font-size: 12.5px; line-height: 1.65;
  color: #7a5524;
}
.safety-bar b { color: var(--warn); flex: 0 0 auto; }

.structure {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 18px;
  font-size: 12px; color: var(--ink-3);
}
.structure .st-step {
  padding: 3px 10px;
  background: var(--bg-soft);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 11.5px;
}

.card {
  padding: 17px 19px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: #dfd2bf; box-shadow: var(--shadow-lg); }
.card-top {
  display: flex; gap: 9px; align-items: center;
  margin-bottom: 9px;
  flex-wrap: wrap;
}
.src-badge {
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 550;
  white-space: nowrap;
}
.src-badge.tcm { background: var(--accent-2-soft); color: var(--accent-2); }
.risk-badge {
  padding: 2px 8px;
  background: var(--warn-soft); color: var(--warn);
  border-radius: 5px; font-size: 11px; font-weight: 550;
}
.card-ref { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.card-body {
  font-size: 13.8px; line-height: 1.78; color: var(--ink);
  word-break: break-word;
}
.card-body p { margin: 0 0 8px; }
.card-body p:last-child { margin-bottom: 0; }
.card-body ul { margin: 4px 0 8px; padding-left: 19px; }
.card-body li { margin-bottom: 3px; }
.card-body strong { color: #6d2f1e; font-weight: 600; }
.card-body code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-soft); padding: 1px 5px; border-radius: 4px;
}
.card-body table {
  width: 100%; border-collapse: collapse;
  margin: 8px 0; font-size: 12.5px;
}
.card-body th, .card-body td {
  border: 1px solid var(--line);
  padding: 6px 9px; text-align: left; vertical-align: top;
}
.card-body th { background: var(--bg-soft); font-weight: 600; color: var(--ink-2); }
.card-body blockquote {
  margin: 6px 0; padding: 7px 12px;
  border-left: 2px solid var(--line);
  color: var(--ink-2); font-size: 13px;
}
.card-body h4 { margin: 10px 0 5px; font-size: 14px; }
.card-foot {
  display: flex; gap: 8px; align-items: center;
  margin-top: 11px; padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
  font-size: 12px; color: var(--ink-3);
}
.card-foot .mini-btn {
  padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--ink-2);
  font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.card-foot .mini-btn:hover { border-color: #d8b8a8; color: var(--accent); }
.card-foot .spacer { margin-left: auto; }

.empty {
  padding: 48px 20px; text-align: center;
  color: var(--ink-3); font-size: 13.5px;
}
.empty b { display: block; font-size: 15px; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- AI 问答 ---------- */
.ask-wrap { display: flex; flex-direction: column; width: 100%; height: 100%; }
.ask-log { flex: 1; overflow-y: auto; padding: 24px 30px 10px; }
.ask-empty { max-width: 640px; margin: 46px auto; text-align: center; }
.ask-empty-mark {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, #f0e2d8, #e8d5c6);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 23px;
}
.ask-empty h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 19px; font-weight: 600; }
.ask-empty p { margin: 0 0 18px; color: var(--ink-3); font-size: 13px; line-height: 1.75; }
.ask-empty .chips { justify-content: center; }

.turn { max-width: 820px; margin: 0 auto 22px; }
.turn-q {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-bottom: 14px;
}
.turn-q .bubble {
  max-width: 76%;
  padding: 10px 15px;
  background: var(--accent);
  color: #fff;
  border-radius: 13px 13px 3px 13px;
  font-size: 14px;
  line-height: 1.65;
}
.turn-a { display: flex; gap: 11px; }
.avatar {
  width: 29px; height: 29px; flex: 0 0 29px;
  border-radius: 8px;
  background: linear-gradient(145deg, #5c8a78, #3d6b5c);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-family: var(--serif);
  margin-top: 2px;
}
.answer { flex: 1; min-width: 0; }
.answer-body {
  padding: 15px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px 13px 13px 13px;
  box-shadow: var(--shadow);
  font-size: 14.2px; line-height: 1.82;
  word-break: break-word;
}
.answer-body p { margin: 0 0 10px; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body h3, .answer-body h4 {
  margin: 14px 0 7px; font-size: 14.5px; color: #6d2f1e;
}
.answer-body strong { color: #6d2f1e; font-weight: 600; }
.answer-body ul, .answer-body ol { margin: 5px 0 10px; padding-left: 20px; }
.answer-body li { margin-bottom: 4px; }
.answer-body table { width: 100%; border-collapse: collapse; margin: 9px 0; font-size: 13px; }
.answer-body th, .answer-body td {
  border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top;
}
.answer-body th { background: var(--bg-soft); font-weight: 600; }
.answer-body blockquote {
  margin: 8px 0; padding: 8px 13px;
  border-left: 2px solid var(--accent);
  background: var(--bg-soft);
  color: var(--ink-2); font-size: 13.2px;
}
.answer-body code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-soft); padding: 1px 5px; border-radius: 4px;
}
.answer-meta {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  margin-top: 9px; font-size: 11.5px; color: var(--ink-3);
}
.answer-meta .src-pill {
  padding: 2px 8px;
  background: var(--bg-soft);
  border-radius: 5px;
  color: var(--ink-2);
}
.thinking { display: inline-flex; gap: 4px; padding: 3px 0; }
.thinking i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-3); opacity: .45;
  animation: blink 1.3s infinite;
}
.thinking i:nth-child(2) { animation-delay: .18s; }
.thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: .9; } }

.ask-input {
  display: flex; gap: 9px; align-items: flex-end;
  padding: 14px 30px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .8);
}
.ask-input textarea {
  flex: 1;
  max-height: 140px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  font: inherit; font-size: 14px;
  color: var(--ink);
  resize: none;
  outline: none;
  line-height: 1.6;
  transition: border-color .15s, box-shadow .15s;
}
.ask-input textarea:focus {
  border-color: #d8b8a8;
  box-shadow: 0 0 0 3px rgba(156, 74, 50, .08);
}

/* ---------- 通用面板 ---------- */
.pane-head { margin-bottom: 20px; }
.pane-head h2 {
  margin: 0 0 5px;
  font-family: var(--serif);
  font-size: 21px; font-weight: 600; letter-spacing: .4px;
}
.pane-head p { margin: 0; color: var(--ink-3); font-size: 12.8px; }
.pane-head .hint { color: var(--ink-2); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 13px;
}
.shot-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.shot-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #dfd2bf;
}
.shot-img {
  width: 100%; aspect-ratio: 16/10;
  object-fit: cover;
  background: var(--bg-soft);
  display: block;
}
.shot-meta { padding: 10px 12px; }
.shot-lesson {
  font-size: 12px; font-weight: 600; color: var(--accent);
  margin-bottom: 3px;
}
.shot-desc {
  font-size: 12px; line-height: 1.6; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.evi-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.evi-tab {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink-2);
  font-size: 12.5px; font-family: inherit;
  cursor: pointer;
}
.evi-tab.active {
  background: var(--accent-soft);
  border-color: #e5cabb;
  color: var(--accent);
  font-weight: 600;
}

.cite-card {
  padding: 14px 17px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.cite-card .cite-src {
  font-size: 12px; font-weight: 600; color: var(--accent-2);
  margin-bottom: 6px;
}
.cite-card .cite-text {
  font-size: 13px; line-height: 1.78; color: var(--ink);
  font-family: var(--serif);
}
.cite-card .cite-loc {
  margin-top: 8px; font-size: 11px; color: var(--ink-3);
  font-family: var(--mono);
}

/* 模块列表 */
.mod-group { margin-bottom: 26px; }
.mod-group h3 {
  margin: 0 0 10px;
  font-size: 13px; font-weight: 600; color: var(--accent-2);
  letter-spacing: .6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.mod-card {
  padding: 13px 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
}
.mod-card:hover { border-color: #dfd2bf; box-shadow: var(--shadow); transform: translateY(-1px); }
.mod-card b { display: block; font-size: 13.5px; margin-bottom: 3px; font-weight: 600; }
.mod-card span { font-size: 11.8px; color: var(--ink-3); line-height: 1.55; display: block; }
.mod-card .mod-stat {
  margin-top: 7px; font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* 阅读器 */
.reader-head { display: flex; gap: 14px; align-items: flex-start; }
.reader-body {
  max-width: 820px;
  font-size: 14.2px; line-height: 1.85;
}
.reader-body h1 { font-family: var(--serif); font-size: 23px; margin: 26px 0 10px; }
.reader-body h2 {
  font-family: var(--serif); font-size: 18px; margin: 28px 0 10px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.reader-body h3 { font-size: 15px; margin: 20px 0 8px; color: #6d2f1e; }
.reader-body p { margin: 0 0 11px; }
.reader-body ul, .reader-body ol { padding-left: 22px; margin: 6px 0 12px; }
.reader-body li { margin-bottom: 5px; }
.reader-body table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px;
}
.reader-body th, .reader-body td {
  border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top;
}
.reader-body th { background: var(--bg-soft); font-weight: 600; }
.reader-body blockquote {
  margin: 10px 0; padding: 9px 14px;
  border-left: 2px solid var(--accent);
  background: var(--bg-soft);
  color: var(--ink-2); font-size: 13.2px;
}
.reader-body code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-soft); padding: 1px 5px; border-radius: 4px;
}
.reader-body strong { color: #6d2f1e; }
.reader-body hr { border: 0; border-top: 1px solid var(--line-soft); margin: 22px 0; }

/* 灯箱 */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(30, 24, 18, .88);
  z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 30px;
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%; max-height: 82vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.lb-close {
  position: absolute; top: 18px; right: 22px;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 21px; line-height: 1;
  cursor: pointer;
}
.lb-cap {
  margin-top: 14px; color: #e8ded2;
  font-size: 12.8px; text-align: center; max-width: 620px;
}

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #ddd2c2; border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #cbbda9; }

/* 响应式 */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 6px 0 30px rgba(0, 0, 0, .1);
  }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: block; }
  .view { padding: 20px 16px 50px; }
  .ask-log { padding: 18px 16px 8px; }
  .ask-input { padding: 12px 16px 16px; }
  .topbar { padding: 11px 14px; }
  .hero h2 { font-size: 22px; }
  .turn-q .bubble { max-width: 88%; }
}
