/* ==========================================================================
 * 她序美学 · 组件基线 v1.0（手写，可改）
 *
 * 规矩只有三条：
 *   1. 只用 --tx-* 令牌，不许出现十六进制、rgb()、px 字号；
 *   2. 类名一律 tx- 前缀，不碰 Discuz 模板与其他套件的类名；
 *   3. 每个可交互元素都要有可见焦点（:focus-visible），不许 outline:none 了事。
 *
 * 尺寸令牌：--tx-control-h(34) / -s(28) / -l(40)
 * ========================================================================== */

/* ---------- 页壳 ---------- */
.tx-page { width: 100%; max-width: var(--tx-container); margin: 0 auto; }
.tx-stack { display: grid; gap: var(--tx-space-4); min-width: 0; }
.tx-stack--tight { gap: var(--tx-space-2); }
.tx-stack--loose { gap: var(--tx-space-5); }
.tx-row { display: flex; align-items: center; gap: var(--tx-space-3); flex-wrap: wrap; min-width: 0; }
.tx-row--between { justify-content: space-between; }
.tx-grid { display: grid; gap: var(--tx-space-4); min-width: 0; }
.tx-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tx-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tx-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.tx-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--tx-space-4); flex-wrap: wrap; }
.tx-page-title { margin: 0; font-family: var(--tx-font-serif); font-size: var(--tx-text-2xl); line-height: var(--tx-leading-tight); color: var(--tx-ink); }
.tx-page-sub { margin: var(--tx-space-1) 0 0; font-size: var(--tx-text-s); color: var(--tx-ink-3); line-height: var(--tx-leading-normal); max-width: 72ch; }
.tx-eyebrow { margin: 0 0 var(--tx-space-2); font-size: var(--tx-text-2xs); letter-spacing: .16em; font-weight: var(--tx-weight-bold); color: var(--tx-ink-3); }

/* ---------- 卡片 ---------- */
.tx-card {
  background: var(--tx-surface);
  border: 1px solid var(--tx-line);
  border-radius: var(--tx-radius-l);
  min-width: 0;
  overflow: visible;
}
.tx-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--tx-space-3); padding: var(--tx-space-4) var(--tx-space-4) 0; flex-wrap: wrap; }
.tx-card__title { margin: 0; font-size: var(--tx-text-m); font-weight: var(--tx-weight-semibold); color: var(--tx-ink); }
.tx-card__sub { margin: var(--tx-space-1) 0 0; font-size: var(--tx-text-xs); color: var(--tx-ink-3); line-height: var(--tx-leading-normal); }
.tx-card__body { padding: var(--tx-space-4); min-width: 0; }
.tx-card__foot { padding: 0 var(--tx-space-4) var(--tx-space-4); display: flex; gap: var(--tx-space-2); flex-wrap: wrap; }
.tx-card--flush > .tx-card__body { padding: 0; }

