:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2330;
  --sub: #6b7280;
  --accent: #4f6bf0;
  --line: #e5e7eb;
  --done: #9aa3b2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a;
    --card: #1a1f2b;
    --text: #e8eaf0;
    --sub: #8b93a5;
    --accent: #7b93ff;
    --line: #2a3040;
    --done: #5a6273;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 跟随手机浏览器工具栏伸缩,保证导航栏始终可见 */
}
.page {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 28px;
}
.head h1 { font-size: 1.5rem; }
.head .sub { color: var(--sub); font-size: .875rem; margin-top: 4px; }
.progress { margin: 16px 0 8px; color: var(--sub); font-size: .875rem; }
.progress strong { color: var(--accent); font-size: 1.05rem; }
.section {
  font-size: .95rem;
  margin: 20px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section .count { color: var(--sub); font-weight: normal; font-size: .8rem; }
.tasks { list-style: none; }
.tasks li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
.tasks label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
}
.tasks input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.tasks .label { flex: 1; line-height: 1.45; }
.tasks input:checked ~ .label {
  color: var(--done);
  text-decoration: line-through;
}
.tasks .mins {
  color: var(--sub);
  font-size: .75rem;
  flex-shrink: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
}
.card .row { padding: 6px 0; font-size: .9rem; line-height: 1.5; }
.card .row.now { color: var(--accent); }
.badge {
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 999px;
}
.day.today .section { color: var(--accent); }
.tabbar {
  flex-shrink: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
}
.tabbar a {
  flex: 1;
  text-align: center;
  padding: 13px 0;
  color: var(--text);
  opacity: .62;
  text-decoration: none;
  font-size: .98rem;
  font-weight: 500;
}
.tabbar a.active {
  color: var(--accent);
  opacity: 1;
  font-weight: 700;
}
.login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 80vh;
  gap: 24px;
  text-align: center;
}
.login form { display: flex; flex-direction: column; gap: 12px; }
.login input {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}
.login button {
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
}
.login .error { color: #e5484d; font-size: .875rem; }

/* 成就统计 */
.stats {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.stats .tile {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stats .num { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.stats .cap { font-size: .72rem; color: var(--sub); }

/* 笔记 */
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  padding: 10px;
  font-size: .95rem;
  font-family: inherit;
  resize: vertical;
}
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: .9rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.note-card { margin-top: 8px; }
.note-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.note-content { line-height: 1.6; white-space: pre-wrap; font-size: .93rem; }
.chip {
  font-size: .72rem;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--sub);
}
.chip.insight { color: var(--accent); border-color: var(--accent); }
.chip.late { color: #b5850e; border-color: #b5850e; margin-left: 6px; }
.banner {
  display: block;
  margin-top: 14px;
  color: var(--accent);
  text-decoration: none;
  font-size: .9rem;
}
.question textarea { margin-top: 10px; }
.q-text { font-weight: 600; }
.expand {
  color: var(--sub);
  padding: 4px 8px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}
.task-detail {
  padding: 0 14px 14px 48px;
  font-size: .85rem;
  line-height: 1.7;
  color: var(--sub);
  white-space: pre-wrap;
}
.task-detail.plain {
  padding: 8px 10px;
  margin: 6px 0;
  background: var(--bg);
  border-radius: 8px;
}
/* 日期/周导航 */
.daynav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.daynav h1 { flex: 1; font-size: 1.35rem; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.nav-btn.dim { opacity: .35; }
.head a { color: var(--accent); text-decoration: none; }

/* 雷达简报 */
.digest.unread { border-color: var(--accent); }
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
}
.digest-body {
  font-size: .9rem;
  line-height: 1.75;
}
.digest-body a { color: var(--accent); }

/* markdown 渲染内容(雷达简报、信箱回信) */
.md { white-space: normal; }
.md p, .md ul, .md ol, .md blockquote, .md pre { margin: .6em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1em 0 .4em; line-height: 1.4; color: var(--text); }
.md h1 { font-size: 1.05rem; }
.md h2 { font-size: 1rem; }
.md h3 { font-size: .95rem; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .25em 0; }
.md blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 10px;
  background: var(--card);
  border-radius: 6px;
  color: var(--sub);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 1em 0; }
.md code { background: var(--card); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
.md pre { background: var(--card); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md a {
  color: var(--accent);
  word-break: break-all;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.md a:active { opacity: .7; }
.md a[target="_blank"]::after { content: " ↗"; font-size: .8em; }
.md table { border-collapse: collapse; margin: .6em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; font-size: .85em; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }

/* 信箱 */
.msg.claude { border-left: 3px solid var(--accent); }
.msg.user { border-left: 3px solid var(--line); }

.program { margin-top: 12px; }
.prog-name { font-size: 1rem; }
.prog-name .chip { margin-right: 6px; }
.north-star {
  margin-top: 8px;
  font-size: .85rem;
  line-height: 1.6;
  color: var(--sub);
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.q-answer {
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  color: var(--sub);
}
.del {
  border: none;
  background: none;
  color: var(--sub);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
}

/* 周进度条：单一强调色，数值直接标注在条外 */
.week-row { padding: 6px 0; }
.bar {
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .3s;
}
.bar-label { font-size: .75rem; color: var(--sub); margin-top: 4px; }

/* 完成庆祝 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .95rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  z-index: 10;
  animation: pop .3s ease;
}
@keyframes pop {
  from { transform: translateX(-50%) scale(.8); opacity: 0; }
  to   { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ---------- 论文双语阅读 ---------- */
.lunch-card { border-color: var(--accent); }
.lunch-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  cursor: pointer;
}
.lunch-item input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.lunch-item .label { flex: 1; line-height: 1.5; }
.lunch-item input:checked ~ .label { color: var(--done); text-decoration: line-through; }
.lunch-item .mins { color: var(--sub); font-size: .75rem; flex-shrink: 0; }
.lunch-go { padding: 8px 14px; font-size: .85rem; text-decoration: none; border-radius: 10px; flex-shrink: 0; }

.paper-form { display: flex; gap: 8px; }
.paper-form input {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
}
.paper-item .prog-name { display: flex; align-items: center; gap: 8px; }
.paper-link { color: var(--text); text-decoration: none; }
.paper-link:active { opacity: .7; }
.paper-dim { color: var(--sub); font-weight: 500; }
.pstatus {
  flex-shrink: 0;
  margin-left: auto;
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--sub);
}
.pstatus.done { background: rgba(61, 165, 96, .15); color: #3da560; }
.pstatus.failed { background: rgba(220, 76, 76, .12); color: #d24c4c; }
.pstatus.fetched { background: rgba(79, 107, 240, .12); color: var(--accent); }
.tr-chip {
  margin-left: 4px;
  padding: 1px 7px;
  font-size: .72rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}
.tr-chip:disabled { opacity: .45; cursor: default; }
.page { scroll-behavior: smooth; }
.papers-wrap { display: flex; flex-direction: column; }
.papers-main { min-width: 0; flex: 1; }
.paper-day .count { color: var(--sub); font-weight: normal; font-size: .8rem; }
/* 手机:日期条横向吸顶 */
.date-rail {
  order: -1;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0;
  background: var(--bg);
}
.date-rail a {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: .8rem;
}
.date-rail a .count {
  margin-left: 4px;
  color: var(--sub);
  font-size: .7rem;
}
/* 桌面:日期轨立在右侧 */
@media (min-width: 900px) {
  .papers-wrap { flex-direction: row; gap: 20px; align-items: flex-start; }
  .date-rail {
    order: 1;
    flex: 0 0 auto;
    flex-direction: column;
    top: 8px;
    padding: 0;
    background: none;
    max-height: 80vh;
    overflow-y: auto;
  }
  .date-rail a { text-align: center; }
}

.paper-brief {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: .82rem;
  line-height: 1.65;
  color: var(--sub);
}
.note-review {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: .86rem;
  line-height: 1.7;
}
.note-review .chip { margin-bottom: 6px; display: inline-block; }
.paper-brief strong { color: var(--text); }
.paper-brief-card { border-left: 3px solid var(--accent); font-size: .88rem; }
.paper-body { font-size: .92rem; }
.paper-brief-card p,
.paper-body p { white-space: pre-line; }
.paper-body blockquote {
  border-left-color: #3da560;
  color: var(--text);
}
.print-head { display: none; }

@media (max-width: 400px) {
  .tabbar a { font-size: .84rem; padding: 12px 0; }
}

/* 打印:干掉应用壳,恢复文档流,只留正文 */
@media print {
  body { display: block; height: auto; }
  .page { overflow: visible; height: auto; max-width: none; padding: 0; }
  .tabbar, .no-print, .toast { display: none !important; }
  .print-head { display: block; margin-bottom: 16px; }
  .print-head h1 { font-size: 1.3rem; }
  .print-head p { color: #555; font-size: .8rem; }
  .card { border: none; padding: 0; margin: 0; }
  .md a { color: inherit; text-decoration: none; }
  .md a[target="_blank"]::after { content: ""; }
  .md blockquote { background: none; border-left: 2px solid #888; }
}

/* ---------- 桌面端(≥900px):底部导航变左侧边栏,内容区放宽 ---------- */
@media (min-width: 900px) {
  body { flex-direction: row; }
  .tabbar {
    order: -1;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    width: 200px;
    padding: 20px 14px;
    border-top: none;
    border-right: 1px solid var(--line);
    box-shadow: none;
  }
  .tabbar::before {
    content: "📚 学习系统";
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    padding: 6px 14px 18px;
  }
  .tabbar a {
    flex: 0 0 auto;
    text-align: left;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 1rem;
  }
  .tabbar a:hover { opacity: 1; background: rgba(127, 140, 170, .12); }
  .tabbar a.active { background: rgba(79, 107, 240, .13); }
  .page {
    max-width: 1200px;
    padding: 36px 56px 48px;
  }
  .head h1 { font-size: 1.7rem; }
  textarea { min-height: 140px; padding: 14px; font-size: 1rem; line-height: 1.7; }
}
/* 超宽屏再放宽一档 */
@media (min-width: 1600px) {
  .page { max-width: 1360px; }
}
