/* ============================================================
   ToBe — 样式 v0.5「liquid glass」
   优先级配色：p1 绿 → p2 蓝 → p3 紫 → p4 金(金属) → p5 红 → p6 黑 → p7 隐藏彩色
   性能约定：backdrop-filter 只用在少数大块，动画只用 transform/opacity
   注意：要兼顾 DarkReader 暗色模式的观感（避免只靠纯黑/纯白传达信息）
   ============================================================ */

:root {
  --text: #1f2328;
  --text-dim: #a0a6ad;
  --cell-bg: rgba(255, 255, 255, .55);
  --cell-other: rgba(255, 255, 255, .28);
  --radius-cell: 10px;
  --radius-window: 26px;

  --p1: #3fb950;
  --p2: #4493f8;
  --p3: #ab7df8;
  --p4: #e3b341;
  /* 金属质感的金：高光→深金→暗铜→反光 */
  --p4grad: linear-gradient(135deg, #f8e08e 0%, #e3b341 30%, #b8860b 55%, #f0d06a 75%, #d4a72c 100%);
  --p5: #f85149;
  --p6: #1f2328;
  --holo: linear-gradient(90deg, #f85149, #e3b341, #3fb950, #4493f8, #ab7df8, #f85149);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 12% 8%,  rgba(68, 147, 248, .18), transparent 60%),
    radial-gradient(800px 700px at 88% 90%, rgba(63, 185, 80, .16), transparent 60%),
    radial-gradient(700px 500px at 75% 15%, rgba(171, 125, 248, .12), transparent 60%),
    linear-gradient(135deg, #eef1f6, #e9edf3);
}

.hidden { display: none !important; }

/* ============================================================
   页面堆 + 玻璃窗
   ============================================================ */
#pages { height: 100vh; transition: transform .65s cubic-bezier(.22, .8, .26, 1); }
.page  { height: 100vh; padding: 16px 68px 16px 16px; }
@supports (height: 100dvh) {
  #pages { height: 100dvh; }
  .page  { height: 100dvh; }
}

.window {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  border-radius: var(--radius-window);
  background: rgba(255, 255, 255, .52);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, .65);
  box-shadow: 0 24px 70px rgba(31, 35, 40, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
  overflow: hidden;
}
@supports not (backdrop-filter: blur(1px)) {
  .window { background: rgba(255, 255, 255, .92); }
}

.win-head { display: flex; align-items: center; gap: 20px; padding: 16px 24px 10px; flex: none; }
.brand {
  font-weight: 700; font-size: 15px; letter-spacing: 1px;
  color: #fff; background: var(--p6);
  border-radius: 9px; padding: 4px 11px;
  box-shadow: 0 4px 14px rgba(31, 35, 40, .25);
}
.win-head h1 { font-size: 25px; font-weight: 650; flex: 1; }

.controls { display: flex; align-items: center; gap: 8px; }
.view-switch {
  display: flex;
  background: rgba(255, 255, 255, .45);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px; padding: 3px;
}
.view-switch button {
  border: none; background: transparent;
  padding: 5px 14px; border-radius: 999px;
  font-size: 14px; cursor: pointer; color: var(--text);
  transition: background .15s;
}
.view-switch button.active { background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); font-weight: 600; }
.nav-btn {
  border: 1px solid rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .45);
  border-radius: 999px; padding: 6px 14px;
  font-size: 13px; cursor: pointer; color: var(--text);
}
.nav-btn:hover, .view-switch button:hover { background: rgba(255, 255, 255, .85); }
.today-btn { font-weight: 600; }
#btn-up { display: none; font-weight: 600; }

/* ============================================================
   日历容器 + 键盘选择框
   ============================================================ */
.cal-wrap { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
#calendar { flex: 1; display: flex; flex-direction: column; padding: 0 24px 20px; min-height: 0; overflow: hidden; }

#kb-frame {
  position: absolute; z-index: 6; pointer-events: none;
  border: 2.5px solid var(--p6); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(31, 35, 40, .22);
  transition: left .15s ease, top .15s ease, width .15s ease, height .15s ease;
}

/* ============================================================
   月视图
   ============================================================ */
.weekday-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 6px 0; flex: none; }
.weekday-row div { font-weight: 600; font-size: 13px; color: var(--text-dim); padding-left: 10px; }

