/* =========================================================
 * 财富遥测台 —— 浅色（默认）/ 深色座舱（data-theme=dark）
 * 基调色用于图形主体（可区分），霓虹色仅作辉光装饰。
 * 字体定义见 fonts.css
 * ========================================================= */
:root {
  color-scheme: dark;
  --bg:      #070b10;
  --bg-2:    #0b1118;
  --panel:   #0d141c;
  --panel-2: #101a24;
  --border:  rgba(122, 170, 205, 0.14);
  --ink:     #e8f0f7;
  --ink-2:   #9db2c4;
  --muted:   #64788c;
  --accent:  #0a84ff;   /* macOS 系统蓝（固定，不提供开关） */
  --glow-rgb: 10, 132, 255;   /* --accent 的 RGB 分量，供需要透明度的辉光使用 */
  --up:      #ff5f56;
  --down:    #34d99a;
  --flat:    #64788c;
  --s1: #1890ae; --s2: #c97922; --s3: #18996c; --s4: #7f5cc8;
  --g1: #38d6ff; --g2: #ffb454; --g3: #3ce99a; --g4: #b78cff;
  --glow-op: 0.5;
  --code-bg: #1e1e1e;
  --code-border: rgba(255, 255, 255, 0.10);
  --sb-thumb: rgba(160, 200, 230, 0.22);
  --sb-thumb-hover: rgba(160, 200, 230, 0.40);
  /* macOS 风格：键盘焦点环是一圈强调色光晕；浮层阴影是"细描边 + 柔投影"两段式 */
  --focus-ring: 0 0 0 3px rgba(10, 132, 255, 0.45);
  --shadow-pop: 0 0 0 0.5px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.30);
  /* macOS 材质：半透明 + 背景模糊（侧栏、浮层菜单、弹窗） */
  --material: rgba(13, 20, 28, 0.72);
  --material-blur: saturate(180%) blur(20px);
  /* 打包字体排在系统字体前面，保证各平台拉丁字母/数字观感统一；
     汉字不在打包字体里，会自动落到后面的系统 CJK 字体 */
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --font-sans: "Inter", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

/* 笔记正文的左右/上下留白：阅读区、Vditor 预览、飞书文档编辑器**必须用同一个值** ——
   只改一边，只读↔编辑切换时正文会横向跳动（原先靠注释维系三个 14px 18px，现在收成一个变量）。
   窄屏下整条覆盖成 12px 12px（见下方 @media (max-width: 600px)）。 */
:root { --notes-pad: 12px 16px; }

:root[data-theme="light"] {
  color-scheme: light;
  --bg:      #eef2f6;
  --bg-2:    #e6ecf2;
  --panel:   #ffffff;
  --panel-2: #f6f9fb;
  --border:  rgba(15, 40, 60, 0.12);
  --ink:     #0d1b26;
  --ink-2:   #4b5f70;
  --muted:   #71879a;
  --accent:  #007aff;
  --glow-rgb: 0, 122, 255;
  --up:      #d64541;
  --down:    #0a8f57;
  --flat:    #71879a;
  --s1: #0891b2; --s2: #d97706; --s3: #059669; --s4: #7c3aed;
  --g1: #0891b2; --g2: #d97706; --g3: #059669; --g4: #7c3aed;
  --glow-op: 0.18;
  --code-bg: #f6f8fa;
  --code-border: rgba(0, 0, 0, 0.10);
  --sb-thumb: rgba(15, 40, 60, 0.20);
  --sb-thumb-hover: rgba(15, 40, 60, 0.36);
  --focus-ring: 0 0 0 3px rgba(0, 122, 255, 0.35);
  --shadow-pop: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(0, 0, 0, 0.14);
  --material: rgba(255, 255, 255, 0.72);
  --material-blur: saturate(180%) blur(20px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 点阵 + 顶部辉光背景 */
.backdrop {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1100px 460px at 50% -180px, rgba(var(--glow-rgb), 0.10), transparent 70%),
    radial-gradient(1.5px 1.5px at 50% 50%, var(--border) 50%, transparent 51%);
  background-size: 100% 100%, 26px 26px;
  opacity: 0.8;
}

.console {
  position: relative; z-index: 1;
  margin: 0 auto;            /* 不再限制版心宽度：两个 tab 都占满视口 */
  padding: 24px 24px 40px;
}
/* 手机纵向寸土寸金：顶部留白 24 -> 12px（桌面仍按规约的 24px，左/右不变）。
   注意 `.console` 有 margin: 0 auto，在「笔记」tab 里它是 flex 项目 —— 光改 padding
   不会破坏那条 flex 链，正文会自动多拿这 12px。 */
@media (max-width: 600px) {
  /* 左右也一起收：24px 是桌面的版心留白，手机上等于白扔掉近 1/5 的宽度 */
  .console { padding-top: 12px; padding-left: 12px; padding-right: 12px; }
}

/* ============ 键盘焦点环（macOS 约定：键盘聚焦必须有可见光晕） ============ */
:where(.edit-btn, .tab, .btn-primary, .ctl, .note-new-item, .doc-menu-item,
       .doc-tool-btn, .doc-gutter-btn, .modal input, .modal-close,
       .doc-title, .doc-content, .doc-code-input, .tree-row, .outline-row):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: inherit;
}

/* ============ 站点头部（标签页 + 站点级控件） ============ */
.topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px; border-bottom: 1px solid var(--border);
}
.site-bar { margin-left:  auto; display: flex; align-items: center; gap: 12px; }
/* 标签行到下面内容之间的距离：18px 在手机上偏空，三个 tab 统一收到 8px
   （量出来 tab 行底边到内容是 9px —— 多出的 1px 是 .topbar 那条分隔线本身）。
   必须放在上面 .topbar 规则**之后**：同优先级时后者胜，放前面会被 18px 盖掉（踩过）。 */
@media (max-width: 600px) {
  .topbar { margin-bottom: 8px; }
}

