/* ============================================================
   考研打卡 · 视觉基础
   奶油底 + 单一蜜桃强调色，卡片质感，克制圆角
   ============================================================ */

:root {
  --bg: #FAF6F1;
  --bg-soft: #F3EBE1;
  --surface: #FFFFFF;
  --surface-2: #FDFAF7;
  --border: #EDE2D6;
  --border-strong: #E2D4C5;
  --text: #3B332C;
  --text-2: #6E6259;
  --muted: #A2948A;
  --accent: #E27D57;
  --accent-hover: #D96E45;
  --accent-soft: #FBEAE1;
  --accent-ink: #B0522D;
  --user-a: #E27D57;
  --user-b: #6F9A7C;
  --user-b-soft: #E8F1EA;
  --ok: #6F9A7C;
  --shadow-sm: 0 1px 2px rgba(96, 72, 52, .05), 0 2px 6px -2px rgba(96, 72, 52, .07);
  --shadow: 0 1px 2px rgba(96, 72, 52, .04), 0 10px 28px -14px rgba(96, 72, 52, .22);
  --shadow-lg: 0 2px 4px rgba(96, 72, 52, .05), 0 22px 48px -20px rgba(96, 72, 52, .28);
  --r-xs: 10px;
  --r-sm: 12px;
  --r: 18px;
  --r-lg: 22px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --pop: cubic-bezier(.34, 1.46, .64, 1);
  --font: "HarmonyOS Sans SC", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC",
          "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --top-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1B1817;
    --bg-soft: #221E1C;
    --surface: #262220;
    --surface-2: #2B2724;
    --border: #393230;
    --border-strong: #4A413D;
    --text: #F2ECE6;
    --text-2: #C6BBB1;
    --muted: #8D8178;
    --accent: #EB9270;
    --accent-hover: #F5A281;
    --accent-soft: #3B2A22;
    --accent-ink: #F6BBA0;
    --user-a: #EB9270;
    --user-b: #8FC0A0;
    --user-b-soft: #26332B;
    --ok: #8FC0A0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 28px -16px rgba(0, 0, 0, .7);
    --shadow-lg: 0 24px 52px -22px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

/* 重要：作者样式里的 display 会覆盖浏览器默认的 [hidden]{display:none}，
   统一强制一次，保证 hidden 属性始终生效（登录页/主界面/弹层都靠它切换）。 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  /* 16px 是手机上的安全基准：再小一行中文就发虚，而且会让 iOS 在聚焦输入框时
     自动放大整页。所有子元素都按这个基准用相对/绝对字号排。 */
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* 横屏或分屏时禁止 iOS 自作主张放大字体 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: none;
  /* 手机上长按选中文字多半是误操作，但打卡文字需要能选，所以只在 UI 区禁掉 */
  -webkit-touch-callout: none;
}

/* 极淡的纸张纹理，避免大面积纯色发闷 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle at 12% 8%, rgba(226, 125, 87, .07), transparent 42%),
                    radial-gradient(circle at 88% 0%, rgba(111, 154, 124, .06), transparent 38%);
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ============================================================
   登录
   ============================================================ */

.gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 26px 26px;
  text-align: center;
}
.gate-badge {
  width: 60px; height: 60px; margin: 0 auto 16px;
  display: grid; place-items: center;
  font-size: 28px;
  border-radius: 20px;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(226, 125, 87, .16);
}
.gate-card h1 { font-size: 22px; margin-bottom: 6px; }
.gate-sub { color: var(--text-2); font-size: 14px; margin-bottom: 22px; }
.gate-card input {
  width: 100%; min-height: 50px;
  padding: 0 15px;
  /* ≥16px：低于 16px 时 iOS Safari 会在聚焦瞬间把整个页面放大 */
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  margin-bottom: 12px;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.gate-card input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.gate-error { margin-top: 12px; font-size: 14px; color: #C0392B; min-height: 20px; }
@media (prefers-color-scheme: dark) { .gate-error { color: #F09A8C; } }

/* ============================================================
   骨架
   ============================================================ */

.app { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--top-h);
  /* 顶部也要让开刘海/灵动岛：index.html 里 viewport-fit=cover 让页面铺满整个屏幕，
     不补 env(safe-area-inset-top) 的话 iPhone 上标题会被状态栏压住。 */
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-left))
           10px max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 16px; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 14px; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 15px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: background .2s var(--ease), color .2s var(--ease), transform .12s var(--ease);
}
.tab:hover { color: var(--text); }
.tab:active { transform: scale(.96); }
.tab.is-active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }

.stage { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; }
@media (min-width: 900px) { .stage { max-width: 820px; padding-top: 28px; } }

.view { display: none; }
.view.is-active { display: block; animation: viewIn .28s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-title { font-size: 16.5px; margin-bottom: 14px; }

.section-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 26px 2px 12px;
}
.section-head h2 { font-size: 16.5px; }
.section-head .hint { font-size: 13px; color: var(--muted); }

.note { font-size: 13px; color: var(--muted); margin-top: 10px; }

/* ============================================================
   按钮
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 46px; padding: 0 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 15.5px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform .13s var(--ease), background .2s var(--ease),
              border-color .2s var(--ease), box-shadow .2s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 18px -8px rgba(226, 125, 87, .75); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost { background: var(--surface-2); color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }

.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 13px; font-size: 13.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--text-2);
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn:active { transform: scale(.92); }

/* ============================================================
   日期条
   ============================================================ */

.daybar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;          /* 极窄屏上宁可换行，也别把两侧的 44px 按钮顶出屏幕 */
  row-gap: 8px;
  padding: 12px;
}
.daybar-main { flex: 1; min-width: 0; text-align: center; }
.daybar-title { font-size: 18px; font-weight: 700; }
.daybar-sub {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-wrap: wrap;                      /* 窄屏上「2026 年 · 周三 · 两人进度」会排不下 */
  font-size: 13px; color: var(--muted);
  margin-top: 2px;
}
.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }

/* ============================================================
   用户切换
   ============================================================ */

.users { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }

