/* 每日運勢｜樣式
 * 風格：第 7 種「靛紫現代風」（2026-10-22 使用者核可，日用小工具走非品牌色系例外條款）。
 * 色碼來源：tokens.json 的 femh.archetype.indigo-modern（淺／深各一組）；狀態色用 femh.semantic、月曆星等用 femh.heat
 *          ——與姊妹作「42_1用藥提醒」同一套，不在這裡自己調色。
 * 字級：內容基準 17px，經 html{font-size:calc(17px*var(--fs))} 縮放（內容全用 rem）；頂欄、分頁列、側邊膠囊固定 px。
 * ⚠️ 值由 CSS 變數決定的屬性不可掛 transition（全域 §七⑧），這支完全不對顏色做 transition。
 * ⚠️ 吉／凶、宜／忌一律「圖示＋文字」雙訊號（✓ 宜、✕ 忌），不只靠顏色：
 *    紅色在農民曆代表吉、在介面代表錯誤，兩種意思會打架，所以不讓顏色單獨承載意義。
 */
:root {
  --fs: 1;
  --maxw: 760px;
  --topbar-h: 52px;
  --tabbar-h: 60px;

  /* 靛紫現代風（淺） */
  --bg: #F5F6FB;
  --surface: #FFFFFF;
  --line: #E2E5F0;
  --input-bd: #8B90A8;
  --zebra: #F7F8FC;
  --ink: #3A3F52;
  --ink2: #6B7288;
  --brand: #635BFF;
  --brand-txt: #4B44D9;
  --btn-bg: #635BFF;
  --btn-fg: #FFFFFF;
  --accent: #22B8CF;
  --link: #10808F;
  --th-bg: #EEF0F9;
  --badge-bg: #ECEAFE;
  --badge-txt: #4B44D9;
  --badge-bd: #D3CFFA;
  --note-bg: #FFEDE7;
  --note-txt: #A8431F;
  --note-bd: #FBD3C4;

  /* 語意（semantic.*） */
  --ok-bg: #E3F1E8;   --ok-fg: #1A5C38;   --ok-bd: #7FB89A;   --ok-txt: #1A5C38;
  --warn-bg: #FBE8C8; --warn-fg: #7A4F00; --warn-bd: #D4A75C; --warn-txt: #8A5A00;
  --bad-bg: #F9D8D3;  --bad-fg: #962317;  --bad-bd: #DE9086;  --bad-txt: #C0392B;
  --info-bg: #CFEAED; --info-fg: #0A5F67; --info-bd: #5FAEB7; --info-txt: #0C676F;

  /* 月曆星等五階（heat.*；每格都另印星數，顏色不單獨承載意義） */
  --h2: #B4D9C2; --on-h2: #2A352C;
  --h3: #7FBE98; --on-h3: #2A352C;
  --h4: #1A5C38; --on-h4: #FFFFFF;
  --h5: #0F3B23; --on-h5: #FFFFFF;

  --shadow-card: 0 6px 18px rgba(26, 92, 56, 0.09);
  --shadow-raised: 0 6px 22px rgba(26, 92, 56, 0.16);
  --scrim: rgba(0, 0, 0, 0.45);

  --font: "Helvetica Neue", Arial, "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "Noto Sans TC", sans-serif;
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #131522;
  --surface: #1B1E2E;
  --line: #2C3145;
  --input-bd: #6B7391;
  --zebra: #1F2233;
  --ink: #E7E9F5;
  --ink2: #9BA2BC;
  --brand: #8B85FF;
  --brand-txt: #A29DFF;
  --btn-bg: #5750E0;
  --btn-fg: #FFFFFF;
  --accent: #3FD0E8;
  --link: #5FD8EC;
  --th-bg: #232739;
  --badge-bg: #252449;
  --badge-txt: #A9A4FF;
  --badge-bd: #3D3A73;
  --note-bg: #33221C;
  --note-txt: #FF9E80;
  --note-bd: #5C382C;

  --ok-bg: #16302A;   --ok-fg: #4BD98A;   --ok-bd: #2F6B52;   --ok-txt: #00C35E;
  --warn-bg: #382C18; --warn-fg: #F0B65C; --warn-bd: #6B5530; --warn-txt: #E8A33D;
  --bad-bg: #3A211E;  --bad-fg: #F0897A;  --bad-bd: #6E403A;  --bad-txt: #E06C5C;
  --info-bg: #123035; --info-fg: #6FD5DE; --info-bd: #2E5B62; --info-txt: #13ABB9;

  /* 深色：由深到淺＝由低到高（與淺色明暗方向相反） */
  --h2: #2C5A3E; --on-h2: #E6EDE8;
  --h3: #3B7A54; --on-h3: #FFFFFF;
  --h4: #7FBE98; --on-h4: #2A352C;
  --h5: #B4D9C2; --on-h5: #2A352C;

  --shadow-card: 0 6px 18px rgba(0, 0, 0, 0.40);
  --shadow-raised: 0 6px 22px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html {
  font-size: calc(17px * var(--fs));
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 12px);
  scroll-behavior: auto;
  overflow-y: scroll;   /* 常駐捲軸位置：放大字級時頁面變長，框寬不會因捲軸出現而跳（ui-rules ⑥） */
}
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); line-height: 1.6;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 24px);
  overflow-wrap: anywhere;
}
button, input, select, textarea { font: inherit; font-size: 1em; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--ink2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--info-txt); text-decoration: underline; }   /* 連結一律加底線（藍綠與主色文字並排時分不出來）；用 info-txt：--link 疊在斑馬底只有 4.39:1 */