/* ============ 标签页 ============ */
.tabs { display: flex; gap: 4px; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--ink-2); font-size: 15px; font-weight: 500;
  padding: 8px 16px; cursor: pointer; white-space: nowrap;
  transition: color .2s ease-out, border-color .2s ease-out;
}
.tabs a.tab { text-decoration: none; }
.tab[hidden] { display: none; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ 站点状态（时钟 + 控件，在头部右侧） ============ */
.sys-clock {
  font-family: var(--font-mono); color: var(--muted); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.controls { display: flex; gap: 6px; }
.ctl {
  width: 32px; height: 32px; font-size: 14px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; display: grid; place-items: center;
  transition: border-color .2s ease-out, box-shadow .2s ease-out, color .2s ease-out;
}
.ctl:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); }
.ctl.spinning svg, .ctl.spinning { animation: spin .6s linear; }

/* ============ 登录（资产 tab 未登录时，居中只留输入与按钮） ============ */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 150px);
  min-height: calc(100dvh - 150px);
  padding: 24px 0;
}
/* display:flex 会盖掉 [hidden] 的 display:none —— 登录后必须真的不占位 */
.login-wrap[hidden] { display: none; }
.login-card {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 20px 22px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.login-card input {
  width: 220px; padding: 0 12px; height: 36px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-mono); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.login-card .btn-primary { width: auto; padding: 0 18px; height: 36px; }
.login-msg { flex-basis: 100%; color: var(--up); font-size: 13px; }
.login-msg:empty { display: none; }   /* 没有错误时不占位，卡片保持紧凑 */
.link-btn {
  background: none; border: none; padding: 0; margin-left: 10px;
  color: var(--accent); font-size: 12px; cursor: pointer; font-family: var(--font-sans);
}
.link-btn:hover { text-decoration: underline; }

/* ============ 总资产仪表 ============ */
.frame {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  padding: 26px 24px;
  text-align: center;
  border-radius: 4px;
}
.frame::before, .frame::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid var(--accent);
}
.frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.frame::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.hero-line {
  display: flex; align-items: baseline; justify-content: center;
  gap: 22px; flex-wrap: wrap;
}
.hero-label { color: var(--ink-2); font-size: 14px; letter-spacing: 1px; }
.hero-value {
  font-family: var(--font-mono);
  font-size: 42px; font-weight: 600; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(var(--glow-rgb), 0.22);
}
.hero-updated { font-family: var(--font-mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta-up   { color: var(--up); }
.delta-down { color: var(--down); }
.delta-flat { color: var(--flat); }

/* ============ 面板通用 ============ */
.panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 20px 22px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-title {
  margin: 0; font-size: 15px; font-weight: 600;
  letter-spacing: 1px; color: var(--ink);
}
.panel-title::before { content: "▸ "; color: var(--accent); }
.alloc-total { color: var(--ink-2); font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ============ 资产配置 ============ */
.alloc-body { display: flex; gap: 36px; align-items: center; flex-wrap: wrap; }

.donut-box { position: relative; width: 180px; height: 180px; flex: none; }
#donut { width: 100%; height: 100%; overflow: visible; }
#donut circle { cursor: pointer; transition: stroke-width .2s ease-out, opacity .2s ease-out, filter .2s ease-out; }
#donut circle.active { stroke-width: 30; filter: drop-shadow(0 0 8px var(--seg-glow)); }

.radar {
  position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 0deg,
    transparent 0deg, transparent 300deg,
    var(--accent) 352deg, transparent 360deg);
  opacity: 0.14; animation: sweep 7s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.donut-readout {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.ro-label { color: var(--muted); font-size: 12px; }
.ro-value { font-family: var(--font-mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ro-sub { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 2px; min-height: 15px; }

.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 290px; }
.legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 10px 10px; border-bottom: 1px solid var(--border);
  cursor: pointer; border-radius: 4px;
  transition: background .2s ease-out;
}
.legend li:last-child { border-bottom: none; }
.legend li:hover, .legend li.active { background: var(--panel-2); }
.legend .dot {
  width: 12px; height: 12px; border-radius: 4px;
  box-shadow: 0 0 8px var(--dot-glow);
}
.legend .name { font-weight: 600; font-size: 15px; }
.legend .value-sub { font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.legend .value-sub span:first-child { font-weight: 600; }
.legend .value-sub .pct { color: var(--muted); }

/* ============ 持仓明细 ============ */
/* 持仓明细：宽屏下股票/基金、现金/存款、房产/实物 并成一行；
   宽度不够时（手机等）退回单列。加密货币行数多、详情列文字长，始终独占一整行 */
.holdings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px; margin-top: 14px;
}
.holdings .holding-card[data-cat="crypto"] { grid-column: 1 / -1; }
/* 三列每张要放得下「名称/数量/现值/利率」四列表格，约需 1050px 以上 */
@media (max-width: 1049px) {
  .holdings { grid-template-columns: 1fr; }
}
.holding-card { margin-top: 0; }
.holding-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.holding-card .cat-total {
  font-family: var(--font-mono); color: var(--ink-2); font-size: 13px;
  font-variant-numeric: tabular-nums;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: right; font-weight: 500; color: var(--muted);
  padding: 6px 6px; border-bottom: 1px solid var(--border); font-size: 12px;
}
th:first-child { text-align: left; }
td { padding: 10px 6px; text-align: right; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
td.num, th:not(:first-child) { font-family: var(--font-mono); }
td:first-child { text-align: left; font-weight: 500; }
tbody tr { transition: background .2s ease-out; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); }
.err { color: var(--up); font-size: 11px; }

/* 资产卡表格：固定数值列宽，使三类的「现值」列水平对齐 */
table.asset-table { table-layout: fixed; }
table.asset-table th.col-qty { width: 80px; }
table.asset-table th.col-value { width: 140px; }
table.asset-table th.col-rate { width: 110px; }
@media (max-width: 600px) {
  table.asset-table th.col-qty { width: 56px; }
  table.asset-table th.col-value { width: 105px; }
  table.asset-table th.col-rate { width: 85px; }
  .detail-col { display: none; }
}

/* ============ 年被动收入 ============ */
/* 年被动收入 + 总资产走势：宽屏并排一行，窄屏（手机等）退回上下排列 */
.assets-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}
.assets-row > .panel { margin-top: 0; }
.assets-row > .passive { display: flex; flex-direction: column; justify-content: center; }  /* 内容比走势图矮，垂直居中 */
/* 走势图是按 viewBox 等比缩放的，两栏后每栏太窄会让坐标轴文字小到看不清，
   所以 1200px 以下干脆上下排列 */
@media (max-width: 1199px) {
  .assets-row { grid-template-columns: 1fr; }
  .assets-row > .passive { justify-content: flex-start; }
}

.passive-line { display: flex; align-items: baseline; justify-content: center; gap: 16px; flex-wrap: wrap; }
.passive-label { color: var(--ink-2); font-size: 14px; }
.passive-value {
  font-family: var(--font-mono); font-size: 26px; font-weight: 600;
  color: var(--accent); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(var(--glow-rgb), 0.25);
}
.passive-bars { margin: 18px auto 0; max-width: 640px; display: grid; gap: 10px; }
.pi-row { display: grid; grid-template-columns: 80px 1fr 120px; gap: 12px; align-items: center; }
.pi-name { font-size: 13px; color: var(--ink-2); text-align: right; }
.pi-track { position: relative; height: 16px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.pi-track::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--axis); }
.pi-bar { position: absolute; top: 0; height: 100%; border-radius: 4px; }
.pi-val { font-family: var(--font-mono); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .pi-row { grid-template-columns: 64px 1fr 92px; gap: 8px; }
}

/* ============ 总资产走势 ============ */
.history-chart { position: relative; margin-top: 6px; }
.hist-svg { width: 100%; height: auto; display: block; }
.hist-y { fill: var(--muted); font-size: 11px; text-anchor: end; font-family: var(--font-mono); }
.hist-x { fill: var(--muted); font-size: 11px; text-anchor: middle; font-family: var(--font-mono); }
.hist-x-future { fill: var(--accent); }
.hist-empty { text-align: center; color: var(--muted); padding: 32px 0; font-size: 13px; }
.hist-actions { display: flex; align-items: center; gap: 12px; }
.hist-point { cursor: pointer; }
.hist-legend { display: flex; gap: 20px; justify-content: flex-end; margin-bottom: 8px; font-size: 12px; color: var(--ink-2); }
.hist-legend span { display: flex; align-items: center; gap: 6px; }
.lg-circle { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.lg-tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--g2); }
.hist-y-right { text-anchor: start; }
.hist-tip {
  position: absolute; display: none; z-index: 10; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 12px; font-family: var(--font-mono);
  color: var(--ink); line-height: 1.7; white-space: nowrap;
  box-shadow: var(--shadow-pop);
}
.hist-tip .tip-title { color: var(--ink-2); font-size: 11px; margin-bottom: 2px; }
.hist-tip .tip-net { margin-top: 2px; }

/* 未来预期弹窗 */
.proj-head-row, .proj-row { display: grid; grid-template-columns: 64px 1fr 1fr 1.25fr; gap: 8px; align-items: center; }
.proj-head-row { color: var(--muted); font-size: 12px; margin: 16px 0 6px; }
.proj-head-row span:not(:first-child) { text-align: center; }
.proj-row { margin-bottom: 10px; }
.proj-month { color: var(--ink-2); font-size: 14px; font-weight: 600; white-space: nowrap; }

/* ============ 页脚 ============ */
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0 0; }

