/* ============================================================
   CPA 工具站 — 设计系统 v2
   暗调奢华 · 玻璃拟态 · 光晕动效 · 实验性排版
   双主题:浅色(:root) / 深色([data-theme="dark"])
   ============================================================ */

:root {
  color-scheme: light;
  --page: #eef1f3;
  --page-2: #f7f8f6;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-soft: #f4f7f5;
  --surface-sunken: #e9efec;
  --ink: #172124;
  --ink-strong: #0b1113;
  --muted: #667477;
  --muted-strong: #49575a;
  --line: rgba(31, 49, 53, 0.12);
  --line-strong: rgba(31, 49, 53, 0.24);
  --accent: #14806f;
  --accent-strong: #0c5d52;
  --accent-soft: #e0f1ec;
  --navy: #31556b;
  --navy-soft: #e7eef2;
  --amber: #ad6818;
  --amber-soft: #fff0d8;
  --danger: #b9473d;
  --danger-soft: #fde8e5;
  --on-accent: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.72);
  --panel-bg: rgba(255, 255, 255, 0.66);
  --input-bg: rgba(255, 255, 255, 0.86);
  --input-ink: #172124;
  --table-head-bg: #e8efeb;
  --table-head-ink: #334144;
  --selected-bg: #e6f4ef;
  --focus-ring: rgba(20, 128, 111, 0.22);
  --accent-shadow: rgba(20, 128, 111, 0.22);
  --grid-line: rgba(23, 121, 109, 0.05);
  --orb-a: rgba(20, 128, 111, 0.14);
  --orb-b: rgba(49, 85, 107, 0.12);
  --halo: rgba(20, 128, 111, 0.08);
  --shadow-sm: 0 8px 22px rgba(26, 39, 42, 0.08);
  --shadow: 0 18px 48px rgba(26, 39, 42, 0.12);
  --shadow-deep: 0 26px 70px rgba(26, 39, 42, 0.18);
  --radius: 8px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 240ms;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #07090b;
  --page-2: #0c0f12;
  --surface: rgba(17, 21, 25, 0.7);
  --surface-solid: #111519;
  --surface-soft: #1a1f24;
  --surface-sunken: #0e1215;
  --ink: #e8edef;
  --ink-strong: #ffffff;
  --muted: #96a2a6;
  --muted-strong: #bcc6c9;
  --line: rgba(224, 236, 235, 0.1);
  --line-strong: rgba(224, 236, 235, 0.2);
  --accent: #4fd1b5;
  --accent-strong: #8fe0cd;
  --accent-soft: #14312c;
  --navy: #8fb3ca;
  --navy-soft: #1b2832;
  --amber: #e6ad5a;
  --amber-soft: #2c2114;
  --danger: #ef8d80;
  --danger-soft: #331f1d;
  --on-accent: #061210;
  --topbar-bg: rgba(10, 13, 16, 0.78);
  --panel-bg: rgba(14, 18, 22, 0.72);
  --input-bg: rgba(8, 11, 13, 0.9);
  --input-ink: #e9eff0;
  --table-head-bg: #161c20;
  --table-head-ink: #c6d1d3;
  --selected-bg: #162b26;
  --focus-ring: rgba(79, 209, 181, 0.3);
  --accent-shadow: rgba(79, 209, 181, 0.16);
  --grid-line: rgba(143, 179, 202, 0.045);
  --orb-a: rgba(79, 209, 181, 0.09);
  --orb-b: rgba(143, 179, 202, 0.07);
  --halo: rgba(79, 209, 181, 0.06);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.36);
  --shadow-deep: 0 26px 74px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

/* ---------- 页面背景:基底 + 网格 + 浮动光晕 ---------- */
body {
  position: relative;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  background-color: var(--page);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  letter-spacing: 0;
  overflow-x: hidden;
}

/* 浮动光晕 A(左上,青绿) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(52vw 52vw at 8% -6%, var(--orb-a), transparent 62%),
    radial-gradient(44vw 44vw at 104% 16%, var(--orb-b), transparent 60%),
    radial-gradient(36vw 36vw at 50% 118%, var(--orb-a), transparent 58%);
  animation: orbDrift 26s ease-in-out infinite alternate;
}

/* 跟随指针的光晕(由 fx.mjs 创建 .bg-halo) */
.bg-halo {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(560px 560px at var(--halo-x, 50%) var(--halo-y, 40%), var(--halo), transparent 68%);
  opacity: 0;
  transition: opacity 900ms ease;
}

