/* ============================================================
   RegexMate — "Signal Box" 铁路信号房风 / 浅色宽幅
   设计隐喻：正则可视化经典形式即铁路图（Railroad Diagram），
   整站做成信号调度室：奶油纸底 + 网格坐标纸 + 铁轨墨 × 信号铜。
   字体：Zilla Slab（展示衬线）+ Public Sans（正文）+ Spline Sans Mono（代码）。
   ============================================================ */

:root {
  --paper: #faf7f0;
  --paper-2: #f2ecdf;
  --surface: #fffef9;
  --surface-2: #f5f1e6;
  --ink: #22333b;
  --ink-soft: #5c6b73;
  --ink-faint: #8a959c;

  --accent: #bc6c25;          /* 信号铜 */
  --accent-deep: #9c5619;
  --accent-soft: rgba(188, 108, 37, .12);
  --rail: #22333b;            /* 轨道墨 */
  --ok: #3a5a40;              /* 通过信号绿 */
  --ok-soft: rgba(58, 90, 64, .10);
  --amber: #e09f3e;
  --err: #9e2a2b;
  --err-soft: rgba(158, 42, 43, .08);

  --line: #e2dbca;
  --line-2: #cec5ae;
  --grid: rgba(34, 51, 59, .05);
  --grid-strong: rgba(34, 51, 59, .085);

  --radius: 14px;
  --radius-sm: 9px;
  --max-width: 1440px;
  --mono: "Spline Sans Mono", "SF Mono", Consolas, monospace;
  --sans: "Public Sans", "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  --display: "Zilla Slab", Georgia, serif;

  --shadow-sm: 0 1px 2px rgba(34, 51, 59, .06), 0 4px 12px rgba(34, 51, 59, .05);
  --shadow-md: 0 2px 6px rgba(34, 51, 59, .07), 0 18px 40px rgba(34, 51, 59, .10);
  --shadow-lg: 0 4px 12px rgba(34, 51, 59, .08), 0 30px 70px rgba(34, 51, 59, .15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.7;
  font-size: 16px;
  position: relative;
  background: var(--paper);
}

/* 坐标网格纸底纹 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px;
  mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,.9), rgba(0,0,0,.35) 60%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,.9), rgba(0,0,0,.35) 60%, transparent 100%);
}

main, .site-header, .site-footer { position: relative; z-index: 1; }

::selection { background: var(--accent-soft); color: var(--ink); }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { color: var(--accent); }

.inner { max-width: var(--max-width); margin: 0 auto; padding: 0 28px; }

/* ============================================================
   两侧信号房坐标装饰条（≥1420px 显示）
   ============================================================ */
.side-rail {
  position: fixed; top: 0; bottom: 0; width: 60px; z-index: 40;
  display: none; flex-direction: column; align-items: center;
  justify-content: space-between; padding: 120px 0 42px;
  pointer-events: none; user-select: none;
}
@media (min-width: 1420px) {
  .side-rail { display: flex; }
  .rail-left  { left: 0;  border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(58,90,64,.06), transparent 30%, transparent 70%, rgba(58,90,64,.06)); }
  .rail-right { right: 0; border-left: 1px solid var(--line); background: linear-gradient(180deg, rgba(188,108,37,.06), transparent 30%, transparent 70%, rgba(188,108,37,.06)); }
}
.rail-coord { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; color: var(--ink-faint); writing-mode: vertical-rl; }
.rail-glyph { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); writing-mode: vertical-rl; }
.rail-mark {
  font-family: var(--mono); font-size: 9px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--ink-faint); writing-mode: vertical-rl; text-orientation: mixed; padding: 10px 0; opacity: .65;
}

/* ============================================================
   报头
   ============================================================ */
