/* ── Reset & 基础 ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --orange:      #FF8C42;
  --orange-lt:   #FFF0E6;
  --orange-glow: rgba(255, 140, 66, 0.45);
  --bg:          #FFFFFF;
  --surface:     #F7F7F7;
  --text1:       #222222;
  --text2:       #888888;
  --text3:       #CCCCCC;
  --divider:     #EEEEEE;
  --sunday:      #D32F2F;
  --saturday:    #1565C0;
  --error:       #D32F2F;
  --radius-lg:   16px;
  --radius-md:   10px;
  --radius-sm:   6px;
}

body {
  font-family: 'Inter', -apple-system, 'PingFang SC', 'Helvetica Neue', sans-serif;
  background: #DADADA;
  height: 100dvh;
  overflow: hidden;
  color: var(--text1);
}

.share-preview-image {
  position: fixed;
  width: 1px;
  height: 1px;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* ── 外层容器（桌面居中模拟手机）────────────────────── */
#app-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  background: linear-gradient(135deg, #C8C8C8 0%, #E0E0E0 100%);
  padding: 0;
}

/* ── App 主体 ─────────────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 100dvh;
  max-height: 844px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 48px rgba(0,0,0,0.28), 0 0 0 1px rgba(0,0,0,0.08);
}

/* 桌面端显示圆角，模拟 Android 手机 */
@media (min-height: 860px) and (min-width: 440px) {
  #app { border-radius: 44px; }
}

/* ── 分隔线 ───────────────────────────────────────────── */
.divider {
  height: 0.5px;
  background: var(--divider);
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────── */
/* ── 顶部导航栏 ────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  padding: 14px 2px 8px;
  flex-shrink: 0;
  background: var(--bg);
  gap: 0;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 30px;
  color: var(--text2);
  cursor: pointer;
  padding: 2px 10px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.icon-btn:hover { background: var(--surface); color: var(--text1); }
.icon-btn:active { background: var(--divider); }

#month-title {
  flex: 1;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  color: var(--text1);
  letter-spacing: 0.5px;
  user-select: none;
}

#btn-today {
  background: none;
  border: none;
  color: var(--orange);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
#btn-today:hover { background: var(--orange-lt); }
#btn-today:active { opacity: 0.8; }

/* ─────────────────────────────────────────────────────── */
/* ── 星期标题行 ────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#week-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 6px 0 5px;
  flex-shrink: 0;
  background: var(--bg);
}

.wlabel {
  text-align: center;
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  user-select: none;
}
.wlabel.sun { color: var(--sunday); }
.wlabel.sat { color: var(--saturday); }

/* ─────────────────────────────────────────────────────── */
/* ── 月历网格 ──────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;   /* 匹配容器高度均分每行 */
  flex: 58;
  min-height: 0;
  overflow: hidden;
  /* 注意：不要加 align-content: start，默认 stretch 才能充满容器 */
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px 3px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--divider);
  overflow: hidden;
  transition: background 0.12s;
  user-select: none;
  box-sizing: border-box;
  /* grid-auto-rows:1fr 已经控制行高，窗格自动拉伸 */
}
.day-cell:hover       { background: #F9F9F9; }
.day-cell.selected    { background: var(--orange-lt); }
.day-cell.other-month { opacity: 0.25; cursor: pointer; }

/* 日期数字圆圈 */
.day-num {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text1);
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.day-num.is-today    { background: var(--orange); color: #fff; font-weight: 700; }
.day-num.is-selected { outline: 2px solid var(--orange); outline-offset: -1px; }
.day-num.is-today.is-selected { outline: 2.5px solid #D06020; }
.day-num.is-sunday:not(.is-today)   { color: var(--sunday); }
.day-num.is-saturday:not(.is-today) { color: var(--saturday); }

/* 任务标签 */
.task-label {
  width: calc(100% - 2px);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 9.5px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text1);
  margin-top: 2px;
  flex-shrink: 0;
  font-weight: 500;
}

.task-more {
  font-size: 9px;
  color: var(--text2);
  margin-top: 1px;
  font-weight: 500;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────── */
/* ── 选中日期任务面板 ────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#day-panel {
  display: flex;
  flex-direction: column;
  flex: 42;
  min-height: 0;
  background: var(--surface);
}

#day-header {
  background: var(--bg);
  padding: 12px 16px 11px;
  flex-shrink: 0;
}

#day-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
  user-select: none;
}

#task-list {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  /* 平滑滚动 */
  -webkit-overflow-scrolling: touch;
}

/* 隐藏滚动条（保留功能） */
#task-list::-webkit-scrollbar { width: 3px; }
#task-list::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 2px; }

/* 任务条目 */
.task-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.12s;
  gap: 14px;
}
.task-item:hover { background: #FAFAFA; }
.task-item:active { background: var(--surface); }

.task-bar {
  width: 4px;
  height: 42px;
  border-radius: 2px;
  flex-shrink: 0;
}

.task-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.task-subject {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1);
}

.task-title-text {
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-note-text {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-arrow {
  font-size: 22px;
  color: var(--text3);
  line-height: 1;
  flex-shrink: 0;
}

.task-divider {
  height: 0.5px;
  background: var(--divider);
  margin-left: 34px;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 8px;
  padding: 20px;
}

.empty-main { font-size: 14px; color: var(--text2); }
.empty-hint { font-size: 12px; color: var(--text3); }

/* ─────────────────────────────────────────────────────── */
/* ── 悬浮按钮 FAB ──────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#fab {
  position: absolute;
  bottom: 22px;
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px var(--orange-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.15s;
  z-index: 20;
  user-select: none;
}
#fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px var(--orange-glow);
}
#fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 10px var(--orange-glow);
}

/* ─────────────────────────────────────────────────────── */
/* ── 遮罩层 ────────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 100;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─────────────────────────────────────────────────────── */
/* ── 底部弹窗（新增/编辑）─────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#task-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(102%);
  width: 100%;
  max-width: 390px;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  z-index: 200;
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.14);
}

#task-sheet.visible {
  transform: translateX(-50%) translateY(0);
}

/* 隐藏弹窗滚动条 */
#task-sheet::-webkit-scrollbar { display: none; }

.sheet-drag-bar {
  width: 38px;
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  margin: 12px auto 4px;
}

#sheet-content {
  padding: 12px 20px 48px;
}

#sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 22px;
}

/* ── 表单 ─────────────────────────────────────────────── */
.form-section {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
  margin-bottom: 9px;
}

/* 科目 Chips */
#subject-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.subject-chip {
  padding: 6px 13px;
  border-radius: 20px;
  border: 1px solid var(--divider);
  background: transparent;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
}
.subject-chip:hover { border-color: var(--text3); color: var(--text1); }
.subject-chip.selected {
  border-color: transparent;
  color: var(--text1);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

/* 输入框 */
input[type="text"],
textarea {
  width: 100%;
  border: 1.5px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text1);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: none;
  background: var(--bg);
  -webkit-appearance: none;
}
input[type="text"]::placeholder,
textarea::placeholder { color: var(--text3); }

