/* ==========================================================================
   役次元 玩法工坊 — 设计系统 style.css
   studio.ycygame.org · 纯静态 · 无外部依赖 · 无 @import · 无网络字体
   CSP: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'

   变量层与主站（apps/web/public/style.css）逐字一致 —— 两个站看上去必须是一套东西。
   组件层只保留工坊真正用得到的那些，另加接线编辑器专用的几组。

   一条贯穿全文件的规矩：**间距一律用类，不写行内 style**。
   唯一由 JS 写的样式是 .split 上的 --aside-w（用户拖出来的栏宽），
   它是数据不是装饰，CSS 类表达不了。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 变量层
   -------------------------------------------------------------------------- */
:root {
  /* 背景与面板 */
  --bg: #0b0d12;
  --bg-deep: #07080c;
  --panel: #12151d;
  --panel-2: #171b26;
  --panel-3: #1c2130;
  --code-bg: #0f1219;

  /* 描边 */
  --line: #1e2330;
  --line-strong: #2b3346;
  --line-focus: #3a4256;

  /* 文字 */
  --fg: #dfe3ec;
  --fg-dim: #aab2c4;
  --muted: #8b93a7;
  --muted-2: #697083;

  /* 强调 */
  --accent: #5b8cff;
  --accent-hi: #8fb0ff;
  --accent-press: #4a78e0;
  --accent-soft: rgba(91, 140, 255, 0.12);
  --accent-line: rgba(91, 140, 255, 0.42);
  --accent-glow: rgba(91, 140, 255, 0.26);

  /* 本机边界 */
  --local: #2ee6a8;
  --local-soft: rgba(46, 230, 168, 0.06);
  --local-line: rgba(46, 230, 168, 0.34);

  /* 信号语义色 */
  --sig-event: #5b8cff;
  --sig-gate: #ffd479;
  --sig-gate-soft: rgba(255, 212, 121, 0.14);
  --sig-wave: #35d0ba;
  --sig-wave-soft: rgba(53, 208, 186, 0.12);
  --sig-cloud: #a78bfa;

  /* 危险 */
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.08);
  --danger-line: rgba(255, 107, 107, 0.28);

  /* 设备族 */
  --fam-ems: #5b8cff;
  --fam-cup: #35d0ba;
  --fam-enema-v1: #ffd479;
  --fam-enema-v2: #a78bfa;

  /* 装饰 */
  --grid-line: rgba(91, 140, 255, 0.055);
  --grad-flow: linear-gradient(90deg, #5b8cff 0%, #8b7bff 100%);
  --grad-hairline: linear-gradient(90deg, transparent, rgba(91, 140, 255, .35), transparent);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow-lift: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.55);

  /* 圆角 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* 字体 */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Noto Sans Mono", monospace;

  /* 动效 */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 180ms;
  --dur-slow: 260ms;

  /* 字号刻度 */
  --t-display: clamp(30px, 5.2vw, 54px);
  --t-h1: 28px;
  --t-h2: 22px;
  --t-h3: 15px;
  --t-body: 15px;
  --t-lead: 16.5px;
  --t-sm: 13.5px;
  --t-xs: 12.5px;
  --t-label: 11.5px;
  --t-mono: 13px;
  --t-metric: clamp(28px, 3.4vw, 40px);
  --t-micro: 12px;

  /* 间距刻度：4 / 8 / 12 / 16 / 24 / 32 / 48 / 72 / 96 */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 72px;
  --s-9: 96px;

  /* 几何 */
  --header-h: 56px;
  /* 两栏编辑器左栏宽度。JS 会覆盖它 —— 见 common.js 的 splitPane */
  --aside-w: 320px;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. Reset 与基座
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  font-weight: 400;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

body.is-drawer-open { overflow: hidden; }

h1, h2, h3, h4, p, figure, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }

h1 { font-size: var(--t-h1); line-height: 1.28; font-weight: 650; letter-spacing: -0.015em; }
h2 { font-size: var(--t-h2); line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: var(--t-h3); line-height: 1.5; font-weight: 600; }

img, svg, video { max-width: 100%; }
img, video { height: auto; display: block; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button[disabled] { cursor: not-allowed; }

:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--line-focus); }

/* --------------------------------------------------------------------------
   3. 排版工具
   -------------------------------------------------------------------------- */