body:hover .bg-halo {
  opacity: 1;
}

@keyframes orbDrift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-2.5vw, 1.6vh, 0) scale(1.08);
  }
}

button,
textarea {
  font: inherit;
}

button {
  letter-spacing: 0;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------- 无障碍跳转 ---------- */
.skip-link {
  position: fixed;
  top: -48px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--navy));
  box-shadow: var(--shadow);
  text-decoration: none;
  font-weight: 650;
  transition: top 200ms var(--ease);
}

.skip-link:focus {
  top: 12px;
}

/* ---------- 站点骨架 ---------- */
.app-shell {
  width: min(100% - 32px, 1500px);
  margin: 0 auto;
  padding: 16px 0 32px;
}

/* ---------- 顶部栏(三栏:品牌 | 导航居中 | 动作) ---------- */
.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--topbar-bg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(20px) saturate(1.4);
  animation: topbarIn 600ms var(--ease) both;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 45%, transparent), transparent);
  opacity: 0.7;
}

@keyframes topbarIn {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand-block,
.topbar-actions,
.toolbar-actions,
.import-actions,
.paste-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-block {
  min-width: 0;
  justify-self: start;
}

.brand-mark {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 48px;
}

.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}

.brand-block h1,
.toolbar h2,
.pane-head h2,
.mini-head h3 {
  margin: 0;
  color: var(--ink-strong);
  font-weight: 780;
  line-height: 1.18;
  text-wrap: balance;
  letter-spacing: -0.01em;
}

.brand-block h1 {
  font-size: 1.2rem;
}

.brand-block p,
.toolbar p,
.pane-head p,
.mini-head span,
.field-label,
.dropzone span,
.stat-block small {
  color: var(--muted);
}

.brand-block p,
.toolbar p,
.pane-head p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.topbar-actions {
  justify-content: flex-end;
  justify-self: end;
  min-width: 0;
}

/* ---------- 导航(首页按钮,统一实心) ---------- */
.site-nav {
  display: flex;
  gap: 4px;
  justify-self: center;
}

.site-nav .nav-link {
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  /* 全站唯一导航入口:统一为 accent 实心样式,不随当前页面变化
     (特异性高于 .mode-button,避免被其透明样式覆盖) */
  color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #ffffff 8%), var(--accent));
  box-shadow: 0 10px 24px var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), filter 200ms var(--ease);
}

.site-nav .nav-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 14px 30px var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.site-nav .nav-link.is-current {
  /* 与基础样式一致(保留类名,未来多导航项时可按需扩展) */
}

/* ---------- 模式切换 / 通用按钮基底 ---------- */
.mode-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

.mode-button,
.button,
.icon-button,
.inline-button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    color 200ms var(--ease),
    background 200ms var(--ease),
    border-color 200ms var(--ease),
    box-shadow 200ms var(--ease),
    transform 160ms var(--ease);
}

.mode-button:active,
.button:active:not(:disabled),
.icon-button:active,
.inline-button:active {
  transform: translateY(0) scale(0.98);
}

.mode-button {
  min-height: 42px;
  padding: 8px 12px;
  color: var(--muted-strong);
  background: transparent;
  white-space: nowrap;
}

.mode-button:hover,
.button:hover:not(:disabled),
.icon-button:hover,
.inline-button:hover {
  transform: translateY(-1px);
}

.mode-button.is-active {
  color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #ffffff 8%), var(--accent));
  box-shadow: 0 10px 24px var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--muted-strong);
  background: var(--surface-solid);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  color: var(--accent-strong);
  border-color: var(--line-strong);
}

.theme-toggle {
  position: relative;
}

/* 图标尺寸规范(Lucide 均为 24 viewBox,统一缩放到目标尺寸) */
.icon-button svg,
.inline-button svg,
.button svg,
.drop-icon svg {
  width: 18px;
  height: 18px;
}

.theme-icon {
  width: 18px;
  height: 18px;
  position: absolute;
  transition: opacity 180ms ease, transform 180ms var(--ease);
}

