/* ============================================================
   CPA 笔记 · 样式
   ============================================================ */

:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #fafbff;
  --sidebar: #ffffff;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --border: #e6e8ef;
  --border-strong: #d5d8e3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .18);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Cascadia Code", Consolas, "Microsoft YaHei", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f1a;
    --panel: #121826;
    --panel-2: #161d2e;
    --sidebar: #0f1524;
    --text: #e8ecf5;
    --text-2: #c3cad9;
    --muted: #8b94a8;
    --border: #232c40;
    --border-strong: #2f3a52;
    --accent: #7c7bf5;
    --accent-hover: #9290f8;
    --accent-soft: #1e2140;
    --danger: #f87171;
    --danger-soft: #2a1517;
    --ok: #34d399;
    --ok-soft: #0f2a23;
    --warn: #fbbf24;
    --warn-soft: #2a2210;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 18px; }

.only-mobile { display: none !important; }

/* ------------------------------ 启动 / 登录 ------------------------------ */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--bg);
}

.auth-view {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% 0%, rgba(79, 70, 229, .18), transparent 60%),
    radial-gradient(900px 500px at 95% 100%, rgba(14, 165, 233, .14), transparent 55%),
    var(--bg);
}

.auth-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  letter-spacing: .5px;
}

.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card > p { margin: 0 0 18px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  transition: background .15s, transform .05s;
  white-space: nowrap;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn.small { padding: 7px 12px; font-size: 13px; }
.primary-btn.block { width: 100%; padding: 11px; margin-top: 4px; }

/* ------------------------------ 布局 ------------------------------ */

.app {
  display: grid;
  grid-template-columns: 250px 340px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------ 侧边栏 ------------------------------ */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 12px 12px;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 4px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-wrap input {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  outline: none;
  font-size: 13px;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); flex: 0 0 auto; }
.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 22px;
  text-align: center;
}
.nav-item.active .nav-count { background: rgba(79, 70, 229, .16); color: var(--accent); }

.side-section { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
}
.mini-btn {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 3px 9px;
  border-radius: 7px;
  transition: all .12s;
}
.mini-btn:hover { color: var(--accent); border-color: var(--accent); }
.side-head .mini-btn { padding: 0 6px; line-height: 18px; font-size: 14px; }
.side-head-actions { display: flex; align-items: center; gap: 4px; }
.side-head-actions .mini-btn { font-size: 11px; font-weight: 600; }
.mini-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
#btn-add-subject { font-size: 14px; line-height: 18px; padding: 0 6px; }

.subject-item.is-hidden { opacity: .5; }
.subject-item.is-hidden .subject-name { text-decoration: line-through; }
.subject-item.manage { cursor: default; }
.subj-toggle {
  flex: 0 0 auto;
  font-size: 10.5px;
  line-height: 15px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel);
  transition: all .12s;
}
.subj-toggle:hover { border-color: var(--accent); color: var(--accent); }
.subj-toggle.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.subject-group-label {
  list-style: none;
  font-size: 10.5px;
  color: var(--muted);
  padding: 8px 9px 2px;
  letter-spacing: .02em;
}

.subject-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.subject-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s;
}
.subject-item:hover { background: var(--panel-2); }
.subject-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.subject-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--c); flex: 0 0 auto; }
.subject-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-count { font-size: 11.5px; color: var(--muted); }
.subject-item.active .subject-count { color: var(--accent); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 3px; }
.tag-chip {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: all .12s;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }

.timer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
}
.timer-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.timer-icon { font-size: 10px; }
.timer.running { border-color: var(--ok); background: var(--ok-soft); }
.timer.running .timer-btn { color: var(--ok); }
.timer-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.timer-clock { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.timer.running .timer-clock { color: var(--ok); font-weight: 600; }

.foot-row { display: flex; gap: 6px; }
.foot-row .mini-btn { flex: 1; text-align: center; padding: 5px 4px; }

/* ------------------------------ 列表 ------------------------------ */

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}
.list-head h2 { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; }
.pill {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 8px;
}
.list-head .primary-btn { margin-left: auto; }