/* 主站里 .t-h1/.t-h2/.t-h3 是有人写没人定义的空类（<div class="t-h3"> 渲染出来是正文大小）。
   这里把它们真的定义出来 —— 同样的类名在两个站给出同样的结果，才叫约定。 */
.t-h1 { font-size: var(--t-h1); line-height: 1.28; font-weight: 650; letter-spacing: -0.015em; }
.t-h2 { font-size: var(--t-h2); line-height: 1.35; font-weight: 650; letter-spacing: -0.01em; }
.t-h3 { font-size: var(--t-h3); line-height: 1.5; font-weight: 600; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.t-display { font-size: var(--t-display); line-height: 1.12; font-weight: 650; letter-spacing: -0.02em; }
.t-lead { font-size: var(--t-lead); color: var(--fg-dim); max-width: 62ch; }
.t-sm { font-size: var(--t-sm); color: var(--muted); }
.t-xs { font-size: var(--t-xs); color: var(--muted); }
.t-micro { font-size: var(--t-micro); color: var(--muted-2); }
.t-label { font-size: var(--t-label); font-weight: 600; letter-spacing: .10em; color: var(--muted-2); }
.t-metric { font-family: var(--font-mono); font-size: var(--t-metric); font-weight: 650; color: var(--fg); font-variant-numeric: tabular-nums; }

.prose { max-width: 68ch; color: var(--fg-dim); }
.prose a,
.link-under { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--accent-line); }
.prose a:hover,
.link-under:hover { text-decoration-color: var(--accent); }

.clamp-1, .clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; }

.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   4. 版面
   -------------------------------------------------------------------------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 var(--s-5); }
.wrap.narrow { max-width: 900px; }
.wrap.mid { max-width: 1080px; }
.wrap.wide { max-width: 1440px; }

.sec { padding: var(--s-8) 0; }
.sec + .sec { padding-top: 0; }

.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap;
}
.sec-head .more { font-size: var(--t-sm); color: var(--muted); display: inline-flex; align-items: center; gap: var(--s-1); }
.sec-head .more:hover { color: var(--accent-hi); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-4); }
.hairline { height: 1px; background: var(--grad-hairline); border: 0; }

.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.grow { flex: 1 1 auto; min-width: 0; }

/* --------------------------------------------------------------------------
   5. 两栏编辑器
   左边是模块（事件与设备动作），右边是正在接的那张线。
   中间那条能拖，宽度记在本机 —— 每个人对「左边要多宽」的答案都不一样。
   -------------------------------------------------------------------------- */
.split {
  display: grid;
  grid-template-columns: var(--aside-w) 7px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  min-height: calc(100vh - var(--header-h) - 120px); min-height: calc(100dvh - var(--header-h) - 120px);
}

.split-aside {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.split-main {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.split-bar {
  cursor: col-resize;
  background: var(--line);
  position: relative;
  touch-action: none;
}
.split-bar::after {
  content: "";
  position: absolute; inset: 0 -4px;
}
.split-bar:hover,
.split-bar:focus-visible { background: var(--accent-line); }

/* 面板内部的三段式：头 / 可滚动的身体 / 脚 */
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex: 0 0 auto;
}
.pane-body { flex: 1 1 auto; overflow: auto; padding: var(--s-4); }
.pane-foot {
  flex: 0 0 auto; padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line); background: var(--panel-2);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   6. 按钮
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 42px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 9px;
  font-size: 14.5px; font-weight: 600; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn-primary { background: var(--accent); color: #0b0d12; }
.btn-primary:hover { background: var(--accent-hi); box-shadow: 0 6px 20px var(--accent-glow); transform: translateY(-1px); }
.btn-primary:active { background: var(--accent-press); transform: none; }

.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); font-weight: 400; }
.btn-ghost:hover { border-color: var(--accent-line); background: var(--accent-soft); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-line); font-weight: 500; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 34px; padding: 0 14px; font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn[disabled],
.btn.is-loading { opacity: .72; transform: none; box-shadow: none; }

.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }

.icon-btn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); color: var(--muted); border: 1px solid transparent;
}
.icon-btn:hover { color: var(--fg); background: var(--panel-3); border-color: var(--line); }
.icon-btn.is-ok { color: var(--sig-wave); }
.icon-btn svg { width: 14px; height: 14px; }