.site-header {
  background: rgba(250, 247, 240, .85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 66px; }
.logo { display: flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; color: var(--ink); }
.logo:hover { color: var(--accent-deep); }
.logo-img { width: 38px; height: 38px; display: block; }
.logo .mate-tag {
  font-family: var(--mono); font-size: .6rem; font-weight: 700; letter-spacing: .12em;
  color: #fff; background: var(--accent); padding: 2px 6px; border-radius: 5px;
  transform: translateY(1px);
}
.nav-links { display: flex; gap: 2px; list-style: none; }
.nav-links a {
  display: block; padding: 7px 14px; font-size: .82rem; font-weight: 600;
  color: var(--ink-soft); border-radius: 8px; transition: background .15s, color .15s;
}
.nav-links a:hover { color: var(--accent-deep); background: var(--accent-soft); }

.menu-btn {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; padding: 0;
}
.menu-btn .bar { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: all .2s; }
.menu-btn[aria-expanded="true"] .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] .bar:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   Hero（左文案 + 右铁路图装饰）
   ============================================================ */
.hero { padding: 72px 0 30px; }
.hero .inner { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: .7rem; font-weight: 600;
  letter-spacing: .24em; text-transform: uppercase; color: var(--accent-deep);
  margin-bottom: 20px; animation: rise .5s ease both;
}
.eyebrow::before { content: ""; width: 26px; height: 2px; background: var(--accent); border-radius: 2px; }
.hero h1 {
  font-family: var(--display); font-weight: 700; font-size: clamp(2.5rem, 5.4vw, 4.1rem);
  line-height: 1.06; letter-spacing: -.01em; color: var(--ink);
  max-width: 640px; animation: rise .55s .06s ease both;
}
.hero h1 em {
  font-style: italic; color: var(--accent);
  text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 8px; text-decoration-color: rgba(188, 108, 37, .35);
}
.lead {
  color: var(--ink-soft); font-size: 1.06rem; max-width: 580px;
  margin: 24px 0 0; animation: rise .55s .12s ease both;
}
.hero-trust { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 26px; list-style: none; animation: rise .55s .18s ease both; }
.hero-trust li { display: flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; color: var(--ink-soft); }
.hero-trust li svg { width: 16px; height: 16px; flex: none; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.hero-map { animation: rise .6s .2s ease both; }
.hero-map svg { width: 100%; height: auto; display: block; }
.dash-move { stroke-dashoffset: 128; animation: dashmove 6s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: 0; } }

/* ============================================================
   信号台（Workspace）
   ============================================================ */
.tool-section { padding: 34px 0 20px; }
.workspace {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise .6s .24s ease both;
}

.win-chrome {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 18px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.win-dots { display: flex; gap: 7px; }
.win-dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.win-dots i:nth-child(1) { background: #9e2a2b; }
.win-dots i:nth-child(2) { background: var(--amber); }
.win-dots i:nth-child(3) { background: var(--ok); }
.win-title { font-family: var(--mono); font-size: .74rem; color: var(--ink-faint); letter-spacing: .05em; flex: 1; }
.win-status {
  font-family: var(--mono); font-size: .66rem; color: var(--ink-faint);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 9px; letter-spacing: .04em;
}
.win-status.ok { color: var(--ok); border-color: rgba(58, 90, 64, .35); background: var(--ok-soft); }
.win-status.bad { color: var(--err); border-color: rgba(158, 42, 43, .35); background: var(--err-soft); }

/* ---- 控制台：模式 + 正则 + flags + chips ---- */
.console { border-bottom: 1px solid var(--line); }
.mode-tabs {
  display: flex; gap: 2px; padding: 10px 16px 0;
}
.mode-tab {
  font-family: var(--mono); font-size: .76rem; font-weight: 600; letter-spacing: .05em;
  padding: 8px 18px; cursor: pointer; border: 1px solid var(--line);
  border-bottom: none; border-radius: 9px 9px 0 0;
  background: var(--surface-2); color: var(--ink-soft); transition: all .15s;
}
.mode-tab:hover { color: var(--accent-deep); }
.mode-tab.on { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: 0 2px 0 var(--surface); }

.pattern-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 8px;
}
.pat-delim {
  font-family: var(--mono); font-size: 1.2rem; font-weight: 700; color: var(--accent);
  flex: none; line-height: 1;
}
#pattern-input {
  flex: 1; min-width: 0; border: none; background: var(--surface);
  font-family: var(--mono); font-size: 1.04rem; font-weight: 500; color: var(--ink);
  padding: 8px 10px; caret-color: var(--accent); border-bottom: 2px solid var(--line-2);
}
#pattern-input:focus { outline: none; border-bottom-color: var(--accent); }
#pattern-input.error { border-bottom-color: var(--err); }
#pattern-input::placeholder { color: var(--ink-faint); font-weight: 400; }

