/* 痛點小工具箱 共用設計系統：深藍 × 嫩黃，扁平精簡
   所有 class 以 tb- 開頭，避免與工具自己的樣式衝突。 */
:root {
  --tb-bg: #f6f7fa;
  --tb-surface: #ffffff;
  --tb-surface-2: #eef1f6;
  --tb-fg: #0f1d33;
  --tb-muted: #5b6578;
  --tb-line: #dfe3ea;
  --tb-primary: #12305c;      /* 深藍 */
  --tb-primary-fg: #ffffff;
  --tb-primary-soft: #e8edf5;
  --tb-accent: #f9dc5c;       /* 嫩黃 */
  --tb-accent-soft: #fff6cc;
  --tb-ok: #166534;   --tb-ok-soft: #e9f6ee;
  --tb-warn: #92400e; --tb-warn-soft: #fff6cc;
  --tb-bad: #b42318;  --tb-bad-soft: #fdecea;
  --tb-radius: 14px;
  --tb-radius-sm: 10px;
  --tb-font: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tb-bg: #0a1424;
    --tb-surface: #111e33;
    --tb-surface-2: #18283f;
    --tb-fg: #e9eef6;
    --tb-muted: #9aa6b8;
    --tb-line: #23344f;
    --tb-primary: #f9dc5c;    /* 深色模式改以嫩黃為主色 */
    --tb-primary-fg: #0a1424;
    --tb-primary-soft: #22304a;
    --tb-accent: #f9dc5c;
    --tb-accent-soft: #2a2a1c;
    --tb-ok: #6ee7a0;   --tb-ok-soft: #12291f;
    --tb-warn: #f9dc5c; --tb-warn-soft: #2a2a1c;
    --tb-bad: #f8a39b;  --tb-bad-soft: #321a1d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--tb-bg); color: var(--tb-fg); font-family: var(--tb-font); line-height: 1.65; -webkit-font-smoothing: antialiased; }
a { color: var(--tb-primary); }
:focus-visible { outline: 3px solid var(--tb-accent); outline-offset: 2px; }

/* 版面 */
.tb-container { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.tb-page { max-width: 820px; margin: 0 auto; padding: 8px 16px 48px; }

/* 頁首 / 頁尾（系統自動插入） */
.tb-header { background: var(--tb-primary); }
.tb-header-inner { display: flex; align-items: center; height: 56px; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.tb-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--tb-primary-fg); text-decoration: none; }
.tb-logo-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--tb-accent); color: #12305c; font-size: 15px; }
.tb-footer { margin-top: 56px; padding: 24px 16px 40px; text-align: center; font-size: .82rem; color: var(--tb-muted); border-top: 1px solid var(--tb-line); }
.tb-footer p { margin: 4px 0; }
.tb-footer a { color: var(--tb-muted); }

/* 文字 */
.tb-breadcrumb { font-size: .85rem; color: var(--tb-muted); margin: 20px 0 6px; }
.tb-breadcrumb a { color: var(--tb-muted); text-decoration: none; }
.tb-h1 { font-size: clamp(1.55rem, 4vw, 2.1rem); line-height: 1.3; margin: 4px 0 10px; }
.tb-h2 { font-size: 1.2rem; margin: 40px 0 14px; }
.tb-lead { font-size: 1.02rem; color: var(--tb-muted); margin: 0 0 16px; }
.tb-note { font-size: .85rem; color: var(--tb-muted); }

/* 徽章 */
.tb-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.tb-badge { padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--tb-accent-soft); color: var(--tb-fg); }
.tb-badge.is-neutral { background: var(--tb-surface-2); color: var(--tb-muted); }

/* 面板 */
.tb-panel { background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius); padding: 20px; margin: 0 0 16px; }
.tb-panel-title { font-size: 1rem; font-weight: 700; margin: 0 0 14px; }

/* 表單 */
.tb-form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tb-field { display: flex; flex-direction: column; gap: 6px; }
.tb-label { font-size: .88rem; font-weight: 600; }
.tb-hint { font-size: .8rem; color: var(--tb-muted); }
.tb-input, .tb-select, .tb-textarea { width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--tb-fg); background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius-sm); }
.tb-textarea { min-height: 120px; resize: vertical; }
.tb-input:focus, .tb-select:focus, .tb-textarea:focus { outline: none; border-color: var(--tb-primary); box-shadow: 0 0 0 3px var(--tb-accent-soft); }
.tb-range { width: 100%; accent-color: var(--tb-primary); }
.tb-dropzone { display: grid; place-items: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--tb-muted); background: var(--tb-surface-2); border: 2px dashed var(--tb-line); border-radius: var(--tb-radius); cursor: pointer; }
.tb-dropzone:hover, .tb-dropzone.is-over { border-color: var(--tb-primary); color: var(--tb-fg); }

