:root {
  --bg: #faf9f5;
  --card: #ffffff;
  --ink: #1f1e1c;
  --muted: #6b6862;
  --line: rgba(31, 30, 28, 0.10);
  --accent: #c96442;
  --accent-soft: rgba(201, 100, 66, 0.09);
  --accent-border: rgba(201, 100, 66, 0.26);
  --green: #3d8a5f;
  --red: #c0492f;
  --radius: 14px;
  --sidebar-w: 84px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ---------- 侧边导航 ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #262417;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 18px;
  z-index: 20;
}

.brand {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  width: 100%;
  padding: 0 10px;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-btn.active {
  color: #fff;
  background: var(--accent);
}

.nav-icon {
  font-size: 18px;
}

.api-indicator .dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8a93ab;
}

.api-indicator.ok .dot {
  background: #3ddc84;
}

.api-indicator.bad .dot {
  background: #ff5f5f;
}

/* ---------- 主区域 ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 22px 26px 40px;
  max-width: 1180px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
}

.countdown {
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.view.active {
  display: flex;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-head h2 {
  font-size: 15px;
  margin: 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0;
}

.state {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  min-height: 16px;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #b05535;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------- 统计 ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  font-size: 20px;
}

/* ---------- 计划 ---------- */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
}

.plan-item:hover {
  background: var(--accent-soft);
}

.plan-item time {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  min-width: 44px;
  padding-top: 1px;
}

.plan-item .plan-body {
  flex: 1;
}

.plan-item .plan-body strong {
  font-size: 14px;
}

.plan-item .plan-body p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.plan-item.done strong,
.plan-item.done p {
  text-decoration: line-through;
  opacity: 0.5;
}

.plan-item.header-item {
  background: var(--accent-soft);
  border: 1px dashed var(--accent-border);
}

.plan-done-btn {
  border: 1px solid var(--accent-border);
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
}

.plan-done-btn:hover {
  background: var(--accent-soft);
}

/* ---------- 复习队列 ---------- */
.review-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.review-item strong {
  display: block;
  font-size: 14px;
}

.review-item .meta {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 8px;
}

.review-actions {
  display: flex;
  gap: 8px;
}

.review-actions button {
  flex: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 13px;
}

.review-actions button[data-result="mastered"]:hover {
  border-color: var(--green);
  color: var(--green);
}

.review-actions button[data-result="fuzzy"]:hover {
  border-color: #d29b3f;
  color: #d29b3f;
}

.review-actions button[data-result="forgot"]:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.form-grid .span-2 {
  grid-column: span 2;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.inline-form input,
.inline-form select {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.inline-form input:focus,
textarea:focus {
  outline: 2px solid var(--accent-border);
  border-color: var(--accent);
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form input#studyTask {
  flex: 1;
  min-width: 180px;
}

.inline-form input#studyMinutes {
  width: 76px;
}

/* ---------- 上传 ---------- */
.upload-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1.5px dashed var(--accent-border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  margin-bottom: 14px;
  transition: background 0.15s;
}

.upload-zone:hover {
  background: var(--accent-soft);
}

.upload-zone img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.upload-hint strong {
  display: block;
  font-size: 14px;
}

.upload-hint small {
  color: var(--muted);
}

.school-hero {
  position: relative;
  /* clip 不会把容器变成可滚动容器；hidden 会让浏览器在聚焦输入框时
     把 hero 内部滚走，导致标题被裁掉 */
  overflow: clip;
  padding: 64px 40px 48px;
  margin-bottom: 20px;
  border: 1px solid #fde7c7;
  border-radius: 26px;
  text-align: center;
  background:
    radial-gradient(60% 90% at 12% 0%, rgba(251, 191, 36, 0.22) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(55% 80% at 88% 10%, rgba(249, 115, 22, 0.14) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, #fffaf2 0%, #fff1dd 100%);
  box-shadow: 0 18px 48px rgba(180, 83, 9, 0.1);
}

.school-hero::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -160px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.16) 0%, rgba(251, 191, 36, 0) 70%);
  pointer-events: none;
}

.school-hero h2 {
  position: relative;
  margin: 0 0 12px;
  font-size: 40px;
  letter-spacing: 1px;
}

.school-hero-sub {
  position: relative;
  margin: 0 auto 30px;
  max-width: 640px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.school-search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 10px 10px 24px;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 22px;
  box-shadow: 0 14px 36px rgba(120, 60, 10, 0.16);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.school-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 18px 44px rgba(180, 83, 9, 0.24);
  transform: translateY(-1px);
}

.school-search-icon {
  font-size: 28px;
  color: var(--muted);
  line-height: 1;
}

