/* ==========================================================================
   知识点记忆卡 · 样式
   ========================================================================== */

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --ink: #14161d;
  --ink-2: #3b4050;
  --muted: #7b8194;
  --line: #e8eaf2;
  --line-2: #f0f2f8;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-ink: #3730a3;
  --teal: #0d9488;
  --teal-soft: #e6f7f5;
  --good: #15a34a;
  --good-soft: #e7f7ee;
  --bad: #e11d48;
  --bad-soft: #fdeef1;
  --warn: #d97706;
  --shadow-sm: 0 1px 2px rgba(20, 22, 29, .04), 0 2px 8px rgba(20, 22, 29, .04);
  --shadow-md: 0 2px 6px rgba(20, 22, 29, .05), 0 12px 32px rgba(20, 22, 29, .07);
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --surface: #171a21;
    --surface-2: #1d2129;
    --ink: #eef1f7;
    --ink-2: #c8cddb;
    --muted: #8d94a8;
    --line: #262b35;
    --line-2: #20242c;
    --accent: #8b8cf7;
    --accent-soft: #23253a;
    --accent-ink: #c7c9ff;
    --teal: #34d3bf;
    --teal-soft: #16302e;
    --good: #3ddc84;
    --good-soft: #14301f;
    --bad: #ff6b8a;
    --bad-soft: #33181f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1100px 500px at 12% -8%, color-mix(in oklab, var(--accent) 9%, transparent), transparent 60%),
    radial-gradient(900px 460px at 92% 0%, color-mix(in oklab, var(--teal) 8%, transparent), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 17px; }
