/* 薪底 PayGround
   原則：說明收進 ⓘ、標題簡短、畫面簡潔；沒有資料的欄位不放。
   顏色：黃色只標「你正在看的那家公司」與目前選取；紅色只標「官方標記」。 */

/* 顏色都用 light-dark()：淺色值在前、深色值在後。
   預設跟系統；使用者手動切換時 <html data-theme> 會覆蓋 color-scheme。 */
:root {
  color-scheme: light dark;

  --paper: light-dark(#f1f4f0, #0c191d);
  --surface: light-dark(#ffffff, #132429);
  --surface-2: light-dark(#f6f8f5, #182d33);
  --ink: light-dark(#142d34, #e6eeea);
  --ink-soft: light-dark(#53686d, #9cb0ab);
  --rule: light-dark(#e0e7e2, #24393f);
  --field-line: light-dark(#b9c6c1, #48626a);
  --tick: light-dark(#9fb0ab, #3f5a60);
  --tick-strong: light-dark(#142d34, #d6e2dd);
  --marker: light-dark(#e0a100, #f2b705);
  --marker-ink: #2b1f00; /* 琥珀底上的字 */
  --select-bg: light-dark(#fdf1c9, #3a3214);
  --flag: light-dark(#a8321c, #f08a70);
  --flag-bg: light-dark(#fbe9e4, #3a1d16);
  --pressed: light-dark(#e8eee9, #1d353b);
  --viz-accent: light-dark(#e0a100, #d99400); /* 這家公司（強調） */
  --viz-muted: light-dark(#a9b8b3, #4f6a70); /* 其他公司（淡化） */
  --viz-main: light-dark(#3d5a62, #8fa7a1); /* 只有一組資料的長條 */
  --viz-grid: light-dark(#e8ede9, #20363c);
  --shadow-color: light-dark(rgb(20 45 52 / 0.08), rgb(0 0 0 / 0.35));

  --font-display: 'Noto Serif TC', 'Songti TC', serif;
  --font-body: -apple-system, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;

  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-stat: clamp(1.5rem, 1.2rem + 1vw, 1.875rem);
  --text-title: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem);

  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --wide: 68rem;
  --r: 8px;
  --r-lg: 14px;
  --tap: 44px;
  --header-h: 60px;
  --tabbar-h: 60px;

  --shadow-sm: 0 1px 2px var(--shadow-color);
  --shadow: 0 1px 2px var(--shadow-color), 0 6px 20px -8px var(--shadow-color);
  --shadow-lg: 0 2px 4px var(--shadow-color), 0 18px 40px -12px var(--shadow-color);

  /* 動態：一律用 --ease，減速停下、不回彈 */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 220ms;
  --dur-slow: 320ms;
  --dur-grow: 520ms;
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* 鍵盤移動焦點時，不讓元素躲在固定版頭（或手機底部 tab）後面 */
  scroll-padding-top: calc(var(--header-h) + 0.5rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration-color: var(--tick);
  text-underline-offset: 0.2em;
}

:focus-visible {
  outline: 3px solid var(--marker);
  outline-offset: 2px;
}

#app:focus {
  outline: none;
}

p {
  margin: 0;
}

.sr-only {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  vertical-align: -0.2em;
}

/* ---------- 版頭版尾 ---------- */

/* 版頭固定在頂端，實色底；捲動後才出現分隔線（.is-scrolled 由 app.js 加） */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid transparent;
  background: var(--paper);
  transition: border-color var(--dur) var(--ease);
}

.site-header.is-scrolled {
  border-bottom-color: var(--rule);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--wide);
  min-height: var(--header-h);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.375rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
}

.brand-sub {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.site-nav {
  display: flex;
  gap: 0.25rem;
}

.site-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 38px;
  padding: 0 0.8rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.site-nav a[aria-current] {
  background: var(--ink);
  color: var(--paper);
}

.compare-count:not(:empty) {
  min-width: 1.4em;
  padding: 0 0.35em;
  border-radius: 999px;
  background: var(--marker);
  color: var(--marker-ink);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.compare-count.bump {
  animation: bump var(--dur-slow) var(--ease);
}

@keyframes bump {
  40% {
    transform: scale(1.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .compare-count.bump,
  .theme-toggle:active .icon {
    animation: none;
    transform: none;
  }
}

/* 最窄的手機：品牌只留圖示（連結有 aria-label），讓搜尋框寬一點 */
@media (max-width: 22.5rem) {
  .brand > span {
    display: none;
  }
}

.theme-toggle .icon {
  transition: transform var(--dur-slow) var(--ease);
}

.theme-toggle:active .icon {
  transform: rotate(-30deg) scale(0.9);
}

/* 桌機的導覽只放文字；icon 只在手機底部 tab 出現，幫忙在小字下面辨認 */
@media (min-width: 40.0625rem) {
  .site-nav a .icon {
    display: none;
  }
}

/* 手機：導覽移到底部 tab，拇指按得到；版頭只留品牌、搜尋、主題 */
@media (max-width: 40rem) {
  .brand-sub {
    display: none;
  }

  .site-nav {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 0.25rem 0.5rem calc(0.25rem + env(safe-area-inset-bottom));
    background: var(--paper);
    border-top: 1px solid var(--rule);
  }

  .site-nav a {
    flex-direction: column;
    justify-content: center;
    gap: 0.1rem;
    min-height: calc(var(--tabbar-h) - 0.5rem);
    padding: 0;
    border-radius: var(--r);
    font-size: 0.75rem;
  }

  .site-nav a .icon {
    width: 22px;
    height: 22px;
  }

  .site-nav a[aria-current] {
    background: none;
    color: var(--ink);
  }

  .site-nav a[aria-current] .icon {
    color: var(--marker);
  }

  .site-nav a[aria-current]::before {
    content: '';
    position: absolute;
    top: -0.25rem;
    left: 30%;
    right: 30%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--marker);
  }

  .compare-count:not(:empty) {
    position: absolute;
    top: 0.2rem;
    left: calc(50% + 4px);
  }

  body {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  }

  html {
    scroll-padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 0.5rem);
  }
}

/* 高對比模式會蓋掉背景色，目前頁籤改用外框標示 */
@media (forced-colors: active) {
  .site-nav a[aria-current] {
    outline: 2px solid CanvasText;
    outline-offset: -2px;
  }
}

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--gutter) 3rem;
}

main > * + * {
  margin-top: 2rem;
}

/* 頁首數字和下面的圖之間拉開，分出「結論」和「細節」兩層 */
main > .kpis + * {
  margin-top: 3.5rem;
}

.site-footer {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 2.5rem;
  color: var(--ink-soft);
  font-size: var(--text-xs);
}

.site-footer p + p {
  margin-top: 0.35rem;
}

.footer-method {
  max-width: 40rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

/* ---------- 關於 ---------- */

.about {
  max-width: 40rem;
}

.about-lede {
  font-size: var(--text-lg);
  line-height: 1.7;
}

.about-section {
  margin-top: 2.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ink);
}

.about-heading {
  margin: 0 0 0.5rem;
  font-size: var(--text-lg);
}

.about-section p + p {
  margin-top: 0.5rem;
}

.about-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.about-list li + li {
  margin-top: 0.35rem;
}

.about-action {
  margin-top: 1rem;
}

.empty {
  padding: 3rem 0;
  color: var(--ink-soft);
}

/* ---------- 載入骨架 ---------- */

/* 稍等 150ms 才淡入：資料很快就到時不會閃一下骨架 */
.skeleton {
  animation: fade 240ms var(--ease) 150ms both;
}

.sk {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--pressed);
}

/* 一道光由左往右掃過，告訴使用者「還在動」 */
.sk::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.sk-head {
  display: grid;
  gap: 0.9rem;
  padding: 2.5rem 0 1rem;
}

.sk-eyebrow {
  width: 11rem;
  height: 0.8rem;
}

.sk-title {
  width: min(14rem, 60%);
  height: 3rem;
  border-radius: var(--r-lg);
}

.sk-search {
  width: min(34rem, 100%);
  height: 60px;
  margin-top: 0.6rem;
  border-radius: var(--r-lg);
}

/* 「員工最多」那一排快速選公司的位置，資料到了內容才不會往下跳 */
.sk-picks {
  width: min(33rem, 100%);
  height: 36px;
  margin-top: 0.1rem;
}

.sk-kpis {
  display: flex;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  border-top: 1px solid var(--ink);
}

/* 跟真正的 KPI 同一套排法：主數字自己一行，其他數字排成一列、用細線隔開 */
.sk-kpi {
  display: grid;
  gap: 0.5rem;
  min-width: 8rem;
  padding: 0.85rem 2.5rem 0.25rem 1.25rem;
  border-left: 1px solid var(--rule);
}

.sk-kpi-hero {
  flex-basis: 100%;
  padding: 1rem 0 1.25rem;
  border-left: 0;
  border-bottom: 1px solid var(--rule);
}

.sk-kpi-hero + .sk-kpi {
  padding-left: 0;
  border-left: 0;
}

.sk-label {
  width: 4rem;
  height: 0.8rem;
}

.sk-value {
  width: 6rem;
  height: 1.75rem;
}

.sk-value-hero {
  width: min(16rem, 70%);
  height: 4rem;
}

.sk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3rem 2.5rem;
  margin-top: 3.5rem;
}

/* 跟真正的區塊一樣：不包卡片，上緣一條深色細線 */
.sk-card {
  display: grid;
  gap: 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ink);
}

.sk-wide {
  grid-column: 1 / -1;
}

.sk-line {
  width: 7rem;
  height: 1.25rem;
}

.sk-caption {
  width: min(20rem, 80%);
  height: 0.8rem;
  margin-bottom: 0.4rem;
}

.sk-chart {
  height: 11rem;
}

.sk-chart-short {
  height: 5rem;
}

@media (max-width: 40rem) {
  .sk-kpi {
    padding: 0.75rem 0 0.5rem 1rem;
  }

  .sk-kpi-hero {
    padding: 0.9rem 0 1rem;
  }

  .sk-kpi:last-child {
    display: none;
  }

  .sk-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sk::after {
    animation: none;
    display: none;
  }
}

.slow-hint {
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  animation: enter var(--dur-slow) var(--ease) both;
}

/* 讀取失敗 */
.load-error {
  margin-top: 2.5rem;
}

.empty .button {
  margin-top: 1rem;
}

/* ---------- 標題 ---------- */

.page-head,
.company-head {
  padding-top: 1.75rem;
}

.page-title,
.company-name {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--text-title);
  line-height: 1.25;
}

.page-head .search {
  margin-top: 1rem;
}

.crumb {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.company-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
}

.company-title {
  min-width: 0;
}

.company-name {
  font-size: clamp(2rem, 1.5rem + 2.2vw, 3rem);
  letter-spacing: 0.02em;
}

.company-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 28px;
  padding: 0 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
}

.tag .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.tag-link {
  color: var(--ink);
  transition: border-color var(--dur) var(--ease);
}

.tag-code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 0.04em;
}

/* 主要按鈕：深色實心；按下（已加入）後變成琥珀淡底 */
.button.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-sm);
}

.button.button-primary[aria-pressed='true'] {
  border-color: var(--marker);
  background: var(--select-bg);
  color: var(--ink);
}

/* ---------- ⓘ ---------- */

.tip {
  position: relative;
  display: inline-flex;
  margin-left: 0.3rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
}

.tip-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

/* 外觀 24px，透明的 ::before 把可點範圍撐到 44px，不影響排版 */
.tip-button::before {
  content: '';
  position: absolute;
  inset: -10px;
}

.tip-button .icon {
  width: 18px;
  height: 18px;
}

.tip-button[aria-expanded='true'] {
  color: var(--ink);
}

.tip-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: -0.5rem;
  width: max-content;
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.tip-panel[hidden] {
  display: none;
}

/* ---------- 按鈕 ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0 1rem;
  border: 1px solid var(--field-line);
  border-radius: var(--r);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button[aria-pressed='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.button:active,
.icon-button:active,
.pill:active {
  transform: scale(0.97);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.actions {
  display: flex;
  gap: 0.75rem;
}

/* ---------- 搜尋 ---------- */

.search {
  position: relative;
  max-width: 34rem;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  font-size: var(--text-lg);
}

/* ---------- 輸入控制項（搜尋框、下拉、數字）共用同一套外觀 ---------- */

.search-input,
.field-control {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--field-line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  /* 不用 font 簡寫：它會把前面 .search-input 設的字級重設掉 */
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

.search-input::placeholder,
.field-control::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}

.search-input:focus,
.field-control:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--marker) 55%, transparent);
}

.search-input:disabled,
.field-control:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 拿掉瀏覽器內建的清除鈕和數字微調箭頭，改用自己的 */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.field-control[type='number'] {
  -moz-appearance: textfield;
}

.field-control::-webkit-inner-spin-button,
.field-control::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  transform: translateY(-50%);
}

/* 有字、清除鈕出現時才在右邊讓出位置，不然窄螢幕的提示文字會被截掉 */
.search:has(.search-clear:not([hidden])) .search-input {
  padding-right: 2.9rem;
}

.search-clear[hidden] {
  display: none;
}

.search-clear .icon {
  width: 18px;
  height: 18px;
}

.search-clear:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

/* 搜尋結果展開時，整個區塊浮到其他區塊上面（進場動畫讓每個區塊各自成一層，只調清單的 z-index 不夠） */
#app > :has(.search-results:not(:empty)) {
  position: relative;
  z-index: 15;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-results a {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
  min-height: var(--tap);
  padding: 0.6rem 1rem;
  text-decoration: none;
}

.search-results li.active a {
  background: var(--select-bg);
}

.search-results a:active {
  background: var(--pressed);
}

.result-name,
.result-value {
  font-weight: 600;
}

.result-code,
.result-meta {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.search-empty {
  padding: 0.75rem 1rem;
  color: var(--ink-soft);
}

/* ---------- 薪資地平線 ---------- */

.strip {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.strip .ground {
  stroke: var(--ink);
  stroke-width: 2;
}

.strip .tick {
  stroke: var(--tick-strong);
  stroke-width: 1.5;
  opacity: 0.12; /* 重疊越多越深，顏色深淺就是公司密度 */
}

.strip .tick-industry {
  stroke: var(--tick-strong);
  stroke-width: 2;
  opacity: 0.85;
}

.strip .axis-label {
  fill: var(--ink-soft);
  font-size: 15px;
}

.strip .marker-line {
  stroke: var(--viz-accent);
  stroke-width: 4;
}

.strip .marker-dot {
  fill: var(--viz-accent);
  stroke: var(--paper);
  stroke-width: 3;
}

.strip .marker-label {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

/* ---------- 值得注意 ---------- */

.notes {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: var(--r);
  background: var(--surface);
}

.note {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}

.note + .note {
  border-top: 1px solid var(--rule);
}

.note-warn .note-title {
  color: var(--flag);
}

.note-title {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-height: 2rem;
  font-weight: 700;
}

.note-fact {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.company-note {
  margin-top: 0.25rem;
  font-size: var(--text-sm);
}

.company-note summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--ink-soft);
  cursor: pointer;
}

.company-note p {
  max-width: 40rem;
  color: var(--ink-soft);
}

/* KPI 下面的「值得注意」：一列並排的短句，用細線隔開，不包卡片 */
.note-strip {
  min-width: 0;
}

.strip-title {
  margin: 0 0 0.5rem;
  font-size: var(--text-lg);
  font-weight: 700;
}

.notes-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 2.5rem;
  border-top: 1px solid var(--ink);
  border-radius: 0;
  background: none;
}

.notes-tiles .note {
  align-items: start;
  padding: 0.85rem 0;
}

.notes-tiles .note + .note {
  border-top: 0;
}

/* 官方標記：紅色只用在這裡 */
.notes-tiles .note-warn .note-fact {
  color: var(--flag);
}

.notes-tiles .note-title {
  min-height: 2rem;
}

/* ---------- 表格 ---------- */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.75rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

thead th {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
}

tbody th {
  font-weight: 600;
}

.fact-value {
  font-weight: 700;
}

.fact-sub {
  display: block;
  color: var(--ink-soft);
  font-size: var(--text-xs);
}

.table-scroll {
  position: relative; /* 裡面絕對定位的隱藏文字才不會跑出捲動區、把整頁撐寬 */
  overflow-x: auto;
}

.industry-table,
.rank-table,
.compare-table {
  min-width: 36rem;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.strong {
  font-weight: 700;
}

.muted {
  color: var(--ink-soft);
}

.code {
  margin-left: 0.4em;
  font-size: var(--text-sm);
}

.range-cell {
  width: 28%;
  min-width: 8rem;
}

.range {
  position: relative;
  display: block;
  height: 0.9rem;
  border-bottom: 1px solid var(--rule);
}

.range-bar {
  position: absolute;
  bottom: 0;
  height: 0.6rem;
  background: var(--tick);
}

.range-mid {
  position: absolute;
  bottom: 0;
  width: 3px;
  height: 0.9rem;
  margin-left: -1px;
  background: var(--ink);
}

.flag-cell {
  width: 2rem;
}

.flag {
  color: var(--flag);
}

/* ---------- 排序 ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.9rem;
  border: 1px solid var(--field-line);
  border-radius: var(--r);
  text-decoration: none;
}

.pill.current {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

/* 排序用的分段控制：一個底座裡放一排選項，目前那個是深色膠囊 */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.segmented .pill {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 600;
}

.segmented .pill.current {
  color: var(--paper);
}

.industry-table tbody th {
  white-space: nowrap;
}

/* 手機：分段控制排成一行、可以橫向滑，不要換行成奇怪的形狀 */
@media (max-width: 40rem) {
  .segmented {
    display: flex;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .segmented .pill {
    flex: none;
  }

  /* 可以橫向捲動時，外側的焦點框會被裁掉，改畫在內側 */
  .segmented .pill:focus-visible {
    outline-offset: -3px;
  }
}

/* 大表格放在一個面板裡，和卡片同一套表面 */
.table-panel {
  margin-top: 1.25rem;
  padding: 0.25rem 1.1rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.table-panel tbody tr:last-child > * {
  border-bottom: 0;
}

@media (max-width: 40rem) {
  .table-panel {
    padding: 0.25rem 0.75rem 0.5rem;
  }
}

/* 目前排序的那一欄：標題加深、數字加粗 */
.industry-table th.sorted {
  color: var(--ink);
  font-weight: 700;
}

.industry-table .sorted-1 > :nth-child(2),
.industry-table .sorted-2 > :nth-child(3),
.industry-table .sorted-4 > :nth-child(5),
.industry-table .sorted-5 > :nth-child(6),
.industry-table .sorted-6 > :nth-child(7),
.industry-table .sorted-7 > :nth-child(8) {
  font-weight: 700;
}

/* ---------- 比較 ---------- */

/* 比較頁的「加入公司」：選了就加入，不換頁 */
.compare-add {
  margin-top: 1.25rem;
}

.search-add {
  max-width: 30rem;
}

.search-add .search-input {
  min-height: var(--tap);
  font-size: var(--text-base);
  border-style: dashed;
}

.search-add .search-input:focus {
  border-style: solid;
}

.search-add .search-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 結果前面多一個「＋」，欄位多一格 */
.search-add .search-results a {
  grid-template-columns: auto auto auto 1fr auto;
}

.result-add {
  align-self: center;
  color: var(--marker);
}

.compare-add-hint {
  margin-top: 0.4rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.empty-state .compare-add {
  width: min(100%, 26rem);
  margin-top: 0.75rem;
  text-align: left;
}

/* 快速起點做成按鈕時，去掉按鈕預設外觀 */
button.chip {
  gap: 0.3rem;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

button.chip .icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--marker);
}

.compare-name {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 700;
}

.compare-name .icon-button {
  margin: -8px 0;
}

.compare-table th[scope='row'] {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--paper);
  font-weight: 400;
  color: var(--ink-soft);
}

.compare-table td {
  padding-left: 0.5rem;
}

.compare-table td.best {
  background: var(--select-bg);
  font-weight: 700;
}

.compare-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.compare-head .eyebrow {
  margin-bottom: 0.25rem;
}

/* 空狀態：靠左的一句話＋可以直接點的起點，不放裝飾圖示 */
.empty-state {
  display: grid;
  justify-items: start;
  gap: 0.35rem;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--ink);
}

.empty-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
}

.empty-text {
  color: var(--ink-soft);
}

.empty-state .quick-picks {
  margin-top: 0.75rem;
}

/* ---------- 有滑鼠才有 hover ---------- */

@media (hover: hover) {
  a:hover {
    text-decoration-color: var(--marker);
    text-decoration-thickness: 2px;
  }

  .search-input:not(:focus):not(:disabled):hover,
  .field-control:not(:focus):not(:disabled):not([aria-invalid='true']):hover,
  .check-field:hover {
    border-color: var(--ink-soft);
  }

  .search-clear:hover,
  .link-button:hover {
    background: var(--pressed);
    color: var(--ink);
  }

  .button:hover,
  .pill:not(.current):hover,
  .icon-button:hover {
    background: var(--pressed);
    color: var(--ink);
  }

  .tip-button:hover {
    color: var(--ink);
  }

  .button.button-primary:hover {
    border-color: var(--ink);
    background: color-mix(in srgb, var(--ink) 88%, var(--marker));
    color: var(--paper);
  }

  .button.button-primary[aria-pressed='true']:hover {
    border-color: var(--marker);
    background: var(--select-bg);
    color: var(--ink);
  }

  .tag-link:hover {
    border-color: var(--marker);
  }

  /* 表格列：滑過整列加淡底，比較好對齊同一列的數字 */
  .industry-table tbody tr:hover > *,
  .rank-table tbody tr:hover > *,
  .similar-table tbody tr:not(.is-self):hover > *,
  .compare-table tbody tr:hover > :not(.best) {
    background: var(--surface-2);
  }

  .segmented .pill:not(.current):hover {
    background: var(--pressed);
    color: var(--ink);
  }

  .chip:hover {
    border-color: var(--marker);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
  }

  .site-nav a:not([aria-current]):hover {
    background: var(--pressed);
    color: var(--ink);
  }

  .button[aria-pressed='true']:hover {
    background: var(--ink);
    color: var(--paper);
  }

  .search-results a:hover {
    background: var(--select-bg);
  }
}

/* ---------- 窄螢幕 ---------- */

@media (max-width: 40rem) {
  .search-results a {
    grid-template-columns: auto 1fr auto;
  }

  .search-add .search-results a {
    grid-template-columns: auto auto 1fr auto;
  }

  .result-meta {
    display: none;
  }

}


/* 標題旁的 ⓘ：放在標題外面，標題的名稱才不會混進說明 */
.title-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.share-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 0.75rem;
  border: 1px solid var(--field-line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
}

.share-input[hidden] {
  display: none;
}

/* ---------- 版頭搜尋 ---------- */

.header-search {
  flex: 1;
  min-width: 0;
  max-width: 22rem;
}

.header-search:empty {
  display: none;
}

.search-compact .search-input {
  min-height: var(--tap);
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  font-size: var(--text-base);
}

.search-compact .search-results {
  min-width: min(26rem, calc(100vw - 2rem));
}

/* ---------- 首頁主視覺 ---------- */

.home-hero {
  position: relative;
  padding: 2.5rem 0 1rem;
}

.eyebrow {
  margin-bottom: 0.5rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.home-hero .page-title {
  font-size: clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem);
  letter-spacing: 0.02em;
}

.home-hero .search {
  margin-top: 1.5rem;
}

.home-hero .search-input {
  min-height: 60px;
  border-radius: var(--r-lg);
}

.quick-picks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1rem;
}

.quick-label {
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
}

.quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.chip:active {
  transform: scale(0.97);
}

/* 安靜的次要按鈕：卡片底部的「看全部」 */
/* 展開長清單時，同一排的卡片不跟著拉長，避免旁邊留一大片空白 */
.dash:has([aria-expanded='true']) {
  align-items: start;
}

.button-quiet {
  min-height: 38px;
  padding: 0 0.75rem;
  border-color: transparent;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.button-quiet .icon {
  transition: transform var(--dur) var(--ease);
}

.button-quiet[aria-expanded='true'] .icon {
  transform: rotate(-90deg);
}

.button-quiet[aria-expanded='false'] .icon {
  transform: rotate(90deg);
}

/* ---------- KPI ---------- */

/* 不包卡片：最重要的數字自己一行、放很大；其他數字排在下面一列，用細線隔開 */
.kpis {
  display: flex;
  flex-wrap: wrap;
  margin: 1.5rem 0 0;
  border-top: 1px solid var(--ink);
}

.kpi {
  flex: 0 1 auto;
  min-width: 8rem;
  padding: 0.85rem 2.5rem 0.25rem 1.25rem;
  border-left: 1px solid var(--rule);
}

.kpi-hero {
  flex-basis: 100%;
  padding: 1rem 0 1.25rem;
  border-left: 0;
  border-bottom: 1px solid var(--rule);
}

.kpi-hero + .kpi {
  padding-left: 0;
  border-left: 0;
}

.kpi dt {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.kpi dd {
  margin: 0;
}

.kpi-value {
  display: block;
  font-size: var(--text-stat);
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: proportional-nums;
}

.kpi-hero dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
}

.kpi-hero .kpi-value {
  font-size: clamp(2.75rem, 2rem + 3vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.kpi-hero .kpi-sub {
  font-size: var(--text-sm);
}

.kpi-sub {
  display: block;
  color: var(--ink-soft);
  font-size: var(--text-xs);
}

@media (max-width: 40rem) {
  .kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi {
    padding: 0.75rem 0 0.5rem 1rem;
  }

  .kpi-hero {
    grid-column: 1 / -1;
    padding: 0.9rem 0 1rem;
  }

  /* 扣掉主數字後剩奇數個：最後一個撐滿，不留半格空位 */
  .kpi:not(.kpi-hero):last-child:nth-child(even) {
    grid-column: 1 / -1;
  }

  /* 兩欄時左右各一個，左邊那個不要分隔線 */

  .kpi-hero ~ .kpi:nth-child(even) {
    padding-left: 0;
    border-left: 0;
  }

  .kpi-hero ~ .kpi:nth-child(odd) {
    padding-left: 1rem;
    border-left: 1px solid var(--rule);
  }
}

/* ---------- 卡片 ---------- */

.dash {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3rem 2.5rem;
  align-items: stretch;
}

.dash-stack {
  display: grid;
  gap: 0.75rem;
}

/* 區塊不包卡片：上緣一條深色細線＋標題，像報紙版面的欄線 */
.card {
  position: relative;
  min-width: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ink);
}

.card-wide {
  grid-column: 1 / -1;
}

.card > .title-row {
  margin-bottom: 0.5rem;
}

.card-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.35;
}

.card-caption {
  max-width: 42rem;
  margin: 0.15rem 0 0.75rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

/* ---------- 圖表 ---------- */

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  font-variant-numeric: tabular-nums;
}

.chart .grid {
  stroke: var(--viz-grid);
  stroke-width: 1;
}

.chart .baseline {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart .axis-label,
.chart .axis-title,
.chart .ref-label {
  fill: var(--ink-soft);
  font-size: 12px;
}

.chart .mark-accent,
.chart .dot-accent {
  fill: var(--viz-accent);
}

.chart .mark-muted {
  fill: var(--viz-muted);
}

.chart .mark-main {
  fill: var(--viz-main);
}

.chart .dot-muted {
  fill: var(--viz-muted);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .dot-accent {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .ref-line {
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 4 3; /* 參考線（同業、中間值），不是格線 */
}

.chart .mark-label,
.chart .point-label.strong,
.chart .bar-name.strong {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.chart .point-label,
.chart .bar-name,
.chart .bar-value {
  fill: var(--ink);
  font-size: 13px;
}

.chart .bar-value {
  fill: var(--ink-soft);
}

.chart .hit {
  fill: transparent;
  cursor: pointer;
  touch-action: pan-y; /* 手機上下捲動照常，點一下才看數值 */
}

.chart g > .hit {
  cursor: default;
}

.chart a .hit {
  cursor: pointer;
}

.chart a:focus-visible {
  outline: none;
}

.chart a:focus-visible .hit {
  fill: var(--select-bg);
}

.chart-tip {
  position: fixed;
  z-index: 30;
  max-width: 16rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--text-sm);
  line-height: 1.45;
  pointer-events: none;
}

.chart-tip[hidden] {
  display: none;
}

.chart-tip-value {
  font-weight: 700;
}

@media (hover: hover) {
  .chart a:hover .hit {
    fill: var(--select-bg);
  }
}

@media (max-width: 40rem) {
  .dash {
    grid-template-columns: 1fr;
  }

  .header-search {
    max-width: none;
  }

  .site-header-inner {
    gap: 0.5rem;
  }
}

/* ---------- 公司頁的清單與數字 ---------- */

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 1rem 1.25rem;
  margin: 0;
}

.fact {
  padding-left: 0.75rem;
  border-left: 2px solid var(--rule);
}

.fact dt {
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.fact dd {
  margin: 0;
}

.more-button {
  margin-top: 0.75rem;
}

/* ---------- 動態 ---------- */

.range-scale {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.range-scale span:first-child,
.range-scale span:last-child {
  font-size: var(--text-xs);
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.kpi-delta .icon {
  width: 0.95em;
  height: 0.95em;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes grow-y {
  from {
    transform: scaleY(0);
  }
}

@keyframes grow-x {
  from {
    transform: scaleX(0);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0);
  }
}

@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
}

@keyframes draw {
  from {
    stroke-dashoffset: 1;
  }
}

.chart .bar-v {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.chart .bar-h,
.range-bar.bar-h {
  transform-box: fill-box;
  transform-origin: 0 50%;
}

.chart circle,
.strip .marker-dot {
  transform-box: fill-box;
  transform-origin: center;
}

@media screen and (prefers-reduced-motion: no-preference) {
  /* 卡片捲進畫面才開始；之前先停在起點，避免先閃一下完整的圖 */
  .card:not(.in-view) .chart .bar-v {
    transform: scaleY(0);
  }

  .card:not(.in-view) .chart .bar-h {
    transform: scaleX(0);
  }

  .card:not(.in-view) .chart circle,
  .card:not(.in-view) .chart .bar-value,
  .card:not(.in-view) .chart .mark-label,
  .card:not(.in-view) .strip .ticks,
  .card:not(.in-view) .strip .marker-line,
  .card:not(.in-view) .strip .marker-dot,
  .card:not(.in-view) .strip .marker-label {
    opacity: 0;
  }

  .card.in-view .chart .bar-v {
    animation: grow-y var(--dur-grow) var(--ease) both;
    animation-delay: var(--d, 0ms);
  }

  .card.in-view .chart .bar-h {
    animation: grow-x var(--dur-grow) var(--ease) both;
    animation-delay: var(--d, 0ms);
  }

  .card.in-view .chart .bar-value {
    animation: fade var(--dur) var(--ease) both;
    animation-delay: calc(var(--d, 0ms) + 360ms);
  }

  .card.in-view .chart .dot-muted {
    animation: pop var(--dur-slow) var(--ease) both;
  }

  /* 這家公司最後落定 */
  .card.in-view .chart .dot-accent,
  .card.in-view .strip .marker-dot {
    animation: pop 480ms var(--ease) both;
    animation-delay: 380ms;
  }

  .card.in-view .chart .mark-label {
    animation: fade var(--dur) var(--ease) both;
    animation-delay: 520ms;
  }

  .card.in-view .strip .ticks {
    animation: fade var(--dur-grow) var(--ease) both;
  }

  .card.in-view .strip .marker-line,
  .card.in-view .strip .marker-label {
    animation: drop 480ms var(--ease) both;
    animation-delay: 300ms;
  }

  /* 使用者動作的回饋 */
  .tip-panel:not([hidden]) {
    animation: enter 160ms var(--ease) both;
  }

  .chart-tip:not([hidden]) {
    animation: fade 120ms var(--ease) both;
  }

  .search-results:not(:empty) {
    animation: enter 160ms var(--ease) both;
  }

  .rank-table tbody tr {
    animation: fade var(--dur) var(--ease) both;
  }

  .button,
  .pill,
  .icon-button {
    transition:
      background-color var(--dur) var(--ease),
      color var(--dur) var(--ease),
      transform 120ms var(--ease);
  }
}

/* 同一頁重畫（比較頁移除公司、轉向）：不重播 */
.no-motion,
.no-motion * {
  animation: none !important;
}

/* ---------- 折線圖 ---------- */

.chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .line-dashed,
.legend-key .line-dashed {
  stroke-dasharray: 5 4;
}

.series-accent .line,
.legend-key.series-accent .line {
  stroke: var(--viz-accent);
}

.series-main .line,
.legend-key.series-main .line {
  stroke: var(--viz-main);
}

.series-muted .line,
.legend-key.series-muted .line {
  stroke: var(--viz-muted);
}

.series-accent .line-dot {
  fill: var(--viz-accent);
}

.series-main .line-dot {
  fill: var(--viz-main);
}

.series-muted .line-dot {
  fill: var(--viz-muted);
}

.chart .line-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .end-label {
  fill: var(--ink-soft);
  font-size: 12px;
}

.chart .end-label.strong {
  fill: var(--ink);
  font-weight: 700;
}

.chart .crosshair {
  stroke: var(--ink-soft);
  stroke-width: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-key {
  width: 18px;
  height: 8px;
  overflow: visible;
}

.legend-key .line {
  fill: none;
  stroke-width: 2;
}

@media screen and (prefers-reduced-motion: no-preference) {
  .card:not(.in-view) .chart .line:not(.line-dashed) {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
  }

  .card.in-view .chart .line:not(.line-dashed) {
    stroke-dasharray: 1;
    animation: draw 700ms var(--ease) both;
  }

  .card.in-view .chart .line-dashed {
    animation: fade var(--dur-grow) var(--ease) both;
  }

  .card:not(.in-view) .chart .line-dashed {
    opacity: 0;
  }

  .card.in-view .chart .end-label {
    animation: fade var(--dur) var(--ease) both;
    animation-delay: 600ms;
  }

  .card.in-view .chart .line-dot {
    animation: pop var(--dur-slow) var(--ease) both;
    animation-delay: 500ms;
  }

  .card:not(.in-view) .chart .end-label {
    opacity: 0;
  }

  .card:not(.in-view) .chart .line-dot {
    opacity: 0;
  }
}

/* ---------- 薪資特性、規模相近的同業 ---------- */

.traits {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.trait dt {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.trait dd {
  margin: 0;
}

.trait-value {
  display: block;
  font-size: 1.375rem;
  font-weight: 800;
  line-height: 1.3;
}

.trait-sub {
  display: block;
  color: var(--ink-soft);
  font-size: var(--text-xs);
}

.similar-table tr.is-self th,
.similar-table tr.is-self td {
  background: var(--select-bg);
}

.similar-table tr.is-self th {
  padding-left: 0.75rem;
}

.similar-table th[scope='row'],
.similar-table thead th:first-child {
  padding-left: 0.75rem;
}

.similar-table th[scope='row'] {
  white-space: nowrap;
}

/* ---------- 篩選、我的薪水 ---------- */

/* 條件面板：欄位自動排成幾欄，手機上兩欄 */
.filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem 1rem;
  align-items: end;
  margin-top: 1.25rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.field {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.field > label,
.field-label {
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 600;
}

.field-control {
  width: 100%;
  min-height: var(--tap);
  padding: 0 0.85rem;
  font-size: inherit; /* 表單元件預設字級比內文小 */
  background: var(--surface-2);
}

.select-wrap,
.unit-wrap {
  position: relative;
  display: block;
}

.select-wrap .field-control {
  padding-right: 2.25rem;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* 下拉箭頭：用線條圖示，跟著文字顏色變 */
.select-wrap .icon {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  width: 1rem;
  height: 1rem;
  color: var(--ink-soft);
  pointer-events: none;
  transform: translateY(-50%) rotate(90deg);
  transition: color var(--dur) var(--ease);
}

.select-wrap:focus-within .icon {
  color: var(--ink);
}

.unit-wrap .field-control {
  padding-right: 2.4rem;
  font-variant-numeric: tabular-nums;
}

.unit {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  pointer-events: none;
  transform: translateY(-50%);
}

.field-control[aria-invalid='true'] {
  border-color: var(--flag);
  background: var(--flag-bg);
}

.field-hint {
  color: var(--ink-soft);
  font-size: var(--text-xs);
}

/* 勾選做成跟其他欄位等高的一格，勾起來時整格變成選取色 */
.check-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--tap);
  padding: 0 0.85rem;
  border: 1px solid var(--field-line);
  border-radius: var(--r);
  background: var(--surface-2);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}

.check-field:has(input:checked) {
  border-color: var(--ink);
  background: var(--select-bg);
}

.check-field:has(input:focus-visible) {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--marker) 55%, transparent);
}

.check-field input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  border: 1.5px solid var(--field-line);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.check-field input:focus {
  outline: none;
}

/* 勾勾：兩條邊框轉 45 度 */
.check-field input::after {
  content: '';
  width: 0.35rem;
  height: 0.65rem;
  margin-top: -0.15rem;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--dur) var(--ease);
}

.check-field input:checked {
  border-color: var(--ink);
  background: var(--ink);
}

.check-field input:checked::after {
  transform: rotate(45deg) scale(1);
}

/* 清除條件：數字旁邊的文字按鈕 */
.link-button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 36px;
  margin-left: 0.75rem;
  padding: 0 0.6rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  vertical-align: middle;
  cursor: pointer;
}

.link-button .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.link-button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 0;
}

/* 條件面板：4 欄兩列；勾選那格佔兩欄，把第二列補滿 */
.filter-form > .field-check {
  grid-column: span 2;
}

@media (max-width: 56rem) {
  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.find-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.find-count {
  margin: 0;
  color: var(--ink-soft);
}

.find-count strong {
  margin-right: 0.15em;
  color: var(--ink);
  font-size: var(--text-stat);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.segmented button.pill {
  background: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.pill.current {
  background: var(--ink);
}

.find-results {
  margin-top: 0.75rem;
}

.find-results .empty-state {
  margin: 0.75rem 0;
  border: 0;
}

.find-table th.sorted {
  color: var(--ink);
  font-weight: 700;
}

.find-table tbody td:nth-child(3) {
  white-space: nowrap;
}

/* 我的薪水：表單只有兩欄，不要撐滿整列 */
.pay-form {
  max-width: 34rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start; /* 年薪下面有說明，欄位要從上面對齊 */
}

.pay-results {
  margin-top: 1.5rem;
}

.pay-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem 2.5rem;
  margin: 0 0 3rem;
}

.pay-stat {
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--ink);
}

.pay-stat dt {
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 600;
}

.pay-stat dd {
  margin: 0;
}

.pay-share {
  display: block;
  font-size: clamp(2rem, 1.5rem + 2vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.pay-next {
  margin: 1.25rem 0 0;
}

@media (max-width: 40rem) {
  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.9rem 0.9rem 1rem;
  }

  .pay-next .button {
    width: 100%;
  }
}

/* 高對比模式：自訂勾選框的底色會被蓋掉，改用系統色，勾勾才看得到 */
@media (forced-colors: active) {
  .check-field input {
    border-color: CanvasText;
  }

  .check-field input:checked {
    background: Highlight;
    border-color: Highlight;
  }

  .check-field input::after {
    border-color: HighlightText;
  }

  .search-input:focus,
  .field-control:focus,
  .check-field:has(input:focus-visible) {
    outline: 2px solid Highlight;
  }
}
