/* ==========================================================================
   view-arther · Apple Design 风格主题
   ========================================================================== */
:root {
  /* 深色（Apple Dark） */
  --bg: #000000;
  --bg2: #1c1c1e;
  --bg3: #2c2c2e;
  --elevated: #2c2c2e;
  --border: #38383a;
  --border-soft: rgba(255, 255, 255, 0.08);
  --fg: #f5f5f7;
  --fg-dim: #98989d;
  --fg-faint: #636366;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --green: #30d158;
  --red: #ff453a;
  --yellow: #ffd60a;
  --purple: #bf5af2;
  --radius: 10px;
  --radius-lg: 16px;
  --pill: 980px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.65), 0 2px 8px rgba(0, 0, 0, 0.4);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --on-accent: #ffffff;
  --term-bg: #141416;
  --scrollbar: rgba(255, 255, 255, 0.18);
  --scrollbar-hover: rgba(255, 255, 255, 0.3);
  --topbar-bg: rgba(28, 28, 30, 0.72);
  --sidebar-bg: rgba(28, 28, 30, 0.6);
  --overlay-bg: rgba(0, 0, 0, 0.55);
  --toast-bg: rgba(44, 44, 46, 0.82);
  --row-alt: rgba(255, 255, 255, 0.03);
  --cm-linenumber: #48484a;
  --cm-activeline: rgba(255, 255, 255, 0.045);
  --cm-selection: rgba(10, 132, 255, 0.28);
  --hairline: rgba(255, 255, 255, 0.06);
}

/* ============================== 浅色主题（Apple Light） ============================== */
[data-theme="light"] {
  --bg: #f5f5f7;
  --bg2: #ffffff;
  --bg3: #e8e8ed;
  --elevated: #ffffff;
  --border: #d2d2d7;
  --border-soft: rgba(0, 0, 0, 0.06);
  --fg: #1d1d1f;
  --fg-dim: #6e6e73;
  --fg-faint: #aeaeb2;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.1);
  --green: #248a3d;
  --red: #ff3b30;
  --yellow: #c93400;
  --purple: #af52de;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  --on-accent: #ffffff;
  --term-bg: #fafafc;
  --scrollbar: rgba(0, 0, 0, 0.18);
  --scrollbar-hover: rgba(0, 0, 0, 0.32);
  --topbar-bg: rgba(255, 255, 255, 0.72);
  --sidebar-bg: rgba(250, 250, 252, 0.7);
  --overlay-bg: rgba(245, 245, 247, 0.6);
  --toast-bg: rgba(255, 255, 255, 0.85);
  --row-alt: rgba(0, 0, 0, 0.025);
  --cm-linenumber: #c7c7cc;
  --cm-activeline: rgba(0, 0, 0, 0.035);
  --cm-selection: rgba(0, 122, 255, 0.16);
  --hairline: rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 var(--sans);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

/* 线性图标（Lucide 风格 stroke） */
.svg-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; flex: none; vertical-align: -2px;
}
.svg-ic svg { width: 100%; height: 100%; display: block; }

/* 细滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================== 顶栏（毛玻璃） ============================== */
#topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
  position: relative;
  z-index: 20;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.brand .logo {
  display: inline-flex; align-items: center;
  filter: drop-shadow(0 1px 4px rgba(10, 132, 255, 0.35));
}
.brand .root {
  color: var(--fg-dim); font-weight: 500; font-size: 11.5px;
  background: var(--bg3);
  padding: 3px 11px; border-radius: var(--pill); margin-left: 6px;
  font-family: var(--mono);
}
.status { display: flex; align-items: center; gap: 12px; }
.save-state { color: var(--fg-faint); font-size: 12px; transition: color 0.2s; }
.save-state.saved { color: var(--green); }

.conn {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); display: inline-block;
  transition: background 0.3s;
}
.conn.online { background: var(--green); box-shadow: 0 0 6px rgba(48, 209, 88, 0.7); }

.users { display: flex; align-items: center; padding-right: 6px; }
.avatar {
  width: 27px; height: 27px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--on-accent); font-weight: 700;
  margin-left: -8px; border: 2px solid var(--bg2);
  cursor: default; position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.avatar:hover { transform: translateY(-2px) scale(1.08); z-index: 2; }
.avatar.editing::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow); border: 2px solid var(--bg2);
}
.avatar .ic-img { font-size: 14px; line-height: 1; }

.me { font-size: 13px; color: var(--fg); font-weight: 500; }
button.logout {
  padding: 4px 13px; font-size: 12px; color: var(--fg-dim); border-radius: var(--pill);
  border-color: transparent; background: var(--bg3);
}
button.logout:hover { color: var(--red); background: rgba(255, 69, 58, 0.12); }

/* ============================== 布局 ============================== */
#layout { display: flex; height: calc(100% - 52px); }

/* ============================== 侧边栏（毛玻璃） ============================== */
#sidebar {
  width: var(--sidebar-w, 280px); min-width: var(--sidebar-w, 280px);
  background: var(--sidebar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  position: relative;
}
/* 宽度拖拽把手：吸附在侧栏右缘 */
#sideDrag {
  position: absolute; top: 0; right: -4px; bottom: 0;
  width: 8px; cursor: col-resize; z-index: 15;
}
#sideDrag::after {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: 3px; width: 2px; border-radius: 1px;
  background: transparent; transition: background 0.15s;
}
#sideDrag:hover::after, body.side-dragging #sideDrag::after {
  background: var(--accent);
}
body.side-dragging { cursor: col-resize; user-select: none; }
body.side-dragging iframe, body.side-dragging .CodeMirror { pointer-events: none; }
.side-actions {
  padding: 10px; display: flex; gap: 6px;
  border-bottom: 1px solid var(--hairline);
}
.side-actions button {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--bg3); color: var(--fg); border: none;
  border-radius: var(--pill); padding: 6px 10px; cursor: pointer; font-size: 12px;
  font-weight: 500; transition: all 0.18s;
}
.side-actions button:last-child { flex: 0 0 auto; }
.side-actions button:hover { background: var(--accent-soft); color: var(--accent); }
.side-actions button:active { transform: scale(0.96); }

