/* 家庭行事曆 — Fantastical 風格 */
:root {
  --accent: #E5484D;
  --accent-soft: color-mix(in srgb, var(--accent) 9%, transparent);
  --bg: #F7F5F2;
  --side-bg: #F2EFEA;
  --border: #E5E1DB;
  --border-strong: #D5D0C8;
  --text: #1C1917;
  --muted: #7D766F;
  --card: #ffffff;
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.08);
  --shadow-md: 0 6px 24px rgba(28, 25, 23, 0.12);
  --shadow-lg: 0 24px 64px rgba(28, 25, 23, 0.22);
  /* 細緻噪點底紋(壓印感) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body, #app { height: 100%; margin: 0; }
/* 手機網址列收合時用動態視口,畫面才會跟瀏覽器視窗切齊 */
@supports (height: 100dvh) {
  html, body, #app { height: 100dvh; }
}
/* 禁止整頁左右平移 */
html, body { overflow-x: hidden; overscroll-behavior-x: none; }
#app { overflow-x: hidden; max-width: 100vw; }
/* 視窗開著時鎖住背景捲動 */
body:has(.modal:not(.hidden)) { overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--grain);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
#main { background: var(--cal-bg, #fff); }
#app { display: flex; }
.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 側邊欄 ---------- */
#sidebar {
  width: 276px; flex: none;
  background-color: var(--side-bg);
  background-image: var(--grain);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.brand { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.brand-icon { font-size: 16px; }

.quickadd-wrap { position: relative; }
#quickadd {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 10px; font-size: 13px; background: #fff; outline: none;
}
#quickadd:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#quickadd-preview {
  margin-top: 6px; font-size: 12px; line-height: 1.5;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; color: var(--text);
}
#quickadd-preview .ok { color: var(--accent); font-weight: 600; }
#quickadd-preview .hint { color: var(--muted); }

/* 迷你月曆 */
#minical { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 10px; box-shadow: var(--shadow-sm); }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-title { font-size: 13px; font-weight: 700; }
.mini-nav { display: flex; gap: 2px; }
.mini-nav button {
  border: none; background: transparent; color: var(--accent);
  font-size: 16px; width: 24px; height: 24px; border-radius: 6px; line-height: 1;
}
.mini-nav button:hover { background: var(--accent-soft); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-wd { text-align: center; font-size: 10px; color: var(--muted); padding: 2px 0; }
.mini-day {
  position: relative; text-align: center; font-size: 12px;
  border: none; background: transparent; border-radius: 50%;
  width: 30px; height: 30px; margin: 0 auto; color: var(--text); padding: 0;
}
.mini-day:hover { background: var(--accent-soft); }
.mini-day.other { color: #c5c5c9; }
.mini-day.selected { background: #e3e3e7; font-weight: 600; }
.mini-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.mini-day .dot {
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.mini-day.today .dot { background: #fff; }

/* 側欄區塊 */
.side-section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; justify-content: space-between;
}
.icon-btn {
  border: none; background: transparent; font-size: 16px; color: var(--accent);
  width: 26px; height: 26px; border-radius: 7px; line-height: 1; display: inline-flex;
  align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--accent-soft); }

/* 行事曆切換(個人/家庭) */
#cal-toggles { display: flex; flex-direction: column; gap: 2px; }
.cal-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 8px; cursor: pointer; font-size: 14px; user-select: none;
}
.cal-row:hover { background: rgba(0,0,0,0.045); }
.cal-row input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.cal-row .swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }
.cal-sub { color: var(--muted); font-size: 12px; margin-left: 2px; }
.cal-hint { font-size: 12px; color: var(--muted); padding: 4px 8px; line-height: 1.5; }
.cal-row .edit-cal {
  border: none; background: transparent; color: var(--muted);
  border-radius: 6px; font-size: 14px; padding: 2px 6px; margin-left: auto;
}
.cal-row .edit-cal:hover { color: var(--text); background: rgba(0,0,0,0.06); }
.cal-row .cal-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
.member-chip.locked { opacity: 0.9; cursor: default; outline: 1.5px dashed var(--border); outline-offset: 1px; }
.color-row.small .color-dot { width: 24px; height: 24px; border-width: 2.5px; }
/* 底色選擇:淺色點要有描邊才看得到 */
.color-row.bg .color-dot { box-shadow: inset 0 0 0 1px var(--border-strong); }
.whoami-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  padding: 6px 8px 0;
}
.whoami-row .spacer { flex: 1; }
.whoami-row b { color: var(--text); }
.whoami-row select {
  flex: 1; border: 1px solid var(--border); border-radius: 7px; padding: 4px 6px;
  font-size: 12px; background: #fff; color: var(--text);
}
.me-mark { color: var(--muted); font-size: 11px; margin-left: 3px; }