input[type="text"]:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.12);
}

/* 错误提示 */
.error-text {
  display: block;
  font-size: 12px;
  color: var(--error);
  margin-top: 5px;
}

/* 保存按钮 */
#btn-save {
  width: 100%;
  height: 50px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}
#btn-save:hover  { opacity: 0.93; }
#btn-save:active { transform: scale(0.98); opacity: 0.88; }

/* 删除按钮 */
#btn-delete {
  width: 100%;
  height: 46px;
  background: none;
  color: var(--error);
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
#btn-delete:hover { background: #FFF5F5; }

/* ─────────────────────────────────────────────────────── */
/* ── 删除确认对话框 ─────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
#delete-dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease;
}

#dialog-box {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 26px 24px 20px;
  width: 290px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: dialogIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dialogIn {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

#dialog-box h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text1);
  margin-bottom: 8px;
}

#dialog-box p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 22px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.dialog-actions button {
  flex: 1;
  height: 46px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.dialog-actions button:hover  { opacity: 0.88; }
.dialog-actions button:active { opacity: 0.75; }

#btn-cancel-delete  { background: var(--surface); color: var(--text1); }
#btn-confirm-delete { background: var(--error);   color: #fff; }

/* ─────────────────────────────────────────────────────── */
/* ── 通用工具类 ─────────────────────────────────────────── */
/* ─────────────────────────────────────────────────────── */
/* ── 月份切换滑入动画 ──────────────────────── */
@keyframes slideFromLeft {
  from { transform: translateX(-22px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes slideFromRight {
  from { transform: translateX(22px);  opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
#month-grid.slide-from-left  { animation: slideFromLeft  0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
#month-grid.slide-from-right { animation: slideFromRight 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94); }

/* ── 弹窗日期副标题 ────────────────────── */
.sheet-date-label {
  font-size: 13px;
  color: var(--orange);
  font-weight: 600;
  margin-top: -16px;
  margin-bottom: 20px;
  letter-spacing: 0.2px;
}

.hidden { display: none !important; }

/* 移动端适配 */
@media (max-width: 439px) {
  #app {
    border-radius: 0;
    max-height: 100dvh;
  }
  #app-wrapper {
    background: #fff;
  }
}
