/* 📅 日历 / 日程面板（js/schedule.js）
 *
 * 颜色只从 style.css 的设计令牌里取（夜空紫底 + 金色点缀），这里不另起一套底色。
 * 弹出来的几层（抽屉 / 范围选择 / 提示条）跟 .modal、.toast 用同一套梅紫渐变，
 * 别再写 #171432 这类偏蓝的实色 —— 那是日历第一版跑偏的地方。
 * 主要场合是 iOS PWA：点按区域不小于 44px，输入框 16px，底部让出安全区。
 */

#schedule-panel {
  /* 弹层表面：和 .modal 同一组色相（48,32,72 → 30,22,50），只是更实，不靠毛玻璃（iOS 上滚动会卡） */
  --sched-sheet: linear-gradient(160deg, rgba(58, 39, 88, 0.98) 0%, rgba(30, 22, 50, 0.99) 100%);
  --sched-sheet-solid: rgb(36, 26, 58);
  --sched-scrim: rgba(14, 13, 31, 0.62);
  --sched-gold: rgb(255, 224, 150);
  --sched-gold-tint: rgba(255, 224, 150, 0.14);
  --sched-rose: #ff9db8;
  --sched-rose-tint: rgba(255, 143, 177, 0.12);
  --sched-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

#schedule-panel [hidden] {
  display: none !important;
}

/* ── 顶栏 ── */
.sched-header {
  gap: 4px;
  padding-left: 10px;
  padding-right: 10px;
}

.sched-header h3 {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-family-display);
  font-size: 1.02rem;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.sched-head-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.sched-head-actions .btn-icon {
  min-width: 40px;
  padding: 8px;
}

.sched-head-actions .btn-icon svg {
  width: 20px;
  height: 20px;
}

.sched-today-btn {
  position: relative;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border-tint-20);
  background: var(--accent-tint-8);
  box-shadow: inset 0 1px 0 var(--glass-light);
  color: var(--text-accent);
  font-size: var(--font-size-xs);
  font-family: var(--font-family);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background var(--transition-fast);
}

/* 看得见的是 32px 的小药丸，摸得到的是 44px */
.sched-today-btn::after {
  content: '';
  position: absolute;
  inset: -6px -2px;
}

.sched-today-btn:active {
  transform: scale(0.95);
  background: var(--accent-tint-20);
}

.sched-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── 一句话添加 ── */
.sched-quick {
  flex-shrink: 0;
  padding: 12px 14px 0;
}

.sched-quick-row {
  display: flex;
  gap: 8px;
}

.sched-quick-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1px solid var(--border-tint-15);
  background: var(--glass-medium);
  color: var(--text-primary);
  font-size: 16px; /* 小于 16px iOS 聚焦时会放大页面 */
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.sched-quick-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-tint-15);
}

.sched-quick-input::placeholder {
  color: var(--text-muted);
  font-size: 14px;
}

.sched-quick-add {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-tint-20);
  background: var(--accent-tint-15);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 18px var(--accent-tint-10);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background var(--transition-fast);
}

.sched-quick-add:active {
  transform: scale(0.92);
  background: var(--accent-tint-30);
}

.sched-quick-add svg {
  width: 20px;
  height: 20px;
}

.sched-quick-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.sched-quick-hint b {
  font-weight: 500;
  color: var(--text-primary);
}

.sched-quick-hint span {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-tint-10);
  color: var(--text-accent);
}

/* ── 工具条 ── */
.sched-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
}

.sched-seg,
.sched-fseg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--glass-light);
  border: 1px solid var(--border-tint-10);
}

.sched-seg button,
.sched-fseg button {
  min-height: 34px;
  padding: 0 13px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-family);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background var(--transition-fast), color var(--transition-fast), transform 160ms var(--ease-out);
}

.sched-seg button:active,
.sched-fseg button:active {
  transform: scale(0.96);
}

.sched-seg button.active,
.sched-fseg button.active {
  background: var(--accent-tint-25);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  color: var(--text-primary);
}

.sched-owners {
  display: flex;
  gap: 2px;
}

.sched-owner-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 0 8px;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform 160ms var(--ease-out);
}

.sched-owner-chip:active {
  transform: scale(0.94);
}