/* ─────────── 頂欄（固定 px，不隨字級縮放） ─────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  box-shadow: var(--shadow-card);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-in {
  max-width: var(--maxw); margin: 0 auto; height: var(--topbar-h);
  padding: 0 14px; display: flex; align-items: center; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; color: var(--brand-txt); min-width: 0; flex: 1 1 auto; }
.brand-ico { flex: none; width: 30px; height: 30px; border-radius: 9px; background: #FFFFFF; border: 1px solid var(--line); display: grid; place-items: center; font-size: 17px; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctl { display: flex; align-items: center; gap: 4px; flex: none; }
.ctl-btn {
  flex: none; min-width: 36px; height: 36px; padding: 0 6px; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--brand-txt);
  font-size: 14px; font-weight: 700; line-height: 1;
}
.ctl-btn:disabled { cursor: default; color: var(--ink2); background: var(--zebra); }
.ctl-pct { min-width: 44px; text-align: center; font-size: 14px; color: var(--ink2); font-variant-numeric: tabular-nums; }

/* ─────────── 主內容 ─────────── */
main { max-width: var(--maxw); margin: 0 auto; padding: 14px 14px 8px; outline: none; }
body.rail-inset main { padding-right: 74px; }
.view > * + * { margin-top: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 14px;
}
.card h2 { font-size: 1.1rem; line-height: 1.35; }
.card h3 { font-size: 1rem; }
.eyebrow { font-size: max(14px, .85rem); color: var(--ink2); font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.note { font-size: .88rem; color: var(--ink2); line-height: 1.55; }
.view > .note { color: var(--ink); }   /* 直接坐在頁面底（--bg）上的小字：--ink2 只有 4.43:1，改用 --ink */

/* ─────────── 按鈕 ─────────── */
.btn {
  text-decoration: none;
  min-height: 44px; padding: 8px 14px; border-radius: 12px; font-weight: 600; font-size: 1rem;
  border: 1px solid var(--input-bd); background: var(--surface); color: var(--brand-txt);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.btn:disabled { cursor: default; color: var(--ink2); background: var(--zebra); border-color: var(--line); }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.btn-sm { min-height: 40px; padding: 4px 10px; font-size: .92rem; border-radius: 10px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { color: var(--bad-txt); border-color: var(--bad-bd); }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--info-txt); text-decoration: underline; font-weight: 600; min-height: 32px; text-align: left; }

/* ─────────── 徽章 ─────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: max(13.5px, .8rem); font-weight: 600; line-height: 1.5; max-width: 100%; text-align: left;
  background: var(--badge-bg); color: var(--badge-txt); border: 1px solid var(--badge-bd);
}
button.chip { min-height: 32px; cursor: pointer; }
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.chip.bad { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }
.chip.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.chip.plain { background: var(--zebra); color: var(--ink); border-color: var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ─────────── 提示條 ─────────── */
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-bd); font-size: .95rem; line-height: 1.5;
}
.banner + .banner { margin-top: 8px; }
.banner.bad { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }
.banner.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.banner .b-ico { flex: none; }
.banner .b-body { flex: 1 1 auto; min-width: 0; }
.banner .btn { margin-top: 6px; }
#banners:empty { display: none; }
#banners { margin-bottom: 14px; }

