/* ============ 文 — 基于 XP.css 的定制层 ============ */

:root {
  --reader-fs: 14px;
  --face: #ece9d8;
  --face-dark: #d6d2c2;
  --edge: #aca899;
  --sunken: #7f9db9;
  --sel: #2267cb;
  --accent: #003399;
  --accent2: #316ac5;
  --link: #1c56c9;
  --tb-grad: linear-gradient(180deg, #0997ff, #0053ee 8%, #0050ee 40%, #06f 88%, #06f 93%, #005bff 95%, #003dd7);
  --tb-text: #fff;
  --tb-shadow: 1px 1px #0f1089;
  --side-grad: linear-gradient(180deg, #8fb4f2, #316ac5);
  --side-text: #fff;
  --task-grad: linear-gradient(180deg, #4a9df8 0, #2b7de9 4%, #1f5fc9 8%, #2465d6 40%, #1a47a8 96%, #153c94);
  --task-edge: #0f3fa8;
  --task-btn-grad: linear-gradient(180deg, #3f8cf3, #2465d6);
  --task-btn-text: #fff;
  --task-btn-active: linear-gradient(180deg, #1a47a8, #2465d6);
  --start-grad: linear-gradient(180deg, #9ede73 0, #63bd37 8%, #46a01e 40%, #3f9a1c 88%, #2e7a12);
  --start-text: #fff;
  --start-shadow: 1px 1px 1px rgba(0, 0, 0, .55);
  --tray-grad: linear-gradient(180deg, #1290e9 0, #0c59c1 50%, #0a4ba8);
  --tray-text: #fff;
  --win-shadow: inset -1px -1px #00138c, inset 1px 1px #0831d9, inset -2px -2px #001ea0, inset 2px 2px #166aee, inset -3px -3px #003bda, inset 3px 3px #0855dd;
  --sm-right-bg: #d3e5fa;
  --sm-right-edge: #a9c9ef;
}

body[data-theme="olive"] {
  --sel: #6f9a37;
  --accent: #3f6d1f;
  --accent2: #5d8f2a;
  --link: #4c7a22;
  --tb-grad: linear-gradient(180deg, #c8e09e 0, #9cc06c 8%, #85ad53 40%, #90ba5e 88%, #7aa547 95%, #4c7a22);
  --tb-shadow: 1px 1px #3f5f1f;
  --side-grad: linear-gradient(180deg, #c2dc9a, #7fa84e);
  --task-grad: linear-gradient(180deg, #b1d287 0, #8ab558 4%, #74a043 8%, #7fa84e 40%, #5d8f2a 96%, #46701c);
  --task-edge: #3f5f1f;
  --task-btn-grad: linear-gradient(180deg, #9cc06c, #6d9a3a);
  --task-btn-active: linear-gradient(180deg, #4c7a22, #6d9a3a);
  --start-grad: linear-gradient(180deg, #d4ecae 0, #a3c878 8%, #85ad53 40%, #7fa84e 88%, #5d8f2a);
  --tray-grad: linear-gradient(180deg, #9cc06c 0, #6d9a3a 50%, #55852a);
  --win-shadow: inset -1px -1px #33511a, inset 1px 1px #9cc06c, inset -2px -2px #4c7a22, inset 2px 2px #b1d287, inset -3px -3px #5d8f2a, inset 3px 3px #85ad53;
  --sm-right-bg: #e4efd2;
  --sm-right-edge: #b9cf97;
}

body[data-theme="silver"] {
  --sel: #7a7a92;
  --accent: #4a4a6a;
  --accent2: #6a6a85;
  --link: #55557a;
  --tb-grad: linear-gradient(180deg, #fdfdfe 0, #e6e6ee 8%, #cdcdd9 40%, #dcdce5 88%, #c2c2d0 95%, #8f8fa3);
  --tb-text: #20203a;
  --tb-shadow: 1px 1px #fff;
  --side-grad: linear-gradient(180deg, #e6e6ee, #b9b9c9);
  --side-text: #20203a;
  --task-grad: linear-gradient(180deg, #f0f0f5 0, #d8d8e2 4%, #c4c4d2 8%, #cdcdd9 40%, #a9a9bc 96%, #8f8fa3);
  --task-edge: #7a7a90;
  --task-btn-grad: linear-gradient(180deg, #e2e2ea, #b9b9c9);
  --task-btn-text: #20203a;
  --task-btn-active: linear-gradient(180deg, #9a9ab0, #c4c4d2);
  --start-grad: linear-gradient(180deg, #f0f0f5 0, #d8d8e2 8%, #c2c2d0 40%, #b9b9c9 88%, #8f8fa3);
  --start-text: #20203a;
  --start-shadow: 1px 1px #fff;
  --tray-grad: linear-gradient(180deg, #d8d8e2 0, #b9b9c9 50%, #a9a9bc);
  --tray-text: #20203a;
  --win-shadow: inset -1px -1px #55556a, inset 1px 1px #e6e6ee, inset -2px -2px #8f8fa3, inset 2px 2px #f5f5f8, inset -3px -3px #a9a9bc, inset 3px 3px #cdcdd9;
  --sm-right-bg: #e8e8f0;
  --sm-right-edge: #c2c2d0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font-family: Tahoma, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  color: #222;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--sel); color: #fff; }

/* ---------- XP 风格滚动条 ---------- */
::-webkit-scrollbar { width: 15px; height: 15px; }
::-webkit-scrollbar-track {
  background: repeating-conic-gradient(#fff 0% 25%, #f1efe2 0% 50%) 0 0 / 2px 2px;
  border-left: 1px solid #d4d0c8;
}
::-webkit-scrollbar-thumb {
  background: var(--face);
  border: 1px solid;
  border-color: #fff #6d6d6d #6d6d6d #fff;
  box-shadow: inset 1px 1px #dfdfdf, inset -1px -1px #a0a0a0;
}
::-webkit-scrollbar-thumb:hover { background: #e6e3d4; }
::-webkit-scrollbar-thumb:active { background: var(--face-dark); }
::-webkit-scrollbar-corner { background: var(--face); }
* { scrollbar-color: #d6d2c2 #f1efe2; }

/* ---------- 桌面 ---------- */
#desktop {
  position: fixed;
  inset: 0;
  background: #2f7015 url("wallpaper.svg") center / cover no-repeat;
  overflow: hidden;
}

#desktop-icons {
  position: absolute;
  top: 14px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 10;
}
.desktop-icon {
  width: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  cursor: default;
  border: 1px dotted transparent;
  user-select: none;
}
.desktop-icon .dic-img {
  width: 40px;
  height: 40px;
  filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, .45));
}
.desktop-icon .dic-label {
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 1.3;
  text-shadow: 1px 1px 2px #000, 0 0 4px rgba(0, 0, 0, .8);
  padding: 0 2px;
}
.desktop-icon.selected { background: rgba(49, 106, 197, .5); border-color: #cfe0f7; }
.desktop-icon.selected .dic-label { background: var(--sel); text-shadow: none; }
.desktop-icon:focus-visible { outline: 1px dotted #fff; }

/* ---------- 主窗口 ---------- */
#app-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 220px;
  box-shadow: var(--win-shadow), 3px 3px 14px rgba(0, 0, 0, .45);
  z-index: 100;
  animation: win-in .18s ease-out;
}
@keyframes win-in { from { opacity: 0; transform: scale(.97); } }
#app-window.maximized { border-radius: 0; }
#app-window.dragging { user-select: none; }
#app-window .window-body {
  margin: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 3px;
}
#title-bar { cursor: default; flex-shrink: 0; }
#title-bar .title-bar-text {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tb-icon { width: 15px; height: 15px; flex-shrink: 0; }
.lb-window .title-bar-text {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
}
#lb-title { overflow: hidden; text-overflow: ellipsis; }
#title-text { overflow: hidden; text-overflow: ellipsis; }
body[data-theme="olive"] #title-bar,
body[data-theme="silver"] #title-bar {
  background: var(--tb-grad);
  color: var(--tb-text);
  text-shadow: var(--tb-shadow);
}
body[data-theme="olive"] #app-window,
body[data-theme="silver"] #app-window { box-shadow: var(--win-shadow), 3px 3px 14px rgba(0, 0, 0, .45); }

#resize-grip {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 50%, #fff 50% 60%, #808080 60% 70%, transparent 70%),
    linear-gradient(135deg, transparent 0 65%, #fff 65% 75%, #808080 75% 85%, transparent 85%);
  z-index: 20;
}

/* ---------- 菜单栏 ---------- */
#menubar {
  position: relative;
  display: flex;
  align-items: center;
  padding: 1px 2px;
  flex-shrink: 0;
  z-index: 600;
}
.menu-btn {
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  min-width: unset;
  min-height: unset;
  padding: 3px 9px;
  font-size: 12px;
  font-family: inherit;
  color: #222;
  cursor: default;
}
.menu-btn:hover, .menu-btn.open {
  background: var(--sel);
  border-color: var(--sel);
  color: #fff;
  box-shadow: none;
}
.menu-btn:active { box-shadow: none; }
#menubar-hint {
  margin-left: auto;
  padding-right: 6px;
  font-size: 11px;
  color: #8a8878;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-dropdown {
  position: absolute;
  top: 100%;
  min-width: 216px;
  background: #fff;
  border: 1px solid var(--edge);
  box-shadow: 2px 2px 5px rgba(0, 0, 0, .28);
  padding: 2px;
  animation: menu-in .12s ease-out;
  z-index: 650;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-3px); } }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 4px 10px;
  font-size: 12px;
  cursor: default;
  white-space: nowrap;
}
.menu-item .mi-check { width: 14px; flex-shrink: 0; text-align: center; }
.menu-item .mi-label { flex: 1; }
.menu-item .mi-key { font-size: 11px; opacity: .72; margin-left: 26px; }
.menu-item:hover { background: var(--sel); color: #fff; }
.menu-item.disabled { color: #aca899; }
.menu-item.disabled:hover { background: transparent; color: #aca899; }
.menu-sep { height: 1px; background: #d4d0c8; margin: 3px 2px; }

/* ---------- 工具栏 / 地址栏 / 查找栏 ---------- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
#toolbar::-webkit-scrollbar { height: 8px; }
.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: unset;
  min-height: unset;
  height: 25px;
  padding: 0 9px;
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.tb-btn.pressed {
  background: var(--face-dark);
  box-shadow: inset 1px 1px #808080, inset -1px -1px #fff, inset 2px 2px #a0a0a0;
}
.tb-btn:disabled { color: #aca899; }
.ic { width: 16px; height: 16px; flex-shrink: 0; }
.tb-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: var(--edge); border-right: 1px solid #fff; flex-shrink: 0; }
.tb-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tb-label select { height: 23px; font-size: 12px; padding: 1px 2px; font-family: inherit; }
#mode-tabs { margin: 0; flex-shrink: 0; }
#mode-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-family: inherit;
  padding: 2px 10px 3px;
}
#mode-tabs .ic { width: 14px; height: 14px; }

#addressbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1px 4px 4px;
  flex-shrink: 0;
}
.addr-label { font-size: 12px; color: #444; white-space: nowrap; }
.addr-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--sunken);
  height: 24px;
  padding: 0 5px;
  min-width: 60px;
}
.addr-wrap:focus-within { border-color: var(--sel); }
.addr-ic { width: 15px; height: 15px; }
#address {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: inherit;
  padding: 0;
  min-width: 0;
  height: 20px;
  box-shadow: none;
}
#btn-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: unset;
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
  flex-shrink: 0;
}

#findbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  background: #f5f4ea;
  border-top: 1px solid #fff;
  border-bottom: 1px solid var(--edge);
  flex-shrink: 0;
}
#find-input { width: 240px; max-width: 46vw; height: 22px; font-size: 12px; font-family: inherit; padding: 1px 5px; }
#find-count { font-size: 12px; color: #555; min-width: 52px; white-space: nowrap; }
#findbar button { min-width: unset; min-height: unset; width: 27px; height: 22px; padding: 0; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
#findbar .ic-close { width: 11px; height: 11px; }
#findbar .ic-close use { stroke: #333; }
#find-close { background: transparent; box-shadow: none; border: 1px solid transparent; }
#find-close:hover { background: #e6e3d4; border-color: var(--edge); box-shadow: none; }

/* ---------- 主区域 / 侧栏 ---------- */
#main {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 4px;
  padding: 0 1px;
  position: relative;
}
#sidebar {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}
body:not(.sidebar-visible) #sidebar { display: none; }
.side-panel { display: flex; flex-direction: column; min-height: 0; }
#toc-panel { flex: 1.25; }
#files-panel { flex: 1; }
.side-title {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--side-grad);
  color: var(--side-text);
  font-size: 12px;
  font-weight: bold;
  padding: 4px 9px;
  border-radius: 4px 4px 0 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
  flex-shrink: 0;
}
body[data-theme="silver"] .side-title { text-shadow: 0 1px 0 #fff; }
.side-title .ic { width: 14px; height: 14px; }
.side-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--sunken);
  border-top: none;
}
.side-body .tree-view {
  font-family: Tahoma, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  padding: 5px 4px;
}
.side-body .tree-view li { margin-top: 1px; }
#toc a {
  display: block;
  padding: 2px 6px;
  border-radius: 2px;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#toc a:hover { background: #e8f0fb; color: var(--accent); }
#toc a.active, #toc a:focus { background: var(--sel); color: #fff; }
#toc .toc-h2 { padding-left: 18px; }
#toc .toc-h3 { padding-left: 32px; }
#toc .toc-h4 { padding-left: 46px; }
#toc .toc-empty { color: #999; padding: 6px; font-style: italic; }

.ft-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px;
  cursor: default;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.ft-row:hover { background: #e8f0fb; }
.ft-row.current { background: var(--sel); color: #fff; }
.ft-row .ft-caret { width: 11px; flex-shrink: 0; font-size: 9px; color: #666; text-align: center; }
.ft-row.current .ft-caret { color: #fff; }
.ft-row .ic { width: 15px; height: 15px; }
.ft-row .ft-name { overflow: hidden; text-overflow: ellipsis; }
.ft-children { margin-left: 13px; padding-left: 6px; border-left: 1px dotted #c9c5b4; }
.ft-loading { color: #999; font-style: italic; padding: 2px 6px; }

/* ---------- 内容区 ---------- */
#content {
  flex: 1;
  min-width: 0;
  display: flex;
  position: relative;
  background: #fff;
  border: 1px solid var(--sunken);
}
#read-pane { flex: 1; min-width: 0; overflow: auto; position: relative; }
#edit-pane { flex: 1; min-width: 0; display: flex; }
#content.split #read-pane { border-left: 1px solid var(--sunken); }
#editor {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: #fff;
  font-family: "Cascadia Code", Consolas, Menlo, "Courier New", "PingFang SC", monospace;
  font-size: 13px;
  line-height: 1.7;
  padding: 14px 16px;
  color: #1a1a1a;
  box-shadow: none;
  tab-size: 2;
}

#loading {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.loading-box { width: 300px; max-width: 80%; text-align: center; }
.loading-icon { width: 42px; height: 42px; }
.loading-text { font-size: 12px; margin: 12px 0 10px; color: #333; word-break: break-all; }
#loading-bar { width: 100%; height: 17px; }

/* ---------- 状态栏 ---------- */
.status-bar { flex-shrink: 0; margin: 2px 0 1px; }
.status-bar-field { font-family: Tahoma, "PingFang SC", sans-serif; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#st-state { flex-grow: 2.2; }
#st-pos { flex-grow: 1.1; }
#st-progress { display: flex; align-items: center; gap: 5px; flex-grow: 1; }
#read-progress-bar {
  display: inline-block;
  width: 68px;
  height: 9px;
  border: 1px solid var(--edge);
  background: #fff;
  flex-shrink: 0;
}
#read-progress-bar i { display: block; height: 100%; width: 0; background: var(--sel); transition: width .12s linear; }

/* ---------- Markdown 排版 ---------- */
.markdown-body {
  max-width: 880px;
  margin: 0 auto;
  padding: 26px 38px 90px;
  font-size: var(--reader-fs);
  line-height: 1.78;
  color: #1a1a1a;
  word-wrap: break-word;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: Tahoma, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--accent);
  line-height: 1.35;
  margin: 1.5em 0 .65em;
  scroll-margin-top: 14px;
  font-weight: bold;
}
.markdown-body h1 { font-size: 1.85em; border-bottom: 2px solid var(--accent2); padding-bottom: .28em; }
.markdown-body h2 { font-size: 1.45em; border-bottom: 1px solid #dcd8c8; padding-bottom: .22em; }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body h5, .markdown-body h6 { font-size: 1em; color: #555; }
.markdown-body p { margin: .85em 0; }
.markdown-body a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body a:hover { color: var(--accent); background: #e8f0fb; }
.markdown-body strong { color: #000; }
.markdown-body ul, .markdown-body ol { padding-left: 1.7em; margin: .85em 0; }
.markdown-body li { margin: .32em 0; }
.markdown-body li::marker { color: var(--accent2); }
.markdown-body li.task-list-item { list-style: none; margin-left: -1.4em; }
.markdown-body li.task-list-item label {
  display: inline;
  font: inherit;
  color: inherit;
  text-shadow: none;
  line-height: inherit;
  cursor: default;
}
.markdown-body blockquote {
  margin: 1.15em 0;
  padding: 8px 15px;
  border-left: 4px solid var(--accent2);
  background: #f0f4fb;
  color: #333;
}
.markdown-body blockquote p { margin: .35em 0; }
.markdown-body hr {
  border: none;
  height: 2px;
  border-top: 1px solid var(--edge);
  border-bottom: 1px solid #fff;
  background: transparent;
  margin: 2.1em 0;
}
.markdown-body code {
  font-family: "Cascadia Code", Consolas, Menlo, "Courier New", monospace;
  font-size: .9em;
  background: #f5f4ea;
  border: 1px solid #dcd8c8;
  border-radius: 2px;
  padding: 1px 5px;
  color: #7a2020;
}
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: .95em;
  display: block;
  overflow-x: auto;
}
.markdown-body th {
  background: linear-gradient(180deg, #fff, #ece9d8 45%, #dcd8c8);
  border: 1px solid var(--edge);
  padding: 6px 11px;
  text-align: left;
  color: var(--accent);
  white-space: nowrap;
}
.markdown-body td { border: 1px solid #dcd8c8; padding: 6px 11px; }
.markdown-body tbody tr:nth-child(even) td { background: #faf9f2; }
.markdown-body tbody tr:hover td { background: #e8f0fb; }
.markdown-body img.xp-img {
  max-width: 100%;
  background: #fff;
  padding: 4px;
  border: 1px solid var(--edge);
  box-shadow: inset 1px 1px #fff, inset -1px -1px #d4d0c8, 1px 1px 4px rgba(0, 0, 0, .22);
}
.markdown-body figure { margin: 1.2em 0; text-align: center; }
.markdown-body figcaption { font-size: .85em; color: #777; margin-top: 5px; }
.img-broken {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--edge);
  background: #f5f4ea;
  color: #8a8878;
  font-size: 12px;
  padding: 10px 14px;
}
.markdown-body mark.find-hit { background: #ffe9a8; color: inherit; padding: 0; }
.markdown-body mark.find-current { background: #f5a623; outline: 1px solid #a86e12; }

/* 代码块 = 迷你 XP 窗口 */
.code-window { margin: 1.25em 0; border: 1px solid var(--sunken); background: #000; }
.code-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 22px;
  padding: 0 4px 0 9px;
  background: var(--tb-grad);
  color: var(--tb-text);
  text-shadow: var(--tb-shadow);
  font-size: 11px;
  font-family: "Trebuchet MS", Tahoma, "PingFang SC", sans-serif;
  border-radius: 5px 5px 0 0;
}
.code-lang { color: #fff; font-weight: bold; text-transform: lowercase; letter-spacing: .3px; }
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: unset;
  min-height: unset;
  height: 17px;
  padding: 0 7px;
  font-size: 10px;
  font-family: inherit;
}
.code-copy .ic { width: 11px; height: 11px; }
.code-window pre {
  margin: 0;
  padding: 12px 15px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.62;
  background: #000;
  color: #d4d0c8;
}
.code-window pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #d4d0c8;
  font-size: inherit;
}

/* highlight.js — XP 控制台（黑底）高对比配色：银灰正文 + 经典 IDE 多色_token */
.hljs-comment, .hljs-quote { color: #6a9955; font-style: italic; }
.hljs-doctag { color: #6a9955; font-weight: bold; }
.hljs-keyword, .hljs-selector-tag { color: #569cd6; }
.hljs-literal { color: #d7ba7d; }
.hljs-string { color: #ce9178; }
.hljs-regexp { color: #d16969; }
.hljs-number, .hljs-addition { color: #b5cea8; }
.hljs-symbol, .hljs-bullet { color: #e5c07b; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #dcdcaa; }
.hljs-title.class_, .hljs-type { color: #4ec9b0; }
.hljs-built_in { color: #4fc1ff; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: #9cdcfe; }
.hljs-variable.language_ { color: #569cd6; }
.hljs-char.escape_ { color: #d7ba7d; }
.hljs-name, .hljs-tag { color: #ff7b72; }
.hljs-selector-id { color: #4fc1ff; }
.hljs-selector-class { color: #d7ba7d; }
.hljs-meta { color: #c586c0; }
.hljs-deletion { color: #f44747; }
.hljs-operator { color: #d4d4d4; }
.hljs-punctuation { color: #a6a6a6; }
.hljs-link { color: #4fc1ff; text-decoration: underline; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }

/* Mermaid 图表 = 迷你 XP 窗口 */
.diagram-window { margin: 1.4em 0; }
.diagram-title {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 4px 0 9px;
  background: var(--tb-grad);
  color: var(--tb-text);
  text-shadow: var(--tb-shadow);
  font-size: 11px;
  font-family: "Trebuchet MS", Tahoma, "PingFang SC", sans-serif;
  border-radius: 5px 5px 0 0;
}
.diagram-title .dt-label { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.diagram-title button {
  min-width: unset;
  min-height: unset;
  height: 17px;
  padding: 0 7px;
  font-size: 10px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.diagram-title .ic { width: 11px; height: 11px; }
.diagram-body {
  background: #fff;
  border: 1px solid var(--sunken);
  border-top: none;
  padding: 12px;
  overflow: auto;
}
.diagram-body svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram-body svg .node rect,
.diagram-body svg .node polygon,
.diagram-body svg .node circle { filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, .14)); }
.diagram-body svg .edgePath path, .diagram-body svg .flowchart-link { stroke-width: 1.7px; }
.diagram-error {
  border: 1px solid #d9342b;
  background: #fdf1f0;
  padding: 10px 13px;
  font-size: 12px;
  color: #8f1610;
}
.diagram-error pre {
  margin: 8px 0 0;
  padding: 8px;
  background: #fff;
  border: 1px solid #e4b7b3;
  font-size: 11px;
  overflow: auto;
  color: #333;
}

/* ---------- 任务栏 ---------- */
#taskbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 36px;
  background: var(--task-grad);
  border-top: 1px solid var(--task-edge);
  display: flex;
  align-items: center;
  z-index: 900;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, .3);
}
#start-button {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  margin: 0 6px 0 2px;
  padding: 0 17px 0 9px;
  border: none;
  border-radius: 0 9px 9px 0;
  background: var(--start-grad);
  box-shadow: inset 0 1px rgba(255, 255, 255, .45), inset 0 -2px rgba(0, 0, 0, .18), 1px 0 2px rgba(0, 0, 0, .3);
  color: var(--start-text);
  font: italic bold 15px "Trebuchet MS", Tahoma, sans-serif;
  text-shadow: var(--start-shadow);
  min-width: unset;
  min-height: unset;
  cursor: default;
  flex-shrink: 0;
}
#start-button:hover { filter: brightness(1.09); box-shadow: inset 0 1px rgba(255,255,255,.45), inset 0 -2px rgba(0,0,0,.18), 1px 0 2px rgba(0,0,0,.3); }
#start-button:active, #start-button.open { filter: brightness(.93); box-shadow: inset 1px 1px 3px rgba(0,0,0,.35); }
.start-flag { width: 20px; height: 20px; filter: drop-shadow(1px 1px 1px rgba(0, 0, 0, .4)); }
#task-buttons { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow: hidden; }
.task-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  max-width: 210px;
  padding: 0 12px;
  background: var(--task-btn-grad);
  border: 1px solid rgba(0, 0, 0, .28);
  border-radius: 3px;
  box-shadow: inset 0 1px rgba(255, 255, 255, .35);
  color: var(--task-btn-text);
  font-size: 12px;
  font-family: inherit;
  min-width: unset;
  min-height: unset;
  cursor: default;
}
.task-btn span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.task-btn .ic { width: 15px; height: 15px; }
.task-btn.active { background: var(--task-btn-active); box-shadow: inset 1px 1px 3px rgba(0, 0, 0, .4); }
.task-btn:hover { filter: brightness(1.08); }
#tray {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 27px;
  padding: 0 13px;
  background: var(--tray-grad);
  border-left: 1px solid rgba(255, 255, 255, .28);
  box-shadow: inset 1px 0 2px rgba(0, 0, 0, .18);
  color: var(--tray-text);
  flex-shrink: 0;
}
#tray-keys {
  background: transparent;
  border: none;
  box-shadow: none;
  min-width: unset;
  min-height: unset;
  padding: 0 2px;
  font-size: 14px;
  color: inherit;
  cursor: default;
}
#tray-keys:hover { box-shadow: none; filter: brightness(1.2); }
#tray-clock { font-size: 12px; font-family: Tahoma, sans-serif; white-space: nowrap; }

/* ---------- 开始菜单 ---------- */
#start-menu {
  position: absolute;
  bottom: 38px;
  left: 2px;
  width: 392px;
  max-width: calc(100vw - 8px);
  background: #fff;
  border: 1px solid var(--task-edge);
  border-radius: 7px 7px 0 0;
  box-shadow: 3px -3px 12px rgba(0, 0, 0, .4);
  overflow: hidden;
  z-index: 950;
  animation: sm-in .15s ease-out;
  transform-origin: bottom left;
}
@keyframes sm-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.sm-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  background: var(--tb-grad);
  color: var(--tb-text);
  text-shadow: var(--tb-shadow);
  font: bold 14px "Trebuchet MS", Tahoma, "PingFang SC", sans-serif;
}
.sm-avatar {
  width: 34px; height: 34px;
  background: var(--face);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 4px;
  padding: 3px;
  flex-shrink: 0;
}
.sm-columns { display: flex; }
.sm-left { flex: 1.25; padding: 4px; background: #fff; min-width: 0; }
.sm-right { width: 158px; padding: 4px; background: var(--sm-right-bg); border-left: 1px solid var(--sm-right-edge); flex-shrink: 0; }
.sm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  font-size: 12px;
  cursor: default;
  border-radius: 2px;
}
.sm-item .ic { width: 22px; height: 22px; }
.sm-item .sm-txt { min-width: 0; }
.sm-item .sm-name { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-item .sm-sub { font-size: 11px; color: #777; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-item:hover { background: var(--sel); color: #fff; }
.sm-item:hover .sm-sub { color: #e2ecfa; }
.sm-sep { height: 1px; background: #d4d0c8; margin: 3px 6px; }
.sm-right .sm-item { padding: 5px 8px; }
.sm-right .sm-item .sm-name { font-weight: normal; }
.sm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 6px 9px;
  background: var(--tb-grad);
}
.sm-footer button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: unset;
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
}

/* ---------- 对话框 ---------- */
#modal-root { position: fixed; inset: 0; z-index: 2000; pointer-events: none; }
.modal-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .22); pointer-events: auto; }
.dialog {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  min-width: 340px;
  max-width: min(540px, 94vw);
  pointer-events: auto;
  animation: dlg-in .16s ease-out;
  box-shadow: var(--win-shadow), 3px 3px 14px rgba(0, 0, 0, .45);
}
@keyframes dlg-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.96); } }
.dialog .window-body { margin: 0; padding: 15px 16px 14px; }
.dlg-content { display: flex; gap: 15px; align-items: flex-start; }
.dlg-icon { width: 32px; height: 32px; flex-shrink: 0; }
.dlg-text { font-size: 12px; line-height: 1.75; word-break: break-all; min-width: 0; }
.dlg-text p { margin: 0 0 6px; }
.dlg-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.dlg-buttons button { min-width: 80px; font-family: inherit; font-size: 12px; }
.dialog-open { width: min(580px, 94vw); }
.dialog-open .window-body { padding: 12px 14px; }
.dlg-field { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: 12px; }
.dlg-field label { white-space: nowrap; }
.dlg-field input[type="text"] { flex: 1; font-size: 12px; font-family: inherit; height: 23px; padding: 1px 6px; min-width: 0; }
.browse-list {
  height: 186px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--sunken);
  padding: 3px;
  margin-bottom: 8px;
}
.browse-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  font-size: 12px;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
}
.browse-row .ic { width: 15px; height: 15px; flex-shrink: 0; }
.browse-row span { overflow: hidden; text-overflow: ellipsis; }
.browse-row:hover { background: #e8f0fb; }
.browse-row.selected { background: var(--sel); color: #fff; }
.browse-path { font-size: 11px; color: #777; margin: 0 0 4px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-title { font-size: 12px; font-weight: bold; color: var(--accent); margin: 6px 0 4px; }
.recent-list { max-height: 92px; overflow: auto; border: 1px solid #dcd8c8; background: #faf9f2; padding: 2px; }
.recent-item { display: flex; gap: 6px; align-items: center; padding: 3px 6px; font-size: 11px; cursor: default; white-space: nowrap; overflow: hidden; }
.recent-item span { overflow: hidden; text-overflow: ellipsis; }
.recent-item:hover { background: var(--sel); color: #fff; }
.recent-empty { font-size: 11px; color: #999; padding: 5px 6px; font-style: italic; }

/* ---------- 气泡提示 ---------- */
#balloon-root {
  position: fixed;
  right: 14px;
  bottom: 48px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-end;
  pointer-events: none;
}
.balloon {
  pointer-events: auto;
  position: relative;
  background: #ffffe1;
  border: 1px solid #000;
  border-radius: 7px;
  padding: 10px 26px 11px 13px;
  max-width: 310px;
  box-shadow: 2px 2px 7px rgba(0, 0, 0, .35);
  animation: balloon-in .25s ease-out;
}
@keyframes balloon-in { from { opacity: 0; transform: translateY(12px); } }
.balloon::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 26px;
  border: 8px solid transparent;
  border-top-color: #ffffe1;
  border-bottom: none;
  filter: drop-shadow(0 1px 0 #000);
}
.balloon-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: bold; margin-bottom: 3px; }
.balloon-title .ic { width: 15px; height: 15px; }
.balloon-text { font-size: 12px; line-height: 1.55; word-break: break-all; }
.balloon-close {
  position: absolute;
  top: 5px; right: 7px;
  background: none;
  border: none;
  box-shadow: none;
  min-width: unset;
  min-height: unset;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  color: #333;
}
.balloon-close:hover { box-shadow: none; color: #000; }
.balloon.out { opacity: 0; transform: translateY(8px); transition: all .25s; }

/* ---------- 图表查看器 ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-window {
  width: min(1020px, 95vw);
  height: min(740px, 90vh);
  display: flex;
  flex-direction: column;
  box-shadow: var(--win-shadow), 4px 4px 18px rgba(0, 0, 0, .5);
  animation: dlg-in .16s ease-out;
}
.lb-window .window-body { margin: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 6px; }
#lb-toolbar { display: flex; align-items: center; gap: 6px; padding: 1px 1px 6px; flex-shrink: 0; flex-wrap: wrap; }
#lb-toolbar button {
  min-width: unset;
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#lb-zoom-label { font-size: 12px; min-width: 44px; text-align: center; }
#lb-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--sunken);
  position: relative;
  cursor: grab;
  touch-action: none;
}
#lb-stage.dragging { cursor: grabbing; }
#lb-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#lb-canvas svg { display: block; }
.lb-window .status-bar { flex-shrink: 0; }

/* ---------- 欢迎页 ---------- */
.welcome-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #e8f0fb, #f5f4ea);
  border: 1px solid #dcd8c8;
  margin-bottom: 1.3em;
}
.welcome-hero svg { width: 52px; height: 52px; flex-shrink: 0; }
.welcome-hero h1 { margin: 0 0 4px; border: none; padding: 0; font-size: 1.5em; }
.welcome-hero p { margin: 0; color: #555; font-size: .92em; }
.welcome-actions { display: flex; gap: 9px; flex-wrap: wrap; margin: 1em 0; }
.welcome-actions button { display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 12px; padding: 4px 14px; }
.welcome-recent { border: 1px solid #dcd8c8; background: #faf9f2; padding: 4px; }
.url-demo {
  display: block;
  background: #f5f4ea;
  border: 1px solid #dcd8c8;
  padding: 9px 12px;
  font-family: Consolas, Menlo, monospace;
  font-size: .88em;
  color: #7a2020;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- 打印 ---------- */
@media print {
  body { overflow: visible; background: #fff; }
  #desktop { position: static; background: none; overflow: visible; }
  #desktop-icons, #taskbar, #menubar, #toolbar, #addressbar, #findbar,
  #sidebar, .status-bar, .title-bar-controls, #resize-grip, #balloon-root, #modal-root { display: none !important; }
  #app-window { position: static !important; width: auto !important; height: auto !important; box-shadow: none; animation: none; }
  #app-window .window-body { display: block; padding: 0; }
  #main { display: block; }
  #content { border: none; display: block; }
  #read-pane { overflow: visible; }
  #edit-pane { display: none !important; }
  .markdown-body { max-width: none; padding: 0; }
  .code-window, .diagram-window, table, blockquote { break-inside: avoid; }
  .code-title { background: #e8e6da !important; color: #000 !important; text-shadow: none !important; border-radius: 0; }
  .code-lang { color: #003399 !important; }
  .code-copy { display: none !important; }
  .code-window, .code-window pre, .code-window pre code { background: #fff !important; color: #000 !important; }
  .hljs-comment, .hljs-quote { color: #008000 !important; }
  .hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: #0000ff !important; }
  .hljs-string, .hljs-regexp, .hljs-link { color: #a31515 !important; }
  .hljs-number, .hljs-symbol, .hljs-bullet, .hljs-addition { color: #098658 !important; }
  .hljs-title, .hljs-title.function_, .hljs-section { color: #795e26 !important; }
  .hljs-title.class_, .hljs-type, .hljs-built_in { color: #267f99 !important; }
  .hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: #e50000 !important; }
  .hljs-name, .hljs-tag { color: #000080 !important; }
  .hljs-meta { color: #808080 !important; }
  .hljs-deletion { color: #a31515 !important; }
  #loading { display: none !important; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  #app-window {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: calc(100dvh - 36px) !important;
    border-radius: 0;
    min-width: 0;
    min-height: 0;
  }
  #resize-grip { display: none; }
  #menubar-hint { display: none; }
  #toolbar { flex-wrap: wrap; overflow: visible; row-gap: 3px; }
  #sidebar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 252px;
    z-index: 40;
    background: var(--face);
    padding: 4px;
    box-shadow: 2px 0 9px rgba(0, 0, 0, .35);
    transform: translateX(-105%);
    transition: transform .2s ease;
    display: flex !important;
  }
  body.sidebar-visible #sidebar { transform: none; }
  .markdown-body { padding: 18px 16px 70px; }
  #content.split { flex-direction: column; }
  #content.split #read-pane { border-left: none; border-top: 1px solid var(--sunken); }
  .addr-label { display: none; }
  .task-btn { max-width: 130px; }
  #tray-keys { display: none; }
  #start-menu { width: min(392px, calc(100vw - 4px)); }
  .sm-right { width: 138px; }
  .dialog { top: 38%; }
  .browse-list { height: 148px; }
  #find-input { width: 150px; }
  .lb-window { width: 97vw; height: 92vh; }
  .welcome-hero { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}