:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #e6e9ee;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --navy: #153e5c;
  --blue: #2774ae;
  --blue-soft: #eaf3fa;
  --green: #1c7c54;
  --green-soft: #e8f6ef;
  --red: #b42318;
  --red-soft: #fef0ee;
  --amber: #9a6700;
  --amber-soft: #fff7df;
  --radius: 18px;
  --shadow: 0 12px 35px rgba(20, 40, 60, 0.07);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  line-height: 1.65;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 68px;
  padding: 0 max(22px, calc((100vw - 1120px) / 2));
  display: flex;
  align-items: center;
  gap: 34px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.1rem; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  color: white; background: var(--navy);
}
.desktop-nav { display: flex; gap: 22px; margin-left: auto; }
.desktop-nav a, .user-menu { color: var(--muted); font-size: 0.93rem; }
.desktop-nav a:hover { color: var(--blue); }
.user-menu { display: flex; align-items: center; gap: 12px; margin-left: 10px; }
.user-menu form { margin: 0; }
.text-button { border: 0; background: none; color: var(--muted); padding: 4px; }
.page-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 90px; }
.messages { margin-bottom: 22px; display: grid; gap: 8px; }
.message { border-radius: 12px; background: var(--blue-soft); color: var(--navy); padding: 12px 16px; }
.message.error { background: var(--red-soft); color: var(--red); }
.message.success { background: var(--green-soft); color: var(--green); }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.35rem); line-height: 1.14; letter-spacing: -0.035em; margin-bottom: 14px; }
h2 { font-size: 1.55rem; line-height: 1.3; margin-bottom: 8px; }
h3 { font-size: 1.12rem; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-weight: 800; letter-spacing: 0.13em; font-size: 0.73rem; text-transform: uppercase; }
.lead { color: var(--muted); max-width: 720px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.83rem; }
.page-heading { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; margin-bottom: 34px; }
.compact-heading { margin-bottom: 22px; }
.section { margin-top: 38px; }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 15px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 43px; padding: 9px 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 700; transition: .18s ease;
}
.button.primary { background: var(--navy); color: white; }
.button.primary:hover { background: #0e3049; transform: translateY(-1px); }
.button.secondary { background: white; color: var(--navy); border-color: #cfd6dd; }
.button.small { min-height: 34px; padding: 5px 12px; font-size: .85rem; }
.button.wide { width: 100%; }
.quiet-link { font-weight: 700; font-size: .9rem; }
.status, .tag, .subject-badge {
  display: inline-flex; align-items: center; border-radius: 999px; font-size: .76rem; font-weight: 700; padding: 4px 9px;
  background: #eef1f4; color: var(--muted);
}
.status.success { color: var(--green); background: var(--green-soft); }
.status.danger { color: var(--red); background: var(--red-soft); }
.status.warning { color: var(--amber); background: var(--amber-soft); }
.tag { background: var(--blue-soft); color: var(--navy); }
.tag.subtle { background: #f1f3f5; color: var(--muted); margin-left: 4px; }
.subject-badge.english { background: #e8f2ff; color: #1857a4; }
.subject-badge.chinese { background: #fff1e8; color: #a64b13; }
.subject-badge.math { background: #eaf7f0; color: var(--green); }

.login-page { min-height: 100vh; background: linear-gradient(135deg, #eef4f8 0%, #f8f5ef 100%); }
.login-page .topbar { position: static; background: transparent; border-bottom: 0; }
.login-page .page-shell { min-height: calc(100vh - 68px); display: grid; place-items: center; padding: 30px 0; }
.login-layout { width: min(1000px, calc(100% - 36px)); display: grid; grid-template-columns: 1.15fr .85fr; gap: 70px; align-items: center; }
.login-copy h1 { font-size: clamp(2.8rem, 7vw, 5rem); }
.login-card { display: grid; gap: 18px; padding: 34px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: .88rem; }
.field input, .field textarea, select, input[type="date"], input[type="number"], input[type="text"] {
  width: 100%; border: 1px solid #cfd6dd; border-radius: 11px; background: white; color: var(--ink); padding: 11px 12px;
}
.field input:focus, .field textarea:focus, select:focus, textarea:focus { outline: 3px solid rgba(39, 116, 174, .15); border-color: var(--blue); }
.form-error { color: var(--red); font-size: .83rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-grid.compact { grid-template-columns: repeat(3, 1fr); margin-bottom: 30px; }
.metric { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 19px; display: grid; gap: 3px; }
.metric span { color: var(--muted); font-size: .83rem; }
.metric strong { font-size: 1.9rem; line-height: 1.2; }
.metric small { color: var(--muted); }
.score-ring { width: 125px; height: 125px; flex: 0 0 auto; border-radius: 50%; border: 9px solid #d9e8f3; display: grid; place-content: center; text-align: center; background: white; }
.score-ring strong { font-size: 1.8rem; }
.score-ring span { color: var(--muted); font-size: .75rem; }
.task-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.task-card { display: grid; gap: 14px; }
.task-top { display: flex; justify-content: space-between; }
.paper-banner, .current-paper { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.paper-actions { display: flex; align-items: center; gap: 12px; }
.stack { display: grid; gap: 16px; }
.empty-state { border: 1px dashed #cdd5dd; border-radius: 16px; padding: 34px; text-align: center; color: var(--muted); background: #fafbfc; }

.practice-shell { width: min(880px, 100%); margin: 0 auto; }
.save-state { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.question-list { display: grid; gap: 17px; }
.question-card { padding: 24px; }
.question-head { display: flex; align-items: center; gap: 12px; margin-bottom: 17px; }
.question-head > :last-child { margin-left: auto; }
.question-number { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--navy); color: white; font-weight: 800; }
.question-score { color: var(--muted); font-size: .8rem; }
.question-stem { font-size: 1.03rem; line-height: 1.85; margin-bottom: 18px; }
.question-image { max-width: 100%; border-radius: 12px; margin: 6px 0 18px; }
.option-list { display: grid; gap: 10px; }
.option { display: flex; gap: 11px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.option:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.option input { margin-top: 4px; }
.option-key { width: 24px; height: 24px; border-radius: 8px; background: #eef1f4; display: inline-grid; place-items: center; font-weight: 800; flex: 0 0 auto; }
.answer-field { margin-top: 4px; }
.submit-bar {
  position: sticky; bottom: 16px; margin-top: 20px; padding: 13px 16px; border-radius: 15px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(12px);
}

.result-list { display: grid; gap: 16px; }
.result-card.correct { border-left: 5px solid var(--green); }
.result-card.incorrect { border-left: 5px solid var(--red); }
.result-card.partial { border-left: 5px solid #d29d00; }
.result-card.pending { border-left: 5px solid var(--blue); }
.snapshot-stem { font-weight: 700; white-space: pre-wrap; }
.snapshot-options { display: grid; gap: 5px; margin-top: 10px; color: var(--muted); font-size: .88rem; }
.snapshot-options b { color: var(--ink); }
.answer-details { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; margin: 18px 0 0; }
.answer-details dt { color: var(--muted); }
.answer-details dd { margin: 0; white-space: pre-wrap; }
.pending-note { margin: 16px 0 0; padding: 11px 13px; border-radius: 10px; background: var(--blue-soft); color: var(--navy); font-size: .86rem; }
.filter-bar { display: flex; gap: 12px; align-items: end; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar label { display: grid; gap: 5px; color: var(--muted); font-size: .8rem; }
.wrong-card { display: grid; gap: 14px; }
.wrong-card time { color: var(--muted); font-size: .8rem; }
.review-card { display: grid; gap: 14px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.review-grid > div { background: #f7f9fa; border-radius: 12px; padding: 13px; }
.label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.review-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.review-form label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; }
.review-form .grow { flex: 1 1 180px; }
.large-count { font-size: 3.2rem; font-weight: 800; color: var(--blue); }

.two-column { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
.bar-chart { height: 240px; display: flex; align-items: end; gap: 9px; padding-top: 20px; }
.bar-item { flex: 1; display: grid; justify-items: center; gap: 6px; height: 100%; grid-template-rows: 1fr auto auto; }
.bar-track { width: min(38px, 80%); height: 100%; border-radius: 8px 8px 4px 4px; background: #eef1f4; display: flex; align-items: end; overflow: hidden; }
.bar-track span { display: block; width: 100%; min-height: 2px; background: var(--blue); border-radius: 7px 7px 0 0; }
.bar-item strong { font-size: .76rem; }
.bar-item small { color: var(--muted); font-size: .7rem; }
.table-card { padding: 0; overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 13px 17px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; background: #f8f9fa; }
tr:last-child td { border-bottom: 0; }
.compact-table td { padding: 9px 0; border-color: #edf0f2; }
.child-switcher label, .page-heading form label { display: grid; gap: 5px; color: var(--muted); font-size: .8rem; }
.mobile-nav { display: none; }

@media (max-width: 760px) {
  body { padding-bottom: 66px; }
  .topbar { min-height: 60px; padding: 0 18px; }
  .desktop-nav { display: none; }
  .user-menu { margin-left: auto; }
  .page-shell { width: min(100% - 26px, 1120px); padding-top: 28px; }
  h1 { font-size: 2.15rem; }
  .page-heading, .paper-banner, .current-paper { flex-direction: column; align-items: stretch; }
  .score-ring { width: 100%; height: auto; border-radius: 16px; border-width: 1px; display: flex; gap: 10px; justify-content: center; align-items: baseline; padding: 14px; }
  .score-ring strong { font-size: 1.45rem; }
  .metric-grid, .metric-grid.compact { grid-template-columns: repeat(2, 1fr); }
  .task-grid, .two-column, .review-grid { grid-template-columns: 1fr; }
  .login-layout { grid-template-columns: 1fr; gap: 26px; padding: 36px 0; }
  .login-copy h1 { font-size: 2.8rem; }
  .question-card { padding: 18px; }
  .answer-details { grid-template-columns: 1fr; gap: 3px; }
  .answer-details dd { margin-bottom: 9px; }
  .submit-bar { bottom: 70px; flex-direction: column; align-items: stretch; }
  .submit-bar .button { width: 100%; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; z-index: 30;
    bottom: 0; left: 0; right: 0; background: white; border-top: 1px solid var(--line); padding: 8px 16px 10px;
  }
  .mobile-nav a { text-align: center; font-weight: 700; font-size: .86rem; padding: 7px; }
  .bar-chart { height: 210px; }
  .review-form { align-items: stretch; }
  .review-form .button { width: 100%; }
  .login-page .topbar { padding-inline: 18px; }
  .login-page .page-shell { min-height: calc(100vh - 60px); }
  .progress-table th:last-child,
  .progress-table td:last-child { width: 84px; white-space: nowrap; }
  .progress-table { table-layout: fixed; }
  .progress-table th:first-child { width: 38%; }
  .progress-table th:nth-child(2) { width: auto; }
}

