:root {
  color-scheme: light;
  --bg: #fbf7f2;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-soft: #fff6f1;
  --text: #23201d;
  --muted: #7a736c;
  --border: rgba(35, 25, 20, 0.10);
  --primary: #ff6b4a;
  --primary-strong: #e8492b;
  --secondary: #16a34a;
  --secondary-strong: #15803d;
  --accent-amber: #f59e0b;
  --accent-mint: #2dd4bf;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(35, 25, 20, 0.05), 0 8px 24px rgba(35, 25, 20, 0.07);
  --radius: 16px;
  --work: #3b82f6;
  --home: #fb923c;
  --study: #a855f7;
  --sport: #22c55e;
  --important: #ef4444;
  --joy: #eab308;
  --travel: #06b6d4;
}

body.dark {
  color-scheme: dark;
  --bg: #1a1614;
  --surface: #241f1c;
  --surface-strong: #241f1c;
  --surface-soft: #2b2420;
  --text: #f4ede8;
  --muted: #a89f97;
  --border: rgba(244, 237, 232, 0.14);
  --primary: #ff8566;
  --primary-strong: #ff6b4a;
  --secondary: #34d399;
  --secondary-strong: #22c55e;
  --accent-amber: #fbbf24;
  --accent-mint: #5eead4;
  --work: #60a5fa;
  --home: #fdba74;
  --study: #c084fc;
  --sport: #4ade80;
  --important: #f87171;
  --joy: #facc15;
  --travel: #22d3ee;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  padding: 22px;
  min-height: 100vh;
}

.sidebar, .main { min-width: 0; }
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), #10b981);
  font-size: 30px;
  box-shadow: var(--shadow);
}
/* 品牌大圖示改用自製 icons/icon.svg：原本放系統 emoji 📅，各平台 emoji 字型長相不一致
   （Windows 藍白格線、iOS 紅色 July 17），改成自家圖檔所有裝置才一致。 */
.brand-icon { background: none; box-shadow: none; }
.brand-icon img { display: block; width: 100%; height: 100%; }
.brand h1 { margin: 0; font-size: 25px; }
.brand p { margin: 4px 0 0; color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.compact { padding: 18px; }
.compact h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.primary-btn, .ghost-btn, .danger-btn, .icon-btn {
  border: 0;
  border-radius: 14px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.primary-btn {
  padding: 13px 18px;
  color: white;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(255, 107, 74, .28);
  font-weight: 700;
}
.primary-btn:hover { background: var(--primary-strong); transform: translateY(-1px); box-shadow: 0 10px 22px rgba(255, 107, 74, .34); }
.primary-btn:active { transform: translateY(0); }
.ghost-btn {
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
/* 導航列的年月日跳轉選擇器：外觀比照 ghost-btn，蓋掉全域 input width:100% 避免撐開版面 */
.date-jump {
  width: auto;
  flex: 0 0 auto;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
/* 選擇年月日按鈕的日曆圖示：自製 HTML+CSS（原本用系統 emoji 📅，各平台長相不一致，
   而且 emoji 上那個日期是字型寫死的、永遠換不掉）。月份／日期文字由 render() 依
   currentDate 更新，所以按了選日期之後圖示會跟著跳到選取那一天。 */
.date-icon {
  display: inline-grid;
  grid-template-rows: 10px 1fr;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .2);
  line-height: 1;
}
.date-icon-month {
  display: grid;
  place-items: center;
  background: #ef4444;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
}
.date-icon-day {
  display: grid;
  place-items: center;
  color: #1e293b;
  font-size: 13px;
  font-weight: 800;
}
#jumpDateBtn {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
}
/* 瀏覽器支援 showPicker() 時，把選擇器本體藏起來（仍需保持 rendered，不能 display:none），
   只留 📅 按鈕與點標題兩個入口，版面乾淨；不支援的舊瀏覽器則顯示小型輸入框當備援。 */
.date-jump.picker-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.calendar-nav { position: relative; }
.danger-btn {
  padding: 10px 14px;
  color: white;
  background: var(--danger);
}
.icon-btn {
  width: 38px;
  height: 38px;
  color: var(--text);
  background: transparent;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.calendar-nav, .toolbar-actions, .view-switch {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar-actions {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.calendar-nav h2 { margin: 0 0 0 8px; font-size: 28px; }
.lunar-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.weather-day-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.weather-day-text:empty { display: none; }
.view-switch {
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.view-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.view-btn:hover:not(.active) {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.view-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 2px 6px rgba(255, 107, 74, .30);
}

/* 桌面工具列六組下拉選單（app.js setupToolbarMenus()）：proxy 模式，原按鈕不搬不刪，
   只在桌面寬度用 .grouped-tool 隱藏原按鈕本體，選單項目由 JS 動態重建。 */
@media (min-width: 761px) {
  .toolbar-actions .grouped-tool { display: none !important; }
}
.toolbar-menu-wrap { position: relative; }
.toolbar-menu-btn.active {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface-strong));
  border-color: var(--primary);
}
.toolbar-menu {
  /* fixed（top/left 由 JS 依按鈕位置設定）：父層 .toolbar-actions 有 overflow:hidden
     （溢出偵測需要），absolute 會被裁切看不到，fixed 才能跳出裁切範圍。 */
  position: fixed;
  z-index: 200;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(44, 64, 105, .16), 0 2px 8px rgba(44, 64, 105, .08);
  animation: dialog-pop-in .16s ease-out;
}
body.dark .toolbar-menu {
  box-shadow: 0 10px 24px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
}
.toolbar-menu[hidden] { display: none; }
.toolbar-menu-item {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  font: inherit;
  white-space: nowrap;
}
.toolbar-menu-item:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
/* D-W4：下拉選單內的子分組分隔小標題（模式／分析／設定）。非首列時上加細線做群組分界；
   若該段成員全隱藏，renderToolbarMenuItems 會整條略過（不會出現孤兒標題）。 */
.toolbar-menu-heading {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--muted);
}
.toolbar-menu-heading:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
@media (max-width: 760px) {
  .toolbar-menu-wrap { display: none !important; }
}

.controls {
  display: grid;
  grid-template-columns: 1fr 170px 160px 150px;
  gap: 14px;
  padding: 16px;
}
.daily-memo { padding: 16px; }
.daily-memo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.daily-memo h3 { margin: 0; font-size: 16px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field[hidden] { display: none; }
.field.full { grid-column: 1 / -1; }
/* 事項名稱欄位：輸入框＋語音輸入鈕同列（voiceInputBtn 不支援的瀏覽器會被 JS 整顆 remove，
   這裡的 flex 版型在按鈕不存在時 input 自然佔滿整列，不會跑版）。 */
.title-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.title-input-row input { flex: 1; min-width: 0; }
.title-input-row .icon-btn {
  flex-shrink: 0;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.nl-hint { margin: 2px 0 0; font-size: 12px; }
/* 結束時間欄位旁的「⚡ 找空檔」鈕：版型比照 title-input-row（輸入框＋圖示鈕同列）。 */
.time-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-input-row input { flex: 1; min-width: 0; }
.time-input-row .icon-btn {
  flex-shrink: 0;
  width: auto;
  padding: 0 10px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

/* 批量新增 dialog：textarea＋解析預覽表格＋動作列，沿用 task-dialog 外觀（含手機懸浮置中）。 */
.batch-add-preview-wrap {
  margin: 4px 0 14px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.batch-add-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.batch-add-table th, .batch-add-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.batch-add-table th { color: var(--muted); font-weight: 700; background: var(--surface); }
.batch-add-table tr:last-child td { border-bottom: 0; }
.batch-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.checkbox-field { justify-content: end; }
.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 43px;
}
.checkbox-field input { width: auto; }

/* D3 任務依賴：前置任務 checkbox 清單，清單過長時容器內捲動。 */
.task-depends-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task-depends-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.task-depends-list label span.muted { margin-left: auto; }
/* 行程表單「自訂色彩」：色彩選擇器＋「使用分類色」核取同列，勾選時色彩選擇器停用變灰。 */
.task-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.task-color-row input[type="color"] {
  width: 48px;
  min-width: 48px;
  padding: 4px;
}
.task-color-row input[type="color"]:disabled { opacity: .5; cursor: not-allowed; }
.task-color-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  margin: 0;
}
.task-color-inline input { width: auto; }
label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 13px;
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 107, 74, .12);
}
textarea { resize: vertical; }

.calendar-view { padding: 18px; min-height: 620px; }
.day-layout {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 0;
}
.hour-row, .day-task-lane {
  min-height: 66px;
  border-bottom: 1px dashed var(--border);
}
.hour-row {
  color: var(--muted);
  font-size: 13px;
  padding-top: 4px;
}
.day-task-lane { position: relative; }

.timeline-wrap {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0;
}
.timeline-hours {
  display: flex;
  flex-direction: column;
}
.timeline-hour-row {
  box-sizing: border-box;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12px;
  padding-top: 2px;
}
.timeline-lane {
  position: relative;
  border-left: 1px solid var(--border);
  border-top: 1px dashed var(--border);
}
.timeline-block {
  position: absolute;
  box-sizing: border-box;
  padding: 5px 8px 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--category-color, var(--primary)) 12%, var(--surface-strong));
  border: 1px solid var(--border);
  border-left: 4px solid var(--category-color, var(--primary));
  overflow: hidden;
  cursor: pointer;
}
.timeline-block.done { opacity: .55; }
.timeline-block.done .timeline-block-title { text-decoration: line-through; }
.timeline-block.conflict { box-shadow: inset 0 0 0 1px var(--danger); }
.timeline-block-title {
  font-weight: 800;
  font-size: 13px;
  line-height: 1.3;
  padding-right: 20px;
}
.timeline-block-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.timeline-block-check {
  position: absolute;
  top: 4px;
  right: 6px;
}
.timeline-block-check input { width: auto; }
.timeline-resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  cursor: ns-resize;
  /* M-W5：手機以自訂 touch 事件拖曳下緣改結束時間（app-06 handleTimelinePointerMove，
     touchmove passive:false）。不設 touch-action:none 時，瀏覽器會把觸控判成捲動、拖不動。NOTES 20。 */
  touch-action: none;
}
.timeline-resize-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: var(--muted);
  opacity: .5;
  transform: translateX(-50%);
}