#member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.member-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 8px; cursor: pointer; font-size: 14px; user-select: none;
}
.member-row:hover { background: rgba(0,0,0,0.045); }
.member-row .swatch {
  width: 12px; height: 12px; border-radius: 4px; flex: none;
  background: var(--c); border: 2px solid var(--c);
}
.member-row.off .swatch { background: transparent; }
.member-row.off .mname { color: var(--muted); }
.member-row .mname { flex: 1; }
.member-row .edit { border: none; background: transparent; color: var(--muted); border-radius: 6px; font-size: 14px; padding: 2px 6px; }
.member-row .edit:hover { color: var(--text); background: rgba(0,0,0,0.06); }

/* 標籤 */
#tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 3px;
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 3px 10px; font-size: 13px; color: var(--text);
}
.tag-chip .hash { color: var(--accent); font-weight: 700; }
.tag-chip .cnt { color: var(--muted); font-size: 10.5px; }
.tag-chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag-chip.selected .hash, .tag-chip.selected .cnt { color: rgba(255,255,255,0.85); }
.tag-clear { border: none; background: transparent; color: var(--accent); font-size: 12px; padding: 3px 6px; }
.ev-tags { opacity: 0.75; font-weight: 400; font-size: 0.92em; }

/* 接下來 */
#upcoming { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.up-date {
  font-weight: 700; font-size: 12.5px; color: var(--text);
  margin: 8px 0 3px; padding-bottom: 3px; border-bottom: 1px solid var(--border);
}
.up-date:first-child { margin-top: 0; }
.up-date.today-label { color: var(--accent); border-color: var(--accent); }
.up-item {
  display: flex; align-items: baseline; gap: 7px; padding: 4px 6px;
  border-radius: 7px; cursor: pointer;
}
.up-item:hover { background: rgba(0,0,0,0.045); }
.up-item .udot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }
.up-item .utitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .utime { color: var(--muted); font-size: 12px; flex: none; }
.up-empty { color: var(--muted); font-size: 13px; padding: 4px 6px; }

/* 搜尋結果 */
#search-results { max-height: 55vh; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
#search-results .up-item { padding: 9px 8px; font-size: 14px; }
#search-results .up-item .utime { font-size: 12.5px; }

/* 快速新增框的搜尋命中 */
.qa-found {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  margin: 8px 0 2px; padding-top: 6px; border-top: 1px solid var(--border);
}
.qa-hit { font-size: 13.5px; }

/* 未登入/未入家庭:背景行事曆模糊、鎖操作(登入視窗本身不在此列) */
body.locked #sidebar, body.locked #main, body.locked #fab {
  filter: blur(9px) saturate(0.85);
  pointer-events: none;
  user-select: none;
}

.version-tag { font-size: 10.5px; color: var(--muted); text-align: center; opacity: 0.8; margin-top: auto; padding-top: 8px; }

