/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --card: #FFFFFF;
  --card-hover: #F5F5F5;
  --border: #E8E8E8;
  --text: #111111;
  --text-sub: #555555;
  --text-muted: #AAAAAA;
  --nav-bg: #111111;
  --nav-text: rgba(255,255,255,0.5);
  --nav-active: #FFFFFF;
  --overdue: #DC2626;
  --upcoming: #F59E0B;
  --done: #16A34A;
  --priority-high: #DC2626;
  --priority-medium: #3B82F6;
  --priority-low: #94A3B8;
  --accent: #111111;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --transition: 0.18s ease;
}

html {
  font-size: 16px;
  /* 讓 CSS 可以讀取 safe-area-inset-bottom，供 JS 參考 */
  --sab: env(safe-area-inset-bottom, 0px);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* iOS safe area */
  padding-top: env(safe-area-inset-top);
}

#app { min-height: 100vh; }

/* ─── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 20px 16px 170px;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Top Bar ───────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #111111;
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar .logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #FFFFFF;
}

.top-bar .logo span { color: rgba(255,255,255,0.4); }

.top-bar .user-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #FFFFFF;
  transition: var(--transition);
}
.top-bar .user-avatar:hover { background: rgba(255,255,255,0.2); }

/* ─── Bottom Navigation ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #111111;
  border-top: none;
  display: flex;
  padding: 10px 0 calc(env(safe-area-inset-bottom, 0px) + 8px);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  cursor: pointer;
  transition: var(--transition);
  color: rgba(255,255,255,0.38);
  font-size: 0.625rem;
  font-weight: 500;
  border: none;
  background: none;
  letter-spacing: 0.2px;
}
.nav-item i { font-size: 1.15rem; }
.nav-item.active { color: #FFFFFF; }
.nav-item:hover { color: rgba(255,255,255,0.7); }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
}

.card-sm {
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius-sm);
  padding: 16px;
}

/* ─── Overview Cards ─────────────────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.overview-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: default;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.overview-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.10); }
.overview-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.overview-card.overdue::after { background: var(--overdue); }
.overview-card.upcoming::after { background: var(--upcoming); }
.overview-card.done::after { background: var(--done); }

.overview-card .count {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.overview-card .label {
  font-size: 0.6rem;
  color: var(--text-sub);
  font-weight: 500;
  line-height: 1.3;
}

.overview-card.overdue .count { color: var(--overdue); }
.overview-card.upcoming .count { color: var(--upcoming); }
.overview-card.done .count { color: var(--done); }

/* ─── Filter Tabs ─────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-sub);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.filter-btn:hover { border-color: #AAAAAA; color: var(--text); }
.filter-btn.active {
  background: #111111;
  color: #FFFFFF;
  border-color: #111111;
}

/* ─── View Toggle ─────────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.view-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
}
.view-btn.active { background: #111111; color: #FFFFFF; border-color: #111111; }

/* ─── Task Cards ─────────────────────────────────────────────── */
.tasks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 16px 20px;   /* extra left for side stripe */
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.task-card:hover {
  border-color: #CCCCCC;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
}

.task-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: 16px 0 0 16px;
  background: var(--border);
}
.task-card.priority-high::before  { background: var(--priority-high); }
.task-card.priority-medium::before { background: var(--priority-medium); }
.task-card.priority-low::before   { background: var(--priority-low); }

/* Overdue card gets a faint red tint */
.task-card.overdue-card {
  background: #FFF5F5;
  border-color: rgba(220,38,38,0.18);
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.task-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
  word-break: break-word;
}
.task-card.done-task .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.priority-dot.high   { background: var(--priority-high); }
.priority-dot.medium { background: var(--priority-medium); }
.priority-dot.low    { background: var(--priority-low); }

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* List view task card */
/* ─── Swipe-to-Complete Task Cards ───────────────────────────── */
.task-swipe-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
}
.task-swipe-bg {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
}
/* 右滑背景（完成/重開，顯示在右側） */
.task-swipe-bg-done {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: 20px;
  background: #22C55E;
  color: #fff; font-weight: 700; font-size: 0.875rem;
  opacity: 0; border-radius: 12px;
  z-index: 0;
}
/* 左滑背景（優先度，顯示在左側，靠右對齊） */
.task-swipe-bg-left {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 20px;
  color: #fff; font-weight: 700; font-size: 0.875rem;
  opacity: 0; border-radius: 12px;
  z-index: 0;
  background: #F59E0B;
}
.task-swipe-card {
  position: relative; z-index: 1;
  will-change: transform;
  border-radius: 12px;
  margin-bottom: 0;
  touch-action: pan-y;
}

/* ─── Done Section (已完成任務折疊區塊) ──────────────────────────── */
.done-section {
  margin-top: 20px;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.done-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  background: #F8FAFC;
  border-bottom: 1px solid transparent;
  user-select: none;
  transition: background 0.15s;
}
.done-section-header:hover { background: #F1F5F9; }
.done-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}
.done-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: #22C55E;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}
.done-section-chevron {
  color: #9CA3AF;
  transition: transform 0.25s ease;
  font-size: 0.85rem;
}
.done-section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
}
.done-section-body.open {
  max-height: 9999px;
  border-top: 1px solid #F0F0F0;
}
.done-section-body .tasks-list {
  padding: 8px 0 4px;
}
.done-section-body .task-swipe-wrap {
  margin: 0 8px 6px;
}

.task-card.list-card {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 20px;
}

.task-card.list-card .task-card-body {
  flex: 1;
  min-width: 0;
}
.task-card.list-card .task-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Tags / Badges ──────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tag-category {
  background: #F3F4F6;
  color: #555555;
  border: 1px solid #E5E5E5;
}

.tag-status {
  border: 1px solid transparent;
}
.tag-status.pending {
  background: #F3F4F6;
  color: #666666;
  border-color: #E5E5E5;
}
.tag-status.in_progress {
  background: #EEF2FF;
  color: #4338CA;
  border-color: #C7D2FE;
}
.tag-status.done {
  background: #DCFCE7;
  color: #15803D;
  border-color: #BBF7D0;
}

/* ─── Due Date ──────────────────────────────────────────────── */
.due-date {
  font-size: 0.75rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 4px;
}
.due-date.overdue  { color: var(--overdue); font-weight: 700; }
.due-date.upcoming { color: var(--upcoming); font-weight: 600; }