.week-grid, .month-grid {
  display: grid;
  gap: 10px;
}
.week-grid { grid-template-columns: repeat(7, minmax(130px, 1fr)); }
.month-grid { grid-template-columns: repeat(7, minmax(110px, 1fr)); }
.week-day, .month-day {
  min-height: 142px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.week-day.today, .month-day.today {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px var(--primary);
  background: var(--surface-soft);
}
/* 月檢視熱力圖：依當天行程數疊一層淡淡的主色底色，疊在最底層——宣告在這裡（比
   .month-day.holiday 早），同一權重（兩個 class）下 CSS 來源順序讓後面的假日紅底
   規則自然覆蓋掉熱力底色，今天的外框高亮（上面這條規則只動 border/box-shadow，
   不動 background）也不受影響。color-mix 沒有 --primary 的固定 RGB 分量，跟著淺色/
   深色主題自動變色，深色模式也看得清。 */
.month-day.mh-1 { background: color-mix(in srgb, var(--primary) 8%, var(--surface-strong)); }
.month-day.mh-2 { background: color-mix(in srgb, var(--primary) 16%, var(--surface-strong)); }
.month-day.mh-3 { background: color-mix(in srgb, var(--primary) 26%, var(--surface-strong)); }
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.month-day.outside { opacity: .42; }

/* 年檢視（新增檢視，不動既有 .month-grid、.week-grid、.month-day 任何規則）：
   12 個迷你月曆格，heat class 沿用月檢視同一顆 heatClass()（mh-1/mh-2/mh-3），
   跟著淺色/深色主題走。點月名切月檢視、點日格切日檢視（見 app-04-render.js
   renderYear() / jumpToMonthView() / jumpToDayView()。 */
.year-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.mini-month {
  padding: 12px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.mini-month-title {
  margin: 0 0 8px;
  padding: 4px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
}
.mini-month-title:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary-strong);
}
.mini-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.mini-weekday-row span {
  display: block;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}
