/* 通用组件：按钮、徽标、卡片、表单、表格、弹窗、抽屉、通知、骨架屏、空态、分页。 */

/* ══ 按钮 ══════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r);
  background: var(--bg-hover);
  color: var(--fg);
  font-size: var(--fs-md);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
}
.btn:hover { background: var(--line); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: none;
  border-color: var(--line-strong);
  color: var(--fg-2);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--fg); }

/* 危险操作绝不能长得像主按钮 —— 手滑点下去是不可逆的 */
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-danger-ghost { background: none; border-color: var(--err); color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-soft); }

.btn-text {
  height: auto; padding: 2px 4px;
  background: none; color: var(--accent); font-weight: 500;
}
.btn-text:hover { background: var(--accent-soft); }

.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-icon {
  width: 38px; padding: 0;
  background: none; color: var(--fg-2);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--fg); }
.btn-icon.btn-sm { width: 30px; }

/* 提交中的转圈。按钮进入 aria-busy 后 pointer-events 关掉，
 * 防止连点提交两次 —— 这在"新建数据源"这种接口上是会真的建出两条的。 */
.btn[aria-busy="true"] { pointer-events: none; }
.spinner {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* 手机上触控目标不能小于 40px */
@media (pointer: coarse) {
  .btn { height: 42px; }
  .btn-sm { height: 36px; }
  .btn-icon { width: 42px; }
}

/* ══ 徽标 ══════════════════════════════════════════════════════ */

/* 颜色不是唯一的状态标识 —— 每个徽标都带文字，色盲用户照样读得出来 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-ok    { background: var(--ok-soft);    color: var(--ok); }
.badge-warn  { background: var(--warn-soft);  color: var(--warn); }
.badge-err   { background: var(--err-soft);   color: var(--err); }
.badge-info  { background: var(--info-soft);  color: var(--info); }
.badge-muted { background: var(--muted-soft); color: var(--fg-2); }
.badge-plain::before { display: none; }

/* ══ 卡片 ══════════════════════════════════════════════════════ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--sp-4); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card-title { font-size: var(--fs-md); font-weight: 600; }
.card-desc { font-size: var(--fs-sm); color: var(--fg-2); margin-top: 2px; }
.card-body { padding: var(--sp-5); }
.card-foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--sp-2); flex-wrap: wrap;
}

/* 统计卡 */
.stat {
  position: relative;
  padding: var(--sp-5);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.stat-name { font-size: var(--fs-sm); color: var(--fg-2); }
.stat-value {
  font-size: var(--fs-3xl);
  font-weight: 600;
  line-height: 1.2;
  margin-top: var(--sp-2);
  font-variant-numeric: tabular-nums;
}
.stat-note { font-size: var(--fs-sm); color: var(--fg-3); margin-top: var(--sp-2); }
.stat-icon {
  position: absolute;
  top: var(--sp-4); right: var(--sp-4);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r);
  background: var(--muted-soft);
  color: var(--fg-2);
}
.stat.is-ok   .stat-icon { background: var(--ok-soft);   color: var(--ok); }
.stat.is-warn .stat-icon { background: var(--warn-soft); color: var(--warn); }
.stat.is-err  .stat-icon { background: var(--err-soft);  color: var(--err); }
.stat.is-err  .stat-value { color: var(--err); }

/* ══ 表单 ══════════════════════════════════════════════════════ */

.form-grid {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: var(--fs-sm); font-weight: 500; color: var(--fg); }
.field .req { color: var(--err); margin-left: 2px; }
.field-help { font-size: var(--fs-xs); color: var(--fg-3); }
/* 错误紧贴字段，不堆在页面顶部 —— 顶部错误列表要人自己找是哪个框 */
.field-err { font-size: var(--fs-xs); color: var(--err); }

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px var(--sp-3);
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  color: var(--fg);
  font-size: var(--fs-md);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-disabled); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--fg-disabled); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input:disabled, .select:disabled, .textarea:disabled {
  /* 禁用要看得出来，但仍然读得清 —— 灰到看不见的话，
   * 用户根本不知道那里本来有值 */
  background: var(--bg-subtle);
  color: var(--fg-2);
  cursor: not-allowed;
}
.field.has-err .input,
.field.has-err .select,
.field.has-err .textarea { border-color: var(--err); }

.textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.textarea.code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.select {
  appearance: none;
  padding-right: var(--sp-8);
  /* 下拉箭头用内联 SVG 画，不引图标文件 */
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  background-size: 16px;
}

/* 开关 */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 22px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--line-strong);
  transition: background var(--t-fast) var(--ease);
}
.switch-thumb {
  display: block;
  width: 18px; height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--t-fast) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-ring); }
.switch input:disabled + .switch-track { opacity: .5; }

/* 单选 / 多选组 */
.choice { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choice label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg-input);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.choice label:hover { border-color: var(--fg-disabled); }
.choice input:checked + span { color: var(--accent); font-weight: 500; }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* 键值对输入 */
.kv-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--sp-2); }
.kv-row + .kv-row { margin-top: var(--sp-2); }

/* 提交栏 */
.form-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-card);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  flex-wrap: wrap;
}

/* ══ 表格 ══════════════════════════════════════════════════════ */

/* 关键：滚动条在这个容器里，不在页面上。
 * 表格宽了只让表格自己横滚，整页永远不出现横向滚动条。 */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  /* ★ 必须有最小宽度。
   *
   * 只写 width:100% 的话，窄屏上表格会**压扁列**去迁就容器 ——
   * 号码 [6, 8, 2] 被折成三行、派生那列挤成一个字符，
   * 而 .table-scroll 的横向滚动条根本不会出现（因为表格"塞得下"）。
   * 给个下限，窄了就让它在自己的容器里横滚，这才是想要的行为。 */
  min-width: 680px;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
table.data th, table.data td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-subtle);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-2);
  white-space: nowrap;
}
table.data tbody tr { transition: background var(--t-fast) var(--ease); }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }
/* 号码、期号这类短字段折行只会更难读 */
table.data td .mono { white-space: nowrap; }

/* 操作列钉在右边，横滚时不跟着跑掉 */
table.data td.actions, table.data th.actions {
  position: sticky;
  right: 0;
  background: var(--bg-card);
  text-align: right;
  white-space: nowrap;
  box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .5);
}
table.data thead th.actions { background: var(--bg-subtle); }
table.data tbody tr:hover td.actions { background: var(--bg-hover); }

/* 可排序表头 */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--fg); }
th.sortable .sort-mark { opacity: .35; margin-left: 4px; }
th.sortable[aria-sort] .sort-mark { opacity: 1; color: var(--accent); }

/* 表格工具条 */
.table-tools {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.table-tools .grow { flex: 1 1 220px; }
/* 工具条里的下拉按内容宽，不撑满 ——
 * .select 默认 width:100%，放进 flex 行里会把搜索框和按钮挤到下一行 */
.table-tools .select,
.table-tools .input:not(.search .input) { width: auto; min-width: 140px; }
.table-tools .field { flex: 0 0 auto; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search .icon {
  position: absolute;
  left: var(--sp-3);
  color: var(--fg-3);
  pointer-events: none;
}
.search input { padding-left: var(--sp-8); padding-right: var(--sp-8); }
.search .clear {
  position: absolute; right: 6px;
  width: 26px; height: 26px;
}

/* 已启用的筛选条件显示成标签，一眼看得出现在筛了什么 */
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--bg-input);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}
.chip button {
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border: 0; border-radius: 50%;
  background: none; color: var(--fg-3); cursor: pointer;
}
.chip button:hover { background: var(--bg-hover); color: var(--fg); }