.sched-owner-chip.is-off {
  opacity: 0.4;
}

.sched-owner-chip.is-off .sched-dot {
  background: none;
  box-shadow: inset 0 0 0 1.5px var(--c, var(--accent));
}

.sched-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  flex-shrink: 0;
}

/* ── 视图容器 ── */
.sched-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px calc(28px + var(--safe-bottom, 0px));
}

.sched-view--tg {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.sched-empty {
  padding: 36px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.sched-empty--small {
  padding: 12px 6px;
  text-align: left;
}

/* ── 月视图 ── */
.sched-wdrow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 2px 0 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 1px;
}

.sched-wdrow .is-weekend {
  color: var(--text-accent);
  opacity: 0.75;
}

/* 只留每一周之间的一条细线：七列竖线会把夜空切成表格 */
.sched-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.sched-cell {
  min-height: 76px;
  padding: 4px 1px 5px;
  border-top: 1px solid var(--border-tint-10);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast);
}

.sched-cell.is-out {
  opacity: 0.36;
}

.sched-cell.is-selected {
  border-radius: 10px;
  border-top-color: transparent;
  background: var(--accent-tint-10);
  box-shadow: inset 0 0 0 1px var(--border-tint-30);
}

.sched-cell-head {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 0 2px;
}

.sched-cell-num {
  flex-shrink: 0;
  min-width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 11px;
  text-align: center;
  font-size: 13px;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.sched-cell.is-weekend .sched-cell-num {
  color: var(--text-accent);
}

.sched-cell.is-today .sched-cell-num {
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  color: var(--text-primary);
  font-weight: 600;
}

.sched-cell-sub {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 9px;
  color: var(--text-muted);
}

.sched-cell-sub.is-special {
  color: var(--sched-rose);
}

.sched-chip {
  display: block;
  margin: 0 1px;
  padding: 1px 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--c, var(--accent)) 34%, transparent);
  color: var(--text-primary);
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
}

/* 定了钟点的：淡底 + 前面一颗小点；全天的：实一点的色块 */
.sched-chip.is-timed {
  background: color-mix(in srgb, var(--c, var(--accent)) 13%, transparent);
}

.sched-chip.is-timed::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  vertical-align: middle;
}

.sched-chip--deadline {
  box-shadow: inset 0 0 0 1px var(--c, var(--accent));
}

/* 待办：不垫底色，前面一个空心小圈（和清单里那只勾选圈是一回事） */
.sched-chip--todo,
.sched-chip--todo.is-timed {
  background: none;
  color: var(--text-secondary);
}

.sched-chip--todo::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 3px;
  border-radius: 50%;
  background: none;
  box-shadow: inset 0 0 0 1px var(--c, var(--accent));
  vertical-align: middle;
}

.sched-chip--overlay {
  background: var(--sched-rose-tint);
  color: var(--sched-rose);
}

.sched-chip.is-done {
  opacity: 0.45;
  text-decoration: line-through;
}

.sched-more {
  padding: 0 5px;
  font-size: 9px;
  color: var(--text-muted);
}

/* ── 一天的清单 / 清单视图 ── */
.sched-agenda,
.sched-group {
  padding: 14px 4px 0;
}

.sched-agenda-head,
.sched-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  margin-bottom: 4px;
  padding-left: 4px;
  font-family: var(--font-family-display);
  font-size: 14px;
  color: var(--text-accent);
  letter-spacing: 0.5px;
}

.sched-agenda-head small {
  margin-left: 8px;
  font-family: var(--font-family);
  font-size: 11px;
  color: var(--text-muted);
}

.sched-group-head.is-warn {
  color: var(--warning);
}

.sched-group-head.is-today {
  color: var(--text-primary);
}

.sched-agenda-add {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-tint-15);
  background: var(--accent-tint-8);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background var(--transition-fast);
}

.sched-agenda-add::after {
  content: '';
  position: absolute;
  inset: -5px;
}

.sched-agenda-add:active {
  transform: scale(0.9);
  background: var(--accent-tint-20);
}

.sched-agenda-add svg {
  width: 16px;
  height: 16px;
}

.sched-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 48px;
  padding: 11px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-md);
  background: var(--glass-light);
  border: 1px solid var(--border-tint-8);
  box-shadow: inset 0 1px 0 var(--glass-subtle);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast), transform 160ms var(--ease-out);
}

