/* ============================================================================
   EdgeKit 仓库后台 · 样式表
   ----------------------------------------------------------------------------
   断点：≤1080 平板横屏 | ≤900 平板 | ≤680 手机 | ≤420 窄屏
   原则：能用流式解决的（clamp / auto-fit / flex-wrap）就不写断点；
        断点只用来收敛「必须换形态」的地方（顶栏、表格、弹窗）。
   坑位备忘：
     · 别在 html/body 上用 overflow-x:hidden —— 会让 .top 的 sticky 失效。
       要用就用 overflow-x:clip（不创建滚动容器，sticky 照常）。
     · 吸顶/吸左单元格必须有不透明底色，否则会透出滚动内容。
   ============================================================================ */

:root {
  color-scheme: dark;                /* 表单控件、下拉、滚动条跟随深色主题 */

  --bg: #0e1318;
  --panel: #171d24;
  --panel-hi: #1c242c;               /* 吸顶表头 / 吸左列的底色（必须不透明） */
  --line: #2a3440;
  --text: #e8edf2;
  --muted: #8b98a5;
  --accent: #3dd68c;
  --accent-ink: #062315;
  --danger: #ef6b6b;
  --warn: #e3b341;
  --gap: #3a1d22;
  --input: #0d1116;

  --r: 12px;
  --r-sm: 8px;
  --pad: clamp(14px, 2.4vw, 28px);
  --max: min(1440px, 100%);

  /* 刘海/圆角屏安全区 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; min-width: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
body { overflow-x: clip; }           /* clip 而非 hidden：不破坏 sticky */
img, svg, video { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .ver, .app-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

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

/* 深色细滚动条（表格横向滑动时不刺眼） */
* { scrollbar-width: thin; scrollbar-color: #33404d transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #33404d; border-radius: 99px;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #465564; background-clip: padding-box; }

/* ---------------------------------------------------------------- 顶栏 --- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 16px;
  padding: calc(9px + var(--safe-t)) calc(var(--pad) + var(--safe-r)) 9px calc(var(--pad) + var(--safe-l));
  border-bottom: 1px solid var(--line);
  background: rgba(23, 29, 36, .92);
  backdrop-filter: saturate(140%) blur(10px);
}
@supports not (backdrop-filter: blur(4px)) { .top { background: var(--panel); } }

.brand { font-weight: 700; color: var(--text); letter-spacing: .02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }

.top nav { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.top nav a {
  color: var(--muted); padding: 8px 12px; border-radius: var(--r-sm);
  white-space: nowrap; line-height: 1.25;
}
.top nav a:hover { color: var(--text); background: #12181f; text-decoration: none; }
.top nav a[aria-current="page"] {
  color: var(--accent); background: rgba(61, 214, 140, .10);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.who {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; min-width: 0;
}
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24vw; }
.role {
  border: 1px solid var(--line); padding: 3px 9px; border-radius: 99px;
  color: var(--muted); flex-shrink: 0; line-height: 1.4;
}
a.role:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.inline { display: inline; margin: 0; }
.who button { background: transparent; color: var(--muted); padding: 6px 8px; min-height: 0; }
.who button:hover { color: var(--danger); filter: none; }

/* --------------------------------------------------------------- 按钮 --- */
button, .ok-btn, .danger {
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: var(--r-sm); padding: 9px 14px; font: inherit; font-weight: 650;
  line-height: 1.25; cursor: pointer; min-height: 38px;
}
.danger { background: var(--danger); color: #fff; }
button:hover:not(:disabled), .ok-btn:hover { filter: brightness(1.07); }
button[disabled] { opacity: .45; cursor: not-allowed; }
button.ghost, .ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.ghost:hover { color: var(--text); border-color: #3b4855; filter: none; }

/* --------------------------------------------------------------- 布局 --- */
.wrap {
  width: var(--max);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px) calc(var(--pad) + var(--safe-r))
           calc(56px + var(--safe-b)) calc(var(--pad) + var(--safe-l));
  min-width: 0;
}
h1 { margin: 0 0 8px; font-size: clamp(21px, 2.5vw, 28px); line-height: 1.25; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 24px 0 10px; font-weight: 650; }
.muted { color: var(--muted); }
p.muted { margin: 0 0 16px; max-width: 78ch; }
.page-head { margin-bottom: 8px; }
.section-head {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px; margin: 24px 0 12px;
}
.section-head h2 { margin: 0; }
section + section { margin-top: 8px; }

.stat { color: var(--muted); margin: 0 0 16px; }
.stat strong { color: var(--text); font-variant-numeric: tabular-nums; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
}
.kpi .n {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  line-height: 1.15;
}
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 6px; letter-spacing: .04em; }

.dash-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px 28px;
}
.bars { display: grid; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 11rem) 1fr auto;
  gap: 10px;
  align-items: center;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.bar-track {
  height: 8px; background: #12181f; border-radius: 99px; overflow: hidden;
}
.bar-fill {
  display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: 99px;
}
.bar-n { font-variant-numeric: tabular-nums; font-size: 13px; }

.day-bars {
  display: flex; align-items: stretch; gap: 6px;
  height: 120px; margin: 8px 0 4px;
}
.day-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px;
}
.day-fill {
  display: block; width: 100%; min-height: 3px;
  background: var(--accent); border-radius: 4px 4px 0 0; opacity: .88;
}
.day-col small { color: var(--muted); font-size: 10px; white-space: nowrap; }

.geo-map {
  height: min(52vh, 460px);
  min-height: 280px;
  margin: 8px 0 4px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: #0e1318;
}
.geo-map svg { display: block; width: 100%; height: 100%; }

.filter-row {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
  margin: 8px 0 16px;
}
.filter-row label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.filter-row input { min-width: 10rem; }

/* --------------------------------------------------------------- 提示 --- */
.flash { display: grid; gap: 8px; margin-bottom: 16px; }
.flash:empty { display: none; }
.flash .ok, p.ok {
  background: #163524; color: var(--accent); padding: 10px 12px;
  border-radius: var(--r-sm); margin: 0;
}
.flash .err, p.err {
  background: #3a1d22; color: var(--danger); padding: 10px 12px;
  border-radius: var(--r-sm); margin: 0;
}
.flash ul.warn, .flash .warn { color: var(--warn); margin: 0; padding-left: 18px; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------- 表格 --- */
/* 横向滑动只发生在表格自己的盒子里，永远不把整页撑宽 */
.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin: 12px 0 8px;
  max-width: 100%;
  background: var(--panel);
}
table {
  width: 100%; min-width: 560px;
  border-collapse: separate;   /* collapse 会让吸顶/吸左单元格的边框错位 */
  border-spacing: 0;
  background: var(--panel);
}
/* 列宽不再靠一个魔法 min-width：让单元格自己撑开，列数多了自然产生滑动 */
.chips-table table, .profile-grid + section .table-scroll table { min-width: 0; }

th, td {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: middle;
}
th {
  color: var(--muted); font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #1a2129; }

/* 吸顶表头 + 吸左首列：横向滑动时永远知道自己在看哪一行 */
thead th { position: sticky; top: 0; z-index: 1; background: var(--panel-hi); }
th:first-child, td:first-child {
  position: sticky; left: 0; z-index: 2;
  background: var(--panel-hi);
  box-shadow: 1px 0 0 var(--line);
}
thead th:first-child { z-index: 3; }
tbody tr:hover td:first-child { background: var(--panel-hi); }

.col-id { width: 1%; white-space: nowrap; color: var(--muted); }
.col-chip, .col-ver, .col-st { white-space: nowrap; }
.col-ops, td.ops { width: 1%; white-space: nowrap; text-align: right; }
.app-id { word-break: break-word; }
.matrix td.gap { background: var(--gap); color: var(--danger); }
.gap-mark { font-size: 12px; font-weight: 600; }
.cell-pkg { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
button.cell-del {
  padding: 2px 8px; min-height: 0; font-size: 12px; background: transparent;
  color: var(--danger); border: 1px solid var(--danger);
}
.ver { font-size: 13px; }
.st { font-size: 11px; color: var(--muted); }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.st-published { background: #14301f; color: var(--accent); border-color: transparent; }
.st-approved  { background: #1d2e3a; color: #8ec8ea; border-color: transparent; }
.st-review    { background: #2a2414; color: var(--warn);   border-color: transparent; }
.st-rejected  { background: var(--gap); color: var(--danger); border-color: transparent; }
.warn-tag { color: var(--warn); font-size: 12px; white-space: nowrap; }

.empty {
  color: var(--muted); padding: 28px 20px; border: 1px dashed var(--line);
  border-radius: var(--r); text-align: center;
}
/* 由 layout.js 在检测到表格溢出时插入 */
.scroll-hint { margin: 10px 2px -4px; font-size: 12px; color: var(--muted); text-align: right; }

/* ------------------------------------------------------- 矩阵卡片 --- */
.app-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; margin: 14px 0; display: grid; gap: 12px; min-width: 0;
}
.app-card-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 8px 14px;
}
.app-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-width: 0; }
.app-title .app-id { font-size: 16px; font-weight: 700; }
.app-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge-gap   { background: var(--gap);  color: var(--danger); border-color: transparent; }
.badge-full  { background: #14301f;     color: var(--accent); border-color: transparent; }
.badge-drift { background: #2a2414;     color: var(--warn);   border-color: transparent; }

/* 芯片瓷砖：auto-fill 自动换行，芯片再多也不横向滚动 */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 8px;
}
.chip-cell {
  display: grid; gap: 2px; align-content: start; min-width: 0;
  background: var(--input); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 9px 11px;
}
.chip-name {
  font-size: 11px; color: var(--muted); letter-spacing: .04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-cell .ver { font-size: 14px; font-weight: 650; }
.chip-cell.gap { background: var(--gap); border-color: rgba(239, 107, 107, .35); }
.chip-cell.gap .chip-name { color: #d99a9a; }
.chip-cell.gap .gap-mark { color: var(--danger); font-size: 13px; font-weight: 600; }
.chip-cell.st-published .ver { color: var(--accent); }
.chip-cell.st-approved  .ver { color: #8ec8ea; }
.chip-cell.st-review    .ver { color: var(--warn); }

/* 一键补齐：每条一个可复制的文件名胶囊 */
.hint-list {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 8px;
}
.hint-list li {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  background: var(--input); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 8px 7px 12px;
}
.hint-list code {
  flex: 1 1 auto; min-width: 0; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copy-btn { flex: 0 0 auto; padding: 4px 10px; min-height: 0; font-size: 12px; }
.copy-btn.copied, button.copied { color: var(--accent); border-color: var(--accent); filter: none; }

/* --------------------------------------------------------- 卡片 / 键值 --- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; display: grid; gap: 12px;
  width: 100%; max-width: min(560px, 100%); margin: 16px 0;
}
.kv { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 8px 16px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.kv.card { max-width: min(760px, 100%); }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px; align-items: start;
}
.profile-grid .card { max-width: none; margin: 0; }
.profile-grid h2 { margin: 0 0 4px; }

/* --------------------------------------------------------------- 上传 --- */
.upload-card { max-width: min(720px, 100%); }
.file-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); padding: 0; border: 0;
}
.dropzone {
  display: grid; gap: 6px; place-items: center; text-align: center;
  min-height: clamp(140px, 22vw, 188px); padding: 24px 16px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--r); background: var(--input);
  color: var(--muted); transition: border-color .15s, background .15s;
}
.dropzone strong { color: var(--text); font-size: 16px; }
.dropzone em { font-style: normal; color: var(--accent); font-size: 13px; word-break: break-all; }
.dropzone.over { border-color: var(--accent); background: #14301f; color: var(--accent); }
.upload-card.busy .dropzone { opacity: .55; pointer-events: none; }
.upload-card button[type=submit] { width: 100%; padding: 12px 14px; }

/* --------------------------------------------------------------- 弹窗 --- */
.dlg {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); overflow: auto;
  border: 1px solid var(--line); border-radius: 14px; padding: 0;
  background: var(--panel); color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}
.dlg::backdrop { background: rgba(8, 12, 16, .66); }
.dlg form { display: grid; gap: 12px; padding: 22px 22px 18px; }
.dlg h2 { margin: 0; font-size: 18px; }
.dlg .muted { margin: 0; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.dlg select { width: 100%; padding: 10px 12px; }

/* --------------------------------------------------------- 工具条 / 表单 --- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; margin: 16px 0; width: 100%;
}
.toolbar label { flex: 1 1 220px; min-width: 0; margin: 0; }
.toolbar button { height: 40px; flex: 0 0 auto; }
/* 只含一个按钮的工具条（邀请码）不该占满整行 */
.toolbar:has(> button:only-child) { display: inline-flex; width: auto; padding: 10px 12px; }

label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.check input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }

input[type=text], input[type=email], input[type=password], input[type=file], select {
  width: 100%; max-width: 100%; background: var(--input); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; font: inherit;
}
input::placeholder { color: #5d6b78; }
input:focus, select:focus {
  outline: 2px solid rgba(61, 214, 140, .35);
  border-color: var(--accent); outline-offset: 0;
}
.rules { color: var(--muted); padding-left: 18px; margin: 8px 0 0; max-width: 72ch; }
.rules code { font-size: 13px; }

/* 表格里的操作按钮组。
   ⚠️ <td class="ops"> 必须保持 table-cell：若把 td 本身变成 flex 容器，
   表格算不出这一列的 min-content，列宽被压到 1%，按钮左溢盖住相邻列。 */
.ops { display: inline-flex; flex-wrap: nowrap; gap: 8px; align-items: center; justify-content: flex-end; }
.ops form { display: inline-flex; flex-wrap: nowrap; gap: 6px; align-items: center; margin: 0; }
.ops button { padding: 7px 12px; font-size: 13px; white-space: nowrap; min-height: 34px; }
.ops select { width: auto; min-width: 7.5rem; padding: 8px 10px; }
td.ops { display: table-cell; text-align: right; white-space: nowrap; }
td.ops > form, td.ops > button { display: inline-flex; vertical-align: middle; margin: 0 0 0 8px; }
td.ops > :first-child { margin-left: 0; }

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}
pre {
  background: var(--input); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px; overflow: auto; overscroll-behavior-x: contain;
  min-height: 160px; max-height: 50vh; font-size: 12px; line-height: 1.5;
  margin: 0; tab-size: 2;
}
.links { margin: 4px 0 0; text-align: center; }
.links a { margin: 0 2px; }
.hints { margin-top: 24px; }
.hints code { font-size: 13px; word-break: break-all; }
.hints ul { padding-left: 18px; }

/* --------------------------------------------------------------- 登录 --- */
.login-body {
  min-height: 100vh;
  min-height: 100dvh;                 /* 移动端地址栏收起时不再被切掉 */
  display: grid; place-items: center;
  padding: calc(16px + var(--safe-t)) calc(var(--pad) + var(--safe-r))
           calc(16px + var(--safe-b)) calc(var(--pad) + var(--safe-l));
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(61, 214, 140, .08), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: clamp(20px, 4vw, 32px) clamp(16px, 4vw, 28px) 24px;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}
.login-card h1 { margin: 0; font-size: clamp(21px, 5vw, 24px); }
.login-card > .muted { margin: 6px 0 22px; }
.login-card form { display: grid; gap: 14px; width: 100%; }
.login-card .flash { margin: 0 0 14px; }
.login-card > .err, .login-card > .ok { margin: 0 0 14px; }
.login-card button[type=submit] { width: 100%; padding: 12px 14px; margin-top: 2px; }
.login-card .links { margin-top: 18px; }

/* --------------------------------------------------------------- 滑块 --- */
.slider { user-select: none; width: 100%; touch-action: pan-y; }
.slider-track {
  position: relative; height: 44px; border-radius: 22px;
  background: var(--input); border: 1px solid var(--line); overflow: hidden;
}
.slider-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 44px;
  background: rgba(61, 214, 140, .22);
}
.slider-tip {
  position: absolute; inset: 0 12px 0 48px;
  display: grid; place-items: center;
  color: var(--muted); font-size: 13px; pointer-events: none;
}
button.slider-knob {
  position: absolute; left: 4px; top: 4px;
  width: 36px; height: 36px; min-width: 36px; min-height: 36px; padding: 0;
  border-radius: 18px; background: var(--accent); cursor: grab; z-index: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); touch-action: none;
}
button.slider-knob:active { cursor: grabbing; filter: none; }
.slider.ok .slider-track { border-color: var(--accent); }
.slider.ok .slider-tip { color: var(--accent); }
#slider-err { margin: 0; }

/* ==========================================================================
   自适应 · 收敛点
   ========================================================================== */

/* --- ≤1080：平板横屏 / 小笔记本 --- */
@media (max-width: 1080px) {
  .top nav a { padding: 8px 10px; }
  .who-name { max-width: 18vw; }
}

/* --- ≤900：顶栏拆两行；导航变单行横滑条（不再折成三行） --- */
@media (max-width: 900px) {
  .top { grid-template-columns: minmax(0, 1fr) auto; row-gap: 8px; }
  /* 显式摆位：品牌 + 账号占第一行，导航单独占第二行。
     不写的话自动放置会把账号块挤到导航下面，顶栏变三行。 */
  .top .brand { grid-column: 1; grid-row: 1; }
  .top .who { grid-column: 2; grid-row: 1; justify-self: end; }
  .top nav {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    margin: 0 calc(-1 * var(--pad));
    padding: 2px var(--pad);
  }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { scroll-snap-align: center; padding: 9px 13px; }
  .who-name { max-width: 30vw; }
}

/* --- ≤680：手机。按钮撑满、弹窗变底部抽屉 --- */
@media (max-width: 680px) {
  table { min-width: 480px; }
  th, td { padding: 9px 10px; }
  th { font-size: 10px; letter-spacing: .04em; }

  /* 操作列在手机上改成可换行的按钮组，贴着左边更好点 */
  .ops, td.ops, .col-ops { justify-content: flex-start; text-align: left; white-space: normal; }
  .ops { flex-wrap: wrap; }
  .ops form { flex-wrap: wrap; }

  .app-card { padding: 13px 13px; }
  .chip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-title .app-id { font-size: 15px; }

  .toolbar { padding: 12px; }
  .toolbar label { flex: 1 1 100%; }
  .toolbar button { flex: 1 1 auto; width: 100%; }
  .toolbar:has(> button:only-child) button { width: auto; }

  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 6px; }
  .kv dt:first-of-type { margin-top: 0; }

  .section-head { align-items: stretch; }
  .section-head button { width: 100%; }

  .dlg {
    width: 100%; max-width: none;
    margin: auto auto 0;                    /* 底部抽屉 */
    max-height: 90dvh;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
  }
  .dlg form { padding: 20px 18px calc(18px + var(--safe-b)); }
  .dlg-actions { justify-content: stretch; }
  .dlg-actions button { flex: 1 1 0; }

  pre { font-size: 11.5px; min-height: 140px; max-height: 42vh; }
  .scroll-hint { text-align: left; }
}

/* --- ≤420：窄屏。账号名让位给角色标签 --- */
@media (max-width: 420px) {
  .top { gap: 6px 8px; }
  .brand { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .who-name { display: none; }
  .rules { padding-left: 16px; }
}

/* --- 触屏设备：把点击目标提到 ≥44px --- */
@media (pointer: coarse) {
  .top nav a { padding: 10px 14px; }
  button, .ok-btn, .danger { min-height: 44px; }
  .ops button { min-height: 40px; }
  .who button { min-height: 40px; }
  .dlg select, input[type=text], input[type=email], input[type=password], select { min-height: 44px; }
}

/* --- 横屏矮屏 --- */
@media (max-height: 520px) and (orientation: landscape) {
  .dlg { max-height: 94dvh; }
  pre { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
