:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e4e8ee;
  --text: #1d2433;
  --muted: #6b7484;
  --brand: #2f6feb;
  --brand-dark: #2559c4;
  --brand-soft: #eaf1ff;
  --green: #12855a;
  --green-soft: #e7f6ef;
  --amber: #b4740a;
  --amber-soft: #fdf3e2;
  --red: #c5342b;
  --red-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 34, 51, .06), 0 8px 24px rgba(22, 34, 51, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  font-size: 16px;
  letter-spacing: .02em;
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 11px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.nav a:hover { background: #f2f4f8; text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.userchip strong { color: var(--text); font-weight: 600; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .label { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #cfd6e0; background: #fafbfc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; line-height: 1.7; font-weight: 600;
  background: #f1f3f7; color: var(--muted);
}
.badge.blue { background: var(--brand-soft); color: var(--brand); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: #f1f3f7; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-20 { margin-top: 20px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: #3b4453; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 111, 235, .12);
}
textarea { min-height: 90px; resize: vertical; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-ok { background: var(--green-soft); color: var(--green); }
.alert-info { background: var(--brand-soft); color: var(--brand); }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
table.list tr:last-child td { border-bottom: none; }

.task-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.task-row:last-child { border-bottom: none; }
.task-idx {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px; background: #f1f3f7; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.task-body { flex: 1; min-width: 0; }
.task-stem { font-size: 15px; word-break: break-word; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.answer-line { margin-top: 6px; font-size: 13px; color: var(--green); }
.answer-line b { font-weight: 600; }

.unit-tree .unit { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.unit-tree .unit-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.unit-tree .sections { display: flex; flex-wrap: wrap; gap: 8px; }
.unit-tree label.chk {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 13px; cursor: pointer; background: #fbfcfd;
}
.unit-tree label.chk:hover { border-color: #c9d4e6; }
.unit-tree input[type=checkbox] { accent-color: var(--brand); }

.subject-block { margin-top: 18px; }
.subject-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.subject-head h3 { margin: 0; }

.progress { height: 8px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.progress.green > span { background: var(--green); }

.day-list { display: flex; gap: 8px; flex-wrap: wrap; }
.day-chip {
  padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line);
  font-size: 13px; color: var(--muted); background: #fff;
}
.day-chip.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 600; }

.empty {
  padding: 26px 16px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 12px; background: #fafbfc;
}

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero .big { font-size: 30px; font-weight: 750; letter-spacing: -.02em; }

.bubble {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; line-height: 1.75; min-height: 60px;
  white-space: pre-wrap; word-break: break-word;
}
.cursor::after {
  content: "▍"; color: var(--brand); animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.grade-banner { border-radius: 12px; padding: 16px; text-align: center; }
.grade-banner.ok { background: var(--green-soft); color: var(--green); }
.grade-banner.bad { background: var(--red-soft); color: var(--red); }
.grade-banner.unknown { background: var(--amber-soft); color: var(--amber); }
.grade-banner .big { font-size: 26px; font-weight: 700; }
.grade-banner .small { font-size: 13px; opacity: .9; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(1200px 500px at 20% -10%, #e8f0ff 0%, transparent 60%), var(--bg);
}
.login-card { width: 100%; max-width: 420px; }
.login-card .brand { margin-bottom: 6px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: #fbfcfe; display: block; color: var(--text);
}
.quick-item:hover { border-color: #c9d4e6; text-decoration: none; }
.quick-item .t { font-weight: 600; font-size: 14px; }
.quick-item .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

.timer { font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .container { padding: 14px 12px 50px; }
  h1 { font-size: 20px; }
  .hero .big { font-size: 24px; }
}
@media (max-width: 540px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 10px; padding: 8px 12px; }
  .quick-grid { grid-template-columns: 1fr; }
  .stat .value { font-size: 22px; }
}

/* 习惯养成柱状 */
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 38px; margin-top: 10px; }
.bars .bar { flex: 1; background: #e9edf3; border-radius: 4px 4px 2px 2px; min-height: 4px; }
.bars .bar.on { background: var(--green); }
.bars .bar.today { outline: 1px solid rgba(47,111,235,.35); }
.habit-strip { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.habit-strip .k { font-size: 12px; color: var(--muted); }
.habit-strip .v { font-size: 20px; font-weight: 700; line-height: 1.2; }
.habit-strip .unit { font-size: 12px; color: var(--muted); font-weight: 500; }

/* 错题本 */
.tag-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 190px;
  flex: 0 1 240px;
  background: #fbfcfe;
}
.tag-card .tag-name { font-weight: 650; font-size: 14px; margin: 6px 0 2px; }

.mistake-list { display: flex; flex-direction: column; }
.mistake-item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.mistake-item:first-child { border-top: none; padding-top: 4px; }
.mistake-answers { display: flex; gap: 22px; flex-wrap: wrap; font-size: 14px; }
.mistake-answers .k { color: var(--muted); font-size: 12px; margin-right: 8px; }
.mistake-answers .v { font-weight: 650; color: var(--red); }
.mistake-answers .v.ok { color: var(--green); }

/* 周报习惯曲线（带日期标签） */
.bars .bar-wrap {
  flex: 1 1 0;
  max-width: 64px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.bars .bar-wrap .bar { width: 100%; flex: none; }
.bars .bar-label { font-size: 10px; color: var(--muted); padding-top: 4px; line-height: 1.2; white-space: nowrap; }

/* 多孩子选择 */
.student-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.student-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  background: #fff;
  margin: 0;
}
.student-chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

/* 教材：按单元分块 */
.unit-divider td { background: #f7f9fc; font-size: 14px; }
pre.example {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.8;
  color: var(--text);
  overflow-x: auto;
  margin: 8px 0 6px;
  white-space: pre;
}

/* 生成页：题量与预算预估 */
.estimate-box {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}
