/* ============================================================
   九回算算網 — 設計系統
   不動產 × 財務管理 專業試算工具站
   ============================================================ */

/* ---------- 主題 Token ---------- */
:root,
:root[data-theme="light"] {
  --bg: #F3F5F7;
  --bg-2: #EAEEF2;
  --surface: #FFFFFF;
  --surface-2: #F7F9FB;
  --surface-3: #EEF2F6;
  --border: #DCE2E9;
  --border-strong: #C3CDD7;
  --divider: #E7EBF0;
  --text: #182331;
  --text-2: #45566B;
  --text-3: #7C8DA0;
  --primary: #0D5C7A;
  --primary-strong: #0A4B66;
  --primary-soft: rgba(13, 92, 122, 0.10);
  --primary-softer: rgba(13, 92, 122, 0.06);
  --gold: #B98A2F;
  --gold-soft: rgba(185, 138, 47, 0.13);
  --teal: #0E7A6C;
  --teal-soft: rgba(14, 122, 108, 0.12);
  --danger: #C24141;
  --danger-soft: rgba(194, 65, 65, 0.10);
  --success: #2E7D5B;
  --success-soft: rgba(46, 125, 91, 0.12);
  --shadow-sm: 0 1px 2px rgba(23, 35, 49, 0.06);
  --shadow-md: 0 6px 18px rgba(23, 35, 49, 0.08);
  --shadow-lg: 0 16px 40px rgba(23, 35, 49, 0.14);
  --topbar-bg: rgba(243, 245, 247, 0.86);
  --hero-grid: rgba(13, 92, 122, 0.07);
  --c1: #0D5C7A; --c2: #B98A2F; --c3: #0E7A6C; --c4: #7A5BB8;
  --c5: #C24141; --c6: #3E7FA8; --c7: #C98A4B; --c8: #5B8C4A;
  --chart-text: #45566B;
  --chart-grid: #E3E9EF;
}

:root[data-theme="dark"] {
  --bg: #0D1319;
  --bg-2: #10171F;
  --surface: #141C25;
  --surface-2: #18212C;
  --surface-3: #1E2835;
  --border: #26323F;
  --border-strong: #34424F;
  --divider: #202B37;
  --text: #E6EDF4;
  --text-2: #A9B9C9;
  --text-3: #718397;
  --primary: #3E9CC4;
  --primary-strong: #57AFD4;
  --primary-soft: rgba(62, 156, 196, 0.16);
  --primary-softer: rgba(62, 156, 196, 0.08);
  --gold: #D9A64A;
  --gold-soft: rgba(217, 166, 74, 0.16);
  --teal: #3BBFAE;
  --teal-soft: rgba(59, 191, 174, 0.16);
  --danger: #E06C6C;
  --danger-soft: rgba(224, 108, 108, 0.14);
  --success: #5BB98C;
  --success-soft: rgba(91, 185, 140, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --topbar-bg: rgba(13, 19, 25, 0.86);
  --hero-grid: rgba(62, 156, 196, 0.08);
  --c1: #3E9CC4; --c2: #D9A64A; --c3: #3BBFAE; --c4: #A78BEA;
  --c5: #E06C6C; --c6: #5FA8C4; --c7: #C98A4B; --c8: #7CB87A;
  --chart-text: #A9B9C9;
  --chart-grid: #26323F;
}

/* ---------- Reset / 基礎 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "微軟正黑體", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
svg { display: block; }
::selection { background: var(--primary-soft); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.num { font-variant-numeric: tabular-nums; }

/* ---------- 應用外殼 ---------- */
.app { display: flex; min-height: 100vh; }

/* 側邊欄 */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 90;
  width: 276px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform 0.22s ease;
}
.sidebar-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--teal) 100%);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16.5px; font-weight: 800; letter-spacing: 0.01em; }
.brand-text small { font-size: 11.5px; color: var(--text-3); letter-spacing: 0.06em; }

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 12px 10px 16px;
}
.sidebar-foot {
  padding: 10px 16px; font-size: 12px; color: var(--text-3);
  border-top: 1px solid var(--divider);
}

/* 領域分組 */
.domain-group { margin-bottom: 16px; }
.domain-title {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 6px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.14em;
}
.domain-title .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.domain-re .dot { background: var(--gold); }
.domain-fin .dot { background: var(--teal); }
.domain-title svg { width: 14px; height: 14px; }