.mini-day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.mini-day {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
}
.mini-day:hover { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.mini-day.outside { opacity: .38; cursor: default; }
.mini-day.today {
  box-shadow: inset 0 0 0 1.5px var(--primary);
  font-weight: 700;
  color: var(--primary-strong);
}
.mini-day.mh-1 { background: color-mix(in srgb, var(--primary) 8%, var(--surface-strong)); }
.mini-day.mh-2 { background: color-mix(in srgb, var(--primary) 16%, var(--surface-strong)); }
.mini-day.mh-3 { background: color-mix(in srgb, var(--primary) 26%, var(--surface-strong)); }

@media (max-width: 1080px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .year-grid { grid-template-columns: 1fr; }
}

.month-day.holiday, .week-day.holiday {
  border-color: rgba(229, 72, 77, .45);
  background: rgba(229, 72, 77, .06);
}
.month-day.holiday .day-head > span:first-child,
.week-day.holiday .day-head > span:first-child {
  color: var(--danger);
}
.holiday-label {
  margin: -4px 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
}
.lunar-mini {
  margin: -2px 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.weather-mini {
  margin-left: 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}
.weather-emoji {
  font-size: 16px;
  line-height: 1;
}
.agenda-weather { margin-left: 0; }
.holiday-banner {
  margin-bottom: 12px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(229, 72, 77, .12);
  border: 1px solid rgba(229, 72, 77, .35);
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
}

/* Agenda 列表檢視：未來 30 天依日期分組，每組一個日期標題列，底下是當天的行程卡片。 */
.agenda-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.agenda-group.today .agenda-date-main { color: var(--primary-strong); }
.agenda-date-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.agenda-date-main {
  font-size: 16px;
  font-weight: 800;
}
.agenda-lunar, .agenda-holiday { margin: 0; }
.agenda-holiday { color: var(--danger); font-weight: 700; font-size: 12px; }
.agenda-day-tasks {
  display: grid;
  gap: 8px;
}

.task-card {
  position: relative;
  margin-bottom: 9px;
  padding: 11px 12px 11px 14px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--category-color, var(--primary)) 9%, var(--surface-strong));
  border: 1px solid var(--border);
  overflow: hidden;
}
.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 100%;
  background: var(--category-color, var(--primary));
}
.task-card.pinned { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .55); }
.task-card.overdue {
  background: rgba(229, 72, 77, .12);
  border-color: rgba(229, 72, 77, .45);
}
.task-card.done { opacity: .58; }
.task-card.done .task-title { text-decoration: line-through; }
.task-card.dragging { opacity: .4; }
.task-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.task-title {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.subtask-list {
  margin: 8px 0 0 26px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
}
.subtask-list li { margin: 3px 0; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.priority-high { color: #ef4444; }
.priority-medium { color: #f59e0b; }
.priority-low { color: #10b981; }
.pinned-badge { color: #b45309; }
.overdue-badge { color: #dc2626; }
.tag-badge { color: var(--primary-strong); }
.depends-badge { color: var(--primary-strong); }
.tz-badge { color: var(--primary-strong); }
.active-mode {
  color: #fff;
  background: var(--primary) !important;
}
.todo-list-mode {
  display: grid;
  gap: 10px;
}
.task-actions {
  display: flex;
  gap: 4px;
}
.small-btn {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 2px 4px;
}
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}
.attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: 220px;
}
.attachment-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.attachment-thumb-file {
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--surface-strong);
  cursor: pointer;
}
.attachment-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
  cursor: pointer;
}
.empty-state {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
  text-align: center;
}
.empty-state strong { color: var(--text); }

.progress-ring {
  width: 132px;
  height: 132px;
  margin: 8px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--primary) var(--progress, 0%), rgba(130, 150, 180, .18) 0);
}
.progress-ring span {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface-strong);
  font-size: 24px;
  font-weight: 900;
}
.muted { color: var(--muted); }
.center { text-align: center; }

.chart-title { margin: 14px 0 4px; font-size: 12px; text-align: center; }
.weekly-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 108px;
  padding-top: 6px;
}
.chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}
.chart-value {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.chart-bar {
  width: 100%;
  max-width: 22px;
  height: var(--bar-height, 4%);
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  transition: height .2s ease;
}
.chart-bar-today { background: linear-gradient(180deg, #10b981, #0f9c73); }
.chart-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.top-three { margin: 0; padding-left: 22px; }
.top-three li { margin: 9px 0; }
.empty-list:empty::after {
  content: "尚無重點事項";
  color: var(--muted);
}

.countdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.countdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  cursor: pointer;
}
.countdown-days {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 12px;
  color: var(--primary-strong);
  white-space: nowrap;
}
.countdown-days.countdown-today { color: var(--danger); }
.countdown-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.habit-actions, .category-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.habit-actions button, .category-actions button {
  min-width: 44px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: var(--primary);
}
.category-actions input[type="color"] {
  width: 48px;
  min-width: 48px;
  padding: 4px;
}
.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.template-apply {
  flex: 1;
  text-align: left;
  padding: 9px 10px;
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.category-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.color-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--dot-color);
  box-shadow: 0 0 0 3px rgba(130, 150, 180, .14);
}
.streak { color: var(--muted); font-size: 12px; white-space: nowrap; }
.streak-badge { display: inline-block; margin-right: 8px; color: #fb923c; font-size: 11px; font-weight: 600; }
body.dark .streak-badge { color: #fbbf24; }
.calendar-rename-input { flex: 1; min-width: 0; padding: 6px 10px; }

.task-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 24px;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}
.task-dialog::backdrop { background: rgba(6, 10, 20, .45); backdrop-filter: blur(4px); }
.dialog-header, .dialog-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}
.dialog-header h2 { margin: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0;
}
.settings-grid { grid-template-columns: repeat(2, 1fr); }
.dialog-actions { grid-template-columns: auto 1fr auto auto; }
.conflict-warning {
  margin: -4px 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fed7aa;
}
body.dark .conflict-warning {
  color: #fdba74;
  background: rgba(154, 52, 18, 0.25);
  border-color: rgba(253, 186, 116, 0.35);
}
.pomodoro-dialog { width: min(420px, calc(100vw - 28px)); }
.pomodoro-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0 4px;
}
.pomodoro-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pomodoro-mode {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.pomodoro-display {
  text-align: center;
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 18px 0;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.pomodoro-dialog.is-break .pomodoro-display { color: var(--sport); }
.pomodoro-actions {
  display: flex;
  gap: 10px;
}
.pomodoro-actions button { flex: 1; }
.pomodoro-actions button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* 全域命令面板（Ctrl+K）：獨立輕量樣式，不共用 .task-dialog 的表單版型，
   置頂置中（top: 8vh + margin-inline: auto），手機寬度滿版 90%。 */
.command-palette-dialog {
  top: 8vh;
  margin: 0 auto;
  width: min(560px, calc(100vw - 28px));
  max-height: 76vh;
  border: 0;
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}
.command-palette-dialog::backdrop { background: rgba(6, 10, 20, .5); backdrop-filter: blur(3px); }
#commandPaletteInput {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 16px 18px;
  outline: none;
}
#commandPaletteInput:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.command-palette-results {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.command-palette-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.command-palette-item .cp-sub { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.command-palette-item.active { background: var(--primary); color: #fff; }
.command-palette-item.active .cp-sub { color: rgba(255, 255, 255, .85); }
.command-palette-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 13px; }
@media (max-width: 760px) {
  .command-palette-dialog { width: 90%; top: 6vh; }
}