/* ─────────── 日期列 ─────────── */
.dhead { display: grid; gap: 8px; }
.dhead-date { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.dhead-date b { font-size: 1.55rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.dhead-date .wk { font-size: 1.05rem; font-weight: 700; color: var(--brand-txt); }
.dhead-lunar { font-size: 1.05rem; font-weight: 700; }
.dhead-gz { font-size: .92rem; color: var(--ink2); }
.dnav { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(5.6rem, 100%), 1fr)); gap: 8px; align-items: center; }   /* 100% 時三顆一排；放大字級時自動換列，不撐破 */
.dnav .btn { white-space: nowrap; padding-inline: 6px; }
.dpick { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: center; font-size: .92rem; font-weight: 600; }
.dpick input[type="date"] { min-width: 0; max-width: 100%; min-height: 40px; }

/* 頂端圖卡導引（跳到哪一段；每張自帶摘要） */
.toc { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9.2rem, 100%), 1fr)); gap: 8px; }
.toc a {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 12px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); min-height: 56px;
}
.toc a b { font-size: .92rem; color: var(--brand-txt); }
.toc a span { font-size: .85rem; color: var(--ink2); line-height: 1.4; }
.toc-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.toc-bar .eyebrow { color: var(--ink); }

/* ─────────── 折疊區塊（⑩：預設展開；標題自帶摘要；全部展開／收合＋逐段） ─────────── */
details.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); }
details.sec > summary {
  list-style: none; cursor: pointer; padding: 12px 14px; min-height: 52px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 10px; align-items: center; font-weight: 700;
}
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "▾"; color: var(--ink2); grid-column: 3; grid-row: 1; }
details.sec[open] > summary::after { content: "▴"; }
details.sec > summary .s-ico { font-size: 1.25rem; line-height: 1; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; background: #FFFFFF; border: 1px solid var(--line); border-radius: 9px; }
details.sec > summary .s-title { font-size: 1.05rem; }
details.sec > summary .s-sum { grid-column: 2 / 4; font-weight: 500; font-size: .88rem; color: var(--ink2); line-height: 1.45; }
details.sec > .sec-body { padding: 2px 14px 14px; }
.sec-body > * + * { margin-top: 12px; }

/* ─────────── 星等 ─────────── */
.stars { color: var(--warn-txt); letter-spacing: 1px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stars .off { color: var(--ink2); }
.big-stars { font-size: 1.7rem; line-height: 1.1; }
.overall-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grade { font-size: 1.2rem; font-weight: 800; }
.comment { font-size: 1.02rem; line-height: 1.65; }

/* ─────────── 天氣 ─────────── */
.wx-now { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.wx-ico { font-size: 2.6rem; line-height: 1; width: 3.4rem; height: 3.4rem; display: grid; place-items: center; background: #FFFFFF; border: 1px solid var(--line); border-radius: 14px; }
.wx-t { font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wx-sub { font-size: .92rem; color: var(--ink2); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(8.5rem, 100%), 1fr)); gap: 8px; }
.kv > div { background: var(--zebra); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-width: 0; }
.kv dt, .kv .k { font-size: .85rem; color: var(--ink2); font-weight: 600; }
.kv dd, .kv .v { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.hours3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(4.6rem, 100%), 1fr)); gap: 6px; }
.hours3 > div { text-align: center; background: var(--zebra); border: 1px solid var(--line); border-radius: 10px; padding: 4px 2px; line-height: 1.35; }
.hours3 .h { font-size: .85rem; color: var(--ink2); font-weight: 600; }
.hours3 .i { font-size: 1.2rem; }
.hours3 .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.hours3 .r { font-size: .85rem; color: var(--info-txt); font-weight: 600; }
.hours3 > div.now { box-shadow: inset 0 0 0 2px var(--info-txt); }
.swatch { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 5px; border: 1px solid var(--input-bd); vertical-align: -0.15em; margin-right: 4px; }
.src-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--ink2); }
.lamp { display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem; border-radius: 50%; font-size: max(12.5px, .8rem); font-weight: 800; flex: none; }
.lamp.ok { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-bd); }
.lamp.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-bd); }
.lamp.bad { background: var(--bad-bg); color: var(--bad-fg); border: 1px solid var(--bad-bd); }