/* ─── Progress Bar ──────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.progress-bar {
  height: 3px;
  background: #E5E5E5;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: #111111;
  transition: width 0.4s ease;
}
.progress-fill.done { background: var(--done); }
.progress-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: right;
}

/* ─── Quick Add ──────────────────────────────────────────────── */
.quick-add-bar {
  position: fixed;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  padding: 0 14px 8px;
  z-index: 101;
  pointer-events: none;
  /* iOS 鍵盤修復：硬體加速 + 平滑過渡 */
  will-change: bottom;
  transition: bottom 0.2s ease;
  /* 確保 iOS Safari 不會因 fixed 定位產生疊加問題 */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.quick-add-inner {
  max-width: 768px;
  margin: 0 auto;
  pointer-events: all;
}

.quick-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  backdrop-filter: blur(12px);
}

.quick-add-form input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #111111;
  font-size: 0.9375rem;
}
.quick-add-form input::placeholder { color: #AAAAAA; }

.quick-add-form button {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #111111;
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  transition: var(--transition);
}
.quick-add-form button:hover { opacity: 0.8; }

/* 快速新增分類浮層 */
.quick-cat-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  max-width: 220px;
  background: #fff;
  border: 1px solid #E5E5E5;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  z-index: 200;
  overflow: hidden;
  max-height: 260px;
  overflow-y: auto;
}
.qcd-item {
  padding: 9px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
  transition: background 0.12s;
}
.qcd-item:hover, .qcd-item.selected { background: #F3F4F6; }
.qcd-item.selected { font-weight: 600; color: #3B82F6; }
.qcd-new { border-top: 1px solid #F0F0F0; margin-top: 2px; }

.quick-add-options {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 6px;
  gap: 10px;
  box-shadow: var(--shadow);
}
.quick-add-options.open { display: flex; flex-wrap: wrap; }

.quick-opt-label { font-size: 0.75rem; color: var(--text-sub); width: 100%; }

/* ─── Auth Page ──────────────────────────────────────────────── */
/* ─── Auth Page ──────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #0f0f1a 0%, #1a1a2e 40%, #16213e 70%, #0f3460 100%);
  position: relative;
  overflow: hidden;
}

/* Decorative blobs */
.auth-bg-decor { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.15;
}
.auth-blob-1 {
  width: 400px; height: 400px;
  background: #3B82F6;
  top: -100px; left: -100px;
  animation: blobFloat 8s ease-in-out infinite;
}
.auth-blob-2 {
  width: 300px; height: 300px;
  background: #8B5CF6;
  bottom: -80px; right: -80px;
  animation: blobFloat 10s ease-in-out infinite reverse;
}
.auth-blob-3 {
  width: 200px; height: 200px;
  background: #06B6D4;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  animation: blobFloat 12s ease-in-out infinite;
}
@keyframes blobFloat {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(20px,-15px) scale(1.05); }
  66% { transform: translate(-10px,20px) scale(0.95); }
}

/* Brand section above card */
.auth-brand {
  text-align: center;
  margin-bottom: 32px;
  z-index: 1;
}
.auth-brand-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6);
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 32px rgba(59,130,246,0.4);
  font-size: 2rem;
  color: #fff;
}
.auth-brand-name {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -1.5px;
  color: #FFFFFF;
  margin-bottom: 6px;
}
.auth-brand-sub {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.3px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255,255,255,0.97);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  z-index: 1;
}

/* Input icon wrapper */
.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon-wrap input {
  padding-left: 38px !important;
}
.input-icon {
  position: absolute;
  left: 12px;
  color: #AAAAAA;
  font-size: 0.875rem;
  pointer-events: none;
  z-index: 1;
}
.input-eye-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #AAAAAA;
  cursor: pointer;
  padding: 4px;
  font-size: 0.875rem;
  line-height: 1;
}
.input-eye-btn:hover { color: #555; }

/* Remember me checkbox */
.remember-me-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-sub);
  cursor: pointer;
  margin-top: 4px;
}
.remember-me-row input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: #111111;
  cursor: pointer;
}

/* ─── Form Elements ──────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-sub);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  background: #F9FAFB;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #111111;
  font-size: 0.9375rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box; /* 確保padding不撐出寬度 */
  max-width: 100%;
  font-family: inherit;
}

