/* cloud2api admin portal — design system (no external assets) */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f7f7f6;
  --surface-3: #f0f0ee;
  --border: #e6e6e3;
  --border-strong: #d6d6d1;
  --text: #292925;
  --text-2: #686863;
  --text-3: #85857e;
  --accent: #30302c;
  --accent-hover: #151513;
  --accent-soft: #ededea;
  --accent-soft-2: #e3e3de;
  --ok: #078762;
  --ok-soft: #e7f7ef;
  --warn: #b45309;
  --warn-soft: #fdf0df;
  --danger: #d02f2f;
  --danger-hover: #b32424;
  --danger-soft: #fdeaea;
  --info: #0f6ba1;
  --info-soft: #e3f1fa;
  --violet: #7341c9;
  --violet-soft: #f0e9fc;
  --slate-soft: #eceff4;
  --sidebar-bg: #ffffff;
  --sidebar-bg-2: #f3f3f0;
  --sidebar-text: #696962;
  --sidebar-text-active: #292925;
  --sidebar-border: #e9e9e5;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(22, 32, 46, .05), 0 1px 3px rgba(22, 32, 46, .06);
  --shadow-2: 0 4px 12px rgba(22, 32, 46, .08), 0 2px 4px rgba(22, 32, 46, .05);
  --shadow-3: 0 16px 48px rgba(16, 23, 37, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --sidebar-w: 240px;
  --topbar-h: 86px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
::placeholder { color: var(--text-3); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.frame { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { flex: 1; padding: 20px 40px 56px; max-width: 1600px; width: 100%; margin: 0 auto; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #d8ef73, #27bb9a);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex: 0 0 auto;
}
.brand-name { color: var(--text); font-size: 18px; font-weight: 650; letter-spacing: .01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); margin-top: -2px; }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px 16px; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 2px; }
.nav-group-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 8px; color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none;
  border: 0; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--sidebar-bg-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface-3); color: var(--sidebar-text-active); box-shadow: inset 0 0 0 1px var(--border); }