.sched-row:active {
  background: var(--glass-medium);
  transform: scale(0.985);
}

.sched-row--overlay {
  align-items: center;
  gap: 8px;
  min-height: 0;
  padding: 8px 12px;
  background: var(--sched-rose-tint);
  border-color: rgba(255, 143, 177, 0.16);
  color: var(--sched-rose);
  font-size: 13px;
  cursor: default;
}

.sched-row--overlay:active {
  background: var(--sched-rose-tint);
  transform: none;
}

.sched-bar {
  flex-shrink: 0;
  width: 4px;
  align-self: stretch;
  min-height: 24px;
  border-radius: 2px;
  background: var(--c, var(--accent));
}

.sched-check {
  position: relative;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--c, var(--accent));
  background: none;
  color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition-fast), transform 160ms var(--ease-out);
}

/* 24px 的圈，44px 的落指区 */
.sched-check::after {
  content: '';
  position: absolute;
  inset: -10px;
}

.sched-check:active {
  transform: scale(0.88);
}

.sched-row.is-done .sched-check {
  background: var(--c, var(--accent));
}

.sched-row-main {
  flex: 1;
  min-width: 0;
}

.sched-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.5;
}

.sched-row-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sched-row.is-done .sched-row-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.sched-row-sub {
  margin-top: 1px;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.sched-tag {
  flex-shrink: 0;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 107, 138, 0.16);
  color: var(--danger);
  font-size: 11px;
  line-height: 19px;
}

.sched-tag--soft {
  background: var(--accent-tint-15);
  color: var(--text-accent);
}

.sched-star {
  flex-shrink: 0;
  color: var(--sched-gold);
  font-size: 12px;
  display: inline-flex;
}

.sched-owner-tag {
  flex-shrink: 0;
  align-self: center;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 45%, transparent);
  color: var(--c, var(--accent));
  font-size: 11px;
}

.sched-progress {
  height: 5px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--glass-medium);
  overflow: hidden;
}

/* 金紫是这个项目的两个主色：进度从紫走到金 */
.sched-progress span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--sched-gold));
}

/* ── 周 / 日视图（时间网格） ── */
.sched-tg {
  --gutter: 44px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sched-tg-head,
.sched-tg-allday,
.sched-tg-body {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols), minmax(0, 1fr));
}

.sched-tg-head {
  flex-shrink: 0;
  padding-right: 4px;
}

.sched-tg-dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 2px 0 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sched-tg-dayhead b {
  min-width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.sched-tg-dayhead.is-today {
  color: var(--text-accent);
}

.sched-tg-dayhead.is-today b {
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.sched-tg-allday {
  flex-shrink: 0;
  padding-right: 4px;
  border-top: 1px solid var(--border-tint-10);
  border-bottom: 1px solid var(--border-tint-15);
  max-height: 96px;
  overflow-y: auto;
}

.sched-tg-gutter {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 7px;
}

.sched-tg-allday .sched-tg-gutter {
  padding-top: 8px;
}

.sched-tg-adcol {
  min-height: 32px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 1px solid var(--border-tint-8);
  cursor: pointer;
}

.sched-tg-adcol .sched-chip {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.sched-tg-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 4px calc(28px + var(--safe-bottom, 0px)) 0;
}

.sched-tg-body {
  position: relative;
}

.sched-tg-hours {
  position: relative;
}

.sched-tg-hours span {
  position: absolute;
  right: 7px;
  transform: translateY(-50%);
  font-variant-numeric: tabular-nums;
}

.sched-tg-col {
  position: relative;
  border-left: 1px solid var(--border-tint-8);
  background-image: linear-gradient(to bottom, var(--border-tint-10) 1px, transparent 1px);
  background-size: 100% var(--hour);
  cursor: cell;
}

.sched-tg-col.is-today {
  background-color: var(--accent-tint-5);
}

.sched-ev {
  position: absolute;
  box-sizing: border-box;
  padding: 4px 6px 2px 9px;
  border-radius: 8px;
  /* 垫底色取弹层那组梅紫，别垫偏蓝的近黑 */
  background: color-mix(in srgb, var(--c, var(--accent)) 30%, var(--sched-sheet-solid));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--accent)) 42%, transparent);
  color: var(--text-primary);
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.sched-ev::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--c, var(--accent));
}