/* ─────────── 農民曆 ─────────── */
.yiji { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: start; }
.yiji .lab { font-weight: 800; font-size: 1.05rem; padding: 2px 10px; border-radius: 10px; text-align: center; min-width: 2.6em; }
.yiji .lab.yi { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-bd); }
.yiji .lab.ji { background: var(--bad-bg); color: var(--bad-fg); border: 1px solid var(--bad-bd); }
.alm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); gap: 8px; }
.alm-grid > div { background: var(--zebra); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-width: 0; }
.alm-grid .k { display: flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--ink2); font-weight: 600; }
.alm-grid .v { font-weight: 600; line-height: 1.5; }
.qbtn { flex: none; width: 1.6rem; height: 1.6rem; min-width: 26px; min-height: 26px; padding: 0; border-radius: 50%; border: 1px solid var(--input-bd); background: var(--surface); color: var(--brand-txt); font-size: .85rem; font-weight: 800; line-height: 1; }
.band { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(4.4rem, 100%), 1fr)); gap: 4px; margin-top: 6px; }
.band > span { text-align: center; font-size: max(14px, .85rem); font-weight: 600; line-height: 1.3; padding: 3px 2px; border-radius: 8px; border: 1px solid var(--line); min-width: 0; }
.band > span.good { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-bd); }
.band > span.bad { background: var(--zebra); color: var(--ink); border-style: dashed; border-color: var(--input-bd); }
.band > span.now { box-shadow: inset 0 -4px 0 var(--info-txt); }
.disclaimer { font-size: .85rem; color: var(--ink2); line-height: 1.55; }

/* ─────────── 時辰時間軸（A2） ─────────── */
.tl { list-style: none; margin: 0; padding: 0; }
.tl > li { display: grid; grid-template-columns: 4.6rem 1fr auto; gap: 4px 10px; align-items: start; padding: 8px 6px; border-top: 1px solid var(--line); }
.tl > li:first-child { border-top: 0; }
.tl > li.now { background: var(--info-bg); box-shadow: inset 4px 0 0 var(--info-txt); border-radius: 8px; }
.tl > li.now .tl-name small { color: var(--info-fg); }
.tl-name { font-weight: 800; line-height: 1.3; }
.tl-name small { display: block; font-weight: 500; font-size: .85rem; color: var(--ink2); font-variant-numeric: tabular-nums; }
.tl-main { min-width: 0; display: grid; gap: 6px; }
.tl-ev { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.tl-ev .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-ev.warn { border-color: var(--warn-bd); background: var(--warn-bg); color: var(--warn-fg); }
.tl-add { width: 2.4rem; height: 2.4rem; min-width: 36px; min-height: 36px; padding: 0; border-radius: 10px; border: 1px dashed var(--input-bd); background: var(--surface); color: var(--brand-txt); font-weight: 800; font-size: 1.1rem; }

/* ─────────── 星座 ─────────── */
.signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(5.6rem, 100%), 1fr)); gap: 6px; }
.signs button { min-height: 44px; border-radius: 10px; border: 1px solid var(--input-bd); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .92rem; padding: 2px 4px; }
.signs button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.signs button.mine:not([aria-pressed="true"]) { box-shadow: inset 0 0 0 2px var(--brand); }
.areas { display: grid; gap: 6px; }
.areas > div { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }   /* 放大字級時說明文字自動換到下一行（格線 1fr 會被星星擠到剩 34px 而撐破） */
.areas > div > span:last-child { min-width: 0; flex: 1 1 12em; }
.areas .a-name { font-weight: 700; }
.lucky { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); gap: 8px; }
.lucky > div { background: var(--zebra); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-width: 0; }
.lucky .k { font-size: .85rem; color: var(--ink2); font-weight: 600; }
.lucky .v { font-weight: 700; }
.lucky .why { font-size: .85rem; color: var(--ink2); line-height: 1.45; margin-top: 2px; }
.skytbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.skytbl th, .skytbl td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.skytbl th { background: var(--th-bg); font-weight: 700; }

