:root {
  color-scheme: light dark;
  --bg: #0f1419;
  --bg-elevated: #1a222c;
  --bg-card: #1e2833;
  --bg-soft: #243040;
  --text: #eef3f8;
  --muted: #93a4b5;
  --line: rgba(255, 255, 255, 0.08);
  --brand: #3dd6c6;
  --brand-2: #5b8cff;
  --ok: #3ecf8e;
  --bad: #ff6b6b;
  --warn: #ffc857;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Noto Sans SC", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f7fb;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-soft: #eef3f8;
    --text: #15202b;
    --muted: #5d6b7a;
    --line: rgba(21, 32, 43, 0.08);
    --shadow: 0 10px 30px rgba(21, 32, 43, 0.08);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(61, 214, 198, 0.12), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(91, 140, 255, 0.12), transparent 45%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.app {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 16px 16px calc(28px + var(--safe-bottom));
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #06221f;
  flex: none;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(61, 214, 198, 0.12);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card + .card {
  margin-top: 14px;
}

.hero {
  padding: 22px 18px;
  background:
    linear-gradient(135deg, rgba(61, 214, 198, 0.14), rgba(91, 140, 255, 0.1)),
    var(--bg-card);
}

.hero h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.25;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.subject-card {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 16px;
}

.subject-card:hover,
.subject-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(61, 214, 198, 0.45);
  outline: none;
}

.subject-card.active {
  border-color: rgba(61, 214, 198, 0.7);
  box-shadow: inset 0 0 0 1px rgba(61, 214, 198, 0.35);
}

.subject-card .tag {
  font-size: 12px;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 8px;
}

.subject-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.subject-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 720px) {
  .menu {
    grid-template-columns: repeat(4, 1fr);
  }
}

.menu button {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 16px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.menu button:hover,
.menu button:focus-visible {
  border-color: rgba(91, 140, 255, 0.5);
  transform: translateY(-1px);
  outline: none;
}

.menu .icon {
  font-size: 20px;
  margin-bottom: 10px;
}

.menu strong {
  display: block;
  margin-bottom: 4px;
}

.menu span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 20px;
  margin-bottom: 4px;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar .left,
.toolbar .right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
}

.btn:hover,
.btn:focus-visible {
  border-color: rgba(61, 214, 198, 0.5);
  outline: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), #2bb8aa);
  color: #06221f;
  border: none;
}

.btn-danger {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.35);
  color: var(--bad);
}

.btn-ghost {
  background: transparent;
}

.progress {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 4px;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: inherit;
  transition: width 0.2s ease;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.q-stem {
  font-size: 18px;
  line-height: 1.65;
  margin: 8px 0 16px;
  font-weight: 600;
}

.chapter-chip {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(91, 140, 255, 0.12);
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 600;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 14px 14px;
  cursor: pointer;
  line-height: 1.5;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover:not(:disabled),
.option:focus-visible:not(:disabled) {
  border-color: rgba(61, 214, 198, 0.5);
  outline: none;
}

.option.selected {
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(91, 140, 255, 0.35);
}

.option.correct {
  border-color: rgba(62, 207, 142, 0.8);
  background: rgba(62, 207, 142, 0.12);
}

.option.wrong {
  border-color: rgba(255, 107, 107, 0.8);
  background: rgba(255, 107, 107, 0.12);
}

.explain {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(91, 140, 255, 0.08);
  border: 1px solid rgba(91, 140, 255, 0.18);
  line-height: 1.7;
  color: var(--text);
}

.explain strong {
  color: var(--brand-2);
}

.explain.ok {
  background: rgba(62, 207, 142, 0.1);
  border-color: rgba(62, 207, 142, 0.25);
}

.explain.bad {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.25);
}

.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.list-item:hover {
  border-color: rgba(61, 214, 198, 0.4);
}

.list-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.5;
}

.list-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
  line-height: 1.7;
}

.result-score {
  text-align: center;
  padding: 10px 0 6px;
}