/* ══ 分页 ══════════════════════════════════════════════════════ */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pager-info { font-size: var(--fs-sm); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.pager-pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-pages button {
  min-width: 32px; height: 32px;
  padding: 0 var(--sp-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  color: var(--fg-2);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pager-pages button:hover:not(:disabled) { background: var(--bg-hover); color: var(--fg); }
.pager-pages button[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.pager-pages button:disabled { opacity: .35; cursor: not-allowed; }
.pager-pages .gap { color: var(--fg-disabled); padding: 0 2px; }
.pager .select { width: auto; min-height: 32px; height: 32px; padding: 0 var(--sp-6) 0 var(--sp-2); font-size: var(--fs-sm); }

/* ══ 空态 / 骨架 / 错误 ═══════════════════════════════════════ */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-10) var(--sp-5);
  text-align: center;
}
.empty .icon { width: 40px; height: 40px; color: var(--fg-disabled); stroke-width: 1.25; }
.empty-title { font-size: var(--fs-md); font-weight: 500; }
.empty-desc { font-size: var(--fs-sm); color: var(--fg-2); max-width: 46ch; }

.skeleton {
  background: var(--bg-hover);
  border-radius: var(--r-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-row { height: 14px; }
.skel-cell { padding: var(--sp-3) var(--sp-4); }

/* ══ 弹窗 ══════════════════════════════════════════════════════ */

.backdrop {
  position: fixed; inset: 0;
  z-index: var(--z-backdrop);
  display: grid;
  /* 同 .login-wrap：内容高过视口时不能让它向上溢出到够不着 */
  place-items: safe center;
  padding: var(--sp-4);
  background: rgba(0, 0, 0, .65);
  animation: fade-in var(--t-fast) var(--ease);
  overflow-y: auto;
}
.modal {
  position: relative;
  z-index: var(--z-modal);
  width: 100%;
  max-height: calc(100vh - var(--sp-8));
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: rise var(--t) var(--ease);
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 960px; }
.modal-head {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}
.modal-head .grow { min-width: 0; }
.modal-title { font-size: var(--fs-lg); font-weight: 600; }
.modal-desc { font-size: var(--fs-sm); color: var(--fg-2); margin-top: 4px; }
.modal-body {
  padding: 0 var(--sp-5) var(--sp-5);
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.modal-icon {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r);
}
.modal-icon.danger { background: var(--err-soft); color: var(--err); }
.modal-icon.warn { background: var(--warn-soft); color: var(--warn); }

/* ══ 抽屉 ══════════════════════════════════════════════════════ */

.drawer-wrap { align-items: stretch; justify-items: end; padding: 0; }
.drawer {
  width: min(440px, 100vw);
  height: 100%;
  max-height: none;
  border-radius: 0;
  border-right: 0;
  border-top: 0; border-bottom: 0;
  animation: slide-in-right var(--t) var(--ease);
}

/* ══ 通知 ══════════════════════════════════════════════════════ */

.toasts {
  position: fixed;
  top: var(--sp-4); right: var(--sp-4);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(380px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--fg-3);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: rise var(--t) var(--ease);
  pointer-events: auto;
}
.toast .icon { flex: none; margin-top: 1px; }
.toast-msg { flex: 1 1 auto; min-width: 0; font-size: var(--fs-md); word-break: break-word; }
.toast-sub { font-size: var(--fs-sm); color: var(--fg-2); margin-top: 2px; }
.toast.ok   { border-left-color: var(--ok); }   .toast.ok .icon   { color: var(--ok); }
.toast.warn { border-left-color: var(--warn); } .toast.warn .icon { color: var(--warn); }
.toast.err  { border-left-color: var(--err); }  .toast.err .icon  { color: var(--err); }
.toast.info { border-left-color: var(--info); } .toast.info .icon { color: var(--info); }

/* ══ 下拉菜单 ══════════════════════════════════════════════════ */

.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--z-sticky);
  min-width: 176px;
  padding: var(--sp-1);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: rise var(--t-fast) var(--ease);
}
.menu button {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%;
  padding: 7px var(--sp-3);
  border: 0; border-radius: var(--r-sm);
  background: none;
  color: var(--fg-2);
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: var(--bg-hover); color: var(--fg); }
.menu button.danger { color: var(--err); }
.menu button.danger:hover { background: var(--err-soft); }
.menu hr { margin: var(--sp-1) 0; }

/* ══ 登录页 ══════════════════════════════════════════════════════ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  /* ★ 用 safe center 而不是 center。
   *
   * 内容比视口高时，普通的居中会让它**同时向上下两边溢出**，
   * 而上面溢出的那半是滚不到的 —— 表现为"登录按钮看不见也够不着"。
   * 短屏幕、或者错误提示把卡片撑高之后就会踩到。
   * safe 在放不下时退化成起始对齐，配合下面的 overflow-y 就能滚。 */
  place-items: safe center;
  padding: var(--sp-4);
  background: var(--bg);
  overflow-y: auto;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--sp-8);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-3); margin-bottom: var(--sp-6); text-align: center;
}
.login-brand .brand-mark { width: 44px; height: 44px; }