.cat-block { margin-bottom: 4px; }
.cat-title {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 8px;
  background: none; border: 0; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer; text-align: left;
}
.cat-title:hover { background: var(--surface-3); color: var(--text); }
.cat-title svg.cat-ic { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.cat-title .cat-name { flex: 1; }
.cat-title .cat-count {
  font-size: 11px; color: var(--text-3);
  background: var(--surface-3); border-radius: 10px; padding: 1px 7px;
}
.cat-title .cat-chev { width: 14px; height: 14px; color: var(--text-3); transition: transform 0.18s ease; }
details[open] > .cat-title .cat-chev { transform: rotate(90deg); }
details[open] > .cat-title { color: var(--text); }

.cat-tools { padding: 2px 0 6px; }
.cat-title { list-style: none; }
.cat-title::-webkit-details-marker { display: none; }
.tool-link.tl-top {
  margin-left: 0; border-left: 0; padding: 7px 10px;
  font-weight: 700; color: var(--text);
  margin-bottom: 10px;
}
.tool-link.tl-top .tl-ic { color: var(--primary); }
.tool-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6.5px 10px 6.5px 14px;
  margin-left: 8px; border-left: 1px solid var(--border);
  border-radius: 0 8px 8px 0;
  font-size: 13.5px; color: var(--text-2);
}
.tool-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.tool-link.active {
  background: var(--primary-soft); color: var(--primary);
  border-left-color: var(--primary); font-weight: 600;
}
.tool-link .tl-ic { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.tool-link.active .tl-ic { color: var(--primary); }
.tool-link .tl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 85;
  background: rgba(10, 16, 24, 0.45);
}

/* 主區 */
.main {
  flex: 1; min-width: 0;
  margin-left: 276px;
  display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 60;
  height: 56px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-menu { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* 麵包屑 */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13.5px; min-width: 0; }
.breadcrumb a { color: var(--text-3); white-space: nowrap; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--text-3); opacity: 0.6; }
.breadcrumb .cur {
  color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px;
}

/* 搜尋框 */
.search-box { position: relative; }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.search-box input {
  width: 230px; height: 36px;
  padding: 0 12px 0 32px;
  font-size: 13.5px; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--surface);
}

/* 主題切換（單一手動日夜切換） */
.theme-switch {
  display: flex; align-items: center; gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px;
}
.theme-switch .icon-btn {
  width: 30px; height: 30px; border-radius: 7px;
}
.theme-switch .icon-btn[aria-pressed="true"] {
  background: var(--surface); color: var(--primary);
  box-shadow: var(--shadow-sm);
}
/* 依當前主題顯示對應圖示（白天顯示太陽、夜晚顯示月亮） */
.theme-switch .ts-moon { display: none; }
[data-theme="dark"] .theme-switch .ts-sun { display: none; }
[data-theme="dark"] .theme-switch .ts-moon { display: block; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  background: none; border: 0; border-radius: 9px;
  color: var(--text-2); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* 檢視區 */
.view { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 30px 28px 48px; }

/* ---------- 通用元件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px 0;
  font-size: 14.5px; font-weight: 700;
}
.section-title svg { width: 16px; height: 16px; color: var(--primary); }
.section-sub { padding: 2px 20px 0; font-size: 12.5px; color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border-radius: 9px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost {
  background: var(--surface); color: var(--text-2);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* 表單 */
.field-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 22px;
  padding: 16px 20px 4px;
}
.field-group-title {
  grid-column: 1 / -1;
  margin-top: 4px;
  font-size: 12.5px; font-weight: 700; color: var(--text-3);
  letter-spacing: 0.08em;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.field-label .unit {
  font-size: 11.5px; font-weight: 500; color: var(--text-3);
  background: var(--surface-3); border-radius: 5px; padding: 0 6px;
}
.field-label .hint-ic { width: 13px; height: 13px; color: var(--text-3); margin-left: auto; cursor: help; }
.field-label .hint-ic svg { width: 13px; height: 13px; }
.field-hint { font-size: 12px; color: var(--text-3); }
.input-row { display: flex; align-items: center; gap: 0; }
.stepper {
  width: 34px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border-strong);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.stepper:hover { background: var(--surface-3); color: var(--text); }
.stepper[disabled] { opacity: 0.4; cursor: not-allowed; }
.stepper.minus { border-radius: 8px 0 0 8px; border-right: 0; }
.stepper.plus { border-radius: 0 8px 8px 0; border-left: 0; }
.input {
  flex: 1; min-width: 0;
  height: 38px; padding: 0 10px;
  font-size: 14.5px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; z-index: 1;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.select {
  width: 100%; height: 38px; padding: 0 10px;
  font-size: 14px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.textarea {
  width: 100%; padding: 8px 10px;
  font-size: 13.5px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px;
  resize: vertical;
  font-variant-numeric: tabular-nums;
}
.field-err { font-size: 12.5px; color: var(--danger); display: none; }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea {
  border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft);
}
.field.invalid .field-err { display: block; }

.form-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px 18px;
}
.form-actions .spacer { flex: 1; }

/* 結果卡 */
.result-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; padding: 16px 20px 20px;
}
.stat-card {
  position: relative;
  padding: 14px 16px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
}
.stat-card .stat-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.stat-card .stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stat-card.emphasis {
  background: var(--primary-softer);
  border-color: var(--primary);
  border-left-color: var(--primary);
}
.stat-card.emphasis .stat-value { color: var(--primary); }