.flag-group { display: flex; gap: 5px; flex: none; }
.flag-btn {
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-faint);
  transition: all .13s;
}
.flag-btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.flag-btn.on {
  background: var(--rail); border-color: var(--rail); color: var(--paper);
  box-shadow: inset 0 -2px 0 rgba(188, 108, 37, .7);
}

.chip-row {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 8px 16px 12px;
}
.chip {
  font-family: var(--mono); font-size: .68rem; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; cursor: pointer; transition: all .14s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }

/* ---- 警告条 ---- */
.alert-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; font-size: .84rem;
}
.alert-err { background: var(--err-soft); border-bottom: 1px solid rgba(158, 42, 43, .3); color: var(--err); }
.alert-redos { background: var(--accent-soft); border-bottom: 1px solid rgba(188, 108, 37, .35); color: var(--accent-deep); }
.al-badge { font-size: 1rem; flex: none; }

/* ---- 主体双栏 ---- */
.desk { display: grid; grid-template-columns: minmax(0, 1.1fr) 34px minmax(0, 1fr); }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.pane-label { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: .66rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); }
.pane-label .swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--ink); }
.pane-text .swatch { background: var(--ok); }
.pane-result .swatch { background: var(--accent); }
.pane-tools { display: flex; gap: 6px; }
.pane-count {
  font-family: var(--mono); font-size: .64rem; color: #fff; background: var(--accent);
  border-radius: 6px; padding: 2px 9px; letter-spacing: .04em; font-weight: 600;
}
.pane-count.zero { background: var(--ink-faint); }
.pane-count.dim { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }

.mini-btn {
  font-family: var(--mono); font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  padding: 4px 11px; cursor: pointer; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-soft);
  transition: all .14s;
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent-deep); box-shadow: var(--shadow-sm); }
.mini-btn:active { transform: translateY(1px); }
.mini-btn.copied { border-color: var(--ok); color: var(--ok); }

#text-input {
  flex: 1; width: 100%; border: none; resize: none; min-height: 420px;
  background: var(--surface); color: var(--ink);
  font-family: var(--mono); font-size: .85rem; line-height: 1.7;
  padding: 14px 16px; caret-color: var(--accent); white-space: pre; overflow-wrap: normal; overflow-x: auto;
}
#text-input:focus { outline: none; box-shadow: inset 0 0 0 2px rgba(34, 51, 59, .10); }

.text-stats {
  font-family: var(--mono); font-size: .64rem; color: var(--ink-faint);
  padding: 5px 16px; border-top: 1px solid var(--line); background: var(--surface-2);
  letter-spacing: .05em;
}

.desk-seam {
  position: relative; background: var(--surface-2);
  border-left: 1px dashed var(--line-2); border-right: 1px dashed var(--line-2);
  display: flex; align-items: center; justify-content: center;
}
.desk-seam .cross {
  font-family: var(--mono); color: var(--accent); font-size: 15px; font-weight: 700;
  background: var(--surface-2); padding: 6px 2px;
}

/* 替换模板行 */
.replace-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.rep-label { font-family: var(--mono); font-size: .64rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); flex: none; }
#replace-input {
  flex: 1; min-width: 0; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--surface); font-family: var(--mono); font-size: .84rem;
  padding: 7px 10px; caret-color: var(--accent); color: var(--ink);
}
#replace-input:focus { outline: none; border-color: var(--accent); }