.cloud-sync-dialog { width: min(440px, calc(100vw - 28px)); }
.cloud-sync-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0 4px;
}
.cloud-sync-body code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* 背景推播提醒（push.js 動態插入到 #cloudSyncLoggedInBox 尾端）：用分隔線＋小標題
   跟上面「自動同步／立即同步／登出…」按鈕群拉開視覺區隔，桌機／手機共用同一份樣式，
   配色沿用既有 CSS 變數（--border/--text/--muted/--surface-strong）自動跟著深色模式切換。 */
.push-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.push-heading {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.push-field { margin: 0; }
.push-test-hint {
  margin: 0;
  font-size: 12px;
}
/* 跟 .fab-add 用同一招：只有 push-test-row 沒有 hidden 屬性時才套用 display:flex，
   避免「作者樣式優先權高於瀏覽器內建 [hidden]{display:none}」導致訂閱前就先跑版露出來。 */
.push-test-row:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.push-test-row .ghost-btn { width: 100%; }

/* 家庭共享（index.html 靜態放在 #cloudSyncLoggedInBox 內、沿用 .push-block 分隔線＋
   小標題樣式；內容由 sync.js 的 renderShareGroupUI() 動態換 innerHTML）。 */
.share-group-body p { margin: 0 0 8px; }
.share-group-body .pomodoro-actions .ghost-btn { width: 100%; }

.cloud-history-dialog { width: min(440px, calc(100vw - 28px)); }
.cloud-history-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 16px 0 4px;
}
.cloud-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.cloud-history-row + .cloud-history-row { margin-top: 8px; }
.cloud-history-info { font-size: 13px; color: var(--muted); }
.cloud-history-row .ghost-btn { flex-shrink: 0; padding: 6px 12px; }

.data-check-dialog { width: min(480px, calc(100vw - 28px)); }
.calendar-visibility-dialog { width: min(420px, calc(100vw - 28px)); }
.calendar-manage-dialog { width: min(460px, calc(100vw - 28px)); }
.calendar-dialog-body { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 4px; }
.data-check-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 4px;
}
.data-check-body hr {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}
.data-check-list {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.data-check-issue {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.weekly-review-dialog { width: min(480px, calc(100vw - 28px)); }
.weekly-review-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0 4px;
}
.weekly-review-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}
.weekly-review-rate {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.weekly-review-rate-value {
  font-size: 34px;
  font-weight: 900;
  color: var(--primary);
}
.weekly-review-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.weekly-review-category-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.weekly-review-category-name { flex: 1; }
.weekly-review-next-list {
  margin: 6px 0 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 統計儀表板（#dashboardDialog）：沿用 .weekly-review-section 的區塊標題樣式，
   長條圖一律用 div+width%/height（px）畫，不用任何圖表庫。 */
.dashboard-dialog { width: min(560px, calc(100vw - 28px)); }
.okr-dialog { width: min(480px, calc(100vw - 28px)); }
.okr-body { display: flex; flex-direction: column; gap: 14px; margin: 16px 0 4px; }
.okr-add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.okr-add-row input[type="text"] { flex: 1 1 200px; }
.okr-add-row input[type="month"] { flex: 0 0 auto; }
.okr-list { display: flex; flex-direction: column; gap: 12px; }
.okr-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
.okr-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.okr-card-title { font-weight: 700; }
.okr-card-due { font-size: 12px; color: var(--muted); }
/* 進度條：外層灰底軌道＋內層依 computeOkrProgress() 百分比縮放的填色條（寬度由 JS 內嵌 style 設定）。 */
.okr-progress-track { width: 100%; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 22%, transparent); overflow: hidden; margin: 8px 0; }
.okr-progress-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.okr-kr-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.okr-kr-title { flex: 1 1 auto; }
.okr-kr-input { width: 64px; padding: 4px 6px; }
.dashboard-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0 4px;
}
.dashboard-bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dashboard-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dashboard-bar-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dashboard-bar-label { flex: 1; min-width: 0; }
.dashboard-bar-value { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dashboard-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.dashboard-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-strong));
}
.dashboard-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.dashboard-trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.dashboard-trend-value { font-size: 11px; color: var(--muted); }
.dashboard-trend-bar-track {
  width: 100%;
  height: 96px;
  display: flex;
  align-items: flex-end;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.dashboard-trend-bar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
}
.dashboard-trend-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.dashboard-overdue-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dashboard-overdue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.dashboard-overdue-item:hover { border-color: var(--primary); }
.dashboard-overdue-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dashboard-overdue-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 手機版「⋯ 更多」工具視窗：桌面版永遠不會開啟（moreToolsBtn 預設 hidden，
   只有手機 matchMedia 才會被 JS 移除 hidden），這裡的樣式對桌面版沒有任何影響。 */
.more-tools-dialog { width: min(360px, calc(100vw - 28px)); }
.more-tools-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 4px;
}
.more-tools-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

/* 「更多」工具視窗的分組。桌機刻意「不」顯示組標題、且項目全部展開，
   讓桌機（工具列溢出時才會開這個 dialog）看到的外觀與分組前的平舖清單
   完全一致——分組純粹是為手機服務的，桌機版面零變動。
   .more-tools-group 自己也是 column flex＋同樣 gap，多包一層不會讓間距跑掉。 */