/* ---------- 按钮 ---------- */
.tx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--tx-space-2);
  height: var(--tx-control-h); padding: 0 var(--tx-space-4);
  border: 1px solid var(--tx-line-strong); border-radius: var(--tx-radius-m);
  background: var(--tx-surface); color: var(--tx-ink);
  font-size: var(--tx-text-s); font-weight: var(--tx-weight-medium); line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--tx-dur-fast) var(--tx-ease), border-color var(--tx-dur-fast) var(--tx-ease), color var(--tx-dur-fast) var(--tx-ease);
}
.tx-btn:hover { background: var(--tx-surface-soft); border-color: var(--tx-ink-4); }
.tx-btn:focus-visible { outline: 2px solid var(--tx-focus); outline-offset: 2px; }
.tx-btn[disabled], .tx-btn.is-disabled { background: var(--tx-disabled-bg); color: var(--tx-disabled-ink); border-color: var(--tx-line); cursor: not-allowed; }
.tx-btn--primary { background: var(--tx-primary); border-color: var(--tx-primary); color: var(--tx-on-primary); }
.tx-btn--primary:hover { background: var(--tx-primary-hover); border-color: var(--tx-primary-hover); }
.tx-btn--accent { background: var(--tx-accent); border-color: var(--tx-accent); color: var(--tx-ink-inv); }
.tx-btn--accent:hover { background: var(--tx-accent-hover); border-color: var(--tx-accent-hover); }
.tx-btn--danger { background: var(--tx-danger); border-color: var(--tx-danger); color: var(--tx-ink-inv); }
.tx-btn--danger:hover { filter: brightness(.94); }
.tx-btn--ghost { background: transparent; border-color: transparent; color: var(--tx-ink-2); }
.tx-btn--ghost:hover { background: var(--tx-surface-sunken); color: var(--tx-ink); }
.tx-btn--link { background: transparent; border-color: transparent; color: var(--tx-primary); padding: 0 var(--tx-space-1); height: auto; text-decoration: underline; text-underline-offset: 3px; }
.tx-btn--link:hover { background: transparent; color: var(--tx-primary-hover); }
.tx-btn--s { height: var(--tx-control-h-s); padding: 0 var(--tx-space-3); font-size: var(--tx-text-xs); }
.tx-btn--l { height: var(--tx-control-h-l); padding: 0 var(--tx-space-5); font-size: var(--tx-text-m); }
.tx-btn--block { width: 100%; }
.tx-btn.is-loading { color: transparent; position: relative; pointer-events: none; }
.tx-btn.is-loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: var(--tx-radius-full);
  border: 2px solid currentColor; border-right-color: transparent;
  animation: tx-spin 640ms linear infinite;
}
@keyframes tx-spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.tx-field { display: grid; gap: var(--tx-space-1); min-width: 0; }
.tx-label { font-size: var(--tx-text-xs); font-weight: var(--tx-weight-semibold); color: var(--tx-ink-2); }
.tx-label .tx-req { color: var(--tx-danger); margin-left: 2px; }
.tx-hint { font-size: var(--tx-text-2xs); color: var(--tx-ink-3); line-height: var(--tx-leading-normal); }
.tx-msg { font-size: var(--tx-text-2xs); line-height: var(--tx-leading-normal); color: var(--tx-danger); }
.tx-input, .tx-select, .tx-textarea {
  width: 100%; min-width: 0; height: var(--tx-control-h);
  padding: 0 var(--tx-space-3);
  border: 1px solid var(--tx-line-strong); border-radius: var(--tx-radius-m);
  background: var(--tx-surface); color: var(--tx-ink);
  font-family: var(--tx-font-sans); font-size: var(--tx-text-s); line-height: var(--tx-leading-normal);
  transition: border-color var(--tx-dur-fast) var(--tx-ease), box-shadow var(--tx-dur-fast) var(--tx-ease);
}
.tx-textarea { height: auto; min-height: 92px; padding: var(--tx-space-2) var(--tx-space-3); resize: vertical; }
.tx-select { appearance: none; padding-right: var(--tx-space-6); background-image: linear-gradient(45deg, transparent 50%, var(--tx-ink-3) 50%), linear-gradient(135deg, var(--tx-ink-3) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.tx-input::placeholder, .tx-textarea::placeholder { color: var(--tx-ink-4); }
.tx-input:hover, .tx-select:hover, .tx-textarea:hover { border-color: var(--tx-ink-4); }
.tx-input:focus-visible, .tx-select:focus-visible, .tx-textarea:focus-visible,
.tx-input:focus, .tx-select:focus, .tx-textarea:focus {
  outline: none; border-color: var(--tx-focus); box-shadow: var(--tx-focus-ring);
}
.tx-input[aria-invalid="true"], .tx-textarea[aria-invalid="true"], .tx-select[aria-invalid="true"] { border-color: var(--tx-danger); }
.tx-input[disabled], .tx-textarea[disabled], .tx-select[disabled] { background: var(--tx-disabled-bg); color: var(--tx-disabled-ink); cursor: not-allowed; }
.tx-input--s { height: var(--tx-control-h-s); font-size: var(--tx-text-xs); }
.tx-input--mono { font-family: var(--tx-font-mono); font-size: var(--tx-text-xs); }
.tx-field--invalid .tx-label { color: var(--tx-danger); }

/* 带前后缀的输入框 */
.tx-input-group { display: flex; align-items: stretch; min-width: 0; }
.tx-input-group > .tx-input { border-radius: 0; }
.tx-input-group > :first-child { border-radius: var(--tx-radius-m) 0 0 var(--tx-radius-m); }
.tx-input-group > :last-child { border-radius: 0 var(--tx-radius-m) var(--tx-radius-m) 0; }
.tx-input-group__addon {
  display: inline-flex; align-items: center; padding: 0 var(--tx-space-3);
  border: 1px solid var(--tx-line-strong); background: var(--tx-surface-sunken);
  color: var(--tx-ink-3); font-size: var(--tx-text-xs); white-space: nowrap;
}
.tx-input-group > .tx-input + .tx-input-group__addon { border-left: 0; }

/* 选择控件 */
.tx-check { display: inline-flex; align-items: flex-start; gap: var(--tx-space-2); font-size: var(--tx-text-s); color: var(--tx-ink); cursor: pointer; line-height: var(--tx-leading-normal); }
.tx-check input { appearance: none; flex: none; width: 16px; height: 16px; margin: 2px 0 0; border: 1px solid var(--tx-line-strong); border-radius: 4px; background: var(--tx-surface); cursor: pointer; transition: background var(--tx-dur-fast) var(--tx-ease), border-color var(--tx-dur-fast) var(--tx-ease); }
.tx-check input[type="radio"] { border-radius: var(--tx-radius-full); }
.tx-check input:checked { background: var(--tx-primary); border-color: var(--tx-primary); }
.tx-check input[type="radio"]:checked { box-shadow: inset 0 0 0 3px var(--tx-surface); }
/* 勾选标记用两条边框拼，而不是背景渐变——渐变画出来是个叉 */
.tx-check input[type="checkbox"]:checked::after {
  content: ""; display: block; width: 4px; height: 8px; margin: 1px auto 0;
  border-right: 2px solid var(--tx-on-primary); border-bottom: 2px solid var(--tx-on-primary);
  transform: rotate(45deg) translate(-1px, -1px);
}
.tx-check input[type="checkbox"]:checked { background-color: var(--tx-primary); border-color: var(--tx-primary); }
.tx-check input:focus-visible { outline: 2px solid var(--tx-focus); outline-offset: 2px; }
.tx-check input:disabled { background: var(--tx-disabled-bg); border-color: var(--tx-line); cursor: not-allowed; }
.tx-check span { min-width: 0; }
.tx-check small { display: block; color: var(--tx-ink-3); font-size: var(--tx-text-2xs); }

.tx-switch { display: inline-flex; align-items: center; gap: var(--tx-space-2); font-size: var(--tx-text-s); color: var(--tx-ink); cursor: pointer; }
.tx-switch input { appearance: none; position: relative; width: 34px; height: 20px; margin: 0; border-radius: var(--tx-radius-full); background: var(--tx-line-strong); cursor: pointer; transition: background var(--tx-dur-base) var(--tx-ease); flex: none; }
.tx-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--tx-radius-full); background: var(--tx-surface); box-shadow: var(--tx-shadow-xs); transition: transform var(--tx-dur-base) var(--tx-ease); }
.tx-switch input:checked { background: var(--tx-success); }
.tx-switch input:checked::after { transform: translateX(14px); }
.tx-switch input:focus-visible { outline: 2px solid var(--tx-focus); outline-offset: 2px; }

