:root {
  --bg: #f4f6fa;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #e8eefb 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #eef4fd 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --accent-border: #bfd4fe;
  --win: #2563eb;
  --kylin: #c2410c;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 2px 8px rgba(15, 23, 42, .07);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --radius: 10px;
  --radius-lg: 14px;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --sidebar-w: 248px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #16233d 0%, transparent 60%),
             radial-gradient(900px 500px at 100% 0%, #131e33 0%, transparent 55%);
  --surface: #131c2e;
  --surface-2: #182338;
  --surface-3: #1f2c45;
  --border: #263349;
  --border-strong: #35455f;
  --text: #e8eefb;
  --text-2: #a3b2cc;
  --text-3: #6b7d9c;
  --accent: #60a5fa;
  --accent-soft: #17233a;
  --accent-border: #2c4570;
  --win: #60a5fa;
  --kylin: #fb923c;
  --danger: #f87171;
  --danger-soft: #2a1518;
  --danger-border: #5b2830;
  --warn: #fbbf24;
  --warn-soft: #2a2113;
  --ok: #34d399;
  --ok-soft: #12251f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ── 布局 ─────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── 侧栏 ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center;
  color: #fff; font-size: 15px;
  box-shadow: var(--shadow-sm);
}
.brand-text { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-3); font-weight: 500; margin-top: -2px; }

.os-switch {
  display: flex; gap: 4px; padding: 12px 12px 8px;
}
.os-btn {
  flex: 1; padding: 7px 4px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.os-btn:hover { border-color: var(--border-strong); color: var(--text); }
.os-btn.on { color: #fff; border-color: transparent; }
.os-btn.on[data-os="windows"] { background: var(--win); }
.os-btn.on[data-os="kylin"] { background: var(--kylin); }

.side-search { padding: 4px 12px 10px; }
.search-box {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px;
  transition: all .15s;
}
.search-box:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { flex: 0 0 auto; color: var(--text-3); }
.search-box input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 13px; min-width: 0;
}
.search-box input::placeholder { color: var(--text-3); }
.search-clear { color: var(--text-3); display: none; font-size: 15px; line-height: 1; padding: 0 2px; }
.search-clear:hover { color: var(--text); }
.search-box.has-value .search-clear { display: block; }

.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
/* 侧栏滚动条做细做淡，避免与内容区滚动条互相干扰 */
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; border: 1px solid transparent; }
.nav::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-label {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .6px;
  padding: 12px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 7px;
  color: var(--text-2); font-size: 13px; font-weight: 500;
  width: 100%; text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-ico { font-size: 14px; width: 18px; text-align: center; flex: 0 0 auto; }
.nav-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item.on .nav-count { color: var(--accent); }

.side-foot {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
}
.bridge-state {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3); font-weight: 500;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.icon-btn {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid var(--border); background: var(--surface-2);
  transition: all .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }

/* ── 主区 ─────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.topbar .sep { color: var(--border-strong); }
.topbar-meta { font-size: 12px; color: var(--text-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }

.content { flex: 1; overflow-y: auto; padding: 20px 22px 60px; }

.cat-head {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 12px;
}
.cat-head:first-child { margin-top: 4px; }
.cat-head h2 { font-size: 14px; font-weight: 700; }
.cat-head .bar { width: 3px; height: 15px; border-radius: 2px; background: var(--accent); }
.cat-head .cnt { font-size: 12px; color: var(--text-3); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 15px 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s, border-color .16s, transform .16s;
  display: flex; flex-direction: column; gap: 9px;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.card.danger { border-left: 3px solid var(--danger); }
.card.danger:hover { border-color: var(--danger-border); }
.card.gui { border-left: 3px solid var(--accent); }

.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-title { font-size: 13.5px; font-weight: 700; flex: 1; line-height: 1.45; }
.card-fav {
  font-size: 14px; color: var(--text-3); flex: 0 0 auto;
  padding: 0 2px; line-height: 1.3; transition: color .12s, transform .12s;
}
.card-fav:hover { color: var(--warn); transform: scale(1.15); }
.card-fav.on { color: var(--warn); }
.card-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.55; flex: 1; }

.cmd-box {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-all;
  white-space: pre-wrap;
}
.cmd-box .ph { color: var(--accent); background: var(--accent-soft); border-radius: 3px; padding: 0 3px; font-weight: 600; }
[data-theme="dark"] .cmd-box .ph { color: #93c5fd; background: #1e2c47; }
.cmd-box.danger { background: var(--danger-soft); border-color: var(--danger-border); }
[data-theme="dark"] .cmd-box.danger { background: #241419; }

.card-note {
  font-size: 11.5px; color: var(--text-3); line-height: 1.5;
  display: flex; gap: 5px; align-items: flex-start;
}
.card-note.warn { color: var(--warn); }

.card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px; font-weight: 600; padding: 2px 6px;
  border-radius: 5px; background: var(--surface-3); color: var(--text-3);
  border: 1px solid var(--border);
}
.tag.admin { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.gui { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.ps { background: #f5f3ff; color: #7c3aed; border-color: transparent; }
[data-theme="dark"] .tag.ps { background: #221a33; color: #c4b5fd; }

.card-actions { margin-left: auto; display: flex; gap: 5px; }

.btn {
  padding: 5px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  transition: all .14s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 3px 8px; font-size: 11.5px; }

.empty { text-align: center; padding: 70px 20px; color: var(--text-3); }
.empty-ico { font-size: 42px; margin-bottom: 12px; opacity: .5; }
.empty h3 { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.empty p { font-size: 13px; }

/* ── 弹层 ─────────────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-mask.on { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.modal-head h3 { font-size: 14.5px; font-weight: 700; flex: 1; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex: 0 0 auto;
  background: var(--surface-2);
}

.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 8px 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; outline: none; transition: all .15s;
  font-family: var(--mono); font-size: 12.5px;
}
.field input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }

.preview {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 12px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  word-break: break-all; white-space: pre-wrap; color: var(--text);
}
.preview.danger { background: var(--danger-soft); border-color: var(--danger-border); }

.info-row { display: flex; gap: 10px; margin-bottom: 12px; font-size: 12.5px; align-items: flex-start; }
.info-key { color: var(--text-3); flex: 0 0 66px; font-weight: 600; }
.info-val { color: var(--text-2); flex: 1; }
.info-val.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ── 输出面板 ─────────────────────────────────────── */
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 460px; max-width: 92vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  z-index: 80; display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.drawer-head h3 { font-size: 14px; font-weight: 700; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.drawer-foot { padding: 11px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: var(--surface-2); flex: 0 0 auto; }

.out {
  font-family: var(--mono); font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 12px; min-height: 60px;
}
.out.err { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.out .meta { color: var(--text-3); font-style: italic; }

/* ── Toast ────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toast-in .22s cubic-bezier(.4,0,.2,1);
  display: flex; align-items: center; gap: 7px;
  max-width: 80vw;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── 快捷键提示 ───────────────────────────────────── */
kbd {
  font-family: var(--mono); font-size: 11px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 4px;
  padding: 1px 5px; color: var(--text-2);
}

@media (max-width: 880px) {
  .sidebar { position: fixed; z-index: 70; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.on { transform: translateX(0); }
  .menu-toggle { display: grid !important; }
  .grid { grid-template-columns: 1fr; }
  .topbar-meta { display: none; }
}
.menu-toggle { display: none; }