.month-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; min-height: 0; }

.day-cell {
  background: var(--cell-bg);
  border-radius: var(--radius-cell);
  padding: 7px 9px;
  display: flex; flex-direction: column;
  overflow: hidden; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .55);
  transition: transform .15s, box-shadow .15s;
  min-height: 0;
}
.day-cell:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(31, 35, 40, .14); }
.day-cell.other-month { background: var(--cell-other); }
.day-cell.other-month .day-num { color: var(--text-dim); }
.day-num { font-size: 14px; font-weight: 600; line-height: 24px; flex: none; display: flex; align-items: center; gap: 5px; }
/* 「今天」= 苹果日历式实心红圈，全站唯一标注方式 */
.day-cell.today .day-num span:first-child {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--p5); color: #fff;
}
.day-icons { font-size: 11px; letter-spacing: 1px; }

.bars { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.bar { height: 6px; border-radius: 4px; flex: none; }
.bar.p1 { background: var(--p1); } .bar.p2 { background: var(--p2); }
.bar.p3 { background: var(--p3); } .bar.p4 { background: var(--p4grad); }
.bar.p5 { background: var(--p5); } .bar.p6 { background: var(--p6); }
.bar.p7 { background: var(--holo); background-size: 300% 100%; animation: holo 3s linear infinite; }
.bar.echo { opacity: .38; }
.bar-more { font-size: 10px; color: var(--text-dim); line-height: 1; }
@keyframes holo { to { background-position: 300% 0; } }

/* 悬停弹窗（从格子长出来的展开动画在 JS 里做） */
#day-pop {
  position: fixed; z-index: 40;
  padding: 11px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 24px 60px rgba(31, 35, 40, .28);
  display: flex; flex-direction: column; gap: 5px;
  cursor: pointer;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.pop-date { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.pop-more {
  border: none; cursor: pointer;
  width: 28px; height: 22px; border-radius: 999px;
  background: rgba(31, 35, 40, .08); color: var(--text);
  font-size: 12px; line-height: 1;
}
.pop-more:hover { background: var(--p6); color: #fff; }

/* ---------- 文字条 chip ---------- */
.chip {
  font-size: 12px; line-height: 1.4;
  padding: 3px 9px; border-radius: 7px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: none;
}
.chip.p1 { background: var(--p1); } .chip.p2 { background: var(--p2); }
.chip.p3 { background: var(--p3); } .chip.p4 { background: var(--p4grad); color: #4a3b00; }
.chip.p5 { background: var(--p5); } .chip.p6 { background: var(--p6); }
.chip.p7 { background: var(--holo); background-size: 300% 100%; animation: holo 3s linear infinite; }
.chip.deadline { border: 1.5px dashed rgba(255, 255, 255, .85); }
.chip.deadline.p4 { border-color: rgba(74, 59, 0, .6); }
.chip.echo { opacity: .6; background: rgba(255, 255, 255, .35); border: 1.5px solid currentColor; }
.chip.echo.p1 { color: var(--p1); } .chip.echo.p2 { color: var(--p2); }
.chip.echo.p3 { color: var(--p3); } .chip.echo.p4 { color: #b8860b; }
.chip.echo.p5 { color: var(--p5); } .chip.echo.p6 { color: var(--p6); }
.chip.echo.p7 { color: var(--p3); }

/* ============================================================
   年视图
   ============================================================ */
.year-grid {
  flex: 1; display: grid;
  grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 14px; min-height: 0;
}
.mini-month {
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: var(--radius-cell);
  padding: 10px 12px; cursor: pointer;
  display: flex; flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, background .18s;
}
.mini-month:hover {
  transform: scale(1.055);
  box-shadow: 0 22px 50px rgba(31, 35, 40, .22);
  background: rgba(255, 255, 255, .88);
  position: relative; z-index: 3;
}
.mini-month h3 { font-size: 14px; margin-bottom: 6px; }
.mini-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; flex: 1; }

/* 每格预留框位：透明边框（悬停细条的范围在框内）；今天不在年视图圈天，
   而是当前月的月份数字变红（苹果日历式，见 .mini-month.current） */
.mini-day {
  border-radius: 4px; min-height: 11px;
  border: 1.6px solid transparent;
  padding: 1px;
  background: rgba(255, 255, 255, .55);
  background-clip: padding-box;
  display: flex; overflow: hidden;
}
.mini-day.empty { background: transparent; }
.mini-month.current h3 {
  color: #fff; background: var(--p5);
  width: fit-content; padding: 0 9px; border-radius: 999px;
}
.mini-day.has-p1 { background: var(--p1); background-clip: padding-box; }
.mini-day.has-p2 { background: var(--p2); background-clip: padding-box; }
.mini-day.has-p3 { background: var(--p3); background-clip: padding-box; }
.mini-day.has-p4 { background: var(--p4grad); background-clip: padding-box; }
.mini-day.has-p5 { background: var(--p5); background-clip: padding-box; }
.mini-day.has-p6 { background: var(--p6); background-clip: padding-box; }
.mini-day.has-p7 { background: var(--holo); background-clip: padding-box; }

/* 往届回声（repeat 投影到未来年份）：整格半透明，与月视图 echo 条一致 */
.mini-day.echo { opacity: .42; }
.mini-month:hover .mini-day.echo { opacity: 1; }   /* 悬停时格子退底色，透明度交给细条 */
.bars-mini b.echo { opacity: .38; }

/* 悬停：显示竖着堆叠的细条（顶部对齐），色块退成底色 */
.bars-mini { display: none; flex-direction: column; justify-content: flex-start; gap: 1px; width: 100%; }
.bars-mini b { display: block; height: 2.5px; border-radius: 2px; }
.bars-mini b.p1 { background: var(--p1); } .bars-mini b.p2 { background: var(--p2); }
.bars-mini b.p3 { background: var(--p3); } .bars-mini b.p4 { background: var(--p4grad); }
.bars-mini b.p5 { background: var(--p5); } .bars-mini b.p6 { background: var(--p6); }
.bars-mini b.p7 { background: var(--holo); }
.mini-month:hover .bars-mini { display: flex; }
.mini-month:hover .mini-day[class*="has-p"] { background: rgba(31, 35, 40, .07); background-clip: padding-box; }

/* ============================================================
   周视图（桌面两周）+ 左侧习惯打卡栏
   ============================================================ */
.week-wrap { flex: 1; display: grid; grid-template-columns: 270px 1fr; gap: 14px; min-height: 0; }

.habit-side { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.habit-side-title { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--text-dim); padding: 2px 2px 0; }
.habit-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 22px; border-radius: 14px;
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .6);
  flex: none;
}
.habit-hit {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  border: 2px solid rgba(31, 35, 40, .25);
  background: rgba(255, 255, 255, .7);
  font-size: 16px; cursor: pointer;
  transition: transform .12s, border-color .15s, background .15s;
}
.habit-hit:hover { transform: scale(1.1); }
.habit-hit:active { transform: scale(.92); }
.habit-hit.reached { border-color: var(--p1); background: rgba(63, 185, 80, .18); }
.habit-info { flex: 1; min-width: 0; }
.habit-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.habit-cad { font-size: 11px; color: var(--text-dim); }
.habit-combo {
  border: none; cursor: pointer; flex: none;
  padding: 4px 10px; border-radius: 999px;
  background: var(--p6); color: #fff;
  font-size: 13px; font-weight: 700;
  transition: transform .12s;
}
.habit-combo:hover { transform: scale(1.08); }
.habit-combo.zero { background: rgba(31, 35, 40, .12); color: var(--text-dim); }

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; min-height: 0; }
.week-grid.two { grid-template-rows: repeat(2, 1fr); }
.week-col {
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: var(--radius-cell);
  padding: 10px; display: flex; flex-direction: column; gap: 4px;
  overflow: hidden; cursor: pointer;
  min-height: 0;
}
.week-col .col-head { font-weight: 600; font-size: 14px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.week-col .col-head small { color: var(--text-dim); font-weight: 400; }
.week-col .col-head small.today-num {
  color: #fff; background: var(--p5); font-weight: 600;
  border-radius: 999px; padding: 1px 8px;
}

/* ============================================================
   日视图
   ============================================================ */
.day-view { flex: 1; display: flex; flex-direction: column; min-height: 0; padding-top: 6px; }
.day-cols { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; min-height: 0; }

.day-timeline {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  border-radius: 12px;
  background: rgba(255, 255, 255, .35);
  border: 1px solid rgba(255, 255, 255, .55);
}
.day-timeline .hour {
  flex: 1; min-height: 0;
  border-top: 1px solid rgba(31, 35, 40, .07);
  font-size: 10px; color: var(--text-dim);
  padding-left: 6px;
}
.day-timeline .hour:first-child { border-top: none; }
.day-timeline .timed { position: absolute; inset: 0 8px 0 52px; }
.timed-item { position: absolute; left: 0; right: 0; display: flex; }
.timed-item .chip { box-shadow: 0 6px 18px rgba(31, 35, 40, .18); }

.day-list { overflow-y: auto; min-height: 0; }
.day-item {
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: var(--radius-cell);
  padding: 12px 16px 12px 24px; margin-bottom: 10px;
}
.day-item .path { font-size: 12px; color: var(--text-dim); margin-bottom: 2px; }
.day-item .title { font-weight: 600; }
.day-item .note { font-size: 13px; color: #57606a; margin-top: 4px; white-space: pre-wrap; }
.day-empty { color: var(--text-dim); text-align: center; margin-top: 60px; font-size: 15px; }

.day-ongoing {
  flex: none; margin-top: 12px;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .22));
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85), 0 10px 30px rgba(31, 35, 40, .10);
  overflow-x: auto; white-space: nowrap;
}
.ongoing-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--text-dim); flex: none; }

