/* =====================================================================
   寶寶出生準備平台的樣式
   風格：B 粉彩貼紙。規則見 docs/ui-guidelines.md（介面設計準則，SSOT）。數值改這裡，用法改那份文件，兩邊一起改。
   順序：1 數值 → 2 基礎 → 3 版面 → 4 元件 → 5 各分頁 → 6 表單頁 → 手機（≤560px）→ 少動畫
   ===================================================================== */

/* ---------- 1. 數值（tokens） ---------- */
/* 風格：B 粉彩貼紙（2026-11-20 決定）。奶油白底、粉彩色塊、墨色描邊加往右下錯位的實心陰影，像貼紙。
   這裡放顏色、字型、描邊、陰影、圓角、頁面邊距；字級與間距直接寫數字，可以用的值見 docs/ui-guidelines.md 第 3 節。 */
:root {
  --font: "Huninn", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --bg: #fff8f0;
  --surface: #fffdfa;
  --surface-2: #faf0e4;
  --ink: #3a2e28;
  --muted: #73635a;
  --line: #efe2d4;
  --line-strong: #93806f;
  --outline: #3a2e28;
  --shadow-c: #3a2e28;
  --bw: 2px;
  --shadow: 4px 4px 0 var(--shadow-c);
  --shadow-sm: 2px 2px 0 var(--shadow-c);
  --accent: #ad3a5c;
  --accent-fill: #ffa197;
  --accent-ink: #3a2e28;
  --accent-soft: #ffe6df;
  --select: #ffcf8f;
  --select-ink: #3a2e28;
  --tint-pink: #ffe6df;
  --tint-mint: #e5f3dc;
  --tint-lemon: #fff1c4;
  --tint-lav: #f6e4ef;
  --on-color: #ffffff;
  --ok: #2f6f45;
  --ok-fill: #93d4a3;
  --ok-soft: #e5f3dc;
  --danger: #b8352a;
  --danger-soft: #ffe1dc;
  --warn: #7f5a00;
  --warn-soft: #fff1c4;
  --info: #7b4a86;
  --info-soft: #f6e4ef;
  --c0: #3a5fb5; --c1: #2a7350; --c2: #a8366f; --c3: #7f5a00; --c4: #6447c2; --c5: #ad3a5c; --c6: #73635a;
  --gutter: clamp(16px, 3vw, 44px);
  --r-sm: 10px;
  --r-md: 12px;
  --r-alert: 14px; /* 不是卡片的方塊：警示、橫幅、心情、選項比較的方案 */
  --r-lg: 18px;
  --r-pill: 999px;
  color-scheme: light;
}
/* 深色：「夜晚的貼紙」。底色改深可可、描邊改淡奶茶色、錯位陰影改黑色、粉彩色塊改深色淺底；蜜桃粉實心按鈕維持蜜桃粉配深色字 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1916;
    --surface: #2a221e;
    --surface-2: #352b26;
    --ink: #f8efe7;
    --muted: #c0afa2;
    --line: #45382f;
    --line-strong: #9c8676;
    --outline: #9c8676;
    --shadow-c: #0e0907;
    --accent: #ffa8b8;
    --accent-fill: #ffa197;
    --accent-ink: #3a2e28;
    --accent-soft: #4b2b27;
    --select: #ffcf8f;
    --select-ink: #3a2e28;
    --tint-pink: #3d2724;
    --tint-mint: #263322;
    --tint-lemon: #3b301a;
    --tint-lav: #3a2733;
    --on-color: #1f1916;
    --ok: #93d4a3;
    --ok-fill: #6cc085;
    --ok-soft: #263322;
    --danger: #ff7466;
    --danger-soft: #48261f;
    --warn: #e8c46a;
    --warn-soft: #3b301a;
    --info: #dcb0e3;
    --info-soft: #3a2733;
    --c0: #8fb0f0; --c1: #93d4a3; --c2: #f39cc6; --c3: #e8c46a; --c4: #c9a8f0; --c5: #ffa8b8; --c6: #c0afa2;
    color-scheme: dark;
  }
}

/* ---------- 2. 基礎 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 var(--font);
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

/* ---------- 3. 版面 ---------- */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: var(--bw) solid var(--outline); }
.top-inner { padding: 12px var(--gutter) 8px; display: flex; align-items: center; gap: 12px; }
/* 站名：粉紅描邊膠囊，左邊是吉祥物 */
.top h1 { display: inline-flex; align-items: center; gap: 6px; font-size: 17px; letter-spacing: .02em; padding: 2px 14px 2px 4px; background: var(--accent-fill); color: var(--accent-ink); border: var(--bw) solid var(--outline); border-radius: var(--r-pill); box-shadow: var(--shadow-sm); white-space: nowrap; }
.top h1 img { width: 28px; height: 28px; display: block; }
/* 分頁：選中的是墨色實心膠囊 */
.tabs { padding: 2px var(--gutter) 10px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 3px 13px; color: var(--muted); text-decoration: none; white-space: nowrap; border: var(--bw) solid transparent; border-radius: var(--r-pill); font-weight: 600; }
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a.active { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.tabs a.active .count:not(:empty) { background: color-mix(in srgb, var(--bg) 22%, transparent); color: var(--bg); }
.main { padding: 20px var(--gutter) 64px; }

/* 卡片牆：每欄至少 360px，放得下幾欄就幾欄；.wide 佔滿一列；空格用後面的卡片補 */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); grid-auto-flow: dense; align-items: start; gap: 18px; margin-top: 18px; }
.ov-grid > .wide { grid-column: 1 / -1; }
.ov-grid > .card + .card { margin-top: 0; }
/* 輸入＋圖表並排：寬螢幕左右兩欄、等高 */
.split { display: grid; gap: 18px; margin: 0 0 26px; }
.split > .card + .card { margin-top: 0; }
@media (min-width: 1180px) { .split { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: stretch; } }
/* .split.even：兩張同等重要的卡片，760px 起左右各半；.split.start：各自依內容高度 */
@media (min-width: 760px) { .split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.split.start { align-items: start; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 區塊工具列：[標題] [分段／篩選] —— [次要] [主要] */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar h2 { margin: 0 4px 0 0; }
.toolbar .spacer { flex: 1; }
.section { margin-top: 26px; }

/* ---------- 4. 元件 ---------- */

/* 按鈕 */
/* 按鈕都是描邊膠囊加小錯位陰影；按下時往右下移、陰影消失，像把貼紙壓平 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: var(--bw) solid var(--outline); background: var(--surface); color: var(--ink); padding: 5px 15px; border-radius: var(--r-pill); cursor: pointer; font-size: 14px; line-height: 1.4; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm); transition: transform .08s, box-shadow .08s, background .15s; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn.primary { background: var(--accent-fill); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-fill) 85%, #fff); }
.btn.danger { background: var(--danger); color: var(--on-color); }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #fff); }
.btn.small { padding: 1px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 9px 12px; font-size: 15px; }
.btn.big-btn { width: 100%; font-size: 20px; padding: 16px; margin: 8px 0; border-radius: var(--r-lg); box-shadow: var(--shadow); }
.btn.big-btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: none; }
/* 對話框的刪除：平常是紅字，按第一下變紅底「確定刪除？」 */
#dlg-delete { background: transparent; color: var(--danger); border-color: transparent; box-shadow: none; }
#dlg-delete.confirm { background: var(--danger); color: var(--on-color); border-color: var(--outline); box-shadow: var(--shadow-sm); }
.linkbtn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; font-size: 13px; border-radius: var(--r-pill); text-decoration: none; }
.linkbtn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: var(--bw) solid var(--outline); background: var(--surface); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; display: inline-grid; place-items: center; text-decoration: none; box-shadow: var(--shadow-sm); }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn:disabled { opacity: .3; cursor: default; box-shadow: none; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* 卡片 */
.card { background: var(--surface); border: var(--bw) solid var(--outline); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 18px; }
/* 色塊卡片：只給「摘要」卡片用（總覽大標、這週、下次產檢、寶寶現在、帳本這個月），清單與表單卡片保持白色 */
.card.tint-pink { background: var(--tint-pink); }
.card.tint-mint { background: var(--tint-mint); }
.card.tint-lemon { background: var(--tint-lemon); }
.card.tint-lav { background: var(--tint-lav); }
/* 卡片標題、區塊標題：字級只寫在這一條，分頁的規則只放位置與間距（16px、15px 的小標題見 docs/ui-guidelines.md「卡片」） */
.card > h2, .card-title h2, .toolbar h2, .cal-head h2, .wc-head h2, .dec h3, .bf-topic, dialog h2, .auth-card h2 { font-size: 17px; }
/* 標題裡的 <small>：補充說明，不加粗、變淡 */
.card > h2 small, .phase > h2 small, .bf-topic small { font-weight: 400; color: var(--muted); font-size: 13px; }
.card > h2 { margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card > h2 .more { margin-left: auto; font-size: 13px; font-weight: 400; text-decoration: none; }
.card-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title h2 { margin: 0 0 2px; }
.card-sub { font-size: 12.5px; color: var(--muted); }

/* 分段按鈕 */
.seg { display: inline-flex; background: var(--surface); border: var(--bw) solid var(--outline); border-radius: var(--r-pill); padding: 2px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button, .seg a { border: 0; background: none; color: var(--muted); font-size: 13.5px; padding: 4px 13px; border-radius: var(--r-pill); cursor: pointer; text-decoration: none; white-space: nowrap; }
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg .on, .seg .on:hover { background: var(--ink); color: var(--bg); font-weight: 600; }

/* 膠囊（篩選、多選） */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: var(--bw) solid var(--outline); background: var(--surface); color: var(--ink); padding: 3px 12px; border-radius: var(--r-pill); cursor: pointer; font-size: 13.5px; text-decoration: none; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--select); color: var(--select-ink); box-shadow: var(--shadow-sm); }
/* 危險症狀：沒選時是紅色虛線（不嚇人），選了才變紅色實心 */
.chips.danger .chip { color: var(--danger); border-style: dashed; border-color: var(--danger); background: var(--surface); }
.chips.danger .chip:hover { background: var(--danger-soft); border-color: var(--danger); }
.chips.danger .chip.on { background: var(--danger); color: var(--on-color); border-style: solid; border-color: var(--danger); box-shadow: var(--shadow-sm); }

/* 圖示選項（心情） */
.moods { display: flex; gap: 6px; flex-wrap: wrap; }
.mood { display: grid; justify-items: center; gap: 2px; min-width: 58px; padding: 7px 6px 5px; border: var(--bw) solid var(--outline); border-radius: var(--r-alert); background: var(--surface); cursor: pointer; transition: background .15s, box-shadow .15s; }
.mood span { font-size: 24px; line-height: 1.1; filter: grayscale(.6); opacity: .7; transition: filter .15s, opacity .15s; }
.mood small { font-size: 11px; color: var(--muted); }
.mood:hover { background: var(--surface-2); }
.mood:hover span, .mood.on span { filter: none; opacity: 1; }
.mood.on { background: var(--accent-soft); box-shadow: var(--shadow-sm); }
.mood.on small { color: var(--ink); font-weight: 600; }

/* 標記 */
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: var(--r-pill); line-height: 18px; vertical-align: 1px; background: color-mix(in srgb, currentColor 13%, transparent); white-space: nowrap; }
.cat-0 { color: var(--c0); } .cat-1 { color: var(--c1); } .cat-2 { color: var(--c2); } .cat-3 { color: var(--c3); }
.cat-4 { color: var(--c4); } .cat-5 { color: var(--c5); } .cat-6 { color: var(--c6); }
.pill { display: inline-block; font-size: 12.5px; padding: 2px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.pill.warn { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.badge { font-style: normal; font-size: 11px; padding: 0 7px; border-radius: var(--r-pill); background: var(--warn-soft); color: var(--warn); margin-left: 4px; white-space: nowrap; }

/* 表單 */
/* 所有輸入框共用同一套外觀：沒寫 type 的 input 也算在內，只排除勾選框、單選、檔案這類不是打字的。
   用 :where 把優先順序壓到最低，元件（.input-unit、.add-item、.date-pill…）寫一個 class 就能覆蓋 */
:where(input:not([type=checkbox], [type=radio], [type=file], [type=hidden], [type=range], [type=color], [type=submit], [type=button], [type=reset]), select, textarea) {
  padding: 7px 12px; border: var(--bw) solid var(--line-strong); border-radius: var(--r-md); background-color: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.5; max-width: 100%;
}
:where(input, textarea)::placeholder { color: var(--muted); opacity: 1; } /* 不調淡：提示文字也要 4.5:1 */
:where(input:not([type=checkbox], [type=radio], [type=file]), select, textarea):hover:not(:focus, :disabled, [readonly]) { border-color: color-mix(in srgb, var(--line-strong) 55%, var(--outline)); }
/* 聚焦：邊框變墨色，右下出現蜜桃粉錯位陰影 */
:where(input:not([type=checkbox], [type=radio], [type=file]), select, textarea):focus { border-color: var(--outline); box-shadow: 2px 2px 0 var(--accent-fill); outline: none; }
/* 唯讀（例如要複製的網址）和停用：底色改淺灰，看得出不能改 */
:where(input, select, textarea):is(:disabled, [readonly]) { background-color: var(--surface-2); }
:where(input, select, textarea):disabled { color: var(--muted); cursor: not-allowed; }
/* 下拉選單：拿掉系統箭頭，改成墨色小箭頭，深色模式也跟著變色 */
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; }
/* Chrome 的日期、時間欄內建上下各 1px 內距，會比旁邊的輸入框、下拉選單高 2px，並排時底部一高一低 */
input::-webkit-datetime-edit-fields-wrapper { padding: 0; }
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }
/* 欄位：標籤文字 → 輸入元件 → 說明（<small>），由上往下排。整個網站只有這一種欄位寫法：
   寫 class="field"，或直接用 <label> 包住輸入框（對話框、設定卡片都是這樣），兩種都套這一條。
   不要在分頁裡另寫 label 樣式。勾選框、單選、開關（.check、.radio、.toggle）不算欄位。
   align-content: start：並排時（.grid2、.grid3），有說明的欄位只會讓自己變高，不會把旁邊欄位的輸入框撐大、撐歪。 */
