/* Hallmark · iOS 移动端 · Apple 风
 * 分组列表 / Large Title 滚动收缩 / 半透明材质栏 / 吸底操作条 / 44pt 触控
 * 深色模式经 tokens.css 换肤，本文件不含硬编码颜色 */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: clip; }

body {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent-wash); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
.katex { font-size: 1.02em; }
.formula-display .katex { font-size: 1.42em; }
.formula-display .katex-display { margin: 0; }

/* 视图切换：一次性淡入（仅非减弱动态偏好） */
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .m-main > *, .m-hero { animation: view-in var(--dur-base) var(--ease-out); }
}

.m-shell { min-height: 100vh; padding-bottom: 96px; }
/* 大屏手机横竖屏临界（560–767px）：内容限宽居中，接近 iPad mini 的阅读宽度 */
@media (min-width: 560px) {
  .m-shell { max-width: 640px; margin-inline: auto; }
}

/* ══ 顶部收缩栏（Large Title 滚出后滑入）══ */
.m-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(48px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-bar);
  backdrop-filter: saturate(1.8) blur(20px);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  box-shadow: 0 0.5px 0 var(--border-hairline);
  font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em;
  transform: translateY(-100%);
  transition: transform var(--dur-base) var(--ease-out);
}
@media (min-width: 560px) { .m-topbar { max-width: 640px; margin-inline: auto; left: 0; right: 0; } }
body.is-scrolled .m-topbar { transform: translateY(0); }

/* Large Title */
.m-hero { padding: var(--space-6) var(--space-4) var(--space-2); }
.m-hero-date { font-size: var(--text-sm); font-weight: 600; color: var(--text-tertiary); letter-spacing: 0.01em; }
.m-hero-title { font-family: var(--font-display); font-size: var(--text-4xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.08; margin-top: 2px; }

.m-main { padding: 0 var(--space-4) var(--space-8); display: flex; flex-direction: column; gap: var(--space-6); }

/* 分组卡片 */
.m-section {}
.m-section-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 var(--space-4) var(--space-2); }
.m-section-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.01em; }
.m-section-more { font-size: var(--text-lg); color: var(--accent); text-decoration: none; }

.m-group { background: var(--bg-group); border-radius: var(--radius-md); box-shadow: var(--shadow-card); overflow: hidden; }

/* 分组列表行（≥44pt · 按压即时反馈）*/
.m-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch-min); padding: var(--space-3) var(--space-4); text-decoration: none; color: inherit; position: relative; transition: background var(--dur-fast) var(--ease-out); }
.m-row + .m-row::before { content: ""; position: absolute; left: var(--space-4); right: 0; top: 0; height: var(--hairline); background: var(--border-hairline); }
.m-row:active { background: var(--bg-fill); }
.m-row-main { flex: 1; min-width: 0; }
.m-row-title { font-size: var(--text-lg); font-weight: 500; letter-spacing: -0.005em; }
.m-row-sub { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 1px; }
.m-row-trail { flex: none; display: flex; align-items: center; gap: var(--space-2); }
.chev { color: var(--text-quaternary); display: flex; align-items: center; }

/* 今日主行动卡 */
.m-cta { background: var(--accent); color: var(--accent-fg); border-radius: var(--radius-lg); box-shadow: var(--shadow-card), inset 0 1px 0 var(--top-inset); padding: var(--space-5); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); text-decoration: none; transition: filter var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
.m-cta:active { filter: brightness(0.94); transform: scale(0.98); }
.m-cta .t { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.01em; }
.m-cta .s { font-size: var(--text-sm); opacity: 0.92; margin-top: 3px; }
.m-cta .go { width: 34px; height: 34px; border-radius: 50%; background: var(--on-accent-tint); display: flex; align-items: center; justify-content: center; flex: none; }

/* 统计 2×2 */
.m-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.m-stat { background: var(--bg-group); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: var(--space-4); }
.m-stat .n { font-family: var(--font-num); font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
.m-stat .l { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

/* 学科行 */
.m-subj { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--bg-group); border-radius: var(--radius-md); box-shadow: var(--shadow-card); text-decoration: none; color: inherit; position: relative; transition: background var(--dur-fast) var(--ease-out); }
.m-subj:active { background: var(--bg-fill); }
.m-subj + .m-subj { margin-top: var(--space-2); }
.m-subj-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--accent-fg); font-size: var(--text-md); font-weight: 700; flex: none; box-shadow: inset 0 1px 0 var(--icon-top-inset); }
.m-subj.yuwen .m-subj-icon { background: var(--subj-yuwen); }
.m-subj.math .m-subj-icon { background: var(--subj-math); }
.m-subj.eng .m-subj-icon { background: var(--subj-eng); }
.m-subj.phys .m-subj-icon { background: var(--subj-phys); }
.m-subj.chem .m-subj-icon { background: var(--subj-chem); }
.m-subj.bio .m-subj-icon { background: var(--subj-bio); }
.m-subj.hist .m-subj-icon { background: var(--subj-hist); }
.m-subj.geo .m-subj-icon { background: var(--subj-geo); }
.m-subj.pol .m-subj-icon { background: var(--subj-pol); }
.m-subj-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.005em; }
.m-subj-sub { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 1px; }
.m-subj.dim { opacity: 0.55; }