/* ---------- 黑色 p6 = 碳纤维纹理（比金色更高级的顶级档） ---------- */
.chip.p6, .bar.p6, .bars-mini b.p6, .mini-day.has-p6 {
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .08) 75%),
    linear-gradient(-45deg, rgba(255, 255, 255, .08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .08) 75%),
    linear-gradient(180deg, #23272d, #16191d);
  background-size: 5px 5px, 5px 5px, auto;
  background-clip: padding-box;
}

/* ============================================================
   清单页（左侧微软 To Do 式分类栏 + 右侧列表）
   ============================================================ */
#todo { flex: 1; min-height: 0; padding: 4px 24px 20px; overflow: hidden; }
.todo-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 18px; height: 100%; min-height: 0; }
.todo-side { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 2px 0; }
.todo-cat {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: none; background: transparent;
  padding: 9px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  cursor: pointer; text-align: left; flex: none;
}
.todo-cat:hover { background: rgba(31, 35, 40, .06); }
.todo-cat.active { background: rgba(255, 255, 255, .85); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.todo-cat span { font-size: 11px; color: var(--text-dim); }
.todo-main { overflow-y: auto; min-height: 0; padding-right: 6px; }
.todo-group { margin-bottom: 20px; max-width: 920px; }
.todo-path { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.todo-row {
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 10px;
  padding: 9px 14px 9px 24px; margin-bottom: 6px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.todo-row.done { opacity: .45; }
.todo-row.done .todo-title { text-decoration: line-through; }

/* ---------- 优先级色条：内嵌胶囊（框内、两端圆弧、弧度贴合卡片圆角） ---------- */
.day-item, .todo-row, .habit-card { position: relative; }
.day-item::before, .todo-row::before, .habit-card::before {
  content: ''; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 5px;
  border-radius: 999px; background: var(--p1);
}
.day-item.p2::before, .todo-row.p2::before, .habit-card.p2::before { background: var(--p2); }
.day-item.p3::before, .todo-row.p3::before, .habit-card.p3::before { background: var(--p3); }
.day-item.p4::before, .todo-row.p4::before, .habit-card.p4::before { background: var(--p4grad); }
.day-item.p5::before, .todo-row.p5::before, .habit-card.p5::before { background: var(--p5); }
.day-item.p6::before, .todo-row.p6::before, .habit-card.p6::before { background: var(--p6); }
.day-item.p7::before, .todo-row.p7::before, .habit-card.p7::before {
  background: var(--holo); background-size: 100% 300%;
}
.todo-row.hole::before { background: #c9cdd2; }
.todo-mark { font-weight: 700; min-width: 16px; text-align: center; flex: none; }
.todo-check { cursor: pointer; transition: transform .12s; }
.todo-check:hover { transform: scale(1.3); }
.todo-title { font-weight: 600; font-size: 14px; }
.todo-meta { font-size: 11px; color: var(--text-dim); }
.todo-note { flex-basis: 100%; font-size: 12.5px; color: #57606a; padding-left: 26px; white-space: pre-wrap; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: rgba(31, 35, 40, .08); flex: none; }
.badge.habit { background: var(--p2); color: #fff; }
.badge.deadline.urgent { background: var(--p5); color: #fff; }

/* ============================================================
   右侧导航栏（桌面端）
   ============================================================ */
#rail {
  position: fixed; right: 0; top: 0; bottom: 0; width: 68px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; z-index: 30;
}
.rail-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .8);
  box-shadow: 0 8px 24px rgba(31, 35, 40, .16);
  font-size: 13px; cursor: pointer; color: var(--text);
  opacity: 0; transform: scale(.8);
  transition: opacity .2s, transform .2s;
}
#rail:hover .rail-btn { opacity: 1; transform: scale(1); }
.rail-btn:hover { background: #fff; }

.dots { display: flex; flex-direction: column; gap: 14px; align-items: center; }
/* 圆点 = 固定尺寸槽位：active 在 ::before 里原地长高，切页时邻居不再被挤动 */
.dot {
  width: 14px; height: 30px;
  position: relative; cursor: pointer;
}
.dot::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); box-sizing: border-box;
  width: 12px; height: 12px; border-radius: 999px;
  border: 2px solid var(--p6); background: transparent;
  transition: height .25s ease, background .25s, opacity .18s ease;
}
.dot.active::before { height: 30px; background: var(--p6); }
/* 悬浮导航栏：点「长」成液态玻璃文字胶囊 —— 同一位置，右缘锚定向左生长，圆点同步淡出 */
#rail:hover .dot::before { opacity: 0; }
.dot-label {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  white-space: nowrap; overflow: hidden;
  font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1;
  padding: 8px 0; border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0);
  max-width: 12px; opacity: 0; pointer-events: none;
  transition: max-width .32s cubic-bezier(.3, .9, .3, 1), opacity .18s ease,
              padding .32s cubic-bezier(.3, .9, .3, 1);
}
#rail:hover .dot-label {
  max-width: 160px; opacity: 1; padding: 8px 16px;
  border-color: rgba(255, 255, 255, .7);
  box-shadow: 0 10px 30px rgba(31, 35, 40, .18);
  pointer-events: auto;
}
.dot.active .dot-label { background: var(--p6); color: #fff; }

/* ============================================================
   中英切换（桌面竖排：中上 EN下）
   ============================================================ */
#lang-toggle {
  position: fixed; right: 15px; top: 18px; z-index: 30;
  display: flex; flex-direction: column-reverse;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 999px; padding: 3px;
  box-shadow: 0 8px 24px rgba(31, 35, 40, .12);
}
#lang-toggle button {
  border: none; background: transparent;
  width: 34px; height: 30px; border-radius: 999px;
  font-size: 12px; cursor: pointer; color: var(--text);
}
#lang-toggle button.active { background: var(--p6); color: #fff; font-weight: 600; }