/* 结果面板 */
.results {
  flex: 1; min-height: 420px; max-height: 560px; overflow-y: auto;
  background: var(--surface); padding: 10px 14px;
}
.res-empty {
  font-family: var(--mono); font-size: .8rem; color: var(--ink-faint);
  padding: 18px 8px; line-height: 1.8; font-style: italic;
}

/* 高亮预览块 */
.hl-preview {
  font-family: var(--mono); font-size: .78rem; line-height: 1.8; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word;
  max-height: 180px; overflow-y: auto;
}
.hl-preview mark {
  background: var(--amber); color: var(--ink); border-radius: 3px; padding: 0 1px;
  box-shadow: 0 0 0 1px rgba(188, 108, 37, .35);
}
.hl-preview mark:nth-of-type(even) { background: rgba(58, 90, 64, .28); box-shadow: 0 0 0 1px rgba(58, 90, 64, .3); }

/* 匹配卡片 */
.match-card {
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px;
  background: var(--surface); overflow: hidden;
}
.match-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.match-no { font-family: var(--mono); font-size: .64rem; font-weight: 700; color: var(--accent-deep); letter-spacing: .08em; }
.match-pos { font-family: var(--mono); font-size: .62rem; color: var(--ink-faint); margin-left: auto; }
.match-val {
  font-family: var(--mono); font-size: .8rem; color: var(--ink);
  padding: 8px 12px; word-break: break-all; white-space: pre-wrap;
}
.group-rows { border-top: 1px dashed var(--line); }
.group-row {
  display: flex; align-items: baseline; gap: 10px; padding: 5px 12px;
  font-family: var(--mono); font-size: .74rem;
}
.group-row + .group-row { border-top: 1px dashed var(--line); }
.g-name { color: var(--ok); font-weight: 600; flex: none; min-width: 58px; }
.g-val { color: var(--ink-soft); word-break: break-all; }
.g-val.undefined { color: var(--ink-faint); font-style: italic; }

