/* 每日计划 —— 撕纸便签
   顶部是照片封面，纸面用 mask 做手撕边缘，横线 / 颗粒 / 对角花纹都在纸内叠。
   花纹浓度调 --corner-alpha 就够，纸的高度靠内容自己撑。*/

:root {
  --paper: #fbfaf8;
  --paper-deep: #e9e8e4;
  --ink: #15100b;
  --ink-soft: #6f6a63;
  --ink-faint: #b4afa7;
  --rule: rgba(21, 16, 11, 0.07);
  --torn-h: 24px;
  --corner-alpha: 0.34;
  --serif: "Cormorant Garamond", "Didot", "Hoefler Text", Georgia, "Songti SC", "Times New Roman", serif;
  --hand: "Bradley Hand", "Snell Roundhand", "Kaiti SC", "STKaiti", "Yuanti SC", cursive;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}
/* --safe-top / --safe-bottom 来自 theme-tokens.css（带 standalone 兜底），这里不要重定义 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100%;
  overflow-x: hidden;
  background: #111110 url("assets/plan/cover.jpg") center / cover no-repeat fixed;
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.plan-page {
  position: relative;
  /* 必须用 100vh，不能用 100dvh（就是「诊断 D」暴露的那个坑）：
     iOS standalone + black-translucent 下 100dvh 报的是收起工具栏前的可视高度，
     纸面撑不到屏幕底，底部会露出 body 的深色 —— 也就是那条黑条，
     手动上滑触发一次 resize 后才补上。100vh 在同样环境下实测铺满整屏（诊断 C）。 */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶部封面 ---------- */

.plan-cover {
  position: relative;
  flex: 0 0 auto;
  height: clamp(132px, 21vh, 210px);
  overflow: hidden;
  background: #0e0d0c;
}
.plan-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  filter: grayscale(1) contrast(1.1) brightness(0.5);
}
.plan-cover-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.05) 45%, rgba(0, 0, 0, 0.35));
}

/* 封面上的浮动控件，跟纸面分开定位，纸滚动时它们不跟着走 */
.plan-cover-bar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 14px;
  right: 14px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.plan-chip {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(30, 28, 26, 0.42);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}
.plan-back {
  width: 38px;
  height: 38px;
  justify-content: center;
  padding: 0 2px 3px 0;
  color: #f4f2ee;
  font-size: 26px;
  line-height: 1;
  text-decoration: none;
}
.plan-cover-tools button {
  width: 40px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: #f4f2ee;
  cursor: pointer;
}
.plan-cover-tools svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.plan-cover-tools #plan-more svg { fill: currentColor; stroke: none; }
.plan-cover-tools button:active { opacity: 0.55; }

/* ---------- 纸面 ---------- */