.theme-icon-light {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-icon-dark {
  opacity: 0;
  transform: rotate(-30deg) scale(0.72);
}

[data-theme="dark"] .theme-icon-light {
  opacity: 0;
  transform: rotate(30deg) scale(0.72);
}

[data-theme="dark"] .theme-icon-dark {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ---------- 工作台(转换台) ---------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.side-pane,
.main-pane {
  display: grid;
  align-content: start;
  gap: 14px;
}

.side-pane {
  position: sticky;
  top: 16px;
}

.main-pane {
  min-width: 0;
}

.pane-head,
.toolbar,
.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar {
  flex-wrap: wrap;
}

.toolbar-actions,
.import-actions,
.paste-actions {
  flex-wrap: wrap;
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px 18px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted-strong);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color 200ms var(--ease), background 200ms var(--ease), transform 200ms var(--ease), box-shadow 200ms var(--ease);
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--focus-ring);
  transform: scale(1.012);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.dropzone strong {
  color: var(--ink-strong);
  font-size: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  white-space: nowrap;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.button.primary {
  color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #ffffff 8%), var(--accent));
  box-shadow: 0 12px 24px var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, #ffffff 14%), var(--accent-strong));
}

.button.secondary {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--line));
}

.button.secondary:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  box-shadow: var(--shadow-sm);
}

.button.ghost {
  color: var(--muted-strong);
  background: var(--surface-soft);
  border-color: var(--line);
}

.button.ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--line-strong);
}

.merge-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--amber) 18%, var(--line));
  border-radius: var(--radius);
  color: var(--amber);
  background: var(--amber-soft);
  line-height: 1.5;
}

.paste-box {
  display: grid;
  gap: 8px;
}

.field-label {
  font-size: 0.86rem;
  font-weight: 680;
}

/* ---------- 输入框全自定义(与 textarea 同级) ---------- */
input[type="text"],
input[type="password"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="url"] {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--input-ink);
  background: var(--input-bg);
  font: 0.88rem/1.4 "Cascadia Mono", "Consolas", "Microsoft YaHei UI", monospace;
  outline: none;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease), background 200ms var(--ease);
}

input::placeholder {
  color: color-mix(in srgb, var(--muted) 76%, transparent);
}

input:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong));
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  caret-color: var(--accent-strong);
}

input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* 浏览器自动填充(黄底)修正 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--input-ink);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  caret-color: var(--accent-strong);
  transition: background-color 99999s ease-in-out 0s;
}

textarea,
pre {
  width: 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--input-ink);
  background: var(--input-bg);
  font: 0.86rem/1.58 "Cascadia Mono", "Consolas", "Microsoft YaHei UI", monospace;
  font-variant-numeric: tabular-nums;
}

textarea {
  min-height: 176px;
  resize: vertical;
  padding: 12px;
  outline: none;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease), background 200ms var(--ease);
}

textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 76%, transparent);
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-block {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.stat-block span {
  color: var(--ink-strong);
  font-weight: 780;
  font-size: 1.18rem;
}

.stat-block.warning span {
  color: var(--amber);
}

.table-zone {
  min-height: 220px;
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--table-head-ink);
  background: var(--table-head-bg);
  font-weight: 680;
  white-space: nowrap;
}

tbody tr {
  transition: background 160ms ease;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

tbody tr.is-selected {
  background: var(--selected-bg);
}

.empty-row td {
  padding: 0;
  border: 0;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 22px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
}

.empty-state strong {
  color: var(--ink-strong);
  font-size: 0.94rem;
}

.file-stack,
.account-stack {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.file-stack strong,
.account-stack strong {
  color: var(--ink-strong);
  font-weight: 640;
  word-break: break-all;
}

.file-stack span,
.account-stack span {
  color: var(--muted);
  font-size: 0.78rem;
}

.output-name {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.8rem;
  color: var(--muted-strong);
  word-break: break-all;
}

.muted-cell {
  color: var(--muted);
}

.platform-chip,
.plan-chip {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 620;
}

.platform-chip {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.plan-chip {
  color: var(--navy);
  background: var(--navy-soft);
}

.inline-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  border-color: var(--line);
}

.inline-button:hover {
  color: var(--accent-strong);
  border-color: var(--line-strong);
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.preview-pane,
.issues-pane {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
}

.mini-head h3 {
  font-size: 0.94rem;
}

#preview-output {
  max-height: 340px;
  overflow: auto;
  padding: 12px;
  font-size: 0.8rem;
}

#issues-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 300px;
  overflow: auto;
}

#issues-list li {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--amber) 22%, var(--line));
  border-radius: var(--radius);
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 0.82rem;
  line-height: 1.5;
}