/* ============================================================
   手机端右下角菜单（两道杠 ⇄ X，菜单从按钮长出来）+ 左下「今天」
   ============================================================ */
#btn-menu {
  display: none;
  position: fixed; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 46;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(31, 35, 40, .2);
  cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
#btn-menu .mline {
  display: block; width: 17px; height: 2.2px;
  background: var(--text); border-radius: 2px;
  transition: transform .25s ease;
}
#btn-menu.open .mline:nth-child(1) { transform: translateY(3.6px) rotate(45deg); }
#btn-menu.open .mline:nth-child(2) { transform: translateY(-3.6px) rotate(-45deg); }

#page-menu {
  position: fixed; right: 14px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); z-index: 45;
  display: none; flex-direction: column; gap: 4px;
  padding: 6px; border-radius: 16px;
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 14px 40px rgba(31, 35, 40, .22);
  transform-origin: bottom right;
  transform: translateY(12px) scale(.25);
  opacity: 0; pointer-events: none;
  transition: transform .26s cubic-bezier(.3,.9,.3,1.1), opacity .2s;
}
#page-menu.open { transform: none; opacity: 1; pointer-events: auto; }
#page-menu button {
  border: none; background: transparent;
  padding: 9px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
#page-menu button:hover { background: rgba(31, 35, 40, .08); }
#menu-lang { border-top: 1px solid rgba(31, 35, 40, .1) !important; }

