/* 郵件待處理系統 視覺系統(票 01 定案)
 *
 * 方向：像一份整理乾淨的紙本待辦夾。暖白紙底、深墨綠字、庭芳洋紅只用在「要你動手」的地方
 * (主要按鈕、目前分頁、焦點)，狀態色(逾期紅、今天到期琥珀、完成綠、有新來信藍)各司其職不混用。
 * 手機優先：單欄、大觸控區(最小 44px)、整頁捲動(iPhone Safari 不做整頁 fixed 版面)；
 * 電腦版內容置中、最寬 880px，清單卡片改兩段式排版。
 *
 * token 分四組：顏色、字級、間距、圓角與陰影。元件只准用 token，不寫死數值。
 */
:root {
  /* 顏色：底與字 */
  --bg: #F6F4EF; --surface: #FFFFFF; --surface-2: #F0EEE8; --surface-3: #E9E6DE;
  --ink: #1E2926; --ink-2: #3F4A46; --muted: #6A746F; --ph: #9CA39F;
  --line: #E4E1D9; --line-2: #D3CFC5;
  /* 品牌：庭芳洋紅(按鈕底用深一階，白字對比 5:1 以上) */
  --brand: #E4007F; --primary: #C8006F; --primary-hover: #A8005D; --primary-soft: #FCEAF3; --on-primary: #FFFFFF;
  /* 狀態 */
  --late: #B42318; --late-soft: #FDECEA; --late-line: #F4C7C2;
  --due: #9A5800; --due-soft: #FFF4DF; --due-line: #F1D9A6;
  --ok: #1D6B45; --ok-soft: #E5F3EB;
  --info: #2A5B9A; --info-soft: #E8F0FA;
  --focus: rgba(200, 0, 111, .24);
  /* 字級(手機基準 16px，不小於 13px) */
  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 13px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 18px; --fs-xl: 21px; --fs-2xl: 26px;
  /* 間距：4 的倍數 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  /* 圓角與陰影 */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(30, 41, 38, .05), 0 2px 10px rgba(30, 41, 38, .04);
  --shadow-2: 0 2px 4px rgba(30, 41, 38, .06), 0 10px 28px rgba(30, 41, 38, .08);
  --shadow-3: 0 18px 50px rgba(30, 41, 38, .22);
  --wrap: 880px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141716; --surface: #1C201F; --surface-2: #232826; --surface-3: #2B312F;
    --ink: #ECEFEC; --ink-2: #CBD1CD; --muted: #98A29D; --ph: #6C7571;
    --line: #2C3230; --line-2: #3A413E;
    --brand: #FF4DA6; --primary: #FF5CAD; --primary-hover: #FF85C1; --primary-soft: #3A1B2B; --on-primary: #1B0912;
    --late: #FF8A7E; --late-soft: #3A1B18; --late-line: #5B2A25;
    --due: #F4B860; --due-soft: #372A12; --due-line: #54401C;
    --ok: #6FD19A; --ok-soft: #16301F; --info: #8DB6F2; --info-soft: #1A2638;
    --focus: rgba(255, 92, 173, .32);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 8px 24px rgba(0, 0, 0, .35); --shadow-3: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141716; --surface: #1C201F; --surface-2: #232826; --surface-3: #2B312F;
  --ink: #ECEFEC; --ink-2: #CBD1CD; --muted: #98A29D; --ph: #6C7571;
  --line: #2C3230; --line-2: #3A413E;
  --brand: #FF4DA6; --primary: #FF5CAD; --primary-hover: #FF85C1; --primary-soft: #3A1B2B; --on-primary: #1B0912;
  --late: #FF8A7E; --late-soft: #3A1B18; --late-line: #5B2A25;
  --due: #F4B860; --due-soft: #372A12; --due-line: #54401C;
  --ok: #6FD19A; --ok-soft: #16301F; --info: #8DB6F2; --info-soft: #1A2638;
  --focus: rgba(255, 92, 173, .32); color-scheme: dark;
}

/* ── 基礎 ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
/* [hidden] 的預設權重最低，任何自己寫的 display 都蓋得過它，所以要 !important */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); font-size: var(--fs-md); line-height: 1.6; color: var(--ink); background: var(--bg);
       min-height: 100vh; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.view { max-width: var(--wrap); margin: 0 auto;
        padding: var(--s5) max(var(--s4), env(safe-area-inset-right)) calc(var(--s8) + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-left)); }

