:root {
  --primary: #4A6CF7;
  --primary-dark: #3a57d6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #23262e;
  --muted: #8a90a0;
  --line: #e6e9f0;
  --danger: #e5484d;
  --ok: #2fa66b;
  --warn: #f2a53d;
  --radius: 14px;
  --shadow: 0 1px 4px rgba(30, 40, 80, .08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.app-header h1 { font-size: 19px; margin: 0; color: var(--primary); }
.header-right { font-size: 13px; color: var(--muted); }

/* ---------- 主区 ---------- */
.app-main {
  max-width: 720px; margin: 0 auto;
  padding: 12px 12px 90px;
}
.tab-page { display: none; }
.tab-page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.nav-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 6px; color: var(--muted); font-size: 11px;
}
.nav-ico { font-size: 20px; line-height: 1.2; }
.nav-btn.active { color: var(--primary); font-weight: 600; }
.nav-btn.active .nav-ico { transform: translateY(-1px); }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card-title {
  font-size: 14px; font-weight: 700; margin: 0 0 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- 按钮 ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer;
  font-size: 14px; font-family: inherit; background: var(--line); color: var(--text);
  transition: opacity .12s, transform .06s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { background: transparent; border: 0; cursor: pointer; font-size: 15px; padding: 2px 6px; color: var(--muted); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-family: inherit; color: var(--text);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }

/* ---------- 科目色块 ---------- */
.subj-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; color: #fff; white-space: nowrap;
}
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* ---------- 列表项 ---------- */
.item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.check {
  width: 22px; height: 22px; flex: none; margin-top: 1px;
  border: 2px solid #c3c9d6; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: #fff; font-size: 14px; color: transparent;
}
.check.checked { background: var(--ok); border-color: var(--ok); color: #fff; }

.add-bar { display: flex; gap: 8px; margin-top: 10px; }
.add-bar .input { flex: 1; }
.add-bar .select { flex: none; max-width: 120px; }

/* ---------- 分数规划 ---------- */
.score-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.score-cell { background: #f8faff; border-radius: 10px; padding: 8px 6px; text-align: center; }
.score-cell .v { font-size: 17px; font-weight: 700; }
.score-cell .l { font-size: 11px; color: var(--muted); }
.score-cell.hl { background: #eef3ff; color: var(--primary); }
.gap-ok { color: var(--ok); } .gap-bad { color: var(--danger); }

/* ---------- 里程碑 ---------- */
.milestone { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.milestone:last-child { border-bottom: 0; }
.milestone .m-text { flex: 1; }
.milestone .m-text.done { text-decoration: line-through; color: var(--muted); }
.milestone .m-subj { flex: none; }

.progress-track { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0 12px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }

/* ---------- 日历 ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-nav .ym { font-size: 16px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-day {
  position: relative; min-height: 58px; background: #f8faff; border-radius: 9px;
  padding: 4px; cursor: pointer; overflow: hidden;
}
.cal-day.today { outline: 2px solid var(--primary); }
.cal-day.other { opacity: .35; }
.cal-day .d { font-size: 13px; font-weight: 600; }
.cal-day .tags { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px; }
.cal-tag { font-size: 9px; color: #fff; border-radius: 3px; padding: 0 4px; line-height: 15px; white-space: nowrap; }
.review-dot { position: absolute; bottom: 3px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.cal-day.sel { outline: 2px solid var(--primary); outline-offset: 1px; background: #eef3ff; }

/* ---------- 番茄钟 ---------- */
.pomo {
  text-align: center; padding: 20px 14px;
  background: linear-gradient(135deg, #4A6CF7, #6c8cff);
  color: #fff; border-radius: var(--radius);
}
.pomo .mode { font-size: 13px; opacity: .9; }
.pomo .time { font-size: 58px; font-weight: 800; letter-spacing: 2px; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.pomo .subject-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0 14px; }
.pomo .subject-row .select { max-width: 150px; }
.pomo .btns { display: flex; justify-content: center; gap: 10px; }
.pomo .btn { min-width: 88px; background: rgba(255,255,255,.2); color: #fff; }
.pomo .btn-primary { background: #fff; color: var(--primary); }
.pomo-stats { display: flex; gap: 8px; margin-top: 12px; }
.pomo-stats .cell { flex: 1; background: rgba(255,255,255,.14); border-radius: 10px; padding: 8px 4px; text-align: center; font-size: 12px; }
.pomo-stats .cell b { display: block; font-size: 17px; }

/* ---------- 笔记本 ---------- */
.note-card { cursor: pointer; }
.note-thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.note-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.note-thumbs.single img { width: 100%; height: auto; object-fit: contain; max-height: 260px; background: #f0f2f8; }
.filter-bar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-btn { font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.type-心得 { background: var(--ok); }
.type-错题 { background: var(--danger); }
.type-要点 { background: var(--warn); }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 25, 40, .45);
}
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 41; width: calc(100% - 32px); max-width: 480px; max-height: 84vh;
  background: #fff; border-radius: 16px; padding: 16px; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------- 其他 ---------- */
.empty { text-align: center; color: var(--muted); padding: 22px 0; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tip { font-size: 12px; color: var(--muted); margin-top: 6px; }
section + section { margin-top: 4px; }

@media (min-width: 760px) {
  .app-main { padding-top: 20px; }
}
