/* 版面：原型 A（貼文卡片）；單欄、最寬 640px，底部固定唯一的主按鈕 */
:root {
  --bg: #F3F1EC; --paper: #FFFFFF; --ink: #232624; --mute: #6B706C; --line: #E2DED6;
  --accent: #4F8A3C; --accent-ink: #FFFFFF; --accent-soft: #E7F0E2;
  --ok: #2E7D32; --ok-soft: #E3F1E4; --run: #9A5B00; --run-soft: #FBF0DD;
  --plan: #3D5A80; --plan-soft: #E4EAF2; --bad: #C62828; --bad-soft: #FBE5E5; --draft: #7C817D;
  --font: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #141515; --paper: #202322; --ink: #ECEDEB; --mute: #A3A8A4; --line: #333836;
  --accent: #7DB866; --accent-ink: #10200A; --accent-soft: #263322;
  --ok: #7CC57F; --ok-soft: #1F3321; --run: #F2B65A; --run-soft: #3A2D15;
  --plan: #9DB7DA; --plan-soft: #212C3A; --bad: #F08080; --bad-soft: #3D2020; --draft: #8A8F8B;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #141515; --paper: #202322; --ink: #ECEDEB; --mute: #A3A8A4; --line: #333836;
  --accent: #7DB866; --accent-ink: #10200A; --accent-soft: #263322;
  --ok: #7CC57F; --ok-soft: #1F3321; --run: #F2B65A; --run-soft: #3A2D15;
  --plan: #9DB7DA; --plan-soft: #212C3A; --bad: #F08080; --bad-soft: #3D2020; --draft: #8A8F8B;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.bar h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; min-width: 0; }
.bar h1 b { color: var(--accent); }
.iconbtn { min-width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; color: var(--mute); font-size: 15px; }

.page { padding: 12px 16px 96px; display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { flex: none; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--mute); font-size: 13.5px; white-space: nowrap; }
.chip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); font-weight: 500; }
.chip .n { font-variant-numeric: tabular-nums; margin-inline-start: 4px; }
.chip.warn .n { color: var(--bad); font-weight: 700; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.head { display: flex; gap: 10px; align-items: flex-start; }
.thumb { width: 44px; height: 44px; border-radius: 8px; flex: none; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 700; overflow: hidden; }
.head .txt { min-width: 0; flex: 1; }
.ttl { font-weight: 700; font-size: 15px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 12.5px; color: var(--mute); }
.rows { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 32px; }
.row .end { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; color: var(--mute); font-variant-numeric: tabular-nums; }
.err { font-size: 12.5px; color: var(--bad); margin: -2px 0 0 34px; white-space: pre-line; }
.pf { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; font-size: 10px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); flex: none; }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st.ok { color: var(--ok); background: var(--ok-soft); }
.st.run { color: var(--run); background: var(--run-soft); }
.st.plan { color: var(--plan); background: var(--plan-soft); }
.st.plan::before { background: none; border: 2px solid currentColor; width: 6px; height: 6px; }
.st.bad { color: var(--bad); background: var(--bad-soft); }
.st.draft { color: var(--draft); border: 1px dashed var(--draft); }
.st.draft::before { display: none; }
.link { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 500; padding: 6px 4px; min-height: 32px; text-decoration: none; }
.link.danger { color: var(--bad); }
.more { margin-top: 8px; display: flex; justify-content: flex-end; gap: 4px; }
.body-preview { margin: 8px 0 0; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }

.fab-wrap { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.primary { display: flex; width: 100%; max-width: 608px; margin: 0 auto; min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15.5px; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-weight: 500; }

.empty { text-align: center; color: var(--mute); padding: 48px 16px; }
.empty p { margin: 6px 0; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 84px; max-width: 608px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; z-index: 20; }

/* 寫稿 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .lbl { font-size: 13px; font-weight: 700; color: var(--mute); }
.field .hint { font-size: 12.5px; color: var(--mute); }
.input, textarea { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.counter { font-size: 12px; color: var(--mute); text-align: end; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); font-weight: 700; }
.drop { border: 1px dashed var(--line); border-radius: 12px; background: var(--paper); padding: 14px; display: flex; gap: 12px; align-items: center; }
.drop .preview { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: var(--bg); flex: none; }
.drop .txt { min-width: 0; flex: 1; font-size: 13.5px; }
.progress { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.plat { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.plat .top { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.plat .top .name { flex: 1; font-weight: 500; }
.switch { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; flex: none; margin: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--paper); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
:root[dir="rtl"] .switch:checked::after { transform: translateX(-18px); }
.problems { margin: 0; padding-inline-start: 18px; color: var(--bad); font-size: 12.5px; }
.okline { color: var(--ok); font-size: 12.5px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: none; min-height: 44px; font-size: 14px; color: var(--mute); }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 4px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--mute); font-size: 12.5px; }

/* 確認視窗 */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 17px; }
.sheet .when { font-size: 14px; }
.sheet .pv { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.sheet .pv .t { white-space: pre-wrap; word-break: break-word; font-size: 14px; margin: 6px 0 0; }
.sheet .actions { display: flex; flex-direction: column; gap: 8px; }
.notice { font-size: 13px; color: var(--mute); }