.field,
:where(label:not(.check, .radio, .toggle):has(> :is(input:not([type=checkbox], [type=radio], [type=file], [type=hidden]), select, textarea))) {
  display: grid; gap: 4px; align-content: start; font-size: 13px; color: var(--muted);
}
:where(.field, label:not(.check, .radio, .toggle)) > :is(input:not([type=checkbox], [type=radio], [type=file], [type=hidden]), select, textarea) { width: 100%; }
:where(.field, label:not(.check, .radio, .toggle)) > small { font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.field-error { color: var(--danger); }
input[type=file]::file-selector-button { font: inherit; font-size: 13px; margin-right: 8px; padding: 2px 12px; border: var(--bw) solid var(--outline); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); cursor: pointer; }
.form-rows { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: start; }
.form-rows + .form-rows, .alert + .form-rows { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-label { font-size: 13px; color: var(--muted); padding-top: 7px; }
.form-rows input[type=text] { width: 100%; }
.input-unit { display: inline-flex; align-items: stretch; border: var(--bw) solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.input-unit:focus-within { border-color: var(--outline); box-shadow: 2px 2px 0 var(--accent-fill); }
.input-unit input { border: 0; border-radius: 0; width: 96px; padding: 7px 10px; font-size: 16px; font-variant-numeric: tabular-nums; background: transparent; }
.input-unit input:focus { box-shadow: none; }
.input-unit > span { padding: 0 10px; color: var(--muted); font-size: 13px; border-left: var(--bw) solid var(--line-strong); display: grid; place-items: center; background: var(--surface-2); }
/* 輸入框旁邊的按鈕（留言的「送出」、複製網址）：跟輸入框等高 */
.msg-form .btn, .copy-row .btn { align-self: stretch; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-pill { position: relative; border: var(--bw) solid var(--outline); background: var(--surface); color: var(--ink); border-radius: var(--r-pill); padding: 4px 14px; font-size: 14px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; box-shadow: var(--shadow-sm); }
.date-pill:not(button) { cursor: default; } /* 月份這類不能點的標籤（帳本） */
.date-pill em { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent); margin-left: 6px; }
.date-pill input { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.check { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); cursor: pointer; }
.check small { display: block; color: var(--muted); font-weight: 400; }
.check.small { font-size: 13px; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); cursor: pointer; }
/* 勾選清單（準備清單 .cl、產檢「這次要問的」.qs）：每列是 <label> 包勾選框加文字，勾選框 17px、薄荷綠 */
.cl li label, .qs label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.cl li input, .qs input { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--ok); flex: none; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
/* 展開說明（<details> 的 <summary>，總覽的推算預產期、計時的出發條件） */
.settings summary, .labor-rule summary { cursor: pointer; color: var(--accent); font-size: 14px; }
/* 危險的文字動作（「移除」「捨棄」），配 .linkbtn 用 */
.danger-text { color: var(--danger); }

/* 警示 */
/* 危險警示用紅色描邊加紅色錯位陰影，跟墨色描邊的一般卡片分得開；其他種類只有淡色邊框 */
.alert { display: flex; gap: 12px; align-items: flex-start; border: var(--bw) solid transparent; border-radius: var(--r-alert); padding: 12px 14px; margin: 12px 0 0; font-size: 14px; }
.alert:first-child { margin-top: 0; }
.toolbar + .alert { margin-bottom: 16px; } /* 工具列下面的整頁提示：跟下面的內容隔開，距離跟工具列一樣 */
.alert.danger { background: var(--danger-soft); border-color: var(--danger); box-shadow: 3px 3px 0 var(--danger); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.alert.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; color: var(--on-color); font-weight: 700; display: grid; place-items: center; font-size: 13px; margin-top: 1px; }
.alert.danger .alert-icon { background: var(--danger); }
.alert.warn .alert-icon { background: var(--warn); }
.alert.ok .alert-icon { background: var(--ok); }
.alert.info .alert-icon { background: var(--info); }
.alert-body { flex: 1; min-width: 0; }
.alert-body > b { display: block; margin-bottom: 2px; }
.alert.danger .alert-body > b { color: var(--danger); }
.alert.warn .alert-body > b { color: var(--warn); }
.alert.ok .alert-body > b { color: var(--ok); }
.alert-body p { margin: 3px 0 0; line-height: 1.6; }
.alert-body .src, .alert .src { font-size: 12px; color: var(--muted); }
.alert a { color: inherit; }
.alert .row-btns { margin-top: 8px; }
/* 全站橫幅（佇列的錯誤與提示，app.js 管理） */
.banner { margin: 12px var(--gutter) 0; padding: 12px 16px; border-radius: var(--r-alert); border: var(--bw) solid var(--danger); box-shadow: 3px 3px 0 var(--danger); background: var(--danger-soft); color: var(--danger); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner p { margin: 0; flex: 1 1 320px; }

/* 數字 */
.stats { display: flex; gap: 8px 26px; flex-wrap: wrap; }
.stat { display: grid; grid-template-columns: auto auto; column-gap: 4px; align-items: baseline; justify-content: start; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .u { font-size: 12px; color: var(--muted); }
.stat .l { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
/* 金額：等寬數字、粗體；收入加 .in（綠色，前面自己加「＋」）。放在 .mini .r 時字放大、不變灰 */
.amount, .mini .r.amount { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); white-space: nowrap; }
.amount.in, .mini .r.amount.in { color: var(--ok); }
.mini .r.amount { font-size: 14px; }

/* 頭像 */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--on-color); border: var(--bw) solid var(--outline); flex: none; }
.avatar.c0 { background: var(--c0); } .avatar.c1 { background: var(--c1); } .avatar.c2 { background: var(--c2); }
.avatar.c3 { background: var(--c3); } .avatar.c4 { background: var(--c4); } .avatar.c5 { background: var(--c5); } .avatar.c6 { background: var(--c6); }
.avatar.small { width: 24px; height: 24px; font-size: 11px; }

/* 空狀態、讀取中 */
/* 空狀態：虛線框，上方是睡覺的小豆子（用 block 排，文字裡有連結也不會被拆成好幾行） */
.empty-state { display: block; min-height: 120px; color: var(--muted); font-size: 14px; text-align: center; padding: 16px 18px 18px; border: var(--bw) dashed var(--line-strong); border-radius: var(--r-lg); line-height: 1.7; background: var(--surface); }
.empty-state::before { content: ""; display: block; width: 64px; height: 64px; margin: 0 auto 4px; background: url(../img/mascot/sleep.svg) center / contain no-repeat; }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0; }
.loading { color: var(--muted); }