#treeDropZone { position: relative; display: flex; flex: 1; min-height: 0; }
.tree { overflow: auto; flex: 1; width: 100%; min-height: 0; padding: 8px 8px; }
.tree.file-drag-active, .tree.tree-move-active {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.tree .row.drop-target, .tree .row.drop-target:hover {
  background: var(--accent-soft); color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tree-drop-hint {
  position: absolute; left: 14px; right: 14px; bottom: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  max-width: calc(100% - 28px); padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: var(--pill); background: var(--toast-bg); color: var(--accent);
  box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  pointer-events: none; font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-drop-hint #treeDropText { overflow: hidden; text-overflow: ellipsis; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; border-left: 1px solid var(--hairline); }
.tree > ul { padding-left: 2px; border-left: none; }
.tree .row {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px; margin: 1px 0; border-radius: 8px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--fg-dim);
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.tree .row:hover { background: var(--row-alt); color: var(--fg); }
[data-theme="light"] .tree .row:hover { background: rgba(0, 0, 0, 0.05); }
/* 多选（Ctrl/Cmd 点选、Shift 连选）：比 .active 淡一档，可整批拖拽 */
.tree .row.selected { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--fg); }
.tree .row.selected .icon.folder, .tree .row.selected .icon.file { color: var(--accent); }
.tree .row.drag-source { opacity: 0.45; }
.tree .row.active { background: var(--accent-soft); color: var(--accent); }
.tree .twisty { width: 12px; color: var(--fg-faint); flex: none; text-align: center; font-size: 9px; }
.tree .icon { flex: none; display: inline-flex; }
.tree .icon .svg-ic { width: 15px; height: 15px; }
.tree .icon.folder { color: var(--accent); }
.tree .icon.file { color: var(--fg-faint); }
.tree .row.active .icon.file { color: var(--accent); }
.tree .name { overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 450; }
.tree .badge {
  flex: none; font-size: 10px; color: var(--on-accent);
  padding: 1px 7px; border-radius: var(--pill); margin-left: 4px; font-weight: 600;
}
.tree .row .ops { display: none; margin-left: auto; flex: none; }
.tree .row:hover .ops { display: inline-flex; gap: 2px; }
.tree .ops button {
  background: none; border: none; color: var(--fg-faint); cursor: pointer;
  padding: 2px 4px; border-radius: 6px; display: inline-flex; align-items: center;
}
.tree .ops button:hover { color: var(--fg); background: var(--bg3); }

/* ============================== 主区 ============================== */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.crumb {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 20px; border-bottom: 1px solid var(--hairline);
  background: var(--bg);
}
.crumb-path {
  color: var(--fg-dim); font-family: var(--mono); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lock-info { font-size: 12px; color: var(--yellow); }

/* Apple 风格按钮：胶囊形、无硬边框、轻按压反馈 */
button {
  background: var(--bg3); color: var(--fg); border: none;
  border-radius: var(--pill); padding: 6px 16px; cursor: pointer; font-size: 13px;
  font-weight: 500; font-family: inherit; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.18s;
}
button:hover { background: var(--accent-soft); color: var(--accent); }
button:active { transform: scale(0.96); }
button.primary {
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  box-shadow: 0 1px 4px rgba(10, 132, 255, 0.35);
}
button.primary:hover { background: var(--accent); filter: brightness(1.1); color: var(--on-accent); }
button.primary:active { filter: brightness(0.94); }

button.theme-btn {
  background: none; padding: 5px; width: 30px; height: 30px;
  border-radius: 50%; color: var(--fg-dim);
}
button.theme-btn:hover { background: var(--bg3); color: var(--fg); }
button.theme-btn .svg-ic { width: 17px; height: 17px; vertical-align: 0; }
button.danger { color: var(--red); }
button.danger:hover { background: rgba(255, 69, 58, 0.12); color: var(--red); }

/* ============================== 内容视图 ============================== */
.viewer {
  flex: 1; overflow: auto; padding: 36px 44px 90px;
  animation: fadein 0.25s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
.viewer.empty { display: flex; align-items: center; justify-content: center; }
.placeholder { color: var(--fg-faint); text-align: center; line-height: 2.2; font-size: 14px; }
.viewer img { max-width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.viewer.raw-img { display: flex; align-items: flex-start; justify-content: center; }
.viewer.drawio-view { padding: 16px; overflow: auto; }
.viewer.drawio-view > .drawio-container {
  width: 100%; max-width: none; min-height: 360px; margin: 0 auto;
}
.viewer.drawio-view img { max-width: none; border-radius: 0; box-shadow: none; }
.drawio-loading { color: var(--fg-dim); text-align: center; padding: 48px 16px; }
.drawio-error {
  color: var(--red); background: rgba(255, 69, 58, 0.09);
  border: 1px solid rgba(255, 69, 58, 0.25); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}

/* markdown 排版 */
.viewer > *:not(pre) { max-width: 880px; }
.viewer h1, .viewer h2, .viewer h3, .viewer h4 {
  border-bottom: 1px solid var(--hairline); padding-bottom: 8px;
  margin: 1.4em 0 0.7em; line-height: 1.25; letter-spacing: -0.02em;
}
.viewer h1 { font-size: 1.8em; font-weight: 700; }
.viewer h2 { font-size: 1.45em; font-weight: 650; }
.viewer h3 { font-size: 1.2em; font-weight: 600; }
.viewer a { color: var(--accent); text-decoration: none; }
.viewer a:hover { text-decoration: underline; }
.viewer code {
  background: var(--bg3); border-radius: 6px; padding: 2px 7px;
  font-family: var(--mono); font-size: 0.88em;
}
.viewer pre {
  background: var(--bg2); border: 1px solid var(--hairline);
  border-radius: var(--radius-lg); padding: 14px 18px; overflow: auto;
  max-width: 880px;
}
.viewer pre code { background: none; padding: 0; font-size: 13px; line-height: 1.6; }
.viewer table { border-collapse: collapse; margin: 12px 0; }
.viewer th, .viewer td { border: 1px solid var(--border); padding: 7px 14px; }
.viewer th { background: var(--bg2); font-weight: 600; }
.viewer tr:nth-child(even) td { background: var(--row-alt); }
.viewer blockquote {
  border-left: 3px solid var(--accent); margin: 12px 0; padding: 6px 18px;
  color: var(--fg-dim); background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.viewer hr { border: none; border-top: 1px solid var(--hairline); margin: 24px 0; }
.viewer li::marker { color: var(--fg-faint); }
.viewer input[type="checkbox"] { accent-color: var(--accent); margin-right: 4px; }

/* ============================== CodeMirror 编辑器 ============================== */
.editor-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drawio-editor { position: relative; flex: 1; min-height: 0; width: 100%; }
.drawio-editor-frame {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff;
}
.drawio-editor-status {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  padding: 32px; background: var(--bg); color: var(--fg-dim);
  text-align: center; line-height: 1.7;
}
.drawio-editor-status > span { max-width: 560px; }
.drawio-retry {
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: var(--pill); padding: 7px 18px; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.drawio-retry:hover { filter: brightness(1.1); }
.drawio-retry:active { transform: scale(0.97); }
.editor-wrap .CodeMirror {
  flex: 1; height: auto;
  background: var(--bg); color: var(--fg);
  font: 14px/1.75 var(--mono);
  padding: 12px 0;
}
/* WYSIWYG（HyperMD）模式：正文用无衬线字体，更像文档 */
.editor-wrap .CodeMirror.cm-s-hypermd {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
}
.editor-wrap .cm-s-hypermd pre.HyperMD-codeblock,
.editor-wrap .cm-s-hypermd span.cm-inline-code {
  font-family: var(--mono);
}
/* 暗色主题下 HyperMD 内置位图资源反色 */
[data-theme="dark"] .cm-s-hypermd span.cm-formatting-task,
[data-theme="dark"] .cm-s-hypermd span.hmd-link-icon {
  filter: invert(0.85);
}
/* 折叠后的代码块占位符 */
.cm-s-hypermd .hmd-fold-code-stub {
  background: var(--bg3); color: var(--fg-dim); border-color: var(--border);
}
.cm-s-hypermd .hmd-fold-code-stub:hover {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
.CodeMirror-gutters {
  background: var(--bg) !important; border-right: 1px solid var(--hairline) !important;
}
.CodeMirror-linenumber { color: var(--cm-linenumber) !important; font-size: 12px !important; padding: 0 12px 0 16px !important; }
.CodeMirror-activeline-background { background: var(--cm-activeline) !important; }
.CodeMirror-activeline .CodeMirror-linenumber { color: var(--fg-faint) !important; }
.CodeMirror-cursor { border-left: 2px solid var(--accent) !important; }
.CodeMirror-selected { background: var(--cm-selection) !important; }

/* markdown 语法高亮（va-dark · Apple Dark 配色） */
.cm-s-va-dark .cm-header { color: #0a84ff; font-weight: 600; }
.cm-s-va-dark .cm-header-1 { font-size: 1.35em; }
.cm-s-va-dark .cm-header-2 { font-size: 1.2em; }
.cm-s-va-dark .cm-header-3 { font-size: 1.1em; }
.cm-s-va-dark .cm-comment { color: #98989d; }
.cm-s-va-dark .cm-quote { color: #98989d; font-style: italic; }
.cm-s-va-dark .cm-string { color: #66d4cf; }
.cm-s-va-dark .cm-link { color: #409cff; }
.cm-s-va-dark .cm-url { color: #636366; }
.cm-s-va-dark .cm-strong { color: #ff9f0a; font-weight: 700; }
.cm-s-va-dark .cm-em { color: #bf5af2; font-style: italic; }
.cm-s-va-dark .cm-strikethrough { color: #636366; }
.cm-s-va-dark .cm-keyword { color: #ff453a; }
.cm-s-va-dark .cm-atom { color: #64d2ff; }
.cm-s-va-dark .cm-number { color: #64d2ff; }
.cm-s-va-dark .cm-variable-2 { color: #ff9f0a; }
.cm-s-va-dark .cm-tag { color: #30d158; }
.cm-s-va-dark .cm-attribute { color: #64d2ff; }
.cm-s-va-dark .cm-hr { color: #48484a; font-weight: 700; }
.cm-s-va-dark .cm-formatting { color: #48484a; opacity: 0.8; }

/* markdown 语法高亮（va-light · Apple Light 配色） */
.cm-s-va-light .cm-header { color: #007aff; font-weight: 600; }
.cm-s-va-light .cm-header-1 { font-size: 1.35em; }
.cm-s-va-light .cm-header-2 { font-size: 1.2em; }
.cm-s-va-light .cm-header-3 { font-size: 1.1em; }
.cm-s-va-light .cm-comment { color: #6e6e73; }
.cm-s-va-light .cm-quote { color: #6e6e73; font-style: italic; }
.cm-s-va-light .cm-string { color: #0a5c8f; }
.cm-s-va-light .cm-link { color: #007aff; }
.cm-s-va-light .cm-url { color: #aeaeb2; }
.cm-s-va-light .cm-strong { color: #c93400; font-weight: 700; }
.cm-s-va-light .cm-em { color: #8944ab; font-style: italic; }
.cm-s-va-light .cm-strikethrough { color: #6e6e73; }
.cm-s-va-light .cm-keyword { color: #d70015; }
.cm-s-va-light .cm-atom { color: #0040dd; }
.cm-s-va-light .cm-number { color: #0040dd; }
.cm-s-va-light .cm-variable-2 { color: #a05a00; }
.cm-s-va-light .cm-tag { color: #248a3d; }
.cm-s-va-light .cm-attribute { color: #0040dd; }
.cm-s-va-light .cm-hr { color: #aeaeb2; font-weight: 700; }
.cm-s-va-light .cm-formatting { color: #c7c7cc; }

/* ============================== WYSIWYG 编辑器（ProseMirror/TipTap） ============================== */
.tt-wrap { flex: 1; min-height: 0; overflow: auto; }
.tt-wrap .ProseMirror {
  outline: none;
  min-height: 100%;
  padding: 28px 40px 90px;
  font: 15px/1.75 var(--sans);
  letter-spacing: -0.01em;
  color: var(--fg);
  caret-color: var(--accent);
}
.tt-wrap .ProseMirror > * { max-width: 880px; }
.tt-wrap .ProseMirror h1, .tt-wrap .ProseMirror h2,
.tt-wrap .ProseMirror h3, .tt-wrap .ProseMirror h4 {
  border-bottom: 1px solid var(--hairline); padding-bottom: 8px;
  margin: 1.3em 0 0.6em; line-height: 1.25; letter-spacing: -0.02em;
}
.tt-wrap .ProseMirror h1 { font-size: 1.8em; font-weight: 700; }
.tt-wrap .ProseMirror h2 { font-size: 1.45em; font-weight: 650; }
.tt-wrap .ProseMirror h3 { font-size: 1.2em; font-weight: 600; }
.tt-wrap .ProseMirror p { margin: 0.5em 0; }
.tt-wrap .ProseMirror a { color: var(--accent); text-decoration: none; }
.tt-wrap .ProseMirror code {
  background: var(--bg3); border-radius: 6px; padding: 2px 7px;
  font-family: var(--mono); font-size: 0.88em;
}
.tt-wrap .ProseMirror pre {
  background: var(--bg2); border: 1px solid var(--hairline);
  border-radius: var(--radius-lg); padding: 14px 18px; overflow: auto;
}
.tt-wrap .ProseMirror pre code { background: none; padding: 0; font-size: 13px; line-height: 1.6; }
.tt-wrap .ProseMirror blockquote {
  border-left: 3px solid var(--accent); margin: 12px 0; padding: 6px 18px;
  color: var(--fg-dim); background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.tt-wrap .ProseMirror hr { border: none; border-top: 1px solid var(--hairline); margin: 24px 0; }
.tt-wrap .ProseMirror ul, .tt-wrap .ProseMirror ol { padding-left: 1.5em; }
.tt-wrap .ProseMirror li::marker { color: var(--fg-faint); }
.tt-wrap .ProseMirror img { max-width: 100%; border-radius: var(--radius-lg); }
.tt-wrap .ProseMirror img.ProseMirror-selectednode { outline: 2px solid var(--accent); }
/* 任务列表 */
.tt-wrap .ProseMirror ul[data-type="taskList"] { list-style: none; padding-left: 0.3em; }
.tt-wrap .ProseMirror li[data-type="taskItem"] { display: flex; gap: 8px; align-items: flex-start; }
.tt-wrap .ProseMirror li[data-type="taskItem"] > label { margin-top: 4px; }
.tt-wrap .ProseMirror li[data-type="taskItem"] input[type="checkbox"] { accent-color: var(--accent); }
.tt-wrap .ProseMirror li[data-type="taskItem"] > div { flex: 1; }
/* 表格 */
.tt-wrap .ProseMirror table { border-collapse: collapse; margin: 12px 0; }
.tt-wrap .ProseMirror th, .tt-wrap .ProseMirror td {
  border: 1px solid var(--border); padding: 7px 14px; position: relative;
}
.tt-wrap .ProseMirror th { background: var(--bg2); font-weight: 600; }
.tt-wrap .ProseMirror .selectedCell::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent-soft); pointer-events: none;
}
/* Yjs 远程协同光标（Google Docs 风格） */
.collaboration-cursor__caret {
  border-left: 1px solid;
  border-right: 1px solid;
  margin-left: -1px;
  margin-right: -1px;
  pointer-events: none;
  position: relative;
  word-break: normal;
}
.collaboration-cursor__label {
  border-radius: 8px 8px 8px 1px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--sans);
  left: -1px;
  line-height: 1.6;
  padding: 1px 7px;
  position: absolute;
  top: -1.6em;
  user-select: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.ProseMirror-yjs-selection {
  border-radius: 2px;
}

/* 远程协作光标 */
.remote-caret {
  position: relative;
  display: inline-block;
  width: 0; height: 1.2em;
  border-left: 2px solid;
  margin-left: -1px; margin-right: -1px;
  vertical-align: text-bottom;
  pointer-events: none;
}
.remote-caret-flag {
  position: absolute; top: -1.55em; left: -2px;
  font-size: 11px; line-height: 1.6; font-family: var(--sans);
  padding: 0 7px; border-radius: 8px 8px 8px 1px;
  color: var(--on-accent); white-space: nowrap; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none; z-index: 6;
}
.cm-remote-selection { border-radius: 2px; }

/* ============================== 底部终端 ============================== */
#termPanel {
  height: 240px; min-height: 120px; max-height: 70vh;
  border-top: 1px solid var(--hairline);
  background: var(--term-bg);
  display: flex; flex-direction: column; flex: none;
  position: relative;
}
#termPanel.collapsed { height: 36px; min-height: 36px; }
#termPanel.collapsed #termWrap, #termPanel.collapsed #termBody { display: none; }
#termPanel.collapsed #termToggleIc { transform: rotate(180deg); }
#termDrag {
  position: absolute; top: -3px; left: 0; right: 0; height: 6px;
  cursor: ns-resize; z-index: 5;
}
#termHeader {
  height: 36px; flex: none; display: flex; align-items: center;
  padding: 0 8px 0 14px; font-size: 12px; color: var(--fg-dim);
  border-bottom: 1px solid var(--hairline);
  background: var(--sidebar-bg);
  position: relative;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  user-select: none; gap: 8px;
}
#termHeader .term-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--fg-dim); }
/* 终端主体：左 rail（竖排 tab）+ 右 xterm */
#termBody { flex: 1; min-height: 0; display: flex; }
#termRail {
  width: 150px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--hairline); background: var(--sidebar-bg);
  padding: 6px; gap: 4px; position: relative;
}
#termRailDrag {
  position: absolute; top: 0; bottom: 0; right: -4px; width: 8px;
  cursor: col-resize; z-index: 15;
}
#termRailDrag::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 3px;
  width: 2px; border-radius: 1px; background: transparent; transition: background 0.15s;
}
#termRailDrag:hover::after, body.side-dragging #termRailDrag::after { background: var(--accent); }
#btnTermNew {
  border: none; background: var(--bg3); color: var(--fg-dim);
  border-radius: 8px; padding: 6px 10px; font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  flex: none; width: 100%; font-family: var(--sans);
}
#btnTermNew:hover { color: var(--fg); background: var(--accent-soft); }
#btnTermNew .svg-ic svg { width: 12px; height: 12px; }
#termTabs {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; min-height: 0; background: none;
}
.term-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
  border-radius: 8px; color: var(--fg-dim);
  transition: all 0.18s; border: none; flex: none; width: 100%;
  box-sizing: border-box; font-size: 12px;
}
.term-tab .trename {
  flex: 1; min-width: 0; background: var(--bg); color: var(--fg);
  border: 1px solid var(--accent); border-radius: 6px;
  font-size: 12px; padding: 1px 5px; outline: none; font-family: var(--sans);
}
.term-tab:hover { background: var(--row-alt); color: var(--fg); }
.term-tab.active {
  background: var(--bg3); color: var(--fg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.term-tab .tname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.term-tab .tusers { display: flex; align-items: center; }
.term-tab .mini-av {
  width: 17px; height: 17px; border-radius: 50%; margin-left: -6px;
  font-size: 10px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--on-accent); font-weight: 700; border: 1.5px solid var(--bg2);
}
.term-tab .tclose {
  border: none; background: none; color: var(--fg-faint); padding: 1px;
  cursor: pointer; border-radius: 50%; line-height: 1; display: inline-flex;
}
.term-tab .tclose:hover { color: var(--red); background: rgba(255, 69, 58, 0.12); }
#termHeader > button {
  padding: 4px; width: 26px; height: 26px; border: none; background: none;
  color: var(--fg-dim); flex: none; border-radius: 50%;
}
#termHeader > button:hover { color: var(--fg); background: var(--bg3); }
#termToggleIc { transition: transform 0.2s; display: inline-flex; }
#termWrap { flex: 1; overflow: hidden; padding: 8px 12px; }
#termWrap .xterm { height: 100%; }

/* 底部面板模式切换（终端 / Git 历史） */
#bpModeTabs {
  display: flex; gap: 2px; background: var(--bg3);
  border-radius: var(--pill); padding: 2px; flex: none;
}
.bp-mode {
  border: none; background: none; color: var(--fg-dim);
  padding: 3px 12px; font-size: 12px; font-weight: 500;
  border-radius: var(--pill); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all 0.18s;
}
.bp-mode:hover { color: var(--fg); }
.bp-mode.active { background: var(--bg2); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.bp-mode .svg-ic svg { width: 13px; height: 13px; }
.term-spacer { flex: 1; }

/* Git 历史视图：左列表 + 右详情 */
#gitHistWrap { flex: 1; min-height: 0; display: flex; }
#gitHistList {
  width: 300px; flex: none; overflow-y: auto; padding: 4px 0;
  border-right: 1px solid var(--hairline);
}
#gitHistList .git-log-row { cursor: pointer; border-radius: 0; }
#gitHistList .git-log-row:hover { background: var(--bg3); }
#gitHistList .git-log-row.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
#gitHistFiles {
  width: 220px; flex: none; overflow-y: auto; padding: 4px 0;
  border-right: 1px solid var(--hairline);
}
.git-file-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--mono);
}
.git-file-row:hover { background: var(--bg3); }
.git-file-row.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.gf-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
#gitHistDetail { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#gitHistDetailHead {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-bottom: 1px solid var(--hairline); flex: none;
}
#histCommitTitle {
  font-size: 12px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#gitHistDiff {
  flex: 1; min-height: 0; overflow: hidden; margin: 0;
  color: var(--fg);
}
/* side-by-side 表宽铺满 */
.d2h-host .d2h-file-side-diff,
.d2h-host .d2h-code-wrapper { width: 100%; }
.d2h-host .d2h-file-side-diff .d2h-code-side-linenumber { min-width: 56px; }

#termNewMenu {
  position: absolute; top: 36px; left: 6px; right: 6px; z-index: 40;
  padding: 5px; display: flex; flex-direction: column; gap: 2px;
  background: var(--bg2); /* 实底，避免终端字符透出来看不清 */
  border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(128, 128, 128, 0.15);
  min-width: 220px;
  animation: va-pop 0.15s cubic-bezier(0.32, 0.72, 0, 1);
}
#termNewMenu button {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  border: none; background: none; color: var(--fg);
  font-size: 12.5px; padding: 7px 12px; border-radius: 8px;
  cursor: pointer; white-space: nowrap; font-family: var(--sans);
}
#termNewMenu button:hover { background: var(--accent); color: var(--on-accent); }
.term-tab .tlock { flex: none; opacity: 0.7; }
.term-tab .tlock svg { width: 11px; height: 11px; }

@keyframes va-pop {
  from { opacity: 0; transform: scale(0.96) translateY(-2px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================== Git 面板 ============================== */
#gitPanel {
  flex: none; border-top: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  max-height: 42%; min-height: 30px;
  position: relative;
}
#gitDrag {
  position: absolute; top: -4px; left: 0; right: 0;
  height: 8px; cursor: row-resize; z-index: 15;
}
#gitDrag::after {
  content: ""; position: absolute; left: 0; right: 0;
  top: 3px; height: 2px; border-radius: 1px;
  background: transparent; transition: background 0.15s;
}
#gitDrag:hover::after, body.side-dragging #gitDrag::after { background: var(--accent); }
.git-ab {
  font-size: 10px; font-weight: 700; color: var(--accent);
  font-family: var(--mono);
}
.git-ab:empty, .git-behind:empty { display: none; }
.git-behind {
  font-size: 10px; font-weight: 700; color: var(--yellow, #ff9f0a);
  font-family: var(--mono);
}
#btnGitPull, #btnGitPush {
  padding: 3px; width: 24px; height: 24px; border: none; background: none;
  color: var(--fg-dim); border-radius: 50%; flex: none;
}
#btnGitPull:hover, #btnGitPush:hover { color: var(--accent); background: var(--accent-soft); }
#btnGitPull .svg-ic svg, #btnGitPush .svg-ic svg { width: 14px; height: 14px; }
#gitHeader {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; flex: none;
  font-size: 12px; font-weight: 600; color: var(--fg-dim);
}
#gitHeader .svg-ic svg { width: 14px; height: 14px; }
.git-branch {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  background: var(--bg3); border-radius: var(--pill); padding: 2px 9px;
  color: var(--accent);
}
.git-count {
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 8px; background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.git-count:empty { display: none; }
.git-spacer { flex: 1; }
#btnGitRefresh, #btnGitToggle {
  padding: 3px; width: 24px; height: 24px; border: none; background: none;
  color: var(--fg-dim); border-radius: 50%; flex: none;
}
#btnGitRefresh:hover, #btnGitToggle:hover { color: var(--fg); background: var(--bg3); }
#gitToggleIc { display: inline-flex; transition: transform 0.18s; }
#gitPanel.collapsed #gitBody { display: none; }

#gitBody { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
#gitChanges { flex: none; }
.git-empty { padding: 8px 12px; font-size: 12px; color: var(--fg-faint); }
.git-row {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 12px; font-size: 12px; cursor: pointer;
}
.git-row:hover { background: var(--bg3); }
.git-letter {
  flex: none; width: 16px; height: 16px; border-radius: 5px;
  font-size: 10px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.git-letter.mod { background: rgba(255, 159, 10, 0.2); color: var(--yellow, #ff9f0a); }
.git-letter.add { background: rgba(48, 209, 88, 0.18); color: var(--green); }
.git-letter.del { background: rgba(255, 69, 58, 0.18); color: var(--red); }
.git-path {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.git-path:hover { color: var(--accent); text-decoration: underline; }
.git-diff {
  margin: 2px 8px 6px; height: 240px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--hairline); border-radius: 8px;
}

/* diff2html 组件微调 */
.d2h-host .d2h-wrapper { font-size: 11.5px; }
.d2h-host .d2h-file-header { font-family: var(--mono); font-size: 11px; padding: 5px 10px; }
.d2h-host .d2h-code-line,
.d2h-host .d2h-code-side-line { font-size: 11.5px; line-height: 1.5; padding: 0 8px 0 8px; }
.d2h-host .d2h-code-linenumber,
.d2h-host .d2h-code-side-linenumber { font-size: 10px; width: 56px; }
.d2h-host .d2h-file-list-wrapper { margin-bottom: 6px; }
.d2h-host .d2h-file-list { font-family: var(--mono); font-size: 11px; }

/* diff2html 暗色主题适配 */
html[data-theme="dark"] .d2h-file-wrapper { border-color: var(--hairline); border-radius: 8px; }
html[data-theme="dark"] .d2h-file-header { background: var(--bg3); border-color: var(--hairline); color: var(--fg-dim); }
html[data-theme="dark"] .d2h-file-header svg { fill: var(--fg-dim); }
html[data-theme="dark"] .d2h-code-line,
html[data-theme="dark"] .d2h-code-side-line { background: var(--bg); color: var(--fg); }
html[data-theme="dark"] .d2h-code-line del,
html[data-theme="dark"] .d2h-code-side-line del { background: rgba(255,69,58,0.18); color: #ffb4ae; }
html[data-theme="dark"] .d2h-code-line ins,
html[data-theme="dark"] .d2h-code-side-line ins { background: rgba(48,209,88,0.16); color: #a9f0b8; }
html[data-theme="dark"] .d2h-code-line-ctn { color: var(--fg); }
html[data-theme="dark"] .d2h-code-linenumber,
html[data-theme="dark"] .d2h-code-side-linenumber { background: var(--bg2); color: var(--fg-dim); border-color: var(--hairline); }
html[data-theme="dark"] .d2h-info { background: var(--bg3); color: var(--fg-dim); }
html[data-theme="dark"] .d2h-file-list-wrapper { background: var(--bg2); border-color: var(--hairline); }
html[data-theme="dark"] .d2h-file-list-header { background: var(--bg3); border-color: var(--hairline); color: var(--fg); }
html[data-theme="dark"] .d2h-file-list-title { color: var(--fg); }
html[data-theme="dark"] .d2h-file-list a { color: var(--fg-dim); }
html[data-theme="dark"] .d2h-file-list li { border-color: var(--hairline); }
html[data-theme="dark"] .d2h-file-stats { color: var(--fg-dim); }
html[data-theme="dark"] .d2h-lines-added { color: var(--green); border-color: var(--green); }
html[data-theme="dark"] .d2h-lines-deleted { color: var(--red); border-color: var(--red); }
html[data-theme="dark"] .d2h-tag { background: var(--bg3); color: var(--fg-dim); border-color: var(--hairline); }
html[data-theme="dark"] .d2h-emptyplaceholder { background: var(--bg2); color: var(--fg-dim); border-color: var(--hairline); }

#gitCommitRow {
  display: flex; gap: 6px; padding: 8px 10px; flex: none;
  border-top: 1px solid var(--hairline);
}
#gitMsg {
  flex: 1; min-width: 0;
  background: var(--bg3); border: none; border-radius: 8px;
  color: var(--fg); padding: 6px 10px; font-size: 12px; outline: none;
  font-family: var(--sans);
}
#gitMsg:focus { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 1px var(--accent); }
#btnGitCommit { padding: 6px 14px; font-size: 12px; flex: none; }

#gitLogHead {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 12px; font-size: 11.5px; font-weight: 600; color: var(--fg-dim);
  cursor: pointer; flex: none; user-select: none;
}
#gitLogHead:hover { color: var(--fg); }
#gitLogHead .svg-ic svg { width: 12px; height: 12px; }
#gitLogIc { display: inline-flex; transition: transform 0.18s; }
#gitLog { flex: none; max-height: 180px; overflow-y: auto; padding-bottom: 6px; }
.git-log-row {
  display: flex; align-items: baseline; gap: 7px;
  padding: 3px 12px; font-size: 11.5px;
}
.gl-hash { font-family: var(--mono); color: var(--accent); flex: none; font-size: 10.5px; }
.gl-msg { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gl-meta { flex: none; color: var(--fg-faint); font-size: 10.5px; }

/* ============================== 树右键菜单 ============================== */
#ctxMenu {
  position: fixed; z-index: 100;
  min-width: 180px; padding: 5px;
  display: flex; flex-direction: column; gap: 1px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(128, 128, 128, 0.12);
  animation: va-pop 0.13s cubic-bezier(0.32, 0.72, 0, 1);
}
.ctx-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 9px; width: 100%;
  border: none; background: none; color: var(--fg);
  font-size: 13px; padding: 6px 10px; border-radius: 8px;
  cursor: pointer; font-family: var(--sans); text-align: left;
  letter-spacing: -0.01em;
}
.ctx-item .svg-ic svg { width: 15px; height: 15px; }
.ctx-item:hover { background: var(--accent); color: var(--on-accent); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red); color: #fff; }
.ctx-sep { height: 1px; background: var(--hairline); margin: 4px 8px; }

/* ============================== 项目切换器 ============================== */
#projBar { padding: 8px 8px 4px; flex: none; }
#projBtn {
  width: 100%; display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--hairline); background: var(--bg3);
  color: var(--fg); border-radius: 10px;
  padding: 7px 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: var(--sans); letter-spacing: -0.01em;
  transition: all 0.15s;
}
#projBtn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#projBtn .svg-ic { flex: none; }
#projBtn .svg-ic svg { width: 15px; height: 15px; }
#projName { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-chev { opacity: 0.5; }
.proj-chev svg { width: 13px !important; height: 13px !important; }

#projMenu {
  position: absolute; top: 48px; left: 8px; right: 8px; z-index: 40;
  padding: 5px; display: flex; flex-direction: column; gap: 1px;
  background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  animation: va-pop 0.15s cubic-bezier(0.32, 0.72, 0, 1);
}
.pm-row {
  display: flex; align-items: center; justify-content: flex-start; gap: 6px; width: 100%;
  border: none; background: none; color: var(--fg);
  font-size: 12.5px; padding: 7px 8px; border-radius: 8px;
  cursor: pointer; font-family: var(--sans); text-align: left;
}
.pm-row:hover { background: var(--bg3); }
.pm-row.active { background: var(--accent-soft); }
.pm-check { width: 14px; flex: none; color: var(--accent); font-weight: 700; }
.pm-name { flex: none; font-weight: 600; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-path {
  flex: 1; min-width: 0; color: var(--fg-faint); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl;
}
.pm-del { flex: none; color: var(--fg-faint); padding: 0 4px; border-radius: 50%; font-size: 14px; display: none; }
.pm-row:hover .pm-del { display: inline; }
.pm-del:hover { color: var(--red); }
.pm-add {
  border-top: 1px solid var(--hairline); margin-top: 4px; padding: 8px 6px 4px;
  display: flex; flex-direction: column; gap: 6px;
}
.pm-add input {
  background: var(--bg3); border: none; border-radius: 8px;
  color: var(--fg); padding: 7px 10px; font-size: 12px; outline: none;
  font-family: var(--sans); width: 100%;
}
.pm-add input:focus { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 1px var(--accent); }
.pm-add-row { display: flex; gap: 6px; }
.pm-add-row .pm-name-input { flex: 1; min-width: 0; }
.pm-ok { padding: 6px 14px; font-size: 12px; flex: none; }

/* ============================== 右侧共享浏览面板 ============================== */
#browsePanel {
  width: var(--browse-w, 520px); min-width: var(--browse-w, 520px);
  border-left: 1px solid var(--hairline);
  background: var(--sidebar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex; flex-direction: column;
  position: relative;
}
#browseBody {
  flex: 1; min-height: 0;
  display: flex; flex-direction: row;
}
/* 左侧竖排标签栏（在顶行地址栏之下） */
#browseRail {
  width: 148px; flex: none;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--hairline);
  padding: 8px 6px;
  position: relative;
}
#browseMain {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
#browseDrag {
  position: absolute; top: 0; bottom: 0; left: -4px;
  width: 8px; cursor: col-resize; z-index: 15;
}
#browseDrag::after {
  content: ""; position: absolute; top: 0; bottom: 0;
  left: 3px; width: 2px; border-radius: 1px;
  background: transparent; transition: background 0.15s;
}
#browseDrag:hover::after, body.side-dragging #browseDrag::after { background: var(--accent); }

#browseHeader {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-bottom: 1px solid var(--hairline);
  flex: none;
}
#browseTabList {
  display: flex; flex-direction: column; gap: 3px;
  flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none;
}
#browseTabList::-webkit-scrollbar { display: none; }
.browse-tab {
  border: none; background: transparent; color: var(--fg-dim);
  padding: 7px 8px; font-size: 12px; font-weight: 500;
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: all 0.18s; width: 100%; text-align: left;
  font-family: var(--sans); flex: none;
}
.browse-tab .svg-ic { flex: none; }
.browse-tab .bt-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
.browse-tab:hover { color: var(--fg); }
.browse-tab.active {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.browse-tab.active .bt-close { color: var(--on-accent); }
.bt-close {
  flex: none; font-size: 14px; line-height: 1; padding: 0 2px;
  color: var(--fg-faint); border-radius: 50%; display: none;
}
.browse-tab:hover .bt-close { display: inline; }
.bt-close:hover { color: var(--red); }
.bt-sep { height: 1px; background: var(--hairline); flex: none; margin: 4px 6px; }
.bt-none { font-size: 11.5px; color: var(--fg-faint); padding: 8px 10px; line-height: 1.6; }
#btnBrowseNew {
  margin-bottom: 6px; padding: 7px 10px; border: 1px dashed var(--hairline);
  background: none; color: var(--fg-dim); border-radius: 10px;
  flex: none; display: flex; align-items: center; justify-content: flex-start;
  gap: 6px; font-size: 12px; font-weight: 500; font-family: var(--sans);
  cursor: pointer; transition: all 0.15s;
}
#btnBrowseNew:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
#btnBrowseNew .svg-ic svg { width: 14px; height: 14px; }
#browseNewMenu {
  position: absolute; top: 42px; left: 6px; right: 6px; z-index: 30;
  padding: 5px;
  background: var(--topbar-bg); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  display: flex; flex-direction: column; gap: 2px;
  animation: va-pop 0.15s cubic-bezier(0.32, 0.72, 0, 1);
}
#browseNewMenu button {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%;
  border: none; background: none; color: var(--fg);
  font-size: 12.5px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-family: var(--sans);
}
#browseNewMenu button:hover { background: var(--accent); color: var(--on-accent); }
#browseViewers { display: flex; align-items: center; flex: none; padding-right: 2px; }
#browseViewers .mini-av {
  width: 20px; height: 20px; border-radius: 50%; margin-left: -6px;
  font-size: 11px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--on-accent); font-weight: 700; border: 2px solid var(--bg2);
}
#btnBrowseClose {
  padding: 4px; width: 26px; height: 26px; border: none; background: none;
  color: var(--fg-dim); border-radius: 50%; flex: none;
}
#btnBrowseClose:hover { color: var(--fg); background: var(--bg3); }

#browseNav {
  display: flex; align-items: center; gap: 2px;
  padding: 5px 8px; flex: none;
}
#browseNav button {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none; color: var(--fg-dim);
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 500; font-family: var(--sans);
  transition: all 0.15s;
}
#browseNav button:hover { color: var(--fg); background: var(--bg3); }
#browseNav button:active { transform: scale(0.94); }
#browseNav .svg-ic svg { width: 16px; height: 16px; }
#browseNav .bn-spacer { flex: 1; }
#btnNavShare { color: var(--accent); }
#btnNavShare:hover { background: var(--accent-soft); color: var(--accent); }

#browseBar {
  display: flex; gap: 6px; padding: 2px 10px 9px;
  border-bottom: 1px solid var(--hairline); flex: none;
}
#browseUrl {
  flex: 1; min-width: 0;
  background: var(--bg3); border: none; border-radius: var(--pill);
  color: var(--fg); padding: 7px 14px; font-size: 13px; outline: none;
  font-family: var(--sans); letter-spacing: -0.01em;
  transition: box-shadow 0.18s;
}
#browseUrl:focus { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); }
#btnBrowseGo { padding: 7px 14px; font-size: 13px; flex: none; }

#browseHint {
  flex: 1; min-width: 0; font-size: 11.5px; color: var(--fg-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#browseFrameWrap { flex: 1; position: relative; min-height: 0; background: #fff; }
#browseFrame { width: 100%; height: 100%; border: none; display: block; background: #fff; }
.browse-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  color: var(--fg-faint); line-height: 2; font-size: 14px;
  background: var(--bg);
}
.browse-empty small { font-size: 12px; opacity: 0.8; }

/* ============================== 登录页（Apple 卡片） ============================== */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(700px 380px at 25% 8%, rgba(10, 132, 255, 0.12), transparent),
    radial-gradient(600px 360px at 80% 92%, rgba(191, 90, 242, 0.1), transparent),
    var(--overlay-bg);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--toast-bg);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--hairline);
  border-radius: 22px;
  padding: 42px 42px 34px;
  width: 372px; text-align: center;
  display: flex; flex-direction: column; gap: 15px;
  box-shadow: var(--shadow-lg);
  animation: cardin 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes cardin { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.login-logo {
  font-size: 25px; font-weight: 700; color: var(--fg); letter-spacing: -0.03em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.login-logo .logo {
  display: inline-flex;
  filter: drop-shadow(0 2px 10px rgba(10, 132, 255, 0.4));
}
.login-tip { color: var(--fg-dim); font-size: 13px; margin: 0; line-height: 1.9; }
.login-card input {
  background: var(--bg3); border: none; border-radius: 12px;
  color: var(--fg); padding: 12px 16px; font-size: 15px; outline: none; text-align: center;
  font-family: inherit; letter-spacing: -0.01em;
  transition: box-shadow 0.18s, background 0.18s;
}
.login-card input:focus {
  background: var(--bg2);
  box-shadow: 0 0 0 3.5px var(--accent-soft), 0 0 0 1px var(--accent);
}
.login-card button { padding: 11px; font-size: 15px; border-radius: var(--pill); }
.login-err { color: var(--red); font-size: 12px; min-height: 16px; }
.icon-label { color: var(--fg-dim); font-size: 12px; text-align: left; margin-bottom: -7px; font-weight: 500; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.icon-grid .ic {
  font-size: 20px; line-height: 38px; text-align: center; cursor: pointer;
  border: 1.5px solid transparent; border-radius: 12px; background: var(--bg3);
  user-select: none; transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-grid .ic:hover { transform: scale(1.1); }
.icon-grid .ic.sel {
  border-color: var(--accent); background: var(--accent-soft);
  transform: scale(1.05);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================== Toast ============================== */
#toasts {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 99;
}
.toast {
  background: var(--toast-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline); border-left: 3px solid var(--accent);
  padding: 11px 17px; border-radius: 14px; max-width: 380px; font-size: 13px;
  box-shadow: var(--shadow);
  animation: slidein 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
.toast.warn { border-left-color: var(--yellow); }
.toast.error { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }

/* Markdown 编辑器工具栏 */
#editorWrap { display: flex; flex-direction: column; }
#editorWrap.hidden { display: none; }
#mdToolbar {
  flex: none; display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 6px 14px; border-bottom: 1px solid var(--hairline);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 6;
}
.tb-sep { width: 1px; height: 18px; background: var(--hairline); margin: 0 6px; flex: none; }
.tb-btn {
  border: none; background: none; color: var(--fg-dim);
  width: 28px; height: 26px; border-radius: 7px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex: none;
}
.tb-btn svg { width: 15px; height: 15px; }
.tb-btn:hover { background: var(--bg3); color: var(--fg); }
.tb-btn.on { background: var(--accent-soft); color: var(--accent); }
.tb-btn.tb-disabled { opacity: 0.3; pointer-events: none; }

/* 用户头像弹出菜单 */
#userMenu {
  position: fixed; z-index: 60; min-width: 190px;
  background: var(--bg2); border: 1px solid var(--hairline); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(128, 128, 128, 0.15);
  padding: 6px; animation: va-pop 0.15s cubic-bezier(0.32, 0.72, 0, 1);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
#userMenu .um-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 8px; border-bottom: 1px solid var(--hairline); margin-bottom: 4px;
}
#userMenu .um-av {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--on-accent);
}
#userMenu .um-name { font-size: 13px; font-weight: 600; }
#userMenu .ctx-item { width: 100%; }
.toast-msg { max-width: 320px; cursor: pointer; }

/* 灵动岛：顶部消息钉 */
/* 顶栏中央容器：灵动岛 + Flappy Bird + 祖玛，一组整体居中 */
#topCenter {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; align-items: flex-start; gap: 8px;
}
#dynIsland {
  position: relative; display: flex; flex-direction: column; align-items: center;
}
/* Flappy Bird / 祖玛 Zuma 小游戏（两个药丸并排，面板样式共用） */
#flappy, #zuma, #versus { position: relative; display: flex; flex-direction: column; align-items: center; }
#flappyPill, #zumaPill, #versusPill {
  display: flex; align-items: center; gap: 7px;
  background: #1c1c1e; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px; padding: 6px 12px;
  font-size: 13px; cursor: pointer; user-select: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s;
}
#flappyPill:hover, #zumaPill:hover, #versusPill:hover { background: #2c2c2e; transform: scale(1.08); }
#flappyScore, #zumaScore { font: 700 12px ui-monospace, monospace; min-width: 8px; text-align: center; }
#flappyScore { color: #ffd75e; }
#zumaScore { color: #5ed46a; }
#flappyPanel, #zumaPanel, #versusPanel {
  /* 给对定位的浮层：展开时不改变 #topCenter 的宽度。
     否则整组会重新居中，另一个药丸在 mousedown / mouseup 之间移位，点击就废了。
     用 width + 负 margin 居中而不是 transform，因为 va-pop 动画会改写 transform */
  position: absolute; top: calc(100% + 8px); left: 50%;
  padding: 8px;
  background: rgba(28, 28, 30, 0.94); color: #eee;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  animation: va-pop 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
#flappyPanel { width: 338px; margin-left: -169px; }   /* 320 画布 + 8*2 内边距 + 1*2 边框 */
#zumaPanel { width: 318px; margin-left: -159px; }     /* 300 画布 + 8*2 内边距 + 1*2 边框 */
#versusPanel { width: 336px; margin-left: -168px; }   /* 容纳 15×20 五子棋盘 + 内边距 */

/* ---------------- 双人对战（国际象棋 / 五子棋） ---------------- */
#versusBadge { font: 700 11px ui-monospace, monospace; min-width: 8px; text-align: center; }
#versusBadge.mine { color: #ffd75e; animation: va-pulse 1.1s ease-in-out infinite; }
#versusBadge.ingame { color: #5ed46a; }
#versusBadge.invite { color: #ff6b6b; animation: va-pulse 0.8s ease-in-out infinite; }
@keyframes va-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

#versusHead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#versusTitle { font-size: 13px; }
#versusHeadHint { flex: 1; text-align: right; font-size: 10px; color: #888; }
#btnVersusClose { background: none; border: 0; color: #999; cursor: pointer; font-size: 13px; padding: 0 2px; }
#btnVersusClose:hover { color: #fff; }

/* 大厅：棋种选择 + 在线用户列表 */
#versusKinds { display: flex; gap: 6px; margin-bottom: 8px; }
.va-kind {
  flex: 1; padding: 6px 8px; border-radius: 9px; cursor: pointer; font-size: 12px;
  background: #2a2a2c; color: #ccc; border: 1px solid rgba(255, 255, 255, 0.1);
}
.va-kind.on { background: #3d6df0; color: #fff; border-color: #3d6df0; }
#versusLobbyHint { font-size: 11px; color: #999; margin-bottom: 6px; min-height: 15px; }
#versusUsers { max-height: 210px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.va-user { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border-radius: 9px; background: rgba(255, 255, 255, 0.05); }
.va-user .va-ico { font-size: 15px; }
.va-user .va-nm { flex: 1; font-size: 12px; color: #eee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.va-user button {
  padding: 3px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.16);
  background: #3d6df0; color: #fff; font-size: 11px; cursor: pointer;
}
.va-user button:disabled { background: #3a3a3c; color: #888; cursor: default; border-color: transparent; }
.va-empty { font-size: 11px; color: #888; text-align: center; padding: 14px 6px; }

/* 对局：玩家条 + 棋盘 + 状态 */
.va-player { display: flex; align-items: center; gap: 7px; padding: 4px 6px; font-size: 12px; color: #ddd; }
.va-player .va-dot { width: 9px; height: 9px; border-radius: 50%; background: #444; flex: none; }
.va-player.active .va-dot { background: #5ed46a; box-shadow: 0 0 6px #5ed46a; }
.va-player .va-nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.va-player .va-tag { font-size: 10px; color: #999; }
#versusBoardBox { position: relative; display: flex; justify-content: center; padding: 4px 0; }
#versusBoard { display: grid; border-radius: 6px; overflow: hidden; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5); user-select: none; }
#versusBoard.chess { grid-template-columns: repeat(8, 34px); grid-template-rows: repeat(8, 34px); }
#versusBoard.gomoku { grid-template-columns: repeat(15, 20px); grid-template-rows: repeat(15, 20px); }
#versusBoard .cell { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#versusBoard .cell.light { background: #e9d7b6; }
#versusBoard .cell.dark { background: #a97a4e; }
#versusBoard .pc { font-size: 26px; line-height: 1; pointer-events: none; }
#versusBoard .pc.white { color: #fff; text-shadow: 0 0 2px #000, 0 1px 2px rgba(0, 0, 0, 0.75); }
#versusBoard .pc.black { color: #17181a; text-shadow: 0 0 1px rgba(255, 255, 255, 0.35); }
#versusBoard .cell.sel { box-shadow: inset 0 0 0 3px #ffd75e; }
#versusBoard .cell.lastmove { box-shadow: inset 0 0 0 3px rgba(94, 212, 106, 0.75); }
#versusBoard .cell.incheck { box-shadow: inset 0 0 0 3px #ff5c5c; background: radial-gradient(circle, #ff6b6b 0%, #b23b3b 100%); }
#versusBoard .cell.target::after {
  content: ''; position: absolute; width: 11px; height: 11px; border-radius: 50%;
  background: rgba(30, 30, 30, 0.35);
}
#versusBoard .cell.target-cap { box-shadow: inset 0 0 0 3px rgba(255, 107, 107, 0.9); }
#versusBoard .lb { position: absolute; font: 600 8px ui-monospace, monospace; color: rgba(0, 0, 0, 0.45); pointer-events: none; }
#versusBoard .lb.rk { top: 1px; left: 2px; }
#versusBoard .lb.fl { bottom: 0; right: 2px; }
#versusBoard .gcell { position: relative; background: #d9a86c; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22); cursor: pointer; }
#versusBoard .stone { position: absolute; inset: 11%; border-radius: 50%; pointer-events: none; }
#versusBoard .stone.black { background: radial-gradient(circle at 34% 30%, #6a6a6a, #0d0d0d 62%); }
#versusBoard .stone.white { background: radial-gradient(circle at 34% 30%, #fff, #c9c9c9 68%); }
#versusBoard .gcell.lastmove::after {
  content: ''; position: absolute; inset: 36%; border-radius: 50%; background: #ff5c5c; opacity: 0.9;
}
#versusBoard .gcell.winline { box-shadow: inset 0 0 0 2px #ffd75e; }
#versusOverlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: rgba(12, 12, 14, 0.82); border-radius: 6px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
#versusOverlayText { font-size: 15px; font-weight: 700; color: #fff; text-align: center; padding: 0 12px; }
#versusOverlayBtns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#versusOverlayBtns button {
  padding: 5px 12px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: #3d6df0; color: #fff; font-size: 12px; cursor: pointer;
}
#versusOverlayBtns button.ghost { background: #2a2a2c; color: #ddd; }
#versusStatus { text-align: center; font-size: 12px; color: #ddd; min-height: 17px; margin-top: 2px; }
#versusBtns { display: flex; justify-content: center; margin-top: 6px; }
#btnVersusLeave {
  padding: 4px 12px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: #2a2a2c; color: #ccc; font-size: 11px; cursor: pointer;
}
#btnVersusLeave:hover { background: #3a2a2a; color: #ffb3b3; }

/* 兵升变选择 */
#versusPromo {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; gap: 6px; padding: 8px; border-radius: 12px; z-index: 3;
  background: rgba(28, 28, 30, 0.97); border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
#versusPromo button {
  width: 40px; height: 40px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: #e9d7b6; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#versusPromo button:hover { background: #ffd75e; }
#versusPromo .pc { font-size: 28px; line-height: 1; }

/* 邀请弹窗（面板收起时也可见） */
#versusInvite {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 400;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  background: rgba(28, 28, 30, 0.97); border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); font-size: 12px; color: #eee;
  animation: va-pop 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
#versusInvite button {
  padding: 4px 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px; cursor: pointer;
}
#btnVersusAccept { background: #2f9e44; color: #fff; border-color: #2f9e44; }
#btnVersusDecline { background: #2a2a2c; color: #ccc; }
#flappyCanvas { display: block; border-radius: 10px; cursor: pointer; }
#zumaCanvas { display: block; border-radius: 10px; cursor: crosshair; }
#flappyHint, #zumaHint { margin-top: 6px; text-align: center; font-size: 11px; color: #999; }
#diPill {
  display: flex; align-items: center; gap: 7px;
  background: #1c1c1e; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px; padding: 6px 14px;
  font-size: 12.5px; cursor: pointer; user-select: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.6);
  max-width: 220px; transition: max-width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1), padding 0.3s;
  white-space: nowrap;
}
#diPill:hover { background: #2c2c2e; }
#dynIsland.pop #diPill {
  max-width: 70vw; padding: 10px 20px;
  animation: di-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 10px 36px rgba(10, 132, 255, 0.45), 0 0 0 1px rgba(10, 132, 255, 0.5);
}
@keyframes di-pop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
#diPreview { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#diCount {
  flex: none; min-width: 17px; height: 17px; border-radius: 999px;
  background: #ff453a; color: #fff; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
