:root {
  --brand: #0E7C66;
  --brand-dark: #0A5C4B;
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --text: #1F2933;
  --muted: #6B7280;
  --line: #E5E7EB;
  --ok: #16A34A;
  --err: #DC2626;
  --warn: #D97706;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 顶栏 */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 52px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
#topTitle { font-size: 18px; font-weight: 600; letter-spacing: .5px; }
.back-btn {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  margin-right: 10px;
  font-size: 14px;
  cursor: pointer;
}

/* 内容区 */
#content { flex: 1; padding: 14px 14px 76px; }
.view[hidden] { display: none; }

/* 首页 */
.hero {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-radius: 14px;
  padding: 20px 18px;
  margin-bottom: 14px;
}
.hero-title { font-size: 19px; font-weight: 700; }
.hero-sub { font-size: 13px; opacity: .9; margin-top: 4px; }

.stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-box {
  flex: 1;
  background: var(--card);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--brand); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.quick-row { display: flex; gap: 10px; margin-bottom: 16px; }
.btn-primary, .btn-ghost {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-primary:active, .btn-ghost:active { opacity: .85; }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

.section-title { font-size: 14px; color: var(--muted); margin: 6px 2px 10px; font-weight: 600; }
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subject-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sc-title { font-size: 16px; font-weight: 700; }
.sc-count { font-size: 13px; color: var(--muted); }
.btn-small {
  margin-top: auto;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-small:active { opacity: .85; }

/* 刷题页 */
.practice-view {
  position: fixed;
  inset: 0;
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.practice-view[hidden] { display: none; }
.practice-inner { flex: 1; overflow-y: auto; padding: 14px 14px 90px; }
.ph-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.q-subject {
  background: rgba(14,124,102,.12);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}
.q-progress { font-size: 13px; color: var(--muted); }
.q-type-tag { font-size: 12px; color: var(--warn); margin-left: 6px; }

.stem {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.6;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 12px;
}

.option {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option .opt-key {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.option .opt-text { flex: 1; font-size: 15px; }
.option.selected { border-color: var(--brand); background: rgba(14,124,102,.06); }
.option.selected .opt-key { background: var(--brand); color: #fff; }
.option.correct { border-color: var(--ok); background: rgba(22,163,74,.10); }
.option.correct .opt-key { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--err); background: rgba(220,38,38,.10); }
.option.wrong .opt-key { background: var(--err); color: #fff; }
.option.locked { cursor: default; }

.feedback {
  margin-top: 6px;
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
}
.feedback.ok { background: rgba(22,163,74,.10); border: 1px solid rgba(22,163,74,.3); }
.feedback.err { background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.3); }
.fb-title { font-weight: 700; margin-bottom: 6px; }
.fb-title.ok { color: var(--ok); }
.fb-title.err { color: var(--err); }
.fb-meta { color: var(--muted); margin-bottom: 6px; }
.fb-analysis { color: var(--text); }

.practice-bar {
  position: fixed;
  bottom: 0;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgba(0,0,0,.05);
  z-index: 31;
  display: flex;
  gap: 10px;
}
.practice-bar button {
  width: auto;
  flex: 1;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.practice-bar .bar-home {
  flex: 0 0 104px;
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
}
.practice-bar button:active { opacity: .85; }
.practice-bar button:disabled { opacity: .45; cursor: not-allowed; }

/* 结果页 */
.result-box {
  background: var(--card);
  border-radius: 14px;
  padding: 24px 18px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 14px;
}
.result-score { font-size: 42px; font-weight: 800; color: var(--brand); }
.result-sub { color: var(--muted); margin-top: 6px; font-size: 14px; }

/* 错题 / 列表 */
.list-item {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  cursor: pointer;
}
.list-item .li-subject { font-size: 12px; color: var(--brand-dark); font-weight: 600; }
.list-item .li-stem { font-size: 15px; margin-top: 4px; line-height: 1.5; }
.list-empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

.detail-panel {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.detail-panel .opt-line { padding: 6px 0; font-size: 15px; }
.detail-panel .opt-line.right { color: var(--ok); font-weight: 600; }
.detail-panel .ana { margin-top: 10px; font-size: 14px; color: var(--muted); line-height: 1.6; }

/* 我的 */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--text); }
.subj-stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.subj-stat:last-child { border-bottom: none; }
.subj-stat .num { color: var(--brand); font-weight: 700; }

.import-area {
  width: 100%;
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  resize: vertical;
}
.import-tip { font-size: 12px; color: var(--muted); margin: 8px 0; line-height: 1.5; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn-small { flex: 1; }
.btn-danger { background: var(--err) !important; }
.btn-outline { background: #fff !important; color: var(--brand) !important; border: 1px solid var(--brand) !important; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.82);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 50;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* 底部标签栏 */
#tabbar {
  position: fixed;
  bottom: 0;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  height: 60px;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 25;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tab.active { color: var(--brand); font-weight: 700; }
