/* ============================== 基础变量 ============================== */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f8f7;
  --panel: #fbfbfa;
  --rail: #f2f4f2;
  --line: #e4e7e4;
  --line-soft: #eef0ee;
  --text: #1c211e;
  --text-2: #4c554f;
  --muted: #8a938d;
  --accent: #00a82d;
  --accent-hover: #00942a;
  --accent-soft: #e7f6ea;
  --hover: #ebedeb;
  --hover-2: #f1f3f1;
  --danger: #d93a3a;
  --danger-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(20, 30, 24, .06);
  --shadow-md: 0 6px 24px rgba(20, 30, 24, .10), 0 2px 6px rgba(20, 30, 24, .05);
  --shadow-lg: 0 18px 48px rgba(16, 24, 20, .16);
  --radius: 10px;
  --rail-w: 76px;
  --tree-w: 304px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #191d1a;
  --bg-soft: #1d211e;
  --panel: #1b1f1c;
  --rail: #151916;
  --line: #2b312d;
  --line-soft: #242925;
  --text: #e7ece8;
  --text-2: #b3bdb6;
  --muted: #838f88;
  --accent: #2fc855;
  --accent-hover: #3ad862;
  --accent-soft: #1d3524;
  --hover: #262c27;
  --hover-2: #212622;
  --danger: #ef5a5a;
  --danger-soft: #3a1f1f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font-family: inherit; color: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.dot { color: var(--muted); opacity: .5; margin: 0 5px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(120, 130, 124, .28); border: 3px solid transparent; background-clip: content-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 130, 124, .45); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================== 整体布局 ============================== */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--tree-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.app > * { min-width: 0; min-height: 0; }

/* ============================== 第一列：功能栏 ============================== */
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 10px;
  gap: 6px;
  user-select: none;
}
.brand {
  width: 34px; height: 34px; margin-bottom: 6px;
  display: grid; place-items: center;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(160deg, #0bbf3a, #009226);
  color: #fff; font-weight: 800; font-size: 17px;
  display: grid; place-items: center;
  box-shadow: 0 3px 10px rgba(0, 168, 45, .35);
  letter-spacing: -.5px;
}
.rail-new {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 3px 10px rgba(0, 168, 45, .3);
  transition: transform .12s ease, background .12s ease;
  margin-bottom: 8px;
}
.rail-new:hover { background: var(--accent-hover); transform: translateY(-1px); }
.rail-new .ic { width: 22px; height: 22px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; align-items: center; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.rail-btn {
  width: 60px; padding: 7px 0 6px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-2); font-size: 11px; line-height: 1;
  transition: background .12s ease, color .12s ease;
  position: relative;
}
.rail-btn .ic { width: 21px; height: 21px; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ============================== 第二列：目录 ============================== */
.tree-pane {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-width: 0;
  height: 100%;
}
.pane-head { padding: 14px 14px 10px; }
.pane-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pane-title { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: .2px; }
.pane-actions { display: flex; gap: 4px; }
.ghost-btn {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--text-2);
  position: relative;
}
.ghost-btn:hover { background: var(--hover); color: var(--accent); }
.ghost-btn .ic { width: 17px; height: 17px; }
.ghost-btn .ic-plus {
  width: 9px; height: 9px; position: absolute; right: 2px; bottom: 3px;
  background: var(--panel); border-radius: 4px;
}
.search-box {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 9px;
  height: 34px;
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .ic { width: 16px; height: 16px; color: var(--muted); }
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 13px; min-width: 0;
}
.search-box input::placeholder { color: var(--muted); }
.search-clear { color: var(--muted); font-size: 18px; line-height: 1; padding: 0 2px; }
.search-clear:hover { color: var(--text); }

.tree-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 8px 20px; }
.tree-drop { height: 44px; border-radius: 10px; margin: 4px 2px 0; border: 1px dashed transparent; transition: all .15s; }
.tree-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }

.row {
  display: flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 6px;
  border-radius: 7px;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  user-select: none;
  font-size: 13.5px;
  transition: background .1s ease;
}
.row:hover { background-color: var(--hover-2); }
.row.is-active { background-color: var(--accent-soft); color: var(--accent); font-weight: 600; }
.row.is-active .row-count { color: var(--accent); opacity: .75; }
.row.drop-hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.row .ic { width: 16px; height: 16px; opacity: .85; }
.row-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-note .row-name { font-weight: 400; }
.row.is-active.row-note .row-name { font-weight: 600; }
.row-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-more {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); opacity: 0; flex: 0 0 auto;
}
.row-more .ic { width: 15px; height: 15px; }
.row:hover .row-more { opacity: 1; }
.row-more:hover { background: var(--hover); color: var(--text); }