/* ---------- 表格 ---------- */
.tx-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; min-width: 0; }
.tx-table { width: 100%; border-collapse: collapse; font-size: var(--tx-text-s); color: var(--tx-ink-2); }
.tx-table th {
  text-align: left; font-size: var(--tx-text-2xs); font-weight: var(--tx-weight-bold); letter-spacing: .04em;
  color: var(--tx-ink-3); padding: var(--tx-space-2) var(--tx-space-3);
  border-bottom: 1px solid var(--tx-line); background: var(--tx-surface-soft); white-space: nowrap;
}
.tx-table td { padding: var(--tx-space-2) var(--tx-space-3); border-bottom: 1px solid var(--tx-line-soft); vertical-align: middle; }
.tx-table tbody tr:last-child td { border-bottom: 0; }
.tx-table tbody tr:hover td { background: var(--tx-surface-soft); }
.tx-table--compact th, .tx-table--compact td { padding: var(--tx-space-1) var(--tx-space-2); }
.tx-table .is-num { text-align: right; font-family: var(--tx-font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-table .is-strong { color: var(--tx-ink); font-weight: var(--tx-weight-semibold); }
.tx-table .is-muted { color: var(--tx-ink-3); }
.tx-table td code { font-family: var(--tx-font-mono); font-size: var(--tx-text-2xs); background: var(--tx-surface-sunken); border-radius: var(--tx-radius-s); padding: 1px var(--tx-space-1); color: var(--tx-ink); word-break: break-all; }
.tx-table-wrap--sticky { max-height: 60vh; overflow-y: auto; }
.tx-table-wrap--sticky thead th { position: sticky; top: 0; z-index: 1; }

/* ---------- 状态与标签 ---------- */
.tx-pill {
  display: inline-flex; align-items: center; gap: var(--tx-space-1);
  height: 20px; padding: 0 var(--tx-space-2);
  border-radius: var(--tx-radius-full);
  font-size: var(--tx-text-2xs); font-weight: var(--tx-weight-semibold); white-space: nowrap;
  background: var(--tx-surface-sunken); color: var(--tx-ink-2);
}
.tx-pill::before { content: ""; width: 5px; height: 5px; border-radius: var(--tx-radius-full); background: currentColor; flex: none; }
.tx-pill--plain::before { display: none; }
.tx-pill--success { background: var(--tx-success-soft); color: var(--tx-success); }
.tx-pill--warning { background: var(--tx-warning-soft); color: var(--tx-warning); }
.tx-pill--danger  { background: var(--tx-danger-soft); color: var(--tx-danger); }
.tx-pill--info    { background: var(--tx-info-soft); color: var(--tx-info); }
.tx-pill--ai      { background: var(--tx-ai-soft); color: var(--tx-ai); }
.tx-pill--brand   { background: var(--tx-primary-soft); color: var(--tx-primary); }
.tx-tag {
  display: inline-flex; align-items: center; gap: var(--tx-space-1);
  padding: 1px var(--tx-space-2); border: 1px solid var(--tx-line); border-radius: var(--tx-radius-s);
  font-size: var(--tx-text-2xs); color: var(--tx-ink-2); background: var(--tx-surface);
}
.tx-tag--solid { background: var(--tx-surface-sunken); border-color: transparent; }

/* ---------- 空态 ---------- */
.tx-empty { display: grid; justify-items: center; gap: var(--tx-space-2); padding: var(--tx-space-7) var(--tx-space-4); text-align: center; }
.tx-empty__mark { width: 40px; height: 40px; border-radius: var(--tx-radius-l); display: grid; place-items: center; background: var(--tx-surface-sunken); color: var(--tx-ink-4); font-size: var(--tx-text-l); }
.tx-empty__title { margin: 0; font-size: var(--tx-text-m); font-weight: var(--tx-weight-semibold); color: var(--tx-ink); }
.tx-empty__desc { margin: 0; font-size: var(--tx-text-s); color: var(--tx-ink-3); max-width: 46ch; line-height: var(--tx-leading-normal); }
.tx-empty__action { margin-top: var(--tx-space-2); }

/* ---------- 提示 ---------- */
.tx-alert { display: flex; gap: var(--tx-space-2); padding: var(--tx-space-3) var(--tx-space-4); border-radius: var(--tx-radius-m); border: 1px solid var(--tx-line); background: var(--tx-surface-soft); color: var(--tx-ink-2); font-size: var(--tx-text-s); line-height: var(--tx-leading-normal); }
.tx-alert b { color: var(--tx-ink); }
.tx-alert--success { background: var(--tx-success-soft); border-color: var(--tx-success-soft); color: var(--tx-success); }
.tx-alert--warning { background: var(--tx-warning-soft); border-color: var(--tx-warning-soft); color: var(--tx-warning); }
.tx-alert--danger  { background: var(--tx-danger-soft); border-color: var(--tx-danger-soft); color: var(--tx-danger); }
.tx-alert--info    { background: var(--tx-info-soft); border-color: var(--tx-info-soft); color: var(--tx-info); }
.tx-alert--ai      { background: var(--tx-ai-soft); border-color: var(--tx-ai-soft); color: var(--tx-ai); }

/* ---------- 标签页 ---------- */
.tx-tabs { display: flex; gap: var(--tx-space-1); border-bottom: 1px solid var(--tx-line); overflow-x: auto; }
.tx-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: var(--tx-space-2) var(--tx-space-3); margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: var(--tx-text-s); color: var(--tx-ink-3); white-space: nowrap;
}
.tx-tab:hover { color: var(--tx-ink); }
.tx-tab[aria-selected="true"] { color: var(--tx-primary); border-bottom-color: var(--tx-primary); font-weight: var(--tx-weight-semibold); }
.tx-tab:focus-visible { outline: 2px solid var(--tx-focus); outline-offset: -2px; }

/* ---------- 分页 ---------- */
.tx-pager { display: flex; align-items: center; gap: var(--tx-space-1); flex-wrap: wrap; }
.tx-pager__item {
  min-width: 30px; height: 30px; padding: 0 var(--tx-space-2);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--tx-line); border-radius: var(--tx-radius-s);
  background: var(--tx-surface); color: var(--tx-ink-2); font-size: var(--tx-text-xs); text-decoration: none;
}
.tx-pager__item:hover { border-color: var(--tx-line-strong); color: var(--tx-ink); }
.tx-pager__item[aria-current="page"] { background: var(--tx-accent); border-color: var(--tx-accent); color: var(--tx-ink-inv); font-weight: var(--tx-weight-semibold); }
.tx-pager__item:focus-visible { outline: 2px solid var(--tx-focus); outline-offset: 2px; }
.tx-pager__gap { color: var(--tx-ink-4); padding: 0 var(--tx-space-1); }