.sched-ev-title {
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.sched-ev-time {
  margin-top: 1px;
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.sched-ev.is-short {
  padding-top: 1px;
}

.sched-ev.is-short::before {
  top: 3px;
  bottom: 3px;
}

.sched-ev.is-short .sched-ev-title {
  -webkit-line-clamp: 1;
  font-size: 11px;
}

.sched-ev.is-short .sched-ev-time {
  display: none;
}

.sched-ev.is-done {
  opacity: 0.5;
}

.sched-ev.is-done .sched-ev-title {
  text-decoration: line-through;
}

/* 按住被「拎起来」：稍微放大 + 一圈紫光，手指底下看得出它离开了格子 */
.sched-ev.is-dragging {
  z-index: 5;
  transform: scale(1.02);
  box-shadow:
    inset 0 0 0 1px var(--c, var(--accent)),
    0 10px 28px var(--overlay-heavy),
    0 0 22px var(--accent-glow);
  cursor: grabbing;
}

.sched-ev.is-dragging .sched-ev-time {
  display: block;
}

.sched-ev--ghost {
  left: 0;
  width: 100%;
  background: var(--accent-tint-25);
  box-shadow: none;
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
  font-size: 10px;
  color: var(--text-accent);
  pointer-events: none;
}

.sched-ev--ghost::before {
  display: none;
}

/* 底边那一条是「拉长短」的把手：手指够得着的高度，但不盖住正文 */
.sched-ev-resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 16px;
  cursor: ns-resize;
}

/* 「现在」是金色的 —— 夜空里那点暖光 */
.sched-nowline {
  position: absolute;
  left: -4px;
  right: 0;
  height: 0;
  border-top: 1.5px solid var(--sched-gold);
  filter: drop-shadow(0 0 4px rgba(255, 224, 150, 0.55));
  z-index: 4;
  pointer-events: none;
}

.sched-nowline::before {
  content: '';
  position: absolute;
  left: 0;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sched-gold);
}

/* ── 提示条（和全局 .toast 同一套表面，多一个「撤销」） ── */
.sched-snack {
  position: absolute;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 28px);
  min-height: 48px;
  padding: 6px 6px 6px 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(30, 30, 53, 0.96) 0%, rgba(48, 32, 72, 0.94) 100%);
  border: 1px solid var(--border-tint-20);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 var(--glass-medium),
    0 0 20px var(--accent-tint-10);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  animation: schedSnackIn 0.28s var(--ease-out) both;
}

.sched-snack span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sched-snack button {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent-tint-30);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}

.sched-snack button:active {
  transform: scale(0.95);
}

@keyframes schedSnackIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── 抽屉 ── */
.sched-mask {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--sched-scrim);
  animation: schedFadeIn 0.2s ease both;
}

.sched-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 11;
  display: flex;
  flex-direction: column;
  max-height: 92%;
  border-radius: 24px 24px 0 0;
  background: var(--sched-sheet);
  border-top: 1px solid var(--border-tint-20);
  box-shadow:
    0 -12px 40px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 var(--glass-medium),
    0 0 60px var(--accent-tint-5);
  animation: schedDrawerUp 0.34s var(--sched-ease-drawer) both;
  will-change: transform;
}

/* 手指开始拽之后由 js 接管 transform：进场动画的收尾状态要先让开 */
.sched-drawer.is-settled {
  animation: none;
}

/* 顶上那一小条：能看出这是张可以往下拽走的纸，也是真的能拽 */
.sched-drawer-grab {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 9px 0 7px;
  touch-action: none;
  cursor: grab;
}

.sched-drawer-grab::before {
  content: '';
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-tint-30);
}

.sched-drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
}

.sched-drawer-scroll:last-child {
  padding-bottom: calc(20px + var(--safe-bottom, 0px));
}

/* 保存 / 删掉钉在抽屉底部：表单再长也不用滚到最下面去找 */
.sched-drawer-foot {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + var(--safe-bottom, 0px));
  border-top: 1px solid var(--border-tint-10);
}