.school-search-box input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  box-shadow: none;
  font-size: 22px;
  padding: 18px 0;
}

.school-search-box .btn {
  flex: 0 0 auto;
  font-size: 18px;
  padding: 18px 40px;
  border-radius: 15px;
  letter-spacing: 2px;
}

.search-understood {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.school-hero .state {
  display: block;
  margin: 14px auto 0;
  max-width: 920px;
  text-align: center;
}

.school-search-result { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.school-search-result[hidden] { display: none; }
.school-search-result .card { margin: 0; }
.search-answer { font-size: 15px; line-height: 1.75; }
.search-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fact-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
}
.search-degraded { color: #b45309; line-height: 1.7; }
.source-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.sources-title { margin: 0; font-size: 13px; color: var(--muted); }
.source-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.source-index { color: var(--muted); font-size: 12px; }
.source-main { flex: 1; min-width: 0; }
.source-main strong { display: block; font-size: 13px; }
.source-main small { color: var(--muted); word-break: break-all; }
.school-library { margin-top: 18px; }
.school-library > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 2px; }
.school-library .card { margin-top: 12px; }

.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.facts-wrap {
  overflow-x: auto;
}

.facts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.facts-table th,
.facts-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.facts-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.candidate-item {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.doc-change {
  display: block;
  margin-top: 4px;
  color: #b45309;
}

.candidate-main { min-width: 0; }
.candidate-main strong { display: block; font-size: 14px; }
.candidate-main small { color: var(--muted); word-break: break-all; }
.candidate-main p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.candidate-side { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.candidate-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.candidate-tag.muted { background: #f3f4f6; color: var(--muted); }

.doc-hint {
  color: var(--muted);
  font-size: 12px;
}

.doc-item.clickable {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.doc-item.clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(180, 83, 9, 0.08);
}

.doc-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.doc-modal[hidden] {
  display: none;
}

.doc-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 10, 0.45);
}

.doc-modal-panel {
  position: relative;
  width: min(780px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  padding: 20px 24px 24px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.3);
}

.doc-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.doc-modal-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.doc-modal-head small {
  color: var(--muted);
  word-break: break-all;
}

.doc-modal-body h4 {
  margin: 16px 0 8px;
  font-size: 14px;
}

.modal-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-text {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

.doc-fulltext {
  white-space: pre-wrap;
  word-break: break-word;
  background: #faf7f2;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  max-height: 42vh;
  overflow: auto;
}

.modal-link a {
  color: var(--accent);
}

@media (max-width: 860px) {
  .doc-modal {
    padding: 0;
  }

  .doc-modal-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    align-self: flex-end;
  }
}

/* ---------- 错题列表 ---------- */
.mistake-list,
.record-list,
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
}

.mistake-item,
.record-item,
.doc-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.mistake-item .row-1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
}

.mistake-item .row-1 strong {
  flex: 1;
  font-size: 13px;
}

.mistake-item .row-2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.mistake-item .mastery {
  color: var(--muted);
  font-size: 12px;
  flex: 1;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--red);
}

/* ---------- 详情/讲解 ---------- */
.detail-panel {
  border-color: var(--accent-border);
}

.detail-content {
  white-space: pre-wrap;
  font-size: 13.5px;
  line-height: 1.8;
}

.analysis-source-image {
  display: block;
  width: 100%;
  max-height: min(70vh, 720px);
  margin: 0 0 16px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  cursor: zoom-in;
}

