/* Study Coach · 四款个性化主题 V1
   仅视觉覆盖 app.css；所有分数/掌握度/错题数据仍由原 API 提供。
   状态语义色（错误/成功/警告）保持一致，避免主题误导判断。 */
:root {
  --sc-tint: #f6f3ff;
  --sc-ink: #322d56;
  --sc-accent-2: #ec8cc7;
  --sc-highlight: #f7eafa;
  --sc-glow: rgba(127, 91, 219, .14);
  --sc-header: linear-gradient(105deg, #fff 0%, #fcf8ff 55%, #f9eeff 100%);
  --sc-hero: linear-gradient(110deg, #ede9ff, #fff4fb 63%, #f5f3ff);
  --sc-focus: #7052bd;
  --sc-motto: "每一份努力，都在悄悄发光";
  --sc-icon: "✦";
  --sc-motif: url("motifs/unicorn.svg");
  --bg: #f7f6fd;
  --card: #fff;
  --text: #2d2947;
  --muted: #69657e;
  --line: #e7e0f4;
  --primary: #7052bd;
  --primary-soft: #eee8ff;
  --blue: #625acf;
  --blue-soft: #eaeaff;
  --radius: 18px;
  color-scheme: light;
}
:root[data-study-theme="sakura"] {
  --bg: #fff7f8; --text: #4b2c40; --muted: #806575; --line: #f3dce3;
  --primary: #ad406f; --primary-soft: #ffe9f0;
  --blue: #9b58b3; --blue-soft: #f5eaff;
  --sc-tint: #fff2f6; --sc-ink: #843d62; --sc-accent-2: #ec87a5;
  --sc-glow: rgba(222, 97, 147, .13);
  --sc-header: linear-gradient(110deg, #fff, #fff0f4);
  --sc-hero: linear-gradient(105deg, #ffeaf1, #fff9f9 62%, #ffe5ec);
  --sc-focus: #ad406f;
  --sc-motto: "把每一次坚持，写进成长手账";
  --sc-icon: "❀";
  --sc-motif: url("motifs/sakura.svg");
}
:root[data-study-theme="starlight"] {
  --bg: #f2f5fe; --text: #25345c; --muted: #617094; --line: #dce4fa;
  --primary: #565eb8; --primary-soft: #e5eafd;
  --blue: #526dba; --blue-soft: #e9efff;
  --sc-tint: #e8eeff; --sc-ink: #253a78; --sc-accent-2: #a88de7;
  --sc-glow: rgba(59, 82, 164, .2);
  --sc-header: linear-gradient(110deg, #172d60 0%, #394982 70%, #65549e 100%);
  --sc-hero: linear-gradient(110deg, #dae5ff, #f9f7ff 65%, #e2dcff);
  --sc-focus: #565eb8;
  --sc-motto: "星光不负赶路人，认真走好每一步";
  --sc-icon: "☾";
  --sc-motif: url("motifs/starlight.svg");
}
:root[data-study-theme="cat"] {
  --bg: #fffaf4; --text: #4c392f; --muted: #77655e; --line: #efe2d3;
  --primary: #995b48; --primary-soft: #fcebe3;
  --blue: #597d71; --blue-soft: #e9f4ed;
  --sc-tint: #fff2e8; --sc-ink: #704a38; --sc-accent-2: #eaa886;
  --sc-glow: rgba(176, 113, 73, .14);
  --sc-header: linear-gradient(105deg, #fffefa, #fff0e5 70%, #f0f7ef);
  --sc-hero: linear-gradient(110deg, #ffecdf, #fffef6 60%, #edf6eb);
  --sc-focus: #995b48;
  --sc-motto: "慢慢来，也会抵达想去的地方";
  --sc-icon: "♡";
  --sc-motif: url("motifs/cat.svg");
}
/* 统一页面骨架：上方柔和主题横幅，内容卡片保持高对比和可读性 */
html { scroll-behavior: smooth; }
body { min-width: 320px; background: var(--bg); color: var(--text); }
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: min(420px, 55vh);
  background: radial-gradient(ellipse 50% 70% at 85% -10%, var(--sc-glow), transparent),
              radial-gradient(ellipse 60% 80% at 2% 0, var(--sc-tint), transparent);
  pointer-events: none; z-index: -1;
}
.topbar { background: var(--sc-header); box-shadow: 0 4px 20px rgba(26, 29, 58, .04); }
.topbar-inner { max-width: 1180px; min-height: 66px; height: auto; gap: 14px; }
.brand { color: var(--sc-ink); display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand::before {
  content: var(--sc-icon); display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  color: var(--primary); background: var(--primary-soft); font-size: 20px;
}
.nav { min-width: 0; justify-content: center; gap: 2px; }
.nav a { white-space: nowrap; border-radius: 12px; font-size: 14px; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--primary); }
.subject-switch { flex-shrink: 0; border-radius: 12px; }
.subject-switch button { white-space: nowrap; }
.page { max-width: 1180px; padding: 24px 22px 88px; position: relative; }
.page::before {
  content: var(--sc-motto); display: block; padding: 13px 22px;
  background: var(--sc-hero); background-image: var(--sc-motif), var(--sc-hero);
  background-size: 72px 72px, cover; background-repeat: no-repeat;
  background-position: calc(100% - 12px) center, center; padding-right: 96px;
  color: var(--sc-ink);
  border: 1px solid var(--line); border-radius: 18px;
  font-size: 13px; font-weight: 600; letter-spacing: .04em; margin: 0 0 22px;
}
.page h1 { color: var(--sc-ink); font-size: clamp(23px, 3vw, 30px); font-weight: 760; letter-spacing: -.02em; }
.page h2 { color: var(--sc-ink); font-size: 19px; margin-top: 26px; }
.lead { max-width: 66ch; }
.card {
  border-color: var(--line); border-radius: var(--radius);
  box-shadow: 0 5px 22px rgba(43, 37, 79, .045);
}
.card:focus-within { border-color: var(--primary); }
.summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.summary .card { padding: 20px 14px; }
.summary .num { color: var(--sc-ink); font-size: 30px; }
.btn, input[type=text], input[type=date], input[type=search], textarea, select, .choices label {
  border-radius: 12px;
}
.btn.primary {
  border-color: var(--primary);
  background: linear-gradient(110deg, var(--primary), var(--sc-accent-2));
  box-shadow: 0 5px 13px var(--sc-glow);
}
.btn.primary:hover { filter: brightness(.94); }
input[type=text], input[type=date], input[type=search], textarea, select,
.choices label, .preview, .kp-results { background: var(--card); }
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--sc-focus); outline-offset: 3px;
}
.tip.info { color: var(--sc-ink); }
.reasons { color: var(--text); }
.q-list .card:hover { border-color: var(--primary); }
.preview { background: var(--sc-tint); }
.modal { border-radius: 20px; background: var(--card); color: var(--text); }

/* 个性化主题选择器 */
.theme-menu { position: relative; flex: 0 0 auto; }
.theme-menu > summary {
  list-style: none; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--sc-ink); border-radius: 13px;
  padding: 7px 12px; white-space: nowrap; font-size: 14px; font-weight: 650;
  display: flex; gap: 7px; align-items: center; user-select: none;
}
.theme-menu > summary::-webkit-details-marker { display: none; }
.theme-menu > summary::after { content: "⌄"; font-weight: 700; }
.theme-menu[open] > summary { background: var(--primary-soft); border-color: var(--primary); }
.theme-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 300px;
  border: 1px solid var(--line); border-radius: 18px; padding: 13px;
  background: var(--card); box-shadow: 0 18px 40px rgba(25, 24, 54, .18); z-index: 40;
}
.theme-panel-title { font-weight: 750; margin: 0 0 9px; color: var(--sc-ink); }
.theme-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.theme-choice {
  appearance: none; background: #fff; border: 2px solid #ede9f1;
  color: #39364a; border-radius: 13px; padding: 9px;
  text-align: left; cursor: pointer; font: inherit; line-height: 1.4;
}
.theme-choice:hover, .theme-choice[aria-pressed="true"] {
  border-color: var(--primary); background: var(--primary-soft);
}
.theme-swatch {
  display: block; height: 34px; border-radius: 8px; margin-bottom: 7px;
  background: linear-gradient(110deg, #e8dcff, #ffdcef);
}
.theme-choice[data-theme-choice="sakura"] .theme-swatch { background: linear-gradient(110deg, #ffdbe6, #fff5f0); }
.theme-choice[data-theme-choice="starlight"] .theme-swatch { background: linear-gradient(110deg, #182d65, #7d7bd1); }
.theme-choice[data-theme-choice="cat"] .theme-swatch { background: linear-gradient(110deg, #ffdec9, #e6f5e9); }
.theme-choice strong { display: block; font-size: 13px; }
.theme-choice small { color: #655d73; font-size: 11px; display: block; }
.theme-note { color: var(--muted); font-size: 11px; margin: 10px 2px 0; }

:root[data-study-theme="starlight"] .topbar .brand,
:root[data-study-theme="starlight"] .topbar .nav a,
:root[data-study-theme="starlight"] .topbar .subject-switch button { color: #f6f6ff; }
:root[data-study-theme="starlight"] .topbar .brand::before { background: rgba(255,255,255,.17); color: white; }
:root[data-study-theme="starlight"] .topbar .nav a.active,
:root[data-study-theme="starlight"] .topbar .nav a:hover { background: rgba(255,255,255,.17); }
:root[data-study-theme="starlight"] .topbar .subject-switch { border-color: rgba(255,255,255,.3); }
:root[data-study-theme="starlight"] .topbar .subject-switch button.active { background: #e9e6ff; color: #26366b; }

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; justify-content: space-between; padding: 10px 16px; gap: 9px; }
  .nav { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: thin; padding: 2px 0 4px; }
  .nav a { font-size: 13px; padding: 7px 10px; }
  .page { padding: 17px 16px 70px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { flex-wrap: wrap; }
  .row > * { min-width: min(100%, 200px); }
}
@media (max-width: 540px) {
  .topbar-inner { padding: 9px 12px; gap: 6px; }
  .brand { font-size: 16px; gap: 5px; }
  .brand::before { width: 28px; height: 28px; font-size: 17px; }
  .subject-switch button { padding: 5px 7px; font-size: 12px; }
  .theme-menu > summary { padding: 5px 7px; font-size: 12px; }
  .theme-panel { width: min(292px, calc(100vw - 24px)); right: 0; }
  .page { padding: 13px 12px 82px; }
  .page::before { margin-bottom: 15px; border-radius: 14px; padding: 10px 65px 10px 13px; font-size: 12px; background-size: 46px 46px, cover; }
  .page h1 { font-size: 23px; }
  .card { padding: 14px; border-radius: 15px; }
  .row { display: flex; flex-direction: column; gap: 4px; }
  .row > * { flex: auto; width: 100%; min-width: 0; }
  .summary { gap: 9px; }
  .summary .card { padding: 12px 7px; }
  .summary .num { font-size: 22px; }
  table.plain { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.plain th, table.plain td { white-space: nowrap; }
  .actions { flex-wrap: wrap; }
  .actions .btn { min-height: 42px; }
  .q-meta { gap: 4px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
