:root {
  --bg: #f4f6fb;
  --surface: #fff;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --muted: #7b8494;
  --line: #e5e9f2;
  --brand: #4f46e5;
  --brand-2: #0ea5e9;
  --brand-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --shadow: 0 8px 26px rgba(31, 41, 55, .06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #eef2ff, transparent 45%), radial-gradient(circle at 85% 80%, #e0f2fe, transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 60px rgba(31,41,55,.10); padding: 34px; }
.login-logo { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; }
.login-card h1 { font-size: 24px; margin: 18px 0 6px; letter-spacing: -.6px; }
.login-card p { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; outline: none; background: #fbfcfe; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.10); }
.login-error { color: var(--bad); font-size: 13px; min-height: 20px; margin: 4px 0 8px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 10px; padding: 9px 15px; font-size: 13px; font-weight: 650; transition: all .18s ease; }
.btn:hover { border-color: #c7cddb; color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.2); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; color: #fff; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* App shell */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--line); }
.side-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; }
.side-logo .login-logo { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.side-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.search { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; margin-top: 14px; outline: none; font-size: 13px; }
.search:focus { border-color: var(--brand); }
.group-label { font-size: 10px; letter-spacing: 1.2px; font-weight: 800; color: var(--muted); padding: 14px 20px 6px; text-transform: uppercase; }
.day-list { padding: 0 10px 16px; }
.day-item { width: 100%; text-align: left; border: none; background: transparent; border-radius: 9px; padding: 9px 10px; display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 13px; }
.day-item:hover { background: #f5f7fb; }
.day-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 750; }
.day-num { width: 26px; height: 26px; border-radius: 7px; background: #f1f3f8; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none; }
.day-item.active .day-num { background: #fff; }
.day-progress { margin-left: auto; font-size: 10px; color: var(--muted); }
.day-item.done .day-progress { color: var(--ok); font-weight: 800; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 13px 26px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.crumb { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 1px; }
.top-title { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.top-spacer { flex: 1; }
.pill { font-size: 12px; font-weight: 700; background: #f3f5f9; color: var(--ink-soft); border-radius: 99px; padding: 5px 11px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.content { max-width: 980px; margin: 0 auto; padding: 26px 26px 80px; }
.hero { background: linear-gradient(135deg, #eef2ff, #f0f9ff 60%, #fff); border: 1px solid #e3e8f5; border-radius: 18px; padding: 24px 28px; margin-bottom: 20px; }
.hero h1 { font-size: 26px; margin: 8px 0 6px; letter-spacing: -.7px; }
.hero p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.hero-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: 11px; color: var(--muted); }
.hero-meta span::before { content: "•"; color: var(--brand); margin-right: 6px; }

.section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.section-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.sec-num { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 12px; flex: none; }
.sec-title { margin: 0; font-size: 15px; font-weight: 750; }
.sec-desc { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.sec-status { margin-left: auto; font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: #f3f5f9; color: var(--muted); white-space: nowrap; }
.sec-status.good { background: var(--ok-soft); color: var(--ok); }
.sec-status.bad { background: var(--bad-soft); color: var(--bad); }
.section-body { padding: 20px 22px; }
.section-foot { border-top: 1px solid var(--line); padding: 12px 22px; background: #fcfcfe; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.feedback { font-size: 12px; color: var(--muted); flex: 1; min-width: 160px; }
.feedback.ok { color: var(--ok); font-weight: 700; }
.feedback.bad { color: var(--bad); font-weight: 700; }

/* match */
.match-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; }
.col-label { font-size: 10px; font-weight: 800; letter-spacing: 1.1px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-btn { text-align: left; width: 100%; border: 1px solid var(--line); background: #fbfcfe; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--ink); transition: .15s; }
.match-btn:hover { border-color: #c3c9f7; }
.match-btn.selected { border-color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.match-btn.matched { border-color: #9fdfc8; background: var(--ok-soft); }
.match-btn.wrong { border-color: #fca5a5; background: var(--bad-soft); }
.match-btn.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.match-btn.is-incorrect { border-color: var(--bad); background: var(--bad-soft); }
.match-btn.revealed { border-color: #a5b4fc; background: var(--brand-soft); }
.match-btn .tag { font-size: 10px; font-weight: 800; color: var(--brand); background: #fff; border: 1px solid #dfe4fb; border-radius: 5px; padding: 1px 6px; margin-right: 8px; }

/* inputs */
.word-bank { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.word-bank span { font-size: 12px; font-weight: 650; color: var(--ink-soft); background: var(--brand-soft); border: 1px solid #dfe4fb; border-radius: 8px; padding: 5px 10px; }
.fill-list { display: flex; flex-direction: column; gap: 12px; }
.fill-item { border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; background: #fbfcfe; }
.qno { font-size: 10px; font-weight: 800; color: var(--brand); letter-spacing: .8px; }
.sentence { font-size: 14px; line-height: 2.1; }
.zh { font-size: 12px; color: var(--muted); margin-top: 3px; }
.blank { border: none; border-bottom: 2px solid #b8bfd2; background: transparent; color: var(--brand); font-weight: 700; padding: 2px 6px; border-radius: 5px 5px 0 0; outline: none; }
select.blank { max-width: 260px; cursor: pointer; }
input.blank { min-width: 160px; max-width: 100%; width: 100%; }
textarea.answer { width: 100%; min-height: 74px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; background: #fff; resize: vertical; font-size: 13.5px; }
.blank:focus, textarea.answer:focus { border-color: var(--brand); background: var(--brand-soft); }
select.blank:focus { border-bottom-color: var(--brand); }
.blank.is-correct, textarea.answer.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.blank.is-incorrect, textarea.answer.is-incorrect { border-color: var(--bad); background: var(--bad-soft); }
.blank.revealed, textarea.answer.revealed { border-color: #a5b4fc; background: var(--brand-soft); }
select.blank.is-correct { border-bottom-color: var(--ok); }
select.blank.is-incorrect { border-bottom-color: var(--bad); }
select.blank.revealed { border-bottom-color: #a5b4fc; }

/* paragraph */
.paragraph { background: #fbfcfe; border: 1px solid var(--line); border-radius: 11px; padding: 16px; font-size: 14px; line-height: 2.3; }
.paragraph select.blank { max-width: 230px; }
.note-card { background: #fbfcfe; border: 1px solid var(--line); border-radius: 11px; padding: 15px; margin-bottom: 12px; }
.note-card h4 { margin: 0 0 7px; font-size: 13px; color: var(--brand); }
.note-card p { margin: 0; font-size: 13.5px; white-space: pre-wrap; color: var(--ink-soft); }

.answer-box { display: none; margin-top: 16px; padding: 15px 17px; background: var(--brand-soft); border: 1px solid #dfe4fb; border-radius: 11px; font-size: 12.5px; color: var(--ink-soft); }
.answer-box.open { display: block; }
.answer-box b { display: block; color: var(--brand); font-size: 10px; letter-spacing: 1px; margin-bottom: 6px; }
.answer-box ol, .answer-box ul { margin: 5px 0 0; padding-left: 19px; }
.answer-box li { margin-bottom: 5px; }
.submit-bar { position: sticky; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; display: flex; align-items: center; gap: 12px; box-shadow: 0 -6px 20px rgba(31,41,55,.05); margin-top: 20px; }
.submit-bar .score-big { font-size: 20px; font-weight: 850; color: var(--brand); }
.submit-bar .meta { font-size: 12px; color: var(--muted); }
.submit-bar .grow { flex: 1; }
.toast { position: fixed; right: 22px; bottom: 22px; background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateY(0); }

/* Records */
.records-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.records-table th, .records-table td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); }
.records-table th { font-size: 10px; letter-spacing: .8px; color: var(--muted); text-transform: uppercase; background: #f8f9fc; }
.records-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .day-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .group-label { display: none; }
  .day-item { padding: 7px; font-size: 11px; gap: 5px; }
  .day-num { width: 22px; height: 22px; }
  .day-progress { display: none; }
  .content { padding: 20px 14px 80px; }
  .topbar { padding: 11px 14px; }
  .match-grid { grid-template-columns: 1fr; }
}
@media print { .sidebar, .topbar, .section-foot, .submit-bar { display: none; } }
