/* 毛概历史学习时间轴 - 样式 */
:root {
  --bg: #faf7f2;
  --panel: #ffffff;
  --ink: #2b2320;
  --ink-soft: #6b5f58;
  --line: #e7dfd6;
  --red: #b91c1c;
  --red-deep: #7f1d1d;
  --gold: #b45309;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(60, 34, 20, 0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 60%, #c2410c 100%);
  color: #fff; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.topbar h1 { font-size: 21px; letter-spacing: 1px; }
.sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#searchBox {
  width: min(340px, 60vw); padding: 9px 14px; border: none; border-radius: 999px;
  font-size: 13px; outline: none; background: rgba(255,255,255,.92);
}
.ghost-btn {
  padding: 8px 14px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px;
  background: transparent; color: #fff; cursor: pointer; font-size: 13px;
  transition: background .2s;
}
.ghost-btn:hover { background: rgba(255,255,255,.14); }

/* ---------- 时代导航 ---------- */
.era-nav { display: flex; gap: 8px; padding: 10px 22px 0; flex-wrap: wrap; }
.era-nav button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; cursor: pointer; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px;
}
.era-nav button:hover { border-color: currentColor; }
.era-nav .swatch { width: 10px; height: 10px; border-radius: 50%; }

/* ---------- 时间轴 ---------- */
.timeline-wrap { padding: 10px 0 0; }
.timeline-scroll {
  overflow-x: auto; overflow-y: hidden;
  cursor: grab; position: relative;
  background:
    linear-gradient(180deg, #fffdf9 0%, #faf5ec 100%);
  border-block: 1px solid var(--line);
  box-shadow: inset 0 10px 18px -14px rgba(0,0,0,.25);
}
.timeline-scroll.dragging { cursor: grabbing; }
.timeline-scroll::-webkit-scrollbar { height: 9px; }
.timeline-scroll::-webkit-scrollbar-thumb { background: #d8c8b4; border-radius: 99px; }
.timeline {
  position: relative; height: 190px;
  width: max-content; padding: 0 60px;
  user-select: none;
}
.era-band {
  position: absolute; top: 14px; height: 26px; border-radius: 8px;
  color: #fff; font-size: 11px; line-height: 26px; text-align: center;
  white-space: nowrap; overflow: hidden; padding: 0 6px; opacity: .95;
}
.axis { position: absolute; left: 30px; right: 30px; top: 118px; height: 3px;
  background: linear-gradient(90deg,#caa 0%, #a33 8%, #a33 92%, #caa 100%); border-radius: 3px; }
.year-col { position: absolute; top: 0; width: 34px; height: 100%; }
.year-col .tick { position: absolute; top: 108px; left: 50%; width: 2px; height: 8px; background: #d3b9a3; transform: translateX(-50%); }
.year-col .dot {
  position: absolute; top: 111px; left: 50%; transform: translate(-50%,-50%);
  border-radius: 50%; cursor: pointer; transition: transform .15s;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.28);
}
.year-col .dot.empty { width: 7px; height: 7px; background: #cbb6a2; border: none; box-shadow: none; top: 119.5px; cursor: pointer; }
.year-col .dot.has { width: 13px; height: 13px; }
.year-col .dot.has.imp2 { width: 16px; height: 16px; }
.year-col .dot.has.imp3 { width: 19px; height: 19px; }
.year-col .dot:hover { transform: translate(-50%,-50%) scale(1.5); z-index: 5; }
.year-col .yr { position: absolute; top: 132px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: #a8968a; white-space: nowrap; }
.year-col .yr.decade { font-size: 12px; font-weight: 700; color: var(--ink); }
.year-col .star { position: absolute; top: 88px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: var(--gold); }
.today-line { position: absolute; top: 74px; bottom: 44px; width: 2px; background: #16a34a; opacity: .65; }
.today-label { position: absolute; top: 56px; transform: translateX(-50%); font-size: 10px; color: #16a34a; font-weight: 700; }
.scroll-hint { text-align: center; font-size: 11.5px; color: var(--ink-soft); padding: 8px 0 2px; }
.scroll-hint .star { color: var(--gold); }

/* 年份悬浮提示 */
.hover-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #3b2b23; color: #fff; font-size: 12px; line-height: 1.5;
  padding: 8px 12px; border-radius: 10px; max-width: 280px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); display: none;
}
.hover-tip b { color: #ffd9a0; }

/* ---------- 年份面板 ---------- */
.year-panel { flex: 1; padding: 14px 22px 20px; }
.year-panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.year-panel-head h2 { font-size: 19px; color: var(--red-deep); }
.era-tag { font-size: 12px; padding: 3px 12px; border-radius: 999px; color: #fff; }
.placeholder { color: var(--ink-soft); padding: 26px 0; text-align: center; }
.year-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.era-blurb {
  grid-column: 1 / -1; background: #fff; border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 16px 18px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.8;
}
.era-blurb b { color: var(--red-deep); }
.event-card {
  background: var(--panel); border-radius: var(--radius); padding: 15px 17px;
  border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(80,50,30,.06);
  cursor: pointer; transition: transform .16s, box-shadow .16s; position: relative;
}
.event-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #e5b8a5; }
.event-card h3 { font-size: 15.5px; color: var(--ink); margin-bottom: 6px; padding-right: 26px; }
.event-card .date { font-size: 12px; color: var(--red); font-weight: 600; margin-bottom: 6px; }
.event-card p { font-size: 12.8px; color: var(--ink-soft); line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.event-card .open-ai { position: absolute; right: 14px; top: 14px; font-size: 17px; }
.imp-star { color: var(--gold); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(40,24,14,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  backdrop-filter: blur(3px);
}
.modal {
  position: relative;
  background: var(--bg); border-radius: 18px; width: min(1180px, 96vw);
  height: min(88vh, 860px); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.35); animation: pop .22s ease;
}
.close-x {
  position: absolute; top: 16px; right: 18px; z-index: 6;
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.2); color: #fff; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .2s;
}
.close-x:hover { background: rgba(255,255,255,.4); transform: rotate(90deg); }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.small-modal { width: min(520px, 94vw); height: auto; max-height: 88vh; }
.modal-head { padding: 16px 20px 12px; background: linear-gradient(135deg, #7f1d1d, #b91c1c); color: #fff; }
.back-btn { background: rgba(255,255,255,.15); border: none; color: #fff; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; margin-bottom: 10px; }
.back-btn:hover { background: rgba(255,255,255,.28); }
.modal-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.modal-year { font-size: 26px; font-weight: 800; font-family: Georgia, serif; }
.modal-title h2 { font-size: 18px; font-weight: 600; }
.modal-chips { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.modal-chips span { background: rgba(255,255,255,.16); padding: 3px 10px; border-radius: 999px; font-size: 11.5px; }
.modal-tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); }
.modal-tabs button {
  flex: 1; padding: 12px 6px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--ink-soft); border-bottom: 3px solid transparent;
}
.modal-tabs button.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; background: #fff7f0; }
.modal-tabs button.ai-tab .dot-badge { display: none; width: 8px; height: 8px; background: #22c55e; border-radius: 50%; margin-left: 4px; }
.modal-tabs button.ai-tab .dot-badge.on { display: inline-block; }
.modal-body { flex: 1; overflow: hidden; position: relative; }
.tab-pane { position: absolute; inset: 0; overflow-y: auto; padding: 20px 24px 30px; display: none; }
.tab-pane.active { display: block; }
.tab-pane.ai-pane { padding: 0; display: none; }
.tab-pane.ai-pane.active { display: flex; }

.ev-date { font-size: 13px; color: var(--red); font-weight: 600; margin-bottom: 10px; }
.ev-text { font-size: 14.5px; line-height: 2; color: #3c332e; }
.ev-text b { color: var(--red-deep); }
.section-label {
  font-size: 13px; font-weight: 700; color: var(--red-deep);
  margin: 18px 0 8px; padding-left: 10px; border-left: 4px solid var(--red);
}
.nav-row { display: flex; justify-content: space-between; margin-top: 26px; gap: 10px; }
.nav-row .ghost-btn { border-color: #d9c6b8; color: var(--ink-soft); }
.chapter-list { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.chapter-list span { background: #fdeee4; color: #9a3412; font-size: 12px; padding: 4px 12px; border-radius: 999px; }

/* Q&A */
.qa-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.qa-item summary { padding: 13px 16px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink); list-style: none; display: flex; gap: 8px; }
.qa-item summary::before { content: "❓"; }
.qa-item summary .kp-tag { background: #fdeee4; color: #9a3412; font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.qa-item[open] summary { background: #fff7f0; color: var(--red-deep); }
.qa-item .a { padding: 14px 18px; font-size: 13.8px; line-height: 1.95; color: #4a403a; border-top: 1px dashed var(--line); }
.qa-item .a::before { content: "💡 "; }

/* ---------- AI 聊天 ---------- */
.chat { flex: 1; display: flex; flex-direction: column; width: 100%; background: #f6f1e9; }
.chat-status {
  position: relative; font-size: 11.5px; text-align: center; padding: 6px 74px;
  color: var(--ink-soft); background: #efe7db;
}
#newChatBtn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 1px solid #d8c3ae; background: #fff; color: #8a4b2b; font-size: 11.5px;
  padding: 3px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
#newChatBtn:hover { background: #fdeee4; border-color: #c99; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: 13.8px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--red); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant.offline { background: #fdf6e3; border-color: #e8d19a; }
.msg.assistant b { color: var(--red-deep); }
.msg.typing { color: var(--ink-soft); }
.chat-suggest { display: flex; gap: 8px; padding: 8px 14px; flex-wrap: wrap; border-top: 1px dashed var(--line); background: #faf6ef; }
.chat-suggest button {
  border: 1px solid #dcc7b2; background: #fff; color: #8a4b2b; font-size: 12px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.chat-suggest button:hover { background: #fdeee4; }
.chat-input { display: flex; gap: 10px; padding: 12px 14px; background: #fff; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 13.8px; font-family: inherit; max-height: 110px; outline: none;
}
.chat-input textarea:focus { border-color: var(--red); }
.chat-input button {
  background: var(--red); color: #fff; border: none; border-radius: 12px;
  padding: 10px 20px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.chat-input button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 设置 / 帮助 ---------- */
.settings-body { padding: 18px 22px 22px; overflow-y: auto; }
.settings-body .hint { font-size: 12.5px; color: var(--ink-soft); line-height: 1.7; margin-bottom: 14px; }
.settings-body label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--ink); }
.settings-body input {
  width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; outline: none; font-family: inherit;
}
.settings-body input:focus { border-color: var(--red); }
.preset-row { font-size: 12.5px; color: var(--ink-soft); margin: 4px 0 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.preset-row button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.preset-row button:hover { border-color: var(--red); color: var(--red); }
.settings-actions { display: flex; justify-content: space-between; gap: 10px; }
.primary-btn { background: var(--red); color: #fff; border: none; padding: 10px 26px; border-radius: 10px; font-size: 14px; cursor: pointer; font-weight: 600; }
.primary-btn:hover { background: var(--red-deep); }
.settings-actions .ghost-btn { border-color: #d9c6b8; color: var(--ink-soft); }
.help-text { font-size: 13.8px; line-height: 2; }
.help-text li { margin-bottom: 6px; }
.help-text .star { color: var(--gold); }

.footer { text-align: center; font-size: 11.5px; color: #a8968a; padding: 10px 0 14px; }

/* ---------- 知识点（毛概补充 tab + 知识库） ---------- */
.kp-item {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--gold);
  border-radius: 10px; padding: 12px 15px; margin-bottom: 10px;
}
.kp-label { font-size: 12px; font-weight: 700; color: #9a3412; margin-bottom: 5px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.kp-label .kp-tag { background: #fdeee4; color: #9a3412; font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.kp-points { font-size: 13.3px; line-height: 1.85; color: #4a403a; }
.kp-ask { margin-top: 8px; border: 1px solid #dcc7b2; background: #fff; color: #8a4b2b; font-size: 12px; padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.kp-ask:hover { background: #fdeee4; }
.kb-note { font-size: 11px; opacity: .8; margin-top: 6px; line-height: 1.6; }
.kb-toolbar { padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.kb-toolbar input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 13.5px; outline: none; font-family: inherit;
}
.kb-toolbar input:focus { border-color: var(--red); }
.kb-body { flex: 1; overflow-y: auto; padding: 14px 20px 24px; }
.kb-course { font-size: 15px; font-weight: 800; color: var(--red-deep); margin: 16px 0 8px; padding-left: 10px; border-left: 4px solid var(--red); }
.kb-chapter { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.kb-chapter > summary {
  padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--ink);
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.kb-chapter > summary::after { content: "▸"; color: var(--ink-soft); transition: transform .2s; }
.kb-chapter[open] > summary::after { transform: rotate(90deg); }
.kb-chapter > summary:hover { background: #fff7f0; }
.kb-chap-points { padding: 0 16px 12px; font-size: 12.8px; color: var(--ink-soft); line-height: 1.8; border-top: 1px dashed var(--line); padding-top: 10px; }
.kb-sec { padding: 12px 16px; border-top: 1px dashed var(--line); }

/* ---------- 课后思考题 ---------- */
.ex-item { background: #fff; border: 1px solid var(--line); border-left: 4px solid #1d4ed8; border-radius: 10px; padding: 11px 14px; margin-bottom: 9px; }
.ex-q { font-size: 13.8px; font-weight: 600; color: var(--ink); line-height: 1.7; }
.ex-tag { background: #e8f0fe; color: #1d4ed8; font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 600; margin-right: 8px; white-space: nowrap; }
.ex-foot { font-size: 11.5px; color: var(--ink-soft); margin-top: 7px; }
.ex-ask { border: 1px solid #dcc7b2; background: #fff; color: #8a4b2b; font-size: 11.5px; padding: 3px 11px; border-radius: 999px; cursor: pointer; }
.ex-ask:hover { background: #fdeee4; }

/* 搜索结果浮层 */
.search-pop {
  position: fixed; z-index: 90; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); max-height: 46vh; overflow-y: auto;
  width: min(400px, 86vw); display: none;
}
.search-pop .sr { padding: 10px 14px; border-bottom: 1px solid #f3ebe2; cursor: pointer; font-size: 13px; }
.search-pop .sr:hover { background: #fff7f0; }
.search-pop .sr b { color: var(--red); margin-right: 8px; }
.search-pop .sr small { display: block; color: var(--ink-soft); margin-top: 2px; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .modal { width: 96vw; }
  .modal-tabs button { font-size: 12.5px; padding: 10px 2px; }
  .tab-pane { padding: 16px 16px 24px; }
  .topbar { padding: 12px 14px; }
  .year-panel { padding: 12px 14px 16px; }
}