.spinner { animation: spin 800ms linear infinite; }
.spinner circle { stroke: currentColor; stroke-width: 2; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   7. 标记
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 4px 8px; border-radius: var(--r-sm);
  border: 1px solid var(--line); color: var(--muted);
  font-size: var(--t-label); white-space: nowrap;
}
.chip-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.chip-blue { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip-wave { color: var(--sig-wave); border-color: rgba(53, 208, 186, .34); background: var(--sig-wave-soft); }
.chip-amber { color: var(--sig-gate); border-color: rgba(255, 212, 121, .34); background: var(--sig-gate-soft); }

.eyebrow-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--code-bg); border: 1px solid var(--line);
  font-family: var(--font-mono); font-size: var(--t-micro); color: var(--muted);
}

.dot-live { width: 5px; height: 5px; border-radius: 50%; background: var(--local); animation: breathe 2.4s var(--ease) infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.badge-18 {
  font-family: var(--font-mono); font-size: var(--t-micro);
  padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); color: var(--muted);
}

/* 风险等级。文案见 common.js 的 RISK_LABELS，别在别处另起一套说法。 */
.risk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-label); padding: 3px 9px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.risk::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.risk-none { color: var(--local); }
.risk-caution { color: var(--sig-gate); }
.risk-high { color: var(--danger); }
.risk-undeclared { color: var(--muted); }

/* 设备标签：颜色由 DEVICE_COLOR 决定，写成三条而不是行内色值 */
.dev-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-label); padding: 3px 9px;
  border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--muted);
}
.dev-tag svg { width: 13px; height: 13px; }
.dev-tag[data-device="ems"] { color: var(--fam-ems); border-color: rgba(91, 140, 255, .32); }
.dev-tag[data-device="cup"] { color: var(--fam-cup); border-color: rgba(53, 208, 186, .32); }
.dev-tag[data-device="enema"] { color: var(--fam-enema-v1); border-color: rgba(255, 212, 121, .32); }

/* --------------------------------------------------------------------------
   8. 卡片
   -------------------------------------------------------------------------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  padding: var(--s-4);
}
.card-link { display: block; color: inherit; }
.card-link:hover { border-color: var(--accent-line); }

/* ---- 规则卡：一条「什么时候 → 做什么」 ---- */
.rule-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  overflow: hidden;
}
.rule-card + .rule-card { margin-top: var(--s-3); }
.rule-card.is-off { opacity: .55; }
.rule-card.is-invalid { border-color: var(--danger-line); }
.rule-card.is-dragging { border-color: var(--accent-line); box-shadow: var(--shadow-lift); }

.rule-head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line); background: var(--panel-3);
}
.rule-grip {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); color: var(--muted-2); cursor: grab; touch-action: none;
}
.rule-grip:hover { color: var(--fg-dim); background: var(--panel); }
.rule-grip:active { cursor: grabbing; }
.rule-name { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: var(--t-sm); }
.rule-num { font-family: var(--font-mono); font-size: var(--t-micro); color: var(--muted-2); }

.rule-body { padding: var(--s-3); display: grid; gap: var(--s-3); }
.rule-when, .rule-then {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel); padding: var(--s-3);
}
.rule-when { border-left: 3px solid var(--sig-event); }
.rule-then { border-left: 3px solid var(--sig-wave); }
.rule-arrow { display: flex; align-items: center; justify-content: center; color: var(--muted-2); }
.rule-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-top: 1px solid var(--line); flex-wrap: wrap;
}

/* ---- 动作卡：规则里的一个设备动作 ---- */
.act-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel-2); }
.act-card + .act-card { margin-top: var(--s-2); }
.act-head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line);
}
.act-title { flex: 1 1 auto; min-width: 0; font-size: var(--t-sm); }
.act-params { padding: var(--s-3); display: grid; gap: var(--s-4); }
.act-summary { padding: 0 var(--s-3) var(--s-3); font-size: var(--t-xs); color: var(--muted); }

/* ---- 事件清单：左栏那些「模块」 ---- */
.ev-list { display: flex; flex-direction: column; gap: 2px; }
.ev-item {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; text-align: left;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  border: 1px solid transparent; color: var(--fg-dim);
}
.ev-item:hover { background: var(--panel-3); border-color: var(--line); color: var(--fg); }
.ev-item.is-used { border-color: var(--accent-line); background: var(--accent-soft); }
.ev-name { flex: 1 1 auto; min-width: 0; font-size: var(--t-sm); }
.ev-key { font-family: var(--font-mono); font-size: var(--t-micro); color: var(--muted-2); }