/* ============ 卡片头（含修改按钮） ============ */
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.card-head .push { margin-left:  auto; }
.apy { color: var(--ink-2); font-size: 13px; font-family: var(--font-mono); }
.edit-btn {
  background: none; border: 1px solid var(--border); color: var(--accent);
  border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 13px;
}
.edit-btn:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.edit-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
select.edit-btn {
  appearance: none; -webkit-appearance: none;
  padding-right: 28px; font-family: var(--font-sans);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.edit-btn.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 6px; line-height: 1; }
.edit-btn.icon-btn svg { display: block; }
.edit-btn.primary { background: var(--accent); border-color: var(--accent); color: #04121a; font-weight: 600; }
.edit-btn.primary:hover { filter: brightness(1.1); box-shadow: none; }
.edit-btn.danger { color: var(--up); }
.edit-btn.danger:hover { border-color: var(--up); box-shadow: 0 0 0 1px var(--up); }

/* ============ 笔记 ============ */
/* 滚动条：全站统一成 macOS 式浮层细滚动条 —— 轨道透明、滑块半透明内缩，
   既不额外占一条异色竖条，也不会在 Windows 上露出粗方块 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--sb-thumb) transparent;
}
*::-webkit-scrollbar { width: auto; height: auto; }   /* 宽度交给引擎的 thin，避免与 Firefox 差一截 */
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border: 3px solid transparent;
  border-radius: 6px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--sb-thumb-hover);
  background-clip: content-box;
}

/* 目录收起按钮：只在窄屏（手机）出现，宽屏目录栏是侧列，不需要 */
#note-side-collapse { display: none; }

/* 两个 tab 都铺满视口；只是宽屏下给笔记目录栏封个顶 */
@media (min-width: 601px) {  /* 移动端目录栏仍要占满一行 */
  body[data-tab="notes"] .notes-side { max-width: 272px; }   /* 原 320px，同比例缩窄 15% */
}

.notes-layout { display: flex; gap: 16px; height: calc(100vh - 128px); min-height: 460px; }

/* 笔记 tab 的高度：让正文占满「视口 − 顶部真实占用」。
   上面那句（以及窄屏那句）是早期按估算写的死高度 —— 顶部实际只占约 80px
   （console 上边距 24 + topbar 38 + topbar 下边距 18），按 128 / 118 扣就多扣了
   48 / 38px，页面底部白白空出一条，看着铺不满。
   改成把 .console → #tab-notes → .notes-layout 串成一条纵向 flex 链，高度交给 flex 分配：
   顶部多高（换字号、换机型、横竖屏、目录展开或收起）都自动对得上，不再有魔法数字。
   只作用于「笔记」这一个 tab —— body[data-tab] 是站点既有的做法（见 .notes-side 那条），
   资产总览 / 我和本站两个 tab 的页面滚动照旧。 */
