:root{
  --bg: #F5F7FB;
  --bg-soft: #EDF2FA;
  --card: #FFFFFF;
  --primary: #2563EB;
  --primary-deep: #1D4ED8;
  --primary-soft: #E8EFFD;
  --accent: #0EA5E9;
  --text: #16233B;
  --muted: #64748B;
  --border: #E2E8F2;
  --hover: #F0F4FA;
  --ok: #16A34A;
  --danger: #DC2626;
  --radius: 20px;
  --shadow: 0 2px 6px rgba(37,99,235,.06), 0 14px 36px rgba(15,40,90,.08);
  --shadow-lg: 0 4px 10px rgba(37,99,235,.10), 0 24px 60px rgba(15,40,90,.14);
}
*{ box-sizing: border-box; margin: 0; padding: 0; }
html{ scroll-behavior: smooth; }
body{
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.7;
  min-height: 100vh; overflow-x: hidden;
}
button, input, select, textarea{ font-family: inherit; font-size: inherit; color: inherit; }
button{ cursor: pointer; }

/* ===== 顶栏 ===== */
.topbar{
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 42px;
  background: rgba(245,247,251,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand{ display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 19px; cursor: pointer; user-select: none; }
.brand .logo{
  width: 40px; height: 40px; border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 6px 16px rgba(37,99,235,.30);
}
.crumb{ font-size: 15px; color: var(--muted); white-space: nowrap; }
.crumb b{ color: var(--primary); font-weight: 700; }
.top-actions{ margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn{
  border: 1px solid var(--border); background: var(--card);
  width: 42px; height: 42px; border-radius: 13px; font-size: 18px;
  box-shadow: var(--shadow);
}
.icon-btn:hover{ border-color: var(--primary); }

/* ===== 搜索 ===== */
.search-box{ position: relative; width: 300px; }
.search-box input{
  width: 100%; border: 1px solid var(--border); background: var(--card);
  border-radius: 999px; padding: 10px 20px; outline: none; box-shadow: var(--shadow);
}
.search-box input:focus{ border-color: var(--primary); }
.search-results{
  display: none; position: absolute; top: 50px; left: 0; right: 0; z-index: 70;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto;
}
.search-results.open{ display: block; }
.search-group{
  padding: 8px 16px 4px; font-size: 12.5px; font-weight: 700; color: var(--primary);
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.search-hit{ padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.search-hit:hover{ background: var(--primary-soft); }
.search-hit .kind{ color: var(--primary); font-weight: 700; margin-right: 8px; }
.search-hit .src{ color: var(--muted); font-size: 12px; }

/* ===== 页面 ===== */
.page{ display: none; padding-bottom: 110px; }
.page.active{ display: block; }
.container{ max-width: 1380px; margin: 0 auto; padding: 0 42px; }

/* ===== Hero ===== */
.hero{
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 420px at 12% -10%, #DCE9FF 0%, transparent 60%),
    radial-gradient(760px 420px at 88% 0%, #E4F4FF 0%, transparent 55%),
    linear-gradient(180deg, #EDF3FC 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 76px 0 60px;
}
.blob{ position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none; }
.blob.b1{ width: 320px; height: 320px; background: #BFDBFE; top: -80px; left: 6%; }
.blob.b2{ width: 260px; height: 260px; background: #BAE6FD; bottom: -90px; right: 8%; }
.hero-inner{ position: relative; z-index: 2; }
.hero-eyebrow{
  display: inline-block; font-size: 15px; font-weight: 700; letter-spacing: 1px;
  color: var(--primary); background: rgba(255,255,255,.75);
  border: 1px solid #D8E4FB; padding: 8px 22px; border-radius: 999px;
}
.hero-title{
  font-size: clamp(44px, 6vw, 68px); font-weight: 900; letter-spacing: 1px;
  line-height: 1.18; margin: 26px 0 20px; min-height: 1.3em;
}
.hero-title .grad{
  background: linear-gradient(100deg, var(--primary) 10%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub{ font-size: 20px; color: var(--muted); max-width: 640px; }
.hero-actions{ display: flex; gap: 16px; margin-top: 34px; flex-wrap: wrap; }
.btn{
  border: none; font-size: 17px; font-weight: 700;
  padding: 16px 38px; border-radius: 16px; transition: transform .15s;
}
.btn.primary{
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 12px 28px rgba(37,99,235,.35);
}
.btn.ghost{ color: var(--primary); background: #fff; border: 1.5px solid #D5E2FB; }
.hero-stats{
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 44px;
}
.stat{
  background: rgba(255,255,255,.82); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 26px; box-shadow: var(--shadow);
}
.stat b{ display: block; font-size: 38px; font-weight: 900; color: var(--primary); line-height: 1.15; }
.stat span{ font-size: 15px; color: var(--muted); }

/* ===== 区块 ===== */
.section{ margin-top: 60px; }
.section-title{ font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.section-sub{ font-size: 16px; color: var(--muted); margin-bottom: 24px; }
.section-title-row{ display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: space-between; }

/* ===== 科目卡片 ===== */
.cards{ display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.card{
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 34px; cursor: pointer; position: relative; overflow: hidden;
}
.card::after{
  content: ""; position: absolute; right: -60px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, var(--primary-soft), transparent 70%);
}
.card:hover{ border-color: var(--primary); box-shadow: var(--shadow-lg); }
.card .emoji{ font-size: 46px; display: block; }
.card h3{ font-size: 24px; font-weight: 800; margin: 16px 0 6px; }
.card p{ font-size: 16px; color: var(--muted); line-height: 1.7; }
.card .meta{ display: flex; gap: 18px; margin-top: 18px; font-size: 15px; color: var(--muted); }
.card .last{ display: none; margin-top: 14px; font-size: 13px; color: var(--primary); background: var(--primary-soft); padding: 4px 14px; border-radius: 999px; width: fit-content; }
.card .del{ position: absolute; top: 16px; right: 18px; color: var(--muted); font-size: 15px; opacity: 0; transition: opacity .2s; }
.card:hover .del{ opacity: 1; }
.card.add{
  border-style: dashed; display: grid; place-items: center; text-align: center;
  color: var(--muted); min-height: 220px;
}
.card.add .plus{ font-size: 44px; line-height: 1; }
.card.add p{ margin-top: 10px; font-size: 18px; }
.card.add:hover{ color: var(--primary); border-color: var(--primary); }

/* ===== 科目详情 ===== */
.back-btn{
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 12px 24px; border-radius: 14px; font-size: 16px; font-weight: 600;
  margin: 26px 0 8px; box-shadow: var(--shadow);
}
.back-btn:hover{ border-color: var(--primary); color: var(--primary); }
.subject-head{ display: flex; align-items: baseline; gap: 16px; margin: 18px 0 4px; flex-wrap: wrap; }
.subject-head h1{ font-size: 38px; font-weight: 900; }
.subject-head .sub{ font-size: 16px; color: var(--muted); }
.subnav{ display: flex; gap: 10px; margin: 20px 0 24px; flex-wrap: wrap; }
.subnav button{
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 14px 30px; border-radius: 14px; font-size: 17px; font-weight: 700;
  transition: all .2s;
}
.subnav button.active{ background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 8px 20px rgba(37,99,235,.30); }
.view{ display: none; }
.view.active{ display: block; }

/* ===== 文件浏览 ===== */
.split{ display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.tree{
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; font-size: 15px;
  max-height: 720px; overflow: auto;
}
.tree-group{ font-size: 13.5px; color: var(--muted); padding: 10px 12px 6px; font-weight: 700; letter-spacing: 1px; }
.tree-item{
  padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-item:hover{ background: var(--hover); }
.tree-item.active{ background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.tree-item .arr{ font-size: 10px; color: var(--muted); width: 12px; flex: none; }
.tree-children{ margin-left: 20px; border-left: 1px solid var(--border); padding-left: 4px; }
.badge-book{
  font-size: 11px; color: var(--primary); background: var(--primary-soft);
  padding: 2px 10px; border-radius: 999px; margin-left: auto; flex: none;
}
.badge-last{
  font-size: 11px; color: #b45309; background: #fef3c7;
  padding: 2px 10px; border-radius: 999px; flex: none; white-space: nowrap;
}

/* ===== 阅读器 ===== */
.reader{
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  position: relative;
}
.reader:fullscreen{ border-radius: 0; box-shadow: none; background: #fff; }
.reader:fullscreen .pdf-canvas-wrap{ max-height: calc(100vh - 64px); }
.reader-bar{
  display: flex; align-items: center; gap: 14px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); font-size: 14.5px;
}
.reader-bar .fname{ font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.reader-bar .ctrl{ margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.pdf-clock{
  display: none; margin: 0 auto; font-size: 15px; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
}
.reader:fullscreen .pdf-clock{ display: block; }
.pdf-ctrl{
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-soft); cursor: pointer; user-select: none;
}
.pdf-ctrl:hover{ background: var(--primary-soft); color: var(--primary); }
.page-ind{ min-width: 64px; text-align: center; font-size: 13px; }
.reader-bar input{
  width: 120px; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; outline: none;
}
.reader-bar #pdfPageInput{ width: 74px; text-align: center; }
.tree-item.ol-node{ font-size: 13px; padding: 6px 10px; }
.tree-item.ol-node .tname{ overflow: hidden; text-overflow: ellipsis; }
.tree-children .tree-item.ol-node{ font-size: 12.5px; }
.tree-children .tree-children .tree-item.ol-node{ font-size: 12px; }
.pdf-canvas-wrap{
  min-height: 780px; max-height: 92vh; overflow: auto; background: var(--bg-soft);
  text-align: center; padding: 20px;
}
#pdfCanvas{ background: #fff; box-shadow: 0 2px 14px rgba(15,40,90,.12); display: inline-block; }
.pdf-loading{
  position: absolute; inset: 0; display: none; place-items: center;
  background: rgba(255,255,255,.7); font-size: 18px; color: var(--primary); z-index: 5;
}
.pdf-loading.on{ display: grid; }

/* ===== 筛选标签 ===== */
.chips{ display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.chips button{
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 10px 24px; border-radius: 999px; font-size: 15px; font-weight: 600;
  transition: all .2s;
}
.chips button.active{ background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 答案汇总 ===== */
.answer-item{
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 28px; margin-bottom: 18px;
}
.answer-head{ display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.answer-head .sec{ font-weight: 800; font-size: 18px; }
.answer-head .qs{ font-size: 14.5px; color: var(--muted); }
.answer-rows{ margin-top: 16px; font-family: "Cascadia Mono", Consolas, monospace; font-size: 19px; display: flex; flex-direction: column; gap: 10px; }
.answer-row{ display: flex; align-items: center; gap: 18px; flex-wrap: nowrap; }
.answer-row .range{ color: var(--muted); min-width: 54px; font-size: 15px; }
.letters{ display: flex; gap: 10px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.letter{
  min-width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  padding: 0 12px; letter-spacing: 1px; flex: none;
  background: var(--bg-soft); border: 1px solid var(--border); font-weight: 800; font-size: 18px;
  cursor: pointer; position: relative; transition: background .2s;
}
.letter:hover{ background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.letter.starred{ background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.letter .star{ position: static; margin-left: 5px; font-size: 12px; display: inline-flex; align-items: center; }
.star-ic{ display: inline-block; vertical-align: -3px; }
.star-ic.on{ color: #F59E0B; }
.star-ic.off{ color: #94A3B8; }

/* ===== 题目详情弹窗 ===== */
.q-modal{ width: 640px; }
.q-detail{ display: flex; flex-direction: column; gap: 14px; }
.q-label{ font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: 1px; }
.q-body{
  background: var(--bg-soft); border-radius: 12px; padding: 14px 18px;
  font-size: 15px; line-height: 1.9; white-space: pre-wrap;
}
.q-body.qm-answer{ color: var(--ok); font-weight: 700; }
.expand-btn{
  margin-top: 14px; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--primary); padding: 10px 22px; border-radius: 12px;
  font-size: 15px; font-weight: 700;
}
.expand-btn:hover{ background: var(--primary-soft); }
.q-list{ margin-top: 14px; display: none; flex-direction: column; gap: 12px; }
.q-list.open{ display: flex; }
.q-card{ border: 1px solid var(--border); border-radius: 14px; padding: 16px 20px; background: var(--bg-soft); }
.q-card .q-no{ font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.q-card .q-text{ font-size: 15.5px; }
.q-card .q-ans{ margin-top: 10px; font-size: 15.5px; }
.q-card .q-ans b{ color: var(--ok); }
.q-card .q-expl{ margin-top: 8px; font-size: 14.5px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 10px; }
.q-card .q-expl b{ color: var(--text); }
.empty-tip{
  background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 44px; text-align: center; color: var(--muted); font-size: 16px;
}
.empty-tip button{ margin-top: 16px; }
.mini-btn{
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 9px 20px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
}
.mini-btn.primary{ background: var(--primary); border-color: var(--primary); color: #fff; }
.mini-btn:hover{ border-color: var(--primary); }
.mini-btn:disabled{ opacity: .55; cursor: not-allowed; }
.mini-btn.tiny{ padding: 4px 12px; font-size: 12px; border-radius: 999px; }
.mini-btn.danger{ color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.mini-btn.danger:hover{ border-color: #dc2626; }
.build-area{ display: flex; align-items: center; gap: 12px; }
.build-status{ font-size: 14px; color: var(--muted); }
.ring-wrap{ position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ring{ transform: rotate(-90deg); flex: none; }
.ring-track{ stroke: #e9edf4; }
.ring-bar{ stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset .3s ease; }
.ring-tip{
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; font-size: 12px; line-height: 1.6; padding: 6px 10px;
  border-radius: 8px; white-space: nowrap; text-align: center; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity .18s ease; z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.ring-tip::after{
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #1f2937;
}
.ring-wrap:hover .ring-tip{ opacity: 1; visibility: visible; }

/* ===== 收藏 ===== */
.fav-grid{ columns: 340px; column-gap: 22px; }
.fav-grid > .empty-tip, .notes-list > .empty-tip{ column-span: all; }
.fav{
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px;
  break-inside: avoid; margin-bottom: 22px;
}
.fav .head{ display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px; color: var(--muted); gap: 10px; }
.fav .q{ font-size: 16.5px; line-height: 1.8; margin-bottom: 14px; font-weight: 600; }
.fav .ans{
  display: inline-block; font-size: 16.5px; font-weight: 800; color: var(--ok);
  background: var(--primary-soft); padding: 8px 20px; border-radius: 999px;
}
.fav .expl{
  margin-top: 14px; padding: 12px 16px; font-size: 14.5px; color: var(--muted);
  background: var(--bg-soft); border-radius: 12px;
}
.fav .expl b{ color: var(--text); }
.fav .note{
  margin-top: 10px; padding: 12px 16px; font-size: 14.5px; color: var(--muted);
  background: var(--bg-soft); border-radius: 12px; border-left: 4px solid var(--primary);
}
.fav .ops{ margin-top: 14px; display: flex; gap: 18px; font-size: 14px; color: var(--muted); }
.fav .ops span{ cursor: pointer; }
.fav .ops span:hover{ color: var(--primary); }

/* ===== 随想笔记 ===== */
.notes-editor{
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 18px;
}
.notes-toolbar{ display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.notes-toolbar .tb{ padding: 5px 12px; font-size: 12.5px; border-radius: 999px; }
.notes-toolbar .tb.active{ background: var(--primary); border-color: var(--primary); color: #fff; }
.notes-tip{ font-size: 12px; color: var(--muted); margin-left: auto; }
.notes-editor textarea{
  width: 100%; border: 1px solid var(--border); background: var(--bg-soft); border-radius: 14px;
  padding: 12px 16px; font-size: 15px; line-height: 1.7; outline: none; resize: none;
  font-family: inherit; min-height: 76px; max-height: 260px;
}
.notes-editor textarea:focus{ border-color: var(--primary); background: var(--card); }
.notes-editor-ops{ display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.modal .notes-toolbar{ margin-bottom: 8px; }
.modal textarea#neContent{ min-height: 120px; max-height: 300px; }
.notes-tools{ display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.notes-tools input{
  width: 280px; border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 10px 22px; font-size: 14px; outline: none;
}
.notes-tools input:focus{ border-color: var(--primary); }
.notes-count{ font-size: 13px; color: var(--muted); }
.notes-list{ columns: 320px; column-gap: 16px; }
.note-card{
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 18px 20px;
  break-inside: avoid; margin-bottom: 16px;
}
.note-card .note-text{ font-size: 15px; line-height: 1.8; word-break: break-word; }
.note-text p{ margin: 6px 0; }
.note-text ul, .note-text ol{ margin: 6px 0; padding-left: 22px; }
.note-text li{ margin: 3px 0; }
.note-text a{ color: var(--primary); text-decoration: underline; word-break: break-all; }
.note-text img{ max-width: 100%; border-radius: 10px; margin: 8px 0; display: block; }
.note-text code{
  background: rgba(15,40,90,.09); padding: 2px 6px; border-radius: 6px;
  font-family: Consolas, Monaco, "Courier New", monospace; font-size: .92em;
}
.note-text pre{
  background: #0f2547; color: #e6edf7; padding: 12px 14px; border-radius: 12px;
  overflow-x: auto; margin: 10px 0;
}
.note-text pre code{ background: none; color: inherit; padding: 0; font-size: 13px; line-height: 1.6; }
.note-text h1, .note-text h2, .note-text h3, .note-text h4{ margin: 10px 0 6px; line-height: 1.4; font-weight: 800; }
.note-text blockquote{
  margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--primary);
  background: rgba(37,99,235,.06); border-radius: 0 10px 10px 0; color: var(--muted);
}
.note-text table{
  border-collapse: collapse; margin: 8px 0; font-size: 14px;
  display: block; overflow-x: auto; width: max-content; max-width: 100%; min-width: 100%;
}
.note-text th, .note-text td{ border: 1px solid var(--border); padding: 6px 10px; word-break: normal; }
.note-text th{ background: rgba(15,40,90,.06); font-weight: 700; }
.note-text hr{ border: none; border-top: 1px dashed var(--border); margin: 10px 0; }
.note-card .note-meta{
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; font-size: 12px; color: var(--muted);
}
.note-card .note-ops{ display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.note-card .note-ops span{ cursor: pointer; }
.note-card .note-ops span:hover{ color: var(--primary); }

/* ===== 聊天 ===== */
.chat-fab{
  position: fixed; right: 34px; bottom: 34px; z-index: 100;
  width: 66px; height: 66px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-size: 28px;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 12px 32px rgba(37,99,235,.40);
}
.chat-panel{
  position: fixed; right: 34px; bottom: 116px; z-index: 99;
  width: 460px; max-width: calc(100vw - 24px); height: 600px; max-height: calc(100vh - 140px); display: none;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  flex-direction: column; overflow: hidden;
}
.chat-head{
  padding: 14px 18px; display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 16px; background: var(--bg-soft);
}
.chat-title{ flex: none; }
.chat-head-right{ margin-left: auto; display: flex; align-items: center; gap: 10px; }
.chat-controls{
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--border); background: var(--card);
}
.chat-controls select.model{
  font-size: 12.5px; font-weight: 600; color: var(--primary); background: var(--primary-soft);
  border: none; padding: 5px 12px; border-radius: 999px;
}
.chat-controls .think-switch{ margin-left: auto; }
.think-switch{
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; user-select: none; flex-shrink: 0;
}
.think-switch input{ display: none; }
.think-slider{
  width: 34px; height: 20px; border-radius: 999px; background: var(--border);
  transition: background .2s; position: relative; flex-shrink: 0;
}
.think-slider::after{
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s;
}
.think-switch input:checked + .think-slider{ background: var(--primary); }
.think-switch input:checked + .think-slider::after{ transform: translateX(14px); }
.think-label{ font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.think-switch input:checked ~ .think-label{ color: var(--primary); }
.key-ind{ font-size: 11px; color: var(--danger); }
.key-ind.ok{ color: var(--ok); }
.chat-close{ cursor: pointer; color: var(--muted); font-size: 18px; padding: 0 4px; }
.chat-body{ flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg{ max-width: 92%; padding: 12px 16px; border-radius: 14px; font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.msg.user{ align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai{ align-self: flex-start; background: var(--bg-soft); border-bottom-left-radius: 4px; white-space: normal; }
.msg .src{ display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.msg.thinking{ color: var(--muted); font-style: italic; }
.msg-ops{ display: flex; justify-content: flex-end; margin-top: 8px; }
.copy-md{ font-size: 11.5px; color: var(--muted); cursor: pointer; user-select: none; }
.copy-md:hover{ color: var(--primary); }
.msg.ai > :first-child{ margin-top: 0; }
.msg.ai > :last-child{ margin-bottom: 0; }
.msg.ai p{ margin: 6px 0; }
.msg.ai h1, .msg.ai h2, .msg.ai h3, .msg.ai h4, .msg.ai h5, .msg.ai h6{ margin: 12px 0 6px; line-height: 1.4; font-size: 1.12em; font-weight: 800; }
.msg.ai ul, .msg.ai ol{ margin: 6px 0; padding-left: 22px; }
.msg.ai li{ margin: 3px 0; }
.msg.ai blockquote{
  margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--primary);
  background: rgba(37,99,235,.06); border-radius: 0 10px 10px 0; color: var(--muted);
}
.msg.ai code{
  background: rgba(15,40,90,.09); padding: 2px 6px; border-radius: 6px;
  font-size: .92em; font-family: Consolas, Monaco, "Courier New", monospace;
}
.msg.ai pre{
  background: #0f2547; color: #e6edf7; padding: 12px 14px; border-radius: 12px;
  overflow-x: auto; margin: 10px 0; word-break: normal;
}
.msg.ai pre code{ background: none; color: inherit; padding: 0; font-size: 13px; line-height: 1.6; }
.msg.ai a{ color: var(--primary); text-decoration: underline; }
.msg.ai table{
  border-collapse: collapse; margin: 8px 0; font-size: 13.5px;
  display: block; overflow-x: auto; width: max-content; max-width: 100%; min-width: 100%;
}
.msg.ai th, .msg.ai td{ border: 1px solid var(--border); padding: 6px 10px; word-break: normal; white-space: normal; text-align: left; }
.msg.ai th{ background: rgba(15,40,90,.06); font-weight: 700; }
.msg.ai hr{ border: none; border-top: 1px dashed var(--border); margin: 10px 0; }
.chat-input{ display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-input textarea{
  flex: 1; border: 1px solid var(--border); background: var(--bg-soft);
  border-radius: 16px; padding: 11px 16px; font-size: 14.5px; line-height: 1.6;
  outline: none; resize: none; min-height: 46px; max-height: 132px; font-family: inherit;
}
.chat-input textarea:focus{ border-color: var(--primary); }
.chat-input textarea::placeholder{ color: var(--muted); }
.chat-input button{
  border: none; background: var(--primary); color: #fff; border-radius: 16px;
  padding: 12px 24px; font-size: 15px; font-weight: 700; flex: none;
}

/* ===== 弹窗 ===== */
.modal-mask{
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(22,35,59,.35); place-items: center; backdrop-filter: blur(3px);
}
.modal-mask.open{ display: grid; }
.modal{
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow-lg);
  width: 460px; max-width: 92vw; padding: 30px; max-height: 88vh; overflow: auto;
}
.modal h3{ font-size: 22px; font-weight: 800; margin-bottom: 18px; }
.modal label{ display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.modal input, .modal select, .modal textarea{
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; outline: none; background: var(--bg-soft);
}
.modal input:focus, .modal textarea:focus{ border-color: var(--primary); background: var(--card); }
.modal .think-row{
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 4px; font-size: 14px; color: var(--muted); font-weight: 600;
}
.modal .prompt-sec{ margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 2px; }
.modal .prompt-head{ display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.modal .prompt-head label{ margin: 0; }
.modal .prompt-ops{ display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; flex-wrap: wrap; }
.prompt-tip{ font-size: 12px; color: var(--muted); line-height: 1.5; }
.modal .prompt-block{ margin-top: 16px; }
.modal .prompt-block-title{
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 8px;
}
.modal .prompt-block-title span{ font-size: 12px; font-weight: 600; color: var(--muted); }
.prompt-list{ display: flex; flex-direction: column; gap: 8px; max-height: 190px; overflow: auto; padding-right: 2px; }
.prompt-item{
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.prompt-item-main{ flex: 1; min-width: 0; }
.prompt-item-name{ font-size: 13.5px; font-weight: 800; margin-bottom: 3px; }
.prompt-item-preview{
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.prompt-item-preview.open{ white-space: pre-wrap; word-break: break-word; }
.prompt-item-time{ font-size: 11px; color: var(--muted); margin-top: 4px; }
.prompt-item-ops{ display: flex; gap: 6px; flex-shrink: 0; }
.prompt-empty{ font-size: 12.5px; color: var(--muted); padding: 6px 2px; }
.modal .hint{ font-size: 13px; color: var(--muted); margin-top: 10px; }
.modal-ops{ display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ===== Toast ===== */
.toast{
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 28px; border-radius: 999px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: all .3s; z-index: 300;
}
.toast.on{ opacity: 1; transform: translateX(-50%) translateY(0); }

.back-top{
  position: fixed; left: 30px; bottom: 30px; z-index: 90;
  border: 1px solid var(--border); background: var(--card); color: var(--primary);
  padding: 12px 22px; border-radius: 14px; font-size: 14px; font-weight: 700;
  box-shadow: var(--shadow-lg); cursor: pointer;
  opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: all .25s;
}
.back-top.on{ opacity: 1; pointer-events: auto; transform: translateY(0); }

.foot-note{ text-align: center; font-size: 13px; color: var(--muted); padding: 20px 20px 0; }

@media (max-width: 960px){
  .topbar{ padding: 12px 20px; flex-wrap: wrap; }
  .container{ padding: 0 20px; }
  .split{ grid-template-columns: 1fr; }
  .search-box{ width: 200px; }
  .hero-stats{ grid-template-columns: repeat(2, 1fr); }
}