/* 模块目录行 */
.m-mod-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--touch-min); padding: var(--space-3) var(--space-4); text-decoration: none; color: inherit; position: relative; transition: background var(--dur-fast) var(--ease-out); }
.m-mod-row + .m-mod-row::before { content: ""; position: absolute; left: var(--space-4); right: 0; top: 0; height: var(--hairline); background: var(--border-hairline); }
.m-mod-row:active { background: var(--bg-fill); }
.m-mod-num { font-family: var(--font-num); font-size: var(--text-sm); font-weight: 700; color: var(--text-tertiary); width: 22px; flex: none; font-variant-numeric: tabular-nums; }
.m-mod-name { font-size: var(--text-lg); font-weight: 500; letter-spacing: -0.005em; }
.m-mod-meta { font-size: var(--text-sm); color: var(--text-tertiary); margin-top: 1px; }
.m-mod-side { margin-left: auto; text-align: right; flex: none; }
.m-mastery-track { width: 52px; height: 4px; border-radius: var(--radius-chip); background: var(--bg-fill); overflow: hidden; }
.m-mastery-fill { height: 100%; background: var(--green); border-radius: var(--radius-chip); }

/* 吸底自评操作条（半透明材质）*/
.m-gradebar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--bg-bar); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px); box-shadow: var(--shadow-tabbar); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
@media (min-width: 560px) { .m-gradebar { max-width: 640px; margin-inline: auto; } }
.m-grade-btn { min-height: 52px; border-radius: var(--radius-sm); border: var(--hairline) solid var(--border-strong); background: var(--bg-group); font-size: var(--text-lg); font-weight: 600; font-family: var(--font-ui); cursor: pointer; color: var(--text-primary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; transition: background var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
.m-grade-btn small { font-size: var(--text-xs); font-weight: 400; color: var(--text-tertiary); font-family: var(--font-num); }
.m-grade-btn:active { background: var(--bg-fill); transform: scale(0.98); }
.m-grade-btn.forgot { color: var(--red); }
.m-grade-btn.fuzzy { color: var(--orange); }
.m-grade-btn.got { color: var(--green); }

/* Tab Bar（5 枚 · SF 风描边图标 · 半透明材质）*/
.m-tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--bg-bar); backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px); box-shadow: var(--shadow-tabbar); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 560px) { .m-tabbar { max-width: 640px; margin-inline: auto; } }
.m-tab { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--text-tertiary); font-size: var(--text-2xs); padding-top: 4px; transition: color var(--dur-fast) var(--ease-out); }
.m-tab .ic { display: flex; align-items: center; justify-content: center; }
.m-tab.is-active { color: var(--accent); font-weight: 600; }

/* 复习页 */
.review-progress-track { height: 4px; border-radius: var(--radius-chip); background: var(--bg-fill); overflow: hidden; }
.review-progress-fill { height: 100%; background: var(--accent); border-radius: var(--radius-chip); transition: width var(--dur-base) var(--ease-out); }
.recall-prompt { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.01em; line-height: 1.4; }
.done-icon { color: var(--green); margin-bottom: var(--space-3); display: flex; justify-content: center; }
/* 长公式横向滚动，不裁断 */
.formula-display { background: var(--bg-group-2); border-radius: var(--radius-md); padding: var(--space-5) var(--space-3); text-align: center; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 374px) { .formula-display .katex { font-size: 1.28em; } }

.chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: var(--radius-chip); font-size: var(--text-xs); color: var(--text-secondary); background: var(--bg-fill); white-space: nowrap; font-weight: 500; }
.chip-accent { color: var(--accent); background: var(--accent-wash); }
.stage-badge { font-family: var(--font-num); font-size: var(--text-xs); color: var(--text-tertiary); white-space: nowrap; }

.hook-box { background: var(--accent-wash); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-size: var(--text-md); }
.mistake-box { background: var(--orange-wash); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-size: var(--text-md); }
.mistake-box ul, .hook-box ul { padding-left: var(--space-5); }
.variation { background: var(--bg-group); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: var(--space-4); margin-bottom: var(--space-3); }
.variation-q { margin-bottom: var(--space-2); font-size: var(--text-md); }
.variation-q .v-tag { font-family: var(--font-num); font-size: var(--text-xs); color: var(--accent); margin-right: var(--space-2); font-weight: 600; }
.reveal { border-top: var(--hairline) dashed var(--border-strong); margin-top: var(--space-3); padding-top: var(--space-3); color: var(--text-secondary); font-size: var(--text-sm); }

.section-label { font-size: var(--text-sm); font-weight: 700; color: var(--text-primary); margin: var(--space-4) 0 var(--space-2); display: flex; align-items: center; gap: var(--space-2); letter-spacing: 0.01em; }
.section-label::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--accent); }

.note { font-size: var(--text-xs); color: var(--text-tertiary); border-top: var(--hairline) solid var(--border-hairline); padding-top: var(--space-3); margin-top: var(--space-6); line-height: 1.7; }

/* 提高对比度偏好 */
@media (prefers-contrast: more) {
  .m-group, .m-stat, .m-subj, .variation { box-shadow: none; border: var(--hairline) solid var(--border-strong); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