/* ─────────── 事項 ─────────── */
.evlist { list-style: none; margin: 0; padding: 0; }
.evlist > li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 10px 2px; border-top: 1px solid var(--line); }
.evlist > li:first-child { border-top: 0; }
.ev-check { width: 26px; height: 26px; accent-color: var(--brand); }
.ev-dot { width: 26px; text-align: center; font-size: 1.05rem; }
.ev-title { font-weight: 700; line-height: 1.4; }
.ev-title.done { text-decoration: line-through; color: var(--ink2); }
.ev-sub { font-size: .85rem; color: var(--ink2); line-height: 1.45; }
.ev-sub .chip { margin: 2px 4px 0 0; }
.dategrp { font-weight: 800; margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.dategrp small { font-weight: 500; color: var(--ink2); }

/* ─────────── 表單 ─────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .lab { font-weight: 600; font-size: .95rem; }
.field .hint { font-size: .85rem; color: var(--ink2); line-height: 1.5; }
.input, select.input, textarea.input {
  width: 100%; min-width: 0; max-width: 100%; min-height: 46px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--input-bd);
  background: var(--surface); color: var(--ink); font-size: 1rem;
}
textarea.input { min-height: 80px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); gap: 10px; }
.seg { display: flex; border: 1px solid var(--input-bd); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1 1 0; min-height: 44px; border: 0; background: var(--surface); color: var(--ink); font-weight: 600; padding: 0 8px; }
.seg button + button { border-left: 1px solid var(--input-bd); }
.seg button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-fg); }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
.pick { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--zebra); }
.pick .pk-title { font-weight: 700; margin-bottom: 4px; }
.pick ul { margin: 4px 0 0; padding-left: 1.2em; }
.pick li { margin: 2px 0; }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ─────────── 週 ─────────── */
.wk-list { display: grid; gap: 10px; }
.wk-day { display: grid; grid-template-columns: 4.6rem 1fr; gap: 6px 12px; align-items: start; text-align: left; width: 100%;
  padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); color: var(--ink); }
.wk-day.today { border: 2px solid var(--brand); }
.wk-date b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.wk-date span { font-size: .85rem; color: var(--ink2); }
.wk-date .rest { color: var(--bad-txt); font-weight: 700; }
.wk-main { min-width: 0; display: grid; gap: 4px; }
.wk-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: .92rem; }