/* ══ 其它 ══════════════════════════════════════════════════════ */

.kbd {
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-2);
}

pre.out {
  margin: 0;
  padding: var(--sp-3);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--fs-sm);
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

.divider-label {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-xs); color: var(--fg-3);
  text-transform: uppercase; letter-spacing: .06em;
  margin: var(--sp-5) 0 var(--sp-3);
}
.divider-label::after { content: ""; flex: 1 1 auto; border-top: 1px solid var(--line); }

/* 「试一下」打回来的原始响应。
 *
 * 必须限高且可滚：draws?limit=100 的响应有好几百行，不限高的话整页被它
 * 撑开，下面的字段说明全被推到屏幕外面去了。 */
.code-out {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-subtle);
  font-size: var(--fs-xs);
  line-height: 1.55;
  white-space: pre;
  tab-size: 2;
}

/* 标签页：同一个对象的两种视角（标准接口 / 旧接口兼容）。
 *
 * 用下划线而不是按钮组：这两个模式不是"操作"，是"看哪一份"，
 * 下划线式的标签更符合这个语义，也不会和页面上真正的按钮抢注意力。 */
.tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-5);
  overflow-x: auto;
}
.tab {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--fg-2);
  text-align: left;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  /* 负 margin 让下边框压在 .tabs 的边框上，而不是叠出两条线 */
  margin-bottom: -1px;
}
.tab:hover { color: var(--fg); }
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-label { font-size: var(--fs-md); font-weight: 500; white-space: nowrap; }
.tab-sub { font-size: var(--fs-xs); color: var(--fg-3); white-space: nowrap; }
.tab.is-active .tab-sub { color: var(--accent); opacity: .75; }

/* 独占一行的代码块（旧地址这种，长到放不进句子里） */
code.block {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-subtle);
  font-size: var(--fs-xs);
  overflow-x: auto;
  white-space: nowrap;
}

/* 浮层菜单：脱离任何裁剪容器。
 *
 * ★ 为什么必须是 fixed
 *
 * 原来是 position:absolute + 父级 .menu-wrap 定位。但行操作的菜单在
 * .table-scroll 里面，而那个容器有 overflow-x:auto —— 只要 overflow 不是
 * visible 就会形成裁剪上下文，**纵向也一起裁**。表现是：点最后一行还能勉强
 * 看见半截菜单，点上面的行完全看不见。
 *
 * fixed 相对视口定位，不受祖先的 overflow 影响。代价是坐标要在打开时用 JS
 * 现算（见 table.js 的 placeMenu），并且页面一滚就得关掉 —— 否则菜单会
 * 停在原地和按钮脱节。 */
.menu.is-floating {
  position: fixed;
  top: 0;
  left: 0;
  /* ★ 必须显式取消 right。
   *
   * 基础 .menu 规则里有 right:0（absolute 时用来右对齐父级）。fixed 之后
   * left:0 与 right:0 同时生效，元素就横向撑满视口 —— 实测被拉成 1411px 宽。
   * 症状不是"看不见"而是"糊了一整条"，比原来的裁剪更难一眼看出原因。 */
  right: auto;
  /* 要盖过 sticky 的表头与操作列 */
  z-index: var(--z-modal, 1000);
}