#btn-today-float {
  display: none;
  position: fixed; left: 14px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 45;
  padding: 11px 18px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .7);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(31, 35, 40, .2);
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
#btn-today-float.off { display: none !important; }   /* 只在日历页显示 */

/* ============================================================
   侧板 & 加载错误
   ============================================================ */
#day-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-left: 1px solid rgba(255, 255, 255, .7);
  box-shadow: -12px 0 40px rgba(31, 35, 40, .18);
  padding: 18px 20px; overflow-y: auto; z-index: 35;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { font-size: 18px; }
#panel-close { border: none; background: none; font-size: 26px; cursor: pointer; color: var(--text-dim); line-height: 1; }

#load-error {
  position: fixed; inset: 0; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; font-size: 16px; z-index: 50; text-align: center; padding: 20px;
}

/* ============================================================
   DarkReader 对策：给色块加一圈半透明深色描边——
   浅色模式下低调不违和；DarkReader 会把深色反转成浅色，
   描边就变成浅色轮廓，和暗背景形成对比（手机深色模式不受影响）
   ============================================================ */
.bar, .chip { border: 1px solid rgba(31, 35, 40, .28); }
.mini-day[class*="has-p"] { border-color: rgba(31, 35, 40, .28); }

/* ============================================================
   提高页（Y1 提分中心）
   语义色沿用优先级体系：不及格/未达标=红 p5，通过/达标=绿 p1，超越=金 p4
   ============================================================ */