.user {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 34px 13px 15px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), border-color .2s var(--ease),
              box-shadow .2s var(--ease), background .2s var(--ease);
}
.user:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.user:active { transform: translateY(0) scale(.985); }
.user .avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px; font-size: 20px;
  background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px var(--border);
}
.user[data-user="A"].is-active { border-color: var(--user-a); background: var(--accent-soft); }
.user[data-user="A"].is-active .avatar { background: #fff; box-shadow: inset 0 0 0 1.5px var(--user-a); }
.user[data-user="B"].is-active { border-color: var(--user-b); background: var(--user-b-soft); }
.user[data-user="B"].is-active .avatar { background: #fff; box-shadow: inset 0 0 0 1.5px var(--user-b); }
@media (prefers-color-scheme: dark) {
  .user[data-user="A"].is-active .avatar,
  .user[data-user="B"].is-active .avatar { background: var(--surface); }
}
.user-meta { min-width: 0; flex: 1; }
.user-name {
  display: block;
  font-weight: 700; font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-sub {
  display: block;
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-tick {
  position: absolute; top: 9px; right: 10px;
  font-size: 11.5px; font-weight: 700;
  color: var(--ok);
  opacity: 0; transform: scale(.6);
  transition: opacity .2s var(--ease), transform .3s var(--pop);
}
.user.is-active .user-tick { opacity: 1; transform: none; }

/* ============================================================
   科目卡片
   ============================================================ */

.subjects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.subject {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 116px;
  padding: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .16s var(--ease), border-color .2s var(--ease),
              box-shadow .2s var(--ease), background .2s var(--ease);
}
.subject:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.subject:active { transform: translateY(0) scale(.985); }
.subject.is-open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.subject.is-done { background: var(--surface-2); }
.subject-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.subject-emoji { font-size: 19px; }
.subject-name { font-weight: 700; font-size: 16px; }
.subject-badge {
  margin-left: auto;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 100px;
  white-space: nowrap;
  background: var(--bg-soft); color: var(--muted);
  transition: all .2s var(--ease);
}
.subject.is-done .subject-badge { background: var(--accent-soft); color: var(--accent-ink); }
.subject-preview {
  font-size: 13.5px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.subject.is-done .subject-preview { color: var(--text-2); }
.subject-foot { display: flex; gap: 6px; align-items: center; margin-top: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 100px;
  background: var(--bg-soft); color: var(--text-2);
}
.pill-thumb { width: 26px; height: 26px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }
.who-dots { margin-left: auto; display: flex; gap: 4px; }
.who-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-strong);
  transition: background .25s var(--ease), transform .25s var(--pop);
}
.who-dot.on[data-u="A"] { background: var(--user-a); }
.who-dot.on[data-u="B"] { background: var(--user-b); }

/* ============================================================
   打卡输入区
   ============================================================ */

.composer { margin-top: 14px; animation: viewIn .26s var(--ease) both; }
.composer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.composer-title { font-weight: 700; font-size: 16.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-title .tag {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 100px;
  background: var(--accent-soft); color: var(--accent-ink);
}
.composer textarea {
  width: 100%;
  padding: 13px 14px;
  /* ≥16px：否则 iOS 聚焦时会把整个页面放大，手机上手感很别扭 */
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.composer textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.composer textarea::placeholder { color: var(--muted); }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.thumbs:empty { display: none; }
.thumb {
  position: relative;
  width: 92px; height: 92px;
  border-radius: var(--r-xs);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  animation: viewIn .24s var(--ease) both;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb-del {
  position: absolute; top: 5px; right: 5px;
  /* 手机上手指触点约 9mm，22px 的按钮很难点中，放大到 30px */
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(28, 22, 18, .62); color: #fff;
  font-size: 15px; line-height: 1;
  display: grid; place-items: center;
  transition: transform .14s var(--ease), background .18s;
}
.thumb-del:hover { background: #C0392B; transform: scale(1.08); }
.thumb-bar { position: absolute; inset: auto 0 0 0; height: 3px; background: rgba(255, 255, 255, .3); }
.thumb-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s var(--ease); }

.composer-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.composer-actions .btn-primary { flex: 1 1 auto; min-width: 0; }
.upload-btn { cursor: pointer; }
.composer-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; min-height: 19px; }

/* ============================================================
   记录时间线
   ============================================================ */

.timeline { display: flex; flex-direction: column; gap: 12px; }

.rec {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.rec.is-new { animation: recPop .42s var(--pop) both; }
@keyframes recPop {
  0%   { opacity: 0; transform: translateY(14px) scale(.96); }
  60%  { opacity: 1; transform: translateY(-2px) scale(1.012); }
  100% { opacity: 1; transform: none; }
}
.rec-avatar {
  width: 46px; height: 46px; border-radius: 15px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--bg-soft);
  box-shadow: inset 0 0 0 1px var(--border);
}
.rec[data-user="A"] .rec-avatar { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--user-a); }
.rec[data-user="B"] .rec-avatar { background: var(--user-b-soft); box-shadow: inset 0 0 0 1.5px var(--user-b); }
.rec-body { min-width: 0; }
/* 右上角是常驻的删除按钮（手机上一直显示），头部必须给它留出位置，
   否则 .rec-time（margin-left:auto 顶到最右）会被压在按钮底下。 */
.rec-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px; padding-right: 38px;
}
.rec-who { font-weight: 700; font-size: 15px; }
.rec-subject {
  font-size: 12.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 100px;
  background: var(--bg-soft); color: var(--text-2);
}
.rec-time {
  margin-left: auto; font-size: 12px; color: var(--muted);
  flex: 0 0 auto; white-space: nowrap;
}
.rec-text { font-size: 15px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.rec-text:empty { display: none; }
.rec-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rec-imgs img {
  width: 100px; height: 100px; object-fit: cover;
  border-radius: var(--r-xs); border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform .18s var(--ease);
}
.rec-imgs img:hover { transform: scale(1.04); }
.rec-del {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 15px;
  opacity: 0; transition: opacity .18s, color .18s, background .18s;
}
.rec:hover .rec-del, .rec:focus-within .rec-del { opacity: 1; }
.rec-del:hover { color: #C0392B; background: var(--bg-soft); }

.empty {
  text-align: center; padding: 32px 20px;
  color: var(--muted); font-size: 14.5px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r);
}
.empty b { display: block; font-size: 24px; margin-bottom: 8px; }

/* ============================================================
   日历
   ============================================================ */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head strong { font-size: 17px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lg-a { background: var(--user-a); }
.lg-b { background: var(--user-b); }

/* 7 列必须用 minmax(0, 1fr)：`1fr` 等价于 minmax(auto, 1fr)，轨道压不到小于内容的
   自动最小尺寸。而 .cal-day 带 aspect-ratio:1/1 + min-height:44px，会把每列顶到 44px
   下限 → 7×44 + 间隙 = 332px，比窄屏上的可用宽度还大，整条网格就溢出屏幕
   （表现就是「最右边周日那一列被切掉」）。改成 minmax(0, 1fr) 后列可以正常收缩。
   ⚠️ 表头 .cal-week 与格子 .cal-grid 共用这一条规则，千万别只改其中一个，否则错位。 */
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-week span { text-align: center; font-size: 12.5px; color: var(--muted); padding-bottom: 6px; }

.cal-day {
  position: relative;
  /* 宽度给成确定值（= 轨道宽），切断 aspect-ratio ← min-height 的反向传导：
     只写 aspect-ratio + min-height 时，浏览器会把 44px 的高度下限换算成 44px 的
     **宽度**下限，于是 7 列在小屏上合起来要 332px，整条网格溢出屏幕
     （就是「最右一列被切掉」那个 bug）。宽度确定后：宽屏仍是正方形，
     小屏上宽度可以正常收缩、高度保持 44px 的点按下限，变成窄高矩形。 */
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 44px;
  min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background: transparent; cursor: pointer;
  font-size: 15px; color: var(--text-2);
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .13s var(--ease);
}
.cal-day:hover { background: var(--bg-soft); }
.cal-day:active { transform: scale(.94); }
.cal-day.is-blank { visibility: hidden; pointer-events: none; }
.cal-day.is-other { color: var(--muted); opacity: .45; }
.cal-day.is-today { border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cal-day.is-selected { background: var(--accent-soft); }
.cal-day.is-has { background: var(--surface-2); color: var(--text); font-weight: 600; }
.cal-day.is-has.is-selected { background: var(--accent-soft); }
.cal-dots { display: flex; gap: 3px; height: 8px; align-items: center; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.cal-dots i[data-u="A"] { background: var(--user-a); }
.cal-dots i[data-u="B"] { background: var(--user-b); }
.cal-count { font-size: 10.5px; color: var(--muted); line-height: 1; }

/* ============================================================
   统计
   ============================================================ */

.quote {
  display: flex; gap: 12px; align-items: flex-start;
  background: linear-gradient(140deg, var(--accent-soft), var(--surface) 72%);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}
.quote-mark { font-size: 34px; line-height: .8; color: var(--accent); opacity: .5; font-family: Georgia, serif; }
.quote p { font-size: 15.5px; color: var(--accent-ink); font-weight: 600; }

.streak-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.streak {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.streak-who { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.streak-num { display: flex; align-items: baseline; gap: 5px; }
.streak-num b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.streak-num span { font-size: 13px; color: var(--muted); }
.streak-meta { font-size: 12.5px; color: var(--muted); }
.flame { display: inline-block; transform-origin: 50% 80%; }
.flame.lit { animation: flame 1.6s var(--ease) infinite; }
@keyframes flame {
  0%, 100% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.16) rotate(-5deg); }
  60% { transform: scale(1.04) rotate(4deg); }
}
.streak-num.bump b { animation: bump .6s var(--pop); }
@keyframes bump { 0% { transform: scale(.7); } 55% { transform: scale(1.18); } 100% { transform: none; } }

.rate-list { display: flex; flex-direction: column; gap: 2px; }
.rate-row {
  display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.rate-row:first-child { border-top: 0; }
.rate-name { display: block; font-size: 14px; font-weight: 600; }
.rate-name em { display: block; margin-top: 1px; font-style: normal; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.rate-bars { display: flex; flex-direction: column; gap: 7px; }
.rate-bar { display: flex; align-items: center; gap: 8px; }
.rate-bar .who { width: 16px; flex: none; font-size: 13px; line-height: 1; }
.rate-bar .track { flex: 1; height: 10px; border-radius: 100px; background: var(--bg-soft); overflow: hidden; }
.rate-bar .fill { display: block; height: 100%; border-radius: 100px; width: 0; transition: width .6s var(--ease); }
.rate-bar[data-u="A"] .fill { background: var(--user-a); }
.rate-bar[data-u="B"] .fill { background: var(--user-b); }
.rate-bar .pct {
  font-size: 12px; color: var(--muted); width: 34px; text-align: right;
  font-variant-numeric: tabular-nums; flex: none;
}

.week-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.week-col { display: flex; flex-direction: column; gap: 8px; }
.week-head { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.week-strip { display: flex; gap: 5px; }
.week-strip i {
  flex: 1; height: 36px; border-radius: 9px; background: var(--bg-soft);
  display: grid; place-items: center; font-size: 11px; color: var(--muted);
  transition: background .3s var(--ease), color .3s var(--ease), transform .3s var(--pop);
}
.week-strip i.on[data-u="A"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--user-a) 55%, transparent); }
.week-strip i.on[data-u="B"] { background: var(--user-b-soft); color: var(--user-b); font-weight: 700; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--user-b) 55%, transparent); }
.week-strip i.is-today { outline: 1.5px dashed var(--border-strong); outline-offset: 1px; }

/* ============================================================
   设置
   ============================================================ */

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13.5px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; min-height: 50px; padding: 0 14px;
  font-size: 16px;                      /* 同 textarea：避免 iOS 聚焦缩放整页 */
  background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.field input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* ============================================================
   移动底栏 / 提示 / 灯箱
   ============================================================ */

.tabbar {
  display: none;
  position: sticky; bottom: 0; z-index: 40;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-btn {
  min-height: 62px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: color .2s var(--ease), transform .12s var(--ease);
}
.tabbar-btn span { font-size: 21px; line-height: 1; }
.tabbar-btn:active { transform: scale(.94); }
.tabbar-btn.is-active { color: var(--accent-ink); }

@media (max-width: 700px) {
  .tabs { display: none; }
  .tabbar { display: grid; }
  .stage { padding: 16px 16px 28px; }
  .brand-text small { display: none; }
  .rec { grid-template-columns: 42px minmax(0, 1fr); padding: 14px; }
  .rec-avatar { width: 42px; height: 42px; font-size: 20px; border-radius: 14px; }
  /* 手机上本来就没有 hover，删除按钮常驻显示 */
  .rec-del { opacity: 1; }

  /* 打卡面板的两个按钮：让「添加图片」自适应、「保存打卡」吃掉剩余宽度，
     保证在 360px 的窄屏上也排成一行（挤成两行会让面板变长）。 */
  .composer-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; }
  .composer-actions .btn-primary { min-width: 0; }
  .upload-btn { padding: 0 14px; }
  .upload-btn span { font-size: 17px; }

  /* 科目完成率：窄屏下 116px 的科目名列会把右侧挤扁，改成上下堆叠 */
  .rate-row { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 0; }
  .rate-name { display: flex; align-items: baseline; gap: 8px; }
  .rate-name em { margin-top: 0; }

  /* 日历格子 + 圆点在小屏上会顶到边，稍微收一点 */
  .cal-day { font-size: 14.5px; }
  .cal-dots { height: 7px; }
  .cal-dots i { width: 5px; height: 5px; }
  .cal-grid, .cal-week { gap: 4px; }

  /* 日期副标题换行后，分隔用的圆点会孤零零留在行尾，窄屏直接去掉 */
  .daybar-sub .dot { display: none; }

  /* 底部提示条要避开底部导航 */
  .toast-wrap { bottom: calc(88px + env(safe-area-inset-bottom)); }
}

.toast-wrap {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 100px;
  background: var(--text); color: var(--bg);
  font-size: 14.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s var(--pop) both;
  max-width: min(92vw, 420px);
}
.toast.is-error { background: #B23B2C; color: #fff; }
.toast.is-out { animation: toastOut .24s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.96); } }

.lightbox {
  position: fixed; inset: 0; z-index: 130;
  display: grid; place-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(20, 15, 12, .88);
  backdrop-filter: blur(6px);
  animation: viewIn .2s var(--ease) both;
  cursor: zoom-out;                 /* 点空白处关闭 */
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  cursor: default;                  /* 点图片本身不关闭（以前会，导致「闪过就没了」） */
  animation: viewIn .24s var(--ease) both;
}
.lightbox-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .18s var(--ease), transform .14s var(--ease);
}
.lightbox-close:hover { background: rgba(255, 255, 255, .3); }
.lightbox-close:active { transform: scale(.92); }
.lightbox-hint {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, .62);
  pointer-events: none;             /* 不能挡住「点空白关闭」 */
}

/* 打卡成功星星 */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 140; }
.burst span {
  position: absolute;
  font-size: 18px;
  animation: burst 900ms var(--ease) forwards;
}
@keyframes burst {
  0%   { opacity: 0; transform: translate(0, 0) scale(.4) rotate(0); }
  22%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.15) rotate(var(--rot)); }
}

