:root {
  color-scheme: light;
  --blue-950: #10284d;
  --blue-700: #2362aa;
  --blue-600: #2d73c9;
  --blue-100: #eaf3ff;
  --blue-50: #f5f9ff;
  --line: #d5e2f2;
  --text: #17243a;
  --muted: #68758a;
  --green: #208561;
  --red: #bd3d4a;
  --shadow: 0 12px 36px rgba(27, 67, 116, .1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: #fff;
  color: var(--text);
  font-family: "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--blue-50), #fff 55%);
}
.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
  background: #fff;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--blue-50);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
h1 { font-size: 26px; margin: 18px 0 6px; }
.auth-panel p { color: var(--muted); margin: 0 0 24px; }
label { display: grid; gap: 7px; margin: 14px 0; font-size: 14px; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(45, 115, 201, .25); outline-offset: 2px; }
.error { min-height: 22px; margin-top: 10px; color: var(--red); font-size: 14px; }

button {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}
.primary { background: var(--blue-700); color: #fff; }
.secondary { border-color: var(--line); background: #fff; }
.success { background: #e7f6ef; color: var(--green); border-color: #bce6d5; }
.wide { width: 100%; margin-top: 12px; }
.text-button { width: 100%; color: var(--blue-700); background: transparent; font-size: 14px; }
.icon-button { width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); }
.icon-button.active { background: var(--blue-700); color: #fff; border-color: var(--blue-700); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  min-height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px max(18px, calc((100vw - 1100px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.topbar strong { display: block; color: var(--blue-950); }
.topbar span { color: var(--muted); font-size: 12px; }
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-brand img { width: 36px; height: 36px; object-fit: contain; }
.header-actions { display: flex; gap: 8px; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 18px 60px; }
.dashboard {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--blue-50);
}
.dashboard div { padding: 16px; border-right: 1px solid var(--line); }
.dashboard div:last-child { border: 0; }
.dashboard span { display: block; color: var(--blue-700); font-size: 24px; font-weight: 800; }
.dashboard small { color: var(--muted); }
.tabs { display: flex; gap: 6px; margin: 24px 0 16px; border-bottom: 1px solid var(--line); }
.tab { border-radius: 0; border-bottom: 3px solid transparent; color: var(--muted); }
.tab.active { color: var(--blue-700); border-bottom-color: var(--blue-700); }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar select { max-width: 260px; }
.card-filters { display: flex; gap: 8px; flex: 1; }
.quiz-filters { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto; gap: 8px; margin-bottom: 8px; }
.quiz-summary { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; }
.segmented button { padding: 7px 10px; color: var(--muted); }
.segmented button.active { background: var(--blue-100); color: var(--blue-700); }

.study-card, .quiz-card {
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  min-height: 440px; padding: clamp(20px, 4vw, 42px); background: #fff;
}
.card-meta { color: var(--blue-700); font-size: 13px; font-weight: 800; }
.study-card h2, .quiz-card h2 { margin: 10px 0 8px; font-size: clamp(22px, 4vw, 32px); }
.prompt { margin: 0 0 26px; color: var(--muted); line-height: 1.7; }
.organizer-note { margin: 0 0 22px; padding: 12px 14px; border-left: 3px solid #d39527; background: #fff9eb; color: #75531b; line-height: 1.7; }
.answer-block {
  width: 100%; text-align: left; margin: 9px 0; padding: 15px 17px;
  border: 1px solid var(--line); border-left: 4px solid var(--blue-600);
  border-radius: 7px; background: var(--blue-50); line-height: 1.8; font-weight: 500;
}
.answer-block.mnemonic { border-left-color: #e0a12f; background: #fff9eb; }
.answer-block.concealed {
  min-height: 62px; color: transparent; background: repeating-linear-gradient(-45deg,#f3f7fc,#f3f7fc 10px,#eaf1fa 10px,#eaf1fa 20px);
}
.study-card.timeline .blocks { position: relative; padding-left: 22px; }
.study-card.timeline .blocks::before { content: ""; position: absolute; left: 7px; top: 12px; bottom: 12px; width: 2px; background: var(--line); }
.study-card.timeline .answer-block { position: relative; border-left-width: 1px; background: #fff; }
.study-card.timeline .answer-block::before { content: ""; position: absolute; left: -22px; top: 23px; width: 11px; height: 11px; border: 3px solid #fff; border-radius: 50%; background: var(--blue-600); box-shadow: 0 0 0 2px var(--blue-600); }
.study-card.comparison .blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.study-card.comparison .answer-block { height: 100%; margin: 0; border-left-color: #d39527; background: #fffdf7; }
.study-card.comparison .answer-block.concealed { background: repeating-linear-gradient(-45deg,#fffaf0,#fffaf0 10px,#f8f0df 10px,#f8f0df 20px); }
.keyword {
  display: inline-block; min-width: 4em; padding: 0 4px; border-bottom: 2px solid var(--blue-600);
  color: transparent; background: var(--blue-100); border-radius: 3px;
}
.keyword.revealed { color: var(--blue-950); }
.card-actions, .quiz-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.options { display: grid; gap: 10px; margin-top: 24px; }
.option { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); }
.option span:first-child { display: grid; place-items: center; width: 30px; height: 30px; background: var(--blue-100); color: var(--blue-700); border-radius: 6px; }
.option.selected { border-color: var(--blue-600); background: var(--blue-50); box-shadow: inset 0 0 0 1px var(--blue-600); }
.option.correct { border-color: #62b596; background: #edf9f4; }
.option.wrong { border-color: #e18b94; background: #fff2f3; }
.explanation { margin-top: 20px; padding: 16px; border-radius: 7px; background: var(--blue-50); line-height: 1.7; }
.question-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge { padding: 4px 8px; border-radius: 999px; background: var(--blue-100); color: var(--blue-700); font-size: 12px; font-weight: 700; }
.question-submit { margin-top: 14px; }

@media (max-width: 720px) {
  main { padding-inline: 12px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar select { max-width: none; }
  .card-filters { flex-direction: column; }
  .quiz-filters { grid-template-columns: 1fr 1fr; }
  .quiz-filters #randomize-quiz { grid-column: 1 / -1; }
  .segmented { display: grid; grid-template-columns: repeat(3, 1fr); }
  .study-card, .quiz-card { min-height: 390px; padding: 20px; }
  .study-card.comparison .blocks { grid-template-columns: 1fr; }
  .dashboard small { font-size: 11px; }
  .dashboard div { padding: 12px 9px; }
  .card-actions button { flex: 1 1 calc(50% - 8px); }
}