.analysis-image-error {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- AI 同类题任务面板 ---------- */
.practice-panel {
  background: var(--card);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(31, 30, 28, 0.06);
  overflow: hidden;
}

.practice-panel[hidden],
.practice-panel [hidden] {
  display: none !important;
}

.practice-toolbar,
.practice-toolbar-actions,
.practice-meta,
.practice-actions {
  display: flex;
  align-items: center;
}

.practice-toolbar {
  justify-content: space-between;
  gap: 16px;
}

.practice-toolbar h2 {
  margin: 2px 0 0;
  font-size: 16px;
  letter-spacing: 0;
}

.practice-eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.practice-toolbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.practice-stage-badge,
.practice-review-badge {
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.4;
}

.practice-progress {
  height: 4px;
  margin: 14px 0 0;
  overflow: hidden;
  background: rgba(31, 30, 28, 0.08);
  border-radius: 2px;
}

.practice-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.practice-loading,
.practice-paused,
.practice-error {
  min-height: 148px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding: 20px 2px 4px;
}

.practice-loading p,
.practice-paused p,
.practice-error p {
  margin: 0;
  color: var(--muted);
}

.practice-error strong {
  color: var(--red);
}

.practice-question {
  padding-top: 20px;
}

.practice-meta {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.practice-question h3 {
  margin: 16px 0;
  font-size: 17px;
  line-height: 1.7;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.practice-diagram {
  width: min(100%, 780px);
  aspect-ratio: 3 / 2;
  min-height: 0;
  max-height: 520px;
  margin: 0 auto 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
}

.practice-diagram svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
  height: auto;
}

.practice-diagram img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#practiceOptions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.practice-option {
  min-height: 54px;
  display: grid;
  grid-template-columns: 20px 26px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  overflow-wrap: anywhere;
}

.practice-option:hover,
.practice-option.selected {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.practice-option.correct {
  border-color: var(--green);
  background: rgba(61, 138, 95, 0.08);
}

.practice-option.incorrect {
  border-color: var(--red);
  background: rgba(192, 73, 47, 0.07);
}

.practice-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.practice-option-key {
  font-weight: 700;
  color: var(--accent);
}

.practice-actions {
  gap: 10px;
  margin-top: 14px;
}

.practice-answer {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 3px solid var(--green);
  background: rgba(61, 138, 95, 0.07);
  border-radius: 0 8px 8px 0;
}

.practice-answer p {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.practice-connection {
  color: var(--muted);
  font-size: 13px;
}

.school-answer {
  margin-top: 10px;
  color: var(--ink);
}

.school-answer:empty {
  display: none;
}

/* ---------- 聊天 ---------- */
.chat-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  min-height: 420px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
  margin-bottom: 12px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  font-size: 14px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-bottom-left-radius: 4px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input-row textarea,
.chat-input-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  resize: none;
}

/* ---------- PDF 导入 ---------- */
.pdf-import {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  border: 1.5px dashed var(--accent-border);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--accent);
}

.pdf-import:hover {
  background: var(--accent-soft);
}

/* ---------- 记忆 ---------- */
.memory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.memory-list li .memory-text {
  flex: 1;
}

.memory-list li .confidence {
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 分析 ---------- */
.analysis-body p {
  margin: 8px 0 4px;
}

.analysis-body ul {
  margin: 4px 0;
  padding-left: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 52px 1fr 90px;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 13px;
}

.bar-track {
  background: var(--accent-soft);
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
}

.bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 6px;
}

.bar-row small {
  color: var(--muted);
  text-align: right;
}

.record-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.record-item strong {
  flex: 1;
  font-weight: 500;
}

.record-item small {
  color: var(--muted);
}

.doc-item strong {
  display: block;
  font-size: 13px;
}

.doc-item small {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-top: 2px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: #262417;
  color: #f5f0e8;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 100;
  max-width: 80vw;
  box-shadow: 0 6px 24px rgba(38, 36, 23, 0.28);
}

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
  :root {
    --sidebar-w: 0px;
  }

  .sidebar {
    inset: auto 0 0 0;
    width: 100%;
    height: 62px;
    flex-direction: row;
    padding: 0 8px;
    gap: 8px;
    align-items: center;
  }

  .brand,
  .api-indicator {
    display: none;
  }

  .nav {
    flex-direction: row;
    padding: 0;
    justify-content: space-around;
    width: 100%;
    gap: 2px;
  }

  .nav-btn {
    padding: 6px 2px;
    flex: 1 1 0;
    min-width: 0;
  }

  .nav-label {
    font-size: 10px;
  }

  .nav-icon {
    font-size: 16px;
  }

  .main {
    margin-left: 0;
    padding: 16px 14px 90px;
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .two-col,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: span 1;
  }

  .chat-card {
    height: calc(100vh - 200px);
  }

  .chat-bubble {
    max-width: 92%;
  }
}

/* ---------- 答题模式复习卡片 ---------- */
.review-question {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.6;
}

.review-answer-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-field {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(22, 32, 58, 0.03);
}

.review-field span {
  color: var(--muted);
}

.review-field.correct {
  background: rgba(18, 146, 79, 0.08);
  color: var(--green);
}

.review-field.analysis {
  white-space: pre-wrap;
  background: transparent;
  border: 1px solid var(--line);
}

.review-reveal-btn {
  margin-top: 10px;
  width: 100%;
  border: 1px dashed var(--accent-border);
  background: transparent;
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 13px;
}

.review-reveal-btn:hover {
  background: var(--accent-soft);
}

/* ---------- 章节覆盖率 ---------- */
.coverage-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.coverage-subject strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13.5px;
}

.coverage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 3px;
}