.nav-item svg { flex: 0 0 auto; opacity: .85; }
.nav-badge {
  margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: 10px; background: #e5484d; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 19px; text-align: center;
}
.nav-badge:empty { display: none; }
.sidebar-foot { border-top: 1px solid var(--sidebar-border); padding: 12px; }
.session-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--sidebar-bg-2); border-radius: 8px; padding: 9px 10px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #33415c, #475569);
  color: #cbd5e1; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex: 0 0 auto;
}
.session-name { color: var(--text); font-size: 12.5px; font-weight: 550; line-height: 1.2; }
.session-hint { font-size: 11px; color: var(--text-3); }
.sb-overlay {
  position: fixed; inset: 0; background: rgba(10, 14, 22, .5); z-index: 39;
}

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-title h1 { font-size: 16px; font-weight: 650; white-space: nowrap; }
.topbar-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mock-pill {
  font-size: 11.5px; font-weight: 600; color: var(--violet);
  background: var(--violet-soft); border: 1px solid #ddd0f5;
  padding: 3px 10px; border-radius: 999px;
}
.nav-toggle { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 13px; font-weight: 550;
  border-radius: 8px; border: 1px solid transparent;
  padding: 7px 14px; cursor: pointer; user-select: none;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap; line-height: 1.3;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent, #fff); box-shadow: var(--shadow-1); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: #fbdcdc; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { padding: 2px 8px; font-size: 12px; border-radius: 6px; gap: 4px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linklike:hover { text-decoration: underline; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14.5px; font-weight: 650; }
.card-desc { font-size: 12.5px; color: var(--text-3); }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head-text h2 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.page-head-text .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); padding: 16px 18px;
  display: block; color: inherit;
}
a.stat-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.stat-top { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 550; }
.stat-top .icon-chip { margin-left: auto; }
.stat-num { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.15; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat-num.alert { color: var(--warn); }

/* ---------- badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-slate { background: var(--slate-soft); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-xs { font-size: 10.5px; padding: 2px 7px; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-3); color: var(--text-2);
  border-radius: 6px; padding: 2px 7px;
  font-size: 11.5px; font-weight: 550; font-family: var(--mono);
  white-space: nowrap;
}
.chip.perm-p { background: var(--accent-soft); color: var(--accent); font-family: inherit; }
.chip.perm-g { background: var(--violet-soft); color: var(--violet); font-family: inherit; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.customized-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--warn); font-weight: 550; white-space: nowrap; }
.customized-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ec9326; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .cell-main { font-weight: 600; }
.tbl .cell-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
/* drive state explanation line under the state badge (W4) */
.state-desc { max-width: 230px; margin-top: 4px; line-height: 1.45; }
.tbl .cell-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tr-static { opacity: .82; }
tr.row-child td:first-child { position: relative; }
tr.row-child td:first-child::before {
  content: ""; position: absolute; left: 16px; top: 0; bottom: 0;
  border-left: 2px solid var(--accent-soft-2);
}
tr.row-muted td { color: var(--text-3); }
tr.row-muted .cell-main { color: var(--text-2); }
.path-cell { font-family: var(--mono); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* keys table: condensed columns fit ≥1280px; secondary fields live in the
   expander row; the actions column stays pinned if it ever scrolls */
.keys-tbl th, .keys-tbl td { padding-left: 10px; padding-right: 10px; }
.keys-tbl .cell-main { white-space: nowrap; }
.keys-tbl th:last-child, .keys-tbl td:last-child {
  position: sticky; right: 0; z-index: 2;
  background: var(--surface);
  box-shadow: -10px 0 10px -10px rgba(22, 32, 46, .18);
}
.keys-tbl tbody tr:hover td:last-child { background: var(--surface-2); }
.key-id-cell { display: flex; align-items: flex-start; gap: 7px; min-width: 0; }
.key-id-cell .grow { min-width: 0; }
.caret-btn {
  flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; border-radius: 5px; color: var(--text-3); cursor: pointer; padding: 0;
}
.caret-btn:hover { background: var(--surface-3); color: var(--text); }
.caret-btn .caret {
  width: 0; height: 0; border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .14s;
}
tr.row-open .caret-btn .caret { transform: rotate(90deg); }
/* sub-lines inside a key cell: wrap between items (reflow) instead of
 * clipping; a single over-long token (the key prefix) still ellipsizes */
.key-sub { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; row-gap: 1px; overflow: hidden; max-width: 262px; }
.key-sub > * { white-space: nowrap; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.key-sub .sub-sep { color: var(--border-strong); flex: 0 0 auto; overflow: visible; }
.key-sub { font-size: 11.5px; }
/* child-key marker line ("由 agent 签发" badge, TTL): wraps instead of
 * clipping — nothing on this line may be truncated (W4 fix) */
.key-sub-extra { max-width: none; margin-top: 3px; flex-wrap: wrap; overflow: visible; row-gap: 2px; }
.key-sub-extra > * { flex: 0 0 auto; overflow: visible; text-overflow: clip; }
.grants-cell { flex-direction: row; flex-wrap: wrap; gap: 4px; }
.grant-chip { gap: 5px; max-width: 175px; }
.grant-chip .grant-drive { font-weight: 600; color: var(--text); }
.grant-chip .grant-perms-mono { color: var(--accent); font-weight: 700; letter-spacing: .04em; }
.grant-chip .grant-root { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
/* expander details row */
tr.row-details { display: none; }
tr.row-details.open { display: table-row; }
tr.row-details:hover { background: var(--surface) !important; }
tr.row-details > td {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 16px 37px;
}
.details-inner { max-width: 860px; }
.kv-mini {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px 22px; margin: 0; font-size: 12.5px;
}
.kv-mini .kv-item { display: flex; gap: 10px; min-width: 0; margin: 0; }
.kv-mini dt, .kv-item > dt, .kv-item > .kv-mini-k { flex: 0 0 84px; color: var(--text-3); margin: 0; }
.kv-mini dd, .kv-item > dd, .kv-item > .kv-mini-v { margin: 0; min-width: 0; word-break: break-all; }
.kv-mini-rows { display: flex; flex-direction: column; gap: 4px; }
.kv-mini-row { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.kv-mini-row .kv-mini-k { flex: 0 0 110px; font-weight: 600; }
.kv-mini-row .kv-mini-v { color: var(--text-2); }
.grant-perm-names { color: var(--text-2); }
.text-warn { color: var(--warn); font-weight: 550; }
.empty-soon { padding: 34px 20px; }
.empty-soon .empty-title { color: var(--text-2); }
.status-code { font-family: var(--mono); font-weight: 600; font-size: 12.5px; }
.status-2xx { color: var(--ok); }
.status-4xx { color: var(--warn); }
.status-5xx { color: var(--danger); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-help { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.45; }
.field-error { font-size: 12.5px; color: var(--danger); margin-top: 5px; min-height: 0; }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 7px 10px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(81, 85, 205, .14);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2355617a' stroke-width='2.5' 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 10px center; padding-right: 30px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.check-block { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.check-block input { accent-color: var(--accent); width: 15px; height: 15px; margin-top: 2px; cursor: pointer; }
.check-block .cb-title { font-size: 13px; font-weight: 600; color: var(--text); }
.check-block .cb-sub { font-size: 12px; color: var(--text-3); }
.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong);
  transition: background .15s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(14px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* checkbox group */
.checkgrid { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.checkgrid .check { font-size: 12.5px; }

/* filter bar */
.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filterbar .field { margin: 0; }
.filterbar .field-label { font-size: 12px; color: var(--text-2); }
.filterbar .input, .filterbar .select { width: 160px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  appearance: none; background: none; border: 0; font-family: inherit;
  font-size: 13.5px; font-weight: 550; color: var(--text-2);
  padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { background: var(--surface-3); color: var(--text-2); border-radius: 999px; font-size: 11.5px; padding: 1px 7px; font-weight: 600; }
.tab .count:empty { display: none; }
.tab.active .count { background: var(--accent-soft); color: var(--accent); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 20, 32, .46);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 24px; overflow-y: auto;
  animation: fadeIn .14s ease;
}
.modal {
  background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow-3);
  width: 520px; max-width: 100%;
  animation: popIn .16s ease;
  display: flex; flex-direction: column;
  max-height: 88vh;
}
.modal-w-md { width: 640px; }
.modal-w-lg { width: 780px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.modal-title { font-size: 15.5px; font-weight: 650; }
.modal-close { margin-left: auto; }
.modal-body { padding: 14px 20px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.modal-foot .spacer { margin-right: auto; display: flex; align-items: center; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }

/* ---------- toasts ---------- */
.toast-root { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; width: 340px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: 10px; padding: 11px 12px;
  box-shadow: var(--shadow-2);
  font-size: 13px; color: var(--text);
  animation: toastIn .18s ease;
}
.toast .toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
.toast .icon-btn { width: 22px; height: 22px; flex: 0 0 auto; }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } }
.toast.leaving { transition: opacity .18s, transform .18s; opacity: 0; transform: translateX(14px); }

/* ---------- empty / loading / error states ---------- */
.empty {
  text-align: center; padding: 44px 20px; color: var(--text-3);
}
.empty svg { opacity: .55; margin-bottom: 10px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 3px; }
.empty-sub { font-size: 12.5px; }
.empty .btn { margin-top: 14px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 6px; min-height: 14px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 46px 0; color: var(--text-3); font-size: 13px; }

/* ---------- callouts & banners ---------- */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-sm); padding: 11px 13px;
  font-size: 13px; line-height: 1.55;
}
.callout svg { flex: 0 0 auto; margin-top: 1px; }
.callout-info { background: var(--info-soft); color: var(--info); }
.callout-warn { background: var(--warn-soft); color: var(--warn); }
.callout-danger { background: var(--danger-soft); color: var(--danger); }
.callout-neutral { background: var(--surface-3); color: var(--text-2); }
.callout .co-text { flex: 1; min-width: 0; }
.callout a { color: inherit; font-weight: 600; text-decoration: underline; }

.warning-list { display: flex; flex-direction: column; gap: 8px; }
.warning-item {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; background: var(--surface-2);
  font-size: 13px;
}
.warning-item .wi-text { flex: 1; min-width: 0; }
.warning-item .wi-act { flex: 0 0 auto; }
.warning-lv-error { border-left: 3px solid var(--danger); }
.warning-lv-warning { border-left: 3px solid #ec9326; }
.warning-lv-info { border-left: 3px solid var(--info); }

/* ---------- code / snippet blocks ---------- */
.codebox {
  position: relative;
  background: #0f1722; color: #dbe3ef;
  border-radius: 9px; padding: 12px 14px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  margin: 0;
}
.codebox .copy-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,.1); color: #cdd7e4;
  border: 1px solid rgba(255,255,255,.14); border-radius: 6px;
  font-size: 11.5px; padding: 3px 9px; cursor: pointer; font-family: inherit;
}
.codebox .copy-btn:hover { background: rgba(255,255,255,.2); }
.codebox.key-plain { color: #ffd28a; background: #241a0d; font-size: 13.5px; }
.key-secret-row { display: flex; gap: 8px; align-items: stretch; }
.key-secret-row .codebox { flex: 1; }
.snippet-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; margin: 16px 0 7px; }
.snippet-title:first-child { margin-top: 0; }
.snippet-title .tag-opt { font-size: 11px; color: var(--violet); background: var(--violet-soft); border-radius: 5px; padding: 2px 7px; font-weight: 600; }

/* ---------- prompts ---------- */
.prompt-box {
  width: 100%; font-family: var(--mono); font-size: 12px; line-height: 1.6;
  border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 12px 14px; background: var(--surface-2); color: var(--text);
  resize: vertical; min-height: 200px; white-space: pre-wrap; overflow-wrap: break-word;
}
.prompt-box:focus { outline: none; border-color: var(--accent); }

/* ---------- key grants editor ---------- */
.grant-table { border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.grant-row { display: grid; grid-template-columns: 170px 1fr 8px; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); align-items: start; }
.grant-row:last-child { border-bottom: 0; }
.grant-row-head { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.grant-perms { display: flex; flex-wrap: wrap; gap: 5px 11px; margin-top: 7px; }
.grant-perms .check { font-size: 12px; }
.grant-remove { display: flex; align-items: flex-start; justify-content: center; }
.grant-add { padding: 9px 12px; }

/* token note inside the key onboarding dialog (OpenList handles tokens) */
.oplist-note { font-size: 11.5px; color: var(--text-3); }

/* ---------- 使用此 Key tabs ---------- */
.usekey-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.usekey-tab {
  appearance: none; background: none; border: 0; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 550; color: var(--text-2);
  padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.usekey-tab:hover { color: var(--text); }
.usekey-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.relay-check { width: 100%; align-items: center; }

/* ---------- dropdown menu ---------- */
.menu-pop {
  position: absolute; z-index: 150;
  min-width: 176px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  padding: 5px;
  animation: popIn .12s ease;
}
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  background: none; border: 0; font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 7px 9px; border-radius: 7px; cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item:disabled { color: var(--text-3); cursor: not-allowed; }
.menu-item:disabled:hover { background: none; }

/* ---------- misc ---------- */
.kv-list { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; }
.kv-list dt { color: var(--text-3); }
.kv-list dd { margin: 0; min-width: 0; word-break: break-all; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.text-muted { color: var(--text-3); }
.text-sub { color: var(--text-2); }
.text-danger { color: var(--danger); font-weight: 550; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-14 { margin-top: 14px; } .mt-18 { margin-top: 18px; }
.mb-8 { margin-bottom: 8px; } .mb-14 { margin-bottom: 14px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-14 { gap: 14px; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.elide { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* events timeline */
.event-list { display: flex; flex-direction: column; }
.event-item { display: flex; gap: 14px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.event-item:last-child { border-bottom: 0; }
.event-time { flex: 0 0 138px; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.event-body { flex: 1; min-width: 0; font-size: 13px; }
.event-drive { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.event-detail { color: var(--text-2); margin-top: 2px; word-break: break-word; }

/* responsive */
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .18s ease; box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-3); }
  .nav-toggle { display: inline-flex; }
  .page { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .filterbar .input, .filterbar .select { width: 100%; }
  .filterbar .field { flex: 1 1 150px; }
  .kv-list { grid-template-columns: 105px 1fr; }
}
@media (max-width: 640px) {
  .modal-overlay { padding: 3vh 8px 16px; }
  .topbar-sub { display: none; }
}


/* ---------- console refinement ---------- */
:root { --motion-fast: 160ms; --motion: 240ms; --ease: cubic-bezier(.2,.7,.2,1); color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171917; --surface: #202320; --surface-2: #252925; --surface-3: #2e332e;
  --border: #363c36; --border-strong: #4e574e;
  --text: #f0f1eb; --text-2: #bec4b9; --text-3: #99a293;
  --accent: #e3e9dd; --accent-hover: #ffffff; --on-accent: #202620;
  --accent-soft: #333a30; --accent-soft-2: #3c4537;
  --ok: #68d8af; --ok-soft: #223c30; --warn: #edba79; --warn-soft: #403322;
  --danger: #ff9393; --danger-hover: #dd6565; --danger-soft: #472b2b;
  --info: #8dcffa; --info-soft: #233845; --violet: #baa6f8; --violet-soft: #352e47;
  --slate-soft: #30362f; --sidebar-bg: #1e211e; --sidebar-bg-2: #292e29;
  --sidebar-text: #aeb7a7; --sidebar-text-active: #f0f1eb; --sidebar-border: #363c36;
  --shadow-1: 0 1px 2px #00000014; --shadow-2: 0 8px 24px #00000025;
}
[hidden] { display: none !important; }
body { transition: background-color var(--motion-fast), color var(--motion-fast); }
.sidebar { border-right: 1px solid var(--sidebar-border); transition: width var(--motion) var(--ease), flex-basis var(--motion) var(--ease), transform var(--motion) var(--ease); }
.brand { min-height: 86px; padding: 20px; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: transparent; box-shadow: none; overflow: hidden; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand-sub { margin-top: 2px; font-size: 11px; white-space: nowrap; }
.nav { padding: 20px 12px; }
.nav-group { margin-top: 26px; }
.nav-group-label { font-size: 11px; font-weight: 500; letter-spacing: .04em; padding-bottom: 10px; }
.nav-item { min-height: 43px; padding: 10px 12px; margin: 4px 0; gap: 12px; border-radius: 11px; transition: color var(--motion-fast), background-color var(--motion-fast), box-shadow var(--motion-fast); }
.nav-item.active { font-weight: 650; }
.sidebar-foot { padding: 16px 12px; }
.session-card { background: transparent; gap: 9px; }
.avatar { background: var(--ok-soft); color: var(--ok); }
.session-name { line-height: 1.6; }
.sidebar-collapse { position: absolute; right: -15px; top: 50%; width: 29px; height: 46px; border: 1px solid var(--border); border-radius: 20px; color: var(--text-2); background: var(--surface); box-shadow: var(--shadow-2); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1; }
.sidebar-collapse svg { transition: transform var(--motion) var(--ease); }
.topbar { background: var(--bg); border-bottom: 0; padding: 0 40px; }
.topbar .nav-toggle { display: none; }
.topbar-title { gap: 12px; }
.topbar-title h1 { font-size: 13px; color: var(--text-2); font-weight: 500; }
.topbar-title h1::before { content: '控制台 / '; color: var(--text-3); }
.topbar-sub { font-size: 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.topbar-actions { background: var(--surface); padding: 9px 12px; border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 6px 24px #29292505; gap: 3px; }
.topbar-actions .icon-btn { width: 34px; height: 34px; }
#refresh-btn { order: -1; border-radius: 11px; padding: 8px 10px; }
.mock-pill { margin-right: 8px; font-size: 10px; }
.page-head { align-items: center; margin-bottom: 24px; }
.page-head-text h2 { letter-spacing: -.035em; line-height: 1.35; }
.page-head-text .sub { margin-top: 8px; font-size: 13px; color: var(--text-3); }
.page-head-actions .btn-primary { border-radius: 999px; padding: 11px 19px; }
.btn, .icon-btn { transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast); }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled) { transform: scale(.96); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 12px #1a1a1820; }
.btn-secondary { border-color: var(--border); box-shadow: none; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .sidebar-collapse:focus-visible, .provider-tab:focus-visible { outline: 2px solid var(--ok); outline-offset: 3px; }
.card { box-shadow: none; }
.card-head { padding: 17px 20px; }
.card-title { font-size: 14px; }
.stat-grid { gap: 20px; margin-bottom: 24px; }
.stat-card { padding: 23px 24px; box-shadow: none; transition: transform var(--motion), border-color var(--motion), box-shadow var(--motion); }
.stat-num { font-size: 38px; margin: 12px 0 8px; }
.stat-top .icon-chip { color: var(--ok); background: var(--ok-soft); }
.stat-sub { font-size: 12px; }
.input, .select, .textarea { transition: border-color var(--motion-fast), box-shadow var(--motion-fast); }
.input:focus, .select:focus, .textarea:focus { box-shadow: 0 0 0 3px var(--ok-soft); border-color: var(--ok); }
.tbl th { background: var(--surface-2); padding-top: 14px; padding-bottom: 14px; }
.tbl td { padding-top: 16px; padding-bottom: 16px; }
.tbl tbody tr { transition: background-color var(--motion-fast); }
.menu-pop { animation: popIn var(--motion-fast) var(--ease); border-radius: 13px; }
.modal { border-radius: 20px; animation: popIn var(--motion) var(--ease); }
.modal-overlay { backdrop-filter: blur(4px); }
.modal-head { padding-top: 22px; }
.modal-title { font-size: 18px; }
.modal-foot { border-radius: 0 0 20px 20px; }
.modal-overlay.leaving { animation: overlayOut 160ms ease forwards; pointer-events: none; }
.modal-overlay.leaving .modal { animation: modalOut 160ms ease forwards; }
.page-enter > *, .drive-card { animation: contentIn 320ms var(--ease) both; }
.page-enter > :nth-child(2) { animation-delay: 35ms; }
.page-enter > :nth-child(3) { animation-delay: 65ms; }
.drive-card { animation-delay: var(--enter-delay, 0ms); }
.refreshing .ico { animation: spin 900ms linear infinite; }
@keyframes contentIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes overlayOut { to { opacity: 0; } }
@keyframes modalOut { to { opacity: 0; transform: translateY(8px) scale(.985); } }

/* ---------- storage cards and filters ---------- */
.drive-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.drive-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; border-left: 3px solid #14b88b; padding-left: 13px; font-size: 13px; color: var(--text-2); }
.drive-counts strong { font-family: var(--mono); font-weight: 600; }
.text-ok { color: var(--ok); }
.drive-summary .card-desc { display: flex; align-items: center; gap: 5px; font-size: 11px; }
.health-strip { display: flex; align-items: flex-end; gap: 4px; height: 24px; margin: 0 0 8px; }
.health-segment { width: 19px; height: 9px; border-radius: 3px 3px 1px 1px; }
.health-ok { background: #18bc88; height: 20px; }
.health-warn { background: #e9b65e; height: 14px; }
.health-off { background: var(--border-strong); }
.provider-tabs { display: flex; gap: 8px; overflow-x: auto; border-bottom: 1px solid var(--border); padding-top: 12px; margin-bottom: 20px; scrollbar-width: thin; }
.provider-tab { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; position: relative; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 12px 14px; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; transition: color var(--motion-fast), border-color var(--motion-fast), background-color var(--motion-fast); }
.provider-tab:hover { background: var(--surface-2); color: var(--text); }
.provider-tab[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--text); }
.tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-family: var(--mono); }
.provider-dot { width: 9px; height: 9px; border-radius: 3px; box-shadow: inset 0 0 0 2px currentColor; }
.drive-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 22px; }
.drive-search { flex: 1 1 260px; max-width: 450px; position: relative; }
.drive-search > .ico { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.drive-search .input { width: 100%; padding: 11px 12px 11px 40px; border-radius: 13px; }
.drive-toolbar .select { padding: 10px 32px 10px 13px; border-radius: 12px; min-width: 126px; width: auto; }
.result-count { margin-left: auto; font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.view-switch { display: flex; padding: 3px; gap: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.view-switch .icon-btn { width: 34px; height: 32px; border-radius: 8px; }
.view-switch .icon-btn[aria-pressed="true"] { color: var(--text); background: var(--surface-3); }
.drive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.drive-card { background: var(--surface); border: 1px solid var(--border); border-radius: 17px; padding: 21px; min-width: 0; display: flex; flex-direction: column; transition: border-color var(--motion), box-shadow var(--motion); }
.drive-card-head { display: flex; gap: 8px; align-items: center; min-height: 28px; }
.provider-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 10px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.tone-amber { color: #af6b10; background: #fff2d8; }
.tone-violet { color: #7050c1; background: #f0eafd; }
.tone-blue { color: #2469c5; background: #e9f1ff; }
.tone-teal { color: #0c8783; background: #e2f6f3; }
.tone-slate { color: var(--text-2); background: var(--surface-3); }
[data-theme="dark"] .tone-amber { color: #e8bd71; background: #403722; }
[data-theme="dark"] .tone-violet { color: #c2aff5; background: #372d4b; }
[data-theme="dark"] .tone-blue { color: #99c3ff; background: #24374f; }
[data-theme="dark"] .tone-teal { color: #77d6ce; background: #203e3a; }
.static-label { color: var(--text-3); font-size: 10px; white-space: nowrap; }
.storage-label { margin-left: auto; color: var(--text-3); font-size: 11px; }
.drive-name { font-size: 18px; font-weight: 650; letter-spacing: -.025em; margin: 15px 0 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.drive-mount { color: var(--text-3); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.drive-status { margin-top: 20px; padding: 12px; border-radius: 11px; background: var(--surface-2); min-height: 93px; }
.drive-status-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drive-status-top .badge { font-size: 11px; padding: 4px 8px; }
.drive-status-top .card-desc { font-size: 10px; }
.drive-status-desc { color: var(--text-2); font-size: 11.5px; line-height: 1.7; margin-top: 9px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drive-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-3); font-size: 11px; margin: 15px 0; }
.drive-meta > span:first-child { display: flex; align-items: center; gap: 5px; }
.drive-meta strong { color: var(--text-2); font-family: var(--mono); font-weight: 500; }
.drive-card-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.drive-created { width: 100%; color: var(--text-3); font-size: 10.5px; font-family: var(--mono); }
.drive-card-foot .cell-actions { display: flex; align-items: center; gap: 7px; width: 100%; justify-content: flex-start; }
.drive-card-foot .cell-actions > .icon-btn { margin-left: auto; border: 1px solid var(--border); border-radius: 9px; }
.drive-card-foot .btn { padding: 7px 10px; border-radius: 9px; font-size: 11.5px; }
.drive-skeleton { min-height: 325px; }
.drive-results .empty { border: 1px dashed var(--border-strong); border-radius: 17px; background: var(--surface); }
@media (hover: hover) {
  .drive-card:hover { border-color: var(--border-strong); box-shadow: 0 7px 24px #29292508; }
  a.stat-card:hover { transform: translateY(-2px); }
}
@media (min-width: 1025px) {
  .sidebar-compact .sidebar { width: 76px; flex-basis: 76px; }
  .sidebar-compact .brand { padding: 20px 16px; }
  .sidebar-compact .brand > div:last-child, .sidebar-compact .nav-item > span:not(.ico), .sidebar-compact .nav-group-label, .sidebar-compact .session-card .grow, .sidebar-compact .session-card > .icon-btn { display: none; }
  .sidebar-compact .nav-item { justify-content: center; padding: 10px; }
  .sidebar-compact .nav-group { margin-top: 20px; }
  .sidebar-compact .nav-item .nav-badge:not(:empty) { display: block; position: absolute; right: 0; top: -2px; min-width: 15px; height: 15px; line-height: 15px; font-size: 9px; padding: 0 3px; }
  .sidebar-compact .session-card { padding: 9px 12px; }
  .sidebar-compact .sidebar-collapse svg { transform: rotate(180deg); }
}
@media (max-width: 1024px) {
  .sidebar-collapse { display: none; }
  .topbar .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 20px; height: 72px; }
  .page { padding: 16px 20px 40px; }
  .topbar-sub { display: none; }
  .page-head-text h2 { font-size: 26px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-title h1::before { content: ''; }
  .topbar-actions { padding: 5px; border-radius: 15px; }
  .topbar-actions .icon-btn { width: 30px; height: 30px; }
  #refresh-btn { padding: 7px; font-size: 0; gap: 0; }
  .mock-pill { display: none; }
  .page { padding: 14px 16px 32px; }
  .page-head { gap: 16px; }
  .page-head-text { flex: 1 1 200px; }
  .page-head-text h2 { font-size: 25px; }
  .page-head-actions { margin-left: 0; flex-wrap: wrap; row-gap: 8px; }
  .drive-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .drive-toolbar { gap: 10px; }
  .drive-search { max-width: none; flex-basis: 100%; }
  .drive-toolbar .select { flex: 1; }
  .result-count { font-size: 10px; }
  .drive-card { padding: 18px; }
  .drive-summary .card-desc { display: none; }
  .stat-grid { gap: 12px; }
  .stat-card { padding: 20px; }
  .modal-title { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}

/* ---------- OpenList entry (step 1): sync actions & replacement storage ---------- */
.drive-repl {
  margin-top: 12px;
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-2);
}
.drive-repl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-1); }
.drive-repl .repl-warn { margin-top: 8px; padding: 8px 10px; font-size: 12px; }
.drive-repl .repl-kv { margin-top: 8px; grid-template-columns: 64px 1fr; font-size: 12.5px; }
/* scroll targets for「前往网盘 X」and post-sync scroll */
[data-drive-id], [data-section] { scroll-margin-top: 84px; }
@keyframes cardFlash {
  0%, 55% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.drive-card.drive-flash { animation: cardFlash 2.2s ease-out; }
@keyframes rowFlash {
  0%, 55% { background-color: var(--accent-soft); }
  100% { background-color: transparent; }
}
tr.drive-flash > td { animation: rowFlash 2.2s ease-out; }

/* ---- Key form: scope / presets / advanced folding ---- */
.scope-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.scope-opt { align-items: flex-start; }
.scope-opt .cb-title { font-weight: 600; color: var(--text-1); }
.scope-opt .cb-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.scope-picker { margin-top: 4px; }
.drive-checklist { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft, #fafaf9); }
.drive-check { font-size: 13px; }
.drive-check .mono { font-size: 12.5px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.chip-btn {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: #fff; cursor: pointer; text-align: left; font: inherit;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.chip-btn-label { font-weight: 650; font-size: 13px; color: var(--text-1); }
.chip-btn-sub { font-size: 11.5px; color: var(--text-3); }
.chip-btn.chip-custom { cursor: default; background: transparent; border-style: dashed; }
.chip-btn.chip-custom.on { border-color: var(--warn); background: var(--warn-soft); box-shadow: none; }
.adv-details { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 4px; }
.adv-details summary {
  cursor: pointer; user-select: none; padding: 10px 12px; font-weight: 600;
  font-size: 13px; color: var(--text-1); list-style: none; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.adv-details summary::-webkit-details-marker { display: none; }
.adv-details summary::before { content: '▸'; color: var(--text-3); transition: transform .15s; }
.adv-details[open] summary::before { transform: rotate(90deg); }
.adv-summary-sub { font-weight: 400; font-size: 12px; color: var(--text-3); }
.adv-body { padding: 4px 12px 12px; border-top: 1px solid var(--border); display: grid; gap: 14px; }
