:root {
  --blue: #4A90E2;
  --pink: #F6809A;
  --green: #5CD4A6;
  --yellow: #F5B741;
  --purple: #9A7CE3;
  --default-text: #224488;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-blur: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #e8eef4;
  color: #1e2a3a;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
.bg-layer {
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(160deg, #dce9f5, #f4e8ee 50%, #e4f2ea);
  background-size: cover; background-position: center;
}
.app { max-width: 520px; margin: 0 auto; padding: 16px 12px 32px; }
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
}
.calendar-header { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 10px; }
.nav-btn {
  width: 40px; height: 40px; border: none; border-radius: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 22px; cursor: pointer; color: #334;
}
.month-label { font-size: 20px; font-weight: 700; cursor: pointer; padding: 4px 12px; border-radius: 10px; transition: background 0.2s; }
.month-label:hover { background: rgba(255,255,255,0.5); }
.toolbar { text-align: center; margin-bottom: 12px; }
.small-btn {
  border: none; border-radius: 20px; padding: 6px 16px; font-size: 13px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: pointer; color: #445;
}
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: #667; margin-bottom: 6px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 16px; }
.day-cell {
  position: relative; min-height: 72px; border-radius: 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 2px solid transparent;
  padding: 4px 3px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
  transition: border-color 0.2s;
}
.day-cell.other-month { opacity: 0.35; }
.day-cell.today .day-num { color: var(--blue); font-weight: 800; }
.day-cell.selected { border: 2px solid var(--blue); box-shadow: 0 0 0 2px rgba(74,144,226,0.2); }
.day-num { font-size: 12px; font-weight: 600; color: #334; }
.day-event {
  font-size: 10px; line-height: 1.3; padding: 1px 3px; border-radius: 3px;
  color: var(--default-text); background: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-event[data-color="blue"]   { color: var(--blue); background: rgba(74,144,226,0.1); }
.day-event[data-color="pink"]   { color: var(--pink); background: rgba(246,128,154,0.1); }
.day-event[data-color="green"]  { color: var(--green); background: rgba(92,212,166,0.1); }
.day-event[data-color="yellow"] { color: var(--yellow); background: rgba(245,183,65,0.1); }
.day-event[data-color="purple"] { color: var(--purple); background: rgba(154,124,227,0.1); }
.day-panel { padding: 14px; }
.day-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.day-panel-header h2 { font-size: 15px; }
.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.schedule-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px;
  border-radius: 10px; background: rgba(255,255,255,0.6); cursor: pointer;
}
.schedule-item .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; background: var(--default-text); }
.schedule-item .dot[data-color="blue"]   { background: var(--blue); }
.schedule-item .dot[data-color="pink"]   { background: var(--pink); }
.schedule-item .dot[data-color="green"]  { background: var(--green); }
.schedule-item .dot[data-color="yellow"] { background: var(--yellow); }
.schedule-item .dot[data-color="purple"] { background: var(--purple); }
.schedule-item .info { flex: 1; min-width: 0; }
.schedule-item .title { font-size: 14px; font-weight: 600; }
.schedule-item .remark { font-size: 12px; color: #778; margin-top: 2px; }
.empty-tip { text-align: center; font-size: 13px; color: #889; padding: 12px 0; }
.primary-btn { border: none; border-radius: 10px; padding: 8px 16px; font-size: 14px; background: var(--blue); color: #fff; cursor: pointer; }
.secondary-btn { border: 1px solid #ccd; border-radius: 10px; padding: 8px 16px; font-size: 14px; background: transparent; cursor: pointer; }
.danger-btn { border: none; border-radius: 10px; padding: 8px 16px; font-size: 14px; background: #e05a5a; color: #fff; cursor: pointer; }
.text-btn { border: none; background: transparent; font-size: 15px; color: #667; cursor: pointer; }

/* 弹窗通用 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,40,0.35);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal { width: 100%; max-width: 380px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.modal h3 { margin-bottom: 4px; font-size: 18px; }
.modal label { font-size: 13px; color: #556; margin-top: 6px; }
.modal input[type="text"], .modal input[type="email"], .modal input[type="password"], .modal textarea {
  width: 100%; border: 1px solid #dde; border-radius: 8px;
  padding: 10px; font-size: 14px; font-family: inherit; background: rgba(255,255,255,0.7);
}
.required { color: #e05a5a; }
.color-picker { display: flex; gap: 12px; padding: 6px 0; }
.color-dot {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid transparent; background: var(--dot); cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.color-dot.selected { border-color: #334; transform: scale(1.08); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ============ 自定义年月选择器（类似 APP 底部弹窗） ============ */
.picker-overlay { align-items: flex-end; padding: 0; }
.picker-container {
  width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0;
  padding-bottom: 20px;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.picker-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,0.05);
  font-weight: 600; font-size: 16px;
}

/* 年份滑动列表（横向） */
.picker-years-wrap { width: 100%; overflow-x: auto; padding: 10px 0; background: rgba(255,255,255,0.3); }
.picker-years-wrap::-webkit-scrollbar { display: none; }
.picker-years { display: flex; gap: 10px; padding: 0 20px; width: max-content; }
.year-item {
  padding: 8px 16px; font-size: 15px; font-weight: 600; color: #667;
  border-radius: 20px; cursor: pointer; transition: 0.2s;
}
.year-item.active { background: var(--blue); color: #fff; }

/* 月份网格 */
.picker-months {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  padding: 20px;
}
.month-item {
  padding: 12px 0; text-align: center; font-size: 15px; font-weight: 600;
  background: rgba(255,255,255,0.6); border-radius: 12px; cursor: pointer;
  color: #334; transition: 0.2s;
}
.month-item.active { background: var(--blue); color: #fff; box-shadow: 0 4px 10px rgba(74,144,226,0.3); }

@media (max-width: 400px) {
  .day-cell { min-height: 60px; }
  .day-event { font-size: 9px; }
}
/* 管理员登录按钮：固定右上角 */
#authBtn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  color: #445;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
/* ===== 顶部工具条 ===== */
.top-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}
#searchInput {
  flex: 1;
  padding: 9px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.8);
  font-size: 14px;
  outline: none;
}
#searchInput:focus { border-color: #9ab8ff; }
.archive-btn {
  border: none;
  border-radius: 20px;
  padding: 9px 16px;
  background: linear-gradient(135deg, #a8c0ff, #c2a8ff);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.archive-btn:hover { opacity: 0.9; }

/* ===== 新功能专用弹窗（fx- 前缀，不影响原有弹窗） ===== */
.fx-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
.fx-box {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  width: min(520px, 92vw);
  max-height: 78vh;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.fx-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.fx-head h3 { margin: 0; font-size: 17px; }
.fx-close {
  border: none; background: none; font-size: 18px;
  cursor: pointer; color: #888;
}

/* ===== 搜索结果 ===== */
.search-results { overflow-y: auto; }
.search-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  background: #f6f7fb;
}
.search-item:hover { background: #eef1ff; }
.search-item .s-date { font-weight: 600; color: #4a5a8a; margin-right: 8px; }
.search-item .s-note { display: block; font-size: 12px; color: #999; margin-top: 3px; }
.search-empty { color: #999; text-align: center; padding: 30px 0; }

/* ===== 档案馆 ===== */
.archive-year-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px; overflow-y: auto;
}
.year-card {
  background: linear-gradient(135deg, #f0f4ff, #f6efff);
  border-radius: 14px;
  padding: 24px 0;
  text-align: center;
  font-size: 22px; font-weight: 700; color: #4a5a8a;
  cursor: pointer;
  transition: transform 0.15s;
}
.year-card:hover { transform: translateY(-3px); }
.year-card .year-count { font-size: 12px; font-weight: 400; color: #999; margin-top: 4px; }

.archive-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.archive-tabs button {
  border: none; border-radius: 16px;
  padding: 6px 14px; font-size: 13px;
  background: #f0f0f4; color: #555; cursor: pointer;
}
.archive-tabs button.active { background: #6a7fd6; color: #fff; }

.archive-list { overflow-y: auto; }
.archive-item {
  padding: 9px 12px;
  border-bottom: 1px solid #f2f2f6;
  line-height: 1.5;
}
.archive-item .a-note { font-size: 12px; color: #999; }

/* ===== 日历单元格搜索高亮 ===== */
.day-cell.search-hit {
  outline: 2px solid #ffb84d;
  animation: hitFlash 1.2s ease-in-out 2;
}
@keyframes hitFlash {
  0%,100% { background-color: transparent; }
  50% { background-color: #fff3d6; }
}
.archive-tabs button { border: 1px solid transparent; }
/* 颜色标签带文字 */
.color-picker {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.color-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.color-option .color-label {
  font-size: 11px;
  color: #888;
}
/* 档案馆弹窗放大 */
/* ===== 档案馆：准全屏 + 四栏流式排版 ===== */
/* 弹窗本体必须是纵向 flex，列表区才能撑满 */
#archiveView .fx-box {
  display: flex;
  flex-direction: column;
  width: 95vw;
  height: 92vh;
}

/* 列表区撑满弹窗剩余空间 */
#archiveView #archiveListWrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 双保险：即使列表没撑满，也把翻页条压到底部 */
.archive-pager {
  margin-top: auto;
}


/* 容器：横向排列各栏，每栏内部自管高度 */
#archiveView #archiveList {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0 28px;
  align-items: flex-start;
  overflow: hidden;
}

.archive-col {
  flex: 1;
  min-width: 0;
}

/* 月份标题：占一格 */
.month-header {
  padding: 10px 0 4px;
  font-size: 15px; font-weight: 700; color: #4a5a8a;
  border-bottom: 2px solid #eef1ff;
}

/* 条目：第一行"日期 | 标题"，备注在下一行 */
.archive-item {
  padding: 6px 0;
  border-bottom: 1px solid #f6f6fa;
}
.archive-item .a-main {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 14px;
}
.archive-item .a-date { flex-shrink: 0; font-weight: 700; }
.archive-item .a-sep { color: #ccc; font-weight: 400; }
.archive-item .a-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 备注：限 1 行，超出省略号，悬浮看全文 */
.archive-item .a-note {
  margin-top: 3px;
  font-size: 12px; color: #888;
  background: #f5f6fa;
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 底部翻页条（在网格外面、弹窗底部） */
.archive-pager {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  padding: 10px 0 2px;
  border-top: 1px solid #eef1ff;
}
.archive-pager button {
  border: none; border-radius: 18px;
  padding: 7px 20px; font-size: 14px;
  background: #6a7fd6; color: #fff; cursor: pointer;
}
.archive-pager button:disabled { background: #ccc; cursor: default; }
.archive-pager .page-info { font-size: 13px; color: #666; }


/* ② 条目悬浮高亮，视线有落点 */
.archive-item:hover {
  background: #f6f8ff;
  border-radius: 6px;
}

/* ③ 月份标题更精致一点：小圆点 + 大间距 */
.month-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.month-header::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #6a7fd6;
}

/* ④ 网格容器加一点内边距，别让文字顶到弹窗边缘 */
#archiveView #archiveList {
  padding: 4px 4px 0;
}
/* ===== 档案馆布局总控（必须放在文件最后） ===== */
#archiveView .fx-box {
  position: relative !important;
  width: 95vw !important;
  height: 92vh !important;
  max-height: 92vh !important;
  display: flex !important;
  flex-direction: column !important;
}
#archiveView #archiveListWrap {
  flex: 1 !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}
#archiveView #archiveList {
  flex: 1 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
.archive-pager {
  margin-top: auto !important;
  flex-shrink: 0 !important;
}
.archive-pager {
  margin-top: auto !important;
  flex-shrink: 0 !important;
  background: #fff;
  padding: 10px 0 6px;
  border-top: 1px solid #eef1ff;
}
.archive-back-btn {
  margin-left: 12px;
  padding: 4px 16px;
  border: 1px solid #c5c9d6;
  border-radius: 999px;
  background: #f3f4f8;
  color: #445;
  font-size: 14px;
  cursor: pointer;
  vertical-align: middle;
  font-weight: normal;
}
.archive-back-btn:hover { background: #e7e9f0; }