/* ── 頂欄：跟著頁面捲走(不 fixed)，iPhone Safari 的工具列才不會蓋住內容 ── */
.top { background: color-mix(in srgb, var(--bg) 88%, var(--surface)); border-bottom: 1px solid var(--line); }
.top-in { max-width: var(--wrap); margin: 0 auto; height: 60px; display: flex; align-items: center; gap: var(--s3);
          padding: 0 max(var(--s4), env(safe-area-inset-right)) 0 max(var(--s4), env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: var(--fs-lg);
         letter-spacing: .02em; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.top-link { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--r-pill);
            color: var(--ink-2); font-weight: 700; font-size: var(--fs-sm); }
.top-link:hover { background: var(--surface-2); text-decoration: none; }
.top-link.on { background: var(--primary-soft); color: var(--primary); }
.me { position: relative; }
.me-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 4px; border: 1px solid var(--line);
          background: var(--surface); border-radius: var(--r-pill); cursor: pointer; }
.me-btn:hover { border-color: var(--line-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 800;
          background: var(--primary-soft); color: var(--primary); }
.me-name { font-size: var(--fs-sm); font-weight: 700; max-width: 7em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 240px; background: var(--surface);
        border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); padding: 6px; }
.menu-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.menu-head span { font-size: var(--fs-xs); color: var(--muted); }
.menu button, .menu a { display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
                        padding: 11px 12px; border-radius: var(--r-sm); color: var(--ink); font-size: var(--fs-sm); }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
@media (max-width: 480px) { .me-name { display: none; } .me-btn { padding: 0 4px; } .brand { font-size: var(--fs-md); } }

/* ── 按鈕 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
       border: 0; border-radius: var(--r-pill); cursor: pointer; font-weight: 700; white-space: nowrap;
       background: var(--primary); color: var(--on-primary); transition: background .15s, transform .06s, box-shadow .15s;
       box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 4px 12px color-mix(in srgb, var(--primary) 22%, transparent); }
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; transform: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn.quiet { background: transparent; color: var(--ink-2); box-shadow: none; }
.btn.quiet:hover { background: var(--surface-2); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.actions { display: flex; gap: var(--s2); margin-top: var(--s5); }
.actions .btn { flex: 1; }

/* ── 輸入 ── */
.field { display: block; }
.field + .field { margin-top: var(--s4); }
.field > span { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=tel], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 48px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px 14px; outline: none; font-size: var(--fs-md); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--focus); }
input::placeholder, textarea::placeholder { color: var(--ph); }

/* ── 卡片、標籤、提示條 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: var(--s5); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--r-pill);
        font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.chip.late { background: var(--late-soft); color: var(--late); }
.chip.due { background: var(--due-soft); color: var(--due); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--primary-soft); color: var(--primary); }
.chip svg { width: 14px; height: 14px; }
.banner { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md);
          font-size: var(--fs-sm); background: var(--info-soft); color: var(--info); }
.banner.warn { background: var(--due-soft); color: var(--due); }
.banner.late { background: var(--late-soft); color: var(--late); }
.banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ── 頁首(每一頁的標題列) ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.page-head h1 { font-size: var(--fs-2xl); line-height: 1.25; letter-spacing: .01em; }
.page-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }

/* ── 分頁(清單的四個分頁)：手機可以左右滑，不換行 ── */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-pill);
        overflow-x: auto; scrollbar-width: none; margin-bottom: var(--s5); }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px;
       border-radius: var(--r-pill); color: var(--ink-2); font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
.tab .count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); display: inline-grid; place-items: center;
              font-size: 12px; background: var(--surface-3); color: var(--muted); }
.tab.on .count { background: var(--primary-soft); color: var(--primary); }

/* ── 待處理事項卡片(票 02 起用)：左邊一條狀態色，一眼分出逾期、今天到期 ── */
.items { display: grid; gap: var(--s3); }
.item { position: relative; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
        box-shadow: var(--shadow-1); padding: var(--s4) var(--s4) var(--s4) calc(var(--s4) + 4px); color: var(--ink); overflow: hidden;
        transition: box-shadow .15s, border-color .15s, transform .06s; }