/* 分割片段 chip */
.split-chip {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 6px 6px 0;
  font-family: var(--mono); font-size: .76rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.split-chip .sp-no { color: var(--accent-deep); font-size: .62rem; font-weight: 700; }

.res-replaced {
  font-family: var(--mono); font-size: .8rem; line-height: 1.8; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; white-space: pre-wrap; word-break: break-word;
}
.res-none { font-family: var(--mono); font-size: .8rem; color: var(--ink-faint); padding: 16px 8px; }

/* ============================================================
   铁路图（Railroad Diagram）
   ============================================================ */
.rail-section { border-top: 1px solid var(--line); }
.rail-canvas {
  min-height: 120px; max-height: 300px; overflow: auto;
  padding: 18px 20px 20px; background: var(--surface);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 12px 12px;
}
.rail-root {
  display: inline-flex; align-items: center; gap: 0;
  font-family: var(--mono); font-size: .8rem; min-width: 100%;
}

/* 序列：横向排布 + 轨道连线 */
.rr-seq { display: inline-flex; align-items: center; gap: 0; flex-wrap: nowrap; }
.rr-arrow {
  width: 22px; height: 2px; background: var(--rail); flex: none; position: relative;
}
.rr-arrow::after {
  content: ""; position: absolute; right: 0; top: -3px;
  border-left: 6px solid var(--rail); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}

/* 分支：纵向堆叠 + 左侧汇流轨道 */
.rr-alt { display: inline-flex; flex-direction: column; gap: 6px; position: relative; padding: 4px 0 4px 18px; }
.rr-alt::before {
  content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px;
  width: 2px; background: var(--rail); border-radius: 2px;
}
.rr-branch { display: inline-flex; align-items: center; position: relative; }
.rr-branch::before {
  content: ""; position: absolute; left: -14px; top: 50%; width: 14px; height: 2px;
  background: var(--rail);
}
.rr-branch:first-child::before, .rr-branch:last-child::before { width: 10px; }

/* 字符块 */
.rr-char, .rr-any, .rr-class, .rr-shorthand, .rr-anchor, .rr-backref {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 26px; padding: 0 8px; flex: none;
  border-radius: 7px; font-size: .78rem; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1.6px solid var(--rail); white-space: nowrap;
}
.rr-class { background: rgba(224, 159, 62, .16); border-color: var(--accent-deep); color: var(--accent-deep); }
.rr-class.neg { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.rr-shorthand { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.rr-anchor { background: var(--surface-2); border-style: dashed; border-color: var(--ink-soft); color: var(--ink-soft); }
.rr-backref { background: rgba(58, 90, 64, .1); border-color: var(--ok); }

/* 分组：框 */
.rr-group {
  display: inline-flex; flex-direction: column; position: relative; flex: none;
  border: 1.6px solid var(--rail); border-radius: 10px;
  padding: 16px 12px 8px; background: var(--surface);
}
.rr-group.group-cap { border-color: var(--rail); box-shadow: 0 0 0 1px rgba(34, 51, 59, .12); }
.rr-group.group-non { border-style: dashed; border-color: var(--ink-soft); }
.rr-group.group-look { border-style: dotted; border-color: var(--ok); }
.rr-group-tag {
  position: absolute; top: -9px; left: 10px;
  font-family: var(--mono); font-size: .6rem; font-weight: 700;
  background: var(--rail); color: var(--paper); border-radius: 4px; padding: 0 6px;
  letter-spacing: .04em;
}
.rr-group.group-non .rr-group-tag { background: var(--ink-soft); }
.rr-group.group-look .rr-group-tag { background: var(--ok); }

/* 量词：包裹 + 徽章 + 回环 */
.rr-rep { display: inline-flex; align-items: center; position: relative; flex: none; padding: 6px 0 8px; }
.rr-rep::before {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 0;
  height: 8px; border: 1.6px dashed var(--accent); border-top: none;
  border-radius: 0 0 10px 10px;
}
.rr-quant {
  font-family: var(--mono); font-size: .66rem; font-weight: 700; color: var(--accent-deep);
  background: var(--accent-soft); border: 1px solid rgba(188, 108, 37, .4);
  border-radius: 6px; padding: 1px 7px; margin-left: 8px; align-self: flex-start;
  position: relative; top: -6px;
}
.rr-lazy-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ok); color: var(--paper); font-size: .6rem; font-weight: 700;
  margin-left: 4px; position: relative; top: -6px;
}

.rail-legend {
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center;
  padding: 10px 16px 14px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.rail-legend .lg { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: .66rem; color: var(--ink-soft); }
.rail-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg-char { border: 1.6px solid var(--rail); background: var(--surface); }
.lg-class { background: rgba(224, 159, 62, .16); border: 1.6px solid var(--accent-deep); }
.lg-group-cap { background: var(--rail); }
.lg-group-non { border: 1.6px dashed var(--ink-soft); background: var(--surface); }
.lg-quant, .lg-lazy {
  width: auto; height: auto; border-radius: 6px; padding: 0 6px; font-style: normal;
  font-weight: 700; font-size: .66rem;
}
.lg-quant { background: var(--accent-soft); color: var(--accent-deep); border: 1px solid rgba(188, 108, 37, .4); }
.lg-lazy { background: var(--ok); color: var(--paper); }

/* ============================================================
   Features / 速查表 / FAQ
   ============================================================ */
.content-section { padding: 30px 0 22px; }
.sec-no {
  display: block; text-align: center; font-family: var(--mono); font-size: .64rem;
  font-weight: 600; letter-spacing: .3em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.content-section h2 {
  font-family: var(--display); font-weight: 700; font-size: clamp(1.6rem, 3vw, 2.15rem);
  letter-spacing: -.01em; margin: 0 0 8px; color: var(--ink); text-align: center;
}
.content-section .sec-sub { text-align: center; color: var(--ink-soft); font-size: .96rem; max-width: 640px; margin: 0 auto 30px; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 20px; box-shadow: var(--shadow-sm);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.feature .f-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-deep); margin-bottom: 14px;
}
.feature h3 { font-family: var(--display); font-size: 1.06rem; font-weight: 700; margin-bottom: 7px; }
.feature p { font-size: .85rem; color: var(--ink-soft); }
.feature code { font-family: var(--mono); font-size: .84em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--accent-deep); }

.cheat-wrap { max-width: 960px; }
.cheat-table {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.cheat-row {
  display: grid; grid-template-columns: 150px 1.2fr 1.2fr 1fr; gap: 10px;
  align-items: center; padding: 11px 18px;
  border-bottom: 1px solid var(--line); font-size: .88rem;
}
.cheat-row:last-child { border-bottom: none; }
.cheat-row:nth-child(odd):not(.cheat-head) { background: var(--surface-2); }
.cheat-head {
  font-family: var(--mono); font-size: .62rem; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-faint); background: var(--paper-2);
}
.cheat-row .syn { font-family: var(--mono); font-size: .8rem; font-weight: 700; color: var(--accent-deep); background: var(--accent-soft); border-radius: 5px; padding: 2px 8px; justify-self: start; }
.cheat-row code:not(.syn) { font-family: var(--mono); font-size: .78rem; color: var(--ink); }
.cheat-row span { color: var(--ink-soft); font-size: .86rem; }

.faq-block { max-width: 820px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px 24px; box-shadow: var(--shadow-sm); }
.faq-block details { border-bottom: 1px solid var(--line); }
.faq-block details:last-child { border-bottom: none; }
.faq-block summary {
  cursor: pointer; list-style: none; padding: 16px 30px 16px 0; position: relative;
  font-weight: 700; font-size: .96rem; color: var(--ink);
}
.faq-block summary::-webkit-details-marker { display: none; }
.faq-block summary::after {
  content: "+"; position: absolute; right: 0; top: 15px;
  font-family: var(--mono); font-size: 1.2rem; font-weight: 400; color: var(--accent);
  transition: transform .2s;
}
.faq-block details[open] summary::after { transform: rotate(45deg); }
.faq-block details p { padding: 0 30px 18px 0; color: var(--ink-soft); font-size: .9rem; }
.faq-block details p code { font-family: var(--mono); font-size: .84em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--accent-deep); }

