/* ==========================================================================
   DesignHub 界面样式
   深色外壳 + 浅色画布：设计师看稿时画布必须接近真实观感，
   周边控件用深色减少干扰、也让长时间盯屏更舒服。
   ========================================================================== */

:root {
  --bg: #171716;
  --bg-elev: #1f1f1e;
  --bg-elev2: #262624;
  --bg-hover: #2e2e2b;
  --border: #333331;
  --border-soft: #2a2a28;

  --text: #edebe4;
  --text-dim: #a8a69d;
  --text-faint: #78766e;

  --accent: #0091FF;
  --accent-soft: rgba(0, 145, 255, 0.16);
  --accent-hover: #33a7ff;
  --accent-text: #a6d8ff;
  --accent-ink: #fff;
  --accent-label: #0069b9;
  --blue: var(--accent);
  --blue-soft: rgba(0, 145, 255, 0.18);
  --teal: #1d9e75;
  --amber: #ba7517;
  --red: #e24b4a;

  --radius: 8px;
  --radius-lg: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font-family: inherit; font-size: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a3a37; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #4a4a46; }

/* ------------------------------- 通用零件 ------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 6px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  color: var(--text-dim); white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--bg-hover); color: var(--text); }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-elev2); }
.btn.sm { padding: 3px 8px; font-size: 12px; }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-size: 11px; line-height: 1.7; white-space: nowrap;
  background: var(--bg-elev2); color: var(--text-faint); border: 1px solid var(--border-soft);
}
.chip.ok { color: #5dcaa5; border-color: rgba(29,158,117,.4); background: rgba(29,158,117,.13); }
.chip.warn { color: #efb15f; border-color: rgba(186,117,23,.4); background: rgba(186,117,23,.13); }
/* 危险态：只给「数据可能不完整」这种必须停下来看一眼的情况用 */
.chip.danger { color: #f4a5a5; border-color: rgba(226,75,74,.5); background: rgba(226,75,74,.15); }
/* 批注态：走查中，还没到「出错」，但要显眼 */
.chip.review { color: #a9c8f5; border-color: rgba(0,145,255,.45); background: var(--blue-soft); }
.chip.clickable { cursor: pointer; }
.chip.clickable:hover { filter: brightness(1.18); }

.sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex: none; }
.spacer { flex: 1; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 24px; color: var(--text-faint); text-align: center;
}
.empty code { font-family: var(--mono); background: var(--bg-elev2); padding: 2px 6px; border-radius: 4px; color: var(--accent-text); }

/* -------------------------------- 顶栏 --------------------------------- */

.topbar {
  height: 46px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 500; flex: none; }
.brand .brand-logo {
  display: block; width: 100px; height: 32px; object-fit: contain; flex: none;
}
.brand .sub { color: var(--text-faint); font-weight: 400; font-size: 12px; }

.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--text-dim); min-width: 0; }
.breadcrumb .crumb { padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.breadcrumb .crumb:hover { background: var(--bg-elev2); color: var(--text); }
.breadcrumb .crumb.cur { color: var(--text); }

.searchbox {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 9px; width: 200px;
}
.search-icon {
  width: 18px; height: 18px; flex: none; color: var(--text-faint);
  stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
}
.searchbox input {
  background: none; border: none; outline: none; color: var(--text); width: 100%;
}
.searchbox input::placeholder { color: var(--text-faint); }

/* -------------------------------- 布局 --------------------------------- */

.app { display: flex; flex-direction: column; height: 100vh; }

.workspace { flex: 1; display: flex; min-height: 0; }

.panel {
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  min-height: 0;
}
.panel-left { width: 264px; flex: none; border-right: 1px solid var(--border); }
.panel-right { width: 320px; flex: none; border-left: 1px solid var(--border); }

.panel-head {
  flex: none; height: 34px; display: flex; align-items: center; gap: 6px;
  padding: 0 10px; border-bottom: 1px solid var(--border-soft);
  color: var(--text-faint); font-size: 11px; letter-spacing: .04em;
}
.panel-body { flex: 1; overflow: auto; min-height: 0; }

/* ------------------------------- 图层树 -------------------------------- */

.tree { padding: 4px 0 20px; }

.tree-row {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 6px;
  white-space: nowrap; cursor: default;
  border-left: 2px solid transparent;
}
.tree-row:hover { background: var(--bg-elev2); }
.tree-row.hovered { box-shadow: inset 0 0 0 1px var(--blue); }
.tree-row.sel { background: var(--blue-soft); border-left-color: var(--blue); }
.tree-row.has-export .tree-name::after {
  content: "切"; font-size: 9px; color: var(--teal);
  border: 1px solid rgba(29,158,117,.45); border-radius: 3px;
  padding: 0 3px; margin-left: 5px; vertical-align: 1px;
}
.tree-row.hidden-layer { opacity: .45; }

.tree-caret {
  width: 13px; height: 13px; flex: none; display: grid; place-items: center;
  color: var(--text-faint); font-size: 9px; transition: transform .12s;
}
.tree-caret.open { transform: rotate(90deg); }
.tree-caret.leaf { visibility: hidden; }

.tree-icon { width: 14px; flex: none; text-align: center; font-size: 10px; color: var(--text-faint); }
.tree-name { overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }
.tree-row.sel .tree-name { color: var(--text); }
.tree-text { color: var(--text-faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }

/* -------------------------------- 画布 -------------------------------- */

.canvas-wrap {
  flex: 1; position: relative; min-width: 0;
  background:
    repeating-conic-gradient(#1c1c1b 0% 25%, #191918 0% 50%) 50% / 22px 22px;
  overflow: auto;
}

.canvas-stage { position: relative; margin: 32px auto; }

.canvas-frame {
  position: relative;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 18px 48px rgba(0,0,0,.45);
}

.canvas-frame img.preview { display: block; width: 100%; height: 100%; }

/* 无栅格预览时的矢量兜底画布 */
.vec-root { position: absolute; inset: 0; }
.vec-node { position: absolute; }
.vec-text { position: absolute; white-space: pre; overflow: hidden; }

.hot { position: absolute; cursor: crosshair; }
.hot:hover { outline: 1px solid rgba(0,145,255,.85); outline-offset: 0; background: rgba(0,145,255,.07); }
.hot.sel { outline: 2px solid var(--blue); outline-offset: 0; background: rgba(0,145,255,.1); }
.hot.pin { outline: 1px dashed rgba(226,75,74,.9); }
#hots .hot.hovered { outline: 1px dashed #E24B4A; background: rgba(226,75,74,.06); }
#hots.quiet .hot:hover, #hots.quiet .hot.hovered { outline: none; background: none; }
#hots .hot.sel { outline: 2px solid var(--blue); background: rgba(0,145,255,.06); }
#hots .hot.pin { outline: 2px dashed #E24B4A; }

.overlay { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.overlay .m-guide { stroke: #d9364d; stroke-width: 1; fill: none; }
.overlay .m-guide line { vector-effect: non-scaling-stroke; }
.overlay .m-label-bg { fill: #d9364d; }
.overlay .m-label {
  fill: #fff; font: 500 12px var(--sans); font-variant-numeric: tabular-nums;
  text-anchor: middle; dominant-baseline: central;
}

.canvas-tools { position: sticky; top: 0; z-index: 5; }
.canvas-toolbar {
  position: relative;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 12px;
  background: rgba(31,31,30,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.zoom-label { font-family: var(--mono); color: var(--text-faint); min-width: 44px; text-align: center; }
.canvas-toolbar #canvasMeta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.measure-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
  min-height: 34px; color: var(--text-dim); font-size: 12px;
}
#measureHint { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#copyMeasure { flex: none; }

/* -------------------------------- 右栏 --------------------------------- */

.tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border-soft); flex: none; }
.tab {
  padding: 4px 10px; border-radius: 6px; color: var(--text-faint); font-size: 12px;
}
.tab:hover { background: var(--bg-elev2); color: var(--text-dim); }
.tab.active { background: var(--bg-elev2); color: var(--text); }

.tabpane { display: none; padding: 10px 12px 40px; }
.tabpane.active { display: block; }

.section { margin-bottom: 16px; }
.section-title {
  font-size: 11px; color: var(--text-faint); letter-spacing: .04em;
  margin-bottom: 7px; display: flex; align-items: center; gap: 6px;
}

.node-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; word-break: break-all; }
.node-path { font-size: 11px; color: var(--text-faint); font-family: var(--mono); word-break: break-all; margin-bottom: 12px; }

.prop-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid var(--border-soft);
}
.prop-row.token-expanded { flex-wrap: wrap; }
.prop-row:last-child { border-bottom: none; }
.prop-key { width: 74px; flex: none; color: var(--text-faint); font-size: 12px; }
.prop-val {
  flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text);
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.prop-val span.val { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.swatch {
  width: 14px; height: 14px; border-radius: 4px; flex: none;
  border: 1px solid rgba(255,255,255,.22);
  background-image: linear-gradient(45deg,#555 25%,transparent 25%,transparent 75%,#555 75%), linear-gradient(45deg,#555 25%,transparent 25%,transparent 75%,#555 75%);
  background-size: 8px 8px; background-position: 0 0, 4px 4px;
  position: relative; overflow: hidden;
}
.swatch i { position: absolute; inset: 0; display: block; }

.copy-btn {
  flex: none; padding: 1px 6px; border-radius: 4px; font-size: 11px;
  color: var(--text-dim); border: 1px solid var(--border);
}
.copy-btn:hover { background: var(--bg-elev2); color: var(--text); border-color: var(--border); }

.token-ref {
  flex: none; width: 18px; height: 18px; padding: 0; border-radius: 4px;
  position: relative; display: inline-block; color: var(--accent-text); font-size: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--border));
  background: var(--accent-soft); line-height: 1;
}
.token-ref::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px;
  border: 1px solid currentColor; transform: translate(-50%, -50%) rotate(45deg);
}
.token-ref:hover, .token-ref[aria-expanded="true"] { color: var(--text); background: var(--accent); border-color: var(--accent); }
.token-ref:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.token-popover {
  flex: 0 0 100%; min-width: 0; margin: 3px 0 1px 82px; padding: 7px 9px;
  border-left: 2px solid var(--accent); background: var(--bg-elev2);
  font-size: 11px; line-height: 1.5;
}
.token-popover-title { color: var(--text-faint); margin-bottom: 2px; }
.token-popover-value { color: var(--accent-text); font-family: var(--mono); overflow-wrap: anywhere; }
.token-popover-meta { color: var(--text-faint); overflow-wrap: anywhere; }

.code-block {
  background: #131312; border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 10px 11px; font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  white-space: pre; overflow: auto; color: #d6d3c9; max-height: 340px;
}
.code-block .k { color: var(--accent-text); }
.code-block .v { color: #7ec7a2; }

.asset-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--radius);
  border: 1px solid var(--border-soft); background: var(--bg-elev2);
  margin-bottom: 7px;
}
.asset-thumb {
  width: 38px; height: 38px; flex: none; border-radius: 6px;
  background: repeating-conic-gradient(#2c2c2a 0% 25%, #242422 0% 50%) 50% / 10px 10px;
  display: grid; place-items: center; overflow: hidden;
}
.asset-thumb img { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.asset-meta { flex: 1; min-width: 0; }
.asset-name { font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-sub { font-size: 11px; color: var(--text-faint); }
.asset-files { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.asset-file {
  font-family: var(--mono); font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
}
.asset-file:hover { border-color: var(--blue); color: var(--blue); }
.inspect-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.asset-item.selected { border-color: var(--blue); }
#paneAssets > .section .section-title { flex-wrap: wrap; }
.asset-filters { display: flex; gap: 8px; margin-bottom: 12px; }
.asset-filters input { flex: 1; width: 0; min-width: 0; }
.asset-filters select { max-width: 112px; }
.asset-notice { color: var(--amber); font-size: 12px; line-height: 1.6; }
.tree-row:focus-visible, .copy-btn:focus-visible, .zoom-label:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.token-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.token-cell {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px;
  border-radius: var(--radius); border: 1px solid var(--border-soft); background: var(--bg-elev2);
  min-width: 0;
}
.token-cell .meta { min-width: 0; }
.token-cell .hex { font-family: var(--mono); font-size: 11.5px; }
.token-cell .cnt { font-size: 10.5px; color: var(--text-faint); }
.token-cell .swatch { width: 18px; height: 18px; }

/* ------------------------------ 项目首页 ------------------------------ */

.home { flex: 1; min-height: 0; width: 100%; padding: 24px 24px 48px; overflow: auto; }

.hero { margin-bottom: 30px; }
.hero h1 { font-size: 24px; font-weight: 500; letter-spacing: -.01em; }
.hero p { color: var(--text-dim); margin-top: 6px; }
.hero .hint {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-lg);
  background: var(--bg-elev); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim);
}
.hero .hint code { font-family: var(--mono); color: var(--accent-text); background: var(--bg-elev2); padding: 1px 6px; border-radius: 4px; }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 16px; }

.proj-card {
  min-width: 0; display: flex; flex-direction: column;
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--bg-elev); overflow: hidden; cursor: pointer;
  transition: border-color .14s, transform .14s;
}
.proj-card:hover { border-color: #4a4a46; transform: translateY(-2px); }
.proj-card.has-alert { border-color: rgba(226,75,74,.45); }
.proj-card.has-alert:hover { border-color: rgba(226,75,74,.75); }

/* --------------------------- 首页警示横幅 --------------------------- */

.banner {
  margin-bottom: 16px; padding: 12px 14px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--bg-elev); font-size: 12.5px;
}
.banner.danger-banner { border-color: rgba(226,75,74,.45); background: rgba(226,75,74,.09); }
.banner-title { font-weight: 500; color: #f4a5a5; margin-bottom: 4px; }
.banner-body { color: var(--text-dim); }
.banner-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.proj-cover {
  height: 130px; flex: none; background: #131312; display: flex; gap: 8px;
  align-items: center; justify-content: center; overflow: hidden; padding: 12px;
  border-bottom: 1px solid var(--border);
}
.proj-cover img { height: 100%; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.proj-cover .noprev { color: var(--text-faint); font-size: 11px; }
.proj-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.proj-heading { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; }
.proj-name { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.proj-copy-mcp.btn { flex: none; width: 24px; height: 24px; padding: 3px; justify-content: center; }
.proj-meta { font-size: 11.5px; color: var(--text-faint); display: flex; gap: 10px; flex-wrap: wrap; }
.proj-body > .proj-meta:nth-last-child(2) { margin-bottom: 12px; }
.proj-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.proj-actions .btn { flex: 1; justify-content: center; }
.proj-context-hint {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 12px; height: 12px; border: 1px solid currentColor; border-radius: 50%;
  color: #efb15f; font-size: 9px; font-weight: 600; line-height: 1;
}

@media (max-width: 680px) {
  .home { padding: 20px 16px 32px; }
}

/* -------------------------------- Toast ------------------------------- */

.toast-host {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 7px 14px; border-radius: 20px; font-size: 12.5px;
  background: rgba(38,38,36,.97); border: 1px solid var(--border);
  color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toastIn .16s ease-out;
}
.toast.err { border-color: rgba(226,75,74,.55); color: #f4a5a5; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------ 搜索面板 ------------------------------ */

.search-panel {
  position: absolute; top: 42px; left: 12px; z-index: 20;
  width: 380px; max-height: 420px; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 16px 44px rgba(0,0,0,.5);
  display: none;
}
.search-panel.open { display: block; }
.search-hit {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.search-hit:last-child { border-bottom: none; }
.search-hit:hover { background: var(--bg-elev2); }
.search-hit .h-name { color: var(--text); }
.search-hit .h-path { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

/* --------------------------- 标注页顶部提示条 --------------------------- */

.notice-bar {
  display: flex; flex-direction: column; gap: 1px;
  border-bottom: 1px solid var(--border); flex: none;
}
.notice {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; font-size: 12.5px; background: var(--bg-elev);
  border-left: 3px solid var(--border);
}
.notice.danger { background: rgba(226,75,74,.1); border-left-color: var(--red); color: #f4a5a5; }
.notice.info { background: rgba(0,145,255,.08); border-left-color: var(--blue); color: #b9d3f3; }
.notice .n-label { font-weight: 500; flex: none; }
.notice .n-body { color: var(--text-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice.danger .n-body { color: #e7b4b4; }
.notice .spacer { flex: 1; }
.notice-hist {
  background: var(--bg-elev); border-left: 3px solid var(--border);
  padding: 4px 14px 8px; font-size: 12px;
}
.notice-hist .h-row {
  display: flex; gap: 8px; padding: 3px 0; color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
}
.notice-hist .h-row:last-child { border-bottom: none; }
.notice-hist .h-time { font-family: var(--mono); font-size: 11px; color: var(--text-faint); flex: none; }
.notice-hist .h-who { color: var(--text-faint); flex: none; }

/* ------------------------------ 批注打点 ------------------------------ */

.cmt-pin {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50% 50% 50% 2px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff; cursor: pointer; z-index: 30;
  background: var(--red); border: 1.5px solid rgba(255,255,255,.85);
  box-shadow: 0 2px 8px rgba(0,0,0,.45); transition: transform .12s;
  /* 角标层整体不接事件（否则会挡住宿主的 hover 热区），但角标自己要能点 */
  pointer-events: auto;
}
.cmt-pin:hover { transform: scale(1.18); }
.cmt-pin.resolved { background: var(--teal); }
.cmt-pin.orphaned { background: var(--amber); }
.cmt-pin.active { outline: 2px solid #fff; outline-offset: 1px; }
.cmt-pin.hidden-by-filter { display: none; }

#hots.comment-mode { cursor: crosshair; }
#hots.comment-mode .hot:hover { background: rgba(226,75,74,.22) !important; }

/* ------------------------------ 批注面板 ------------------------------ */

.cmt-list { padding: 10px; display: flex; flex-direction: column; gap: 9px; }
.cmt-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); overflow: hidden;
}
.cmt-card.resolved { opacity: .62; }
.cmt-card.active { border-color: var(--accent); }
.cmt-head {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px;
  background: var(--bg-elev2); border-bottom: 1px solid var(--border-soft); font-size: 11.5px;
}
.cmt-idx {
  width: 18px; height: 18px; flex: none; border-radius: 50% 50% 50% 2px;
  background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
}
.cmt-card.resolved .cmt-idx { background: var(--teal); }
.cmt-card.orphaned .cmt-idx { background: var(--amber); }
.cmt-who { color: var(--text); }
.cmt-time { color: var(--text-faint); font-family: var(--mono); font-size: 10.5px; }
.cmt-anchor {
  padding: 5px 10px; font-size: 11px; color: var(--text-faint); font-family: var(--mono);
  border-bottom: 1px solid var(--border-soft); word-break: break-all;
}
.cmt-body { padding: 8px 10px; white-space: pre-wrap; word-break: break-word; }
.cmt-replies { padding: 0 10px 4px; display: flex; flex-direction: column; gap: 6px; }
.cmt-reply {
  padding: 6px 8px; border-radius: 6px; background: var(--bg-elev2);
  border-left: 2px solid var(--border); font-size: 12px;
}
.cmt-reply .r-head { font-size: 10.5px; color: var(--text-faint); margin-bottom: 2px; }
.cmt-acts { display: flex; gap: 6px; padding: 7px 10px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.cmt-form { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 10px; }
.cmt-form.hidden { display: none; }
.cmt-input {
  width: 100%; min-height: 54px; resize: vertical; padding: 6px 8px;
  background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 12.5px; font-family: inherit;
}
.cmt-input:focus { outline: none; border-color: var(--accent); }
.cmt-hint-row {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px 2px;
  font-size: 11.5px; color: var(--text-faint);
}
.cmt-filters { display: flex; gap: 6px; padding: 10px 10px 0; }

/* 打点时的浮层输入框 */
.cmt-pop {
  position: absolute; z-index: 60; width: 250px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0,0,0,.55); padding: 9px;
  display: flex; flex-direction: column; gap: 7px;
}
.cmt-pop .p-anchor { font-size: 11px; color: var(--text-faint); font-family: var(--mono); word-break: break-all; }

.hidden { display: none !important; }

/* ------------------------------- 快捷键表 ------------------------------ */

.kbd {
  display: inline-block; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-elev2);
  font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
}

/* ---------------------------- 项目协作工作区 ---------------------------- */

.save-state { font-size: 11.5px; color: var(--text-faint); }
.save-state.dirty { color: #efb15f; }
.btn:disabled { opacity: .5; cursor: default; }

.project-workspace {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr);
}

.workspace-sidebar {
  min-height: 0; padding: 24px 14px; border-right: 1px solid var(--border);
  background: var(--bg-elev); display: flex; flex-direction: column;
}
.workspace-title { display: flex; flex-direction: column; padding: 0 10px 18px; }
.workspace-title strong { margin-top: 4px; font-size: 16px; font-weight: 600; color: var(--text); }
.workspace-title > span:last-child { margin-top: 3px; font-size: 11px; color: var(--text-faint); }
.eyebrow { color: var(--text-faint); font-size: 11px; }

.workspace-nav { display: flex; flex-direction: column; gap: 2px; }
.workspace-nav a {
  padding: 7px 10px; border-radius: 6px; color: var(--text-dim); font-size: 12.5px;
  border-left: 2px solid transparent;
}
.workspace-nav a:hover { color: var(--text); background: var(--bg-elev2); }
.workspace-nav a.active { color: var(--accent-text); background: var(--accent-soft); border-left-color: var(--accent); }

.workspace-health { margin-top: auto; padding: 18px 10px 2px; }
.health-label { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); }
.health-label strong { color: var(--text); font-family: var(--mono); font-weight: 500; }
.health-track { height: 4px; margin-top: 8px; border-radius: 2px; overflow: hidden; background: var(--bg); }
.health-track i { display: block; height: 100%; border-radius: inherit; background: var(--teal); transition: width .2s; }
.workspace-health p { margin-top: 7px; font-size: 10.5px; line-height: 1.45; color: var(--text-faint); }

.workspace-content { min-width: 0; overflow: auto; scroll-behavior: smooth; background: #1a1a19; }
.workspace-header, .workspace-section, .workspace-footer { width: min(960px, calc(100% - 64px)); margin: 0 auto; }
.workspace-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 42px 0 28px; border-bottom: 1px solid var(--border);
}
.workspace-header h1 { margin-top: 6px; font-size: 25px; line-height: 1.3; font-weight: 550; letter-spacing: 0; }
.workspace-header p { margin-top: 7px; color: var(--text-dim); }

.workspace-section { padding: 30px 0 34px; border-bottom: 1px solid var(--border); scroll-margin-top: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 32px; margin-bottom: 20px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { font-size: 16px; font-weight: 550; letter-spacing: 0; }
.section-index { color: var(--accent); font: 11px var(--mono); }
.section-heading p { max-width: 430px; color: var(--text-faint); font-size: 12px; text-align: right; }
.section-heading code { font-family: var(--mono); color: var(--accent-text); }

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.field.wide { margin-bottom: 14px; }
.field > span { color: var(--text-dim); font-size: 12px; font-weight: 500; }
.field > span b { margin-left: 4px; color: #efb15f; font-size: 10px; font-weight: 500; }
.field input, .field textarea, .mini-field input, .mini-field textarea, .mini-field select {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; outline: none;
  background: var(--bg-elev); color: var(--text); padding: 8px 10px; line-height: 1.55;
}
.field textarea, .mini-field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field textarea:focus, .mini-field input:focus, .mini-field textarea:focus, .mini-field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
.field input::placeholder, .field textarea::placeholder, .mini-field input::placeholder, .mini-field textarea::placeholder { color: #65635d; }

.list-editor { display: flex; flex-direction: column; gap: 6px; }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) 28px; gap: 5px; }
.list-row input { min-width: 0; }
.list-row button, .icon-remove {
  border-radius: 5px; color: var(--text-faint); font-size: 18px; line-height: 1;
}
.list-row button:hover, .icon-remove:hover { background: rgba(226,75,74,.13); color: #f4a5a5; }
.list-add { align-self: flex-start; color: var(--blue); padding: 3px 1px; font-size: 11.5px; }
.list-add:hover { color: #76b7ed; }
.code-list input { font-family: var(--mono); font-size: 12px; }

.record-list { display: flex; flex-direction: column; gap: 10px; }
.record-card { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.record-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.record-head strong { color: var(--text-dim); font-size: 11.5px; font-weight: 500; }
.icon-remove { width: 26px; height: 24px; }
.record-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.mini-field { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.mini-field.full { grid-column: 1 / -1; }
.mini-field > span { color: var(--text-faint); font-size: 10.5px; }
.mini-field input, .mini-field textarea, .mini-field select { padding: 6px 8px; font-size: 12px; }
.record-list.compact .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.add-record { margin-top: 10px; }
.workspace-footer { padding: 18px 0 44px; color: var(--text-faint); font-size: 11px; }

@media (max-width: 920px) {
  .project-workspace { grid-template-columns: 180px minmax(0, 1fr); }
  .workspace-header, .workspace-section, .workspace-footer { width: calc(100% - 36px); }
  .form-grid.three { grid-template-columns: 1fr; }
  .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { overflow: auto; }
  .topbar .breadcrumb, .topbar .save-state, .topbar #copyContextBtn { display: none; }
  .project-workspace { display: block; }
  .workspace-sidebar { display: none; }
  .workspace-content { overflow: visible; }
  .workspace-header, .workspace-section, .workspace-footer { width: calc(100% - 28px); }
  .workspace-header { padding-top: 28px; }
  .workspace-header h1 { font-size: 21px; }
  .section-heading { display: block; }
  .section-heading p { margin-top: 5px; text-align: left; }
  .form-grid.two, .form-grid.four, .record-grid, .record-list.compact .record-grid { grid-template-columns: 1fr; }
  .mini-field.full { grid-column: auto; }
}

/* ----------------------------- 项目文档工作区 ----------------------------- */

.document-page { overflow: hidden; }
.document-app { height: 100dvh; min-height: 0; }
.document-topbar { position: relative; z-index: 40; }
.document-topbar .crumb-separator { color: var(--text-faint); }
.document-topbar .save-state { min-width: 76px; text-align: right; }
.document-topbar .save-state.dirty { color: #efb15f; }
.dialog-backdrop {
  position: fixed; z-index: 80; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(0,0,0,.62);
}
.dialog-card {
  width: min(380px, 100%); padding: 22px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-elev); box-shadow: 0 18px 60px rgba(0,0,0,.42);
}
.dialog-card h2 { margin-bottom: 7px; font-size: 16px; font-weight: 570; }
.dialog-card p { margin-bottom: 18px; color: var(--text-dim); font-size: 12px; line-height: 1.65; }
.dialog-card label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 12px; }
.dialog-card input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 7px;
  outline: 0; background: var(--bg); color: var(--text); font: inherit;
}
.dialog-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog-error { min-height: 19px; margin-top: 7px; color: #f4a5a5; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.document-workspace {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: #1a1a19;
}
.document-sidebar {
  z-index: 30; min-height: 0; padding: 18px 12px 14px;
  display: flex; flex-direction: column;
  background: var(--bg-elev); border-right: 1px solid var(--border);
}
.document-sidebar-head {
  min-height: 30px; padding: 0 8px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.document-sidebar-head strong { font-size: 12px; color: var(--text-dim); font-weight: 550; }
.icon-button {
  width: 30px; height: 30px; flex: none; display: inline-grid; place-items: center;
  color: var(--text-faint); border-radius: 6px;
}
.icon-button:hover { color: var(--text); background: var(--bg-hover); }
.document-close-toc { display: none; font-size: 21px; line-height: 1; }
.document-open-toc { display: none; }
.document-sidebar-backdrop { display: none; }
.document-toc { flex: 1; min-height: 0; overflow: auto; padding: 3px 0 12px; }
.document-toc-link {
  width: 100%; min-height: 31px; padding: 5px 9px 5px calc(9px + var(--toc-depth, 0) * 14px);
  display: block; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap;
  border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
  color: var(--text-faint); font-size: 12px;
}
.document-toc-link:hover { color: var(--text); background: var(--bg-elev2); }
.document-toc-link.active { color: var(--accent-text); background: var(--accent-soft); border-left-color: var(--accent); }
.document-toc-empty { display: block; padding: 9px; color: var(--text-faint); font-size: 11.5px; line-height: 1.6; }
.document-toc-help {
  padding: 11px 8px 2px; border-top: 1px solid var(--border-soft);
  color: var(--text-faint); font-size: 10.5px; line-height: 1.55;
}

.document-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.document-header {
  height: 68px; flex: none; padding: 0 18px 0 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border-bottom: 1px solid var(--border); background: #1a1a19;
}
.document-title-row { display: flex; align-items: center; min-width: 0; gap: 8px; }
.document-header h1 { margin-top: 1px; font-size: 17px; line-height: 1.25; font-weight: 570; letter-spacing: 0; }
.document-modes {
  height: 30px; flex: none; padding: 2px; display: flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg-elev);
}
.document-modes button { min-width: 48px; padding: 0 9px; border-radius: 5px; color: var(--text-faint); font-size: 11.5px; }
.document-modes button:hover { color: var(--text); }
.document-modes button.active { background: var(--bg-hover); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.28); }

.document-status {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-faint);
}
.document-status.error { color: #f4a5a5; }
.document-panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.document-panes[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.document-panes[data-mode="edit"] .document-preview,
.document-panes[data-mode="preview"] .document-source { display: none; }
.document-source, .document-preview { min-width: 0; min-height: 0; }
.document-source {
  display: flex; flex-direction: column; background: #191918;
  border-right: 1px solid var(--border);
}
.document-pane-label {
  height: 34px; flex: none; padding: 0 14px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-soft); color: var(--text-faint); font-size: 10.5px;
}
.document-pane-label strong { color: var(--text-dim); font-size: 11px; font-weight: 550; }
#documentEditor {
  width: 100%; flex: 1; min-height: 0; padding: 24px clamp(18px, 4vw, 48px) 64px;
  resize: none; border: 0; outline: 0; background: transparent; color: #dedcd5;
  font: 13.5px/1.72 var(--mono); tab-size: 2; caret-color: var(--accent);
}
#documentEditor::placeholder { color: #5f5d57; }
#documentEditor::selection { background: rgba(0,145,255,.38); }

.document-preview { overflow: auto; scroll-behavior: smooth; background: #1c1c1b; }
.markdown-document, .document-empty {
  width: min(780px, calc(100% - 64px)); margin: 0 auto; padding: 48px 0 92px;
}
.markdown-document { color: #d6d4cd; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
.markdown-document > :first-child { margin-top: 0; }
.markdown-document h1, .markdown-document h2, .markdown-document h3,
.markdown-document h4, .markdown-document h5, .markdown-document h6 {
  scroll-margin-top: 36px; color: var(--text); font-weight: 590; letter-spacing: 0; line-height: 1.35;
}
.markdown-document h1 { margin: 0 0 24px; padding-bottom: 14px; border-bottom: 1px solid var(--border); font-size: 28px; }
.markdown-document h2 { margin: 38px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); font-size: 20px; }
.markdown-document h3 { margin: 30px 0 10px; font-size: 17px; }
.markdown-document h4 { margin: 24px 0 8px; font-size: 15px; }
.markdown-document h5, .markdown-document h6 { margin: 20px 0 8px; font-size: 14px; color: var(--text-dim); }
.markdown-document p { margin: 0 0 15px; }
.markdown-document ul, .markdown-document ol { margin: 0 0 16px; padding-left: 25px; }
.markdown-document li { margin: 4px 0; padding-left: 2px; }
.markdown-document li > ul, .markdown-document li > ol { margin: 4px 0; }
.markdown-document .task-list-item { list-style: none; margin-left: -22px; }
.markdown-document .task-list-item input { margin: 0 8px 0 0; accent-color: var(--accent); }
.markdown-document a { color: #72b4ed; text-decoration: underline; text-underline-offset: 3px; }
.markdown-document strong { color: #eceae3; font-weight: 620; }
.markdown-document code {
  padding: 2px 5px; border: 1px solid var(--border-soft); border-radius: 4px;
  background: var(--bg-elev2); color: var(--accent-text); font: 12.5px/1.6 var(--mono);
}
.markdown-document pre {
  margin: 18px 0; padding: 15px 17px; overflow: auto;
  border: 1px solid var(--border); border-radius: 7px; background: #151514;
}
.markdown-document pre code { padding: 0; border: 0; background: transparent; color: #d6d4cd; white-space: pre; }
.markdown-document blockquote {
  margin: 18px 0; padding: 10px 16px; border-left: 3px solid var(--accent);
  background: rgba(0,145,255,.08); color: var(--text-dim);
}
.markdown-document blockquote > :last-child { margin-bottom: 0; }
.markdown-document hr { margin: 32px 0; border: 0; border-top: 1px solid var(--border); }
.markdown-document img { display: block; max-width: 100%; height: auto; margin: 18px 0; border-radius: 6px; }
.markdown-table-wrap { max-width: 100%; margin: 18px 0; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.markdown-document table { width: 100%; border-collapse: collapse; font-size: 13px; }
.markdown-document th, .markdown-document td { min-width: 100px; padding: 8px 11px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; }
.markdown-document th:last-child, .markdown-document td:last-child { border-right: 0; }
.markdown-document tbody tr:last-child td { border-bottom: 0; }
.markdown-document th { background: var(--bg-elev2); color: var(--text); font-weight: 550; }
.markdown-document .markdown-raw-html { color: var(--text-faint); white-space: pre-wrap; }
.markdown-render-error { color: #f4a5a5; }

.document-empty { height: 100%; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.document-empty strong { font-size: 16px; font-weight: 560; }
.document-empty p { margin: 7px 0 16px; color: var(--text-faint); }
.document-footer {
  min-height: 30px; flex: none; padding: 5px 14px; display: flex; align-items: center; gap: 18px;
  border-top: 1px solid var(--border); background: var(--bg-elev); color: var(--text-faint); font-size: 10.5px;
}
.document-footer #updatedAt { margin-left: auto; }

@media (max-width: 920px) {
  .document-workspace { grid-template-columns: minmax(0, 1fr); }
  .document-sidebar {
    position: fixed; top: 46px; bottom: 0; left: 0; width: min(280px, 84vw);
    transform: translateX(-102%); transition: transform .18s ease; box-shadow: 14px 0 42px rgba(0,0,0,.38);
  }
  .document-toc-open .document-sidebar { transform: translateX(0); }
  .document-close-toc, .document-open-toc { display: inline-grid; }
  .document-sidebar-backdrop {
    position: fixed; z-index: 20; inset: 46px 0 0; display: block;
    pointer-events: none; opacity: 0; background: rgba(0,0,0,.48); transition: opacity .18s ease;
  }
  .document-toc-open .document-sidebar-backdrop { pointer-events: auto; opacity: 1; }
}

@media (max-width: 680px) {
  body.document-page { overflow: hidden; }
  .document-topbar .breadcrumb, .document-topbar #copyContextBtn { display: none; }
  .document-topbar .save-state { display: inline; min-width: auto; }
  .document-header { height: 62px; padding: 0 10px; }
  .document-header .eyebrow { display: none; }
  .document-header h1 { font-size: 15px; }
  .document-modes button { min-width: 40px; padding: 0 6px; }
  .document-modes button[data-mode="split"] { display: none; }
  .document-panes[data-mode="split"] { grid-template-columns: minmax(0, 1fr); }
  .document-panes[data-mode="split"] .document-preview { display: none; }
  #documentEditor { padding: 18px 16px 56px; font-size: 13px; }
  .markdown-document, .document-empty { width: calc(100% - 32px); padding-top: 30px; }
  .markdown-document h1 { font-size: 24px; }
  .markdown-document h2 { font-size: 19px; }
  .document-footer { gap: 10px; }
  .document-shortcut { display: none; }
}