.sched-drawer-foot .sched-btn--primary {
  flex: 1;
  max-width: 220px;
  margin-left: auto;
}

.sched-layer-closing {
  pointer-events: none;
}

.sched-layer-closing.sched-drawer,
.sched-layer-closing .sched-scope-card {
  animation: schedDrawerDown 0.2s var(--ease-out) both;
}

.sched-layer-closing.sched-mask,
.sched-layer-closing.sched-scope {
  animation: schedFadeOut 0.2s ease both;
}

@keyframes schedDrawerUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes schedDrawerDown {
  to { transform: translateY(100%); }
}

@keyframes schedFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes schedFadeOut {
  to { opacity: 0; }
}

.sched-drawer-top {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.sched-drawer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-family: var(--font-family-display);
  font-size: var(--font-size-base);
  color: var(--text-accent);
}

.sched-title-input {
  flex: 1;
  min-width: 0;
  padding: 10px 2px;
  border: none;
  border-bottom: 1px solid var(--border-tint-20);
  border-radius: 0;
  background: none;
  color: var(--text-primary);
  font-size: 19px;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast);
}

.sched-title-input::placeholder {
  color: var(--text-muted);
}

.sched-title-input:focus {
  border-bottom-color: var(--accent);
}

.sched-star-btn {
  flex-shrink: 0;
  width: 44px;
  min-height: 44px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform 160ms var(--ease-out);
}

.sched-star-btn:active {
  transform: scale(0.88);
}

.sched-star-btn.active {
  color: var(--sched-gold);
  filter: drop-shadow(0 0 6px rgba(255, 224, 150, 0.4));
}

.sched-star-btn.active svg {
  fill: currentColor;
}

.sched-fseg {
  display: flex;
  margin-bottom: 14px;
}

.sched-fseg button {
  flex: 1;
  justify-content: center;
  min-height: 38px;
  padding: 0 8px;
  font-size: 14px;
}

.sched-frow {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.sched-field {
  display: block;
  flex: 1;
  min-width: 0;
  margin-bottom: 14px;
}

.sched-field > span,
.sched-flabel {
  display: block;
  margin-bottom: 6px;
  padding-left: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.sched-field input,
.sched-field select,
.sched-field textarea {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-tint-15);
  background: var(--overlay-light);
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-family);
  outline: none;
  color-scheme: dark;
  /* iOS 的日期 / 钟点输入自带一套尺寸，不关掉会把这一行撑出抽屉 */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

/* iOS：空着的日期框会塌成一条线，值默认居中 */
.sched-field input::-webkit-date-and-time-value {
  min-height: 1.5em;
  text-align: left;
}

.sched-field select {
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  background-color: var(--overlay-light);
}

.sched-field select option {
  background: var(--sched-sheet-solid);
  color: var(--text-primary);
}

.sched-field textarea {
  resize: none;
  line-height: 1.5;
}

.sched-field input:focus,
.sched-field select:focus,
.sched-field textarea:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-tint-20), 0 0 12px var(--accent-tint-10);
}

/* 开关：iOS 那种拨片，不用系统的小方框 */
.sched-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 14px;
  padding: 0 2px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sched-switch input {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  border: 1px solid var(--border-tint-18);
  background: var(--glass-medium);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sched-switch input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 1px 3px var(--overlay-medium);
  transition: transform 0.2s var(--ease-out);
}

.sched-switch input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.sched-switch input:checked::after {
  transform: translateX(18px);
}

.sched-switch--wide {
  display: flex;
  justify-content: space-between;
  flex-direction: row-reverse;
  padding: 0 4px;
  font-size: 14px;
  color: var(--text-primary);
}

.sched-colors {
  display: flex;
  gap: 6px;
  margin: 0 -4px 14px;
}

/* 28px 的色点，外面一圈透明留白凑够 40px 的落指区 */
.sched-color {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}

.sched-color::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--c, transparent);
}

.sched-color--auto::before {
  border: 1px dashed var(--border-tint-30);
}

.sched-color svg {
  position: relative;
  width: 14px;
  height: 14px;
}

.sched-color:active {
  transform: scale(0.9);
}

.sched-color.active::before {
  box-shadow: 0 0 0 2px var(--sched-sheet-solid), 0 0 0 4px var(--text-primary);
}

