/* ==================================================================
   喵小程 · 设计系统
   —— 纯手写 CSS，零构建。所有页面共用这一份基础层。
   ================================================================== */

/* ---------------- Design tokens ---------------- */
:root {
  /* 品牌色 */
  --brand-50:  #eef0ff;
  --brand-100: #e0e3ff;
  --brand-200: #c7ccfe;
  --brand-300: #a5aafc;
  --brand-400: #8385f7;
  --brand-500: #6366f1;
  --brand-600: #5b5bd6;
  --brand-700: #4a4ab5;
  --brand-800: #3b3c91;
  --brand-900: #2e2f6f;

  --cyan-400: #22d3ee;
  --cyan-500: #06b6d4;

  /* 语义色 */
  --ok-50: #ecfdf5;  --ok-100: #d1fae5;  --ok-500: #10b981; --ok-600: #059669; --ok-700: #047857;
  --warn-50:#fffbeb; --warn-100:#fef3c7; --warn-500:#f59e0b; --warn-600:#d97706; --warn-700:#b45309;
  --bad-50: #fff1f2; --bad-100: #ffe4e6; --bad-500: #f43f5e; --bad-600: #e11d48; --bad-700: #be123c;
  --info-50:#eff6ff; --info-100:#dbeafe; --info-500:#3b82f6; --info-600:#2563eb;

  /* 中性 */
  --ink-900: #0c1222;
  --ink-800: #131c31;
  --ink-700: #1f2a44;
  --ink-600: #334155;
  --ink-500: #475569;
  --ink-400: #64748b;
  --ink-300: #94a3b8;
  --ink-200: #cbd5e1;
  --ink-100: #e2e8f0;
  --ink-50:  #f1f5f9;

  --bg:        #f5f7fb;
  --bg-soft:   #fafbff;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --line:      #e8ecf4;
  --line-strong: #dbe2ee;

  /* 侧栏（深色） */
  --side-bg: linear-gradient(180deg, #121a2e 0%, #0d1424 100%);
  --side-ink: #a9b4c9;
  --side-ink-strong: #f1f5f9;
  --side-line: rgba(255, 255, 255, .07);
  --side-active: rgba(99, 102, 241, .18);

  /* 圆角 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-full: 999px;

  /* 阴影 */
  --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-md: 0 2px 6px -1px rgba(16, 24, 40, .06), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --sh-lg: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 20px 48px -16px rgba(16, 24, 40, .16);
  --sh-brand: 0 8px 22px -8px rgba(99, 102, 241, .55);

  /* 尺寸 */
  --side-w: 252px;
  --side-w-collapsed: 76px;
  --top-h: 62px;
  --page-max: 2200px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* 侧栏折叠：宽度、主区左边距、悬浮开关统一跟随这个变量 */
html.side-collapsed { --side-w: var(--side-w-collapsed); }

/* ---------------- Reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.62;
  color: var(--ink-800);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; line-height: 1.32; letter-spacing: -.012em; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0 0 .7em; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand-600); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--brand-700); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
ul, ol { margin: 0 0 .7em; padding-left: 1.4em; }
code, pre { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-200); color: var(--ink-900); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d7deea; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c0cadb; background-clip: content-box; }

/* ---------------- 排版工具 ---------------- */
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-400); }
.dim { color: var(--ink-300); }
.strong { font-weight: 650; }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.big { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.c-ok { color: var(--ok-600); } .c-bad { color: var(--bad-600); }
.c-warn { color: var(--warn-600); } .c-brand { color: var(--brand-600); }
.center { text-align: center; } .right { text-align: right; }

/* ---------------- 布局工具 ---------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-top { display: flex; align-items: flex-start; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.g4 { gap: 4px; } .g6 { gap: 6px; } .g8 { gap: 8px; } .g12 { gap: 12px; }
.g16 { gap: 16px; } .g20 { gap: 20px; } .g24 { gap: 24px; }
.mt4{margin-top:4px}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}
.mt20{margin-top:20px}.mt24{margin-top:24px}.mt32{margin-top:32px}
.mb8{margin-bottom:8px}.mb12{margin-bottom:12px}.mb16{margin-bottom:16px}.mb20{margin-bottom:20px}
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.hide { display: none !important; }

/* ---------------- 按钮 ---------------- */
.btn {
  --h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--h); padding: 0 16px;
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 560; white-space: nowrap;
  border: 1px solid transparent;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), transform .12s var(--ease), box-shadow .16s var(--ease);
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; flex: none; }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff; box-shadow: var(--sh-brand);
}
.btn-primary:hover { box-shadow: 0 10px 26px -8px rgba(99,102,241,.72); filter: brightness(1.04); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink-600); box-shadow: var(--sh-xs); }
.btn-ghost:hover { border-color: var(--brand-300); color: var(--brand-600); background: var(--brand-50); }
.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }
.btn-dark { background: var(--ink-800); color: #fff; }
.btn-dark:hover { background: var(--ink-900); }
.btn-ok { background: var(--ok-600); color: #fff; box-shadow: 0 8px 20px -10px rgba(5,150,105,.7); }
.btn-ok:hover { background: var(--ok-700); }
.btn-danger { background: var(--bad-50); color: var(--bad-600); border-color: var(--bad-100); }
.btn-danger:hover { background: var(--bad-100); }
.btn-plain { color: var(--ink-500); }
.btn-plain:hover { background: var(--ink-50); color: var(--ink-700); }
.btn-sm { --h: 30px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-sm .ico { width: 14px; height: 14px; }
.btn-lg { --h: 46px; padding: 0 24px; font-size: 15px; border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-500); letter-spacing: .01em; }
.label .req { color: var(--bad-500); margin-left: 2px; }
.hint { font-size: 12px; color: var(--ink-400); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink-800);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s;
  font-size: 13.5px;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-200); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-400); box-shadow: 0 0 0 3.5px var(--brand-50);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.7; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.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 10px center;
  padding-right: 30px; cursor: pointer;
}
.input-lg { height: 44px; font-size: 14.5px; border-radius: var(--r-lg); }
.input-sm { height: 30px; font-size: 12.5px; padding: 0 9px; border-radius: var(--r-sm); }
.input-icon { position: relative; }
.input-icon .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-300); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }

/* 开关 */
.switch { position: relative; display: inline-flex; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px; background: var(--ink-200);
  transition: background .2s var(--ease);
}
.switch i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--sh-sm);
  transition: transform .2s var(--ease-out);
}
.switch input:checked + i { background: var(--brand-500); }
.switch input:checked + i::after { transform: translateX(18px); }

/* 复选 / 单选 */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-500); cursor: pointer; }

/* ---------------- 卡片 / 面板 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card-pad { padding: 18px 20px; }
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  min-height: 54px;
}
.card-hd h3 { font-size: 15px; font-weight: 640; }
.card-bd { padding: 18px 20px; }
.card-bd.flush { padding: 0; }
.card-ft { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-hover { transition: transform .2s var(--ease-out), box-shadow .2s var(--ease), border-color .2s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--brand-200); }

/* 统计卡 */
.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-xs);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease-out);
}
.stat:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.stat-label { font-size: 12.5px; color: var(--ink-400); display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--ink-400); margin-left: 3px; letter-spacing: 0; }
.stat-foot { font-size: 12px; color: var(--ink-400); display: flex; align-items: center; gap: 4px; }
.stat-ico {
  position: absolute; right: 14px; top: 14px;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600);
}
.stat-ico .ico { width: 17px; height: 17px; }
.stat-ico.ok { background: var(--ok-50); color: var(--ok-600); }
.stat-ico.warn { background: var(--warn-50); color: var(--warn-600); }
.stat-ico.bad { background: var(--bad-50); color: var(--bad-600); }
.stat-ico.info { background: var(--info-50); color: var(--info-600); }
.stat-ico.cyan { background: #ecfeff; color: var(--cyan-500); }

/* ---------------- 徽标 / 胶囊 ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px; border-radius: var(--r-xs);
  font-size: 11.5px; font-weight: 600; line-height: 1;
  background: var(--ink-50); color: var(--ink-500); white-space: nowrap;
}
.badge-brand { background: var(--brand-50); color: var(--brand-700); }
.badge-ok { background: var(--ok-50); color: var(--ok-700); }
.badge-warn { background: var(--warn-50); color: var(--warn-700); }
.badge-bad { background: var(--bad-50); color: var(--bad-700); }
.badge-info { background: var(--info-50); color: var(--info-600); }
.badge-outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-500); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 12.5px; color: var(--ink-500); white-space: nowrap;
  transition: all .15s var(--ease);
}
.chip.is-active { background: var(--ink-800); border-color: var(--ink-800); color: #fff; font-weight: 560; }
.chip-btn { cursor: pointer; }
.chip-btn:hover { border-color: var(--brand-300); color: var(--brand-600); }
.chip-btn.is-active:hover { color: #fff; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-300); flex: none; }
.dot.ok { background: var(--ok-500); } .dot.warn { background: var(--warn-500); }
.dot.bad { background: var(--bad-500); } .dot.brand { background: var(--brand-500); }

/* ---------------- 表格 ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-400);
  letter-spacing: .02em; padding: 9px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table th:first-child { border-radius: var(--r-sm) 0 0 0; }
.table th:last-child { border-radius: 0 var(--r-sm) 0 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table-compact th { padding: 7px 10px; }
.table-compact td { padding: 8px 10px; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 4px; align-items: center; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; height: 40px; padding: 0 14px; display: inline-flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 550; color: var(--ink-400);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s var(--ease), border-color .15s var(--ease);
  white-space: nowrap;
}
.tab:hover { color: var(--ink-700); }
.tab.is-active { color: var(--brand-600); border-bottom-color: var(--brand-500); }
.tab .n {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--ink-100); color: var(--ink-500);
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.tab.is-active .n { background: var(--brand-100); color: var(--brand-700); }

.segmented { display: inline-flex; padding: 3px; background: var(--ink-50); border-radius: var(--r-md); gap: 2px; }
.segmented button {
  height: 30px; padding: 0 13px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 550; color: var(--ink-500);
  transition: all .15s var(--ease);
}
.segmented button.is-active { background: var(--surface); color: var(--ink-900); box-shadow: var(--sh-xs); }

/* ---------------- 进度 ---------------- */
.bar { height: 7px; border-radius: 99px; background: var(--ink-100); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  transition: width .5s var(--ease-out);
}
.bar.ok > i { background: linear-gradient(90deg, #34d399, var(--ok-600)); }
.bar.warn > i { background: linear-gradient(90deg, #fbbf24, var(--warn-600)); }
.bar.bad > i { background: linear-gradient(90deg, #fb7185, var(--bad-600)); }
.bar.thin { height: 4px; }

.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-txt {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: -.02em;
}

/* ---------------- 头像 ---------------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  color: #fff; font-size: 13px; font-weight: 650; letter-spacing: .01em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  overflow: hidden;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; border-radius: 14px; }
.avatar.xl { width: 68px; height: 68px; font-size: 24px; border-radius: 20px; }
.avatar.c-0 { background: linear-gradient(135deg,#818cf8,#4f46e5); }
.avatar.c-1 { background: linear-gradient(135deg,#34d399,#059669); }
.avatar.c-2 { background: linear-gradient(135deg,#fbbf24,#d97706); }
.avatar.c-3 { background: linear-gradient(135deg,#f472b6,#db2777); }
.avatar.c-4 { background: linear-gradient(135deg,#22d3ee,#0891b2); }
.avatar.c-5 { background: linear-gradient(135deg,#a78bfa,#7c3aed); }
.avatar.c-6 { background: linear-gradient(135deg,#fb7185,#e11d48); }
.avatar.c-7 { background: linear-gradient(135deg,#38bdf8,#2563eb); }

/* ---------------- 空状态 ---------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 52px 20px; text-align: center; color: var(--ink-400);
}
.empty-ico {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: var(--ink-50); color: var(--ink-300); margin-bottom: 2px;
}
.empty-ico .ico { width: 26px; height: 26px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--ink-600); }
.empty-desc { font-size: 12.5px; max-width: 320px; line-height: 1.7; }

/* ---------------- 加载 ---------------- */
.skeleton {
  background: linear-gradient(90deg, #eef2f8 25%, #f7f9fc 37%, #eef2f8 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--brand-200); border-top-color: var(--brand-600);
  animation: spin .7s linear infinite;
}
.spinner.lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; padding: 60px; gap: 12px; }

/* ---------------- Toast ---------------- */
.toast-host {
  position: fixed; z-index: 9000; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  min-width: 200px; max-width: 460px;
  padding: 11px 16px; border-radius: var(--r-md);
  background: var(--ink-900); color: #fff; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--sh-lg);
  animation: toastIn .28s var(--ease-out);
  pointer-events: auto;
}
.toast .ico { width: 17px; height: 17px; flex: none; }
.toast.ok .ico { color: #4ade80; }
.toast.bad .ico { color: #fb7185; }
.toast.warn .ico { color: #fbbf24; }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------------- Modal / Drawer ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(12, 18, 34, .46);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn .18s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 48px);
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: 0 32px 80px -20px rgba(9, 14, 30, .42);
  display: flex; flex-direction: column;
  animation: modalIn .26s var(--ease-out);
}
.modal.wide { width: min(880px, 100%); }
.modal.xwide { width: min(1120px, 100%); }
.modal.giant { width: min(1380px, calc(100vw - 40px)); }
.modal.narrow { width: min(420px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.modal-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px 14px;
}
.modal-hd h3 { font-size: 16.5px; }
.modal-bd { padding: 4px 22px 20px; overflow-y: auto; }
.modal-ft {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.modal-x {
  width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center;
  color: var(--ink-400); transition: all .15s;
}
.modal-x:hover { background: var(--ink-50); color: var(--ink-700); }

.drawer-overlay {
  position: fixed; inset: 0; z-index: 8000; background: rgba(12,18,34,.42);
  animation: fadeIn .18s var(--ease);
}
.drawer {
  position: fixed; z-index: 8001; top: 0; right: 0; bottom: 0;
  width: min(680px, 100%); background: var(--surface);
  box-shadow: -24px 0 64px -24px rgba(9,14,30,.36);
  display: flex; flex-direction: column;
  animation: drawerIn .3s var(--ease-out);
}
.drawer.wide { width: min(960px, 100%); }
@keyframes drawerIn { from { transform: translateX(28px); opacity: .6; } }

/* ---------------- 下拉菜单 ---------------- */
.menu {
  position: absolute; z-index: 7000; min-width: 168px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-lg);
  animation: menuIn .14s var(--ease-out);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-600); text-align: left;
  transition: background .12s, color .12s;
}
.menu-item:hover { background: var(--brand-50); color: var(--brand-700); }
.menu-item .ico { width: 15px; height: 15px; color: var(--ink-400); }
.menu-item:hover .ico { color: var(--brand-600); }
.menu-item.danger { color: var(--bad-600); }
.menu-item.danger:hover { background: var(--bad-50); }
.menu-item.danger .ico { color: var(--bad-500); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; color: var(--ink-300); letter-spacing: .04em; }

/* ---------------- Markdown 内容 ---------------- */
.md { font-size: 14.5px; line-height: 1.9; color: var(--ink-600); }
.md > *:first-child { margin-top: 0; }
.md h2 {
  font-size: 19px; color: var(--ink-900); margin: 1.6em 0 .6em;
  padding-bottom: .35em; border-bottom: 1px solid var(--line);
}
.md h3 { font-size: 16px; color: var(--ink-800); margin: 1.4em 0 .5em; }
.md h4 { font-size: 14.5px; color: var(--ink-700); margin: 1.2em 0 .4em; }
.md p { margin: 0 0 1em; }
.md ul, .md ol { margin: 0 0 1em; padding-left: 1.5em; }
.md li { margin-bottom: .4em; }
.md li::marker { color: var(--brand-400); }
.md strong { color: var(--ink-900); font-weight: 650; }
.md code {
  background: var(--brand-50); color: var(--brand-700);
  padding: 1px 6px; border-radius: 5px; font-size: .88em;
}
.md pre {
  background: #0f172a; color: #e2e8f0; padding: 15px 17px; border-radius: var(--r-md);
  overflow-x: auto; margin: 0 0 1.1em; line-height: 1.75; font-size: 13px;
}
.md pre code { background: none; color: inherit; padding: 0; }
.md blockquote {
  margin: 0 0 1em; padding: 2px 0 2px 15px;
  border-left: 3px solid var(--brand-300); color: var(--ink-500);
}
.md img { border-radius: var(--r-md); margin: .6em 0 1.1em; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.8em 0; }
.md .md-tip {
  display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--r-md);
  background: var(--brand-50); border: 1px solid var(--brand-100);
  margin: 0 0 1.1em; font-size: 13.5px; line-height: 1.8; color: var(--ink-600);
}
.md .md-tip .md-tip-ico { flex: none; margin-top: 2px; }
.md .md-tip .ico { width: 17px; height: 17px; color: var(--brand-600); }
.md .md-tip.warn { background: var(--warn-50); border-color: var(--warn-100); }
.md .md-tip.warn .ico { color: var(--warn-600); }
.md .md-tip.info { background: var(--info-50); border-color: var(--info-100); }
.md .md-tip.info .ico { color: var(--info-600); }
.md .md-tip p { margin-bottom: .35em; }
.md .md-tip > div > *:last-child { margin-bottom: 0; }

/* 积木文本标记：讲课时【移动 (10) 步】这种写法自动高亮 */
.md .blk-ref, .blk-ref {
  display: inline-block; padding: 0 5px; border-radius: 4px;
  background: #eef2ff; color: #4338ca; font-size: .93em; font-weight: 560;
  border-bottom: 1px solid #c7d2fe;
}

/* ---------------- 键盘 ---------------- */
kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  background: var(--ink-50); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-500);
}

/* ---------------- 动画 ---------------- */
.fade-in { animation: fadeUp .34s var(--ease-out) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
.stagger > * { animation: fadeUp .38s var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .08s; }
.stagger > *:nth-child(4) { animation-delay: .11s; }
.stagger > *:nth-child(5) { animation-delay: .14s; }
.stagger > *:nth-child(6) { animation-delay: .17s; }
.stagger > *:nth-child(7) { animation-delay: .2s; }
.stagger > *:nth-child(8) { animation-delay: .23s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