#improve { flex: 1; min-height: 0; padding: 4px 24px 20px; overflow-y: auto; }
.improve-wrap { max-width: 1100px; }
.imp-section { margin-bottom: 32px; }
.imp-sec-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.imp-piece { font-size: 12.5px; color: var(--text-dim); margin-bottom: 10px; }

/* ---- 成绩总览卡片 ---- */
.imp-mods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.imp-mod {
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: var(--radius-cell);
  padding: 10px 14px 12px 24px; position: relative;
}
.imp-mod::before {
  content: ''; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 5px;
  border-radius: 999px; background: var(--p1);
}
.imp-mod.bad::before { background: var(--p5); }
.imp-mod-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.imp-code { font-weight: 700; font-size: 13px; }
.imp-mname { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.imp-cred { font-size: 11px; color: var(--text-dim); flex: none; }
.imp-mark { font-size: 19px; font-weight: 700; flex: none; }
.imp-mod.bad .imp-mark { color: var(--p5); }
.imp-mod.ok .imp-mark { color: var(--p1); }
.imp-res { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: rgba(31, 35, 40, .08); flex: none; }
.imp-mod.bad .imp-res { background: var(--p5); color: #fff; }
.imp-parts { font-size: 12px; color: #57606a; margin-top: 4px; }
.imp-minibar { position: relative; height: 6px; border-radius: 4px; background: rgba(31, 35, 40, .08); margin-top: 8px; }
.imp-minibar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--p1); }
.imp-mod.bad .imp-minibar i { background: var(--p5); }
.imp-minibar u, .imp-simbar u {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--p6); text-decoration: none;
}