/* 進度條 */
.bar { height: 12px; border-radius: var(--r-pill); background: var(--surface); border: var(--bw) solid var(--outline); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok-fill); border-radius: inherit; }

/* 清單：主要清單（日程、避免事項） */
.evs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: var(--bw) solid var(--outline); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.ev { display: grid; grid-template-columns: 28px 160px minmax(0, 1fr) auto; gap: 4px 14px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: start; }
.ev:first-child { border-top: 0; }
.ev .ck { padding-top: 2px; }
.ev .ck input { width: 18px; height: 18px; accent-color: var(--ok); cursor: pointer; }
.ev .ms { color: var(--accent); font-size: 13px; display: inline-block; padding: 2px 0 0 3px; }
.ev .dt b { font-weight: 600; font-variant-numeric: tabular-nums; display: block; }
.ev .dt small { color: var(--muted); font-size: 12.5px; }
.ev .tt { font-weight: 500; }
/* 長備註（日程、避免事項、選項比較）：保留換行、變淡、每行最多 78 字 */
.ev .note, .dec .note { white-space: pre-wrap; color: var(--muted); font-size: 13.5px; margin: 4px 0 0; max-width: 78ch; }
.ev .ext { font-size: 13px; }
.ev .side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.ev .rel { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ev.done .tt, .ev.done .dt b { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.ev.overdue { background: color-mix(in srgb, var(--danger-soft) 55%, var(--surface)); box-shadow: inset 4px 0 0 var(--danger); }
.ev.overdue .rel { color: var(--danger); font-weight: 600; }
.ev.milestone .tt { color: var(--accent); }
.ev.is-today .rel { color: var(--accent); font-weight: 600; }
.today-line { display: flex; align-items: center; gap: 8px; padding: 3px 16px; font-size: 12px; color: var(--accent); font-weight: 600; background: var(--accent-soft); }
/* 主要清單換成兩列的寬度是 640，不是手機斷點 560：四欄排法在 561–640px 時內容欄只剩約 200px，備註會折成三四行（2026-11-25 實測） */
@media (max-width: 640px) {
  .ev { grid-template-columns: 24px minmax(0, 1fr) auto; padding: 11px 14px; }
  .ev .dt { grid-column: 2 / 3; }
  .ev .bd { grid-column: 2 / 4; grid-row: 2; }
  .ev .side { grid-column: 3; grid-row: 1; }
}
/* 清單：卡片裡的短清單 */
.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px dashed var(--line); }
.mini li:first-child { border-top: 0; }
.mini .d { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 88px; }
.mini .t { flex: 1; min-width: 0; }
.mini .t small { display: block; color: var(--muted); font-size: 12.5px; }
.mini .r { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mini li.overdue .r { color: var(--danger); font-weight: 600; }
.mini.cols { columns: 2; column-gap: 28px; }
.mini.cols li { break-inside: avoid; border-top: 0; padding: 5px 0; }
@media (max-width: 760px) { .mini.cols { columns: 1; } }
/* 鍵值列表：左邊小標、右邊內容。一項資訊有好幾個欄位時用（例如補助的「誰可以領／期限／怎麼申請」） */
.kv { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 6px 10px; margin: 0; font-size: 14px; line-height: 1.6; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.kv dd { margin: 0; }
.kv dd small { display: block; color: var(--muted); font-size: 12.5px; }
/* 次數格：一排固定次數的格子（例如公費產檢 14 次）。有紀錄＝薄荷綠、下一次＝選取色、已過沒紀錄＝虛線、之後＝白底 */
.slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.slot { display: grid; justify-items: center; padding: 6px 4px 5px; border: var(--bw) solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); font-size: 12px; color: var(--muted); line-height: 1.4; }
.slot b { font-size: 15px; color: var(--ink); }
.slot em { font-style: normal; font-size: 11px; }
.slot.is-done { background: var(--ok-soft); border-color: var(--ok); }
.slot.is-done em { color: var(--ok); font-weight: 600; }
.slot.is-next { background: var(--select); border-color: var(--outline); color: var(--select-ink); box-shadow: var(--shadow-sm); }
.slot.is-next b, .slot.is-next em { color: var(--select-ink); font-weight: 600; }
.slot.is-missed { border-style: dashed; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sub-h { font-size: 13.5px; color: var(--muted); font-weight: 600; margin: 14px 0 4px; }

/* 時間軸 */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-day { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 0 14px; position: relative; padding-bottom: 20px; }
.tl-day::before { content: ''; position: absolute; left: 35px; top: 74px; bottom: 6px; border-left: 2px dashed var(--line-strong); }
.tl-date { display: grid; justify-items: center; align-content: start; gap: 1px; padding-top: 4px; text-align: center; }
.tl-dd { font-size: 26px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tl-mm { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tl-wk { margin-top: 5px; font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: var(--r-pill); padding: 1px 7px; white-space: nowrap; }
.tl-date.today .tl-dd { color: var(--accent); }
.tl-items { display: grid; gap: 8px; min-width: 0; }
/* 時間軸的卡片多，用小陰影，避免整頁太吵 */
.tl-card { background: var(--surface); border: var(--bw) solid var(--outline); border-radius: var(--r-lg); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.tl-kicker { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.tl-log-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tl-mood { font-size: 14px; margin-right: 4px; }
.tl-weight { margin-left: auto; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-weight small { font-size: 12px; font-weight: 400; color: var(--muted); }
.tl-note { margin: 8px 0 0; font-size: 14px; color: var(--muted); max-width: 78ch; }
.tl-who { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tl-who .spacer { flex: 1; }
.tl-kind { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: var(--r-pill); padding: 0 8px; }
.tl-text { margin: 0; white-space: pre-wrap; line-height: 1.75; max-width: 78ch; }
.tl-msg { display: flex; align-items: flex-end; gap: 8px; }
.tl-msg .bubble { background: var(--surface); border: var(--bw) solid var(--outline); border-radius: 16px 16px 16px 4px; padding: 7px 12px; max-width: min(560px, 85%); font-size: 14px; line-height: 1.6; }
.tl-msg.mine { flex-direction: row-reverse; }
.tl-msg.mine .bubble { background: var(--accent-soft); border-radius: 16px 16px 4px 16px; }
.bubble-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.bubble-meta b { color: var(--ink); font-size: 12.5px; }
.bubble-meta .linkbtn { padding: 0; font-size: 12px; }
.tl-more { text-align: center; margin-top: 4px; }

/* 照片 */
.pgrid { display: grid; gap: 4px; margin-top: 10px; border-radius: var(--r-md); overflow: hidden; }
.pgrid.one { grid-template-columns: 1fr; max-width: 480px; }
.pgrid.two { grid-template-columns: 1fr 1fr; max-width: 640px; }
.pgrid.many { grid-template-columns: repeat(3, 1fr); max-width: 640px; }
.pcell { position: relative; padding: 0; border: 0; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 1; display: block; overflow: hidden; }
.pgrid.one .pcell { aspect-ratio: 4 / 3; }
.pcell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.pcell:hover img { transform: scale(1.03); }
.pmore { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-size: 20px; font-weight: 700; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thumb { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--r-sm); overflow: hidden; line-height: 0; }
.thumb img { width: 84px; height: 84px; object-fit: cover; display: block; background: var(--surface-2); }
.lightbox { padding: 0; border: 0; background: transparent; box-shadow: none; max-width: 96vw; max-height: 92vh; }
.lightbox::backdrop { background: rgba(0, 0, 0, .8); }
.lightbox img { max-width: 96vw; max-height: 86vh; display: block; margin: 0 auto; }
.lightbox .hint { color: #ddd; text-align: center; }
/* 對話框裡的照片欄：縮圖方格＋「加照片」格；整欄可以拖照片進來（docs/ui-guidelines.md「照片欄」） */
.dlg-body .photos-field { gap: 10px; transition: background .15s, border-color .15s; }
.photos-field.is-drag { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.pf-count { font-variant-numeric: tabular-nums; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; align-items: start; }
.pf-tile { position: relative; display: grid; gap: 6px; min-width: 0; }
.pf-img { position: relative; aspect-ratio: 1; border: var(--bw) solid var(--outline); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-sm); }
.pf-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-badge { position: absolute; top: 5px; left: 5px; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: var(--r-pill); background: var(--select); color: var(--select-ink); border: 1.5px solid var(--outline); }
.pf-name { display: none; }
.pf-tile.no-preview img { display: none; }
.pf-tile.no-preview .pf-name { display: grid; place-items: center; height: 100%; padding: 8px; font-size: 12px; color: var(--muted); text-align: center; word-break: break-all; }
.pf-flag { display: none; }
.pf-tile.is-removed .pf-img { border-style: dashed; border-color: var(--danger); box-shadow: none; }
.pf-tile.is-removed .pf-img img { opacity: .3; filter: grayscale(1); }
.pf-tile.is-removed .pf-flag { display: grid; place-items: center; position: absolute; inset: 0; font-size: 13px; font-weight: 600; color: var(--danger); }
.pf-tile.is-removed .pf-cap { opacity: .45; }
.dlg-body .pf-cap { padding: 4px 9px; font-size: 13px; border-radius: var(--r-sm); }
.pf-x { position: absolute; top: -7px; right: -7px; width: 26px; height: 26px; padding: 0; border-radius: 50%; border: var(--bw) solid var(--outline); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); display: grid; place-items: center; font: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.pf-x:hover { background: var(--danger-soft); color: var(--danger); }
.pf-tile.is-removed .pf-x:hover { background: var(--ok-soft); color: var(--ok); }
.pf-x:active { transform: translate(2px, 2px); box-shadow: none; }
.dlg-body .pf-add { position: relative; aspect-ratio: 1; display: grid; place-content: center; justify-items: center; gap: 2px; padding: 8px; text-align: center; border: var(--bw) dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.dlg-body .pf-add[hidden] { display: none; }
.pf-add:hover, .pf-add:focus-within, .photos-field.is-drag .pf-add { border-color: var(--outline); color: var(--ink); background: var(--surface-2); }
.pf-add:focus-within { box-shadow: 2px 2px 0 var(--accent-fill); }
.pf-add small { font-size: 11px; line-height: 1.4; color: var(--muted); }
.pf-plus { font-size: 28px; line-height: 1; color: var(--accent); }
.pf-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (hover: none) { .pf-drag { display: none; } } /* 手機、平板不能拖檔案，只說「點一下選擇」 */
.pf-msg { margin: 0; font-size: 13px; color: var(--danger); white-space: pre-line; }

/* 圖表（依容器實際寬度重畫，文字固定大小） */
.chart-host { width: 100%; }
.chart-host .chart { display: block; width: 100%; height: auto; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-axis { stroke: var(--muted); stroke-width: 1; }
.ch-tick { fill: var(--muted); font-size: 12px; }
.ch-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.ch-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.ch-dot.alt { fill: var(--c0); }
.ch-band { fill: transparent; }
.ch-band.alt { fill: var(--surface-2); opacity: .55; }
.ch-band-label { fill: var(--muted); font-size: 11px; }
.ch-ref { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1; }
.ch-ref-label { fill: var(--muted); font-size: 11px; }
.ch-range { fill: var(--ok-soft); stroke: var(--ok); stroke-width: 1; }
.ch-range-label { fill: var(--ok); font-size: 11px; font-weight: 600; }
.ch-now { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 3; }
.ch-now-label { fill: var(--accent); font-size: 11px; font-weight: 600; }
.legend { display: inline-flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.legend i { display: inline-block; margin-left: 8px; }
.legend i:first-child { margin-left: 0; }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.lg-dot.alt { background: var(--c0); width: 10px; height: 10px; }
.lg-ref { width: 16px; border-top: 1.5px dashed var(--muted); }
.lg-range { width: 8px; height: 14px; border-radius: 4px; background: var(--ok-soft); border: 1px solid var(--ok); }

/* 對話框 */
dialog { border: var(--bw) solid var(--outline); border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 6px 6px 0 var(--shadow-c); }
/* 遮罩用錯位陰影的顏色（淺色可可、深色黑）。舊版瀏覽器的 ::backdrop 讀不到 :root 的變數，所以留備用值 */
dialog::backdrop { background: color-mix(in srgb, var(--shadow-c, #3a2e28) 40%, transparent); }
dialog form { padding: 20px 22px; display: grid; gap: 12px; max-height: calc(100vh - 48px); overflow: auto; }
.dlg-body { display: grid; gap: 12px; }
/* :where 把優先順序壓低：下面 .radio 裡的短欄位、其他元件寫一個 class 就能覆蓋，不用 !important */
.dlg-body :where(input:not([type=radio], [type=checkbox], [type=file]), select, textarea) { width: 100%; }
.dlg-body .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-body fieldset { border: var(--bw) solid var(--line); border-radius: var(--r-md); padding: 8px 12px 12px; display: grid; gap: 8px; margin: 0; }
.dlg-body legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.dlg-body .radio { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; flex-wrap: wrap; }
.dlg-body .radio input[type=number] { width: 80px; }
.dlg-body .radio input[type=date] { width: auto; }
.dlg-body .check { color: var(--ink); }
.dlg-error { color: var(--danger); margin: 0; font-size: 14px; white-space: pre-wrap; }
.dlg-actions { display: flex; gap: 8px; align-items: center; }
.dlg-actions .spacer { flex: 1; }

/* 頂部列的儲存狀態、分頁上的數字、帳號選單 */
.status { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status.saving { color: var(--warn); }
.status.unsaved { color: var(--danger); font-weight: 600; }
.count:not(:empty) { margin-left: 6px; font-size: 12px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); }
.count.is-alert:not(:empty) { background: var(--danger-soft); color: var(--danger); }
.tabs a.active .count.is-alert:not(:empty) { background: var(--danger); color: var(--on-color); }
.user-menu { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.user-menu .who { color: var(--muted); }
.user-menu a { text-decoration: none; }
.user-menu form { display: inline; margin: 0; }
@media (max-width: 560px) { .user-menu .who { display: none; } }

/* 錯誤頁 */
.fatal { max-width: 720px; }
.fatal h2 { color: var(--danger); margin-bottom: 8px; }
.fatal li { margin: 4px 0; }
.fatal code, .fatal pre { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.fatal pre { padding: 10px 12px; overflow-x: auto; }

/* ---------- 5. 各分頁 ---------- */

/* 總覽 */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 18px; align-items: center; padding: 20px 24px; }
.hero-main { display: grid; gap: 8px; min-width: 0; }
.hero-art { width: 112px; height: 112px; display: block; }
.hero .big { font-size: 30px; font-weight: 700; letter-spacing: .01em; }
.hero .sub { color: var(--muted); }
.hero .bar { height: 16px; margin-top: 6px; }
.hero .bar > i { background: var(--accent-fill); }
.hero .ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.weekly .wk-size { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.weekly .emoji { font-size: 30px; line-height: 1; }
.weekly .wk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .weekly .wk-grid { grid-template-columns: 1fr; } }
.weekly .wk-sec b { display: block; font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.weekly .wk-sec p { margin: 0; line-height: 1.7; }
.weekly .sources { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.weekly .sources a { color: inherit; }
.weekly .linkbtn { margin-top: 8px; padding-left: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.today-log { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.msg-form { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: nowrap; }
.msg-form input { flex: 1; min-width: 0; }
.msgs li { align-items: flex-start; }
.msgs li .t { display: flex; gap: 8px; align-items: flex-start; }
.msgs li.new .t b::after { content: ' 新'; color: var(--accent); font-size: 12px; }
.prog-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 6px 0; }
.prog-row a { text-decoration: none; color: var(--ink); }
.prog-row .bar { grid-column: 1 / -1; }
.prog-row span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.settings .grid2, .settings .grid3 { margin-bottom: 12px; }
.settings details { margin-top: 12px; }
.calc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.calc input { width: auto; }
.footnote { color: var(--muted); font-size: 12.5px; margin-top: 22px; }
.footnote code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* 日程、避免事項 */
.phase { margin-top: 24px; }
.phase:first-of-type { margin-top: 0; }
.phase > h2 { font-size: 15px; display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.ev.av .ic { display: inline-block; padding: 1px 0 0 3px; font-size: 14px; color: var(--muted); }
.ev.av.active { box-shadow: inset 3px 0 0 var(--warn); }
.ev.av.active .ic { color: var(--warn); }
.ev.av.ended .tt, .ev.av.ended .dt b { color: var(--muted); }
.ev.av .bd .ext { display: inline-block; margin-top: 4px; }

/* 月曆 */
.cal-head { display: flex; align-items: center; gap: 8px; }
.cal-head h2 { margin: 0 4px; min-width: 7.5em; text-align: center; }
.cal-wrap { overflow-x: auto; background: var(--surface); border: var(--bw) solid var(--outline); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal tr > :first-child { border-left: 0; }
.cal tr > :last-child { border-right: 0; }
.cal tbody tr:last-child td { border-bottom: 0; }
.cal th { font-size: 12px; color: var(--muted); padding: 6px 0; font-weight: 500; }
.cal td { border: 1px solid var(--line); vertical-align: top; padding: 0; height: 96px; }
.cal td.out { background: var(--surface-2); opacity: .6; }
.cal td.today .d { background: var(--accent-fill); color: var(--accent-ink); border-radius: var(--r-pill); padding: 0 6px; }
.cal td.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day { width: 100%; height: 100%; min-height: 96px; display: flex; flex-direction: column; gap: 2px; align-items: stretch; text-align: left; padding: 4px 5px; background: none; border: 0; color: inherit; cursor: pointer; overflow: hidden; min-width: 0; }
.cal-day .d { font-size: 13px; align-self: flex-start; }
.cal-day .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--c1); margin-left: 3px; vertical-align: 2px; }
.cal-day .wk { font-size: 11px; color: var(--accent); font-weight: 600; }
/* 格子裡的項目：日程 .sch、期限 .dl、產檢 .vs（不借用清單列的 .ev，免得吃到它的框線） */
.cal-item { display: block; max-width: 100%; font-size: 12px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 0 4px; }
.cal-item.sch { background: var(--accent-soft); }
.cal-item.sch.done { text-decoration: line-through; opacity: .6; }
.cal-item.dl { background: var(--warn-soft); color: var(--warn); }
.cal-item.vs { background: var(--ok-soft); color: var(--ok); }
.cal-item em, em.est { font-style: normal; font-size: 10px; color: var(--muted); margin-left: 2px; }
.cal-day .more { font-size: 10px; color: var(--muted); }
.cal-wrap + .hint { margin-top: 12px; }
.cal-detail { margin-top: 14px; }
@media (max-width: 560px) { .cal td { height: 64px; } .cal-day { min-height: 64px; padding: 2px 3px; } .cal-item { font-size: 10px; } }

/* 選項比較 */
.dec header { display: flex; gap: 12px; align-items: flex-start; }
.dec header > div { flex: 1; }
.dec .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.dec .note { margin-top: 6px; }
.state { font-size: 12.5px; padding: 1px 9px; border-radius: var(--r-pill); font-weight: 600; }
.state.open { background: var(--warn-soft); color: var(--warn); }
.state.closed { background: var(--ok-soft); color: var(--ok); }
.meta .late { color: var(--danger); font-weight: 600; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.opt { border: var(--bw) solid var(--outline); border-radius: var(--r-alert); padding: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--surface); box-shadow: var(--shadow-sm); }
.opt.chosen { border-color: var(--ok); box-shadow: 3px 3px 0 var(--ok); background: var(--ok-soft); }
.dec.decided .opt:not(.chosen) { opacity: .62; }
.opt-head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.opt .price { font-size: 13px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.opt p { margin: 0; font-size: 13.5px; white-space: pre-wrap; }
.opt .pros { color: var(--ok); }
.opt .cons { color: var(--danger); }
.opt-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.opt-actions .btn { flex: 1; }
.opt.add { border-style: dashed; border-color: var(--line-strong); box-shadow: none; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; min-height: 90px; font-size: 14px; }
.opt.add:hover { color: var(--ink); border-color: var(--outline); }
.btn.chosen-btn { background: var(--ok); color: var(--on-color); }

/* 準備清單 */
.cl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; }
.cl-grid > .card + .card { margin-top: 0; }
.cl header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.cl h3 { font-size: 16px; flex: 1; }
.cl .prog { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cl ul { list-style: none; margin: 10px 0 0; padding: 0; }
.cl li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.cl li label { flex: 1; }
.cl li.done span { color: var(--muted); text-decoration: line-through; }
.cl li small { display: block; color: var(--muted); font-size: 12.5px; white-space: pre-wrap; }
.cl li .linkbtn { visibility: hidden; }
.cl li:hover .linkbtn, .cl li:focus-within .linkbtn { visibility: visible; }
@media (hover: none) { .cl li .linkbtn { visibility: visible; } }
.add-item input { width: 100%; margin-top: 8px; padding: 6px 10px; border: var(--bw) dashed var(--line-strong); border-radius: var(--r-md); background: transparent; }
.add-item input:focus { border-style: solid; border-color: var(--outline); outline: none; }

/* 記錄：身體狀況 */
.day-card { padding: 18px 20px; }
.day-card .form-rows input.dc-note { width: 100%; }
.danger-open { border: var(--bw) dashed var(--line-strong); background: none; color: var(--muted); border-radius: var(--r-md); padding: 7px 12px; font-size: 13px; cursor: pointer; text-align: left; line-height: 1.5; }
.danger-open:hover { color: var(--danger); border-color: var(--danger); }
.weight-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.weight-field small { color: var(--muted); font-size: 12.5px; }
.dc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.dc-foot .linkbtn:hover { color: var(--danger); }
/* 記錄：體重（寬螢幕時跟左邊等高，圖表填滿剩下的高度） */
.wc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 20px; margin-bottom: 10px; }
.wc-head h2 { margin: 0; }
.wc-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.wc-foot .src a { color: inherit; }
@media (min-width: 1180px) {
  .weight-card { display: flex; flex-direction: column; }
  .weight-card .chart-host.fill { flex: 1 1 auto; position: relative; }
  .weight-card .chart-host.fill .chart { position: absolute; inset: 0; }
}

/* 產檢 */
.big-line { font-size: 18px; font-weight: 600; margin: 0 0 2px; }
.qs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qs small { display: block; color: var(--muted); font-size: 12.5px; }
.visits { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.visit .card-head { margin-bottom: 8px; }
.visit .meta { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.visit .measures { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.visit p { margin: 4px 0 0; max-width: 78ch; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.album figure { margin: 0; }
.album .thumb { display: block; width: 100%; border-radius: var(--r-md); }
.album .thumb img { width: 100%; height: 150px; }
.album figcaption { font-size: 13px; margin-top: 4px; }

/* 計時 */
.timer-read { font-size: 18px; margin: 4px 0; }
.timer-read .timer-num { font-size: 32px; font-weight: 700; } /* 不叫 .count：那是分頁上的數字膠囊 */
.ctable { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.ctable th, .ctable td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); }
.ctable th { font-size: 12px; color: var(--muted); font-weight: 500; }
.labor-rule summary { margin-top: 10px; }
.labor-rule .grid3 { margin-top: 8px; }
ol.plain { margin: 0; padding-left: 0; list-style: none; max-height: 40vh; overflow: auto; }

/* 寶寶 */
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.quick .btn { padding: 10px 14px; }
.baby-list li { align-items: center; }
.baby-list .t b { font-variant-numeric: tabular-nums; margin-right: 6px; }

/* 補助分頁（docs/design-benefits.md） */
.bf-place .hint { margin-top: 10px; }
.bf-county-note { margin: 12px 2px 0; }
.bf-top { margin-top: 18px; }
.bf-topic { margin: 26px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.bf-topic-hint { margin: -6px 0 12px; max-width: 72ch; }
.bf-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; align-items: start; }
.bf-list > .card + .card { margin-top: 0; }
.bf-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 6px; }
.bf-head h3 { font-size: 16px; margin: 0; }
.bf-amount { font-weight: 600; margin: 0 0 10px; line-height: 1.6; }
.bf-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.bf-actions .ext { font-size: 13px; }
.bf-actions .bf-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }

/* 產檢分頁：公費產檢 14 次 */
.pn-next { margin: 0 0 10px; }
.pn-next b { margin: 0 4px; }
.pn .mini li.pn-now .r { color: var(--ink); font-weight: 600; }
.pn .mini .d { min-width: 96px; }

/* ---------- 6. 表單頁（登入、註冊、家庭成員、行事曆訂閱） ---------- */
.auth-page { min-height: 100vh; }
.auth-wrap { max-width: 440px; margin: 0 auto; padding: 40px 16px 64px; }
.auth-wrap.wide { max-width: 760px; }
.auth-brand { margin: 0 0 16px; font-weight: 700; font-size: 18px; }
.auth-brand a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.auth-brand img { width: 40px; height: 40px; display: block; }
.auth-card h1 { font-size: 20px; margin-bottom: 12px; }
.auth-card h2 { margin: 22px 0 8px; }
.auth-intro { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.auth-form { display: grid; gap: 12px; }
/* 機器人驗證框（Cloudflare Turnstile）：先保留高度，框出現時送出按鈕不會被往下推 */
.auth-form .cf-turnstile { min-height: 65px; }
.auth-form .cf-turnstile[data-size="compact"] { min-height: 140px; }
.auth-links { margin: 0; font-size: 13.5px; text-align: center; }
.auth-below { text-align: center; font-size: 14px; color: var(--muted); margin-top: 16px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 200px; }
.member-list { list-style: none; margin: 0 0 14px; padding: 0; }
.member-list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.member-list li:first-child { border-top: 0; }
.member-list li > span:first-child { flex: 1; min-width: 0; }
.member-list small { color: var(--muted); }
.member-list form { margin: 0; }
/* 按兩下確認時出現的說明（public/js/form-guard.js）：自己佔一行，放在按鈕下面。寫成 form .confirm-note 才蓋得過上面 .member-list small 的灰字 */
form .confirm-note { color: var(--danger); display: block; flex-basis: 100%; font-size: 12.5px; line-height: 1.5; margin-top: 4px; }
.steps { padding-left: 18px; }
.steps li { margin: 6px 0; }

/* ---------- 手機 ---------- */
@media (max-width: 760px) { .ov-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .card { padding: 14px 16px; }
  .top-inner { gap: 8px; }
  .top h1 { font-size: 15px; padding: 1px 10px 1px 3px; }
  .top h1 img { width: 24px; height: 24px; }
  .hero { padding: 16px 18px; gap: 6px 12px; }
  .hero .big { font-size: 24px; }
  .hero-art { width: 76px; height: 76px; }
  .day-card { padding: 16px; }
  .form-rows { grid-template-columns: 1fr; gap: 6px; }
  .form-label { padding-top: 4px; font-weight: 600; color: var(--ink); }
  .form-rows > .form-label:not(:first-child) { margin-top: 10px; }
  .mood { min-width: 0; flex: 1; }
  .toolbar h2 { width: 100%; }
  .toolbar .spacer { display: none; }
  .tl-day { grid-template-columns: 1fr; padding-bottom: 18px; }
  .tl-day::before { display: none; }
  .tl-date { display: flex; align-items: baseline; gap: 8px; justify-content: start; margin-bottom: 8px; padding-top: 0; }
  .tl-dd { font-size: 20px; }
  .tl-wk { margin-top: 0; }
  .stats { gap: 8px 18px; }
  .stat .v { font-size: 19px; }
  .quick .btn { flex: 1 1 calc(50% - 8px); }
  /* 手機上常用的按鈕至少 40px 高；小按鈕（.btn.small）、文字按鈕（.linkbtn）不放大 */
  .btn:not(.small) { min-height: 40px; }
  .icon-btn { width: 40px; height: 40px; }
}

/* ---------- 少動畫 ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn, .mood, .mood span, .pcell img { transition: none; }
  .btn:active:not(:disabled), .icon-btn:active:not(:disabled), .btn.big-btn:active:not(:disabled), .pf-x:active { transform: none; }
}