.more-tools-group { display: flex; flex-direction: column; gap: 10px; }
.more-tools-group-title { display: none; }

/* 桌面版工具列動態溢出收合（app.js setupToolbarOverflow()）用的 proxy 群組：
   跟 .more-tools-body 其餘固定項目視覺一致（同樣的直向排列＋間距），
   只是獨立管理避免跟手機固定的 proxy 互相覆蓋。 */
#overflowProxyGroup {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#overflowProxyGroup:empty { display: none; }

/* 首次進入的歡迎教學卡片：沿用 .task-dialog 外觀（手機為懸浮置中卡片），這裡只補自身版型。
   桌機六個分類用兩欄網格、卡片寬度比照 .more-tools-dialog 的 min(px, 100vw-28px)；
   手機（≤760px，本專案斷點）改單欄，底部三控制項用 flex-wrap 保證不擠爆到看不懂。 */
.welcome-dialog { width: min(560px, calc(100vw - 28px)); }
.welcome-intro { margin: 14px 2px 2px; color: var(--muted); font-size: 14px; }
.welcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0 18px;
}
.welcome-feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.welcome-ico {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  color: var(--primary);
}
.welcome-feature-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.welcome-feature-title { font-weight: 700; }
.welcome-feature-desc { font-size: 13px; line-height: 1.5; color: var(--muted); }
.welcome-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.welcome-dontshow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.welcome-dontshow input { width: auto; margin: 0; }
.welcome-actions-btns { display: flex; gap: 10px; align-items: center; }

@media (max-width: 760px) {
  .welcome-dialog { width: 100%; }
  .welcome-grid { grid-template-columns: 1fr; gap: 10px; }
  .welcome-actions { gap: 10px; }
  .welcome-actions-btns { flex: 1 0 100%; justify-content: flex-end; }
}

/* 懸浮新增按鈕（FAB）：桌面版固定隱藏，只有 @media (max-width:760px) 內才會顯示
   （且需要 JS 在手機時移除 hidden 屬性，兩個條件都成立才真的看得到）。 */