h2 { font-size: 22px; letter-spacing: -.02em; }
h3 { font-size: 14px; color: var(--ink-2); }
h4 { font-size: 14.5px; }
p { margin: 0; }
button { font-family: inherit; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

.app { max-width: 1180px; margin: 0 auto; padding: 20px 22px 36px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 4px 2px 18px;
}
.brand { display: flex; align-items: center; gap: 11px; flex: none; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #7c3aed 60%, var(--teal));
  color: #fff; font-size: 19px; font-weight: 700;
  box-shadow: 0 6px 18px color-mix(in oklab, var(--accent) 35%, transparent);
}
.brand-text p { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; }

.tabs {
  display: flex; gap: 3px; padding: 4px; margin-left: 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  font-size: 13.5px; padding: 7px 15px; border-radius: 9px; cursor: pointer;
  white-space: nowrap; transition: .16s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.sync-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--ink-2);
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: .16s;
}
.sync-chip:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); }
.sync-chip .dot, .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none;
  display: inline-block;
}
.sync-chip.online .dot, .dot.online { background: var(--good); box-shadow: 0 0 0 3px color-mix(in oklab, var(--good) 18%, transparent); }
.sync-chip.connecting .dot, .dot.connecting { background: var(--warn); animation: pulse 1.1s infinite; }
.sync-chip.offline .dot, .dot.offline { background: var(--bad); }
.sync-chip.local .dot, .dot.local { background: var(--muted); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 18px; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { color: var(--ink); border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }

/* ---------------- 页签视图 ---------------- */
.view { animation: fadeIn .2s ease; }
.today-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 322px; gap: 18px; align-items: start;
}
.side { display: flex; flex-direction: column; gap: 18px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.panel h3 { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.deck-line {
  font-size: 11.5px; color: var(--muted); margin: -8px 0 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.deck-line:empty { display: none; }

/* ---------------- 今日任务头 ---------------- */
.panel-head { display: flex; gap: 20px; align-items: center; }

.ring-wrap { position: relative; width: 96px; height: 96px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-bg { stroke: var(--line-2); }
.ring-fg {
  stroke: var(--accent);
  stroke-dasharray: 270.2;
  stroke-dashoffset: 270.2;
  transition: stroke-dashoffset .5s cubic-bezier(.4, 0, .2, 1);
}
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.15; }
.ring-label strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: 12px; color: var(--muted); }
.ring-label em { font-style: normal; }

.head-meta { min-width: 0; }
.eyebrow { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.head-meta h2 { margin: 2px 0 4px; }
.head-meta .muted { font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.chip {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip b { font-variant-numeric: tabular-nums; }
.chip.new { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chip.review { background: var(--teal-soft); border-color: transparent; color: var(--teal); }
.chip.drill { background: #fff7ed; border-color: transparent; color: var(--warn); }

.refresh-line { margin-top: 9px; }
.refresh-line b { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------------- 筛选 ---------------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; }
.filter {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-size: 12.5px; padding: 5px 12px; border-radius: 999px; cursor: pointer; transition: .16s;
}
.filter:hover { color: var(--ink); border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ---------------- 任务卡 ---------------- */
.task-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.task {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); padding: 14px 16px;
  transition: border-color .18s, box-shadow .18s, opacity .25s;
}
.task:hover { border-color: color-mix(in oklab, var(--accent) 22%, var(--line)); }
.task.is-active { border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px var(--accent-soft); }
.task.is-done { opacity: .62; background: var(--surface-2); }

.task-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.num {
  font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted);
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); flex: none;
}
.kind { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.kind.k-new { background: var(--accent-soft); color: var(--accent-ink); }
.kind.k-review { background: var(--teal-soft); color: var(--teal); }
.kind.k-drill { background: #fff7ed; color: var(--warn); }
@media (prefers-color-scheme: dark) {
  .kind.k-drill, .chip.drill { background: #2a2113; }
}
.tag {
  font-size: 11px; color: var(--muted); padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--line); margin-left: auto; white-space: nowrap;
  max-width: 52%; overflow: hidden; text-overflow: ellipsis; flex: none;
}
.star { color: var(--warn); font-size: 12px; line-height: 1; }

.task-front { font-size: 15.5px; font-weight: 560; color: var(--ink); }
.task-back {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border-left: 3px solid var(--accent);
  color: var(--ink-2); font-size: 14px; white-space: pre-wrap; word-break: break-word;
  animation: fadeIn .22s ease;
}
.task-back.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.task-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.task.is-done .task-actions { display: none; }

.result {
  margin-top: 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
}
.result.ok { background: var(--good-soft); color: var(--good); }
.result.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------------- 按钮 ---------------- */
.btn {
  font-size: 13px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: .16s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: none; }
.btn.sm { font-size: 12.5px; padding: 6px 12px; }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.good { background: var(--good-soft); color: var(--good); border-color: transparent; font-weight: 600; }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn kbd {
  font: inherit; font-size: 10.5px; padding: 1px 5px; border-radius: 5px;
  background: color-mix(in oklab, currentColor 10%, transparent); opacity: .75;
}

/* ---------------- 侧栏 ---------------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  padding: 11px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line-2);
}
.stat span { display: block; font-size: 11.5px; color: var(--muted); }
.stat strong { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat strong i { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 500; }

.curve svg { width: 100%; height: auto; display: block; }
.curve-note { margin-top: 8px; line-height: 1.5; }

.forecast { display: flex; align-items: flex-end; gap: 6px; height: 108px; }
.fc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; height: 100%; }
.fc-bar {
  width: 100%; border-radius: 6px 6px 3px 3px; min-height: 3px;
  background: color-mix(in oklab, var(--accent) 75%, transparent);
  transition: height .4s cubic-bezier(.4, 0, .2, 1);
}
.fc-col.today .fc-bar { background: var(--ink); }
.fc-col.is-zero .fc-bar { background: var(--line); }
.fc-val { font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fc-day { font-size: 11px; color: var(--muted); }
.fc-empty { margin-top: 10px; line-height: 1.5; }

.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.hm-cell { width: 100%; aspect-ratio: 1; border-radius: 3px; background: var(--line-2); display: block; }
.hm-cell.is-empty { background: transparent; }
.hm-cell.lv0 { background: var(--line-2); }
.hm-cell.lv1 { background: color-mix(in oklab, var(--accent) 28%, var(--surface)); }
.hm-cell.lv2 { background: color-mix(in oklab, var(--accent) 52%, var(--surface)); }
.hm-cell.lv3 { background: color-mix(in oklab, var(--accent) 76%, var(--surface)); }
.hm-cell.lv4 { background: var(--accent); }
.hm-legend { display: flex; align-items: center; gap: 5px; margin-top: 10px; }
.hm-legend .hm-cell { width: 12px; height: 12px; aspect-ratio: auto; }

/* ---------------- 卡片库 ---------------- */
.cards-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.cards-toolbar input[type="search"] {
  flex: 1; min-width: 170px; font-size: 13.5px; padding: 9px 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.cards-toolbar input:focus, .cards-toolbar select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.cards-toolbar select, .practice-head select {
  font-size: 13px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  max-width: 220px;
}
.chip-btn {
  font-size: 12.5px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip-btn.is-on { background: #fff7ed; border-color: #fde3c4; color: var(--warn); }
@media (prefers-color-scheme: dark) { .chip-btn.is-on { background: #2a2113; border-color: #3b2f1b; } }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }
.lib-card {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px;
  background: var(--surface-2); display: flex; flex-direction: column; gap: 8px;
  transition: .16s; cursor: pointer;
}
.lib-card:hover { border-color: color-mix(in oklab, var(--accent) 30%, var(--line)); box-shadow: var(--shadow-sm); }
.lib-head { display: flex; align-items: flex-start; gap: 8px; }
.lib-head h4 { flex: 1; line-height: 1.45; }
.star-btn {
  border: 0; background: transparent; color: var(--line); font-size: 15px; line-height: 1;
  cursor: pointer; padding: 0 2px; transition: .15s;
}
.star-btn:hover { color: var(--warn); }
.star-btn.on { color: var(--warn); }
.lib-back {
  font-size: 12.5px; color: var(--ink-2); white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-foot { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); margin-top: auto; }
.deck-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.lib-next { margin-left: auto; white-space: nowrap; }
.icon-link {
  border: 0; background: transparent; color: var(--muted); font-size: 11px;
  cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px;
}
.icon-link:hover { color: var(--ink); }
.icon-link.danger:hover { color: var(--bad); }
.dots { display: inline-flex; gap: 3px; }
.dot-small, .dots .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots .dot.on { background: var(--accent); }

/* ---------------- 背诵 / 抽卡 ---------------- */
.practice-panel { max-width: 760px; margin: 0 auto; }
.practice-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.practice-head h2 { margin-top: 2px; }

.flip-card {
  width: 100%; min-height: 300px; padding: 32px 26px;
  border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  cursor: pointer; text-align: center; transition: .18s; color: var(--ink);
}
.flip-card:hover { border-color: color-mix(in oklab, var(--accent) 30%, var(--line)); }
.flip-card.is-flipped { background: linear-gradient(180deg, var(--accent-soft), var(--surface)); border-color: color-mix(in oklab, var(--accent) 30%, var(--line)); }
.flip-label { font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.flip-text { font-size: 20px; line-height: 1.75; font-weight: 560; white-space: pre-wrap; word-break: break-word; max-width: 100%; }
.flip-hint { font-size: 11.5px; color: var(--muted); }

.practice-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(12, 14, 20, .45);
  display: grid; place-items: center; padding: 20px; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-md); border: 1px solid var(--line);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-card p { margin-bottom: 12px; }
.modal-card code {
  font-size: 11.5px; padding: 1px 5px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.modal-card textarea, .modal-card input[type="text"], .modal-card input:not([type]) {
  width: 100%; font-family: inherit; font-size: 13.5px; line-height: 1.7; padding: 10px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); resize: vertical;
}
.modal-card textarea { min-height: 84px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.modal-card textarea:focus, .modal-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.field-col { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.field-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.field-row .field-col { flex: 1; min-width: 180px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); padding-bottom: 12px; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

.sync-box {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px;
  background: var(--surface-2); margin-bottom: 16px;
}
.sync-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.sync-box input { width: 100%; font-family: ui-monospace, Consolas, monospace; letter-spacing: .06em; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.field input[type="number"] {
  width: 78px; font-size: 13px; text-align: center; padding: 7px 8px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--surface); font-size: 13px;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity .22s, transform .22s; z-index: 60; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { text-align: center; padding-top: 20px; }

/* ---------------- 桌面任务列表内滚动 ---------------- */
@media (min-width: 981px) {
  .task-list {
    max-height: calc(100vh - 360px);
    min-height: 380px;
    overflow-y: auto;
    padding: 2px 8px 6px 2px;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in oklab, var(--muted) 40%, transparent) transparent;
    mask-image: linear-gradient(to bottom, #000 calc(100% - 34px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 34px), transparent 100%);
  }
  .task-list.at-bottom { mask-image: none; -webkit-mask-image: none; }
  .task-list::-webkit-scrollbar { width: 8px; }
  .task-list::-webkit-scrollbar-thumb {
    background: color-mix(in oklab, var(--muted) 35%, transparent); border-radius: 999px;
  }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 980px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .tabs { margin-left: 0; }
  .topbar { flex-wrap: wrap; }
  .tabs { order: 3; flex: 1 1 100%; }
  .topbar-right { margin-left: auto; }
}

@media (max-width: 620px) {
  .app { padding: 14px 14px 30px; }
  .brand { flex: 1 1 auto; }
  .topbar { gap: 10px; padding-bottom: 12px; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { font-size: 11px; }
  .sync-chip { padding: 5px 10px; font-size: 11.5px; }
  .panel { padding: 16px; border-radius: 16px; }
  .panel-head { flex-direction: row; align-items: center; gap: 14px; }
  .ring-wrap { width: 66px; height: 66px; }
  .ring-label strong { font-size: 18px; }
  .ring-label span { font-size: 10px; }
  h2 { font-size: 19px; }
  .chips { margin-top: 9px; }
  .side { grid-template-columns: 1fr; }
  .task { padding: 12px 14px; }
  .task-front { font-size: 14.5px; }
  .task-back { font-size: 13.5px; }
  .cards-grid { grid-template-columns: 1fr; }
  .cards-toolbar input[type="search"] { min-width: 0; flex: 1 1 100%; }
  .cards-toolbar select { flex: 1; max-width: none; }
  .heatmap { max-width: 320px; }
  .flip-card { min-height: 240px; padding: 24px 18px; }
  .flip-text { font-size: 17px; }
  .settings-grid { grid-template-columns: 1fr; }
  .field-row { flex-direction: column; align-items: stretch; }
  .check { padding-bottom: 0; }
}

/* ==================== 单卡聚焦 · 极简 ==================== */
:root {
  --star: #b45309;
  --star-soft: #fff7ed;
  --star-line: #f59e0b;
}

.today-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.today-bar { display: flex; align-items: center; gap: 14px; padding: 2px 4px; }
.today-date { font-size: 12.5px; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.meter-wrap { flex: 1; display: flex; align-items: center; gap: 10px; max-width: 300px; }
.meter { flex: 1; height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.meter i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.meter i.is-full { background: linear-gradient(90deg, #16a34a, #34d399); }
.meter-text { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-note { font-size: 12px; color: var(--muted); white-space: nowrap; }
.link-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 4px 2px; transition: .15s;
}
.link-btn:hover { color: var(--ink); }

/* 焦点卡 */
.focus-card {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px 28px 20px;
  min-height: 360px;
  display: flex; flex-direction: column;
  box-shadow: 0 1px 2px rgba(20, 22, 29, .03), 0 24px 48px -32px rgba(20, 22, 29, .22);
  transition: border-color .2s, box-shadow .2s;
}
.focus-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 160px;
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 6%, transparent), transparent);
  pointer-events: none;
}
.focus-card.is-star {
  border-color: color-mix(in oklab, var(--star-line) 42%, var(--line));
  background: linear-gradient(180deg, #fffdf7, var(--surface) 58%);
}
.focus-card.is-star::before { background: linear-gradient(180deg, rgba(245, 158, 11, .12), transparent); }
.focus-card.is-star::after {
  content: ''; position: absolute; left: 0; top: 22px; bottom: 22px; width: 4px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #fbbf24, #d97706);
}
.focus-card.is-done { background: var(--surface-2); }

.focus-head {
  position: relative; display: flex; align-items: center; gap: 10px;
  font-size: 12px; min-height: 22px;
}
.focus-idx { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.focus-deck {
  margin-left: auto; color: var(--muted); font-size: 11.5px;
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.star-pill {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
  box-shadow: 0 3px 10px -2px rgba(217, 119, 6, .5);
}

.focus-body {
  position: relative; flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  padding: 22px 0 18px; gap: 18px;
}
.focus-front {
  font-size: 27px; line-height: 1.6; font-weight: 600;
  letter-spacing: -.012em; word-break: break-word;
}
.focus-back {
  font-size: 15px; line-height: 1.95; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
  padding-top: 18px; border-top: 1px dashed var(--line);
  animation: fadeIn .2s ease;
}

.focus-foot { position: relative; display: flex; align-items: center; gap: 10px; }
.focus-actions { flex: 1; }
.focus-mark { display: flex; gap: 10px; }
.focus-mark .btn { flex: 1; justify-content: center; }
.btn.wide { width: 100%; justify-content: center; }
.focus-done { flex: 1; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.result-flag { font-size: 12.5px; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
.result-flag.ok { background: var(--good-soft); color: var(--good); }
.result-flag.bad { background: var(--bad-soft); color: var(--bad); }

.focus-tools {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px;
}

/* 完成卡 */
.finish-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 48px 28px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.finish-mark {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 18px;
  display: grid; place-items: center; font-size: 24px; color: #fff;
  background: linear-gradient(135deg, #16a34a, #34d399);
  box-shadow: 0 12px 26px -10px rgba(22, 163, 74, .6);
}
.finish-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.finish-note { margin-top: 14px; }

/* 列表 / 复盘 */
.list-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; flex-wrap: wrap; }
.list-bar .filters { margin: 0; }
.review-note { padding: 2px 4px 4px; }

.task-row {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 15px; margin-bottom: 8px;
  cursor: pointer; transition: .15s;
}
.task-row:hover { border-color: color-mix(in oklab, var(--accent) 28%, var(--line)); box-shadow: var(--shadow-sm); }
.task-row.is-star {
  border-left: 3px solid var(--star-line);
  background: linear-gradient(90deg, #fffdf7, var(--surface) 30%);
}
.task-row.is-done { opacity: .66; }
.task-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.task-row-num { font-size: 11px; color: var(--muted); width: 22px; font-variant-numeric: tabular-nums; }
.task-row-deck {
  margin-left: auto; font-size: 11px; color: var(--muted);
  max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-row-front { font-size: 15px; font-weight: 560; }
.task-row-back {
  margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line);
  font-size: 13px; line-height: 1.85; color: var(--ink-2); white-space: pre-wrap;
}
.task-row-flag { font-size: 12px; flex: none; }
.task-row-flag.ok { color: var(--good); }
.task-row-flag.bad { color: var(--bad); }

.task-list { max-height: none; mask-image: none; -webkit-mask-image: none; overflow: visible; padding: 0; }

/* 卡片库里的重点 */
.lib-card.is-star {
  border-left: 3px solid var(--star-line);
  background: linear-gradient(90deg, #fffdf7, var(--surface-2) 32%);
}
.star-btn.on { color: var(--star-line); }
.star { color: var(--star-line); }

.footer { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.foot-right b { color: var(--ink-2); font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  .focus-card { min-height: 320px; }
  .meter-wrap { max-width: none; }
}

@media (max-width: 620px) {
  .today-bar { flex-wrap: wrap; gap: 8px; }
  .today-date { font-size: 12px; }
  .meter-wrap { order: 3; flex: 1 1 100%; }
  .meter-note { order: 2; margin-left: auto; }
  .focus-card { padding: 18px 18px 16px; min-height: 300px; border-radius: 20px; }
  .focus-card.is-star::after { top: 16px; bottom: 16px; }
  .focus-front { font-size: 21px; line-height: 1.55; }
  .focus-back { font-size: 14px; line-height: 1.85; }
  .focus-deck { max-width: 40%; }
  .focus-mark .btn { padding: 9px 10px; font-size: 12.5px; }
  .finish-card { padding: 36px 18px; border-radius: 20px; }
  .focus-tools .muted { display: none; }
}

/* ---- 打磨：进度条 / 按钮对比 / 卡片高度 ---- */
.meter {
  background: #e7eaf3;
  height: 7px;
  box-shadow: inset 0 0 0 1px rgba(20, 22, 29, .04);
}
.meter i { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.meter i.is-full { background: linear-gradient(90deg, #10b981, #34d399); }

.focus-card { min-height: clamp(380px, 54vh, 520px); }

.focus-actions { display: flex; justify-content: center; }
.focus-actions .btn.wide {
  width: auto; min-width: 220px; padding: 11px 34px;
  border-radius: 12px; justify-content: center;
}
.focus-mark {
  max-width: 460px; width: 100%; margin: 0 auto; gap: 12px;
}
.focus-mark .btn {
  flex: 1; justify-content: center; padding: 11px 12px;
  border-radius: 12px; font-weight: 600;
}
.focus-mark .btn.good {
  background: #15a34a; color: #fff; border-color: #15a34a;
  box-shadow: 0 8px 20px -10px rgba(21, 163, 74, .8);
}
.focus-mark .btn.good:hover { background: #12903f; }
.focus-mark .btn.good kbd { background: rgba(255, 255, 255, .22); }
.focus-mark .btn.bad {
  background: #fff; color: #d81b45; border-color: #f4c3cf;
}
.focus-mark .btn.bad:hover { background: #fff5f7; border-color: #ee9db0; }

.focus-done .btn { border-radius: 12px; padding: 10px 22px; }

/* 顶部条更紧凑 */
.today-bar { gap: 12px; }
.today-bar .link-btn {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; background: var(--surface); font-size: 12px;
  box-shadow: var(--shadow-sm);
}
.today-bar .link-btn:hover { border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }

/* 侧栏稍微收一点 */
.forecast { height: 92px; }
.panel { padding: 18px; }
.panel h3 { margin-bottom: 12px; }

@media (max-width: 620px) {
  .today-bar { gap: 6px 10px; }
  .today-date { order: 1; }
  .meter-note { order: 2; margin-left: auto; }
  .today-bar .link-btn { order: 3; }
  .meter-wrap { order: 4; flex: 1 1 100%; }
  .focus-card { min-height: 380px; }
}

@media (max-width: 620px) {
  .focus-card { min-height: 320px; }
  .focus-body { padding: 18px 0 14px; }
}

/* 卡片内容顶部对齐，避免短问题悬空 */
.focus-body { justify-content: flex-start; padding: 34px 0 24px; }
.focus-card { min-height: clamp(340px, 46vh, 460px); }
.focus-back { margin-top: 4px; }

@media (max-width: 620px) {
  .focus-body { padding: 20px 0 16px; }
  .focus-card { min-height: 300px; }
}

/* 操作区左对齐，和内容对齐 */
.focus-actions { justify-content: flex-start; }
.focus-actions .btn.wide { min-width: 200px; padding: 11px 28px; }
.focus-mark { margin: 0; max-width: 420px; }

/* 「只练重点」开关 */
.mode-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: 12px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: .15s; white-space: nowrap; line-height: 1.6;
}
.mode-chip:hover { color: var(--star); border-color: color-mix(in oklab, var(--star-line) 45%, var(--line)); }
.mode-chip.is-on {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; border-color: transparent;
  box-shadow: 0 5px 14px -6px rgba(217, 119, 6, .75);
}
@media (max-width: 620px) {
  .mode-chip { order: 3; }
  .today-bar .link-btn { order: 4; }
  .meter-wrap { order: 5; }
}

/* 学习中的状态（还需 N 次） */
.result-flag.waiting { background: #fff7ed; color: var(--star); }
.task-row-flag.waiting { color: var(--star); font-size: 11px; }
.focus-tools .muted { white-space: nowrap; }

/* 考试倒计时 */
.exam-badge {
  font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); white-space: nowrap; box-shadow: var(--shadow-sm);
}
.exam-badge.urgent {
  background: #fff1f2; border-color: #fecdd3; color: #be123c; font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .exam-badge.urgent { background: #33141c; border-color: #4c1d24; }
}
@media (max-width: 620px) {
  .exam-badge { order: 1; }
  .today-date { order: 0; }
}

/* 顽固卡标记 */
.hard-badge {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  background: #fef2f2; color: #b91c1c; white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  .hard-badge { background: #33161a; color: #fca5a5; }
}

/* ==================== 顽固卡 ==================== */
.tab-badge {
  display: inline-block; margin-left: 5px; padding: 0 5px;
  font-size: 10px; line-height: 15px; border-radius: 999px;
  background: #fef2f2; color: #b91c1c; font-weight: 600;
  vertical-align: 1px;
}
@media (prefers-color-scheme: dark) {
  .tab-badge { background: #33161a; color: #fca5a5; }
}

.weak-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.weak-head h2 { margin-top: 2px; }
.weak-head-right { display: flex; align-items: center; gap: 10px; }
.weak-tip { margin: 10px 0 16px; line-height: 1.6; }

.weak-list { display: flex; flex-direction: column; gap: 10px; }
.weak-card {
  border: 1px solid var(--line); border-left: 3px solid #f0a7a7;
  border-radius: 14px; padding: 13px 16px; background: var(--surface-2);
  cursor: pointer; transition: .15s;
}
.weak-card:hover { border-color: color-mix(in oklab, #e11d48 25%, var(--line)); }
.weak-card.is-star { border-left-color: var(--star-line); }
.weak-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 11.5px; color: var(--muted); }
.weak-lapses {
  padding: 1px 8px; border-radius: 999px; background: #fef2f2; color: #b91c1c; font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .weak-lapses { background: #33161a; color: #fca5a5; }
}
.weak-deck { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.weak-next { margin-left: auto; white-space: nowrap; }
.weak-front { font-size: 15px; font-weight: 560; }
.weak-back {
  margin-top: 8px; font-size: 13px; line-height: 1.85; color: var(--ink-2);
  white-space: pre-wrap; display: none;
}
.weak-card.is-open .weak-back { display: block; }

@media (max-width: 620px) {
  .weak-deck { max-width: 32%; }
  .weak-next { font-size: 11px; }
}