#issues-list li strong {
  color: var(--ink-strong);
}

#issues-list .empty-issue {
  color: var(--muted);
  background: var(--surface-soft);
  border-color: var(--line);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(440px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-solid);
  box-shadow: var(--shadow-deep);
  animation: toastIn 200ms var(--ease) forwards;
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(440px, calc(100vw - 40px));
}

.toast-container .toast {
  position: static;
  right: auto;
  bottom: auto;
  max-width: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--muted-strong);
}

.toast-icon svg {
  width: 16px;
  height: 16px;
}

.toast[data-kind="success"] {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
}

.toast[data-kind="success"] .toast-icon {
  color: var(--accent-strong);
}

.toast[data-kind="error"] {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
}

.toast[data-kind="error"] .toast-icon {
  color: var(--danger);
}

.toast[data-kind="info"] .toast-icon {
  color: var(--navy);
}

.toast-close {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.toast-close:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.toast.leaving {
  animation: toastOut 160ms ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- 转换台模式切换动画 ---------- */
.workbench.is-switching {
  animation: modePulse 280ms var(--ease) both;
}

@keyframes modePulse {
  from {
    opacity: 0.55;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 原生控件自定义(select / checkbox / number / 滚动条 / 选区) ---------- */
::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--ink-strong);
}

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

/* 滚动条(WebKit) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: color-mix(in srgb, var(--muted) 26%, transparent);
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 52%, transparent);
  background-clip: padding-box;
}

/* 滚动条(Firefox) */
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 36%, transparent) transparent;
}

/* 下拉框:去原生外观,自定义 chevron(Lucide) */
select {
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23495558' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 15px;
  padding-right: 38px;
  cursor: pointer;
}

[data-theme="dark"] select {
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2396a2a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* 数字输入:隐藏原生 spinner */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* 复选框:自定义外观(对勾) */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  cursor: pointer;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

input[type="checkbox"]:hover {
  border-color: var(--accent);
}

input[type="checkbox"]:checked {
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #ffffff 8%), var(--accent));
  box-shadow: 0 4px 12px var(--accent-shadow);
}

input[type="checkbox"]:checked::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) translateY(-1px);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .site-nav {
    grid-column: 1 / -1;
    justify-self: center;
  }

  .topbar-actions {
    grid-column: 2;
  }

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

  .side-pane {
    position: static;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
    align-items: start;
  }

  .pane-head,
  .dropzone,
  .import-actions,
  .paste-box,
  .paste-actions,
  .stats-grid,
  .merge-note {
    grid-column: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 18px, 1500px);
    padding: 9px 0 18px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
  }

  .brand-block {
    align-items: flex-start;
  }

  .topbar-actions,
  .toolbar,
  .toolbar-actions {
    flex-direction: column;
  }

  .site-nav,
  .mode-switch,
  .toolbar-actions,
  .import-actions,
  .paste-actions {
    width: 100%;
  }

  .mode-switch {
    flex-wrap: wrap;
  }

  .mode-button {
    min-width: 0;
    white-space: normal;
    flex: 1 1 auto;
  }

  .toolbar-actions .button,
  .import-actions .button,
  .paste-actions .button {
    flex: 1 1 0;
  }

  .side-pane,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .brand-block h1 {
    font-size: 1.08rem;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: stretch;
  }

  .topbar-actions > .icon-button {
    order: 1;
  }

  .site-nav {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
  }

  .mode-switch {
    order: 3;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .icon-button {
    width: 42px;
  }

  .table-zone {
    min-height: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
  }

  td {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  td:last-child {
    border-bottom: 0;
  }

  .row-actions {
    justify-content: flex-end;
  }

  .lower-grid {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