/*
 * 「通用」角标。
 *
 * 做得很轻是有意的：接哪个键这件事默认已经替用户选对了，角标只是让好奇的人
 * 能看出区别、悬停能看到解释。做成醒目的彩色标签会把一个用户不需要做的决定
 * 摆到他面前，逼他去理解「通用事件」是什么。
 */
.ev-tag {
  flex: 0 0 auto;
  font-size: var(--t-micro);
  line-height: 1;
  padding: 2px 5px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  color: var(--muted-2);
  white-space: nowrap;
}
.ev-item:hover .ev-tag { border-color: var(--line-strong); color: var(--muted); }
.ev-count {
  font-family: var(--font-mono); font-size: var(--t-micro); color: var(--accent);
  min-width: 18px; text-align: right;
}
.ev-group { margin-bottom: var(--s-4); }
.ev-group > h3 { margin-bottom: var(--s-2); }

/* ---- 设备动作面板 ---- */
.dev-palette { display: grid; gap: var(--s-3); }
.dev-group { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.dev-group > h3 {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); background: var(--panel-3); border-bottom: 1px solid var(--line);
}
.dev-actions { display: flex; flex-direction: column; }
.dev-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: var(--s-2) var(--s-3); border: 0; border-top: 1px solid var(--line);
}
.dev-actions .dev-action:first-child { border-top: 0; }
.dev-action:hover { background: var(--panel-3); }
.dev-action b { font-size: var(--t-sm); font-weight: 600; }
.dev-action span { font-size: var(--t-xs); color: var(--muted); }
.dev-action .req { font-size: var(--t-label); color: var(--sig-gate); }

/* --------------------------------------------------------------------------
   9. 控件
   -------------------------------------------------------------------------- */