.list-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.list-filter button { color: var(--accent); font-size: 12px; }

.list-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.note-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }

.note-item {
  padding: 10px 11px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.note-item:hover { background: var(--panel-2); }
.note-item.active { background: var(--accent-soft); border-color: rgba(79, 70, 229, .25); }

.ni-top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.ni-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.ni-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.ni-badge.wrong { background: var(--danger-soft); color: var(--danger); }
.ni-badge.due { background: var(--warn-soft); color: var(--warn); }
.ni-excerpt {
  margin: 0 0 5px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ni-meta { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  color: var(--c);
  font-weight: 600;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-pill::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--c); }
.ni-time { margin-left: auto; white-space: nowrap; }

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

/* ------------------------------ 编辑区 ------------------------------ */

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.editor-empty {
  margin: auto;
  text-align: center;
  padding: 40px;
  max-width: 420px;
}
.empty-art {
  font-size: 44px;
  color: var(--border-strong);
  margin-bottom: 8px;
  line-height: 1;
}
.editor-empty h3 { margin: 0 0 8px; font-size: 16px; }
.editor-empty p { margin: 0; font-size: 13px; line-height: 1.7; }
.editor-empty code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
}
.title-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 18px;
  font-weight: 700;
  padding: 2px 0;
}
.title-input::placeholder { color: var(--border-strong); font-weight: 600; }

.editor-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.save-state { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.chip-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-2);
  background: var(--panel);
  white-space: nowrap;
  transition: all .12s;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.chip-btn.on.review { background: var(--accent); border-color: var(--accent); }

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 5px;
  min-width: 160px;
  z-index: 40;
  display: flex;
  flex-direction: column;
}
.menu button {
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
}
.menu button:hover { background: var(--panel-2); color: var(--text); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  flex-wrap: wrap;
}
.select {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
  max-width: 160px;
}
.tags-input {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 12px;
  outline: none;
  min-width: 140px;
  flex: 0 1 200px;
}
.tags-input:hover { border-color: var(--border); }
.tags-input:focus { border-color: var(--accent); background: var(--panel-2); }

.due-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  white-space: nowrap;
}
.due-badge.overdue { background: var(--danger-soft); color: var(--danger); }

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.editor-toolbar::-webkit-scrollbar { display: none; }

.seg { display: inline-flex; background: var(--bg); border-radius: 8px; padding: 2px; flex: 0 0 auto; }
.seg button {
  font-size: 12px;
  padding: 3px 11px;
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
}
.seg button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }

.tool-btn {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--panel);
  white-space: nowrap;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }

.editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.editor-textarea {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 20px 22px 60px;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  tab-size: 2;
}
.editor-textarea::placeholder { color: var(--border-strong); }
.editor-body.drag .editor-textarea { background: var(--accent-soft); }

.preview {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 26px 80px;
  border-left: 1px solid var(--border);
}

.editor-body.mode-edit .preview { display: none; }
.editor-body.mode-preview .editor-textarea { display: none; }
.editor-body.mode-preview .preview { border-left: none; }
.editor-body.mode-split .editor-textarea { flex: 1 1 50%; }
.editor-body.mode-split .preview { flex: 1 1 50%; }

/* ------------------------------ Markdown 渲染 ------------------------------ */

.markdown-body { font-size: 14.5px; line-height: 1.78; color: var(--text-2); word-wrap: break-word; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 { color: var(--text); line-height: 1.35; margin: 1.4em 0 .6em; font-weight: 700; }
.markdown-body h1 { font-size: 1.6em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.markdown-body h2 { font-size: 1.32em; border-bottom: 1px solid var(--border); padding-bottom: .25em; }
.markdown-body h3 { font-size: 1.14em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body p { margin: .7em 0; }
.markdown-body ul,
.markdown-body ol { margin: .6em 0; padding-left: 1.5em; }
.markdown-body li { margin: .22em 0; }
.markdown-body li > ul,
.markdown-body li > ol { margin: .2em 0; }
.markdown-body blockquote {
  margin: .8em 0;
  padding: .3em 1em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-2);
  border-radius: 0 6px 6px 0;
}
.markdown-body blockquote p { margin: .3em 0; }
.markdown-body code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: .1em .35em;
  border-radius: 5px;
}
.markdown-body pre {
  margin: .8em 0;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}
.markdown-body pre code { background: none; border: none; padding: 0; font-size: 12.8px; line-height: 1.65; }
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: .9em 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.markdown-body th,
.markdown-body td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.markdown-body th { background: var(--panel-2); font-weight: 600; color: var(--text); }
.markdown-body tr:nth-child(even) td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.markdown-body img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--border); margin: .5em 0; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body input[type="checkbox"] { margin-right: .4em; }