body[data-tab="notes"] { display: flex; flex-direction: column; height: 100vh; min-height: 0; }
@supports (height: 100dvh) {
  /* dvh 才是「当前真正看得见的高度」（iOS 地址栏收起/展开会变）。
     上面那句 min-height: 0 不能少 —— 基础样式里 body 有 min-height: 100vh，
     而 iOS 的 100vh 是「地址栏收起时」的高度、比看得见的区域更高，
     不清掉它就会把 100dvh 顶成 100vh，正文反而探出屏幕底部。
     老浏览器没有 dvh 就退回 100vh：最多多出一条可滚动的余量，不会把内容切掉。 */
  body[data-tab="notes"] { height: 100dvh; }
}
/* width: 100% 不能省：.console 上有 margin: 0 auto，做成 flex 项目后自动外边距会把
   两侧剩余空间吃掉，项目就收缩成「内容宽度」—— 正文区会平白窄掉一大截。 */
body[data-tab="notes"] .console { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; }
body[data-tab="notes"] #tab-notes { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body[data-tab="notes"] .notes-layout { flex: 1; height: auto; }
.notes-side {
  flex: 0 0 14.45%; min-width: 145px; min-height: 0;   /* 原 17% / 170px，整体缩窄 15% */
  /* 有材质底色就该是张圆角卡片：四周留白 + 圆角，与右侧正文面板同一套圆角尺度 */
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.notes-side-head { display: flex; gap: 6px; flex-wrap: wrap; }
.view-toggle { margin-left:  auto; }
.view-toggle.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); }
.notes-tree { list-style: none; margin: 0; padding: 0 0 4px; overflow-y: auto; flex: 1; min-height: 0; }
/* 目录大纲：与文件树同一套行样式，按标题级别缩进 */
.notes-outline { list-style: none; margin: 0; padding: 0 0 4px; overflow-y: auto; flex: 1; min-height: 0; }
.outline-row { font-size: 13px; }
.outline-row .outline-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-row.active { background: var(--panel-2); color: var(--accent); }
.outline-l1 { color: var(--ink); }
.outline-l2 { color: var(--ink-2); }
.notes-tree ul { list-style: none; margin: 0; padding: 0; }
.tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  color: var(--ink-2); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .2s ease-out, color .2s ease-out;
}
.tree-row:hover { background: var(--panel-2); }
/* 选中项：macOS 侧栏的实心药丸（强调色填充 + 白字），和 hover 一眼能分开 */
.tree-row.note.active,
.outline-row.active { background: var(--accent); color: #fff; }
.tree-row.note.active .tree-name,
.tree-row.note.active .tree-icon,
.outline-row.active .outline-text { color: #fff; }
.tree-arrow { width: 14px; flex: none; display: flex; align-items: center; color: var(--muted); }

/* 侧栏分组标题：工具栏与列表之间的结构感 */
.notes-side-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 2px 6px 6px 16px; margin-bottom: 4px;   /* 文字与列表行文字对齐 */
  border-bottom: 1px solid var(--border);
  font-size: 11px; letter-spacing: .5px; color: var(--muted);
}
.notes-side-count { font-family: var(--font-mono); font-size: 11px; opacity: .8; }

/* 层级引导线：子级列表左侧一条竖线，让缩进关系肉眼可见 */
.tree-children { position: relative; }
.tree-children::before {
  content: ""; position: absolute; left: var(--guide-x, 14px); top: 0; bottom: 6px;
  width: 1px; background: var(--border); pointer-events: none;
}

/* 空态：居中给一句"下一步做什么"，而不是一行小字 */
.notes-empty {
  display: block; padding: 20px 12px; text-align: center;
  color: var(--ink-2); font-size: 13px; line-height: 1.6;
}
.notes-empty span { color: var(--muted); font-size: 12px; }
.tree-icon { flex: none; }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sortable-ghost { opacity: 0.4; }
.note-li { cursor: grab; user-select: none; -webkit-user-select: none; }
.note-li:active { cursor: grabbing; }
.sortable-fallback, .sortable-drag { pointer-events: none; }

.notes-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.notes-toolbar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notes-breadcrumb { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.notes-editor-box { position: relative; flex: 1; min-height: 0; }
.notes-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; pointer-events: none;
  background: none;   /* 不铺面板底色，跟页面背景统一（未选笔记时只留提示文字） */
}
.notes-article {
  height: 100%; overflow-y: auto;
  padding: var(--notes-pad); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
  line-height: 1.75; font-size: 15px; color: var(--ink);
  word-break: break-word; overflow-wrap: break-word;
}
.notes-article h1, .notes-article h2, .notes-article h3, .notes-article h4, .notes-article h5, .notes-article h6 { margin: 1.2em 0 0.6em; line-height: 1.3; }
.notes-article h1 { font-size: 22px; }
.notes-article h2 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.notes-article h3 { font-size: 15px; }
.notes-article h4 { font-size: 14px; }
.notes-article h5 { font-size: 13px; }
.notes-article h6 { font-size: 12px; color: var(--muted); }
.notes-article p { margin: 0.75em 0; }
.notes-article ul, .notes-article ol { padding-left: 24px; margin: 0.75em 0; }
.notes-article li { margin: 0.25em 0; }
.notes-article code { font-family: var(--font-mono); background: var(--panel-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.notes-article pre { background: var(--code-bg); border: 1px solid var(--code-border); padding: 1px; border-radius: 8px; overflow-x: auto; line-height: 1.5; }
.notes-article pre code { background: none; padding: 0; font-size: 13px; }
.notes-article a { color: var(--accent); }
.notes-article blockquote { border-left: 3px solid var(--accent); margin: 0.75em 0; padding: 2px 14px; color: var(--ink-2); }
.notes-article hr { border: none; border-top: 1px solid var(--border); margin: 1.3em 0; }
.notes-article table { border-collapse: collapse; margin: 1em 0; }
.notes-article th, .notes-article td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.notes-article img { max-width: 100%; }
/* 朗读按钮：笔记源文件里只写 <button class="say"></button>，喇叭图标由 app.js 注入（见 initSpeech） */
.notes-article button.say {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin: 0 2px; padding: 0; vertical-align: -5px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel-2); color: var(--ink-2); cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.notes-article button.say:hover { color: var(--accent); border-color: rgba(var(--glow-rgb), .50); }
.notes-article button.say.speaking { color: var(--accent); border-color: rgba(var(--glow-rgb), .55); background: rgba(var(--glow-rgb), .14); }
.notes-article button.say svg { width: 13px; height: 13px; }
/* 句子下面的中文释义；朗读时会跳过 .zh，只读英文 */
.notes-article .zh { display: block; margin: 1px 0 10px; color: var(--muted); font-size: 13.5px; }
#note-editor.vditor {
  display: flex;
  flex-direction: column;
  position: absolute; inset: 0;   /* 覆盖在预览之上，切换时原文不消失（见 renderNoteView） */
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  --toolbar-height: 28px;
}
#note-editor .vditor-toolbar__item .vditor-tooltipped { padding: 6px 4px; }
#note-editor .vditor-content { min-height: 0; }
#note-editor .vditor-ir { min-height: 0; box-sizing: border-box; padding: 0; }
/* Vditor 把内边距写在行内样式上（style="padding: 10px 35px"），普通规则盖不住，
   必须 !important。这里对齐预览的内边距，让预览切到编辑时正文不横移、宽度不缩水 */
#note-editor .vditor-ir pre.vditor-reset {
  margin: 0 !important;
  padding: var(--notes-pad) !important;
}
/* 编辑器的字号层级对齐预览：Vditor 默认 16px 基准 + em 标题（h1 会到 28px），
   与预览的 22/18/15 是两套，导致同一篇笔记在编辑和预览下排版不一致 */
#note-editor .vditor-ir .vditor-reset { font-size: 15px; }
#note-editor .vditor-ir .vditor-reset > h1 { font-size: 22px; }
#note-editor .vditor-ir .vditor-reset > h2 { font-size: 18px; }
#note-editor .vditor-ir .vditor-reset > h3 { font-size: 15px; }
#note-editor .vditor-ir .vditor-reset > h4 { font-size: 14px; }
#note-editor .vditor-ir .vditor-reset > h5 { font-size: 13px; }
#note-editor .vditor-ir .vditor-reset > h6 { font-size: 12px; }
/* 聚焦时 Vditor 会把底色从 --panel-background-color 换成 --textarea-background-color，
   深色下 #24292e → #2f363d，点进正文整块背景「跳」一下。这里固定成同一个色 */
#note-editor .vditor-ir pre.vditor-reset:focus {
  background-color: var(--panel-background-color);
}
/* IR 模式下代码块等内容包在 .vditor-ir__preview 里，Vditor 默认给 cursor: pointer，
   但整块本来就是可编辑区，悬停显示「手」会让人以为点不进去 —— 统一回文本光标 */