.result-score .big {
  font-size: clamp(42px, 10vw, 64px);
  font-weight: 800;
  line-height: 1;
  margin: 8px 0;
}

.result-score .pass {
  color: var(--ok);
}

.result-score .fail {
  color: var(--bad);
}

.timer.warn {
  color: var(--warn);
  font-weight: 700;
}

.timer.danger {
  color: var(--bad);
  font-weight: 800;
}

.notice {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.footer {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.footer a {
  color: inherit;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

.chip.active {
  border-color: rgba(61, 214, 198, 0.6);
  color: var(--brand);
  font-weight: 700;
}

.loading {
  min-height: 40vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.sheet-title {
  margin: 0 0 8px;
  font-size: 20px;
}

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

.exam-hint {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(91, 140, 255, 0.1);
  border: 1px solid rgba(91, 140, 255, 0.2);
}

.exam-hint.study {
  background: rgba(61, 214, 198, 0.1);
  border-color: rgba(61, 214, 198, 0.25);
}

.learn-panel {
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--bg-soft);
}

.learn-panel.ok {
  border-color: rgba(62, 207, 142, 0.35);
}

.learn-panel.ok.compact {
  background: rgba(62, 207, 142, 0.1);
}

.learn-panel.ok.compact .learn-status {
  border-bottom: none;
  padding: 12px 14px;
}

.learn-panel.bad {
  border-color: rgba(255, 107, 107, 0.35);
}

.learn-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: rgba(62, 207, 142, 0.18);
  color: var(--ok);
}

.badge.bad {
  background: rgba(255, 107, 107, 0.18);
  color: var(--bad);
}

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

.ans-line b {
  color: var(--text);
}

.ans-ok {
  color: var(--ok) !important;
}

.ans-bad {
  color: var(--bad) !important;
}

.chapter-mini {
  width: 100%;
  font-size: 12px !important;
}

.learn-block {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.learn-block:first-of-type,
.learn-status + .learn-block {
  border-top: none;
}

.learn-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.learn-label.sub {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.learn-block p,
.explain-text {
  margin: 0;
  line-height: 1.75;
  color: var(--text);
  font-size: 14px;
}

.learn-list,
.koujue-list,
.key-points ol {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.7;
  font-size: 14px;
}

.learn-list li,
.koujue-list li,
.key-points li {
  margin: 4px 0;
}

.learn-block.analysis.bad {
  background: rgba(255, 107, 107, 0.08);
}

.learn-block.analysis.ok {
  background: rgba(62, 207, 142, 0.08);
}

.learn-block.tip {
  background: linear-gradient(
    135deg,
    rgba(255, 200, 87, 0.14),
    rgba(61, 214, 198, 0.08)
  );
}

.learn-block.tip .learn-label {
  color: #c9992a;
}

.koujue-list {
  font-weight: 600;
}

.koujue-list li {
  padding: 4px 0;
}

@media (prefers-color-scheme: dark) {
  .learn-block.tip .learn-label {
    color: var(--warn);
  }
}

.related-desc {
  margin: 0 0 10px !important;
  color: var(--muted) !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
}

.related-list {
  display: grid;
  gap: 8px;
}

.related-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.related-item:hover {
  border-color: rgba(61, 214, 198, 0.45);
  background: rgba(61, 214, 198, 0.06);
}

.rel-idx {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(91, 140, 255, 0.15);
  color: var(--brand-2);
}

.rel-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.rel-stem {
  font-size: 13px;
  line-height: 1.45;
}

.rel-meta {
  font-size: 11px;
  color: var(--muted);
}

.rel-go {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  padding-top: 2px;
}

.related-actions {
  margin-top: 10px;
}

.wrong-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-soft);
}

.wrong-head {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.wrong-body {
  padding: 0 10px 12px;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--bg-soft);
}

.result-item.bad {
  border-color: rgba(255, 107, 107, 0.3);
}

.result-item.ok {
  border-color: rgba(62, 207, 142, 0.25);
}

.result-item-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.result-item-head strong {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
}