.item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line-2); }
.item:hover { text-decoration: none; box-shadow: var(--shadow-2); border-color: var(--line-2); }
.item:active { transform: scale(.995); }
.item.late { border-color: var(--late-line); } .item.late::before { background: var(--late); }
.item.due::before { background: var(--due); }
.item.done { opacity: .78; } .item.done::before { background: var(--ok); }
.item-top { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: 6px; }
.item h3 { font-size: var(--fs-lg); line-height: 1.45; font-weight: 800; }
.item .act { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 4px; }
.item .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: var(--s3); font-size: var(--fs-xs); color: var(--muted); }
.item .meta span { display: inline-flex; align-items: center; gap: 4px; }
.item .meta svg { width: 14px; height: 14px; opacity: .8; }
.deadline { margin-left: auto; font-weight: 800; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.item.late .deadline { color: var(--late); } .item.due .deadline { color: var(--due); }
@media (min-width: 720px) {
  .item { display: grid; grid-template-columns: 1fr auto; column-gap: var(--s5); padding: var(--s5) var(--s5) var(--s5) calc(var(--s5) + 4px); }
  .item-top { grid-column: 1 / -1; }
  .item .meta { grid-column: 1 / -1; }
}

/* ── 空狀態 ── */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: var(--s8) var(--s5);
         background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty .art { width: 96px; height: 96px; margin-bottom: var(--s2); }
.empty h2 { font-size: var(--fs-xl); }
.empty p { color: var(--muted); font-size: var(--fs-sm); max-width: 28em; }

/* ── 登入與門口(尚未開通)頁 ── */
.gate { min-height: calc(100vh - 40px); display: grid; align-content: center; justify-items: center; padding: var(--s6) 0; }
.gate-box { width: 100%; max-width: 400px; }
.gate-head { text-align: center; margin-bottom: var(--s6); }
.gate-head .logo { width: 72px; height: 72px; border-radius: 50%; box-shadow: var(--shadow-2); }
.gate-head .org { margin-top: var(--s4); font-size: var(--fs-sm); color: var(--muted); letter-spacing: .12em; }
.gate-head h1 { font-size: var(--fs-2xl); line-height: 1.3; margin-top: 2px; letter-spacing: .04em; }
.gate .card { padding: var(--s6) var(--s5); }
.gate .banner { margin-bottom: var(--s4); }
.login-actions { display: flex; gap: var(--s2); margin-top: var(--s5); }
.login-actions #go { flex: 1; }
#passkey { width: 48px; min-width: 48px; padding: 0; background: var(--surface); color: var(--primary); border: 1px solid var(--line-2); box-shadow: none; }
#passkey:hover { background: var(--primary-soft); border-color: var(--primary); }
#passkey svg { width: 26px; height: 26px; }
.forgot { text-align: center; margin-top: var(--s4); font-size: var(--fs-sm); }
.gate-foot { text-align: center; margin-top: var(--s5); font-size: var(--fs-xs); color: var(--muted); }
.gate-closed { text-align: center; }
.gate-closed .art { width: 88px; height: 88px; margin: 0 auto var(--s3); }
.gate-closed h2 { font-size: var(--fs-xl); }
.gate-closed p { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--s2); }

/* ── 彈窗、提示、載入 ── */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(20, 23, 22, .45); display: grid; place-items: center; padding: var(--s4); }
.modal { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: var(--s6) var(--s5) var(--s5); }
.modal p { font-size: var(--fs-md); line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
         background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: var(--r-pill); font-size: var(--fs-sm);
         font-weight: 700; box-shadow: var(--shadow-3); max-width: calc(100vw - 32px); }
.loading { display: grid; place-items: center; min-height: 160px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 2s !important; } }

/* ── 樣式頁(#/style)：視覺系統的樣張，截圖自查用 ── */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--s2); }
.swatch { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); font-size: var(--fs-xs); }
.swatch i { display: block; height: 44px; }
.swatch b, .swatch span { display: block; padding: 0 10px; }
.swatch b { padding-top: 6px; } .swatch span { color: var(--muted); padding-bottom: 8px; }
.section-title { font-size: var(--fs-sm); font-weight: 800; color: var(--muted); letter-spacing: .08em; margin: var(--s7) 0 var(--s3); }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* ── 詳細頁(票 02)：上面是這件事(要做什麼、什麼時候前)，下面是原信全文與附件 ── */
.muted { color: var(--muted); }
.deadline.muted { color: var(--muted); font-weight: 700; }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin: calc(-1 * var(--s2)) 0 var(--s2) -6px;
        color: var(--ink-2); font-weight: 700; font-size: var(--fs-sm); }