#diHistory {
  margin-top: 8px; width: 360px; max-height: 320px;
  background: rgba(28, 28, 30, 0.92); color: #eee;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: va-pop 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}
#diHistHead {
  display: flex; align-items: center; padding: 10px 14px 8px;
  font-size: 12.5px; font-weight: 700; color: #ccc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.di-spacer { flex: 1; }
#btnDiClear {
  border: none; background: none; color: #999; font-size: 11.5px;
  cursor: pointer; border-radius: 6px; padding: 3px 8px;
}
#btnDiClear:hover { color: #ff9f0a; background: rgba(255, 255, 255, 0.08); }
#diList { overflow-y: auto; padding: 6px 0; }
.di-row {
  display: flex; align-items: baseline; gap: 7px;
  padding: 6px 14px; font-size: 12.5px; line-height: 1.45;
}
.di-row:hover { background: rgba(255, 255, 255, 0.06); }
.di-tag { flex: none; }
.di-from { flex: none; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-text { flex: 1; min-width: 0; word-break: break-all; }
.di-time { flex: none; color: #888; font-size: 10.5px; font-family: var(--mono); }
.di-empty { padding: 20px; text-align: center; color: #888; font-size: 12px; }

/* 全员通知大横幅：屏幕中部，左→右滚动 + 彩虹流光 + 逐字波浪 */
#bigBanner {
  position: fixed; left: 0; right: 0; top: 42%; z-index: 80;
  display: flex; align-items: center; overflow: hidden;
  padding: 20px 60px 20px 0;
  background: linear-gradient(100deg,
    #ff5f57, #ff9f0a, #ffd60a, #30d158, #0a84ff, #bf5af2, #ff375f, #ff5f57);
  background-size: 400% 100%;
  animation: bb-flow 6s linear infinite, bb-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: #fff;
  box-shadow: 0 12px 44px rgba(10, 132, 255, 0.4), inset 0 0 30px rgba(255,255,255,0.12);
}
/* 背景彩虹流动 */
@keyframes bb-flow {
  from { background-position: 0% 0; }
  to { background-position: 400% 0; }
}
/* 弹簧入场：从上弹入并回稳 */
@keyframes bb-in {
  0% { transform: translateY(-80px) scale(0.9); opacity: 0; }
  60% { transform: translateY(8px) scale(1.02); opacity: 1; }
  100% { transform: translateY(0) scale(1); }
}
#bigBanner.fade { opacity: 0; transform: translateY(-10px); transition: all 0.5s; }
.bb-track {
  display: flex; flex: none; width: max-content;
  animation: bb-scroll 14s linear infinite;
}
.bb-text {
  flex: none; min-width: 100vw; padding-right: 80px;
  font-size: 24px; font-weight: 800; letter-spacing: 1px;
  white-space: nowrap;
}
/* 逐字波浪 + 发光 */
.bb-ch {
  display: inline-block;
  animation: bb-wave 1.4s ease-in-out infinite;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
}
@keyframes bb-wave {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-7px) rotate(-2deg); }
  75% { transform: translateY(4px) rotate(2deg); }
}
@keyframes bb-scroll {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}
.bb-close {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.bb-close:hover { background: rgba(255, 255, 255, 0.4); transform: translateY(-50%) rotate(90deg); }
.bb-close svg { width: 16px; height: 16px; }


/* ==========================================================================
   远程协作台 · 石墨深色 / 青色强调 / 紧凑工具栏（覆盖层）
   原有 Apple 主题变量被此覆盖；浅色主题仅微调，主形态为石墨深色。
   ========================================================================== */
:root {
  /* 石墨深色 */
  --bg: #0e1116;
  --bg2: #161a21;
  --bg3: #1e242d;
  --elevated: #1a1f27;
  --border: #2a323d;
  --border-soft: rgba(148, 163, 184, 0.12);
  --fg: #e6eaf0;
  --fg-dim: #94a0ae;
  --fg-faint: #5c6873;
  --accent: #2dd4bf;            /* 青色强调 */
  --accent-soft: rgba(45, 212, 191, 0.14);
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --purple: #a78bfa;
  --on-accent: #06251f;
  --term-bg: #0b0e13;
  --topbar-bg: rgba(22, 26, 33, 0.92);
  --sidebar-bg: rgba(20, 24, 31, 0.85);
  --overlay-bg: rgba(8, 10, 14, 0.62);
  --toast-bg: rgba(26, 31, 39, 0.92);
  --row-alt: rgba(148, 163, 184, 0.045);
  --cm-linenumber: #45505c;
  --cm-activeline: rgba(148, 163, 184, 0.05);
  --cm-selection: rgba(45, 212, 191, 0.22);
  --hairline: rgba(148, 163, 184, 0.1);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg: #f2f5f7;
  --bg2: #ffffff;
  --bg3: #e8edf1;
  --elevated: #ffffff;
  --border: #d3dbe2;
  --border-soft: rgba(71, 85, 105, 0.08);
  --fg: #1c2430;
  --fg-dim: #5b6772;
  --fg-faint: #9aa5b0;
  --accent: #0d9488;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --green: #059669;
  --red: #dc2626;
  --yellow: #b45309;
  --purple: #7c3aed;
  --on-accent: #ffffff;
  --term-bg: #fafbfc;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --sidebar-bg: rgba(247, 249, 251, 0.9);
  --overlay-bg: rgba(240, 243, 245, 0.6);
  --toast-bg: rgba(255, 255, 255, 0.92);
  --row-alt: rgba(71, 85, 105, 0.03);
  --cm-linenumber: #b6c0ca;
  --cm-activeline: rgba(71, 85, 105, 0.045);
  --cm-selection: rgba(13, 148, 136, 0.15);
  --hairline: rgba(71, 85, 105, 0.08);
}

/* ---- 顶栏：更紧凑（44px），工作台气质 ---- */
#topbar { height: 44px; padding: 0 12px; gap: 8px; }
#layout { height: calc(100% - 44px); }
#topbar .brand { font-size: 13.5px; gap: 7px; font-weight: 650; }
#topbar .brand .logo svg { filter: drop-shadow(0 1px 6px rgba(45, 212, 191, 0.35)); }

/* ---- 紧凑工具按钮 ---- */
#topbar .theme-btn,
#topbar .logout {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 8px;
  min-width: 30px;
}
#topbar .me { font-size: 12px; }
#topbar .status { gap: 6px; }

/* ---- 「更多」菜单（游戏收纳） ---- */
#btnExtras { position: relative; }
.extras-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 8px; height: 8px; border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  display: none;
}
.extras-badge:not(:empty) { display: block; }
.extras-menu {
  position: absolute; top: 40px; right: 64px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 60;
  min-width: 168px;
  display: flex; flex-direction: column; gap: 2px;
}
.extras-menu button {
  background: none; border: none; color: var(--fg-dim);
  text-align: left; padding: 7px 12px; font-size: 12.5px;
  border-radius: 7px; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.extras-menu button:hover { background: var(--accent-soft); color: var(--accent); }

/* ---- 侧栏：项目 / 文件 / 终端更突出 ---- */
.side-actions { padding: 6px 8px; gap: 4px; }
.side-actions button { padding: 5px 8px; font-size: 11.5px; border-radius: 8px; }
#projBar { padding: 6px 8px 2px; }
#gitHeader .git-title { color: var(--accent); font-weight: 650; }
.tree .icon.folder { color: var(--accent); }
.tree .row.active { background: var(--accent-soft); color: var(--accent); }
#flappy, #zuma, #versus { top: 48px; }

/* ---- 登录页：石墨 + 青色 ---- */
.login-overlay {
  background:
    radial-gradient(700px 380px at 25% 8%, rgba(45, 212, 191, 0.10), transparent),
    radial-gradient(600px 360px at 80% 92%, rgba(13, 148, 136, 0.08), transparent),
    var(--overlay-bg);
}
.login-card { border-radius: 16px; padding: 36px 36px 28px; gap: 13px; }
.login-logo .logo { filter: drop-shadow(0 2px 12px rgba(45, 212, 191, 0.35)); }
.login-card button.primary {
  background: var(--accent); color: var(--on-accent); font-weight: 650;
}
.login-card input#loginPassword {
  text-align: left; font-family: var(--mono); letter-spacing: 0.08em;
}