/* ---- 分段选择器。选中态是 aria-checked，状态只有一处真相，读屏器也能读到。
        [aria-selected] 一并支持，是为了照顾按主站旧约定手写的标记。 ---- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--r-md);
  max-width: 100%; overflow-x: auto;
}
.seg-btn {
  padding: 5px 13px; border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--muted); white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--fg-dim); }
.seg-btn[aria-checked="true"],
.seg-btn[aria-selected="true"] { background: var(--panel-3); color: var(--fg); box-shadow: var(--shadow-card); }
.seg.is-disabled { opacity: .55; }

/* ---- 滑杆。读数永远在，不用松手才知道自己调到了几。 ---- */
.sl { display: grid; gap: var(--s-2); }
.sl-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.sl-label { font-size: var(--t-sm); color: var(--fg-dim); }
.sl-out {
  font-size: var(--t-sm); color: var(--fg); font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sl-row { display: flex; align-items: center; gap: var(--s-3); }

.sl-range {
  flex: 1 1 auto; min-width: 0; height: 24px;
  accent-color: var(--accent);
  background: transparent; cursor: pointer;
}
.sl-range:disabled { cursor: not-allowed; }

.sl-num {
  flex: 0 0 78px; width: 78px; height: 32px; padding: 0 var(--s-2);
  background: var(--code-bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: var(--t-sm); text-align: right; font-variant-numeric: tabular-nums;
}
.sl-num:focus-visible { border-color: var(--accent-line); }

.sl-hint { color: var(--muted-2); }
.sl-cap { color: var(--sig-gate); }
.sl.is-capped .sl-out { color: var(--sig-gate); }
.sl.is-disabled { opacity: .55; }

/* ---- 试一下。它会让真的设备动起来，所以三态必须分得清清楚楚。 ---- */
.try { display: inline-flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.try-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  font-size: var(--t-sm); color: var(--fg-dim);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.try-btn:hover:not([disabled]) { color: var(--fg); border-color: var(--accent-line); background: var(--accent-soft); }
.try-btn[disabled] { opacity: .6; }
.try-btn.is-ok { color: var(--local); border-color: var(--local-line); background: var(--local-soft); }
.try-btn.is-fail { color: var(--danger); border-color: var(--danger-line); }
.try-note { font-size: var(--t-xs); color: var(--danger); }

/* ---- 表单行 ---- */
.filters {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  align-items: center; margin-bottom: var(--s-5);
}
.filters .grow { flex: 1 1 240px; min-width: 200px; }

.field { display: grid; gap: var(--s-2); }
.field > label { font-size: var(--t-sm); color: var(--fg-dim); }
.field > .t-xs { color: var(--muted-2); }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; height: 40px; padding: 0 var(--s-3);
  background: var(--code-bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { height: auto; min-height: 96px; padding: var(--s-2) var(--s-3); line-height: 1.7; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select { appearance: none; padding-right: var(--s-6); cursor: pointer; }
.select-wrap { position: relative; }
.select-wrap .chev { position: absolute; right: var(--s-3); top: 50%; margin-top: -5px; color: var(--muted); pointer-events: none; }

/* 排序中的容器：拖动时把整列的过渡关掉，否则节点换位会拖出一串残影 */
.is-reordering * { transition: none !important; }

/* --------------------------------------------------------------------------
   10. 状态
   -------------------------------------------------------------------------- */
.skeleton {
  position: relative; overflow: hidden; min-height: 96px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-4); display: grid; gap: var(--s-2); align-content: start;
}
.skeleton + .skeleton { margin-top: var(--s-3); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .04), transparent);
  animation: sh 1.4s var(--ease) infinite;
}
@keyframes sh { to { transform: translateX(100%); } }
.sk-bar { background: var(--panel-3); border-radius: var(--r-sm); }
.sk-bar.h14 { height: 14px; }
.sk-bar.h12 { height: 12px; }
.sk-bar.w60 { width: 60%; }
.sk-bar.w100 { width: 100%; }
.sk-bar.w40 { width: 40%; }

.empty {
  grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center;
  text-align: center; max-width: 460px; margin: 0 auto; padding: var(--s-8) var(--s-5); gap: var(--s-3);
}
.empty .vis svg { width: 96px; height: 96px; color: var(--muted-2); }
.empty h3 { font-size: 18px; }
.empty p { max-width: 34ch; font-size: var(--t-sm); color: var(--muted); }
.empty .btn-row { justify-content: center; }
.empty .kw { color: var(--fg); font-weight: 600; }
.empty--light { padding: 56px var(--s-5); }
.empty--light .vis svg { width: 40px; height: 40px; }
.empty--light h3 { font-size: var(--t-h3); }
.empty--compact { padding: 40px var(--s-5); min-height: 240px; justify-content: center; }
.empty--compact .vis svg { width: 64px; height: 64px; }

.error {
  grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--s-3);
  border-left: 3px solid var(--danger); background: var(--danger-soft);
  border-radius: var(--r-lg); padding: var(--s-5);
}
.error .vis svg { width: 40px; height: 40px; }
.error .code {
  font-family: var(--font-mono); font-size: var(--t-micro); color: var(--muted);
  word-break: break-all; background: var(--code-bg); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
}
.error p { max-width: 48ch; font-size: var(--t-sm); color: var(--fg-dim); }
.retry-note { font-size: var(--t-micro); color: var(--muted-2); }

/* ---- 问题清单。错误和建议共用一个渲染器，差别只有颜色。 ---- */
.issues { border-radius: var(--r-lg); padding: var(--s-4); border: 1px solid var(--line); }
.issues--error { border-left: 3px solid var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.issues--note { border-left: 3px solid var(--sig-gate); background: var(--sig-gate-soft); border-color: rgba(255, 212, 121, .28); }
.issues-head { font-size: var(--t-sm); margin-bottom: var(--s-3); }
.issues--error .issues-head { color: var(--danger); }
.issues--note .issues-head { color: var(--sig-gate); }

.issue-items { display: grid; gap: 2px; }
.issue-item { border-radius: var(--r-sm); }
.issue-body,
.issue-jump {
  display: block; width: 100%; text-align: left;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  font-size: var(--t-sm); line-height: 1.6; color: var(--fg-dim);
}
.issue-jump:hover { background: rgba(255, 255, 255, .04); color: var(--fg); }
.issue-where { display: block; font-size: var(--t-xs); color: var(--muted); font-weight: 600; }
.issue-msg { display: block; }

/* --------------------------------------------------------------------------
   11. 页头
   -------------------------------------------------------------------------- */
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: var(--s-2) var(--s-4); background: var(--accent); color: #0b0d12; border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus { left: 0; }

#top-sentinel { position: absolute; top: 0; height: 1px; width: 1px; }

#site-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
#site-header.is-stuck {
  background: rgba(11, 13, 18, .80);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom-color: var(--line);
}

.bar { height: var(--header-h); display: flex; align-items: center; gap: var(--s-5); }

.brand { display: inline-flex; align-items: center; gap: var(--s-2); flex: 0 0 auto; }
.brand b { font-weight: 650; letter-spacing: -0.01em; }
.brand span { font-size: var(--t-xs); color: var(--muted-2); }
.mark-svg { flex: 0 0 auto; }

.nav-main { display: flex; align-items: center; gap: var(--s-4); flex: 1 1 auto; min-width: 0; }
.nav-main a {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-sm); color: var(--muted); position: relative; padding: 4px 0;
}
.nav-main a:hover { color: var(--fg); }
.nav-main a.is-current { color: var(--fg); }
.nav-main a.is-current::after {
  content: ""; position: absolute; left: 0; bottom: -2px; width: 16px; height: 2px;
  background: var(--accent); border-radius: var(--r-pill);
}
.ext-arr { color: var(--muted-2); transition: transform var(--dur) var(--ease); }
a:hover > .ext-arr { transform: translate(1px, -1px); color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: var(--s-3); flex: 0 0 auto; margin-left: auto; }
.nav-account { position: relative; }