#note-editor .vditor-ir__preview,
#note-editor .vditor-ir__preview * { cursor: text; }
/* IR 模式下标题前的 H1/H2/H3… 级别标签：小号圆角徽章 */
#note-editor .vditor-ir .vditor-reset > h1:before,
#note-editor .vditor-ir .vditor-reset > h2:before,
#note-editor .vditor-ir .vditor-reset > h3:before,
#note-editor .vditor-ir .vditor-reset > h4:before,
#note-editor .vditor-ir .vditor-reset > h5:before,
#note-editor .vditor-ir .vditor-reset > h6:before {
  float: none;
  display: inline-block;
  margin: 0 6px 0 0;
  padding: 1px 4px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--accent);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  vertical-align: middle;
}
/* 编辑器内代码块：VS Code 风格背景 */
#note-editor .vditor-ir div[data-type="code-block"] > pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 1px;
}
/* IR 模式对代码块是「平时显示高亮预览，点一下展开源码」两套视图。
   展开时源码和预览会同时渲染，代码就显示两遍、一份还露在框外，很怪。
   本应用编辑时不需要预览视角：直接常显可编辑源码、隐藏预览 */
#note-editor .vditor-ir div[data-type="code-block"] .vditor-ir__preview { display: none !important; }
#note-editor .vditor-ir div[data-type="code-block"] .vditor-ir__marker--pre {
  display: block !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;   /* 覆盖 .vditor-ir__marker 的 width/height:0 + overflow:hidden */
  float: none !important;
  margin: 0 !important;
  padding: 4px 8px !important;
}
/* 语言标签（js 之类）常显，别只在展开时冒出来 */
#note-editor .vditor-ir div[data-type="code-block"] .vditor-ir__marker--info {
  display: inline-block !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  font-size: 11px;
  padding: 2px 4px 0;
}
/* 不要 ``` 围栏（展开态 Vditor 会用 :before/:after 画出来） */
#note-editor .vditor-ir div[data-type="code-block"]:before,
#note-editor .vditor-ir div[data-type="code-block"]:after { content: none !important; }
/* IR 模式下代码块里的 <code> 没有 hljs 类，会被 content-theme 的
   `.vditor-reset code:not(.hljs)` 刷成蓝色底，这里一律去掉 */
#note-editor .vditor-ir .vditor-reset code,
#note-editor .vditor-ir div[data-type="code-block"] code { font-size: 13px; }
/* Vditor 自带的浮层文字（提示气泡、hint 菜单）也挂到本站字号档位，别留 16px 的孤例 */
#note-editor .vditor-tooltip, #note-editor .vditor-hint, #note-editor .vditor-tip { font-size: 12px; }
#note-editor .vditor-ir div[data-type="code-block"] code {
  background: none;
  padding: 0;
}

/* 笔记 - 移动端：目录栏置顶、编辑器占满剩余空间 */
@media (max-width: 600px) {
  /* 高度不在这里定：交给上面那条 flex 链（写死的 calc(100dvh - 118px) 会空出 38px） */
  .notes-layout {
    flex-direction: column;
    min-height: 0;
    gap: 10px;
  }
  /* 手机上别浪费时间：底部留一点点边就行（桌面那 40px 是版心留白，小屏不划算） */
  body[data-tab="notes"] .console { padding-bottom: 10px; }
  /* 笔记正文留白整条收紧：12px 12px 与站壳的窄屏内边距一致
     （改前 fdoc 正文离屏幕左缘 31px、html 笔记 24px，同一目录里来回看就显出来了）。
     改这一个变量，阅读区 / Vditor 预览 / 飞书编辑器三处同时跟上。 */
  :root { --notes-pad: 12px 12px; }
  .notes-side {
    flex: none;
    width: 100%;
    min-width: 0;
    padding: 8px 8px 6px;
  }
  .notes-tree { max-height: 24vh; }
  .notes-outline { max-height: 24vh; }   /* 大纲也要封顶，否则长目录会把正文挤没 */
  .notes-toolbar { flex-wrap: wrap; }
  .notes-main { flex: 1; min-height: 0; }

  /* 窄屏：整块目录（文件列表 / 大纲）可以收起，把高度全让给正文 */
  .notes-side.collapsed { padding: 8px 8px 6px; gap: 0; }
  .notes-side.collapsed .notes-side-label { display: none; }
  .notes-side.collapsed #notes-tree,
  .notes-side.collapsed #notes-outline { display: none; }
  .notes-side.collapsed #note-side-collapse svg { transform: rotate(180deg); }
  #note-side-collapse { display: inline-flex; }
  #note-side-collapse svg { transition: transform .2s ease-out; }
}