.sched-fnote {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.sched-fnote.is-warn {
  color: var(--warning);
}

/* 按钮：同 .btn-subtle 的玻璃做法；主按钮用舒薇自己那只聊天气泡的紫 */
.sched-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-tint-15);
  background: var(--border-tint-8);
  box-shadow: inset 0 0 10px var(--border-tint-5), inset 0 1px 0 var(--glass-light);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background 200ms ease, opacity 200ms ease;
}

.sched-btn:active {
  transform: scale(0.97);
  background: var(--border-tint-15);
}

.sched-btn:disabled {
  opacity: 0.45;
  transform: none;
}

.sched-btn--primary {
  background: var(--bg-message-user);
  border-color: var(--border-tint-30);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 4px 18px var(--accent-tint-20);
  font-weight: 500;
}

.sched-btn--primary:active {
  background: var(--bg-message-user);
  filter: brightness(1.12);
}

.sched-btn--danger {
  color: var(--danger);
  border-color: rgba(255, 107, 138, 0.22);
  background: rgba(255, 107, 138, 0.06);
  box-shadow: none;
}

.sched-btn--danger:active {
  background: rgba(255, 107, 138, 0.14);
}

.sched-btn--small {
  position: relative;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
}

.sched-btn--small::after {
  content: '';
  position: absolute;
  inset: -5px 0;
}

/* ── 倒推 ── */
.sched-bp {
  margin: 4px 0 6px;
  padding: 14px 12px 12px;
  border-radius: var(--radius-md);
  background: var(--accent-tint-8);
  border: 1px solid var(--border-tint-15);
}

.sched-bp-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--text-accent);
  font-size: 14px;
}

.sched-bp-head b {
  font-family: var(--font-family-display);
  font-weight: 500;
}

.sched-bp-head small {
  font-size: 11px;
  color: var(--text-muted);
}

.sched-bp .sched-progress {
  margin: 0 0 6px;
}

.sched-bp .sched-btn {
  width: 100%;
}

.sched-bp #bp-result {
  margin-top: 12px;
}

.sched-bp-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
}

.sched-bp-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border-tint-8);
  font-size: 13px;
  color: var(--text-primary);
}

.sched-bp-list b {
  font-weight: 400;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── 系列范围：从底下升起来的一小张，拇指够得着 ── */
.sched-scope {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 10px calc(10px + var(--safe-bottom, 0px));
  background: var(--sched-scrim);
  animation: schedFadeIn 0.2s ease both;
}

.sched-scope-card {
  width: 100%;
  max-width: 420px;
  padding: 18px 14px 8px;
  border-radius: var(--radius-lg);
  background: var(--sched-sheet);
  border: 1px solid var(--border-tint-20);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 var(--glass-medium),
    0 0 60px var(--accent-tint-5);
  animation: schedDrawerUp 0.3s var(--sched-ease-drawer) both;
}

.sched-scope-card p {
  margin: 0 0 14px;
  text-align: center;
  font-family: var(--font-family-display);
  font-size: 15px;
  color: var(--text-accent);
}

.sched-scope-card button {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-tint-15);
  background: var(--border-tint-8);
  box-shadow: inset 0 1px 0 var(--glass-light);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background 200ms ease;
}

.sched-scope-card button:active {
  transform: scale(0.98);
  background: var(--border-tint-18);
}

.sched-scope-card button.is-cancel {
  margin-bottom: 0;
  background: none;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

/* ── 改动记录 ── */
.sched-change {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-tint-8);
}

.sched-change:last-child {
  border-bottom: none;
}

.sched-change.is-undone .sched-change-main {
  opacity: 0.45;
  text-decoration: line-through;
}