/* 按鈕 */
.tb-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.tb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; font: inherit; font-weight: 600; color: var(--tb-fg); background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius-sm); cursor: pointer; text-decoration: none; }
.tb-btn:hover { border-color: var(--tb-primary); }
.tb-btn-primary { color: var(--tb-primary-fg); background: var(--tb-primary); border-color: var(--tb-primary); }
.tb-btn-primary:hover { opacity: .92; }
.tb-btn-sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.tb-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 結果 */
.tb-result-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tb-stat { padding: 14px 16px; background: var(--tb-surface-2); border-radius: var(--tb-radius-sm); }
.tb-stat-label { font-size: .82rem; color: var(--tb-muted); }
.tb-stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tb-stat.is-highlight { background: var(--tb-accent-soft); box-shadow: inset 4px 0 0 var(--tb-accent); }
.tb-callout { margin: 12px 0; padding: 12px 16px; background: var(--tb-surface-2); border-left: 4px solid var(--tb-muted); border-radius: var(--tb-radius-sm); }
.tb-callout.is-ok { background: var(--tb-ok-soft); border-color: var(--tb-ok); }
.tb-callout.is-warn { background: var(--tb-warn-soft); border-color: var(--tb-accent); }
.tb-callout.is-bad { background: var(--tb-bad-soft); border-color: var(--tb-bad); }
.tb-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tb-table th, .tb-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--tb-line); }
.tb-table th { color: var(--tb-muted); font-weight: 600; }
.tb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tb-source { margin-top: 12px; font-size: .8rem; color: var(--tb-muted); }

/* 教學 / FAQ */
.tb-steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tb-steps li { counter-increment: s; position: relative; padding: 10px 14px 10px 48px; background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius-sm); }
.tb-steps li::before { content: counter(s); position: absolute; left: 14px; top: 10px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--tb-accent); color: #12305c; font-size: .82rem; font-weight: 700; }
.tb-faq { display: grid; gap: 8px; }
.tb-faq details { padding: 0 16px; background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius-sm); }
.tb-faq summary { display: flex; justify-content: space-between; gap: 12px; padding: 14px 0; font-weight: 600; cursor: pointer; list-style: none; }
.tb-faq summary::-webkit-details-marker { display: none; }
.tb-faq summary::after { content: "+"; color: var(--tb-muted); }
.tb-faq details[open] summary::after { content: "−"; }
.tb-faq details > :not(summary) { margin: 0 0 14px; color: var(--tb-muted); }

/* 提示訊息 */
.tb-toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; padding: 10px 18px; font-size: .9rem; color: var(--tb-primary-fg); background: var(--tb-primary); border-radius: 999px; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: all .2s; }
.tb-toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* 推薦卡片（系統插入，低調呈現） */
.tb-aff { margin: 28px 0; }
.tb-aff-title { margin: 0 0 10px; font-size: .85rem; font-weight: 600; color: var(--tb-muted); }
.tb-aff-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.tb-aff-card { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; color: var(--tb-fg); text-decoration: none; background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius-sm); }
.tb-aff-card:hover { border-color: var(--tb-primary); }
.tb-aff-card span { font-size: .85rem; color: var(--tb-muted); }
.tb-aff-card em { margin-top: 6px; font-size: .85rem; font-style: normal; font-weight: 600; color: var(--tb-primary); }
.tb-aff-note { margin-top: 8px; font-size: .75rem; color: var(--tb-muted); }

/* 廣告位（設定 AdSense 後才會出現） */
.tb-ad { margin: 32px 0; }
.tb-ad-label { margin-bottom: 4px; font-size: .7rem; color: var(--tb-muted); text-align: center; }

/* 首頁 */
.tb-hero { padding: 40px 0 20px; }
.tb-hero h1 { margin: 0 0 12px; font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.2; }
.tb-hero h1 em { font-style: normal; background: linear-gradient(transparent 62%, var(--tb-accent) 62%); }
.tb-hero p { max-width: 620px; margin: 0 0 20px; color: var(--tb-muted); }
.tb-search input { width: 100%; max-width: 520px; padding: 13px 16px; font: inherit; color: var(--tb-fg); background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: 12px; }
.tb-search input:focus { outline: none; border-color: var(--tb-primary); box-shadow: 0 0 0 3px var(--tb-accent-soft); }
.tb-chips { display: flex; gap: 8px; margin: 16px 0 8px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.tb-chips::-webkit-scrollbar { display: none; }
.tb-chip { flex: none; padding: 6px 14px; font: inherit; font-size: .88rem; color: var(--tb-fg); background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: 999px; cursor: pointer; }
.tb-chip:hover { border-color: var(--tb-primary); }
.tb-chip.is-active { color: var(--tb-primary-fg); background: var(--tb-primary); border-color: var(--tb-primary); }
.tb-section { margin: 28px 0 8px; }
.tb-section-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.tb-section-head h2 { margin: 0; font-size: 1.1rem; }
.tb-section-head span { font-size: .82rem; color: var(--tb-muted); }
.tb-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tb-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; color: var(--tb-fg); text-decoration: none; background: var(--tb-surface); border: 1px solid var(--tb-line); border-radius: var(--tb-radius); }
.tb-card:hover { border-color: var(--tb-primary); }
.tb-card-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; font-size: 1.2rem; background: var(--tb-accent-soft); border-radius: 10px; }
.tb-card-body { min-width: 0; }
.tb-card-title { display: block; margin: 0 0 2px; font-weight: 700; }
.tb-card-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .86rem; color: var(--tb-muted); }
.tb-empty { padding: 40px 16px; text-align: center; color: var(--tb-muted); background: var(--tb-surface); border: 1px dashed var(--tb-line); border-radius: var(--tb-radius); }