/* 三色覆盖状态：full 绿 / partial 黄 / none 红 */
.coverage-row.cov-full {
  background: rgba(18, 146, 79, 0.06);
}
.coverage-row.cov-full small {
  color: var(--green);
}

.coverage-row.cov-partial {
  background: rgba(214, 158, 46, 0.10);
}
.coverage-row.cov-partial small {
  color: #b7791f;
}

.coverage-row.cov-none {
  background: rgba(210, 63, 63, 0.06);
}
.coverage-row.cov-none small {
  color: var(--red);
}

/* ================================================================
   登录界面
   ================================================================ */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 36px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 32px rgba(22,32,58,0.10);
}

.login-brand {
  font-size: 36px;
  font-weight: 700;
  width: 60px;
  height: 60px;
  line-height: 60px;
  border-radius: 14px;
  background: var(--accent, #5865f2);
  color: #fff;
  margin: 0 auto 16px;
}

.login-card h2 {
  margin: 0 0 28px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.login-icp {
  display: block;
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.login-icp a {
  color: var(--muted);
  text-decoration: none;
}

.login-icp a:hover {
  color: var(--accent);
}

.login-card .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.login-card .form-group label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-card .form-group input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

.login-card .form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  font-size: 15px;
}

/* 用户信息栏（侧边栏） */
.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  margin: 4px 8px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--text-muted, #8b8fa8);
  gap: 2px;
}

.user-info #userNameLabel {
  font-size: 11px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info[hidden] { display: none; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.6;
  line-height: 1;
  padding: 2px 4px;
}

.btn-icon:hover { opacity: 1; }

/* ================================================================
   院校 AI 分析
   ================================================================ */

.doc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}

.doc-content {
  flex: 1;
  min-width: 0;
}

.doc-content strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.doc-content small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-sm.primary {
  background: var(--accent);
  color: #fff;
}

.btn-sm.primary:hover {
  opacity: 0.9;
}

.analysis-result .loading,
.analysis-result .error {
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.analysis-result .loading {
  background: var(--accent-soft);
  color: var(--accent);
}

.analysis-result .error {
  background: rgba(210, 63, 63, 0.08);
  color: var(--red);
}

.analysis-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--card);
}

.analysis-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--ink);
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.analysis-field {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
}

.analysis-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.analysis-field div {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.5;
}

.btn-sm.danger {
  background: var(--red);
  color: #fff;
}

.btn-sm.danger:hover { opacity: 0.85; }

.doc-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* 小节展开 */
.btn-expand {
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 7px;
  color: var(--muted);
  white-space: nowrap;
}
.btn-expand:hover { border-color: var(--accent); color: var(--accent); }

.subsection-list {
  margin: 0 0 4px 16px;
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

.coverage-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  margin-bottom: 2px;
}
.coverage-sub.touched { background: rgba(18,146,79,0.05); }
.coverage-sub.untouched { background: rgba(210,63,63,0.04); }
.coverage-sub span { color: var(--ink); }
.coverage-sub small { color: var(--muted); }

/* ================================================================
   Claude 风格装饰层
   ================================================================ */

/* 1. 背景纸张肌理（SVG噪点，模拟 Anthropic 官网的暖色纸感） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px;
}

.app, .main { position: relative; z-index: 1; }
.sidebar { z-index: 20; }

/* 2. 卡片更暖的阴影 */
.card {
  box-shadow: 0 1px 3px rgba(31,30,28,0.06), 0 4px 16px rgba(31,30,28,0.05);
}

/* 3. 顶栏细腻边线（替代冷色边框） */
.topbar {
  border-bottom: 1px solid rgba(201,100,66,0.12);
  background: rgba(250,249,245,0.92);
  backdrop-filter: blur(8px);
}

/* 4. 星芒/火花装饰 — 放在 topbar 标题右侧 */
#viewTitle::after {
  content: "✦";
  font-size: 11px;
  color: var(--accent);
  opacity: 0.5;
  margin-left: 8px;
  vertical-align: middle;
}

/* 5. 登录卡片升级：纸张感 + 暖色阴影 */
.login-card {
  box-shadow: 0 2px 8px rgba(31,30,28,0.07), 0 16px 48px rgba(31,30,28,0.10);
}

/* 6. 主按钮去方角，更柔和 */
.btn.primary {
  border-radius: 10px;
  letter-spacing: 0.01em;
}

/* 7. stat-card 暖色左边线 */
.stat-card {
  border-left: 3px solid var(--accent-border);
}

/* 错题缩略图与放大 */
.mistake-thumb {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: zoom-in;
  border: 1px solid var(--line);
}

.img-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31,30,28,0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
  padding: 24px;
}