/* ============================================================
   文章列表（CMS 兼容）
   ============================================================ */
.article-list { display: grid; gap: 14px; }
.article-list a {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.article-list a:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-md); }
.article-list .article-title { font-weight: 700; font-size: 1.02rem; color: var(--ink); margin-bottom: 6px; line-height: 1.45; }
.article-list a:hover .article-title { color: var(--accent-deep); }
.article-list .article-desc { font-size: .86rem; color: var(--ink-soft); line-height: 1.6; }

/* ============================================================
   文章正文（CMS 生成页兼容）
   ============================================================ */
.article-content { padding: 40px 0 50px; }
.article-content .inner { max-width: 800px; }
.article-back {
  display: inline-block; font-family: var(--mono); font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 22px;
  border-bottom: 1px dashed var(--line-2); padding-bottom: 2px; transition: color .15s, border-color .15s;
}
.article-back:hover { color: var(--accent-deep); border-color: var(--accent); }
.article-content h1 { font-family: var(--display); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.2; color: var(--ink); margin-bottom: 14px; }
.article-meta { font-family: var(--mono); font-size: .72rem; color: var(--ink-faint); letter-spacing: .05em; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 26px; }
.article-content h2 { font-family: var(--display); font-weight: 700; font-size: 1.45rem; color: var(--ink); margin: 38px 0 15px; }
.article-content h3 { font-weight: 700; font-size: 1.16rem; color: var(--ink); margin: 28px 0 12px; }
.article-content p { margin-bottom: 18px; color: #3b4d55; font-size: 1.02rem; }
.article-content ul, .article-content ol { margin: 0 0 18px 26px; }
.article-content li { margin-bottom: 10px; color: #3b4d55; font-size: 1.02rem; }
.article-content strong { color: var(--ink); }
.article-content code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; color: var(--accent-deep); }
.article-content pre { background: var(--ink); color: #e8eef0; padding: 18px 20px; border-radius: 12px; overflow-x: auto; margin: 0 0 20px; font-family: var(--mono); font-size: .84rem; line-height: 1.7; }
.article-content pre code { background: none; color: inherit; padding: 0; }
.article-content blockquote { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 14px 20px; margin: 0 0 20px; color: var(--ink-soft); border-radius: 0 10px 10px 0; }

.faq-section h2 { font-family: var(--display); font-weight: 700; font-size: 1.45rem; margin-bottom: 16px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 700; padding: 13px 4px; color: var(--ink); list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "Q  "; font-family: var(--mono); color: var(--accent-deep); }
.faq details p { padding: 0 4px 16px 22px; color: var(--ink-soft); font-size: .92rem; }

.related-articles { margin-top: 44px; border-top: 2px solid var(--ink); padding-top: 22px; }
.related-articles h2 { font-family: var(--display); font-weight: 700; font-size: 1.35rem; margin-bottom: 14px; }
.related-articles ul { list-style: none; }
.related-articles li { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.related-articles a { font-weight: 600; font-size: .95rem; }

/* ============================================================
   页脚
   ============================================================ */
.site-footer {
  margin-top: 34px; border-top: 1px solid var(--line);
  background: rgba(250, 247, 240, .88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 28px 0 24px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; margin-bottom: 14px; }
.footer-links a { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); transition: color .15s; }
.footer-links a:hover { color: var(--accent-deep); }
.copyright { text-align: center; font-family: var(--mono); font-size: .7rem; color: var(--ink-faint); letter-spacing: .05em; }
.colophon { text-align: center; font-size: .76rem; color: var(--ink-faint); margin-top: 8px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1060px) {
  .desk { grid-template-columns: 1fr; }
  .desk-seam { order: -1; border: none; border-bottom: 1px dashed var(--line-2); padding: 8px 0; }
  #text-input { min-height: 280px; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .hero .inner { grid-template-columns: 1fr; }
  .hero-map { max-width: 420px; margin: 0 auto; }
}
@media (max-width: 640px) {
  .hero { padding: 46px 0 24px; }
  .site-header .inner { position: relative; }
  .menu-btn { display: flex; }
  nav { display: contents; }
  .nav-links {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 8px; margin: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 14px 40px rgba(34, 51, 59, .14);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
  }
  .nav-links.open { opacity: 1; visibility: visible; transform: translateY(0); }
  .nav-links li { list-style: none; }
  .nav-links a { display: block; padding: 11px 14px; font-size: .88rem; }
  .logo { font-size: 1.04rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .cheat-row { grid-template-columns: 110px 1fr 1fr; }
  .cheat-row > :nth-child(4) { display: none; }
  .pattern-bar { flex-wrap: wrap; }
  #pattern-input { flex: 1 1 100%; order: 5; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .dash-move { animation: none; }
}
/* ===== 二级页面移动端导航保护（:has 门控） =====
   上方下拉菜单规则会误伤无汉堡按钮的页面（文章页/合规页不加载菜单 JS，
   导航会被 opacity:0 隐藏且无法打开）。仅在页面存在 .menu-btn 时
   保留下拉行为；其余页面恢复可见的换行压缩导航。 */
@media (max-width: 640px) {
  .site-header .inner:not(:has(.menu-btn)) nav { display: block; }
  .site-header .inner:not(:has(.menu-btn)) .nav-links {
    position: static;
    opacity: 1; visibility: visible; transform: none;
    flex-direction: row; flex-wrap: wrap; gap: 6px;
    background: none; border: none; box-shadow: none; padding: 0;
    transition: none;
  }
  .site-header .inner:not(:has(.menu-btn)) .nav-links a { padding: 6px 9px; font-size: .8rem; }
}