.fab-add { display: none; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 12px 16px;
  border-radius: 14px;
  color: white;
  background: #111827;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .24s ease, transform .24s cubic-bezier(.2, .8, .2, 1);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* SW 新版更新提示：跟 .fab-add 同一招，用 :not([hidden]) 避免 display 蓋掉 hidden 屬性。
   file:// 開啟（無 Service Worker）時 app.js 整段邏輯靜默跳過，這顆橫幅永遠不會被顯示。 */
.sw-update-banner { display: none; }
.sw-update-banner:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 12px;
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 14px 10px 18px;
  border-radius: 14px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
  z-index: 900;
  max-width: calc(100vw - 32px);
}
.sw-update-banner button {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.sw-update-banner button:disabled { opacity: .6; cursor: not-allowed; }

body.widget-mode .sidebar .panel:not(:first-of-type),
body.widget-mode .controls,
body.widget-mode .daily-memo,
body.widget-mode #backupBtn,
body.widget-mode #restoreBtn,
body.widget-mode #settingsBtn,
body.widget-mode #pomodoroBtn,
body.widget-mode #cleanupBtn,
body.widget-mode #exportCsvBtn,
body.widget-mode #printBtn,
body.widget-mode #exportIcsBtn,
body.widget-mode #importIcsBtn,
body.widget-mode #enableNotificationsBtn,
body.widget-mode .view-switch {
  display: none !important;
}
body.widget-mode .app-shell { grid-template-columns: 260px 1fr; }
body.widget-mode .calendar-view { min-height: 360px; }
body.widget-mode .task-card { font-size: 14px; }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: repeat(2, 1fr); }
  .brand, .sidebar > .primary-btn { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .app-shell { padding: 14px; display: flex; flex-direction: column; }
  .controls, .form-grid, .sidebar { grid-template-columns: 1fr; }
  .week-grid, .month-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; }
  .toolbar-actions, .calendar-nav { flex-wrap: wrap; }
  .calendar-nav h2 { width: 100%; margin: 6px 0 0; }

  /* 天氣資訊在手機窄版只留 emoji，隱藏溫度文字，避免標題列/欄頭擠版換行。 */
  .weather-temp { display: none; }

  /* 檢視切換多了第四顆「列表」鈕，手機寬度縮小 padding/字級才放得下四顆不擠壓換行。 */
  .view-switch .view-btn { padding: 7px 10px; font-size: 13px; }

  /* 行事曆優先：.main 排到最前面，.sidebar（今日重點/完成率/每週目標/習慣追蹤/
     自訂分類/快速範本）排到後面，使用者一開頁面先看到行事曆本體。 */
  .main { order: 1; }
  .sidebar { order: 2; }

  /* 側欄的大顆「＋ 新增行程」在手機隱藏（右下角 FAB 取代，避免重複）。 */
  #quickAddBtn { display: none; }

  /* 品牌區被 setupMobilePanels() 搬到 .main 最上方當表頭：只留圖示＋標題一大列，
     下方的今天日期隱藏（緊接著的日期大標題已經有同樣資訊，重複）。 */
  .brand-mobile { padding: 4px 2px 0; gap: 14px; align-items: center; }
  .brand-mobile .brand-icon {
    width: 66px;
    height: 66px;
    border-radius: 18px;
    font-size: 34px;
    box-shadow: 0 10px 24px rgba(255, 107, 74, .3);
  }
  .brand-mobile h1 { font-size: 29px; }
  .brand-mobile p { display: none; }

  /* 側欄面板／搜尋篩選區／每日備忘錄：收合式。app.js 的 setupMobilePanels() 只在
     手機時才幫這些區塊加上 collapsible（可收合）與 collapsed（預設收合）class，
     並幫標題列加上 panel-collapse-head class 綁 click 切換；桌面寬度時這幾個 class
     即使還留在 DOM 上，因為所有規則都包在這個 media query 內，不會有任何視覺效果。 */
  .panel.collapsible > .panel-collapse-head {
    cursor: pointer;
    position: relative;
    padding-right: 22px;
  }
  .panel.collapsible > .panel-collapse-head::after {
    content: '▾';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--muted);
  }
  .panel.collapsible.collapsed > .panel-collapse-head::after {
    content: '▸';
  }
  .panel.collapsible.collapsed > *:not(.panel-collapse-head) {
    display: none;
  }
  /* 搜尋/篩選區（.controls）本來沒有標題，setupMobilePanels() 會動態插入
     一個 h2.controls-heading 當可點的標題列，這裡讓它跟其他面板標題視覺一致。 */
  .controls-heading { margin: 0 0 12px; font-size: 17px; }

  /* 懸浮新增按鈕（FAB）：只有 hidden 屬性被 JS 移除（手機模式）時才真的顯示，
     用 :not([hidden]) 避免 CSS 的 display:flex 蓋掉 HTML 的 hidden 屬性。 */
  .fab-add:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 0;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    box-shadow: 0 14px 28px rgba(255, 107, 74, .35);
    font-size: 28px;
    font-weight: 700;
    z-index: 500;
  }

  /* 工具列只留常用按鈕（檢視切換／日模式切換／清空當日週月／主題／雲端同步／今日待辦），
     其餘次要工具用 id 列舉藏起來，收進「⋯ 更多」（#moreToolsBtn）彈出的 dialog。 */
  #commandPaletteBtn,
  #enableNotificationsBtn,
  #backupBtn,
  #restoreBtn,
  #settingsBtn,
  #pomodoroBtn,
  #widgetModeBtn,
  #cleanupBtn,
  #exportCsvBtn,
  #printBtn,
  #exportIcsBtn,
  #importIcsBtn,
  #weeklyReviewBtn,
  #dashboardBtn,
  #dataCheckBtn,
  #batchAddBtn,
  #deferBtn,
  /* 以下三顆是第五波新增的工具鈕，當時漏了加進本清單，導致它們同時出現在
     手機頂部工具列「以及」⋯更多視窗裡（同一個功能兩個入口）。補上去。 */
  #okrBtn,
  #calendarsBtn,
  #printViewBtn,
  #shareCardBtn {
    display: none !important;
  }

  /* 手機檢視切換交給底部導航列（日/週/月/列表/今天），頂部這條就不再重複佔一整行。
     底部導航沒有的「年／甘特」已在 ⋯更多 →「檢視與模式」補上入口。
     只隱藏主檢視切換，日檢視的「清單／時間軸」（#dayModeSwitch）要留著。 */
  .toolbar-actions > .view-switch:not(#dayModeSwitch) { display: none !important; }

  /* ⋯更多：手機改成分組下拉，預設全收合，點組標題才展開該組（一次一組）。 */
  .more-tools-group {
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px;
    background: var(--surface);
  }
  .more-tools-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
  }
  .more-tools-group-title::after {
    content: '›';
    font-size: 18px;
    color: var(--muted);
    transition: transform .18s ease;
  }
  .more-tools-group.open > .more-tools-group-title::after { transform: rotate(90deg); }
  .more-tools-group:not(.open) > .more-tools-item { display: none; }

  /* 行事曆下方的側欄小面板（今日重點／倒數日／完成率／每週目標／習慣追蹤／自訂分類／
     快速範本）原本一格一行、七行收合標題就吃掉半個螢幕。改成兩欄，展開中的那格
     才跨整行，高度直接砍半，捲動距離大幅縮短。 */
  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-content: start;
  }
  .sidebar > .primary-btn,
  .sidebar > .panel:not(.collapsed) { grid-column: 1 / -1; }
  .sidebar > .panel.collapsed { margin: 0; }
  .sidebar > .panel.collapsed h2 { font-size: 14px; }

  /* Dialog 手機版＝懸浮置中卡片（2026-08-09 依使用者指示：原貼底 bottom-sheet 全部改為懸浮置中）。
     四角全圓、左右留白、垂直置中，內容過長可捲動。原 M-W5 的 grabber 細條隨貼底一起移除
     （grabber 是 bottom-sheet 把手，置中卡片不需要）。 */
  dialog.task-dialog {
    width: calc(100vw - 32px);
    max-width: 440px;
    max-height: 88vh;
    margin: auto;
    border-radius: 18px;
    overflow-y: auto;
  }
  /* 歡迎教學卡片沿用同一套懸浮置中，只微調尺寸略窄略低。
     （改懸浮後已無「貼底 vs 置中」覆寫競賽，不再依賴原始碼順序；保留本條僅為尺寸微調。） */
  dialog.welcome-dialog {
    max-width: 420px;
    max-height: 82vh;
  }

  /* toast 提示原本跟 FAB 同一個右下角位置，手機加了 FAB 後把 toast 往上推，避免疊在一起。 */
  .toast { bottom: 86px; }
}

/* ============================================================
   UI 美化增強：過渡／dialog 動畫／捲軸／focus-visible／卡片
   hover 層次／reduced-motion。全走既有 CSS 變數，深色模式陰影
   一律黑色系。此區塊刻意排在 @media print 之前，讓列印區塊的
   box-shadow:none 等規則仍可覆蓋，不影響列印輸出。
   ============================================================ */

/* 1. 卡片／清單項目 hover 過渡（按鈕已於上方統一，故此處不重複） */
.task-card,
.timeline-block,
.countdown-item,
.habit-item,
.category-item,
.template-apply,
.week-day,
.month-day,
.dashboard-overdue-item {
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
/* ghost-btn hover 補一層淡陰影（上浮由全域 button:hover 提供） */
.ghost-btn:hover { box-shadow: 0 6px 16px rgba(44, 64, 105, .12); }
body.dark .ghost-btn:hover { box-shadow: 0 6px 16px rgba(0, 0, 0, .4); }

/* 2. dialog 開啟動畫（fade + scale in），一組共用 */
@keyframes dialog-pop-in {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
dialog[open] { animation: dialog-pop-in .18s ease-out; }
/* 未被個別 backdrop 規則（.task-dialog / .command-palette-dialog）覆蓋時的統一樣式 */
dialog::backdrop { background: rgba(6, 10, 20, .45); backdrop-filter: blur(2px); }

/* 3. 卡片層次：task-card hover 陰影加深（保留 pinned 內框環） */
.task-card:hover { box-shadow: 0 6px 18px rgba(44, 64, 105, .13); }
.task-card.pinned:hover { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .55), 0 6px 18px rgba(44, 64, 105, .13); }
body.dark .task-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }
body.dark .task-card.pinned:hover { box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .55), 0 6px 18px rgba(0, 0, 0, .5); }

