:root {
  --green: #1e9e75;
  --green-dark: #167d5d;
  --green-light: #eaf6f1;
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #1f2a26;
  --muted: #8a9490;
  --border: #eef2f0;
  --red: #ef4444;
  --amber: #b45309;
  --radius: 16px;
  --app-max: 720px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: #e8ecea;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
#app {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.06);
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 52px; display: flex; align-items: center;
  background: var(--green); color: #fff; padding: 0 12px;
}
.topbar-title { flex: 1; text-align: center; font-size: 16px; font-weight: 600; }
.topbar-spacer, .icon-btn { width: 40px; }
.icon-btn { background: none; border: none; color: #fff; font-size: 30px; line-height: 1; cursor: pointer; text-align: left; padding: 0; visibility: hidden; }
.icon-btn.visible { visibility: visible; }

.main { padding: 16px 16px calc(72px + env(safe-area-inset-bottom)); min-height: calc(100vh - 52px); }
@media (min-width: 900px) { .main { padding: 24px 32px calc(88px); } }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-max);
  height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #fff; border-top: 1px solid var(--border); z-index: 20;
}
.tab { flex: 1; border: none; background: none; color: #8a9490; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.tab.active { color: var(--green); font-weight: 600; }
.tab-icon { font-size: 20px; line-height: 1; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: 0 2px 12px rgba(30,158,117,0.05); }
.section-title { display: block; font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 12px; }
.state-card { background: #fff; border-radius: var(--radius); padding: 48px 20px; text-align: center; }
.state-title { display: block; font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.state-description { display: block; color: var(--muted); font-size: 13px; }

.btn { display: block; width: 100%; height: 44px; line-height: 44px; border: none; border-radius: 22px; font-size: 15px; cursor: pointer; text-align: center; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-secondary { background: var(--green-light); color: var(--green); }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #fecaca; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn + .btn { margin-top: 12px; }

.input { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; font-size: 14px; background: #f9fbf9; outline: none; }
.input:focus { border-color: var(--green); }
.field { margin-bottom: 16px; }
.label { display: block; font-size: 13px; margin-bottom: 8px; color: #4b5752; }
.error-msg { color: var(--red); font-size: 13px; margin-bottom: 12px; }

.header-hero { background: var(--green); border-radius: 0 0 24px 24px; color: #fff; padding: 20px 20px 28px; margin: -16px -16px 16px; }
@media (min-width: 900px) { .header-hero { margin: -24px -32px 20px; } }
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.subject-picker { font-size: 13px; background: rgba(255,255,255,0.18); padding: 6px 14px; border-radius: 16px; cursor: pointer; border: none; color: #fff; }
.header-action { font-size: 12px; color: #fff; border: 1px solid rgba(255,255,255,0.6); padding: 5px 12px; border-radius: 16px; background: none; cursor: pointer; }
.hero-year { display: block; font-size: 13px; opacity: 0.9; }
.hero-title { display: block; font-size: 30px; font-weight: 700; margin: 4px 0 6px; }
.hero-sub { display: block; font-size: 12px; opacity: 0.85; }

.stats { display: flex; text-align: center; padding: 16px 8px; }
.stat { flex: 1; }
.stat-num { display: block; font-size: 24px; font-weight: 700; color: var(--green); }
.stat-label { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 8px; margin-top: 8px; }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(8, 1fr); } }
.grid-item { text-align: center; cursor: pointer; }
.grid-icon { width: 46px; height: 46px; line-height: 46px; border-radius: 14px; margin: 0 auto 8px; color: #fff; font-size: 18px; font-weight: 600; }
.c-green { background: #1e9e75; } .c-blue { background: #3b82f6; } .c-orange { background: #f59e0b; }
.c-red { background: #ef4444; } .c-purple { background: #8b5cf6; } .c-cyan { background: #06b6d4; }
.c-pink { background: #ec4899; } .c-gray { background: #64748b; }
.grid-label { font-size: 12px; color: #4b5752; }

.list-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.row-title { font-size: 14px; }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; }
.arrow { color: #c8d0cc; font-size: 22px; }

.subject-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 900px) { .subject-grid { grid-template-columns: repeat(4, 1fr); } }
.subject-item { background: #fff; border-radius: 12px; padding: 16px 10px; text-align: center; cursor: pointer; border: 2px solid transparent; font-size: 13px; position: relative; }
.subject-item.selected { border-color: var(--green); background: var(--green-light); color: var(--green); font-weight: 600; }
.check { position: absolute; top: 4px; right: 8px; color: var(--green); font-size: 12px; }
.group-title { display: block; font-size: 13px; color: var(--muted); margin: 18px 0 10px; }

.quiz-head { display: flex; justify-content: space-between; font-size: 12px; color: #4b5752; margin-bottom: 12px; }
.timer { color: var(--red); }
.q-type { font-size: 12px; color: var(--green); }
.q-stem { font-size: 16px; line-height: 1.7; margin: 12px 0 20px; display: block; }
.options { display: flex; flex-direction: column; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; background: #f7f9f8; cursor: pointer; border: 2px solid transparent; }
.option.selected { border-color: var(--green); background: var(--green-light); }
.option.correct { border-color: #22c55e; background: #eafaef; }
.option-key { width: 28px; height: 28px; line-height: 28px; text-align: center; border-radius: 50%; background: #fff; flex-shrink: 0; font-size: 13px; }
.option.selected .option-key { background: var(--green); color: #fff; }
.analysis-box { margin-top: 20px; padding: 14px; background: #fff8e6; border-radius: 12px; }
.analysis-title { display: block; font-weight: 600; color: var(--amber); margin-bottom: 8px; }
.analysis-body { font-size: 13px; color: #6b5a3a; }
.quiz-actions { display: flex; gap: 10px; margin-top: 16px; }
.quiz-actions .btn { flex: 1; margin: 0; height: 40px; line-height: 40px; font-size: 13px; }

.card-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.card-panel { width: 100%; max-width: var(--app-max); background: #fff; border-radius: 20px 20px 0 0; padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 16px 0; }
@media (min-width: 900px) { .card-grid { grid-template-columns: repeat(10, 1fr); } }
.card-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: #f1f5f3; font-size: 13px; cursor: pointer; }
.card-cell.done { background: var(--green); color: #fff; }
.card-cell.current { outline: 2px solid var(--green); }

.score-card { background: var(--green); border-radius: 20px; padding: 36px 20px; text-align: center; color: #fff; margin-bottom: 16px; }
.score-num { display: block; font-size: 48px; font-weight: 700; margin: 6px 0; }
.score-label, .score-total { font-size: 12px; opacity: 0.9; }

.profile { display: flex; align-items: center; background: var(--green); border-radius: 20px; padding: 20px; color: #fff; margin: -16px -16px 16px; }
@media (min-width: 900px) { .profile { margin: -24px -32px 20px; } }
.avatar { width: 52px; height: 52px; line-height: 52px; text-align: center; border-radius: 50%; background: rgba(255,255,255,0.25); font-size: 22px; margin-right: 14px; }
.profile-info { flex: 1; }
.nickname { display: block; font-size: 17px; font-weight: 600; }
.uid { display: block; font-size: 11px; opacity: 0.8; margin-top: 4px; }
.login-link { font-size: 12px; background: #fff; color: var(--green); padding: 6px 14px; border-radius: 16px; cursor: pointer; border: none; }

.vip-card { display: flex; justify-content: space-between; align-items: center; cursor: pointer; background: linear-gradient(90deg,#fff8e6,#fff); }
.vip-title { display: block; font-weight: 600; color: var(--amber); }
.vip-sub { display: block; font-size: 12px; color: #a16207; margin-top: 4px; }

.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-switch { flex: 1; text-align: center; padding: 10px 0; font-size: 14px; color: var(--muted); cursor: pointer; }
.tab-switch.active { color: var(--green); font-weight: 600; border-bottom: 3px solid var(--green); }
.steps { margin-bottom: 20px; }
.step { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.step-num { width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; background: var(--green-light); color: var(--green); font-size: 11px; }
.demo-tip { display: block; font-size: 11px; color: var(--muted); text-align: center; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s; white-space: nowrap; }
.toast.show { opacity: 1; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 340px; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal-content { font-size: 14px; color: #4b5752; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn { flex: 1; height: 40px; border-radius: 20px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.modal-btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.loading-full { text-align: center; padding: 60px; color: var(--muted); }
.notice { font-size: 11px; color: #a8b0ad; text-align: center; line-height: 1.6; padding: 12px 20px 0; }