.math-display { margin: .9em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.katex { font-size: 1.05em; }
.katex-display { margin: .6em 0; }
.math-error { color: var(--danger); }

/* ------------------------------ 复习条 ------------------------------ */

.review-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--warn-soft);
  flex-wrap: wrap;
}
.review-hint { font-size: 12.5px; color: var(--warn); font-weight: 600; }
.review-actions { display: flex; gap: 7px; margin-left: auto; flex-wrap: wrap; }
.grade {
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all .12s;
}
.grade.again { background: var(--panel); border-color: var(--danger); color: var(--danger); }
.grade.again:hover { background: var(--danger); color: #fff; }
.grade.hard { background: var(--panel); border-color: var(--warn); color: var(--warn); }
.grade.hard:hover { background: var(--warn); color: #fff; }
.grade.good { background: var(--panel); border-color: var(--ok); color: var(--ok); }
.grade.good:hover { background: var(--ok); color: #fff; }

/* ------------------------------ 统计 ------------------------------ */

.stats-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 60px;
}
.stats-head { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.stats-head h2 { margin: 0; font-size: 19px; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-card .value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat-card .value small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.panel h3 { margin: 0 0 14px; font-size: 14px; }

.chart { display: flex; align-items: stretch; gap: 4px; height: 132px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.chart-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.chart-bar {
  width: 100%;
  max-width: 26px;
  background: linear-gradient(180deg, #818cf8, var(--accent));
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  transition: height .3s;
}
.chart-bar.zero { background: var(--border); }
.chart-label { font-size: 9.5px; color: var(--muted); white-space: nowrap; text-align: center; height: 13px; line-height: 13px; }

.subject-stats { display: flex; flex-direction: column; gap: 10px; }
.subject-stat-row { display: grid; grid-template-columns: 130px 1fr 90px; gap: 12px; align-items: center; font-size: 12.5px; }
.subject-stat-name { display: flex; align-items: center; gap: 7px; overflow: hidden; }
.subject-stat-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-bar-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.subject-bar-fill { height: 100%; border-radius: 999px; background: var(--c); }
.subject-stat-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.tag-matrix { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------ Toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(10px);
  background: #111827;
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 45;
}

/* ------------------------------ 移动端 ------------------------------ */

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }

  .only-mobile { display: inline-flex !important; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(290px, 84vw);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar.open ~ .scrim { display: block; }

  .list-pane { border-right: none; }

  .editor-pane {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--panel);
  }
  .app:not(.view-editor) .editor-pane { display: none; }
  .app.view-editor .list-pane { display: none; }

  .editor-head { padding: 8px 10px; gap: 6px; }
  .title-input { font-size: 16px; }
  .meta-row { padding: 6px 10px; }
  .editor-toolbar { padding: 6px 10px; }
  .editor-textarea { padding: 14px 14px 40px; font-size: 15px; }
  .preview { padding: 14px 16px 60px; }
  .editor-body.mode-split .editor-textarea { display: none; }
  .editor-body.mode-split .preview { display: block; border-left: none; }
  .stats-view { padding: 16px 14px 60px; }
  .save-state { display: none; }
}

@media (max-width: 640px) {
  .editor-actions .chip-btn { padding: 4px 8px; font-size: 11.5px; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .subject-stat-row { grid-template-columns: 92px 1fr 68px; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

::selection { background: rgba(79, 70, 229, .22); }