/* ============================================================
   确认弹窗
   ============================================================ */

.modal {
  position: fixed; inset: 0; z-index: 125;
  display: grid; place-items: center; padding: 24px;
  background: rgba(28, 20, 15, .42);
  backdrop-filter: blur(4px);
  animation: viewIn .18s var(--ease) both;
}
.modal-card {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: modalIn .3s var(--pop) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.95); } to { opacity: 1; transform: none; } }
.modal-card h3 { font-size: 17px; margin-bottom: 8px; }
.modal-card p { font-size: 14.5px; color: var(--text-2); line-height: 1.65; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

.btn-danger { background: #C0392B; color: #fff; box-shadow: 0 6px 18px -8px rgba(192, 57, 43, .7); }
.btn-danger:hover { background: #A93226; }

/* ============================================================
   无障碍：尊重系统「减弱动态效果」
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .burst { display: none !important; }
}

/* ============================================================
   一科多次打卡：面板里的「今天已打过的卡」列表
   ============================================================ */

.checkin-list {
  margin-bottom: 14px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkin-head {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: .02em;
}

.checkin-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
/* 正在改的那一条：高亮出来，避免改错 */
.checkin-item.is-editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkin-no {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.checkin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.checkin-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.checkin-title em {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.checkin-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.checkin-imgs { display: flex; flex-wrap: wrap; gap: 6px; }
.checkin-img { position: relative; display: block; }
.checkin-img img {
  width: 46px; height: 46px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.checkin-img-del {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(28, 22, 18, .72);
  color: #fff;
  font-size: 11px; line-height: 1;
  cursor: pointer;
}

.checkin-ops {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checkin-ops .btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }

/* 「正在修改某一条」的提示条 */
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
}
.edit-bar .btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }

/* ============================================================
   留言
   ============================================================ */

.cmts {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cmt-list { display: flex; flex-direction: column; gap: 7px; }

.cmt {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 13.5px;
  line-height: 1.55;
}
.cmt-emoji { flex: none; font-size: 14px; line-height: 1.4; }
.cmt-main { flex: 1; min-width: 0; color: var(--text-2); }
.cmt-main b { color: var(--text); font-weight: 700; margin-right: 5px; }
.cmt-text { word-break: break-word; }
.cmt-time { margin-left: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cmt-del {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.cmt-del:hover { background: var(--bg-soft); color: #C0392B; }

.cmt-form { display: flex; gap: 8px; align-items: center; }
.cmt-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  /* ≥16px：低于 16px 时 iOS 聚焦会把整页放大 */
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.cmt-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.cmt-input::placeholder { color: var(--muted); }
.cmt-send { flex: none; border-radius: 100px; }

/* 记录标题里的「打卡1、打卡2」标记 */
.rec-seq {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  .checkin-imgs img { width: 42px; height: 42px; }
  .cmt-form .btn-sm { min-height: 38px; padding: 0 12px; }
}

/* ============================================================
   超小屏（≤360px）：收紧外边距与网格间隙，给内容多争取一点宽度。
   典型机型：小屏安卓、iPhone SE 一代。主流机型（375px 以上）不受影响。
   ============================================================ */

@media (max-width: 360px) {
  .stage { padding: 14px 12px 26px; }
  .card.cal-card { padding: 14px; }
  .cal-grid, .cal-week { gap: 3px; }
}