/* 全天行程 checkbox row */
.allday-row {
  margin-bottom: 14px;
}
.allday-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  user-select: none;
}
.allday-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #111;
  margin: 0;
}
.allday-label span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-sub);
  line-height: 1;
}
.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #999999;
  background: #FFFFFF;
}
.form-group select option { background: #FFFFFF; }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: #111111;
  color: #FFFFFF;
  width: 100%;
}
.btn-primary:hover { background: #333333; }

.btn-secondary {
  background: #F3F4F6;
  color: #555555;
  border: 1px solid #E5E5E5;
}
.btn-secondary:hover { border-color: #AAAAAA; color: #111111; background: #EBEBEB; }

.btn-danger {
  background: rgba(255,68,68,0.1);
  color: var(--overdue);
  border: 1px solid rgba(255,68,68,0.3);
}
.btn-danger:hover { background: rgba(255,68,68,0.2); }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #F3F4F6;
  border: 1px solid #E5E5E5;
  color: #666666;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
}
.btn-icon:hover { border-color: #AAAAAA; color: #111111; background: #EBEBEB; }

/* ─── Auth Tab Toggle ────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  background: #F3F4F6;
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: #888888;
  transition: var(--transition);
  border: none;
  background: transparent;
}
.auth-tab.active {
  background: #FFFFFF;
  color: #111111;
}

/* ─── Section Header ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 1rem; font-weight: 700; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow: hidden; /* 防止overlay造成body橫向滾動 */
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-sheet {
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 768px;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: hidden; /* 防止內容橫向溢出 */
  padding: 24px 16px 32px; /* 左右縮小一點避免撐出 */
  box-sizing: border-box;
  transform: translateY(40px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #F3F4F6;
  border: 1px solid #E5E5E5;
  color: #666666;
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}
.modal-close:hover { color: #111111; background: #EBEBEB; }

/* ─── Modal Actions (底部按鈕，垂直排列，全寬) ──────────────── */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.modal-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 0.95rem;
}

/* ─── Task Detail Actions (垂直排列) ──────────────────────────── */
.task-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.task-detail-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 11px;
}
.task-share-btn {
  border-color: #3B82F6 !important;
  color: #3B82F6 !important;
}
.task-share-btn:hover {
  background: #EFF6FF !important;
}

/* ─── Task Share Preview (in modal) ───────────────────────────── */
.task-share-preview {
  background: #F9FAFB;
  border: 1px solid #E5E5E5;
  border-radius: 10px;
  padding: 12px 14px;
}
.task-share-preview-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
}
.task-share-preview-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ─── Task Detail Page ───────────────────────────────────────── */
.task-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.task-detail-header h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.back-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #F3F4F6;
  border: 1px solid #E5E5E5;
  color: #666666;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.back-btn:hover { color: #111111; background: #EBEBEB; }

.task-detail-card {
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
  font-size: 0.8125rem;
  color: var(--text-sub);
  width: 80px;
  flex-shrink: 0;
  padding-top: 2px;
}
.detail-value { flex: 1; font-size: 0.9375rem; }

/* ─── Progress Slider ────────────────────────────────────────── */
.progress-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-slider {
  -webkit-appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: #E5E5E5;
  outline: none;
}
.progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #111111;
  cursor: pointer;
  border: 2px solid #FFFFFF;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.progress-num { font-size: 0.875rem; color: var(--text-sub); width: 36px; text-align: right; }

/* ─── Calendar ───────────────────────────────────────────────── */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.cal-nav {
  display: flex; align-items: center; gap: 8px;
}
.cal-nav button {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  color: #666666;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem;
  transition: var(--transition);
}
.cal-nav button:hover { color: #111111; background: #F3F4F6; }

.cal-title { font-size: 1.05rem; font-weight: 700; color: #111111; }

.cal-view-toggle {
  display: flex;
  background: #F3F4F6;
  border: 1px solid #E5E5E5;
  border-radius: 8px;
  padding: 2px;
}
.cal-view-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #888888;
  transition: var(--transition);
}
.cal-view-btn.active { background: #111111; color: #FFFFFF; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 16px;
  /* 防止格子撐爆容器 */
  min-width: 0;
  width: 100%;
}

.cal-weekday {
  text-align: center;
  font-size: 0.625rem;
  color: #888888;
  font-weight: 600;
  padding: 6px 0 4px;
}

.cal-day {
  background: #FFFFFF;
  border: 1px solid #EEEEEE;
  border-radius: 8px;
  padding: 4px;
  /* 固定高度：數字行 + 最多2條 pill + more，不讓格子高度不一致造成重疊 */
  min-height: 64px;
  max-height: 90px;
  overflow: hidden;          /* 超出部分截掉，不撐開格子 */
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.cal-day:hover { border-color: #AAAAAA; }
.cal-day.today {
  border-color: #111111;
  background: #FAFAFA;
}
.cal-day.today .cal-day-num {
  background: #111111;
  color: #FFFFFF;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cal-day.other-month { opacity: 0.35; pointer-events: none; }
.cal-day-num {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1;
  flex-shrink: 0;
}

/* 節日標籤：非常小，只顯示節日名，不換行 */
.cal-holiday-label-inline {
  font-size: 0.5rem;
  color: #E53E3E;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-bottom: 1px;
  flex-shrink: 0;
}

.cal-task-dot {
  font-size: 0.55rem;
  padding: 1px 3px;
  border-radius: 3px;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: #F0F0F0;
  color: #555555;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1.4;
}
.cal-task-dot.priority-high   { background: rgba(220,38,38,0.12);  color: var(--priority-high); }
.cal-task-dot.priority-medium { background: rgba(59,130,246,0.12);  color: var(--priority-medium); }
.cal-task-dot.priority-low    { background: rgba(148,163,184,0.12); color: var(--priority-low); }

/* Calendar event pill (colored) */
.cal-event-pill {
  font-size: 0.55rem;
  padding: 1px 3px;
  border-radius: 3px;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #FFFFFF;
  cursor: pointer;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1.4;
}
.cal-more {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: right;
  padding-top: 0;
  margin-top: auto;
  flex-shrink: 0;
}

/* Upcoming events below calendar */
.upcoming-event-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #FFFFFF;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid #EEEEEE;
  cursor: pointer;
  transition: var(--transition);
}
.upcoming-event-item:hover { border-color: #AAAAAA; box-shadow: var(--shadow-sm); }
.upcoming-event-color {
  width: 4px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
}
.upcoming-event-body { flex: 1; }
.upcoming-event-title { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.upcoming-event-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.upcoming-today-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: #111111;
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* Day detail modal items */
.day-detail-event {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #FAFAFA;
  cursor: pointer;
  transition: var(--transition);
}
.day-detail-event:hover { background: #F0F0F0; }
.day-detail-task {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #FAFAFA;
  border: 1px solid #EEEEEE;
  cursor: pointer;
  transition: var(--transition);
}
.day-detail-task:hover { background: #F0F0F0; }

/* ─── Week View: 垂直大格清單 ────────────────────────────────── */
.week-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week-list-day {
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid #EEEEEE;
  overflow: hidden;
  transition: var(--transition);
}
.week-list-day.today {
  border-color: #111;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.week-list-day.empty {
  opacity: 0.6;
}

.week-list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  background: #FAFAFA;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}
.week-list-day.today .week-list-header {
  background: #111;
}
.week-list-day:not(.empty) .week-list-header {
  border-bottom-color: #F0F0F0;
}
.week-list-header:hover { background: #F0F0F0; }
.week-list-day.today .week-list-header:hover { background: #1a1a1a; }

.week-list-date-col {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
  min-width: 72px;
}
.week-list-weekname {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.week-list-weekname.today { color: rgba(255,255,255,0.7); }
.week-list-daynum {
  font-size: 1.35rem;
  font-weight: 800;
  color: #111;
  line-height: 1;
}
.week-list-daynum.today { color: #fff; }

.week-list-summary {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.week-today-badge {
  background: #3B82F6;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.week-holiday-badge {
  background: #FEF3C7;
  color: #92400E;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}
.week-empty-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.week-count-hint {
  font-size: 0.75rem;
  color: var(--text-sub);
  font-weight: 600;
}
.week-list-add {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  cursor: pointer;
}
.week-list-add:hover { background: #E5E7EB; color: #111; }
.week-list-day.today .week-list-add { color: rgba(255,255,255,0.6); }
.week-list-day.today .week-list-add:hover { background: rgba(255,255,255,0.15); color: #fff; }

.week-list-events,
.week-list-tasks {
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.week-list-tasks { padding-top: 0; }

.week-list-event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #F8F9FB;
  border-left: 3px solid #3B82F6;
  cursor: pointer;
  transition: var(--transition);
}
.week-list-event-item:hover { background: #EEF0F5; }

.week-list-event-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.week-list-task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #FAFAFA;
  border: 1px solid #EEEEEE;
  cursor: pointer;
  transition: var(--transition);
}
.week-list-task-item:hover { background: #F0F0F0; border-color: #DDD; }
.week-list-task-item.priority-high { border-left: 3px solid #DC2626; }
.week-list-task-item.priority-medium { border-left: 3px solid #3B82F6; }
.week-list-task-item.priority-low { border-left: 3px solid #10B981; }
.week-list-task-item.done { opacity: 0.55; }

.week-list-task-check {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #D1D5DB;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem;
  color: #fff;
  margin-top: 1px;
}
.week-list-task-check.checked {
  background: #10B981;
  border-color: #10B981;
}

.week-list-item-body {
  flex: 1;
  min-width: 0;
}
.week-list-item-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.week-list-item-title.done {
  text-decoration: line-through;
  color: var(--text-muted);
}
.week-list-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Settings Page ──────────────────────────────────────────── */
.settings-section {
  margin-bottom: 24px;
}

/* Email 提醒區塊 */
.settings-email-block {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}
.settings-email-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-email-time {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #BFDBFE;
  flex-wrap: wrap;
}

.settings-ical-block {
  background: linear-gradient(135deg, #EFF6FF, #F0FDF4);
  border: 1px solid #BFDBFE;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}

.settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.settings-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.settings-row-icon {
  width: 36px; height: 36px;
  background: #F3F4F6;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #666666;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.settings-row-text { flex: 1; }
.settings-row-title { font-size: 0.9375rem; font-weight: 500; }
.settings-row-sub { font-size: 0.8125rem; color: var(--text-sub); margin-top: 2px; }

/* ─── Toggle Switch ──────────────────────────────────────────── */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #DDDDDD;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: #111111; }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #FFFFFF;
}

/* ─── Category Tree ──────────────────────────────────────────── */
.cat-tree-node {
  position: relative;
}
.cat-tree-node + .cat-tree-node {
  margin-top: 4px;
}
.cat-tree-node .cat-tree-node {
  border-left: 2px solid #E5E5E5;
  margin-top: 4px;
  padding-left: 4px;
}
.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #FAFAFA;
  border: 1px solid #E8E8E8;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  transition: var(--transition);
}
.cat-item:hover { background: #F0F0F0; }
.cat-item-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cat-item-name { font-size: 0.9rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item-sub { font-size: 0.75rem; color: var(--text-muted); }

.btn-icon-sm {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  transition: var(--transition);
}
.btn-icon-sm:hover {
  background: rgba(17,17,17,0.08);
  color: #111111;
  border-color: #E5E5E5;
}

.cat-delete-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  transition: var(--transition);
}
.cat-delete-btn:hover {
  background: rgba(220,38,38,0.08);
  color: var(--overdue);
  border-color: rgba(220,38,38,0.25);
}

/* ─── Toast Notification ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #111111;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { border-color: #BBF7D0; }
.toast.error { border-color: #FECACA; }
.toast.warning { border-color: #FDE68A; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}
.empty-state i { font-size: 2.5rem; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; color: var(--text-sub); }
.empty-state p { font-size: 0.875rem; }

/* ─── Loading ────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  gap: 8px;
  font-size: 0.875rem;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text-sub);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Priority Selector ──────────────────────────────────────── */
.priority-selector {
  display: flex;
  gap: 8px;
}
.priority-opt {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #E5E5E5;
  background: #F9FAFB;
  color: #666666;
  cursor: pointer;
  font-size: 0.8125rem;
  text-align: center;
  transition: var(--transition);
}
.priority-opt.selected.high   { background: rgba(220,38,38,0.1);   color: var(--priority-high);   border-color: rgba(220,38,38,0.4); }
.priority-opt.selected.medium { background: rgba(59,130,246,0.1);  color: var(--priority-medium); border-color: rgba(59,130,246,0.4); }
.priority-opt.selected.low    { background: rgba(148,163,184,0.1); color: var(--priority-low);   border-color: rgba(148,163,184,0.4); }

/* ─── Invitation List ────────────────────────────────────────── */
.invite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #F9FAFB;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.invite-email { font-size: 0.9rem; }
.invite-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.invite-status.pending { background: rgba(255,184,0,0.1); color: var(--upcoming); }
.invite-status.accepted { background: rgba(68,255,136,0.1); color: var(--done); }

/* ─── Notification Badge ──────────────────────────────────────── */
.notif-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.notif-badge.overdue { background: rgba(255,68,68,0.1); color: var(--overdue); border: 1px solid rgba(255,68,68,0.2); }
.notif-badge.shared-ev-notif {
  background: rgba(59,130,246,0.08);
  color: #1d4ed8;
  border: 1px solid rgba(59,130,246,0.2);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s;
}
.notif-badge.shared-ev-notif:hover { background: rgba(59,130,246,0.14); }
@media (prefers-color-scheme: dark) {
  .notif-badge.shared-ev-notif { color: #93c5fd; border-color: rgba(59,130,246,0.3); background: rgba(59,130,246,0.12); }
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .tasks-grid { grid-template-columns: 1fr; }
  .overview-grid { gap: 8px; }
  .overview-card { padding: 12px; }
  .overview-card .count { font-size: 1.5rem; }
  .main-content { padding: 16px 12px 170px; }
  /* 月視圖：格子更緊湊 */
  .cal-grid { gap: 2px; }
  .cal-day { min-height: 56px; max-height: 80px; padding: 3px 2px; border-radius: 6px; }
  .cal-day-num { font-size: 0.65rem; }
  .cal-task-dot { display: none; } /* 手機月視圖隱藏任務 dot，只看行程 pill */
  .cal-event-pill { font-size: 0.5rem; padding: 1px 2px; }
  .cal-weekday { font-size: 0.55rem; padding: 4px 0 3px; }
}

@media (min-width: 600px) {
  .tasks-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Divider ────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ─── Profile Header ─────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.profile-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: #111111;
  border: 1px solid #E5E5E5;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}
.profile-name { font-size: 1.1rem; font-weight: 700; }
.profile-email { font-size: 0.875rem; color: var(--text-sub); margin-top: 3px; }

/* ─── Notification Popup ──────────────────────────────────────── */
.notif-popup {
  position: fixed;
  top: 70px;
  right: 16px;
  max-width: 320px;
  width: calc(100vw - 32px);
  background: #FFFFFF;
  border: 1px solid #E5E5E5;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 300;
  animation: fadeSlide 0.3s ease;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-icon { font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.notif-text { font-size: 0.8125rem; line-height: 1.4; }
.notif-text strong { font-weight: 600; }
.notif-time { font-size: 0.6875rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Push Notification Banner ────────────────────────────────── */
.push-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #111111;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  cursor: pointer;
  transition: var(--transition);
}
.push-banner:hover { background: #2a2a2a; }
.push-banner-text { flex: 1; }
.push-banner-title { font-size: 0.875rem; font-weight: 600; color: #FFFFFF; }
.push-banner-sub { font-size: 0.75rem; color: rgba(255,255,255,0.55); margin-top: 2px; }
.push-banner-icon { font-size: 1.2rem; flex-shrink: 0; }
.push-banner-btn {
  background: #FFFFFF;
  color: #111111;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Calendar page white bg ──────────────────────────────────── */
#page-content { background: transparent; }
.calendar-page-wrap { background: var(--bg); }

/* ─── Week num color fix ──────────────────────────────────────── */
.week-day-num { color: #111111; }
.week-day-col.today .week-day-num {
  background: #111111;
  color: #FFFFFF;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 2px auto 0;
  font-size: 0.9rem;
}

/* ─── Settings push row special ───────────────────────────────── */
.settings-push-enabled {
  background: #F0FDF4;
  border-color: #BBF7D0;
}

/* ─── Drag & Drop Sorting ──────────────────────────────────────── */

/* ─── Drag & Drop ─────────────────────────────────────────── */

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.task-card:hover .drag-handle,
.task-card.list-card:hover .drag-handle,
.cat-item:hover .drag-handle,
.cat-tree-node:hover > .cat-item .drag-handle {
  opacity: 0.6;
}
.drag-handle:hover { opacity: 1 !important; }
.drag-handle:active { cursor: grabbing; }

/* Category drag handle always slightly visible */
.cat-drag-handle {
  opacity: 0.3;
  font-size: 0.75rem;
  padding: 3px 5px;
}
.cat-item:hover .cat-drag-handle { opacity: 0.7; }

/* Ghost – floating copy that follows cursor */
.sortable-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.88;
  background: #FFFFFF;
  border: 1.5px solid rgba(0,0,0,0.12);
}

/* Placeholder – dashed area left where the dragged item was */
.sortable-holder {
  border-radius: 10px;
  background: rgba(0,0,0,0.04);
  border: 2px dashed #CCCCCC;
  flex-shrink: 0;
  transition: height 0.1s;
}

/* Tasks grid / list */
.tasks-grid .task-card,
.tasks-list .task-card { position: relative; }

/* swipe-wrap 在 grid/list 容器裡需要讓子 card 撐滿 */
.tasks-grid .task-swipe-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0;
}
.tasks-grid .task-swipe-wrap .task-card {
  margin-bottom: 0;
}

/* ─── Friends & Chat ─────────────────────────────────────────── */

/* Nav badge */
.nav-badge {
  position: absolute;
  top: 4px; right: 14px;
  background: #DC2626;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

/* Friend avatar */
.friend-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

/* Friends page */
.friends-page {
  padding: 16px;
  padding-bottom: 80px;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}
.page-title-row {
  margin-bottom: 16px;
}

/* ─── Friends QR Card ──────────────────────────────────────── */
.friends-qr-card {
  margin-bottom: 16px;
  text-align: center;
  padding: 20px 16px;
}
.friends-qr-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.friends-qr-canvas {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.friends-qr-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.friends-qr-token {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  font-family: monospace;
  word-break: break-all;
}

/* ─── Friends Scan Card ─────────────────────────────────────── */
.friends-scan-card {
  margin-bottom: 16px;
  padding: 16px;
}
.friends-add-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.friends-email-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
.friends-email-input {
  flex: 1;
  min-width: 0;
  background: #F9FAFB;
  border: 1px solid #E5E5E5;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.9rem;
  outline: none;
  color: #111;
  box-sizing: border-box;
  height: 38px;
}
.friends-email-input:focus {
  border-color: #111;
}
/* 搜尋按鈕緊湊，不搶輸入框空間 */
.friends-email-row .btn {
  flex-shrink: 0;
  flex-grow: 0;
  padding: 0 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  height: 38px;
  line-height: 38px;
  min-width: 0;
  width: auto;
}
.friends-scan-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.qr-scanner-box {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1;
}
.qr-scan-hint {
  text-align: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Friends Section Label ─────────────────────────────────── */
.friends-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.friends-badge {
  background: #111;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.friends-badge-gray {
  background: #E5E5E5;
  color: #666;
}

/* ─── Friend Item (垂直優先，不橫向溢出) ───────────────────── */
.friend-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #F3F4F6;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.friend-item:last-child {
  border-bottom: none;
}
.friend-item-clickable {
  cursor: pointer;
}
.friend-item-clickable:active {
  background: #F9FAFB;
  border-radius: 8px;
}
.friend-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.friend-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-status-tag {
  font-size: 0.72rem;
  margin-top: 3px;
}
.friend-status-tag.incoming { color: #3B82F6; }
.friend-status-tag.outgoing { color: #888; }

/* ─── Friend Action Buttons (垂直排列，右側欄位) ────────────── */
.friend-actions-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  align-items: stretch;
  min-width: 76px;
}
.friend-actions-col .btn {
  font-size: 0.75rem;
  padding: 5px 8px;
  white-space: nowrap;
  text-align: center;
  justify-content: center;
  width: 100%;
}
.friend-remove-btn {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 0;
  text-align: center;
  transition: color 0.15s;
}
.friend-remove-btn:hover { color: #DC2626; }

.unread-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #DC2626;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ─── Chat Page (Enhanced) ───────────────────────────────────── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;          /* 填滿父容器 main-content */
  min-height: 0;
  background: #F0F2F5;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(135deg, #111111 0%, #1a1a2e 100%);
  flex-shrink: 0;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.chat-back-btn {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.1) !important;
  border-color: rgba(255,255,255,0.15) !important;
  color: #fff !important;
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  font-weight: 700; font-size: 0.95rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-header-status {
  font-size: 0.7rem; color: rgba(255,255,255,0.5);
  display: flex; align-items: center; gap: 4px; margin-top: 1px;
}
.chat-online-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
  display: inline-block;
  vertical-align: middle;
  margin-right: 3px;
}
.chat-online-dot.offline {
  background: #9CA3AF;
  box-shadow: 0 0 0 2px rgba(156,163,175,0.3);
}

/* 好友列表頭像右下角的上線指示點 */
.friend-online-dot {
  position: absolute;
  bottom: 0; right: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--card);
}
.friend-online-dot.online  { background: #22C55E; }
.friend-online-dot.offline { background: #D1D5DB; }

.chat-header-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.chat-action-btn {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.1) !important;
  border-color: rgba(255,255,255,0.15) !important;
  color: rgba(255,255,255,0.9) !important;
}
.chat-action-btn:hover { background: rgba(255,255,255,0.25) !important; color: #fff !important; }

.chat-messages {
  flex: 1;
  min-height: 0;      /* 關鍵：讓flex子元素可以縮小，不撐爆父容器 */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-loading {
  display: flex; justify-content: center;
  padding: 40px 0; color: var(--text-muted);
}

.chat-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 8px;
}
.chat-date-divider span {
  background: rgba(0,0,0,0.1);
  color: #777;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Message row with avatar */
.chat-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 82%;
}
.chat-msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-row.theirs { align-self: flex-start; }

.chat-avatar-mini {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-bottom: 14px;
}
.chat-avatar-mini.mine { background: linear-gradient(135deg, #111, #444); }

.chat-msg-col { display: flex; flex-direction: column; gap: 2px; }

/* Bubbles */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
  overflow: hidden; /* 防止圖片撐爆氣泡 */
}
.chat-bubble img {
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: 8px;
  margin-bottom: 4px;
}
.chat-bubble.mine {
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.chat-bubble.theirs {
  background: #FFFFFF;
  color: #111;
  border: 1px solid #E5E5E5;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Share bubbles */
.share-bubble {
  background: #FFFFFF !important;
  border: 1px solid #E5E5E5 !important;
  color: #111 !important;
  padding: 12px 14px !important;
  min-width: 200px;
  border-radius: 14px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
}
.share-bubble-header {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.share-bubble-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 4px;
  color: #111;
}
.share-bubble-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.share-bubble-desc {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 4px;
}
.share-bubble-sent {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.chat-time {
  font-size: 0.62rem;
  color: var(--text-muted);
  padding: 0 4px;
}
.chat-time.mine { text-align: right; }

/* Chat input area */
.chat-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: #F0F2F5;
  border-radius: 24px;
  padding: 4px 4px 4px 14px;
  gap: 4px;
}
.chat-input-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 0.925rem;
  color: #111;
  outline: none;
  font-family: inherit;
  padding: 6px 0;
}
.chat-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.85rem;
  transition: var(--transition);
}
.chat-send-btn:hover { background: #333; }

/* 進入聊天頁：隱藏底部導航、頂部、讓內容填滿全螢幕 */
body.chat-open .bottom-nav    { display: none !important; }
body.chat-open .top-bar       { display: none !important; }
body.chat-open .quick-add-bar { display: none !important; }
body.chat-open .app-layout    { height: 100dvh; overflow: hidden; }
body.chat-open .main-content {
  padding: 0 !important;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── QR Scanner ─────────────────────────────────────────────── */
.qr-scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-scan-frame {
  width: 180px; height: 180px;
  border: 3px solid rgba(59,130,246,0.8);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
  position: relative;
}
.qr-scan-frame::before,
.qr-scan-frame::after {
  content: '';
  position: absolute;
  width: 28px; height: 28px;
  border-color: #3B82F6;
  border-style: solid;
}
.qr-scan-frame::before { top: -3px; left: -3px; border-width: 4px 0 0 4px; border-radius: 4px 0 0 0; }
.qr-scan-frame::after  { bottom: -3px; right: -3px; border-width: 0 4px 4px 0; border-radius: 0 0 4px 0; }
.qr-scan-line {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 160px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3B82F6, transparent);
  animation: qrScanAnim 2s ease-in-out infinite;
}
@keyframes qrScanAnim {
  0%, 100% { top: calc(50% - 80px); }
  50% { top: calc(50% + 80px); }
}

/* ─── Shared Calendar ────────────────────────────────────────── */
.cal-holiday-dot {
  font-size: 0.65rem;
  margin-left: 2px;
}
.cal-day.has-holiday .cal-day-num { color: #E53E3E; }

/* Color swatches for event color picker */
.color-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected {
  border-color: #111;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
  transform: scale(1.1);
}

/* ─── Home Hero Section ──────────────────────────────────────── */
.home-hero {
  position: relative;
  background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
  border-radius: 20px;
  padding: 22px 20px 16px;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.home-hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.home-hero-bg::before {
  content: '';
  position: absolute;
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(59,130,246,0.25) 0%, transparent 70%);
  top: -80px; right: -60px;
  animation: heroBlob1 8s ease-in-out infinite;
}
.home-hero-bg::after {
  content: '';
  position: absolute;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(139,92,246,0.2) 0%, transparent 70%);
  bottom: -50px; left: 20px;
  animation: heroBlob2 10s ease-in-out infinite reverse;
}
@keyframes heroBlob1 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(15px,-10px) scale(1.08); }
}
@keyframes heroBlob2 {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(-10px,15px) scale(1.05); }
}

.home-hero-content {
  position: relative;
  z-index: 1;
}
.home-hero-greeting {
  font-size: 1.2rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.home-hero-date {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 6px;
}
.home-hero-holiday {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.8);
  margin-bottom: 4px;
}

.home-hero-stats-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 10px 0;
}
.home-hero-stat {
  flex: 1;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
.home-hero-stat:hover { opacity: 0.8; }
.home-hero-stat-num {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 3px;
}
.home-hero-stat-label {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.45);
  font-weight: 500;
}
.home-hero-stat-divider {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* ─── Share Friend Group ──────────────────────────────────────── */
.share-friend-group {
  background: linear-gradient(135deg, #EFF6FF, #F5F3FF);
  border: 1px solid #DBEAFE;
  border-radius: 12px;
  padding: 12px 14px;
}
.share-friend-group label { color: #1D4ED8; font-weight: 600; }

/* ─── Chat Input Row ─────────────────────────────────────────── */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  position: relative; /* 不用 fixed，由 flex 自然排在底部 */
  z-index: 1;
}

/* 附件按鈕 */
.chat-attach-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #F0F2F5;
  border: none;
  color: #666;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}
.chat-attach-btn:hover { background: #E5E7EB; color: #111; }

/* ─── Chat date divider ──────────────────────────────────────── */
.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}
.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #E5E5E5;
}
.chat-date-divider span {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  background: #F7F8FA;
  padding: 2px 8px;
  border-radius: 999px;
}

/* ─── Chat online dot ────────────────────────────────────────── */
.chat-online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22C55E;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.3);
  animation: onlinePulse 2s ease infinite;
}
.chat-online-dot.offline {
  background: #9CA3AF;
  box-shadow: none;
  animation: none;
}
@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.3); }
  50% { box-shadow: 0 0 0 5px rgba(34,197,94,0.1); }
}



/* ─── 新增：filter group divider ─────────────────────────── */
.filter-group-divider {
  color: #D1D5DB;
  padding: 0 2px;
  align-self: center;
  font-size: 0.9rem;
  user-select: none;
}
.filter-btn-personal.active { background: #3B82F6; border-color: #3B82F6; }
.filter-btn-work.active     { background: #F59E0B; border-color: #F59E0B; }

/* ─── 新增：done-section-link ────────────────────────────── */
.done-section-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin-top: 20px;
  border-radius: 14px;
  background: #F8FAFC;
  border: 1px solid #E5E7EB;
  cursor: pointer;
  transition: background 0.15s;
}
.done-section-link:hover { background: #F1F5F9; }

/* ─── 新增：cat-color-btn ────────────────────────────────── */
.cat-color-btn {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ─── Home Tab Bar ───────────────────────────────────────── */
.home-tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 12px 0 4px;
  padding: 4px;
  background: #F3F4F6;
  border-radius: 14px;
}
.home-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6B7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.home-tab:hover { background: #E5E7EB; color: #374151; }
.home-tab.active {
  background: #fff;
  color: #1F2937;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}
.home-tab-personal.active { color: #3B82F6; }
.home-tab-work.active     { color: #F59E0B; }

.sub-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 2px 2px;
}
.sub-filter-row .filter-btn {
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* ─── Priority Icon Badge (replaces color tags) ──────────── */
.priority-icon-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
  cursor: pointer;
}
.priority-icon-high   { color: #DC2626; background: #FEE2E2; }
.priority-icon-medium { color: #D97706; background: #FEF3C7; }
.priority-icon-low    { color: #94A3B8; background: #F1F5F9; }

/* ─── Due Date Chip (replaces .due-date span) ────────────── */
.due-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: #F3F4F6;
  color: #6B7280;
  flex-shrink: 0;
}
.chip-overdue  { background: #FEE2E2; color: #DC2626; }
.chip-today    { background: #FEF3C7; color: #B45309; }
.chip-tomorrow { background: #DBEAFE; color: #1D4ED8; }
.chip-upcoming { background: #D1FAE5; color: #065F46; }

/* ─── Task category small label ──────────────────────────── */
.task-cat-label {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* ─── Friend Emoji Badge ─────────────────────────────────── */
.friend-emoji-badge {
  font-size: 1rem;
  line-height: 1;
}
.friend-emoji-btn {
  min-width: 36px;
  height: 32px;
  padding: 0 6px;
  border-radius: 8px;
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6B7280;
  font-weight: 600;
  white-space: nowrap;
}
.friend-emoji-btn:hover { background: #E5E7EB; }

/* ─── Emoji Picker Grid ──────────────────────────────────── */
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}
.emoji-pick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #F9FAFB;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.emoji-pick-btn:hover  { background: #E5E7EB; }
.emoji-pick-btn.selected { border-color: #3B82F6; background: #EFF6FF; }

/* ─── Bottom Nav 5 items ─────────────────────────────────── */
.bottom-nav { grid-template-columns: repeat(5, 1fr); }

/* ─── Swipe bg: right side for complete ─────────────────── */
.task-swipe-bg-done {
  right: 0;
  left: auto;
  border-radius: 0 14px 14px 0;
  justify-content: flex-start;
  padding-left: 18px;
}
.task-swipe-bg-left {
  left: 0;
  right: auto;
  border-radius: 14px 0 0 14px;
  justify-content: flex-end;
  padding-right: 18px;
}

/* ─── Category Tree Node – 重設計 ───────────────────────────── */
.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: #FAFAFA;
  border: 1px solid #EBEBEB;
  border-radius: 8px;
  margin-bottom: 3px;
  transition: background 0.12s;
  gap: 6px;
  min-height: 0;
}
.cat-item:hover { background: #F0F4FF; border-color: #DBEAFE; }

.cat-item-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.cat-item-name {
  font-size: 0.855rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* 顏色圓點按鈕 */
.cat-color-dot-btn {
  flex-shrink: 0;
  outline: none;
  transition: transform 0.12s;
}
.cat-color-dot-btn:hover { transform: scale(1.35); }

/* 封存標籤 */
.cat-archived-tag {
  font-size: 0.62rem;
  color: #9CA3AF;
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 操作按鈕區：預設僅 hover 顯示，RWD 小螢幕常駐 */
.cat-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.cat-item:hover .cat-item-actions,
.cat-tree-node:focus-within .cat-item-actions {
  opacity: 1;
}
/* 手機螢幕常駐顯示 */
@media (max-width: 480px) {
  .cat-item-actions { opacity: 1; }
}

/* 各操作按鈕統一樣式 */
.cat-act-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: #9CA3AF;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.cat-act-btn:hover { background: #E5E7EB; color: #374151; }
.cat-act-rename:hover { color: #3B82F6; background: #EFF6FF; }
.cat-act-add:hover    { color: #22C55E; background: #F0FDF4; }
.cat-act-archive:hover { color: #F59E0B; background: #FFFBEB; }
.cat-act-delete:hover  { color: #EF4444; background: #FEF2F2; }

/* ─── List Card – 截止日確保可見 ─────────────────────────────── */
/* 強制讓 task-card-body 不壓縮 due-chip */
.task-card.list-card .task-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* 優先度小圓點（取代大 priority-dot） */
.priority-dot-sm {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
}
.priority-dot-sm-high   { background: #EF4444; box-shadow: 0 0 0 2px #fee2e2; }
.priority-dot-sm-medium { background: #F59E0B; box-shadow: 0 0 0 2px #fef3c7; }
.priority-dot-sm-low    { background: #94A3B8; box-shadow: 0 0 0 2px #f1f5f9; }

/* ─── 分類更多操作選單 ──────────────────────────────────────────── */
.cat-act-more {
  color: #9CA3AF;
}
.cat-act-more:hover {
  background: #E5E7EB;
  color: #374151;
}
.cat-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 2px);
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 200;
  min-width: 130px;
  overflow: hidden;
  padding: 4px;
}
.cat-more-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  color: #374151;
  border-radius: 7px;
  transition: background 0.1s, color 0.1s;
  text-align: left;
  white-space: nowrap;
}
.cat-more-item:hover { background: #F3F4F6; }
.cat-more-item.cat-act-rename:hover { background: #EFF6FF; color: #2563EB; }
.cat-more-item.cat-act-archive:hover { background: #FFFBEB; color: #D97706; }
.cat-more-item.cat-act-delete:hover { background: #FEF2F2; color: #DC2626; }

/* cat-item-actions 需要 position:relative 才能讓下拉正確定位 */
.cat-item-actions {
  position: relative;
}

/* ─── 截止日 chip 確保顯示 ──────────────────────────────────────── */
.due-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  flex-shrink: 0;
  white-space: nowrap;
  background: #F3F4F6;
  color: #6B7280;
}

/* ─── ae-date-input（日期/時間輸入框統一樣式）────────────────────── */
.ae-date-input {
  width: 100%;
  min-width: 0;        /* 修復 grid 內溢出 */
  box-sizing: border-box;
  background: #F9FAFB;
  border: 1px solid #E5E5E5;
  border-radius: 8px;
  padding: 9px 8px;
  font-size: 0.8125rem; /* 縮小字體避免 iOS Safari 自動放大 */
  color: #111;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
  /* iOS Safari date/time input 特殊修正 */
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ae-date-input:focus { border-color: #999; background: #fff; }
/* 確保 grid 容器不溢出 */
.ae-date-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}
.ae-date-grid > div {
  min-width: 0;
  overflow: hidden;
}

/* ─── 好友動作按鈕列（圖示列 + 說明文字列）─────────────────────────── */
.friend-actions-col {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
}
.friend-act-btn {
  width: 34px !important;
  height: 34px;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.friend-act-labels {
  display: flex;
  gap: 4px;
  font-size: 0.58rem;
  color: #9CA3AF;
  white-space: nowrap;
}
.friend-act-labels span {
  width: 34px;
  text-align: center;
}

/* ─── ev-field-label（行程欄位小標籤）────────────────────────────── */
.ev-field-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
}

/* ─── 分類管理：深層名稱顯示修復 ──────────────────────────────────── */
.cat-item-name-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.cat-item-name {
  /* 允許換行（深層分類名稱不截斷） */
  white-space: normal !important;
  word-break: break-word;
  overflow: visible !important;
  text-overflow: unset !important;
  line-height: 1.3;
}
.cat-item-path-hint {
  font-size: 0.62rem;
  color: #9CA3AF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  line-height: 1.2;
}

/* ─── 跨天行程：連續色條效果（Google Calendar 風格）────────────────── */
/* 起始格：左圓角，顯示標題，右邊延伸 */
.cal-event-pill.pill-span-start {
  border-radius: 4px 0 0 4px;
  margin-right: -3px;     /* 與相鄰格子緊接 */
  padding-right: 2px;
  position: relative;
  z-index: 1;
}
/* 中間格：無圓角，無文字，色塊延伸 */
.cal-event-pill.pill-span-mid {
  border-radius: 0;
  margin-left: -3px;
  margin-right: -3px;
  padding: 1px 0;
  overflow: visible;
  font-size: 0;           /* 隱藏文字 */
  min-height: 10px;
}
/* 結尾格：右圓角，色塊延伸到最後 */
.cal-event-pill.pill-span-end {
  border-radius: 0 4px 4px 0;
  margin-left: -3px;
  padding-left: 2px;
  font-size: 0;           /* 隱藏文字，只顯示顏色 */
  min-height: 10px;
}
/* 手機小格子的跨天調整 */
@media (max-width: 480px) {
  .cal-event-pill.pill-span-start { margin-right: -2px; }
  .cal-event-pill.pill-span-mid   { margin-left: -2px; margin-right: -2px; }
  .cal-event-pill.pill-span-end   { margin-left: -2px; }
}

/* ─── 好友按鈕：每個按鈕獨立包含圖示 + 說明文字 ─────────────────────── */
/* 移除舊的整排標籤方式，改為每按鈕自帶標籤 */
.friend-act-labels { display: none !important; }  /* 停用舊標籤列 */

.friend-act-btns-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-wrap: nowrap;
}
.friend-act-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.friend-act-label-single {
  font-size: 0.55rem;
  color: #9CA3AF;
  white-space: nowrap;
  text-align: center;
  line-height: 1;
  display: block;
}
/* 調整 friend-remove-btn 大小與其他按鈕一致 */
.friend-act-btn-wrap .friend-remove-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid #F3F4F6;
  background: #F9FAFB;
}
/* 調整 friend-emoji-btn 大小一致 */
.friend-act-btn-wrap .friend-emoji-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
}
/* 讓 friend-act-btn 也統一 32px */
.friend-act-btn-wrap .friend-act-btn {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  flex-shrink: 0;
}

/* ─── 共同行事曆：防止溢出手機畫面 ──────────────────────────────────── */
/* page-content 裡的 div 全部限制寬度 */
#page-content > div {
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