/* 4. 捲軸美化：細版 8px 圓角，全域套用 */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* 5. focus-visible：鍵盤聚焦統一外框，不影響滑鼠點擊 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
.command-palette-item:focus-visible,
.template-apply:focus-visible,
.countdown-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 6. 月／週檢視格子 hover 背景輕微提亮（不新增閃爍動畫） */
.month-day:hover,
.week-day:hover {
  background: color-mix(in srgb, var(--primary) 7%, var(--surface-strong));
}

/* 8. 空狀態文字：字級行高微調，emoji 與文字垂直置中 */
.empty-state { line-height: 1.7; }
.empty-state p { margin: 6px 0 0; }
.command-palette-empty { line-height: 1.6; }
.empty-list:empty::after { display: inline-block; line-height: 1.6; }

/* 9. prefers-reduced-motion：一律關閉上述動畫／過渡 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  /* 強制淺色紙本配色＋去陰影，只覆蓋主題結構色（bg/surface/text/muted/border/shadow），
     不動 --work/--home/--study/--sport/--important 等分類色變數，深色模式列印時
     也會自動轉回淺色紙本配色；print-color-adjust 確保分類色條/熱力圖底色不被
     瀏覽器省墨模式濾掉。 */
  :root, body.dark {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --text: #000000;
    --muted: #444444;
    --border: #999999;
    --shadow: none;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body { background: #fff; color: #000; }

  /* 隱藏工具列／側欄／篩選列／按鈕／FAB／toast／看板全螢幕層與所有 dialog（任務、設定、命令面板、更多工具…）與日期選擇 input，紙本只留目前檢視本體。 */
  .sidebar, .toolbar-actions, .controls, .task-actions, .primary-btn, .ghost-btn,
  .fab-add, .toast, .kiosk-overlay, .date-jump, dialog, dialog::backdrop {
    display: none !important;
  }
  .app-shell { display: block; padding: 0; }
  .panel { box-shadow: none; border: 1px solid #999; backdrop-filter: none; }
  .calendar-view { min-height: auto; }

  /* 列表／Agenda：逐條避免跨頁攔腰截斷，分隔線靠上面 --border 覆蓋值自動加深。 */
  .agenda-group, .task-card { break-inside: avoid; }

  /* 年檢視：12 格迷你月曆改 3 欄 4 列，適配 A4 一頁放得下（螢幕上的 2欄/1欄手機
     RWD 規則只在對應寬度生效，列印走這條。 */
  .year-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .mini-month { break-inside: avoid; }
}

/* 頁尾版權宣告 */
.app-footer {
  text-align: center;
  padding: 6px 0 18px;
  font-size: 14px;
  font-weight: 700;
  color: #000;
  font-family: "Yuanti TC", "YouYuan", "幼圓", "Microsoft JhengHei", "PingFang TC", sans-serif;
}
body.dark .app-footer { color: #fff; }
@media print { .app-footer { display: none !important; } }

/* 掛牆看板模式：不是 <dialog>，用 :not([hidden]) 蓋掉預設 display:none（同 .sw-update-banner 那招），
   避免作者樣式優先權蓋掉 HTML 的 hidden 屬性。跟隨現有主題變數，深色模式自動深底。 */
.kiosk-overlay { display: none; }
.kiosk-overlay:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  color: var(--text);
  padding: 4vh 4vw;
  overflow: hidden;
}
.kiosk-close-btn {
  position: absolute;
  top: 18px;
  right: 22px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
.kiosk-clock {
  font-size: 15vw;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}
.kiosk-date-line {
  margin-top: 10px;
  font-size: clamp(16px, 1.6vw, 26px);
  color: var(--muted, var(--text));
  opacity: .85;
}
.kiosk-task-list {
  margin-top: 4vh;
  width: min(900px, 92vw);
  flex: 1;
  overflow-y: auto;
}
.kiosk-empty {
  text-align: center;
  font-size: clamp(18px, 2.5vw, 40px);
  opacity: .7;
  margin-top: 6vh;
}
.kiosk-task-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 6px;
  border-bottom: 1px solid var(--border);
  font-size: clamp(18px, 2.5vw, 40px);
}
.kiosk-task-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
  align-self: center;
}
.kiosk-task-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 4.5em;
}
.kiosk-task-title {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.kiosk-task-item.done { opacity: .5; }
.kiosk-task-item.done .kiosk-task-title { text-decoration: line-through; }

@media (max-width: 760px) {
  .kiosk-clock { font-size: 20vw; }
}

/* ── 甘特檢視（V2）── */
.gantt-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.gantt-inner { min-width: max-content; }
.gantt-head-row { display: flex; border-bottom: 1px solid var(--border); }
.gantt-name { flex: 0 0 140px; position: sticky; left: 0; z-index: 2; background: var(--surface); display: flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.gantt-head-name { font-weight: 600; padding: 4px 8px; z-index: 3; cursor: default; }
.gantt-head-cell { display: inline-block; width: 26px; font-size: 10px; text-align: center; color: var(--muted); padding: 4px 0; }
.gantt-head-cell.weekend { background: color-mix(in srgb, var(--muted) 12%, transparent); }
.gantt-head-cell.today { color: var(--primary); font-weight: 700; }
.gantt-body { position: relative; }
.gantt-row { display: flex; height: 30px; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.gantt-cells { position: relative; flex: 0 0 auto; background-image: repeating-linear-gradient(to right, transparent 0, transparent 130px, color-mix(in srgb, var(--muted) 10%, transparent) 130px, color-mix(in srgb, var(--muted) 10%, transparent) 182px); }
.gantt-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
.gantt-bar { position: absolute; top: 4px; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 12px; line-height: 22px; text-align: center; cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.gantt-bar.done { opacity: 0.45; }
.gantt-today-col { position: absolute; top: 0; bottom: 0; width: 26px; background: color-mix(in srgb, var(--primary) 14%, transparent); pointer-events: none; }
.gantt-links { position: absolute; top: 0; pointer-events: none; }
.gantt-links path { fill: none; stroke: var(--primary); stroke-width: 1.5; opacity: 0.75; }
.gantt-links path.blocked { stroke: var(--danger); stroke-dasharray: 4 3; }
.gantt-more { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
/* M1b 行程卡滑動手勢 */
.task-card.swiping { transition: none; }
.task-card.swiping-left { background: #e8f7ec; }
.task-card.swiping-right { background: #fff4e0; }

/* M1c 月曆格長按快建 */
@media (pointer: coarse) {
  .month-day { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
/* M-W4：手機月/週格子密度＋task chip 手機化＋今日高亮加粗。
   手機時 .week-grid/.month-grid 已收成單欄（1fr，見上面 max-width:760 區塊），每個日格是整寬一列。
   桌機 min-height:142px 在窄機上太鬆、要一直捲，這裡收緊留白/圓角/gap 提高一屏密度；
   task 卡片改小一號（chip 化）；今日邊框加粗到 3px 更好認（只動外框/陰影，不碰底色，
   免得蓋掉 .month-day.mh-* 月熱力圖底）。想做「小圓點＋數字、點格子再展開」需改 render JS，屬後續。 */
@media (max-width: 760px) {
  .week-grid, .month-grid { gap: 8px; }
  .week-day, .month-day {
    min-height: 96px;
    padding: 10px 11px;
    border-radius: 14px;
  }
  .day-head { margin-bottom: 8px; font-size: 12px; }
  .task-card {
    margin-bottom: 6px;
    padding: 8px 10px 8px 12px;
    border-radius: 11px;
  }
  .task-card::before { width: 4px; }
  .task-title { font-size: 14px; line-height: 1.3; }
  .week-day.today, .month-day.today { box-shadow: inset 0 0 0 3px var(--primary); }
}

/* M-W5：手機按壓回饋（:active 縮放）。ghost-btn/view-btn 已各有 :active、bottom-nav 已加 scale，
   這裡補上原本只有 translateY(0)（等於無感）的主鈕/圖示鈕/FAB。放在後段確保覆蓋前面的 :active 規則。 */
@media (max-width: 760px) {
  .primary-btn:active,
  .icon-btn:active,
  .fab-add:active { transform: scale(.96); }
}

/* M2 手機底部導航列 */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  .bottom-nav:not([hidden]) {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: var(--surface-strong);
    border-top: 1px solid var(--border);
    box-shadow: 0 -3px 14px rgba(35, 32, 29, .07);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)) 4px;
    gap: 2px;
    justify-content: space-around;
  }
  .bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 日/週/月只有圖示、列表/今天是圖示+文字，內容高度不一樣，用 justify-content:center
       讓每顆圖示都在按鈕垂直置中，不會因為少了下面那行字而整個往上貼，造成上下不均。 */
    justify-content: center;
    gap: 1px;
    background: none;
    border: none;
    font-size: 17px;
    padding: 4px 0;
    min-height: 48px;
    border-radius: 12px;
    color: var(--muted);
    transition: transform .12s ease, background-color .16s ease, color .16s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-btn:active { transform: scale(.92); }
  .bottom-nav-btn span { font-size: 10px; }
  /* 底部導航「日／週／月」的圖示：沿用上面 .date-icon 那張自製日曆卡（原本是系統 emoji，
     各平台 emoji 字型長相不一致、上面的日期還是字型寫死的），中間直接放「日」「週」「月」字。
     選中的那一顆連圖示裡的字一起變主色，比只有下面標籤變色更好認。 */
  .bottom-nav-btn .nav-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    grid-template-rows: 9px 1fr;
    transition: transform .16s ease;
  }
  .bottom-nav-btn .nav-icon .date-icon-day { font-size: 13px; font-weight: 700; }
  .bottom-nav-btn.active .nav-icon .date-icon-day { color: var(--primary); }
  /* 日/週/月圖示本身已經顯示文字，下面原本重複的小標籤拿掉了（見 index.html），
     改由 button 的 aria-label 提供無障礙名稱；列表/今天沒有重複問題所以保留原本標籤。 */
  .bottom-nav-btn.active {
    color: var(--primary);
    font-weight: 700;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
  }
  .bottom-nav-btn.active .nav-icon { transform: translateY(-1px); }
  body.has-bottom-nav { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.has-bottom-nav .fab-add:not([hidden]) { bottom: calc(118px + env(safe-area-inset-bottom)); }
}
/* M3 手機快速新增列 */
.quick-add-bar { display: none; }
@media (max-width: 760px) {
  .quick-add-bar:not([hidden]) {
    display: flex;
    position: fixed;
    left: 0; right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom));
    z-index: 59;
    gap: 6px;
    padding: 6px 8px;
    background: var(--surface-strong);
    border-top: 1px solid var(--border);
  }
  .quick-add-bar input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 14px;
  }
  .quick-add-bar button {
    border: none;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 14px;
  }
  body.has-bottom-nav { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
}

/* M-fix1: FAB 避開快速新增列；手機儲存列 sticky 常顯 */
@media (max-width: 760px) {
  .task-dialog .dialog-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface-strong);
    padding-top: 8px;
    padding-bottom: 8px;
    z-index: 5;
  }
}

/* P1a æ¯æ¥å¿æé¸æåï¼è·èãæ¯æ¥åå¿éãé¢æ¿èµ°ï¼ä¸å¦å¤éé¢æ¿ */
.mood-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.mood-picker .mood-label {
  margin-right: 2px;
}
.mood-btn {
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  border: 1px solid var(--border, #ccc);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  opacity: 0.55;
}
.mood-btn:hover {
  opacity: 0.85;
}
.mood-btn.is-active {
  opacity: 1;
  border-color: var(--accent, #4a90d9);
  background: var(--accent-soft, rgba(74, 144, 217, 0.15));
}
.mood-btn:focus-visible {
  outline: 2px solid var(--accent, #4a90d9);
  outline-offset: 2px;
}

/* P1b 月檢視心情色點：絕對定位，不佔文字流、不改格子高度 */
.month-day {
  position: relative;
}
.mood-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
}
.mood-dot-1 { background: #e05252; }
.mood-dot-2 { background: #e08a4a; }
.mood-dot-3 { background: #b8b8b8; }
.mood-dot-4 { background: #6aa96a; }
.mood-dot-5 { background: #3f9d4f; }


/* === A+B 去 AI 味美化補強（2026-08-09） === */
.compact h2 { position: relative; padding-left: 12px; }
.compact h2::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 1em;
  border-radius: 2px;
  background: var(--primary);
}
.ghost-btn:active, .view-btn:active { transform: translateY(1px); }