/* 列表视图（收藏 / 最近 / 回收站 / 搜索） */
.row-list { height: auto; min-height: 32px; padding-top: 6px; padding-bottom: 6px; align-items: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-main .row-name { display: block; }
.row-snippet {
  font-size: 11.5px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; padding-right: 2px;
}
.row-time { font-size: 11px; color: var(--muted); flex: 0 0 auto; margin-left: 6px; }
.row-note.is-star .ic { color: #f2a900; }
.row-list .ic { opacity: .9; }

.caret {
  width: 16px; height: 16px; flex: 0 0 auto;
  display: grid; place-items: center;
  color: var(--muted); border-radius: 4px;
  transition: transform .14s ease;
}
.caret .ic { width: 12px; height: 12px; }
.caret.open { transform: rotate(90deg); }
.caret:hover { background: var(--hover); }
.caret.empty { visibility: hidden; }

.tree-sep {
  font-size: 11px; color: var(--muted); letter-spacing: .5px;
  padding: 14px 8px 6px; text-transform: uppercase;
}
.tree-empty {
  padding: 28px 14px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.9;
}
.tree-empty b { color: var(--text-2); font-weight: 600; }

.pane-foot {
  border-top: 1px solid var(--line);
  padding: 8px 14px; font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 2px;
  white-space: nowrap; overflow: hidden;
}

/* ============================== 第三列：编辑区 ============================== */
.editor-pane { position: relative; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.doc { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.doc[hidden] { display: none; }

.doc-head {
  height: 50px; flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 22px;
  border-bottom: 1px solid var(--line-soft);
}
.crumb {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.crumb span { overflow: hidden; text-overflow: ellipsis; }
.crumb .sep { opacity: .45; }
.crumb .current { color: var(--text-2); font-weight: 500; }
.doc-tools { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.is-on { color: #f0a500; }
.icon-btn.is-on .ic { fill: #ffb400; stroke: #ffb400; }
.save-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); margin-right: 6px;
  padding: 4px 8px; border-radius: 20px; background: var(--bg-soft);
  transition: color .2s, background .2s;
}
.save-status .dot-ind { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .85; }
.save-status[data-state="saving"] .dot-ind { background: #f0a500; animation: pulse 1s infinite; }
.save-status[data-state="error"] { color: var(--danger); background: var(--danger-soft); }
.save-status[data-state="error"] .dot-ind { background: var(--danger); }
.save-status[data-state="idle"] .dot-ind { background: var(--muted); }
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

.doc-scroll { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.doc-inner { max-width: 780px; margin: 0 auto; padding: 30px 32px 80px; }

.note-title {
  width: 100%; border: 0; outline: 0; background: transparent;
  font-size: 27px; font-weight: 700; line-height: 1.35;
  letter-spacing: -.3px; padding: 0; color: var(--text);
}
.note-title::placeholder { color: var(--muted); opacity: .55; }
.meta-line { font-size: 12px; color: var(--muted); margin: 8px 0 18px; display: flex; align-items: center; }

.trash-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--danger-soft); color: var(--danger);
  padding: 10px 14px; border-radius: 9px; font-size: 13px;
  margin-bottom: 14px;
}
.trash-banner span { flex: 1; }
.trash-banner .text-btn { color: var(--danger); font-weight: 600; text-decoration: underline; }

.toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 5px 6px; margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  position: sticky; top: 0; z-index: 5;
}
.tb-group { display: flex; align-items: center; gap: 1px; padding: 0 4px; }
.tb-group + .tb-group { border-left: 1px solid var(--line); }
.tb-right { margin-left: auto; border-left: 0 !important; }
.tb {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center; color: var(--text-2);
}
.tb .ic { width: 17px; height: 17px; }
.tb:hover { background: var(--hover); color: var(--text); }
.tb.is-on { background: var(--accent-soft); color: var(--accent); }
.tb[disabled] { opacity: .4; cursor: default; }

.editor-wrap { position: relative; }
.editor {
  outline: none;
  min-height: 380px;
  font-size: 15.5px;
  line-height: 1.85;
  color: var(--text);
  word-break: break-word;
  padding-top: 6px;
}
.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted); opacity: .7;
  pointer-events: none;
}
.editor p { margin: 0 0 .75em; }
.editor h2 { font-size: 21px; line-height: 1.45; margin: 1.3em 0 .55em; font-weight: 700; }
.editor h3 { font-size: 17.5px; line-height: 1.5; margin: 1.2em 0 .5em; font-weight: 700; }
.editor h2:first-child, .editor h3:first-child { margin-top: .2em; }
.editor ul, .editor ol { margin: .3em 0 .9em; padding-left: 1.5em; }
.editor li { margin: .18em 0; }
.editor blockquote {
  margin: .8em 0; padding: 8px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
  color: var(--text-2);
}
.editor blockquote p:last-child { margin-bottom: 0; }
.editor pre {
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 12px 14px; border-radius: 9px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  white-space: pre-wrap;
}
.editor code { font-family: var(--mono); font-size: .92em; background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
.editor pre code { background: none; padding: 0; }
.editor a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.editor hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }

.note-image {
  margin: 14px 0; border-radius: 10px; overflow: hidden;
  background: var(--bg-soft);
  max-width: 100%; width: fit-content; line-height: 0; position: relative;
  box-shadow: 0 0 0 1px var(--line);
}
.note-image img { display: block; max-width: 100%; height: auto; margin: 0 auto; cursor: default; }
.note-image.is-selected { box-shadow: 0 0 0 2px var(--accent); }

.note-file {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft);
  max-width: 460px;
  user-select: none;
  transition: border-color .15s, box-shadow .15s;
}
.note-file:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.note-file.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.nf-icon {
  width: 36px; height: 36px; border-radius: 8px; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.nf-icon .ic { width: 19px; height: 19px; }
.nf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 1.3; }
.nf-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nf-size { font-size: 11.5px; color: var(--muted); }
.nf-btn {
  flex: 0 0 auto; font-size: 12.5px; color: var(--accent);
  text-decoration: none; padding: 5px 9px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--line);
}
.nf-btn:hover { background: var(--accent-soft); border-color: var(--accent); }

.editor[contenteditable="false"] { opacity: .92; }

.doc-foot {
  flex: 0 0 auto; border-top: 1px solid var(--line-soft);
  padding: 7px 22px; font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.doc-foot .grow { flex: 1; }
.kbd-hint kbd {
  font-family: var(--font); font-size: 10.5px;
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; margin: 0 1px;
  background: var(--bg-soft); color: var(--text-2);
}

/* ============================== 空状态 ============================== */
.empty-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; color: var(--text-2);
  overflow-y: auto;
}
.empty-art { color: var(--accent); width: 130px; margin-bottom: 14px; }
.empty-art svg { width: 100%; height: auto; display: block; }
.empty-state h2 { font-size: 19px; margin: 0 0 8px; color: var(--text); font-weight: 700; }
.empty-state p { font-size: 13px; color: var(--muted); max-width: 380px; line-height: 1.8; margin: 0 0 20px; }
.primary-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  padding: 9px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 3px 10px rgba(0, 168, 45, .25);
  transition: background .12s, transform .12s;
}
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.primary-btn .ic { width: 16px; height: 16px; }
.primary-btn[disabled] { opacity: .5; pointer-events: none; }
.recent-list { margin-top: 28px; width: 100%; max-width: 420px; text-align: left; }
.recent-list:empty { display: none; }
.recent-title { font-size: 11px; color: var(--muted); letter-spacing: .6px; margin-bottom: 8px; text-transform: uppercase; }
.recent-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-2);
}
.recent-item:hover { background: var(--hover-2); color: var(--text); }
.recent-item .ic { width: 15px; height: 15px; color: var(--muted); }
.recent-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item time { margin-left: auto; font-size: 11px; color: var(--muted); flex: 0 0 auto; }

