/* ====== 基础重置 ====== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e4e7ee;
  --text: #1a1d29;
  --text-2: #5a6072;
  --text-3: #9aa0b0;
  --primary: #4f8cff;
  --primary-d: #3a6fd9;
  --danger: #ff5c5c;
  --success: #2ecc71;
  --warn: #ffa940;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(20,30,60,.06);
  --shadow-lg: 0 10px 40px rgba(20,30,60,.15);
}
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ====== 顶栏 ====== */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 22px; }
.brand .title { font-size: 17px; font-weight: 600; }
.sync-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--surface-2); color: var(--text-3);
}
.sync-badge.syncing { background: #e8f0ff; color: var(--primary); }
.sync-badge.error { background: #ffe8e8; color: var(--danger); }

/* 离线横幅 */
.offline-banner {
  background: #fff3cd; color: #856404; text-align: center;
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  border-bottom: 1px solid #ffc107;
}
.sync-badge.ok { background: #e6fff0; color: var(--success); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* 搜索框 */
.search-box { display: flex; align-items: center; gap: 4px; position: relative; }
.search-box .input {
  width: 200px; padding: 6px 10px; font-size: 12px; border-radius: var(--radius-sm);
  transition: width .2s;
}
.search-box .input:focus { width: 280px; outline: none; }
.search-results {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  z-index: 96; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 90%; max-width: 520px;
  max-height: 60vh; overflow-y: auto;
}
.search-results.hidden { display: none; }
.sr-section { padding: 8px 12px; }
.sr-section-title { font-size: 11px; color: var(--text-3); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; }
.sr-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.sr-item:hover { background: var(--surface-2); }
.sr-item .sr-icon { font-size: 16px; flex-shrink: 0; }
.sr-item .sr-main { flex: 1; min-width: 0; }
.sr-item .sr-title { font-weight: 500; }
.sr-item .sr-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.sr-empty { text-align: center; padding: 24px; color: var(--text-3); font-size: 13px; }

/* 登录界面 */
.auth-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 32px;
  width: 90%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
}
.auth-logo { font-size: 40px; text-align: center; }
.auth-card h2 { text-align: center; font-size: 20px; margin: 0; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-3); margin: 0 0 8px; }
.auth-card .input { width: 100%; padding: 10px 12px; }
.auth-error { color: var(--danger); font-size: 12px; text-align: center; }
.auth-switch { text-align: center; font-size: 13px; color: var(--text-3); }
.auth-switch a { color: var(--primary); text-decoration: none; }
.auth-skip { text-align: center; margin-top: 4px; }
.auth-skip a { font-size: 12px; color: var(--text-3); text-decoration: none; }
.auth-skip a:hover { color: var(--text-2); }

/* 用户标签 */
.user-label { font-size: 12px; color: var(--text-2); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ====== 按钮 ====== */
.btn {
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 32px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: #fff0f0; color: var(--danger); }
.btn-danger:hover { background: #ffe0e0; }
.btn-icon { width: 32px; height: 32px; padding: 0; font-size: 18px; display: flex; align-items: center; justify-content: center; }

/* ====== 布局 ====== */
.layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ====== 日历面板 ====== */
.calendar-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.month-label { font-size: 18px; font-weight: 600; }

/* 视图切换 */
.view-switcher { display: flex; gap: 2px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; }
.vs-btn {
  padding: 5px 12px; border: none; background: transparent;
  border-radius: 4px; font-size: 13px; font-weight: 500;
  color: var(--text-3); cursor: pointer; transition: all .12s;
  -webkit-tap-highlight-color: transparent;
}
.vs-btn:hover { color: var(--text); }
.vs-btn.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; padding: 8px 12px 4px;
  color: var(--text-3); font-size: 12px; font-weight: 500;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  flex: 1; padding: 4px 8px 8px; gap: 2px;
  min-height: 0;
}
.cal-cell {
  border-radius: var(--radius-sm);
  padding: 6px 8px; cursor: pointer;
  display: flex; flex-direction: column;
  transition: background .12s;
  min-height: 0; overflow: hidden;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other-month { color: var(--text-3); opacity: .5; }
.cal-cell.today .date-num {
  background: var(--primary); color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.cal-cell.selected { background: #e8f0ff; }
.cal-cell .date-num { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.cal-cell .dots {
  display: flex; gap: 3px; flex-wrap: wrap;
  margin-top: auto;
}
.cal-cell .dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.cal-cell .event-tag {
  font-size: 10px; padding: 1px 4px; border-radius: 3px;
  color: #fff; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 农历日期显示 */
.cal-cell .lunar-date {
  font-size: 10px; color: var(--text-3); margin-top: 1px;
  white-space: nowrap;
}
.cal-cell .lunar-term {
  font-size: 10px; color: #2ecc71; font-weight: 500; margin-top: 1px;
  white-space: nowrap;
}
.cal-cell .lunar-festival {
  font-size: 10px; color: #ff5c5c; font-weight: 600; margin-top: 1px;
  white-space: nowrap;
}

/* 隐藏辅助 */
.hidden { display: none; }

/* ====== 周视图 ====== */
.week-view, .day-view { flex: 1; flex-direction: column; overflow-y: auto; min-height: 0; }
.week-view.active, .day-view.active { display: flex; }
.week-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 6px 8px; gap: 2px; position: sticky; top: 0;
  background: var(--surface); z-index: 2;
}
.week-day-header {
  text-align: center; padding: 6px 0; border-radius: var(--radius-sm);
}
.week-day-header.today { background: #e8f0ff; }
.week-day-header .wd-date { font-size: 18px; font-weight: 600; }
.week-day-header .wd-lunar { font-size: 10px; color: var(--text-3); }
.week-body {
  display: grid; grid-template-columns: repeat(7, 1fr);
  flex: 1; gap: 2px; padding: 0 8px 8px; overflow-y: auto; min-height: 0;
}
.week-col {
  display: flex; flex-direction: column; gap: 3px;
  border-radius: var(--radius-sm); padding: 3px; min-height: 200px;
}
.week-col:hover { background: var(--surface-2); }
.week-event {
  padding: 4px 6px; border-radius: 4px; font-size: 11px;
  border-left: 3px solid #4f8cff; background: var(--surface-2);
  cursor: pointer; transition: background .1s; word-break: break-word; line-height: 1.3;
}
.week-event:hover { background: var(--border); }
.week-event .we-time { font-size: 10px; color: var(--text-3); }
.week-event .we-title { font-weight: 500; }
.week-more { font-size: 10px; color: var(--text-3); padding: 2px 4px; text-align: center; }

/* ====== 日视图 ====== */
.day-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 2;
}
.day-header .dh-date { font-size: 22px; font-weight: 700; }
.day-header .dh-weekday { font-size: 14px; color: var(--text-2); }
.day-header .dh-lunar { font-size: 12px; color: var(--text-3); }
.day-body { flex: 1; overflow-y: auto; position: relative; padding: 0 16px 8px; }
.day-hour-row {
  display: flex; border-bottom: 1px solid var(--border);
  min-height: 48px; position: relative;
}
.day-hour-label {
  width: 48px; text-align: right; padding: 2px 8px 0 0;
  font-size: 11px; color: var(--text-3); flex-shrink: 0;
}
.day-hour-content { flex: 1; position: relative; min-height: 0; }
.day-event-block {
  position: absolute; left: 2px; right: 2px;
  border-radius: 4px; padding: 4px 6px; font-size: 11px;
  border-left: 3px solid #4f8cff; cursor: pointer; overflow: hidden;
  transition: opacity .1s; z-index: 1; min-height: 20px;
}
.day-event-block:hover { opacity: .85; }
.day-event-block .de-time { font-size: 10px; opacity: .7; }
.day-event-block .de-title { font-weight: 500; }
.day-empty {
  display: flex; align-items: center; justify-content: center;
  height: 200px; color: var(--text-3); font-size: 13px;
}

/* 当日概览 */
.day-overview {
  border-top: 1px solid var(--border);
  padding: 16px 20px; max-height: 200px; overflow-y: auto;
}
.overview-date { font-size: 14px; margin-bottom: 10px; color: var(--text-2); }
.overview-content .empty-hint { color: var(--text-3); font-size: 13px; }
.overview-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: 13px;
}
.overview-item .marker { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.overview-item .time { color: var(--text-3); font-size: 12px; min-width: 90px; }

/* ====== 侧栏 ====== */
.side-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 14px; font-size: 14px; font-weight: 500;
  color: var(--text-3); border-bottom: 2px solid transparent;
  transition: all .15s;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { flex: 1; overflow-y: auto; }
.tab-pane { display: none; padding: 16px; }
.tab-pane.active { display: block; }

/* 工具栏 */
.pane-toolbar {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.input, .select {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--primary); }
.input { flex: 1; min-width: 120px; }
.date-input, .dt-input { flex: 0 0 auto; min-width: 0; width: auto; }
.select { flex: 0 0 auto; }
.textarea { resize: vertical; font-family: inherit; }
.color-input { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: none; }
.checkbox-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; cursor: pointer; }

/* 筛选标签 */
.filter-row { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  padding: 4px 12px; border-radius: 14px; font-size: 12px;
  background: var(--surface-2); color: var(--text-2);
  transition: all .15s;
}
.chip:hover { background: var(--border); }
.chip.active { background: var(--primary); color: #fff; }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: background .12s;
}
.list-item:hover { background: var(--border); }

/* 待办项 */
.todo-item .checkbox {
  width: 18px; height: 18px; border: 2px solid var(--text-3);
  border-radius: 4px; flex-shrink: 0; margin-top: 1px;
  cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.todo-item .checkbox.checked {
  background: var(--success); border-color: var(--success); color: #fff;
}
.todo-item .checkbox.checked::after { content: "✓"; font-size: 12px; }
.todo-item .todo-main { flex: 1; min-width: 0; }
.todo-item .todo-title { font-size: 14px; word-break: break-word; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--text-3); }
.todo-item .todo-meta {
  display: flex; gap: 8px; margin-top: 4px;
  font-size: 11px; color: var(--text-3);
}
.todo-item .priority-tag {
  padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 500;
}
.priority-2 { background: #ffe0e0; color: var(--danger); }
.priority-1 { background: #fff3e0; color: #e67e22; }
.priority-0 { background: var(--surface); color: var(--text-3); }
.due-overdue { color: var(--danger); }
.todo-item .delete-btn {
  opacity: 0; color: var(--text-3); padding: 4px;
  font-size: 16px; transition: opacity .15s;
}
.todo-item:hover .delete-btn { opacity: 1; }
.todo-item .delete-btn:hover { color: var(--danger); }

/* 日程项 */
.event-item { border-left: 3px solid var(--primary); }
.event-item .event-time { font-size: 12px; color: var(--text-3); min-width: 110px; }
.event-item .event-main { flex: 1; min-width: 0; }
.event-item .event-title { font-size: 14px; word-break: break-word; }
.event-item .event-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.event-item .category-tag {
  padding: 1px 6px; border-radius: 3px; font-size: 10px;
  background: var(--surface); color: var(--text-2);
}
.repeat-badge {
  padding: 1px 5px; border-radius: 3px; font-size: 10px;
  background: #e8f0ff; color: var(--primary);
  display: inline-flex; align-items: center; gap: 2px;
}

/* 备忘卡片 */
.note-grid {
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
.note-card {
  padding: 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: transform .12s;
  border: 1px solid rgba(0,0,0,.06);
}
.note-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.note-card .note-title { font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.note-card .note-content {
  font-size: 13px; color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 100px; overflow: hidden;
}
.note-card .note-pin { font-size: 12px; }

/* ====== 弹窗 ====== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-card {
  position: relative; background: var(--surface);
  border-radius: var(--radius); width: 90%; max-width: 480px;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .15s ease;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body label { display: block; font-size: 12px; color: var(--text-2); margin: 10px 0 4px; }
.modal-body label:first-child { margin-top: 0; }
.modal-body .input, .modal-body .select { width: 100%; }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 20px; border-top: 1px solid var(--border);
}
.modal-footer .btn-danger { margin-right: auto; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(20,30,60,.9); color: #fff;
  padding: 10px 20px; border-radius: 20px; font-size: 13px;
  z-index: 200; animation: slideUp .25s ease;
}
.toast.hidden { display: none; }
.toast-undo {
  background: none; border: none; color: #ffe580; cursor: pointer;
  font-weight: 600; font-size: inherit; padding: 0 4px; text-decoration: underline;
}
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* 导入按钮伪装成按钮 */
.import-btn { cursor: pointer; margin: 0; }

/* ====== 统计面板 ====== */
.stats-card { max-width: 560px; }
.stats-body { padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.stat-row { display: flex; gap: 12px; }
.stat-card {
  flex: 1; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 14px; text-align: center; min-width: 0;
}
.stat-card .sc-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .sc-label { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.stat-bar-row .sbr-label { font-size: 12px; color: var(--text-2); width: 44px; text-align: right; flex-shrink: 0; }
.stat-bar-row .sbr-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.stat-bar-row .sbr-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.stat-bar-row .sbr-num { font-size: 12px; color: var(--text-2); width: 24px; }
.stat-section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 2px; }
.progress-ring { display: inline-block; width: 48px; height: 48px; }

/* ====== 日历格子 Hover 浮层 ====== */
.cell-tooltip {
  position: fixed; z-index: 50;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  padding: 14px; min-width: 200px; max-width: 280px;
  font-size: 13px; pointer-events: none;
  animation: tooltipIn .12s ease;
}
.cell-tooltip.hidden { display: none; }
@keyframes tooltipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.cell-tooltip .tt-date { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.cell-tooltip .tt-lunar { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.cell-tooltip .tt-item {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0; font-size: 12px;
}
.cell-tooltip .tt-marker { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.cell-tooltip .tt-empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 6px 0; }
.cell-tooltip .tt-count { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.cell-tooltip .tt-dblclick { font-size: 10px; color: var(--text-3); margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); text-align: center; }

/* ====== 空状态 ====== */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-3); font-size: 13px;
}

/* ====== 底部导航（移动端）====== */
.bottom-nav {
  display: none; /* 默认隐藏，≤768px 显示 */
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
  background: var(--surface);
  border-top: 1px solid var(--border);
  justify-content: space-around;
  height: 56px;
  box-shadow: 0 -2px 8px rgba(20,30,60,.08);
}
.bn-item {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  flex: 1; color: var(--text-3); font-size: 0; /* 隐藏文字，用子元素显示 */
  transition: color .15s; padding: 6px 0;
  border: none; background: none; cursor: pointer;
  min-height: 44px; /* 触控友好 */
}
.bn-item.active { color: var(--primary); }
.bn-icon { font-size: 20px; line-height: 1; }
.bn-label { font-size: 10px; font-weight: 500; line-height: 1; }

/* ====== FAB（移动端浮动操作按钮）====== */
.fab-backdrop {
  display: none; position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.3);
}
.fab-backdrop.show { display: block; }
.fab-container {
  display: none; position: fixed; z-index: 85;
  bottom: 76px; right: 20px;
}
.fab-main {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 26px; border: none; cursor: pointer;
  box-shadow: 0 4px 16px rgba(79,140,255,.4);
  transition: transform .2s; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.fab-main.open { transform: rotate(45deg); }
.fab-menu {
  position: absolute; bottom: 64px; right: 4px;
  display: flex; flex-direction: column; gap: 10px;
  opacity: 0; transform: translateY(10px);
  pointer-events: none; transition: all .2s;
}
.fab-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.fab-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 24px;
  background: var(--surface); color: var(--text);
  border: none; cursor: pointer; box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  -webkit-tap-highlight-color: transparent; min-height: 44px;
}
.fab-item:active { background: var(--surface-2); }
.fab-item-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ====== 移动端更多菜单 ====== */
.more-menu {
  position: fixed; top: 56px; right: 8px; z-index: 95;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 160px;
  display: flex; flex-direction: column; padding: 6px;
}
.more-menu.hidden { display: none; }
.more-menu button {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; border: none; background: none;
  font-size: 14px; color: var(--text); cursor: pointer;
  border-radius: var(--radius-sm); white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.more-menu button:hover { background: var(--surface-2); }
.more-menu button:active { background: var(--border); }

/* ====== 顶栏元素显隐 ====== */
.topbar-desktop { display: inline-flex; }
.topbar-mobile { display: none; }

/* ====== 待办筛选横向滚动 ====== */
.filter-row {
  display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

/* ====== 响应式 ====== */

/* ---------- 大屏 1400+：宽松布局 ---------- */
@media (min-width: 1400px) {
  .layout { grid-template-columns: 1fr 500px; padding: 24px; gap: 24px; }
  .cal-grid { padding: 8px 14px 14px; }
  .cal-header { padding: 18px 24px; }
  .month-label { font-size: 20px; }
  .side-panel { border-radius: var(--radius); }
}

/* ---------- 笔记本 1025-1399：默认 ---------- */
/* （使用根级 CSS，无需额外覆盖） */

/* ---------- 平板横屏 769-1024：紧凑双栏 ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr 340px; gap: 12px; padding: 12px; }
  .cal-grid { padding: 2px 6px 6px; gap: 1px; }
  .cal-header { padding: 12px 16px; }
  .month-label { font-size: 16px; }
  .cal-cell { padding: 4px 5px; }
  .cal-cell .date-num { font-size: 12px; }
  .cal-cell .lunar-date,
  .cal-cell .lunar-term,
  .cal-cell .lunar-festival { font-size: 9px; }
  .cal-cell .event-tag { font-size: 9px; padding: 0 3px; }
  .day-overview { padding: 10px 16px; max-height: 150px; }
}

/* ---------- 平板竖屏 ≤768：单栏视图，上下堆叠 ---------- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr; gap: 12px; padding: 10px;
    height: auto; overflow: visible;
  }
  .calendar-panel { min-height: 420px; flex: none; }
  .side-panel { min-height: 450px; flex: none; }
  .cal-grid { grid-auto-rows: 55px; }
  body { overflow-y: auto; }
  .cal-cell .date-num { font-size: 12px; }
  .cal-cell .lunar-date,
  .cal-cell .lunar-term,
  .cal-cell .lunar-festival { font-size: 9px; white-space: nowrap; overflow: hidden; }
  .cal-cell .event-tag { font-size: 9px; }
  /* 顶栏精简 */
  .topbar { padding: 0 12px; }
  .brand .title { font-size: 15px; }
  .btn { padding: 6px 10px; font-size: 12px; }
  /* 桌面按钮隐藏，移动端替代出现 */
  .topbar-desktop { display: none; }
  .topbar-mobile { display: inline-flex; }
  /* 底部导航 + FAB 出现 */
  .bottom-nav { display: flex; }
  .fab-container { display: block; }
  body { padding-bottom: 60px; }
  .tab-content { max-height: none; }
  /* hover 浮层禁用 */
  .cell-tooltip { display: none !important; }
}

/* ---------- 手机横屏 ≤600：紧凑 ---------- */
@media (max-width: 600px) {
  .layout { padding: 6px; gap: 8px; }
  .calendar-panel { min-height: 380px; }
  .side-panel { min-height: 400px; }
  .cal-grid { grid-auto-rows: 48px; }
  .cal-header { padding: 10px 12px; }
  .cal-cell { padding: 2px 3px; }
  .cal-cell .date-num { font-size: 11px; margin-bottom: 0; }
  .cal-cell .lunar-date,
  .cal-cell .lunar-term,
  .cal-cell .lunar-festival { font-size: 8px; }
  .cal-cell .event-tag { font-size: 7px; padding: 0 2px; }
  .cal-cell .dots { gap: 1px; }
  .cal-cell .dot { width: 4px; height: 4px; }
  .day-overview { padding: 8px 12px; max-height: 120px; }
  .pane-toolbar { flex-direction: column; gap: 6px; }
  .pane-toolbar .input,
  .pane-toolbar .select { width: 100%; }
  .dt-input, .date-input { width: 100% !important; }
  .brand .title { display: none; }
  .tabs { font-size: 13px; }
  .tab { padding: 10px; }
  /* 弹窗全屏 */
  .modal-card {
    width: 100%; height: 100%; max-width: none; max-height: none;
    border-radius: 0;
  }
  .modal-body { flex: 1; }
  .modal-footer { padding: 10px 16px; }
  /* 底部导航缩小 */
  .bn-item { padding: 4px 0; }
  .bn-icon { font-size: 18px; }
  .bn-label { font-size: 10px; }
  /* FAB 缩小 */
  .fab-main { width: 46px; height: 46px; font-size: 22px; }
  .fab-container { bottom: 66px; right: 14px; }
  .fab-item { font-size: 12px; padding: 8px 14px; }
  /* 日历格子只显示圆点 */
  .cal-cell .event-tag { font-size: 7px; padding: 0 2px; }
}

/* ---------- 小手机竖屏 ≤400：极限紧凑 ---------- */
@media (max-width: 400px) {
  .calendar-panel { min-height: 320px; border-radius: var(--radius-sm); }
  .side-panel { min-height: 350px; border-radius: var(--radius-sm); }
  .cal-grid { grid-auto-rows: 42px; }
  .cal-cell { padding: 1px 2px; }
  .cal-cell .date-num { font-size: 10px; }
  .cal-cell .lunar-date,
  .cal-cell .lunar-term,
  .cal-cell .lunar-festival { font-size: 7px; }
  .cal-cell .event-tag { display: none; }
  .cal-weekdays { font-size: 10px; padding: 4px 6px; }
  .topbar { height: 44px; padding: 0 8px; }
  .topbar-actions .btn { font-size: 11px; padding: 4px 8px; }
  .tab-pane { padding: 10px; }
  .list-item { padding: 8px 10px; }
  .input, .select { padding: 6px 8px; font-size: 13px; }
}

/* ---------- 大屏竖屏（如 Surface）特殊处理 ---------- */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
  .layout { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cal-grid { grid-auto-rows: 50px; }
}

/* ====== 深色模式 ====== */
[data-theme="dark"] {
  --bg: #1a1d29;
  --surface: #252836;
  --surface-2: #2e3345;
  --border: #3a3f52;
  --text: #e8eaed;
  --text-2: #a0a5b8;
  --text-3: #6b7085;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}
/* 自动跟随系统 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1d29;
    --surface: #252836;
    --surface-2: #2e3345;
    --border: #3a3f52;
    --text: #e8eaed;
    --text-2: #a0a5b8;
    --text-3: #6b7085;
    --shadow: 0 2px 8px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
  }
}

/* ====== 导出格式选择浮层 ====== */
.export-menu {
  position: fixed;
  z-index: 1200;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
}
.export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
}
.export-menu button:hover { background: var(--surface-2); }