/* ============ 新建菜单（Markdown / 飞书文档） ============ */
.note-new-wrap { position: relative; display: inline-flex; }
.note-new-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 218px; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 2px;
}
.note-new-menu[hidden] { display: none; }
.note-new-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: none; border-radius: 6px;
  background: none; color: var(--ink); text-align: left; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px;
}
.note-new-item:hover { background: var(--panel-2); }
.note-new-item .ni-icon { flex: none; }
.note-new-item .ni-text { display: flex; flex-direction: column; line-height: 1.4; }
.note-new-item .ni-text b { font-size: 13px; font-weight: 600; }
.note-new-item .ni-text i { font-style: normal; font-size: 11px; color: var(--muted); }
.tree-icon.doc-icon { display: block; }

/* ============ 网页笔记（自包含 html，iframe 只读预览） ============ */
#note-html {
  position: absolute; inset: 0;   /* 铺满笔记区，与 .notes-article 同一块地方 */
  width: 100%; height: 100%;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
/* #note-html 自己的页面在内层，这里不设 padding —— 留白由网页自己安排 */

/* ============ 飞书文档（编辑 + 只读预览） ============ */
#doc-editor {
  position: absolute; inset: 0;   /* 同上：与预览重叠，避免切换空帧 */
  height: auto; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: var(--notes-pad) 0;   /* 与 .notes-article 同一个变量：只读切编辑时正文不横移 */
}
.doc-page { max-width: none; }   /* 跟 markdown 预览一致：铺满笔记区，不另做窄栏 */
.doc-title {
  font-size: 26px; font-weight: 700; line-height: 1.35; color: var(--ink);
  padding: 6px 2px 10px; outline: none; word-break: break-word;
}
.doc-title:empty:before { content: attr(data-ph); color: var(--muted); }
.doc-blocks { display: flex; flex-direction: column; }
.doc-block { position: relative; display: flex; align-items: flex-start; }
.doc-block.selected { box-shadow: 0 0 0 2px var(--accent); border-radius: 6px; outline: none; }
.doc-gutter {
  position: absolute; left: -48px; top: 1px;
  display: flex; align-items: center; gap: 1px;
  opacity: 0; transition: opacity .2s ease-out;
}
.doc-block:hover .doc-gutter, .doc-block:focus-within .doc-gutter { opacity: 1; }
.doc-gutter-btn {
  width: 21px; height: 23px; padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 4px;
  color: var(--muted); font-size: 13px; cursor: pointer; font-family: var(--font-sans);
}
.doc-gutter-btn:hover { background: var(--panel-2); color: var(--accent); }
.doc-handle { cursor: grab; letter-spacing: -2px; }
.doc-handle:active { cursor: grabbing; }
.doc-body { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 6px; }
.doc-content {
  flex: 1; min-width: 0; outline: none;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word;
  line-height: 1.7; font-size: 15px; color: var(--ink); padding: 2px 2px;
}
.doc-content:empty:focus:before { content: attr(data-ph); color: var(--muted); }
.doc-content a { color: var(--accent); }
.doc-content code {
  font-family: var(--font-mono); font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px;
}
.doc-prefix { flex: none; min-width: 19px; color: var(--ink-2); font-size: 15px; line-height: 1.7; padding: 2px 0; }
.doc-check { flex: none; margin: 8px 0 0; width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.doc-icon { flex: none; font-size: 15px; line-height: 1.7; padding: 2px 0; }
.doc-bar { flex: none; width: 3px; align-self: stretch; margin: 4px 0; border-radius: 2px; background: var(--accent); opacity: .55; }
.doc-hr { flex: 1; border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.doc-tail { height: 26vh; }
.doc-h1 .doc-content { font-size: 22px; font-weight: 700; line-height: 1.4; padding: 6px 2px 2px; }
.doc-h2 .doc-content { font-size: 18px; font-weight: 700; line-height: 1.45; padding: 6px 2px 2px; }
.doc-h3 .doc-content { font-size: 15px; font-weight: 600; padding: 4px 2px 2px; }
.doc-h4 .doc-content { font-size: 14px; font-weight: 600; padding: 3px 2px 1px; }
/* KaTeX：长公式在窄屏上横向滚动，不撑破正文 */
.doc-content .katex { font-size: 1.04em; }
.doc-content .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.doc-content .katex-display > .katex { white-space: normal; }
.doc-quote .doc-content { color: var(--ink-2); }
.doc-callout { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px; margin: 2px 0; }
.doc-callout .doc-gutter { left: -48px; }
.doc-todo .doc-content[contenteditable="true"] { padding-left: 0; }
.doc-block.doc-todo.done .doc-content { color: var(--muted); text-decoration: line-through; }
.doc-block.doc-code { margin: 4px 0; }
.doc-code-input {
  width: 100%; resize: none; overflow: hidden;
  background: var(--code-bg); color: var(--ink);
  border: 1px solid var(--code-border); border-radius: 8px;
  padding: 8px 10px; margin: 0;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.55;
  outline: none; tab-size: 4;
}
.doc-read .doc-block.doc-code pre {
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 6px;
  padding: 8px 10px; margin: 0; overflow-x: auto;
}
.doc-read .doc-block.doc-code code { background: none; border: none; padding: 0; font-size: 13px; }
.doc-read-title { font-size: 26px; font-weight: 700; margin: 0 0 10px; line-height: 1.35; color: var(--ink); }
.doc-read .doc-h1 .doc-content { font-size: 22px; font-weight: 700; }
.doc-read .doc-h2 .doc-content { font-size: 18px; font-weight: 700; }
.doc-read .doc-h3 .doc-content { font-size: 15px; font-weight: 600; }
.doc-read .doc-h4 .doc-content { font-size: 14px; font-weight: 600; }
.doc-read .doc-block { padding-left: 0; }
/* 阅读态没有 .doc-body 包一层，竖线与正文之间要自己补出编辑态那 6px 的间距 */
.doc-read .doc-bar { margin-right: 6px; }

/* 斜杠菜单 / 类型菜单 */
.doc-menu {
  position: fixed; z-index: 200; min-width: 190px;
  max-height: min(320px, 46vh); overflow-y: auto; overscroll-behavior: contain;
  padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 1px;
}
.doc-menu[hidden] { display: none; }
.doc-menu-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 8px; border: none; border-radius: 6px; background: none;
  color: var(--ink); text-align: left; cursor: pointer; font-family: var(--font-sans); font-size: 13px;
}
.doc-menu-item.active, .doc-menu-item:hover { background: var(--panel-2); }
.doc-menu-item.active .doc-menu-label { color: var(--accent); }
.doc-menu-label { font-weight: 500; }
.doc-menu-hint { font-size: 11px; color: var(--muted); }

/* 选中文字浮动工具栏 */
.doc-toolbar {
  position: fixed; z-index: 200; display: flex; gap: 2px; padding: 2px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-pop);
}
.doc-toolbar[hidden] { display: none; }
.doc-tool-btn {
  min-width: 26px; height: 26px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 6px;
  color: var(--ink-2); font-size: 12px; cursor: pointer; font-family: var(--font-sans);
}
.doc-tool-btn:hover { background: var(--panel-2); color: var(--ink); }
.doc-tool-btn.active { color: var(--accent); background: var(--panel-2); }
.doc-tool-bold { font-weight: 700; }
.doc-tool-italic { font-style: italic; }
.doc-tool-underline { text-decoration: underline; }
.doc-tool-strikeThrough { text-decoration: line-through; }