/* ─────────── 月 ─────────── */
.cal-head { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.cal-head h2 { text-align: center; font-size: 1.15rem; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 10px; }
.cal-dow { text-align: center; font-size: .85rem; color: var(--ink2); font-weight: 700; padding: 2px 0; }
.cell {
  position: relative; min-width: 0; min-height: 4.2rem; padding: 3px 2px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 1px;
  line-height: 1.15; font-variant-numeric: tabular-nums; text-align: center;
}
.cell .d { font-weight: 800; font-size: .95rem; }
.cell .lu { font-size: max(12.5px, .7rem); max-width: 100%; overflow-wrap: anywhere; }
.cell .st { font-size: max(12.5px, .7rem); font-weight: 700; }
.cell .evn { font-size: max(12.5px, .7rem); font-weight: 700; }
.cell .rest { position: absolute; top: 1px; left: 2px; font-size: 12.5px; font-weight: 800; line-height: 1.2; padding: 0 2px; border-radius: 4px; background: var(--surface); color: var(--bad-txt); }   /* 自帶白底：疊在星等色塊上也夠對比 */
.cell.out { background: var(--zebra); color: var(--ink2); border-style: dashed; }
.cell.l2 { background: var(--h2); color: var(--on-h2); border-color: var(--h2); }
.cell.l3 { background: var(--h3); color: var(--on-h3); border-color: var(--h3); }
.cell.l4 { background: var(--h4); color: var(--on-h4); border-color: var(--h4); }
.cell.l5 { background: var(--h5); color: var(--on-h5); border-color: var(--h5); }
.cell.today { outline: 3px solid var(--brand); outline-offset: 1px; }
.cell.match { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.cell.match::after { content: "✓"; position: absolute; top: 0; right: 3px; font-size: 12.5px; font-weight: 800; }
.cell.nomatch { background: var(--zebra); color: var(--ink2); border-color: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .85rem; color: var(--ink2); }
.legend i { display: inline-block; width: 18px; height: 18px; border-radius: 5px; vertical-align: -4px; margin-right: 4px; border: 1px solid var(--line); }
.legend i.l2 { background: var(--h2); } .legend i.l3 { background: var(--h3); } .legend i.l4 { background: var(--h4); } .legend i.l5 { background: var(--h5); }
.legend i.l1 { background: var(--surface); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { min-height: 40px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--input-bd); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .92rem; }
.filters button[aria-pressed="true"] { background: var(--badge-bg); color: var(--badge-txt); border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }

/* ─────────── 設定 ─────────── */
.fam { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.fam:first-child { border-top: 0; }
.order { list-style: none; margin: 0; padding: 0; }
.order li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.order li:first-child { border-top: 0; }
.order li.off .o-name { color: var(--ink2); text-decoration: line-through; }
.log { width: 100%; border-collapse: collapse; font-size: .88rem; }
.log th, .log td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log th { background: var(--th-bg); }
.log td.okc { color: var(--ok-txt); font-weight: 700; }
.log td.badc { color: var(--bad-txt); font-weight: 700; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr)); gap: 2px 12px; }
.checks label { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.checks input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

/* ─────────── 彈窗 ─────────── */
dialog.sheet {
  padding: 0; border: 0; background: var(--surface); color: var(--ink); width: min(100vw, 640px); max-width: 100vw;
  max-height: 94dvh; margin: auto auto 0; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-raised);
}
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 18px; max-height: 90dvh; } }
dialog.sheet::backdrop { background: var(--scrim); }
.sheet-in { max-height: inherit; overflow-y: auto; padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.sheet-in > * + * { margin-top: 12px; }
.sheet-bar {
  position: sticky; top: -14px; z-index: 2; margin: -14px -14px 12px; padding: 14px 14px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px;
}
.sheet-bar h2 { font-size: 1.1rem; flex: 1 1 auto; min-width: 0; }
.sheet-bar .btn { flex: none; }
.sheet-in::-webkit-scrollbar { width: 10px; }
.sheet-in::-webkit-scrollbar-thumb { background: var(--input-bd); border-radius: 5px; }
.sheet-foot { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-foot .btn { flex: 1 1 auto; }
.why-tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.why-tbl th, .why-tbl td { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.why-tbl th { background: var(--th-bg); }
.why-tbl td.d { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.why-tbl td.d.pos { color: var(--ok-txt); }
.why-tbl td.d.neg { color: var(--bad-txt); }
.formula { padding: 10px 12px; border-radius: 12px; background: var(--badge-bg); color: var(--badge-txt); border: 1px solid var(--badge-bd); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ─────────── 提示（可復原） ─────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 400;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
  max-width: min(92vw, 560px); width: max-content; padding: 10px 14px; border-radius: 14px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-raised);
  display: flex; align-items: center; gap: 12px; font-size: 15px; line-height: 1.45;
}
html[data-theme="dark"] .toast { background: #E7E9F5; color: #131522; }
.toast button { flex: none; min-height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid currentColor; background: transparent; color: inherit; font-weight: 700; font-size: 15px; }

/* ─────────── 分頁列（固定 px） ─────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 110; background: var(--surface);
  border-top: 2px solid var(--line); box-shadow: 0 -6px 18px rgba(26, 92, 56, 0.09);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html[data-theme="dark"] .tabbar { box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.4); }
.tabbar-in { max-width: var(--maxw); margin: 0 auto; height: var(--tabbar-h); display: grid; grid-template-columns: repeat(5, 1fr); }
.tab {
  border: 0; background: none; color: var(--ink2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 15px; font-weight: 600; min-width: 0; border-top: 3px solid transparent;
}
.tab-ico { font-size: 19px; line-height: 1; }
.tab[aria-current="page"] { color: var(--brand-txt); border-top-color: var(--brand); background: var(--badge-bg); }

/* ─────────── 側邊導覽膠囊（尺寸固定，位置由 JS 量測） ─────────── */
#rail {
  position: fixed; z-index: 120; top: 50%; transform: translateY(-50%);
  left: var(--rail-left, calc(100% - 66px));
  display: flex; flex-direction: column; gap: 7px; align-items: center; padding: 9px 7px;
  border: 1px solid var(--line); border-radius: 29px; background: var(--surface); box-shadow: var(--shadow-raised); font-size: 15px;
}
.rbtn {
  width: 36px; height: 36px; flex: none; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--bg); color: var(--brand-txt); font-size: 16px; font-weight: 700; line-height: 1;
}
.rbtn:disabled { cursor: default; color: var(--ink2); background: var(--zebra); }
#r-top { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
#r-top:disabled { background: var(--zebra); color: var(--ink2); border-color: var(--line); }
#rail.rail-edge { left: auto; right: 14px; }
@media (max-width: 960px) {
  /* 窄幕：橫排、收到右下角（閃開分頁列，位置由 JS 量測）；四顆鈕全部保留（ui-rules ⑥） */
  #rail { left: auto; right: 8px; top: auto; bottom: var(--rail-bottom, 84px); transform: none; flex-direction: row; padding: 6px 8px; transition: opacity .25s; }
  #rail.rail-dim { opacity: .38; }
}

/* ─────────── 長輩大字模式（C3）：只留核心卡片、按鈕加大 ─────────── */
html.elder .btn { min-height: 56px; font-size: 1.1rem; }
html.elder .btn-sm { min-height: 52px; }
html.elder [data-card]:not([data-core]) { display: none !important; }
html.elder .toc a:not([data-core]) { display: none; }

/* ─────────── 列印 ─────────── */
@media print {
  .no-print, .topbar, .tabbar, #rail, .toast, #banners, .dnav, .toc-bar button, .tl-add { display: none !important; }
  html { font-size: 11pt !important; }
  body { background: #fff !important; color: #000 !important; padding: 0 !important; }
  main { max-width: none !important; padding: 0 !important; }
  .view[hidden] { display: none !important; }
  details { display: block !important; }
  details > * { display: revert !important; }
  details::details-content { content-visibility: visible !important; block-size: auto !important; }
  .card, details.sec { box-shadow: none !important; }
  .chip, .note, .disclaimer, .eyebrow, .ev-sub, .tl-name small, .alm-grid .k, .kv .k, .lucky .k, .lucky .why { font-size: 9.5pt !important; }
}

/* ─────────── 跳到主要內容／減少動效 ─────────── */
.skip { position: absolute; left: 8px; top: -60px; z-index: 500; padding: 10px 14px; border-radius: 10px; background: var(--btn-bg); color: var(--btn-fg); font-weight: 700; text-decoration: none; }
.skip:focus { top: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }

details.sub > summary { cursor: pointer; list-style: none; }
details.sub > summary::-webkit-details-marker { display: none; }
details.sub > summary::before { content: "▸ "; }
details.sub[open] > summary::before { content: "▾ "; }
details.sub > * + * { margin-top: 8px; }