.back svg { width: 20px; height: 20px; }
.back:hover { color: var(--primary); text-decoration: none; }
.detail h1 { font-size: var(--fs-xl); line-height: 1.4; margin-top: var(--s2); }
.todo { margin-top: var(--s4); padding: var(--s3) var(--s4); background: var(--primary-soft); border-radius: var(--r-md); }
.todo span { display: block; font-size: var(--fs-xs); font-weight: 800; color: var(--primary); letter-spacing: .08em; }
.todo p { margin-top: 2px; font-weight: 700; color: var(--ink); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
.facts dt, .mail-meta dt { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; }
.facts dd { font-weight: 800; font-variant-numeric: tabular-nums; }
.mail { padding: var(--s5) var(--s4); }
.mail-subject { font-size: var(--fs-lg); line-height: 1.45; margin-bottom: var(--s2); }
.mail-meta { display: grid; gap: var(--s2); margin: var(--s3) 0 var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mail-meta > div { display: grid; grid-template-columns: 5em 1fr; gap: var(--s2); align-items: baseline; }
.mail-meta dd { font-size: var(--fs-sm); min-width: 0; overflow-wrap: anywhere; }
.addr { color: var(--muted); font-size: var(--fs-xs); }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--r-pill); margin-bottom: var(--s3); }
.seg button { border: 0; background: none; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
/* 原信 HTML 放 sandbox iframe，量不到內容高度，所以給固定高度、框內自己捲 */
.mail-frame { display: block; width: 100%; height: 62vh; min-height: 320px; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-md); line-height: 1.75; }
.att-title { display: flex; align-items: center; gap: 6px; margin-top: var(--s5); font-size: var(--fs-sm); font-weight: 800; color: var(--ink-2); }
.att-title svg { width: 16px; height: 16px; }
.atts { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s2); }
.att { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.att.bad { background: var(--late-soft); border-color: var(--late-line); }
.att-name { flex: 1; min-width: 0; display: grid; }
.att-name b { font-size: var(--fs-sm); overflow-wrap: anywhere; }
.att-name span { font-size: var(--fs-xs); color: var(--muted); }
.mail-foot { margin-top: var(--s4); font-size: var(--fs-xs); color: var(--ph); text-align: right; }
.mail-card .act b { color: var(--muted); font-weight: 800; font-size: var(--fs-xs); }

/* 票 03：期限與國定假日 */
.facts dd.facts-note { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); margin-top: 2px; }
.late-text { color: var(--late); } .due-text { color: var(--due); }
.cal-lead { color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: var(--s4); }
.cal-years { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s3); }
.cal-years li { display: grid; grid-template-columns: 4em 1fr; gap: 2px var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.cal-years li b { grid-row: span 2; font-size: var(--fs-lg); align-self: center; }
.cal-years li .muted { font-size: var(--fs-xs); overflow-wrap: anywhere; }
.cal-none { margin-top: var(--s3); font-size: var(--fs-sm); }
.cal-up { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); display: grid; gap: var(--s3); justify-items: start; }
.cal-help { font-size: var(--fs-xs); color: var(--muted); line-height: 1.7; }
.cal-help b { color: var(--ink-2); }

/* 票 04：勾選與修正 */
/* 未完成清單上的「勾完成」：卡片右下角一顆 48px 圓鈕(手機拇指按得到)，卡片本身仍整張可點進詳細頁 */
.item-wrap { position: relative; transition: opacity .25s, transform .25s; }
.item-wrap.gone { opacity: 0; transform: translateX(24px); }
.item.has-quick .meta, .item.has-quick h3 { padding-right: 56px; }
@media (min-width: 720px) { .item.has-quick { padding-right: calc(var(--s5) + 60px); } .item.has-quick .meta, .item.has-quick h3 { padding-right: 0; } }
.quick { position: absolute; right: var(--s3); bottom: var(--s3); width: 48px; height: 48px; border-radius: 50%; cursor: pointer;
         display: grid; place-items: center; border: 2px solid var(--line-2); background: var(--surface); color: var(--muted);
         transition: background .15s, color .15s, border-color .15s, transform .06s; }