/* 飞书文档 - 移动端：手柄靠 hover，触屏上隐藏；正文留白收紧 */
@media (max-width: 600px) {
  #doc-editor { padding: var(--notes-pad) 0; }   /* 同一个变量，切换时不横移 */
  .doc-gutter { display: none; }
  .doc-title { font-size: 22px; }
  .doc-content { font-size: 15px; }
  .doc-h1 .doc-content { font-size: 18px; }
  .doc-h2 .doc-content { font-size: 15px; }
  .doc-h3 .doc-content { font-size: 14px; }
  .doc-h4 .doc-content { font-size: 13px; }
  .doc-toolbar { transform: scale(.96); }
}

/* ============ 设计规约页（我和本站） ============ */
.spec-hero { margin-bottom: 22px; }
.spec-hero h1 {
  margin: 0 0 8px; font-size: 26px; font-weight: 700; letter-spacing: -0.5px;
}
.spec-hero h1::before { content: "▸ "; color: var(--accent); }
.spec-hero p { margin: 0; color: var(--ink-2); font-size: 14px; }
.spec-meta { margin-top: 6px !important; color: var(--muted) !important; font-size: 13px !important; }

.spec-sec {
  margin-top: 14px; padding: 20px 22px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.spec-sec > h2 {
  margin: 0 0 14px; font-size: 15px; font-weight: 600; letter-spacing: 1px; color: var(--ink);
}
.spec-sec > h2::before { content: "▸ "; color: var(--accent); }
.spec-sec ul { margin: 0; padding-left: 20px; }
.spec-sec li { color: var(--ink-2); font-size: 13px; line-height: 1.85; margin-bottom: 6px; }
.spec-sec li:last-child { margin-bottom: 0; }
.spec-sec b { color: var(--ink); font-weight: 600; }
.spec-sec code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px;
  color: var(--ink);
}
.spec-note { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.8; }
/* 令牌小节标题（4.1 色彩 / 4.2 字体 …） */
.spec-sub {
  margin: 20px 0 10px; font-size: 13px; font-weight: 600;
  color: var(--accent); letter-spacing: .5px;
}
.spec-sub:first-of-type { margin-top: 6px; }
.spec-rule { margin-top: 14px !important; }
.spec-foot {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px; text-align: center;
}