/* ============================== 右键菜单 ============================== */
.menu {
  position: fixed; z-index: 100;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-md);
  padding: 5px; min-width: 178px;
}
.menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 9px; border-radius: 7px;
  font-size: 13px; color: var(--text-2); text-align: left;
}
.menu-item .ic { width: 15px; height: 15px; color: var(--muted); }
.menu-item:hover { background: var(--hover-2); color: var(--text); }
.menu-item:hover .ic { color: var(--text-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ic { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item[disabled] { opacity: .38; pointer-events: none; }
.menu-sep { height: 1px; background: var(--line-soft); margin: 4px 6px; }

/* ============================== 弹窗 & 提示 ============================== */
.modal-mask {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(18, 24, 20, .38);
  display: grid; place-items: center;
  backdrop-filter: blur(2px);
}
.modal-mask[hidden] { display: none; }
.modal {
  width: min(400px, calc(100vw - 40px));
  background: var(--bg); border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 22px 22px 16px;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.modal-desc { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.modal-input {
  width: 100%; height: 38px; padding: 0 11px; margin: 4px 0 18px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-soft); font-size: 14px; outline: none;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--bg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 6px; }
.text-btn { padding: 8px 12px; border-radius: 8px; font-size: 13.5px; color: var(--text-2); }
.text-btn:hover { background: var(--hover); }
.text-btn.danger { color: var(--danger); }
.text-btn.danger:hover { background: var(--danger-soft); }

.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #222825; color: #f2f5f3; font-size: 13px;
  padding: 9px 16px; border-radius: 22px;
  box-shadow: var(--shadow-md);
  animation: toastIn .18s ease-out;
  max-width: 70vw;
}
.toast.error { background: var(--danger); }
.toast.success { background: #16803c; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.mobile-only { display: none; }

/* ============================== 响应式 ============================== */
@media (max-width: 900px) {
  :root { --rail-w: 62px; --tree-w: 260px; }
  .rail-btn { width: 52px; font-size: 10px; }
  .doc-inner { padding: 22px 18px 70px; }
  .note-title { font-size: 23px; }
  .toolbar { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 700px) {
  .app { grid-template-columns: 56px minmax(0, 1fr); }
  .tree-pane {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 56px;
    width: 78vw; max-width: 320px;
    box-shadow: var(--shadow-lg);
    transform: translateX(calc(-100% - 64px));
    transition: transform .22s ease;
  }
  body.tree-open .tree-pane { transform: none; }
  .crumb .sep, .crumb span:not(.current) { display: none; }
  .rail-btn { width: 46px; font-size: 9.5px; }
  .rail-btn .ic { width: 19px; height: 19px; }
  .rail-new { width: 36px; height: 36px; }
  .mobile-only { display: grid; }
  .doc-head { padding: 0 10px 0 14px; }
  .save-status { display: none; }
  .doc-inner { padding: 18px 14px 70px; }
  .doc-foot { padding: 7px 14px; }
  .kbd-hint { display: none; }
}

@media print {
  .rail, .tree-pane, .doc-head, .toolbar, .doc-foot { display: none !important; }
  .app { display: block; height: auto; }
  .doc-scroll { overflow: visible; }
}

/* ============================== 登录 ============================== */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(0, 168, 45, .12), transparent 70%),
    var(--bg-soft);
}
.login-card {
  width: min(384px, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 32px 28px 22px;
  text-align: center;
  animation: pop .18s ease-out;
}
.login-brand { display: flex; justify-content: center; margin-bottom: 14px; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 15px; font-size: 26px; }
.login-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .3px; }
.login-sub { margin: 6px 0 22px; font-size: 13px; color: var(--muted); }
.login-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-btn {
  width: 100%; justify-content: center; height: 42px; margin-top: 4px;
  font-size: 14px; letter-spacing: 2px;
}
.login-error { margin: 0; color: var(--danger); font-size: 12.5px; line-height: 1.5; }
.login-foot { margin: 16px 0 0; font-size: 12px; color: var(--muted); }

/* 通用表单 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  height: 38px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-soft); color: var(--text);
  font-family: inherit; font-size: 13.5px; outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.field select { padding: 0 8px; }
.field input:focus, .field select:focus {
  border-color: var(--accent); background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { margin: 0; color: var(--danger); font-size: 12.5px; }
#pwd-mask .field { margin-bottom: 12px; }

/* 功能栏里的账号入口 */
.rail-user .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700; letter-spacing: 0;
}

/* ============================== 成员管理 ============================== */
.modal-lg {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  display: flex; flex-direction: column;
  padding: 18px 20px 16px;
}
.modal-lg-head { display: flex; align-items: center; justify-content: space-between; }
.modal-lg-head .modal-title { margin: 0; }
.close-x { font-size: 20px; line-height: 1; color: var(--text-2); }
.modal-hint { margin: 8px 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.users-list {
  border: 1px solid var(--line); border-radius: 10px;
  overflow-y: auto; max-height: 40vh; margin-bottom: 16px;
  background: var(--bg-soft);
}
.users-list:empty { display: none; }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
}
.user-row:last-child { border-bottom: none; }
.user-ava {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--bg); color: var(--text-2);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 700;
}
.user-main { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.user-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.badge {
  padding: 1px 7px; border-radius: 20px; font-size: 10.5px; font-weight: 600;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.badge.admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.user-acts { display: flex; gap: 2px; flex: 0 0 auto; }
.user-acts .text-btn { padding: 5px 7px; font-size: 12px; border-radius: 6px; }
.user-add { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-add .primary-btn { align-self: flex-start; }

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
  .modal-lg { max-height: 92vh; }
  .login-card { padding: 26px 20px 18px; }
}