.imp-note { font-size: 12.5px; color: #57606a; margin-top: 10px; line-height: 1.6; white-space: pre-wrap; }
.imp-hint {
  font-size: 13px; font-weight: 600; margin-top: 10px; line-height: 1.55;
  padding: 9px 14px; border-radius: 10px;
  background: rgba(227, 179, 65, .16); border: 1px solid rgba(227, 179, 65, .45);
}
.imp-bandnote { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; }

/* ---- 模拟总分条 ---- */
.imp-sim {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-radius: 14px;
  background: var(--cell-bg); border: 1px solid rgba(255, 255, 255, .6);
}
.imp-cur { font-size: 22px; font-weight: 700; flex: none; }
.imp-cur small { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.imp-simbar { position: relative; flex: 1; height: 10px; border-radius: 6px; background: rgba(31, 35, 40, .08); }
.imp-simbar .base { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 6px 0 0 6px; background: var(--p5); }
.imp-simbar .extra { position: absolute; top: 0; bottom: 0; background: var(--p1); }
.imp-simres { font-size: 13px; flex: none; }
.imp-sim.ok .imp-simres b { color: var(--p1); }
.imp-sim.bad .imp-simres b { color: var(--p5); }

/* ---- 评分项行 ---- */
.imp-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.imp-row {
  background: var(--cell-bg);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 12px;
  padding: 10px 14px 10px 24px; position: relative;
}
.imp-row::before {
  content: ''; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 5px;
  border-radius: 999px; background: var(--p5);
}
.imp-row.meets::before { background: var(--p1); }
.imp-row.exceeds::before { background: var(--p4grad); }
.imp-row-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.imp-ac { font-weight: 700; font-size: 12px; background: rgba(31, 35, 40, .08); border-radius: 6px; padding: 2px 7px; flex: none; }
.imp-name { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 180px; }
.imp-band { font-size: 11px; padding: 2px 9px; border-radius: 999px; color: #fff; background: var(--p5); flex: none; }
.imp-band.meets { background: var(--p1); }
.imp-band.exceeds { background: var(--p4grad); color: #4a3b00; }
.imp-score { font-size: 15px; flex: none; }
.imp-score small { color: var(--text-dim); }
.imp-targets {
  display: flex; gap: 4px; flex: none;
  background: rgba(255, 255, 255, .45);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 999px; padding: 3px;
}
.imp-targets button {
  border: none; background: transparent; border-radius: 999px;
  padding: 3px 10px; font-size: 11.5px; cursor: pointer; color: var(--text);
}
.imp-targets button:hover { background: rgba(255, 255, 255, .85); }
.imp-targets button.on { background: #fff; font-weight: 700; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.imp-gain { min-width: 52px; text-align: right; font-weight: 700; color: var(--p1); font-size: 13px; flex: none; }
.imp-why, .imp-fix { font-size: 12.5px; color: #57606a; margin-top: 6px; line-height: 1.55; }
.imp-why b, .imp-fix b { color: var(--text); font-weight: 700; margin-right: 4px; }

/* ============================================================
   手机端（≤820px）
   ============================================================ */
@media (max-width: 820px) {
  .page { padding: 0; }
  .window { border-radius: 0; border: none; }
  #rail { display: none; }
  #lang-toggle { display: none; }          /* 语言切换收进右下菜单 */

  .win-head { padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 8px; gap: 10px; flex-wrap: wrap; }
  .win-head h1 { font-size: 16px; line-height: 1.3; min-width: 0; }
  .brand { display: none; }                /* 手机端不放 ToBe 标志 */
  .controls { gap: 5px; flex-wrap: wrap; }
  .view-switch button { padding: 4px 10px; font-size: 13px; }
  .view-switch button[data-view="week"] { display: none; }
  #btn-today { display: none; }            /* 「今天」挪到左下角悬浮 */
  #btn-up { display: inline-block; }

  #calendar { padding: 0 10px 12px; }
  .day-num { font-size: 12px; line-height: 20px; }
  .day-cell.today .day-num span:first-child { width: 20px; height: 20px; }
  .day-cell { padding: 4px 5px; }
  .day-icons { font-size: 9px; }

  .year-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(6, 1fr); gap: 8px; }
  .mini-month { padding: 7px 8px; }

  /* 日视图和桌面端一样左右分栏：左 24h 时间轴，右当天待办 */
  .day-cols { grid-template-columns: 2fr 3fr; gap: 8px; }
  .day-view { padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

  #todo { padding: 4px 14px 0; }
  .todo-wrap { grid-template-columns: 1fr; }
  .todo-side { display: none; }              /* 分类栏是桌面端的 */
  .todo-main { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }

  #improve { padding: 4px 14px calc(90px + env(safe-area-inset-bottom, 0px)); }
  .imp-mods { grid-template-columns: 1fr; }
  .imp-sim { flex-wrap: wrap; gap: 8px; }
  .imp-simbar { flex-basis: 100%; order: 3; }
  .imp-name { min-width: 120px; }
  .imp-gain { min-width: 0; }

  #day-pop { max-width: calc(100vw - 20px); }
  #day-panel { width: 100%; }

  #btn-menu { display: flex; }
  #page-menu { display: flex; }
  #btn-today-float { display: block; }
}