.acct-btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 10px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); color: var(--fg-dim);
}
.acct-btn:hover { border-color: var(--accent-line); }
.acct-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.chev { transition: transform var(--dur) var(--ease); }
.acct-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--t-micro); font-weight: 700;
}
.acct-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-sm); }

.acct-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 180px;
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: var(--s-1); display: grid; gap: 1px;
}
.acct-item {
  display: flex; align-items: center; gap: var(--s-2); width: 100%; text-align: left;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-size: var(--t-sm); color: var(--fg-dim);
}
.acct-item:hover { background: var(--panel-3); color: var(--fg); }

#nav-toggle { display: none; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: var(--r-sm); color: var(--fg-dim); }
.hb-line { stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

#nav-drawer {
  border-bottom: 1px solid var(--line); background: var(--panel);
  padding: var(--s-4) var(--s-5); display: grid; gap: var(--s-5);
}
.drawer-group > h3 { color: var(--muted-2); font-size: var(--t-label); letter-spacing: .10em; margin-bottom: var(--s-2); }
.drawer-item {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) 0; color: var(--fg-dim); font-size: var(--t-sm);
}
.drawer-item.is-current { color: var(--accent); }

/* --------------------------------------------------------------------------
   12. 页脚
   -------------------------------------------------------------------------- */
.foot { border-top: 1px solid var(--line); margin-top: var(--s-9); padding: var(--s-7) 0 var(--s-5); background: linear-gradient(180deg, var(--bg), var(--bg-deep)); }
.foot-grid { display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(128px, 1fr)); gap: var(--s-5); }
.foot-brand-row { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); }
.foot-claim { font-size: var(--t-sm); color: var(--muted); max-width: 40ch; }
.foot-col > details > summary { list-style: none; cursor: pointer; margin-bottom: var(--s-2); }
.foot-col > details > summary::-webkit-details-marker { display: none; }
.foot-col h3 { color: var(--muted-2); font-size: var(--t-label); letter-spacing: .10em; }
.foot-link {
  display: flex; align-items: center; gap: var(--s-1);
  padding: 3px 0; font-size: var(--t-sm); color: var(--muted);
  transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.foot-link:hover { color: var(--fg); transform: translateX(3px); }
.foot-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
  margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--line);
  font-size: var(--t-xs); color: var(--muted-2);
}
.foot-bottom .right { display: inline-flex; align-items: center; gap: var(--s-2); }

/* --------------------------------------------------------------------------
   13. 浮层
   -------------------------------------------------------------------------- */
.toast-host {
  position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%);
  z-index: 90; display: grid; gap: var(--s-2); pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-pill);
  background: var(--panel-2); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop); font-size: var(--t-sm); color: var(--fg);
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast svg { color: var(--local); }
.toast--error { border-color: var(--danger-line); }
.toast--error svg { color: var(--danger); }