.quick svg { width: 24px; height: 24px; }
.quick:hover { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.quick:active { transform: scale(.92); background: var(--ok); color: #fff; border-color: var(--ok); }
@media (min-width: 720px) { .quick { top: 50%; bottom: auto; margin-top: -24px; right: var(--s5); } .quick:active { transform: scale(.92); } }
/* 已完成、不用處理的卡片：誰何時勾的 */
.item .by { grid-column: 1 / -1; display: flex; gap: 6px; align-items: flex-start; margin-top: var(--s3); padding-top: var(--s2);
            border-top: 1px dashed var(--line); font-size: var(--fs-xs); color: var(--ink-2); }
.item .by svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.item .by.done svg { color: var(--ok); }
.item .by b { color: var(--muted); }
/* 詳細頁的動作列：手機上兩顆並排、滿寬 */
.act-bar { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--s2); margin-top: var(--s5); }
.act-bar .btn { min-height: 52px; font-size: var(--fs-md); }
@media (min-width: 720px) { .act-bar { display: flex; } .act-bar .btn { min-width: 160px; } }
.state-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s5);
             padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.state-box.done { background: var(--ok-soft); }
.state-box > div { display: flex; gap: var(--s2); align-items: flex-start; min-width: 0; }
.state-box svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.state-box.done > div svg { color: var(--ok); }
.btn.small svg { width: 16px; height: 16px; }
/* 處理紀錄 */
.timeline { list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s3) var(--s4); }
.timeline li { position: relative; display: grid; grid-template-columns: 6.5em 1fr; gap: var(--s3); padding: 8px 0 8px 18px; font-size: var(--fs-sm); }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 6.5px; top: 25px; bottom: -9px; width: 1px; background: var(--line); }
.timeline li.done::before { background: var(--ok); } .timeline li.dismissed::before { background: var(--muted); } .timeline li.open::before { background: var(--primary); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline span { overflow-wrap: anywhere; }
/* 原信底部的「手動加入事項」 */
.add-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s5);
           padding: var(--s4); border: 1px dashed var(--line-2); border-radius: var(--r-md); }
.add-row > div { display: grid; min-width: 0; flex: 1 1 14em; }
.add-row b { font-size: var(--fs-sm); } .add-row span { font-size: var(--fs-xs); color: var(--muted); }
.add-row .btn { flex: 1 0 auto; }
/* 彈窗表單 */
.modal-title { font-size: var(--fs-xl); line-height: 1.35; }
.modal-sub { color: var(--muted); font-size: var(--fs-sm) !important; margin: 4px 0 var(--s4); overflow-wrap: anywhere; }
.modal .hint { font-size: var(--fs-xs) !important; color: var(--muted); margin-top: var(--s2); }
.modal .field + .field { margin-top: var(--s3); }
textarea { resize: vertical; line-height: 1.6; }
@media (max-width: 480px) { .modal-bg { align-items: end; padding: 0; } .modal { max-width: none; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom)); } }
/* 提示條上的「復原」 */
.toast { display: flex; align-items: center; gap: var(--s3); width: max-content; }
.toast > span { white-space: nowrap; }
.toast-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--primary-soft); font-weight: 800;
             cursor: pointer; min-height: 32px; padding: 0 4px; font-size: var(--fs-sm); white-space: nowrap; flex: none; }