/* ---------- 主區 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
#topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--cal-bg, #FAF8F5) 86%, transparent);
  background-image: var(--grain);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 1px 0 rgba(28,25,23,0.04);
  position: relative; z-index: 20;
}
.nav-group { display: flex; align-items: center; gap: 2px; }
.nav-btn {
  border: none; background: transparent; font-size: 22px; color: var(--accent);
  width: 30px; height: 30px; border-radius: 8px; line-height: 1; padding-bottom: 3px;
}
.nav-btn:hover { background: var(--accent-soft); }
.today-btn {
  border: none; background: transparent; color: var(--accent); font-size: 13px;
  font-weight: 600; padding: 5px 10px; border-radius: 8px;
}
.today-btn:hover { background: var(--accent-soft); }
#cal-title { font-size: 19px; font-weight: 700; margin: 0; flex: 1; min-width: 0; white-space: nowrap; }
.view-switch { display: flex; background: #E9E5DF; border-radius: 9px; padding: 2px; box-shadow: inset 0 1px 2px rgba(28,25,23,0.06); }
.view-switch button {
  border: none; background: transparent; padding: 4px 14px; border-radius: 7px;
  font-size: 13px; color: var(--text);
}
.view-switch button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.18); font-weight: 600; }

#calendar { flex: 1; min-height: 0; padding: 4px 10px calc(8px + env(safe-area-inset-bottom)); will-change: transform; }
/* 翻頁滑動效果 */
.slide-out-left { transform: translateX(-7%); opacity: 0; transition: transform 0.13s ease-in, opacity 0.13s ease-in; }
.slide-out-right { transform: translateX(7%); opacity: 0; transition: transform 0.13s ease-in, opacity 0.13s ease-in; }
.slide-in-right { animation: slideInR 0.2s ease-out; }
.slide-in-left { animation: slideInL 0.2s ease-out; }
@keyframes slideInR { from { transform: translateX(9%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideInL { from { transform: translateX(-9%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- FullCalendar 客製 ---------- */
.fc {
  --fc-border-color: var(--border);
  --fc-today-bg-color: color-mix(in srgb, var(--accent) 4.5%, transparent);
  --fc-now-indicator-color: var(--accent);
  --fc-page-bg-color: var(--cal-bg, #fff);
  --fc-list-event-hover-bg-color: var(--accent-soft);
  font-size: 13px;
}
.fc .fc-event { border-radius: 7px; border: none; font-size: 12px; cursor: pointer; }
.fc .fc-timegrid-event {
  padding: 2px 5px;
  background-image: linear-gradient(rgba(255,255,255,0.16), rgba(0,0,0,0.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), inset 0 0 0 1px rgba(255,255,255,0.12), 0 2px 5px rgba(28,25,23,0.25);
}
.fc .fc-daygrid-block-event {
  background-image: linear-gradient(rgba(255,255,255,0.16), rgba(0,0,0,0.07));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 1px 2px rgba(28,25,23,0.15);
}
.fc .fc-event-main { color: #fff; }
.fc .fc-event-title, .fc .fc-event-time { text-shadow: 0 1px 1px rgba(0,0,0,0.12); }
/* 共用行事曆上的行程:不填色、黑框、深色字(中性呈現,避免個人顏色定義衝突) */
/* 用 inset 陰影畫框而不是 border,高度才會跟一般色塊完全一致 */
.fc .ev-outline {
  background: rgba(255, 255, 255, 0.92) !important;
  background-image: none !important;
  border: none !important;
  box-shadow: inset 0 0 0 2px #1C1917 !important;
}
.fc .ev-outline .fc-event-main { color: var(--text) !important; }
.fc .ev-outline .fc-event-title, .fc .ev-outline .fc-event-time { text-shadow: none; color: var(--text); }
.member-chip.add-chip { border-style: dashed; color: var(--muted); }
.member-chip.add-chip .cdot { display: none; }
/* 短行程:文字上下置中、時間和標題排同一行 */
.fc .fc-timegrid-event .fc-event-main { display: flex; flex-direction: column; justify-content: flex-start; }
.fc .fc-timegrid-event-short .fc-event-main { justify-content: center; }
.fc .fc-timegrid-event-short .fc-event-main-frame { align-items: center; gap: 4px; }
.fc .fc-event-title { font-weight: 600; }
.fc .fc-timegrid-slot { height: 2.3em; }
.fc .fc-col-header-cell { border-bottom-width: 0; }
.fc .fc-col-header-cell-cushion { padding: 6px 4px; text-decoration: none; }
.dh { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dh-wd { font-size: 11px; color: var(--muted); font-weight: 500; }
.dh-num {
  font-size: 16px; font-weight: 600; color: var(--text);
  width: 27px; height: 27px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.dh-num.today { background: var(--accent); color: #fff; }
.dh-wd-m { font-size: 12px; color: var(--muted); font-weight: 600; }
.fc .fc-daygrid-day-number { text-decoration: none; color: var(--text); font-size: 12.5px; padding: 4px 6px; }
/* 月檢視:每一天的日期列固定同高,今天的紅圈才不會把行程往下推 */
.fc .fc-dayGridMonth-view .fc-daygrid-day-top,
.fc .fc-multimonth .fc-daygrid-day-top { min-height: 28px; align-items: center; }
.fc .fc-dayGridMonth-view .fc-day-today .fc-daygrid-day-number,
.fc .fc-multimonth .fc-day-today .fc-daygrid-day-number {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 23px; height: 23px; display: flex; align-items: center; justify-content: center;
  margin: 0 2px; padding: 0; font-weight: 700;
}
/* 連續捲動的多月檢視 */
.fc .fc-multimonth { border: none; }
.fc .fc-multimonth-title { font-size: 16px; font-weight: 800; padding: 18px 0 8px; color: var(--text); }
.fc .fc-multimonth-daygrid { background: transparent; }
.fc .fc-daygrid-event { border-radius: 9px; padding: 3px 8px; margin-bottom: 2px; }
.fc .fc-daygrid-dot-event .fc-event-title { color: var(--text); }
/* 列表檢視:左側日期標頭 + 寬鬆行距 */
.fc .fc-list { border: none; }
.fc .fc-list-day-cushion {
  background: var(--side-bg);
  background-image: var(--grain);
  padding: 10px 14px;
}
.fc .fc-list-day-text { font-weight: 700; font-size: 14px; color: var(--text); }
.ld { display: flex; align-items: center; gap: 9px; }
.ld-num { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.ld-meta { display: flex; flex-direction: column; line-height: 1.15; font-size: 11px; color: var(--muted); font-weight: 500; }
.ld.today .ld-num { color: var(--accent); }
.fc .fc-list-event td { padding: 13px 12px; font-size: 14px; }
.fc .fc-list-event-time { color: var(--muted); white-space: nowrap; width: 96px; }
.fc .fc-list-event-graphic { padding-right: 2px; }
.fc .fc-list-event-dot { border-width: 5px; }
.fc .fc-list-event-title { font-weight: 500; }
.fc a { text-decoration: none; }
.fc .fc-timegrid-now-indicator-line { border-width: 2px 0 0; }
.fc .fc-highlight { background: var(--accent-soft); }

/* ---------- 彈出視窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 60;
}
.modal-card {
  background: #fff; border-radius: 16px; width: 440px; max-width: calc(100vw - 24px);
  max-height: 88vh; overflow-y: auto; overflow-x: hidden; padding: 18px;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 12px;
}
.modal-card.small { width: 340px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .close { color: var(--muted); font-size: 14px; }
.title-input {
  border: none; border-bottom: 2px solid var(--border); border-radius: 0;
  font-size: 18px; font-weight: 600; padding: 6px 2px; outline: none; width: 100%;
}
.title-input:focus { border-bottom-color: var(--accent); }
.field-label { font-size: 12px; color: var(--muted); }
.member-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.member-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border); background: #fff; border-radius: 999px;
  padding: 4px 12px; font-size: 13px;
}
.member-chip .cdot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.member-chip.selected { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 7px; font-size: 14px; user-select: none; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.share-targets {
  margin: 6px 0 0 24px; padding: 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
}
#ev-share-wrap { display: flex; flex-direction: column; }
.two-col { display: flex; gap: 10px; }
.two-col .field { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px;
  color: var(--text); outline: none; width: 100%; background: #fff;
}
.field textarea { resize: none; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.weekday-pick { display: flex; gap: 5px; margin-top: 2px; }
.wd-chip {
  width: 34px; height: 30px; border-radius: 8px; border: 1.5px solid var(--border);
  background: #fff; font-size: 13px; color: var(--text);
}
.wd-chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.custom-color { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.custom-color input[type="color"] {
  width: 44px; height: 30px; border: 1px solid var(--border); border-radius: 8px;
  padding: 2px; background: #fff; cursor: pointer;
}
.custom-color.active { color: var(--text); font-weight: 600; }
/* 地點自動完成 */
.loc-field { position: relative; }
#loc-suggest {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18); z-index: 80;
  max-height: 230px; overflow-y: auto;
}
.loc-item { padding: 8px 11px; cursor: pointer; }
.loc-item:hover, .loc-item.active { background: var(--accent-soft); }
.loc-name { font-size: 13px; color: var(--text); }
.loc-addr { font-size: 11px; color: var(--muted); margin-top: 1px; }
.loc-src { font-size: 10.5px; color: var(--muted); padding: 6px 11px; border-top: 1px solid var(--border); }

.color-row { display: flex; flex-wrap: wrap; gap: 9px; }
.color-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent;
  background: var(--c); padding: 0;
}
.color-dot.selected { border-color: var(--text); }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.modal-actions .spacer { flex: 1; }
.btn {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 16px; font-size: 14px;
  background: #fff; color: var(--text); box-shadow: var(--shadow-sm);
}
.btn:hover { background: #F7F6F5; }
.btn.primary {
  background: linear-gradient(color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  border-color: color-mix(in srgb, var(--accent) 80%, black);
  color: #fff; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.04); background: var(--accent); }
.btn.danger { background: transparent; color: var(--accent); }
.btn.danger:hover { background: var(--accent-soft); }

/* 個人登入畫面 */
.key-gate { align-items: center !important; }
.key-card { text-align: center; gap: 10px; border-radius: 16px !important; width: 330px !important; }
.key-icon { font-size: 40px; }
.key-card h3 { margin: 0; font-size: 18px; }
.key-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.login-members { justify-content: center; }
.login-fields { display: flex; flex-direction: column; gap: 8px; }
.login-fields input {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 16px; text-align: center; outline: none; width: 100%;
}
.login-fields input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#key-gate-error { font-size: 12.5px; color: var(--accent); min-height: 16px; }
#login-btn { width: 100%; padding: 10px; font-size: 15px; }
.linklike { border: none; background: transparent; color: var(--accent); font-size: 12.5px; padding: 2px 4px; cursor: pointer; }
.linklike:hover { text-decoration: underline; }
.member-chip.disabled { opacity: 0.35; cursor: not-allowed; }

/* 行程檢視(詳情) */
.detail-card { padding-top: 0; overflow: hidden; }
.detail-accent { height: 6px; margin: 0 -18px; flex: none; }
.detail-head { margin-top: 12px; }
.detail-head h3 { font-size: 19px; line-height: 1.35; }
.dt-rows { display: flex; flex-direction: column; gap: 10px; padding: 2px 0 4px; }
.dt-row { display: flex; gap: 10px; align-items: baseline; font-size: 14px; line-height: 1.5; }
.dt-ic { width: 22px; flex: none; text-align: center; opacity: 0.75; font-size: 13px; font-style: normal; }
.dt-val { min-width: 0; overflow-wrap: anywhere; }
.dt-sub { color: var(--muted); font-size: 12.5px; }
.dt-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.dt-map {
  color: var(--accent); text-decoration: none; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; margin-left: 6px; white-space: nowrap;
}
.dt-map:hover { background: var(--accent-soft); border-color: var(--accent); }
.dt-tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600;
}

/* ---------- 浮動按鈕 / 提示 ---------- */
#fab {
  position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 28px; border: none;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent); z-index: 30; line-height: 1;
}
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: rgba(29,29,31,0.92); color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 10px; z-index: 80;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  display: flex; align-items: center; gap: 12px; white-space: nowrap;
}
#toast .toast-undo {
  border: none; background: none; cursor: pointer;
  color: #FFB3B6; font-size: 13px; font-weight: 700; font-family: inherit;
  padding: 2px 4px;
}

/* ---------- 手機版 ---------- */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 40; }
@media (min-width: 881px) {
  .mobile-only { display: none !important; }
  .view-switch .mobile-view { display: none; } /* 桌機看「週」,不顯示「3天」 */
}
@media (max-width: 880px) {
  .view-switch .desktop-view { display: none; } /* 手機看「3天」,不顯示「週」 */

  /* 側欄抽屜:加寬、加大列高 */
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: min(320px, 88vw);
    transform: translateX(-105%); transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 12px 0 40px rgba(28,25,23,0.25);
    padding-top: calc(16px + env(safe-area-inset-top));
    gap: 18px;
  }
  #sidebar.open { transform: none; }
  #quickadd { padding: 12px; font-size: 16px; border-radius: 11px; }
  .mini-day { width: 36px; height: 36px; font-size: 14px; }
  .mini-wd { font-size: 12px; }
  .mini-title { font-size: 15px; }
  .mini-nav button { width: 34px; height: 34px; font-size: 20px; }
  .member-row { padding: 10px; font-size: 15px; border-radius: 10px; }
  .member-row .swatch { width: 14px; height: 14px; }
  .member-row .edit { font-size: 17px; padding: 4px 10px; }
  .cal-row { padding: 10px; font-size: 15px; border-radius: 10px; }
  .cal-row input { width: 19px; height: 19px; }
  .cal-row .edit-cal { font-size: 17px; padding: 4px 10px; }
  .side-section h3 { font-size: 12px; }
  .icon-btn { width: 34px; height: 34px; font-size: 19px; }
  .up-item { padding: 8px; font-size: 14px; }
  .up-date { font-size: 12.5px; }
  .whoami-row { font-size: 14px; }
  .linklike { font-size: 14px; padding: 6px 8px; }
  .tag-chip { padding: 6px 13px; font-size: 13.5px; }

  /* 工具列 */
  #topbar { gap: 6px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
  #cal-title { font-size: 16px; }
  .nav-btn { width: 38px; height: 38px; font-size: 24px; }
  .today-btn { font-size: 14px; padding: 8px 12px; }
  #menu-btn { width: 38px; height: 38px; }
  .view-switch { order: 10; width: 100%; }
  .view-switch button { flex: 1; padding: 9px 0; font-size: 14px; }

  /* 彈出視窗:底部抽屜,完全貼齊視窗邊緣 + 頂端把手 + 大控件 */
  .modal { align-items: flex-end; padding: 0; }
  .modal-card, .modal-card.small {
    width: 100vw; max-width: 100vw; margin: 0;
    border-radius: 20px 20px 0 0;
    padding: 14px 18px calc(20px + env(safe-area-inset-bottom));
    max-height: 92vh; max-height: 92dvh; border: none; box-shadow: 0 -8px 40px rgba(28,25,23,0.25);
  }
  .modal-card::before {
    content: ''; display: block; width: 38px; height: 4.5px; flex: none;
    background: var(--border-strong); border-radius: 3px; margin: 0 auto 2px;
  }
  .key-gate .modal-card::before { display: none; }
  .detail-accent { margin: 0 -18px; }
  .modal-head h3 { font-size: 18px; }
  .title-input { font-size: 20px; padding: 10px 2px; }
  /* 16px 以上 iOS 才不會聚焦時自動放大整頁 */
  .field input, .field select, .field textarea { font-size: 16px; padding: 11px 12px; border-radius: 10px; }
  .field { font-size: 13px; gap: 6px; }
  .member-chip { padding: 9px 16px; font-size: 15px; }
  .wd-chip { width: 42px; height: 40px; font-size: 15px; border-radius: 10px; }
  .check-row { font-size: 16px; padding: 4px 0; }
  .check-row input { width: 22px; height: 22px; }
  .color-dot { width: 38px; height: 38px; }
  .color-row { gap: 11px; }
  .custom-color input[type="color"] { width: 56px; height: 38px; }
  .btn { padding: 12px 20px; font-size: 16px; border-radius: 12px; }
  .modal-actions { gap: 10px; margin-top: 8px; }
  .dt-row { font-size: 15.5px; gap: 12px; }
  .detail-head h3 { font-size: 21px; }
  .modal-head .close { width: 38px; height: 38px; font-size: 17px; }

  /* 行事曆主體 */
  .two-col { flex-direction: column; }
  #calendar { padding: 2px 4px calc(4px + env(safe-area-inset-bottom)); }
  .fc .fc-timegrid-slot { height: 2.8em; }
  .fc { font-size: 13.5px; }
  .dh-num { width: 31px; height: 31px; font-size: 17px; }

  /* 手機列表檢視:行距再放寬 */
  .fc .fc-list-event td { padding: 16px 12px; font-size: 15.5px; }
  .fc .fc-list-day-cushion { padding: 12px 14px; }
  .fc .fc-list-day-text { font-size: 15px; }
  .fc .fc-list-event-time { width: 104px; font-size: 13.5px; }
}

/* ===== 清單與家務面板(Daykin) ===== */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 100vw;
  background: #fff; border-left: 1px solid var(--border); z-index: 55;
  box-shadow: -12px 0 40px rgba(28,25,23,0.18);
  display: flex; flex-direction: column;
}
.panel-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}
.panel-tabs { display: flex; background: #E9E5DF; border-radius: 9px; padding: 2px; flex: 1; }
.panel-tabs button {
  flex: 1; border: none; background: transparent; padding: 7px 0; border-radius: 7px;
  font-size: 13.5px; color: var(--text); cursor: pointer;
}
.panel-tabs button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.18); font-weight: 600; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.item-add { display: flex; gap: 8px; }
.item-add input {
  flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; outline: none;
}
.item-add input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.item-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px;
  border-bottom: 1px solid var(--border); font-size: 15px;
}
.item-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.item-row .item-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item-row .item-qty { color: var(--muted); font-size: 13px; flex: none; }
.item-row .item-del { border: none; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 8px; font-size: 14px; }
.item-row.done .item-name { text-decoration: line-through; color: var(--muted); }
.list-add-input {
  border: 1px dashed var(--border-strong); border-radius: 999px; padding: 5px 12px;
  font-size: 13px; outline: none; width: 150px;
}
.chip-x { opacity: 0.7; margin-left: 4px; }
.chore-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.chore-info { flex: 1; min-width: 0; cursor: pointer; }
.chore-name { font-size: 15px; font-weight: 600; }
.chore-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.chore-done-btn { padding: 7px 14px; font-size: 13.5px; flex: none; }
.chore-done-btn.is-done { background: #E8F5E9; border-color: #C8E6C9; color: #2F9E44; }
.chore-rest { font-size: 12px; color: var(--muted); flex: none; }
/* 行事曆上的家務標示:輕量、不搶行程的戲 */
.fc .ev-chore {
  background: transparent !important; background-image: none !important;
  box-shadow: none !important; border: none !important;
}
.fc .ev-chore .fc-event-title { color: var(--muted); font-weight: 500; text-shadow: none; font-size: 11px; }
.fc .ev-chore.chore-done .fc-event-title { text-decoration: line-through; opacity: 0.7; }
@media (max-width: 880px) {
  .panel { width: 100vw; }
  #lists-btn { font-size: 17px; }
}

/* Pantone 成套主題晶片 */
#theme-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 5px 11px; font-size: 12px; color: var(--text); cursor: pointer;
}
.theme-chip.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); font-weight: 600; }
.theme-chip .tdot { width: 12px; height: 12px; border-radius: 50%; }
