:root {
  --green: #2f6b5f;
  --green-2: #4d8a78;
  --ink: #1f2a26;
  --muted: #6f7f77;
  --line: #e2eae5;
  --bg: #f4f7f4;
  --gold: #8a5a12;
  --red: #b3261e;
  --indigo: #3e4c6b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }

/* Auth */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 15% 10%, rgba(77,138,120,.18), transparent 32%),
    radial-gradient(circle at 85% 90%, rgba(138,90,18,.10), transparent 30%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%); background: #fff; border: 1px solid var(--line);
  border-radius: 24px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(31,42,38,.08);
}
.brand-mark {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: #eaf2ed; font-size: 28px; margin-bottom: 14px;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 11px; font-size: 20px; margin: 0; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.auth-card h1 { font-size: 28px; margin: 4px 0 6px; letter-spacing: -.03em; }
.lead { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.6; }
.gate-banner {
  display: flex; flex-direction: column; gap: 3px; margin: 0 0 16px;
  padding: 11px 13px; border: 1px solid #f0d9b5; border-radius: 12px;
  background: #fff7e8; color: #745018; font-size: 12px; line-height: 1.5;
}
.gate-banner b { font-size: 12.5px; }
.gate-banner span { color: #8a6a3a; font-size: 11px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 13px 0 6px; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; background: #f8faf8; color: var(--ink); outline: none;
}
input:focus, textarea:focus { border-color: var(--green); background: #fff; }
textarea { resize: vertical; line-height: 1.65; }
.primary, .gold, .danger {
  border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; color: #fff;
}
.primary { background: var(--green); }
.primary:hover { background: #285c52; }
.gold { background: var(--gold); }
.gold:hover { background: #744a0e; }
.danger { background: var(--red); }
.wide { width: 100%; margin-top: 18px; }
.primary:disabled, .gold:disabled, .danger:disabled { opacity: .55; cursor: not-allowed; }
.link-btn { display: block; margin: 14px auto 0; border: 0; background: none; color: var(--green); font-size: 13px; }
.error {
  margin-top: 12px; padding: 10px 12px; background: #fff1f0; color: var(--red);
  border-radius: 10px; font-size: 12px; line-height: 1.5; white-space: pre-wrap;
}
.tiny { color: var(--muted); font-size: 11px; line-height: 1.55; }
.auth-card .tiny { text-align: center; margin: 18px 0 0; }

/* App shell */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: rgba(244,247,244,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226,234,229,.8);
}
.topbar-main { flex: 1; min-width: 0; }
.topbar-main strong { display: block; font-size: 14px; }
.topbar-main span { display: block; color: var(--muted); font-size: 10px; }
.ghost { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 9px; padding: 7px 10px; font-size: 11px; }
.ghost.dark { color: var(--ink); }
.page { max-width: 860px; margin: 0 auto; padding: 16px 16px 40px; }
.tabs {
  display: flex; gap: 4px; max-width: 860px; margin: 0 auto;
  padding: 10px 16px 0;
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 9px 8px; border-radius: 10px 10px 0 0; font-size: 12px; font-weight: 600;
}
.tab.active { background: #fff; color: var(--green); box-shadow: 0 -1px 0 var(--line); }
.note-card { display: block; }
.note-head { display: flex; gap: 6px; align-items: center; }
.note-head b { font-size: 13px; }
.note-head span { margin-left: auto; color: var(--muted); font-size: 10px; }
.note-body {
  margin-top: 6px; color: #53616f; font-size: 12px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap;
}
.wrong-card .q { font-size: 13px; line-height: 1.55; font-weight: 600; }
.wrong-card .a { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.5; white-space: pre-wrap; }
.wrong-meta { display: flex; gap: 6px; margin-top: 6px; color: #9aa5b5; font-size: 10px; }
.review-question { font-size: 16px; line-height: 1.65; font-weight: 600; margin: 8px 0 12px; }
.review-answer {
  margin-top: 12px; padding: 12px; background: #f8faf8; border-radius: 12px;
  font-size: 13px; line-height: 1.65; white-space: pre-wrap;
}
.row-actions { display: flex; gap: 10px; margin-top: 12px; }
.row-actions .wide { margin-top: 0; }

/* Hero */
.hero {
  background: linear-gradient(135deg, #3e4c6b, #7284a8); color: #fff;
  border-radius: 22px; padding: 20px; box-shadow: 0 14px 36px rgba(62,76,107,.18);
}
.hero-top { display: flex; gap: 12px; }
.hero-icon { font-size: 28px; }
.hero h2 { font-size: 18px; margin: 0 0 5px; }
.hero p { margin: 0; font-size: 12px; color: rgba(255,255,255,.78); line-height: 1.6; }
.hero-stats { display: flex; align-items: center; gap: 20px; margin-top: 18px; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats b { font-size: 20px; line-height: 1.1; }
.hero-stats span { font-size: 10px; color: rgba(255,255,255,.7); }
.hero-stats button { margin-left: auto; }
.hero .gold { color: var(--gold); background: #fff; padding: 10px 14px; font-size: 12px; }

/* Sections */
.section-head { display: flex; align-items: center; gap: 8px; margin: 24px 0 8px; }
.section-head h3 { font-size: 16px; margin: 0; }
.section-head span { margin-left: auto; color: var(--muted); font-size: 11px; }
.list { display: grid; gap: 8px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; text-align: left; width: 100%;
}
.card:active { transform: scale(.995); }
.card-top { display: flex; align-items: center; gap: 7px; color: #72809b; font-size: 10px; font-weight: 600; }
.card-top span:last-child { margin-left: auto; color: #9aa5b5; font-weight: 400; }
.card-stem { margin-top: 6px; font-size: 13px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.history-card { display: flex; align-items: center; gap: 11px; }
.history-score {
  width: 42px; height: 42px; flex: none; border-radius: 11px; display: grid; place-items: center;
  background: #edf1f7; color: var(--indigo); font-weight: 800; font-size: 15px;
}
.history-main { flex: 1; min-width: 0; }
.history-main b { display: block; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-main small { color: var(--muted); font-size: 10px; }

/* Practice */
.practice-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.practice-head span { color: var(--muted); font-size: 11px; }
.question-card {
  background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 17px;
}
.question-card .meta { display: flex; gap: 8px; color: #72809b; font-size: 10px; font-weight: 600; }
.question-card .meta span:last-child { margin-left: auto; color: #9aa5b5; font-weight: 400; }
.question-card .stem { margin: 10px 0 8px; font-size: 15px; line-height: 1.7; font-weight: 600; }
.question-card .req { color: #6e7a73; font-size: 12px; line-height: 1.6; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 17px; margin-top: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.step { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 8px; color: #53616f; font-size: 12.5px; line-height: 1.5; }
.step i {
  width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: #edf1f7; color: var(--indigo); font-size: 10px; font-style: normal; font-weight: 700;
}
.timer-card {
  border-radius: 18px; padding: 17px; color: #fff; text-align: center; margin-top: 14px;
}
.timer-card.indigo { background: var(--indigo); }
.timer-card.red { background: var(--red); }
.timer-card span { display: block; font-size: 11px; opacity: .75; }
.timer-card b { display: block; font-size: 42px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.timer-card small { display: block; font-size: 10px; opacity: .72; line-height: 1.45; }
.upload-row { display: flex; align-items: center; gap: 10px; }
.file-btn {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #f8faf8;
  color: var(--ink); font-size: 12px; font-weight: 600;
}
.preview { margin-top: 10px; }
.preview img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; display: block; }
.transcript {
  margin-top: 12px; padding: 12px; background: #f8faf8; border-radius: 12px;
  font-size: 13px; line-height: 1.65; white-space: pre-wrap;
}
.status-line { color: var(--muted); font-size: 11px; margin-top: 8px; line-height: 1.5; }
.status-line.error { color: var(--red); background: none; padding: 0; }

/* Report */
.report-hero {
  background: #f8fafb; border: 1px solid var(--line); border-radius: 20px;
  padding: 20px; text-align: center;
}
.report-hero small { color: #72809b; font-size: 11px; font-weight: 600; }
.score-line { display: flex; align-items: flex-end; justify-content: center; gap: 4px; margin: 3px 0; }
.score-line b { font-size: 54px; line-height: 1; }
.score-line span { color: var(--muted); font-size: 13px; padding-bottom: 6px; }
.report-hero p { color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.dim { margin: 14px 0; }
.dim-head { display: flex; font-size: 12.5px; font-weight: 600; }
.dim-head span { margin-left: auto; color: var(--indigo); font-size: 11px; }
.bar { height: 6px; background: #edf1f7; border-radius: 4px; overflow: hidden; margin: 5px 0; }
.bar i { display: block; height: 100%; background: var(--indigo); border-radius: 4px; }
.dim small { display: block; color: #6e7a73; font-size: 11px; line-height: 1.5; }
.issue {
  background: #fff6e8; border: 1px solid #f0d9b5; border-radius: 12px;
  padding: 12px; margin: 8px 0;
}
.issue b { display: block; color: #6e4a13; font-size: 12.5px; }
.issue q { display: block; color: #7a5a2b; font-size: 12px; font-style: italic; line-height: 1.5; margin: 4px 0; }
.issue span { display: block; color: #6b4a1b; font-size: 12px; line-height: 1.55; }
.report-section { margin-top: 18px; }
.report-section h3 { font-size: 15px; margin: 0 0 7px; }
.report-section p { font-size: 13px; line-height: 1.7; margin: 0; }
.quote-box { background: #eaf2ed; color: var(--green); border-radius: 12px; padding: 12px; font-size: 13px; line-height: 1.6; }
.check-list { margin: 0; padding: 0; list-style: none; }
.check-list li { display: flex; gap: 7px; font-size: 12.5px; line-height: 1.5; margin-bottom: 5px; }
.check-list li:before { content: "✓"; color: var(--green); font-weight: 700; }
.num-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.55; }
.num-list li { margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
  max-width: calc(100vw - 32px); background: #1f2a26; color: #fff; padding: 10px 15px;
  border-radius: 10px; font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 20; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
body.modal-open { overflow: hidden; }

@media (min-width: 720px) {
  .page { padding: 24px 24px 50px; }
  .hero { padding: 24px; }
  .hero h2 { font-size: 21px; }
  .question-card { padding: 20px; }
}