/* ---------- 工具条 / 键值 ---------- */
.tx-toolbar { display: flex; align-items: center; gap: var(--tx-space-2); flex-wrap: wrap; padding: var(--tx-space-2) 0; min-width: 0; }
.tx-toolbar__spacer { flex: 1 1 auto; }
.tx-kv { display: grid; grid-template-columns: minmax(88px, auto) 1fr; gap: var(--tx-space-2) var(--tx-space-3); margin: 0; font-size: var(--tx-text-s); }
.tx-kv dt { color: var(--tx-ink-3); }
.tx-kv dd { margin: 0; color: var(--tx-ink); min-width: 0; word-break: break-word; }

/* ---------- 骨架 ---------- */
.tx-skeleton { display: block; height: 10px; border-radius: var(--tx-radius-s); background: linear-gradient(90deg, var(--tx-surface-sunken) 25%, var(--tx-surface-soft) 50%, var(--tx-surface-sunken) 75%); background-size: 200% 100%; animation: tx-shimmer 1.2s var(--tx-ease) infinite; }
.tx-skeleton--text { height: 11px; }
.tx-skeleton--title { height: 18px; width: 40%; }
@keyframes tx-shimmer { to { background-position: -200% 0; } }

/* ---------- 代码与复制 ---------- */
.tx-code { font-family: var(--tx-font-mono); font-size: var(--tx-text-2xs); line-height: var(--tx-leading-relaxed); background: var(--tx-surface-sunken); border: 1px solid var(--tx-line); border-radius: var(--tx-radius-m); padding: var(--tx-space-3); overflow-x: auto; white-space: pre; color: var(--tx-ink-2); }