/* ---- 主按钮：青色 ---- */
button.primary { background: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent); filter: brightness(1.08); color: var(--on-accent); }

/* ---- 终端面板：融入石墨 ---- */
#termPanel { background: var(--term-bg); }

/* ---- 第三方来源与许可证说明（页脚说明样式，内容见 README） ---- */
.vendor-note {
  font-size: 11px; color: var(--fg-faint); line-height: 1.8;
  padding: 10px 14px; border-top: 1px solid var(--hairline);
}

/* ============================== 登录页双栏布局 ============================== */
.login-card.login-split {
  width: 640px; max-width: calc(100vw - 40px);
  flex-direction: row; text-align: left; gap: 0;
  padding: 0; overflow: hidden; border-radius: 18px;
}
.login-brand {
  flex: 1.05; padding: 34px 26px 28px;
  background:
    radial-gradient(420px 240px at 12% 0%, rgba(45, 212, 191, 0.13), transparent),
    radial-gradient(380px 260px at 110% 100%, rgba(14, 116, 144, 0.18), transparent),
    var(--bg2);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand .login-logo { justify-content: flex-start; font-size: 21px; }
.login-brand .login-tip { margin: 0; font-size: 12.5px; }
.login-feats {
  list-style: none; margin: 4px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 9px;
  font-size: 12.5px; color: var(--fg-dim); line-height: 1.5;
}
.login-feats li { display: flex; align-items: center; gap: 9px; }
.lf-ic { flex: none; width: 26px; height: 26px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 14px;
  background: var(--accent-soft); border-radius: 8px; }
.login-note {
  margin-top: auto; padding-top: 16px;
  font-size: 10.5px; color: var(--fg-faint); letter-spacing: 0.02em;
}
.login-fields {
  flex: 1; padding: 34px 30px 28px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-fields .icon-label { margin-bottom: -6px; }
.login-fields input { text-align: left; }
.login-fields input#loginName { letter-spacing: 0; }
.login-fields input#loginPassword { font-family: var(--mono); letter-spacing: 0.08em; }
.login-fields button.primary { margin-top: 6px; }
.login-fields .icon-grid { grid-template-columns: repeat(8, 1fr); gap: 5px; }
.login-fields .icon-grid .ic { font-size: 18px; line-height: 34px; border-radius: 9px; }

/* 窄屏退化为单栏 */
@media (max-width: 640px) {
  .login-card.login-split { width: 372px; flex-direction: column; }
  .login-brand { border-right: none; border-bottom: 1px solid var(--hairline); }
  .login-note { margin-top: 6px; padding-top: 10px; }
  .login-feats { display: none; }
  .login-fields input { text-align: center; }
}

/* 提钱退休发布：复用协作台主题变量 */
#btnRelease { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.release-overlay[hidden] { display: none; }
.release-overlay { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.58); }
.release-panel { width: min(620px, 100%); max-height: min(80vh, 760px); overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--bg2); color: var(--fg); padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.32); }
.release-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.release-header h2 { margin: 0; font-size: 17px; }
.release-close { padding: 5px 9px; }
.release-intro { color: var(--fg-dim); font-size: 12px; line-height: 1.6; margin: 12px 0; }
.release-message { padding: 10px 12px; border-radius: 8px; background: var(--bg3); font-size: 13px; line-height: 1.5; }
.release-message[data-kind="ok"] { color: #33b89b; }
.release-message[data-kind="warn"] { color: #d99531; }
.release-message[data-kind="error"] { color: #ee6a75; }
.release-list { max-height: 220px; overflow: auto; padding-left: 22px; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.release-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.release-actions button, .release-actions a { padding: 7px 12px; font-size: 12px; }
.release-actions button:disabled { opacity: .55; cursor: wait; }
.release-panel [hidden] { display: none !important; }