/* 圖表卡 */
.chart-box { width: 100%; height: 380px; padding: 8px 10px 6px; }
.table-box { max-height: 440px; overflow: auto; margin: 12px 20px 18px; border: 1px solid var(--border); border-radius: 10px; }
table.calc-table { table-layout: fixed; width: 100%; border-collapse: collapse; font-size: 13px; }
.calc-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--text-2);
  font-weight: 700; text-align: right;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--divider); font-variant-numeric: tabular-nums; }
.calc-table tbody tr:nth-child(even) { background: var(--surface-2); }
.calc-table tbody tr:hover { background: var(--primary-softer); }
.calc-table tfoot td { font-weight: 700; background: var(--surface-3); border-top: 1px solid var(--border-strong); }

/* 註記卡 */
.notes-list { padding: 10px 20px 18px; }
.notes-list li {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px; color: var(--text-2);
  padding: 5px 0; list-style: none;
}
.notes-list svg { width: 15px; height: 15px; color: var(--teal); flex: none; margin-top: 2px; }

/* 錯誤卡 */
.err-card {
  margin: 0 20px 18px;
  padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--danger); font-size: 13.5px;
}
.err-card svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

/* ---------- 首頁 ---------- */
.hero {
  position: relative;
  padding: 34px 34px 30px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(1200px 420px at 85% -10%, var(--primary-soft), transparent 60%),
    radial-gradient(900px 380px at -10% 110%, var(--gold-soft), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--hero-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--hero-grid) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(760px 320px at 80% 20%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(760px 320px at 80% 20%, #000 0%, transparent 75%);
  pointer-events: none;
}
.hero-inner { position: relative; }
.hero .kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; color: var(--gold);
  letter-spacing: 0.1em;
}
.hero .kicker svg { width: 15px; height: 15px; }
.hero h1 { margin-top: 10px; font-size: 34px; font-weight: 800; line-height: 1.28; letter-spacing: -0.01em; }
.hero h1 .accent { color: var(--primary); }
.hero .lead { margin-top: 10px; max-width: 640px; font-size: 15.5px; color: var(--text-2); }
.hero-search {
  margin-top: 24px; max-width: 460px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 6px 6px 6px 14px;
  box-shadow: var(--shadow-md);
}
.hero-search svg { width: 18px; height: 18px; color: var(--text-3); }
.hero-search input { flex: 1; border: 0; background: none; font-size: 15px; color: var(--text); height: 36px; }
.hero-search input:focus { outline: none; }
.hero-search .btn { height: 36px; }

.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.section-head h2 { font-size: 19px; font-weight: 800; }
.section-head .sh-note { font-size: 13px; color: var(--text-3); }

.domain-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.domain-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 22px 22px 18px;
  border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s;
}
.domain-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.domain-card.re { border-top: 3px solid var(--gold); }
.domain-card.fin { border-top: 3px solid var(--teal); }
.domain-card .dc-top { display: flex; align-items: center; gap: 12px; }
.domain-card .dc-ic {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
}
.domain-card.re .dc-ic { color: var(--gold); background: var(--gold-soft); }
.domain-card.fin .dc-ic { color: var(--teal); background: var(--teal-soft); }
.domain-card .dc-ic svg { width: 24px; height: 24px; }
.domain-card .dc-name { font-size: 17px; font-weight: 800; }
.domain-card .dc-count { font-size: 12.5px; color: var(--text-3); }
.domain-card .dc-desc { font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.domain-card .dc-go { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--primary); margin-top: auto; }
.domain-card .dc-go svg { width: 15px; height: 15px; }

.hot-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.hot-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.hot-chip svg { width: 14px; height: 14px; color: var(--primary); }
.hot-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-softer); text-decoration: none; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(262px, 1fr)); gap: 14px; }
.cat-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 16px 14px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); text-decoration: none; }
.cat-card .cc-top { display: flex; align-items: center; gap: 10px; }
.cat-card .cc-ic {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
}
.cat-card .cc-ic svg { width: 18px; height: 18px; }
.cat-card .cc-name { font-size: 14.5px; font-weight: 700; flex: 1; }
.cat-card .cc-count { font-size: 11.5px; color: var(--text-3); background: var(--surface-3); padding: 1px 8px; border-radius: 10px; }
.cat-card .cc-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-card .cc-samples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.cat-card .cc-sample { font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--divider); padding: 2px 8px; border-radius: 7px; }