.img-overlay img {
  max-width: 92vw;
  max-height: 80vh;
  border-radius: 10px;
  object-fit: contain;
}

.img-overlay button {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.img-overlay[hidden] { display: none; }

/* Mermaid 图形块（同类题里的树/图/状态机等） */
.mermaid-block {
  margin: 12px 0;
  padding: 12px;
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  text-align: center;
}
.mermaid-block svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.danger-btn {
  color: var(--red) !important;
}
.danger-btn:hover {
  text-decoration: underline;
}

/* 复习卡片模式 */
.review-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.review-progress {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.review-kp { font-size: 16px; display: block; margin: 6px 0 2px; }
.review-reason { font-size: 13px; color: var(--muted); }
.review-back { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.review-actions { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.review-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.review-actions button[data-result="mastered"] { border-color: var(--green); color: var(--green); }
.review-actions button[data-result="forgot"] { border-color: var(--red); color: var(--red); }
.review-kb-hint { font-size: 11px; color: var(--muted); text-align: center; opacity: 0.7; }

/* 错题筛选栏 */
.mistake-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.filter-input {
  flex: 1;
  min-width: 120px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
}
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tab {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.filter-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

/* 学习热力图 */
.streak-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 8px;
}
/* 最近 N 天学习时长条形图 */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  padding-top: 8px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
}
.bar-track {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: flex-end;
  border-radius: 4px;
}
.bar-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: height 0.3s ease;
}
.bar-fill.empty { background: var(--line); }
.bar-day { font-size: 11px; color: var(--text); }
.bar-wd { font-size: 10px; color: var(--muted); }

/* ============================================================
   移动端补充适配（新功能）
   ============================================================ */
@media (max-width: 860px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  .app {
    display: block;
    width: 100%;
    min-width: 0;
  }

  /* 学习条形图：14 根条形自适应宽度，无需横向滚动 */
  .bar-chart {
    gap: 4px;
  }

  /* 错题筛选栏：垂直堆叠 */
  .mistake-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-tabs {
    flex-wrap: wrap;
  }

  /* 键盘快捷键提示在手机上不显示 */
  .review-kb-hint {
    display: none;
  }

  /* 复习评分按钮更高，更好点击 */
  .review-actions button {
    padding: 14px 8px;
    font-size: 15px;
  }

  /* 侧边栏用户信息行在底部导航上不显示 */
  .user-info {
    display: none !important;
  }

  /* 管理员按钮移到底部导航 */
  #adminNavBtn {
    display: flex;
  }

  /* 登录卡片全宽 */
  .login-card {
    width: 92vw;
    padding: 28px 20px;
  }

  /* 错题缩略图手机上最大高度 */
  .mistake-thumb {
    max-height: 180px;
  }

  /* 图片放大遮罩按钮更大 */
  .img-overlay button {
    padding: 12px 28px;
    font-size: 16px;
  }

  /* 院校资料操作按钮竖排 */
  .doc-item {
    flex-direction: column;
    align-items: stretch;
  }
  .doc-actions {
    justify-content: flex-end;
  }

  /* 分析网格单列 */
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .practice-panel {
    padding: 16px;
  }

  .practice-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .practice-toolbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .practice-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  #practiceOptions {
    grid-template-columns: 1fr;
  }

  .practice-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .practice-actions .btn {
    width: 100%;
  }
}

.key-state {
  font-weight: normal;
  color: var(--muted);
  font-size: 11px;
}

.system-status-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.system-status-row {
  display: grid;
  grid-template-columns: 10px minmax(92px, 0.38fr) minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.system-status-row:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.system-status-row strong,
.system-status-row span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.system-status-row span:last-child {
  color: var(--muted);
}

.system-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2f7d50;
}

.system-status-row[data-status="warning"] .system-status-dot {
  background: #b87816;
}

.system-status-row[data-status="error"] .system-status-dot {
  background: #b54435;
}

@media (max-width: 700px) {
  .system-status-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .system-status-row:nth-child(odd) {
    border-right: 0;
  }
}


@media (max-width: 860px) {
  .school-hero {
    padding: 30px 16px 26px;
    border-radius: 18px;
  }

  .school-hero h2 {
    font-size: 28px;
  }

  .school-hero-sub {
    font-size: 13px;
    margin-bottom: 18px;
  }

  .school-search-box {
    padding: 6px 6px 6px 14px;
    border-radius: 15px;
  }

  .school-search-box input {
    font-size: 16px;
    padding: 12px 0;
  }

  .school-search-box .btn {
    font-size: 14px;
    padding: 11px 18px;
    letter-spacing: 1px;
  }

}