.toast-btn svg { width: 16px; height: 16px; }
/* 管理頁：判斷依據升版素材 */
.cor-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
.cor-head .seg { margin-bottom: 0; }
.cor-count { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s3); }
.cor-rows { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s2); }
.cor-rows li { display: grid; gap: 2px; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.cor-rows li .muted { font-size: var(--fs-xs); overflow-wrap: anywhere; }
.cor-reason { color: var(--ink-2); }

/* ── 後續來信(票 05)：有新來信用藍色(狀態色「有新來信」)，不跟逾期紅、今天到期琥珀搶 ── */
.item.new-mail { border-color: var(--info); box-shadow: 0 0 0 1px var(--info), var(--shadow-1); }
.item.new-mail:not(.late):not(.due)::before { background: var(--info); }
.new-mail-note { margin-bottom: var(--s3); }
.new-mail-bar { align-items: center; margin-bottom: var(--s3); }
.new-mail-bar > div { flex: 1; min-width: 0; }
.new-mail-bar .btn { flex: none; }
.follow-ups { list-style: none; display: grid; gap: var(--s2); }
.follow-ups a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3) var(--s4); color: var(--ink); }
.follow-ups a:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--shadow-1); }
.follow-ups .fu-top { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
.follow-ups .fu-top span { display: inline-flex; align-items: center; gap: 4px; }
.follow-ups .fu-top svg { width: 14px; height: 14px; opacity: .8; }
.follow-ups time { font-variant-numeric: tabular-nums; }
.follow-ups b { display: block; overflow-wrap: anywhere; }
.follow-ups p { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
.follow-ups .fu-tags { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.follow-ups .fu-tags .chip { height: auto; min-height: 24px; padding: 2px 10px; }
.timeline li.info::before { background: var(--info); }
@media (max-width: 480px) { .new-mail-bar { flex-wrap: wrap; } .new-mail-bar .btn { margin-left: 32px; } }

/* ── 略過規則(票 09)：管理頁一段清單加原信頁的「建立略過規則」 ── */
.skip-help { list-style: none; display: grid; gap: 6px; margin: 0 0 var(--s4); padding: var(--s3) var(--s4); background: var(--surface-2); border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--ink-2); }
.skip-help b { color: var(--ink); }
.skip-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); font-size: var(--fs-xs); }
.skip-rules { list-style: none; display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.skip-rule { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.skip-rule.off { background: var(--surface-2); }
.skip-rule.off .sr-sender, .skip-rule.off .sr-kw { color: var(--muted); }
.sr-main { display: grid; gap: 2px; min-width: 0; }
.sr-sender { font-size: var(--fs-md); overflow-wrap: anywhere; }
.sr-kw { font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.sr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.sr-hits { display: grid; justify-items: end; align-content: start; line-height: 1.2; }
.sr-hits b { font-size: var(--fs-xl); color: var(--ink); }
.sr-hits span { font-size: var(--fs-xs); color: var(--muted); }
.sr-acts { grid-column: 1 / -1; display: flex; gap: var(--s2); padding-top: var(--s2); border-top: 1px dashed var(--line); }
.btn.danger { color: var(--late); }
.btn.danger:hover { background: var(--late-soft); }
.btn.danger-fill { background: var(--late); color: #fff; box-shadow: none; }
.btn.danger-fill:hover { background: color-mix(in srgb, var(--late) 85%, #000); }
.skip-preview:not(:empty) { display: flex; gap: var(--s2); align-items: flex-start; margin-top: var(--s3); padding: var(--s3); border-radius: var(--r-md); background: var(--primary-soft); font-size: var(--fs-sm); color: var(--ink); overflow-wrap: anywhere; }
.skip-preview svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--primary); }
.modal #skipErr { margin-top: var(--s3); }
.skip-row { margin-top: var(--s3); }
/* 收件處理人(票 10) */
#rcpState .banner { margin-bottom: var(--s3); }
.rcp-list { list-style: none; display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.rcp-row { display: grid; grid-template-columns: 44px 1fr; gap: var(--s2) var(--s3); align-items: start; padding: var(--s3) var(--s4) var(--s3) var(--s2);
           border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.rcp-row.on { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.rcp-row.off { background: var(--surface-2); }
.rcp-row.off .rcp-name b { color: var(--muted); }
.rcp-check { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; }
.rcp-check input { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; }
.rcp-check input:disabled { cursor: default; }
.rcp-main { display: grid; gap: 4px; min-width: 0; padding-top: 9px; }
.rcp-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rcp-mail { font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }
.rcp-warn { display: inline-flex; gap: 6px; align-items: flex-start; color: var(--late); }
.rcp-warn svg { width: 16px; height: 16px; flex: none; margin-top: 3px; }
.rcp-fill { display: flex; gap: var(--s2); margin-top: var(--s2); }
.rcp-fill input { min-height: 40px; padding: 6px 12px; font-size: var(--fs-sm); }
.rcp-fill .btn { flex: none; min-height: 40px; }
@media (min-width: 720px) {
  .skip-rule { grid-template-columns: 1fr auto auto; align-items: center; }
  .sr-acts { grid-column: auto; border-top: 0; padding-top: 0; }
  .sr-hits { min-width: 4.5em; }
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger-fill { color: #1B0912; } }
:root[data-theme="dark"] .btn.danger-fill { color: #1B0912; }