.howto { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.howto-card { padding: 18px; border-radius: 13px; background: var(--surface); border: 1px solid var(--border); }
.howto-card .hc-num {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 50%; background: var(--primary); color: #fff;
  font-weight: 800; font-size: 14px;
}
.howto-card h3 { margin-top: 10px; font-size: 15px; font-weight: 700; }
.howto-card p { margin-top: 5px; font-size: 13px; color: var(--text-2); }

.feat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.feat-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; font-size: 13.5px; color: var(--text-2); }
.feat-item svg { width: 18px; height: 18px; color: var(--teal); flex: none; }

/* ---------- 工具頁 ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head .ph-ic {
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 13px;
}
.page-head .ph-ic svg { width: 26px; height: 26px; }
.page-head h1 { font-size: 23px; font-weight: 800; line-height: 1.3; }
.page-head .ph-desc { margin-top: 4px; font-size: 14px; color: var(--text-2); max-width: 760px; }
.page-head .ph-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.ph-tag { font-size: 11.5px; color: var(--text-3); background: var(--surface-3); padding: 2px 9px; border-radius: 8px; }

/* ---------- 清單頁 ---------- */
.list-head { margin-bottom: 20px; }
.list-head h1 { font-size: 24px; font-weight: 800; }
.list-head p { margin-top: 6px; font-size: 14px; color: var(--text-2); }
.list-search { max-width: 420px; margin-top: 14px; position: relative; }
.list-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.list-search input {
  width: 100%; height: 40px; padding: 0 14px 0 34px;
  font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
}
.list-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.list-group { margin-top: 26px; }
.list-group-title {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 800;
}
.list-group-title .lg-ic { width: 28px; height: 28px; display: grid; place-items: center; background: var(--surface-3); border-radius: 8px; color: var(--text-2); }
.list-group-title .lg-ic svg { width: 16px; height: 16px; }
.list-group-title .lg-count { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.tool-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.tool-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px;
  border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.tool-row:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }
.tool-row .tr-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; background: var(--primary-softer); color: var(--primary); border-radius: 9px; }
.tool-row .tr-ic svg { width: 17px; height: 17px; }
.tool-row .tr-main { flex: 1; min-width: 0; }
.tool-row .tr-name { font-size: 14px; font-weight: 700; color: var(--text); }
.tool-row .tr-desc { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-row .tr-go { width: 22px; height: 22px; color: var(--text-3); }
.tool-row .tr-go svg { width: 22px; height: 22px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-3); font-size: 14px; }

/* 內嵌於標題的圖示 */
.list-head h1 svg { width: 26px; height: 26px; display: inline-block; vertical-align: -4px; color: var(--primary); margin-right: 4px; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 18px;
  background: var(--text); color: var(--bg);
  border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast svg { width: 16px; height: 16px; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok svg { color: var(--teal); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 22px 28px 26px; }
.footer-brand { display: flex; align-items: baseline; gap: 10px; font-size: 15px; }
.footer-brand span { font-size: 12px; color: var(--text-3); }
.footer-disclaimer { margin-top: 8px; font-size: 12.5px; color: var(--text-3); max-width: 900px; line-height: 1.65; }
.footer-note { margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
.footer-credit { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }

/* ---------- 響應式 ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .topbar-menu { display: inline-grid; }
  .search-box input { width: 190px; }
}
@media (max-width: 760px) {
  .view { padding: 18px 14px 40px; }
  .field-grid { grid-template-columns: 1fr; padding: 14px 14px 2px; }
  .section-title, .section-sub { padding-left: 14px; padding-right: 14px; }
  .form-actions { padding: 12px 14px 16px; }
  .result-cards { grid-template-columns: 1fr 1fr; padding: 14px; }
  .chart-box { height: 320px; }
  .table-box { margin: 10px 14px 14px; }
  .notes-list { padding: 8px 14px 14px; }
  .hero { padding: 24px 20px 22px; border-radius: 14px; }
  .hero h1 { font-size: 25px; }
  .domain-cards { grid-template-columns: 1fr; }
  .howto { grid-template-columns: 1fr; }
  .breadcrumb .sep, .breadcrumb a:not(:last-child) { display: none; }
  .breadcrumb { max-width: 46vw; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-right { gap: 8px; }
  .search-box { display: none; }
  .stat-card .stat-value { font-size: 19px; }
}
@media (max-width: 420px) {
  .result-cards { grid-template-columns: 1fr; }
}

/* ---------- 動效偏好 / 列印 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
@media print {
  .sidebar, .topbar, .form-actions, .toast-wrap { display: none !important; }
  .main { margin-left: 0; }
  .view { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