dialog.modal {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  background: var(--panel); color: var(--fg); padding: 0; box-shadow: var(--shadow-pop);
}
dialog.modal::backdrop { background: rgba(4, 6, 10, .72); backdrop-filter: blur(3px); }
.modal-head { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.modal-body { padding: var(--s-4) var(--s-5); font-size: var(--t-sm); color: var(--fg-dim); display: grid; gap: var(--s-3); }
.modal-body b { color: var(--fg); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--s-3);
  padding: var(--s-3) var(--s-5) var(--s-4); border-top: 1px solid var(--line);
}
.modal-foot .btn:disabled { opacity: .45; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   14. 间距工具
   CSP 下不写行内 style，间距一律走类。就这几个，不要再加。
   -------------------------------------------------------------------------- */
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; }
.my-0 { margin-top: 0; margin-bottom: 0; }

/* --------------------------------------------------------------------------
   15. 断点
   -------------------------------------------------------------------------- */
@media (max-width: 1099px) {
  .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  /* 两栏塌成上下两段。拖动条在这个宽度下没有意义，直接收起来。 */
  .split { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .split-bar { display: none; }
  .split-aside { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 320px; }
  .split-main { border-left: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
}

@media (max-width: 860px) {
  .nav-main { display: none; }
  #nav-toggle { display: inline-flex; }
}

@media (max-width: 767px) {
  .wrap { padding: 0 20px; }
  .card-grid { grid-template-columns: 1fr; }
  .sec { padding: var(--s-7) 0; }
}

@media (max-width: 720px) {
  .acct-name { display: none; }
  .foot-grid { grid-template-columns: 1fr; gap: var(--s-4); }
  .foot-col > details > summary { pointer-events: auto; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 var(--s-4); }
  .sl-row { flex-wrap: wrap; }
  .sl-num { flex: 0 0 100%; width: 100%; text-align: left; }
}

@media (max-width: 420px) {
  .brand span { display: none; }
}

/* 宽屏上 summary 不可点：页脚各栏必须永远展开，收起来就再也打不开了 */
@media (min-width: 721px) {
  .foot-col > details > summary { pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .skeleton::after { display: none; }
  .btn-primary:hover { transform: none; }
  .foot-link:hover { transform: none; }
}

@media print {
  #site-header, #nav-drawer, .toast-host, .split-bar { display: none; }
}


/* ==========================================================================
   响应式加固 —— 手机 / 平板 / 各种比例

   这一段处理的不是「小屏幕」，是**各种比例**：

     · 刘海屏 / 挖孔屏   横过来时屏幕左右各有一条被摄像头和圆角吃掉的区域，
                         底部还有一条手势条。内容得从那几条里让开。
     · 手机横屏           可视高度只剩 360–430px。按竖屏那套纵向留白排，
                         一屏就只剩两行正文，粘顶栏还要再吃掉 14%。
     · 平板竖屏           768–1024 宽。按手机排是浪费，按桌面排又挤。
     · 折叠屏 / 分屏      宽高比什么都可能。所以断点按内容排不下的位置给，
                         不按机型给。
     · 地址栏收放         100vh 在手机上把被收起的那条地址栏也算了进去，
                         底部会被截掉一截。用 dvh。
     · 手指不是鼠标       点击目标 44px；输入框字号必须 ≥16px ——
                         小于 16px 时 iOS 聚焦会把整页放大，而且不会缩回去。
   ========================================================================== */

:root { --edge-x: var(--s-5); }

/* --- 安全区 --------------------------------------------------------------
   viewport-fit=cover 让页面铺满整块屏幕，代价是我们自己得让开那几条。
   用 max() 而不是加法：没有安全区的设备上它就等于原来的边距。 */
@supports (padding: max(0px)) {
  .wrap {
    padding-left: max(var(--edge-x), env(safe-area-inset-left));
    padding-right: max(var(--edge-x), env(safe-area-inset-right));
  }
  body { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* --- 长串不许把版面撑开 --------------------------------------------------
   哈希、事件键、包名都是不带空格的长串。一个 64 位哈希就能把整页顶出
   横向滚动条，而横向滚动条在手机上是找不回来的 —— 用户只会觉得页面坏了。 */
pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
code, kbd, samp { overflow-wrap: anywhere; }
.tbl-scroll, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
img, svg, video, canvas { max-width: 100%; }

/* --- 手指不是鼠标 -------------------------------------------------------- */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm,
  .seg button,
  .pager button,
  .sidenav-item,
  .nav-main a,
  .tab,
  .who-item { min-height: 40px; }
  /* < 16px 时 iOS 一聚焦就把整页放大，而且不会自己缩回去 */
  input, select, textarea { font-size: max(16px, var(--t-sm)); }
  /* 悬停态在触屏上会「粘住」—— 手指点完抬起来，卡片还留在 hover 的样子 */
  .p-card:hover, .mini-card:hover { transform: none; }
}

/* --- 手机横屏：可视高度只剩 360–430px ------------------------------------ */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --header-h: 46px; }
  .sec { padding: var(--s-6) 0; }
  .sec + .sec { padding-top: 0; }
  .t-display { font-size: clamp(22px, 5.4vh, 34px); }
  /* 粘顶栏在 400px 高的屏上要吃掉 14% 的可视面积，这里让它跟着走 */
  #site-header, .acct-header, .topbar, .sidenav { position: static; }
  .console { padding-top: var(--s-4); }
}

/* --- 平板竖屏 768–1024 ---------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) {
  .card-grid, .p-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .console { grid-template-columns: 196px minmax(0, 1fr); gap: var(--s-5); }
}

/* --- 侧栏在窄屏上不再是一栏，而是一条可横滑的标签 ------------------------ */
@media (max-width: 860px) {
  .console { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .sidenav { position: static; }
  .sidenav-list {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
    gap: var(--s-1);
    padding-bottom: 2px;
  }
  .sidenav-list::-webkit-scrollbar { display: none; }
  .sidenav-item {
    border-left: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .sidenav-item.is-current { border-left-color: transparent; border-bottom-color: var(--accent); }
}

/* --- 弹窗在小屏上是底部抽屉 ----------------------------------------------
   520px 宽的居中卡片在 375px 的手机上四周只剩 16px，按钮还够不着拇指。
   底部抽屉是手机上大家都认的形状。 */
@media (max-width: 560px) {
  dialog.modal {
    width: 100%;
    max-width: 100%;
    margin: auto auto 0;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    max-height: 88dvh;
    overflow-y: auto;
  }
  .modal-foot {
    position: sticky;
    bottom: 0;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .modal-foot .btn { flex: 1 1 140px; justify-content: center; }
  .hide-sm { display: none !important; }
}

/* --- 极窄：≤360px（SE / 折叠屏合起来 / 分屏三分之一） --------------------- */
@media (max-width: 360px) {
  :root { --t-h1: 24px; --t-h2: 19px; --edge-x: 14px; }
  .btn { padding-left: 12px; padding-right: 12px; }
  .btn-row { gap: var(--s-2); }
}

/* --- 页脚这一片的点击目标（实测补的） ---------------------------------------
   页脚链接普遍只有 22–30px 高，可折叠分组的 summary 只有 17px。
   桌面上鼠标点得准，手指点不准 —— 而页脚恰恰是「条款」「隐私」「状态页」
   这些出问题时才会去找的入口，点不中的代价比别处更大。 */
@media (pointer: coarse) {
  .foot-link,
  .foot-col a,
  .foot-bottom a,
  .foot-links a,
  .crumb a,
  .brand,
  .side-brand {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .foot details > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  /* 面包屑那一行本来就是一行文字，撑高之后不该把上下推开 */
  .crumb { align-items: center; }
}

/* 手机上的汉堡菜单是唯一的导航入口，34px 点不准。 */
@media (pointer: coarse) {
  #nav-toggle, .nav-toggle, .who-btn, .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* --------------------------------------------------------------------------
   强度跟随

   这一块之前根本不存在，而缺了它的后果不是「少一个开关」：不开跟随的语义是
   每次都用声明值，声明值又正是这条规则的最大值。也就是说工坊拼出来的规则
   以前只有一档 —— 最狠的那一档。所以它在动作卡里要显眼，不能收进折叠区。
   -------------------------------------------------------------------------- */
.scale-box {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--code-bg);
}
.scale-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.scale-toggle input {
  margin: 3px 0 0;
  width: 15px; height: 15px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
.scale-toggle b { display: block; font-weight: 600; font-size: var(--t-sm); }
.scale-hint {
  display: block;
  margin-top: 3px;
  font-size: var(--t-xs);
  line-height: 1.6;
  color: var(--muted);
}
.scale-more {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.scale-curve { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.scale-curve-lb { font-size: var(--t-sm); color: var(--muted); flex: 0 0 auto; }
.scale-curve .scale-hint { flex: 1 1 100%; margin-top: 0; }