.plan-paper {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  /* 花纹是负偏移贴在角上的，必须裁掉，否则整页会横向溢出 */
  overflow: hidden;
  touch-action: pan-y;
  margin-top: calc(var(--torn-h) * -1);
  padding-top: var(--torn-h);
  background:
    linear-gradient(180deg, var(--paper) 0%, #f7f5f2 42%, var(--paper-deep) 100%);
  /* 手撕上边缘：第一层是锯齿贴图，第二层补齐下面的实心区域 */
  -webkit-mask-image: url("assets/plan/torn-edge.svg"), linear-gradient(#000, #000);
  mask-image: url("assets/plan/torn-edge.svg"), linear-gradient(#000, #000);
  -webkit-mask-size: 400px var(--torn-h), 100% calc(100% - var(--torn-h) + 1px);
  mask-size: 400px var(--torn-h), 100% calc(100% - var(--torn-h) + 1px);
  -webkit-mask-position: left top, left var(--torn-h);
  mask-position: left top, left var(--torn-h);
  -webkit-mask-repeat: repeat-x, no-repeat;
  mask-repeat: repeat-x, no-repeat;
}

.paper-torn,
.paper-rules,
.paper-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 横线：从标题下方开始铺，左边留一条竖装订线 */
.paper-rules {
  top: calc(var(--torn-h) + 92px);
  background:
    repeating-linear-gradient(180deg, transparent 0 45px, var(--rule) 45px 46px);
}
.paper-rules::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 26px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(21, 16, 11, 0.09) 8%, rgba(21, 16, 11, 0.09) 92%, transparent);
}

/* 纸纹颗粒 */
.paper-grain {
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.16'/%3E%3C/svg%3E");
}

/* 对角花卉：左上 / 右下。浓度调 --corner-alpha，尺寸调 width */
.paper-corner {
  position: absolute;
  width: 58%;
  max-width: 300px;
  opacity: var(--corner-alpha);
  pointer-events: none;
  mix-blend-mode: multiply;
}
.paper-corner--tl {
  top: calc(var(--torn-h) - 22px);
  left: -16%;
  transform: rotate(-10deg);
  -webkit-mask-image: linear-gradient(150deg, #000 34%, transparent 88%);
  mask-image: linear-gradient(150deg, #000 34%, transparent 88%);
}
.paper-corner--br {
  right: -16%;
  bottom: -6%;
  transform: rotate(170deg);
  -webkit-mask-image: linear-gradient(150deg, #000 34%, transparent 88%);
  mask-image: linear-gradient(150deg, #000 34%, transparent 88%);
}

.paper-inner {
  position: relative;
  z-index: 1;
  padding: 26px 18px calc(44px + var(--safe-bottom));
  transition: transform 0.18s ease, opacity 0.18s ease;
}

/* 翻页：新的一页从滑动来的方向推入 */
.slide-in-right { animation: page-right 0.26s ease both; }
.slide-in-left { animation: page-left 0.26s ease both; }
@keyframes page-right { from { opacity: 0; transform: translateX(34px); } }
@keyframes page-left { from { opacity: 0; transform: translateX(-34px); } }

/* 历史日：纸压暗一点，暗示已归档（仍可补勾选） */
.plan-paper.is-past { filter: saturate(0.9) brightness(0.985); }

/* ---------- 翻页指示 ---------- */

.plan-navrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
  padding: 0 8px 12px;
}
.plan-dots { display: flex; align-items: center; gap: 6px; }
.plan-dots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(21, 16, 11, 0.2);
  transition: background 0.18s ease, transform 0.18s ease;
}
.plan-dots .dot--today { box-shadow: 0 0 0 1.5px rgba(21, 16, 11, 0.18); }
.plan-dots .dot.is-on { background: var(--ink); transform: scale(1.35); }
.plan-dots .dot--more {
  width: 12px;
  height: 1px;
  border-radius: 0;
  background: rgba(21, 16, 11, 0.18);
}
.plan-today-jump {
  border: 0;
  padding: 2px 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.plan-today-jump:active { opacity: 0.5; }

/* ---------- 标题 ---------- */

.paper-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 18px;
}
.paper-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: 0.2em;
  line-height: 1;
  white-space: nowrap;
}
.paper-head time {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---------- 新增一条 ---------- */

.task-add {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px 16px;
}
.task-input,
.task-time {
  height: 46px;
  border: 1px solid rgba(21, 16, 11, 0.16);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--sans);
  /* 不能低于 16px：iOS 聚焦 <16px 的输入框会强制放大整页 */
  font-size: 16px;
  color: var(--ink);
}
.task-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 14px;
  -webkit-appearance: none;
  appearance: none;
}
.task-input::placeholder { color: var(--ink-faint); }
.task-input:focus,
.task-time:focus-within {
  outline: none;
  border-color: rgba(21, 16, 11, 0.4);
  background: rgba(255, 255, 255, 0.85);
}

.task-time {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  min-width: 92px;
  padding: 0 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
/* 原生 time 控件铺满并透明，点哪都能唤起系统时间选择器 */
.task-time-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  opacity: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.task-plus {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  border: 1px solid rgba(21, 16, 11, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font-size: 26px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.task-plus:active { transform: scale(0.9); background: rgba(21, 16, 11, 0.07); }

/* ---------- 任务列表 ---------- */

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.task-item {
  display: grid;
  /* 四列：时间 / 正文 / 重要度 / 完成勾。列数必须和 plan.js 里 li.append 的孩子数一致，
     少一列的话最后那个「完成」按钮会被挤到第二行去。 */
  grid-template-columns: 62px minmax(0, 1fr) auto 27px;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 4px 4px 4px 8px;
  border-bottom: 1px solid rgba(21, 16, 11, 0.07);
  animation: task-in 0.28s ease both;
}
@keyframes task-in { from { opacity: 0; transform: translateY(-5px); } }

.task-item time {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.task-item p {
  margin: 0;
  min-width: 0;
  font-size: 16.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-item.is-open p { white-space: normal; overflow: visible; }

.task-check {
  justify-self: end;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.4px solid rgba(21, 16, 11, 0.28);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.task-check svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--paper);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.3, 1.5, 0.6, 1);
}
.task-item.is-done .task-check { background: var(--ink); border-color: var(--ink); }
.task-item.is-done .task-check svg { opacity: 1; transform: scale(1); }
.task-item.is-done time { opacity: 0.45; }
.task-item.is-done p { color: var(--ink-faint); text-decoration: line-through; text-decoration-thickness: 1px; }

.task-item.is-removing { animation: task-out 0.22s ease both; }
@keyframes task-out { to { opacity: 0; transform: translateX(-14px); height: 0; min-height: 0; padding: 0; border-width: 0; } }

.task-empty {
  margin: 18px 8px 0;
  font-family: var(--hand);
  font-size: 16px;
  color: var(--ink-faint);
}

/* ---------- TA 的签到 ---------- */

.checkin {
  margin: 40px 4px 0;
  padding: 2px 0 2px 16px;
  border-left: 1.5px solid rgba(21, 16, 11, 0.22);
}
.checkin-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
}
.checkin-body {
  margin: 8px 0 0;
  font-family: var(--hand);
  font-size: 17.5px;
  line-height: 1.5;
}
.checkin-body b { font-weight: 400; font-variant-numeric: tabular-nums; }
.checkin-body.is-pending { color: var(--ink-faint); }
.checkin-body.is-pending::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1s steps(2, start) infinite;
  vertical-align: middle;
}
@keyframes blink { 50% { opacity: 0.15; } }

.checkin-retry {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.checkin-retry:active { opacity: 0.5; }

/* ---------- 提示条 ---------- */

.plan-toast {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: calc(26px + var(--safe-bottom));
  transform: translate(-50%, 8px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(20, 18, 16, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f6f4f0;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.plan-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

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

/* 催进度：默认只是任务列表左下角的一枚小胶囊，点开才长出设置 */
.plan-nudge { margin: 2px 4px 4px; }
.plan-nudge-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid rgba(21, 16, 11, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}
.plan-nudge-toggle b { font-weight: 500; color: var(--ink); }
.plan-nudge-toggle i {
  width: 0;
  height: 0;
  border-top: 4px solid currentColor;
  border-right: 3.5px solid transparent;
  border-left: 3.5px solid transparent;
  opacity: 0.5;
  transition: transform 0.15s ease;
}
.plan-nudge-toggle.is-open i { transform: rotate(180deg); }
.plan-nudge-body {
  margin-top: 9px;
  padding: 11px 13px;
  border: 1px solid rgba(21, 16, 11, 0.1);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.42);
}
.plan-nudge-body[hidden] { display: none; }
.plan-nudge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}
.plan-nudge-row + .plan-nudge-row { margin-top: 8px; }
.plan-nudge-row[hidden] { display: none; }
.plan-nudge-row span { flex: none; font-family: var(--sans); font-size: 13px; color: var(--ink-soft); }
.plan-nudge-row select,
.plan-nudge-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(21, 16, 11, 0.14);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
  font-family: var(--sans);
  /* 同样不能低于 16px，iOS 聚焦会放大整页 */
  font-size: 16px;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.plan-nudge-hint { margin: 9px 0 0; font-family: var(--sans); font-size: 11px; line-height: 1.6; color: var(--ink-faint); }

/* 任务上的重要度标签 */
.task-weight {
  flex: none;
  height: 21px;
  padding: 0 8px;
  white-space: nowrap;
  border: 1px solid rgba(21, 16, 11, 0.14);
  border-radius: 999px;
  background: transparent;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.task-weight.is-high { border-color: rgba(21, 16, 11, 0.5); color: var(--ink); }
.task-weight.is-low { opacity: 0.55; }
.task-item.is-done .task-weight { opacity: 0.35; }

/* ---------- 导入课表弹窗 ---------- */

#import-schedule-dialog {
  width: min(340px, calc(100vw - 40px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25);
}
#import-schedule-dialog::backdrop { background: rgba(0, 0, 0, 0.33); }
.import-schedule-form {
  display: grid;
  gap: 10px;
  padding: 20px;
  background: var(--paper);
}
.import-schedule-form h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink);
}
.import-schedule-form p {
  margin: 0 0 4px;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.import-schedule-form textarea {
  width: 100%;
  border: 1px solid rgba(21, 16, 11, 0.16);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}
.import-weeks-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
}
.import-weeks-row input {
  width: 72px;
  height: 32px;
  border: 1px solid rgba(21, 16, 11, 0.16);
  border-radius: 6px;
  padding: 0 8px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}
.import-weeks-row select {
  height: 32px;
  border: 1px solid rgba(21, 16, 11, 0.16);
  border-radius: 6px;
  padding: 0 6px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}
.import-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
}
.import-file-row input[type="file"] {
  max-width: 62%;
  font-size: 12px;
  color: var(--ink-soft);
}
.import-file-hint {
  margin: -4px 0 0;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-3, var(--ink-soft));
}
.import-schedule-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.import-schedule-actions button {
  flex: 1;
  height: 40px;
  border: 1px solid rgba(21, 16, 11, 0.16);
  border-radius: 8px;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
#import-schedule-confirm {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