/* ---------- 分节标题 ---------- */
.tx-h2 { display: flex; align-items: baseline; gap: var(--tx-space-2); margin: 0; padding-bottom: var(--tx-space-2); border-bottom: 1px solid var(--tx-line); font-family: var(--tx-font-serif); font-size: var(--tx-text-xl); color: var(--tx-ink); }
.tx-h2 i { font-style: normal; font-family: var(--tx-font-mono); font-size: var(--tx-text-2xs); color: var(--tx-ink-3); letter-spacing: .08em; }
.tx-h3 { margin: 0; font-size: var(--tx-text-m); font-weight: var(--tx-weight-semibold); color: var(--tx-ink); }
.tx-note { margin: 0; font-size: var(--tx-text-2xs); color: var(--tx-ink-3); line-height: var(--tx-leading-normal); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .tx-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tx-grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tx-grid--2 { grid-template-columns: 1fr; }
  .tx-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tx-page-title { font-size: var(--tx-text-xl); }
  .tx-table { min-width: 520px; }
  .tx-table--stack { min-width: 0; }
  .tx-table--stack thead { display: none; }
  .tx-table--stack tr { display: grid; gap: 2px; padding: var(--tx-space-2) 0; border-bottom: 1px solid var(--tx-line-soft); }
  .tx-table--stack td { border: 0; padding: 1px var(--tx-space-3); display: flex; justify-content: space-between; gap: var(--tx-space-3); }
  .tx-table--stack td::before { content: attr(data-th); color: var(--tx-ink-3); font-size: var(--tx-text-2xs); }
}

@media (prefers-reduced-motion: reduce) {
  .tx-btn, .tx-input, .tx-select, .tx-textarea, .tx-switch input, .tx-switch input::after { transition: none; }
  .tx-skeleton, .tx-btn.is-loading::after { animation: none; }
}

@media print {
  .tx-btn, .tx-pager, .tx-tabs { display: none; }
  .tx-card { border-color: var(--tx-line-strong); }
}
