:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e6f4f1;
  --gold: #b7791f;
  --gold-soft: #fdf6e7;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #e2e8ec;
  --bg: #f7f8f6;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2dd4bf; --brand-dark: #5eead4; --brand-soft: #123330; --gold: #f6c56b; --gold-soft: #2e2615;
    --ink: #e6eaee; --muted: #9aa6b2; --line: #2b343d; --bg: #11161b; --card: #182028; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #2dd4bf; --brand-dark: #5eead4; --brand-soft: #123330; --gold: #f6c56b; --gold-soft: #2e2615;
  --ink: #e6eaee; --muted: #9aa6b2; --line: #2b343d; --bg: #11161b; --card: #182028; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.35; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); margin: .3em 0 .4em; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }

/* header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--gold)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.logo-text { font-weight: 700; font-size: 1.15rem; line-height: 1.1; display: flex; flex-direction: column; }
.logo-text small { font-weight: 400; font-size: .72rem; color: var(--muted); }
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: var(--ink); padding: 8px 10px; border-radius: 8px; font-size: .95rem; }
.site-nav a:hover { background: var(--brand-soft); text-decoration: none; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 20px; padding: 4px 10px; color: var(--ink); cursor: pointer; }
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 64px; background: var(--card); border-bottom: 1px solid var(--line); flex-direction: column; padding: 8px 16px 16px; }
  .site-nav.open { display: flex; }
}

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; padding-block: 24px 48px; }
.layout.no-side { grid-template-columns: minmax(0, 820px); justify-content: center; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.sidebar { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 1000px) { .sidebar { display: none; } }
.side-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: sticky; top: 84px; }
.side-box h2 { font-size: 1rem; margin: 0 0 8px; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list a { display: flex; gap: 8px; padding: 6px 0; color: var(--ink); border-bottom: 1px dashed var(--line); }
.side-list li:last-child a { border-bottom: 0; }

.breadcrumb { font-size: .85rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.lead { color: var(--muted); font-size: 1.02rem; margin-top: 0; }

/* hero */
.hero { background: linear-gradient(135deg, var(--brand-soft), var(--gold-soft)); border-radius: calc(var(--radius) + 4px); padding: 36px 28px; margin-bottom: 28px; }
.hero h1 { margin-top: 0; }
.hero h1 span { color: var(--brand); font-size: .7em; }
.hero p { margin: 0; color: var(--muted); max-width: 40em; }

.section-title { font-size: 1.25rem; display: flex; align-items: baseline; justify-content: space-between; margin: 32px 0 14px; }
.section-title .more { font-size: .9rem; font-weight: 400; }

/* tool cards */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 45%), 1fr)); gap: 12px; }
.tool-grid.small { margin-bottom: 24px; }
.tool-card { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tool-card:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.tool-icon { font-size: 26px; }
.tool-card small { color: var(--muted); font-size: .82rem; line-height: 1.5; }

/* article cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card a { display: block; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); }
.card a:hover { border-color: var(--brand); text-decoration: none; }
.card h3 { font-size: 1.05rem; margin: 6px 0; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; font-size: .75rem; background: var(--brand-soft); color: var(--brand-dark); padding: 2px 8px; border-radius: 99px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 4px 14px; color: var(--ink); }

/* calculator */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; margin: 20px 0 28px; }
@media (max-width: 760px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.calc-form, .calc-result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.calc-result { align-self: start; scroll-margin-top: 80px; }
.calc-result.is-error { border-color: #d97706; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.input-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.input-wrap:focus-within, select:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
.field input, .field select { width: 100%; font: inherit; color: var(--ink); background: transparent; border: 0; padding: 10px 12px; min-height: 44px; }
.field select { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.field input:focus { outline: none; }
.suffix { font-style: normal; color: var(--muted); padding: 0 12px; white-space: nowrap; font-size: .9rem; }
.hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 3px; }
.btn { width: 100%; font: inherit; font-weight: 700; color: #fff; background: var(--brand); border: 0; border-radius: 10px; padding: 12px; cursor: pointer; min-height: 48px; }
.btn:hover { background: var(--brand-dark); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.stat-main { grid-column: 1 / -1; background: var(--brand-soft); }
.stat-label { display: block; font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.15rem; font-variant-numeric: tabular-nums; word-break: break-word; }
.stat-main .stat-value { font-size: 1.7rem; color: var(--brand-dark); }
.compare { background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.small { font-size: .8rem; color: var(--muted); }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }

/* tables */
.table-wrap { overflow-x: auto; margin: 12px 0; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; }
table.data th { background: var(--bg); font-weight: 600; }

/* article */
.post header .meta { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }
.prose { font-size: 1.02rem; }
.prose h2 { font-size: 1.35rem; margin: 2em 0 .6em; padding-left: 12px; border-left: 4px solid var(--brand); scroll-margin-top: 80px; }
.prose h3 { font-size: 1.1rem; margin: 1.5em 0 .4em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.note { background: var(--gold-soft); border-left: 4px solid var(--gold); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 16px 0; }
.formula { background: var(--brand-soft); border-radius: 10px; padding: 14px 16px; margin: 14px 0; font-weight: 600; overflow-x: auto; }
.toc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0; }
.toc ol { margin: 6px 0 0; padding-left: 1.3em; }
.tool-cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.tool-cta a { background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; display: inline-flex; gap: 6px; align-items: center; }
.tool-cta a:hover { background: var(--brand-dark); text-decoration: none; }
.tool-cta strong { margin-left: 2px; }
.related { margin-top: 36px; }
.related h2 { font-size: 1.2rem; }
.disclaimer { font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 28px; }
.contact-mail { font-size: 1.1rem; font-weight: 600; }

/* ads:預留高度避免版面位移(CLS) */
.ad { margin: 24px 0; min-height: 120px; text-align: center; }
.ad-sidebar { min-height: 250px; position: sticky; top: 360px; }
@media (max-width: 1000px) { .ad-sidebar { display: none; } }

/* footer */
.site-footer { background: var(--card); border-top: 1px solid var(--line); padding-block: 32px 20px; font-size: .9rem; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; }
.footer-cols p { color: var(--muted); margin: 6px 0; }
.footer-cols ul { list-style: none; padding: 0; margin: 6px 0; }
.footer-cols li { padding: 2px 0; }
.copyright { color: var(--muted); font-size: .8rem; margin-top: 24px; }

/* 第二批:分享、資料來源、多模式表單 */
.calc-side { align-self: start; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-share { font: inherit; font-size: .9rem; color: var(--brand-dark); background: var(--card); border: 1px solid var(--brand); border-radius: 10px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.btn-share:hover { background: var(--brand-soft); }
.share-msg { color: var(--brand-dark); font-size: .85rem; }
.mode-set { border: 0; padding: 0; margin: 0; min-width: 0; }
.mode-set legend { display: none; }
.sources { margin-top: 28px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.sources h2 { font-size: 1rem; margin: 0 0 6px; border: 0; padding: 0; }
.sources ul { margin: 0; padding-left: 1.2em; font-size: .9rem; }
.sources .small { margin: 8px 0 0; }
