/* 移动优先：手机底部 Tab、安全区；平板 ≥720px 双栏。 */
:root {
  --ink: #1c2b2a;
  --text: #1c2b2a;
  --muted: #667775;
  --line: #dfe7e4;
  --paper: #ffffff;
  --bg-elev: #ffffff;
  --bg: #f3f7f5;
  --brand: #0f6e62;
  --brand-soft: #e2f1ed;
  --bad: #c0392b;
  --bad-soft: #fbece9;
  --warn: #b26a00;
  --warn-soft: #fdf3e2;
  --ok: #247a4b;
  --ok-soft: #e8f5ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 45, 40, .05), 0 10px 24px -18px rgba(20, 45, 40, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.app-top {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 10px;
  max-width: 1060px; margin: 0 auto;
}
.kicker { font-size: 11px; letter-spacing: .12em; color: var(--brand); font-weight: 700; }
.app-top h1 { font-size: 20px; line-height: 1.3; margin-top: 2px; letter-spacing: -.01em; }
.top-side { text-align: right; flex-shrink: 0; }
.today { font-size: 12px; color: var(--muted); }
.countdown { font-size: 13px; font-weight: 700; color: var(--brand); margin-top: 2px; }

.view { max-width: 1060px; margin: 0 auto; padding: 2px 14px 24px; }
.loading { color: var(--muted); text-align: center; padding: 60px 0; }

/* 学科切换 */
.subject-bar {
  display: flex; gap: 8px; padding: 0 18px 10px; max-width: 1060px; margin: 0 auto;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.subject-bar::-webkit-scrollbar { display: none; }
.subject-chip {
  flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 5px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.subject-chip b { font-weight: 700; }
.subject-chip i { font-style: normal; font-size: 10px; opacity: .7; }
.subject-chip.on {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 6px 16px -10px rgba(15, 110, 98, .7);
}
.subject-chip.soon { color: #9aa8a5; border-style: dashed; cursor: pointer; background: transparent; }
.subject-chip.soon.on { background: transparent; color: var(--muted); box-shadow: none; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-top: 12px;
}
.card.tight { padding: 12px 14px; }
.card h2 { font-size: 16px; line-height: 1.4; }
.card h3 { font-size: 14px; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 15px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn.danger { color: var(--bad); border-color: #efd6d1; background: #fff; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }

.hero-card { background: linear-gradient(145deg, #0f6e62, #128174); color: #fff; border: 0; }
.hero-card h2 { font-size: 17px; }
.hero-card .sub { color: rgba(255,255,255,.82); }
.hero-stats { display: flex; gap: 18px; margin-top: 12px; }
.hero-stats b { display: block; font-size: 22px; line-height: 1.1; }
.hero-stats span { font-size: 11.5px; opacity: .85; }
.hero-card .btn { background: #fff; border-color: #fff; color: var(--brand); margin-top: 14px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-top: 20px; }
.section-title h2 { font-size: 15px; }
.section-title a { font-size: 12.5px; }

.task {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 0;
  border-top: 1px solid var(--line);
}
.task:first-of-type { border-top: 0; }
.task-main { flex: 1; min-width: 0; }
.task-name { font-weight: 600; font-size: 14.5px; line-height: 1.4; word-break: break-word; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.task .btn { flex-shrink: 0; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px;
  font-weight: 700; line-height: 1.8; white-space: nowrap;
}
.badge.weak { color: var(--bad); background: var(--bad-soft); }
.badge.shaky { color: var(--warn); background: var(--warn-soft); }
.badge.mastered { color: var(--ok); background: var(--ok-soft); }
.badge.unknown { color: var(--muted); background: #eef1f0; }
.badge.due { color: var(--brand); background: var(--brand-soft); }
.badge.new { color: #4b5bd6; background: #eceefc; }

.quick-grid { display: grid; gap: 10px; }
.quick {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
}
.quick b { font-size: 14px; display: block; }
.quick span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.quick .go { margin-left: auto; color: var(--brand); font-weight: 700; font-size: 18px; }
.quick select { width: 100%; margin-top: 6px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.stat b { display: block; font-size: 23px; line-height: 1.15; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: var(--ok); }

.group-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .04em;
}
.topic-list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.topic-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.topic-row:first-child { border-top: 0; }
.topic-row .name { flex: 1; font-size: 13.5px; line-height: 1.4; min-width: 0; word-break: break-word; }
.topic-row .name small { display: block; color: var(--muted); font-size: 11.5px; }

.wrong-card { border-top: 1px solid var(--line); padding: 13px 0; }
.wrong-card:first-of-type { border-top: 0; padding-top: 2px; }
.prompt { white-space: pre-wrap; font-size: 14px; line-height: 1.6; word-break: break-word; }
.answer-line { margin-top: 6px; font-size: 12.5px; }
.answer-line.bad { color: var(--bad); }
.answer-line.ok { color: var(--ok); }
.explain {
  margin-top: 6px; padding: 8px 10px; border-radius: 9px; background: #f6f9f8;
  color: #41514f; font-size: 12.5px; white-space: pre-wrap;
}
.wrong-actions { margin-top: 9px; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13px; }
.empty b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }

.progress { height: 7px; border-radius: 99px; background: #e7eeeb; overflow: hidden; margin-top: 9px; }
.progress i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }

/* 水平评估：按学期一行 */
.band-row {
  display: grid; grid-template-columns: 46px 1fr 44px; gap: 8px;
  align-items: center; padding: 7px 0; border-top: 1px solid var(--line);
}
.band-row:first-child { border-top: 0; }
.band-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.band-bar { height: 8px; border-radius: 99px; background: #e7eeeb; overflow: hidden; }
.band-bar i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.band-num { font-size: 12px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.band-sub { grid-column: 1 / -1; font-size: 11px; color: var(--muted); margin: -3px 0 2px 54px; }

.weekly { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 12px; }
.day-col { text-align: center; }
.day-col .bar { height: 72px; display: flex; align-items: flex-end; justify-content: center; }
.day-col .bar i { display: block; width: 12px; border-radius: 6px; background: var(--brand-soft); min-height: 3px; }
.day-col .bar i.has { background: var(--brand); }
.day-col em { font-style: normal; font-size: 10.5px; color: var(--muted); display: block; margin-top: 4px; }

.form-row { margin-top: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.input {
  width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; font-size: 15px;
}
.code-input { letter-spacing: .18em; text-transform: uppercase; font-weight: 700; }
.note { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 8px; }
.sync-state { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f6f9f8; font-size: 12.5px; color: #41514f; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tabbar a {
  flex: 1; text-align: center; color: var(--muted); padding: 4px 2px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tabbar a b { font-size: 13.5px; }
.tabbar a span { font-size: 10px; opacity: .8; }
.tabbar a.on { color: var(--brand); background: var(--brand-soft); }

.footnote { color: var(--muted); font-size: 11.5px; line-height: 1.7; padding: 18px 4px 4px; }
.footnote a { text-decoration: underline; }

@media (min-width: 720px) {
  body { padding-bottom: 100px; }
  .app-top { padding-top: 24px; }
  .app-top h1 { font-size: 24px; }
  .view { padding: 6px 22px 34px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .tabbar {
    left: 50%; right: auto; bottom: 18px; transform: translateX(-50%);
    width: 520px; border: 1px solid var(--line); border-radius: 16px;
    padding: 6px; box-shadow: 0 10px 30px -10px rgba(15, 60, 50, .25);
  }
}

@media print {
  body { background: #fff; padding: 0; }
  .app-top { padding: 0 0 8px; }
  .view { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .no-print, .tabbar { display: none !important; }
}
