:root {
  --bg: #eef7f2;
  --paper: #ffffff;
  --paper-soft: #f8fcfa;
  --ink: #172321;
  --muted: #6b7b78;
  --line: #d8e7e1;
  --mint: #36b58a;
  --mint-dark: #16815e;
  --teal: #1a9288;
  --rose: #e56565;
  --amber: #d99a2b;
  --shadow: 0 18px 50px rgba(33, 84, 72, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at top left, rgba(82,135,216,.16), transparent 34rem), linear-gradient(135deg, #f7fbf9 0%, var(--bg) 58%, #e8f4f5 100%);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
button, input, textarea { font: inherit; }
button { border: 0; border-radius: 8px; background: var(--paper); color: var(--ink); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(37,86,73,.12); }
button:active { transform: translateY(0); }
.shell { width: min(1120px, calc(100vw - 28px)); margin: 0 auto; padding: 28px 0 44px; }
.hero { min-height: 170px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.kicker { margin: 0 0 8px; color: var(--mint-dark); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(36px, 7vw, 72px); letter-spacing: 0; }
h2 { margin-bottom: 6px; font-size: 22px; letter-spacing: 0; }
.subtitle { color: var(--muted); font-size: 18px; margin-bottom: 0; }
.daily-ring { position: relative; width: 128px; height: 128px; display: grid; place-items: center; flex: 0 0 auto; }
.daily-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.daily-ring circle { fill: none; stroke-width: 11; }
.ring-bg { stroke: #d6ebe2; }
.ring-fg { stroke: var(--mint); stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314; transition: stroke-dashoffset .35s ease; }
.daily-ring div { text-align: center; }
.daily-ring strong { font-size: 32px; }
.daily-ring span { color: var(--muted); }
.dashboard { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.dashboard div, .panel, .card { border: 1px solid rgba(216,231,225,.88); background: rgba(255,255,255,.82); backdrop-filter: blur(14px); box-shadow: var(--shadow); border-radius: 8px; }
.dashboard div { padding: 16px; }
.dashboard span { display: block; font-size: 30px; font-weight: 850; }
.dashboard small { color: var(--muted); }
.main-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { padding: 16px; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; background: #edf7f2; border-radius: 8px; }
.mode-tabs button { padding: 9px 6px; background: transparent; color: var(--muted); }
.mode-tabs button.active { background: var(--paper); color: var(--mint-dark); font-weight: 800; box-shadow: 0 7px 18px rgba(22,129,94,.12); }
.field { display: block; margin: 16px 0; }
.field span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.field input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); outline: none; }
.field input { padding: 12px 13px; }
.chapter-list { display: flex; flex-direction: column; gap: 8px; max-height: 330px; overflow: auto; padding-right: 2px; }
.chapter-list button { width: 100%; padding: 10px 12px; text-align: left; background: transparent; color: #38514b; }
.chapter-list button.active { background: #e7f7ef; color: var(--mint-dark); font-weight: 800; }
.reminder { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin: 16px 0; padding: 12px; background: var(--paper-soft); border: 1px solid var(--line); border-radius: 8px; }
.reminder p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.reminder button, .ghost { border: 1px solid var(--line); background: transparent; padding: 10px 12px; }
.full { width: 100%; }
.study-area { min-width: 0; }
.card { min-height: 480px; padding: 28px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(248,252,250,.94)), var(--paper); }
.card-top, .schedule-note { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 14px; }
.question { margin: 34px 0 26px; font-size: clamp(28px, 4.8vw, 54px); line-height: 1.28; font-weight: 850; letter-spacing: 0; }
.answer { margin-top: 10px; padding: 20px; border-radius: 8px; background: #f1f9f5; color: #21302d; font-size: 22px; line-height: 1.55; }
.hidden { display: none; }
.controls { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }
.primary { padding: 12px 22px; color: #fff; background: linear-gradient(135deg, var(--mint), var(--teal)); font-weight: 800; }
.round { width: 46px; height: 46px; font-size: 28px; line-height: 1; }
.grade-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.grade { padding: 13px 12px; text-align: left; border: 1px solid transparent; }
.grade strong, .grade span { display: block; }
.grade span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.again { background: #fff2f2; border-color: #ffd0d0; }
.hard { background: #fff8e8; border-color: #f6dfad; }
.good { background: #effaf4; border-color: #cfeedd; }
.editor { margin-top: 20px; }
.editor-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.editor-head p { margin-bottom: 12px; color: var(--muted); }
.editor-actions { display: flex; gap: 8px; }
textarea { min-height: 250px; resize: vertical; padding: 13px; line-height: 1.48; font-family: Consolas, "Microsoft YaHei", monospace; }
.editor-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
#saveHint { color: var(--muted); font-size: 14px; }
@media (max-width: 820px) {
  .shell { width: min(100vw - 20px, 680px); padding-top: 18px; }
  .hero { align-items: flex-start; }
  .daily-ring { width: 102px; height: 102px; }
  .dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-grid { grid-template-columns: 1fr; }
  .chapter-list { flex-direction: row; max-height: none; overflow-x: auto; padding-bottom: 4px; }
  .chapter-list button { white-space: nowrap; }
  .card { min-height: 410px; padding: 20px; }
  .question { font-size: 30px; }
  .answer { font-size: 19px; padding: 16px; }
  .grade-row { grid-template-columns: 1fr; }
  .editor-head { flex-direction: column; }
}

.catalog-panel { margin-bottom: 18px; }
.catalog-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.catalog-head p { margin-bottom: 0; color: var(--muted); }
.catalog-head span { color: var(--mint-dark); font-weight: 850; background: #e7f7ef; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.catalog-item { padding: 13px; text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.72); min-height: 120px; }
.catalog-item.active { border-color: rgba(54,181,138,.72); background: #f0fbf6; }
.catalog-item strong { display: block; margin-bottom: 6px; line-height: 1.35; }
.catalog-item small { display: block; color: var(--muted); line-height: 1.45; }
.catalog-meter { height: 7px; margin: 12px 0 8px; overflow: hidden; border-radius: 999px; background: #e3f0ea; }
.catalog-meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mint), var(--teal)); border-radius: inherit; }
.catalog-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
@media (max-width: 900px) { .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .catalog-grid { grid-template-columns: 1fr; } }




.card, .question, .answer { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.card { overflow: hidden; gap: 18px; }
.question { font-size: clamp(28px, 4.8vw, 54px); }
.answer { overflow: hidden; overflow-wrap: anywhere; }
.answer mjx-container { max-width: 100% !important; overflow: hidden !important; }
.answer mjx-container[jax="SVG"] { display: inline-block; vertical-align: middle; }
.answer mjx-container[display="true"] { display: block; margin: 0.45rem auto; text-align: center; }
.answer mjx-container[jax="SVG"] > svg { max-width: 100% !important; height: auto !important; }
.answer .MathJax, .answer svg { max-width: 100%; }
@media (max-width: 820px) { .question { font-size: 30px; } }