/* 色卡：色值实时读取当前主题的 CSS 变量 */
.swatches {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px;
}
.swatch {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
}
.swatch-chip {
  flex: none; width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid var(--border);
  background-image: linear-gradient(45deg, rgba(128,128,128,.18) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.18) 75%),
                    linear-gradient(45deg, rgba(128,128,128,.18) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.18) 75%);
  background-size: 10px 10px; background-position: 0 0, 5px 5px;
}
.swatch-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.45; }
.swatch-text b { font-size: 13px; font-weight: 600; color: var(--ink); }
.swatch-text i {
  font-style: normal; font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.swatch-text span { font-size: 11px; color: var(--ink-2); }

/* 字号样例 */
.spec-type { display: flex; flex-direction: column; }
.spec-type-row {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.spec-type-row:last-child { border-bottom: none; }
.spec-type-demo { color: var(--ink); line-height: 1.3; }
.spec-type-spec { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left:  auto; }

/* 表格 */
.spec-table { width: 100%; border-collapse: collapse; margin: 4px 0 0; }
.spec-table th, .spec-table td {
  border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 13px; vertical-align: top;
}
.spec-table th { background: var(--panel-2); color: var(--ink); font-weight: 600; }
.spec-table td { color: var(--ink-2); }

/* 组件演示 */
.spec-demo { display: flex; flex-wrap: wrap; gap: 22px; margin-bottom: 4px; }
.spec-demo-item { display: flex; flex-direction: column; gap: 6px; }
.spec-demo-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* 目录树样例 */
.spec-tree {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 8px;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.75; color: var(--ink);
}

@media (max-width: 600px) {
  .spec-hero h1 { font-size: 22px; }
  .spec-sec { padding: 16px 14px; }
  .spec-type-spec { margin-left: 0; }
  .swatches { grid-template-columns: 1fr; }
}

/* ============ 修改弹窗 ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 20px; background: rgba(4, 8, 12, 0.72);
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 500px; max-width: 100%; max-height: 84vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 22px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--ink); }
.modal label { display: block; color: var(--ink-2); font-size: 13px; margin: 14px 0 6px; }
.modal input {
  width: 100%; padding: 10px 12px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px; font-family: var(--font-mono);
  font-size: 14px; outline: none;
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.otp-hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.edit-add { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr auto; gap: 8px; margin: 14px 0 4px; }
.btn-primary { background: var(--accent); color: #04121a; border: none; border-radius: 6px; padding: 0 16px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn-primary:hover { filter: brightness(1.1); }
.edit-msg { color: var(--up); font-size: 13px; min-height: 18px; margin-top: 8px; }
/* 删除笔记确认框（#del-modal）：只是一段警示 + 密码 + 两个按钮 */
.del-warn { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.del-warn b { color: var(--ink); }
.del-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.edit-list { list-style: none; margin: 6px 0 0; padding: 0; }
.edit-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--border);
}
.edit-list li:last-child { border-bottom: none; }
.edit-list .e-info { font-family: var(--font-mono); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-actions { display: flex; gap: 6px; flex: none; }
.edit-edit { background: none; border: 1px solid var(--border); color: var(--accent); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 13px; flex: none; }
.edit-edit:hover { border-color: var(--accent); }
.edit-del { background: none; border: 1px solid var(--border); color: var(--up); border-radius: 6px; padding: 4px 12px; cursor: pointer; font-size: 13px; flex: none; }
.edit-del:hover { border-color: var(--up); }
@media (max-width: 600px) {
  .edit-add { grid-template-columns: 1fr 1fr; }
  .btn-primary { padding: 10px; }
}

/* ============ 动画 ============ */
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 响应式 ============ */
@media (max-width: 780px) {
  .alloc-body { gap: 20px; }
  .donut-box { margin: 0 auto; }
  .hero-value { font-size: 26px; }
  .sys-clock { display: none; }
}

/* ============ 无障碍：减少动态 ============ */
@media (prefers-reduced-motion: reduce) {
  .radar { animation: none; }
  * { transition: none !important; }
}

/* ============ 统一图标（线性、等粗笔画、currentColor） ============ */
.icon { display: block; flex: none; }
.tree-icon { display: flex; align-items: center; color: var(--ink-2); }
.tree-row.folder .tree-icon { color: var(--muted); }
.tree-icon.doc { color: #3370ff; }          /* 飞书文档：用品牌蓝区分格式，图标形状与其他笔记一致 */
.tree-icon.html { color: #1890ae; }         /* 网页笔记：同色系的青，跟飞书文档一眼区分开 */
.tree-arrow { display: flex; align-items: center; color: var(--muted); }
.tree-arrow svg { transition: transform .2s ease-out; }
.tree-arrow.open svg { transform: rotate(90deg); }

.ctl .ico-eye, .ctl .ico-eye-off, .ctl .ico-moon, .ctl .ico-sun { display: flex; }
.ctl .ico-eye-off, .ctl .ico-moon { display: none; }
.ctl.masked .ico-eye { display: none; }
.ctl.masked .ico-eye-off { display: flex; }
:root[data-theme="light"] #theme .ico-moon { display: flex; }
:root[data-theme="light"] #theme .ico-sun { display: none; }

/* ============ macOS 材质（毛玻璃） ============ */
.notes-side, .note-new-menu, .doc-menu, .doc-toolbar, .modal {
  background: var(--material);
  -webkit-backdrop-filter: var(--material-blur);
  backdrop-filter: var(--material-blur);
}
/* 不支持 backdrop-filter 的老浏览器：退回不透明底色，别让文字糊在背景上 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .notes-side, .note-new-menu, .doc-menu, .doc-toolbar, .modal { background: var(--panel); }
}

/* 新建菜单里的图标：与目录树同一套，飞书文档用品牌蓝 */
.note-new-item .ni-icon { display: flex; align-items: center; color: var(--ink-2); }
.note-new-item .ni-icon.doc { color: #3370ff; }
.note-new-item .ni-icon.html { color: #1890ae; }
.edit-btn.icon-btn .icon { color: currentColor; }

/* 目录树的键盘焦点行：程序化聚焦时 :focus-visible 不一定命中，显式给一份 */
.tree-row.focused, .outline-row.focused {
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}

/* ============ 文档里的图片块 ============ */
.doc-image { flex: 1; min-width: 0; padding: 4px 2px; }
.doc-image img {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--border); border-radius: 8px;
}
.doc-image.uploading { color: var(--muted); font-size: 13px; padding: 10px 2px; }
.doc-image.broken img { display: none; }
.doc-image.broken::after { content: "图片加载失败（文件可能已被移动或删除）"; color: var(--up); font-size: 13px; }
.doc-block.doc-image-block:hover .doc-gutter, .doc-block[data-type="image"]:hover .doc-gutter { opacity: 1; }

/* ============ 文档里的表格块 ============ */
.doc-table {
  flex: 1; min-width: 0; border-collapse: collapse; margin: 2px 0;
  table-layout: fixed; width: 100%;
}
.doc-table th, .doc-table td {
  border: 1px solid var(--border); padding: 0; vertical-align: top; text-align: left;
}
.doc-table th { background: var(--panel-2); font-weight: 600; }
.doc-table .doc-cell {
  padding: 6px 8px; outline: none; font-size: 14px; line-height: 1.6;
  min-height: 20px; word-break: break-word;
}
.doc-table .doc-cell:focus { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 2px; }
.doc-read .doc-table { margin: 10px 0; }
.doc-read .doc-table th, .doc-read .doc-table td { padding: 6px 10px; }

/* ============ 链接指向不存在的笔记（红链）============ */
.stub-note { padding: 46px 8px; max-width: 520px; }
.stub-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--ink); }
.stub-sub { margin: 0 0 20px; font-size: 13px; line-height: 1.8; color: var(--muted); word-break: break-all; }
.stub-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stub-login { font-size: 13px; color: var(--muted); }