.sched-change-main {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.sched-change-main small {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sched-change-done {
  flex-shrink: 0;
  padding: 0 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 谁动的：舒薇 = 紫，顾言 = 金，小助手 = 不抢眼的玻璃灰 */
.sched-actor {
  flex-shrink: 0;
  min-width: 46px;
  padding: 2px 6px;
  border-radius: 999px;
  text-align: center;
  font-size: 11px;
  background: var(--accent-tint-15);
  color: var(--text-accent);
}

.sched-actor--gu_yan {
  background: var(--sched-gold-tint);
  color: var(--sched-gold);
}

.sched-actor--extraction {
  background: var(--glass-medium);
  color: var(--text-secondary);
}

/* ── 状态页「近期计划」删完留的那一行撤销（js/memory.js） ── */
.plan-item--undo .plan-content {
  color: var(--text-secondary);
}

.plan-undo {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-tint-20);
  background: var(--accent-tint-10);
  color: var(--text-accent);
  font-size: 12px;
  font-family: var(--font-family);
  cursor: pointer;
  transition: transform 160ms var(--ease-out), background var(--transition-fast);
}

.plan-undo:active {
  transform: scale(0.95);
  background: var(--accent-tint-20);
}

/* ── 翻页时那一下很轻的平移（js 里按方向加类） ── */
.sched-view.is-slide-next > * {
  animation: schedSlideNext 0.2s var(--ease-out) both;
}

.sched-view.is-slide-prev > * {
  animation: schedSlidePrev 0.2s var(--ease-out) both;
}

@keyframes schedSlideNext {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes schedSlidePrev {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (hover: hover) and (pointer: fine) {
  .sched-row:hover {
    background: var(--glass-medium);
  }

  .sched-cell:hover {
    background: var(--accent-tint-5);
  }

  .sched-btn:hover {
    background: var(--border-tint-15);
  }

  .sched-btn--primary:hover {
    background: var(--bg-message-user);
    filter: brightness(1.08);
  }

  .sched-seg button:hover,
  .sched-fseg button:hover {
    color: var(--text-primary);
  }
}

@media (min-width: 640px) {
  .sched-cell {
    min-height: 98px;
  }

  .sched-chip {
    font-size: 11px;
  }

  .sched-drawer {
    width: 520px;
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sched-drawer,
  .sched-mask,
  .sched-scope,
  .sched-scope-card,
  .sched-snack,
  .sched-layer-closing,
  .sched-view.is-slide-next > *,
  .sched-view.is-slide-prev > * {
    animation: none !important;
  }

  .sched-ev.is-dragging {
    transform: none;
  }
}

/* Lucide 图标在这些小地方默认 24px 太大 */
.sched-fnote svg,
.sched-row--overlay svg,
.sched-star svg,
.sched-bp-head svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.sched-btn svg,
.sched-drawer-title svg {
  width: 16px;
  height: 16px;
}

.sched-check svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
}

.sched-star svg {
  fill: currentColor;
}

/* ── 小纸条：顾言留在某一天的一句话 ───────────────────────────────── */

.sched-cell-note {
  flex-shrink: 0;
  margin-left: auto;
  display: inline-flex;
  color: var(--sched-rose);
}

.sched-cell-note svg {
  width: 10px;
  height: 10px;
}

.sched-note {
  margin: 0 0 8px;
  padding: 10px 12px 12px;
  border-radius: 4px 14px 14px 14px;
  background: var(--sched-rose-tint);
  color: var(--text-primary);
}

.sched-note-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  font-size: 11px;
  color: var(--sched-rose);
}

.sched-note-head svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.sched-note p {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sched-note-del {
  margin-left: auto;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms ease-out, background var(--transition-fast);
}

.sched-note-del:active {
  transform: scale(0.95);
}

.sched-note-del.is-armed {
  padding: 0 10px;
  background: rgba(255, 143, 177, 0.18);
  color: var(--sched-rose);
}

.sched-chip--note {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--sched-rose-tint);
  color: var(--sched-rose);
  cursor: pointer;
}

.sched-chip--note svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* 纸条翻页：这天换过、拿掉过纸条时的 ◀ 1/2 ▶（按钮本身用聊天里翻版本的 .version-btn） */
.sched-note-tools {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sched-note-tools .sched-note-del {
  margin-left: 0;
}

.sched-note-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sched-note.is-gone {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--border-color);
}

.sched-note.is-gone .sched-note-head,
.sched-note.is-gone p {
  color: var(--text-muted);
}

.sched-note-past {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  margin: 0 0 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms ease-out;
}

.sched-note-past:active {
  transform: scale(0.97);
}

.sched-note-past svg {
  width: 13px;
  height: 13px;
}
