/* ============================================================
   app.css — 应用外壳样式（浅色 · 极简 · 参照 ima 布局）
   Markdown 正文排版见 note.css
   ============================================================ */

:root {
    --c-bg: #ffffff;
    --c-side: #f7f8fa;
    --c-border: #ebedf0;
    --c-border-2: #e3e5e9;
    --c-text: #1f2329;
    --c-text-2: #545a63;
    --c-muted: #8f959e;
    --c-faint: #b4b9c1;
    --c-accent: #1a6dff;
    --c-accent-soft: rgba(26, 109, 255, .09);
    --c-hover: rgba(31, 35, 41, .05);
    --c-press: rgba(31, 35, 41, .09);
    --c-danger: #e5484d;
    --c-shadow: 0 1px 2px rgba(31, 35, 41, .04), 0 8px 28px rgba(31, 35, 41, .09);
    --c-shadow-sm: 0 1px 2px rgba(31, 35, 41, .05), 0 3px 12px rgba(31, 35, 41, .07);
    --sidebar-w: 256px;
    --topbar-h: 54px;
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --ease: cubic-bezier(.22, .68, .32, 1);
}

* { box-sizing: border-box; }

/* 关键：author 样式里的 display 会覆盖 UA 的 [hidden]，
   这里强制 hidden 永远生效，否则弹窗 / 工具栏会一直显示并挡住点击 */
[hidden] { display: none !important; }

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: rgba(26, 109, 255, .18); }

button { font-family: inherit; }

/* ---------- 滚动条 ---------- */
.scroll-y { overflow-y: auto; overscroll-behavior: contain; }
.scroll-y::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll-y::-webkit-scrollbar-track { background: transparent; }
.scroll-y::-webkit-scrollbar-thumb {
    background: rgba(31, 35, 41, .14);
    border: 2.5px solid transparent;
    background-clip: content-box;
    border-radius: 6px;
}
.scroll-y::-webkit-scrollbar-thumb:hover { background: rgba(31, 35, 41, .26); background-clip: content-box; }

/* ============================================================
   布局
   ============================================================ */
.app {
    display: flex;
    height: 100%;
    width: 100%;
}

.sidebar {
    flex: none;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--c-side);
    border-right: 1px solid var(--c-border);
    transition: margin-left .24s var(--ease), width .24s var(--ease);
}
.app.side-collapsed .sidebar {
    margin-left: calc(var(--sidebar-w) * -1);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--c-bg);
}

/* ============================================================
   侧栏
   ============================================================ */
.side-top {
    flex: none;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark {
    flex: none;
    width: 24px; height: 24px;
    border-radius: 7px;
    background: linear-gradient(135deg, #1a6dff, #4b8dff);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 7px rgba(26, 109, 255, .3);
}
.brand-name {
    font-size: 14px;
    font-weight: 640;
    letter-spacing: -.01em;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    color: var(--c-text-2);
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .13s, color .13s, opacity .13s;
}
.icon-btn:hover { background: var(--c-hover); color: var(--c-text); }
.icon-btn:active { background: var(--c-press); }
.icon-btn:disabled { opacity: .34; cursor: default; background: transparent; color: var(--c-text-2); }

/* ---------- 搜索 ---------- */
.side-search {
    flex: none;
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 12px 10px;
    padding: 0 10px;
    height: 34px;
    background: rgba(31, 35, 41, .045);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.side-search:focus-within {
    background: #fff;
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(26, 109, 255, .1);
}
.side-search .s-ico { flex: none; color: var(--c-muted); }
.side-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--c-text);
    background: transparent;
    border: 0;
    outline: none;
}
.side-search input::placeholder { color: var(--c-faint); }
.s-clear {
    flex: none;
    display: grid;
    place-items: center;
    width: 20px; height: 20px;
    color: var(--c-muted);
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
}
.s-clear:hover { background: var(--c-hover); color: var(--c-text); }

/* ---------- 工具按钮 ---------- */
.side-tools {
    flex: none;
    display: flex;
    gap: 6px;
    padding: 0 12px 10px;
}
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 520;
    color: var(--c-text-2);
    background: transparent;
    border: 1px solid var(--c-border-2);
    border-radius: var(--r-md);
    cursor: pointer;
    white-space: nowrap;
    transition: background .13s, border-color .13s, color .13s, box-shadow .13s;
}
.tool-btn:hover { background: #fff; color: var(--c-text); border-color: #d5d8dd; }
.tool-btn.primary {
    color: #fff;
    background: var(--c-accent);
    border-color: var(--c-accent);
    box-shadow: 0 1px 2px rgba(26, 109, 255, .22);
}
/* 只有侧栏那一行按钮需要撑满剩余宽度；空态是纵向 flex，撑开会被拉高 */
.side-tools .tool-btn.primary { flex: 1; }
.tool-btn.primary:hover { background: #0f5ce0; border-color: #0f5ce0; color: #fff; }
.side-tools .tool-btn:not(.primary) { width: 34px; padding: 0; }

/* ---------- 目录树 ---------- */
.side-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 8px 12px;
}
.side-body::-webkit-scrollbar { width: 9px; }
.side-body::-webkit-scrollbar-track { background: transparent; }
.side-body::-webkit-scrollbar-thumb {
    background: rgba(31, 35, 41, .14);
    border: 2.5px solid transparent;
    background-clip: content-box;
    border-radius: 6px;
}
.side-body::-webkit-scrollbar-thumb:hover { background: rgba(31, 35, 41, .26); background-clip: content-box; }

.tree { user-select: none; }
.node { margin: 1px 0; }

.row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--r-md);
    cursor: pointer;
    color: var(--c-text-2);
    transition: background .1s, color .1s;
}
.row:hover { background: var(--c-hover); color: var(--c-text); }
.row.active {
    background: var(--c-accent-soft);
    color: var(--c-accent);
    font-weight: 560;
}
.row.active .r-ico { color: var(--c-accent); }
.row.drop-target { background: rgba(26, 109, 255, .13); box-shadow: inset 0 0 0 1px var(--c-accent); }

.r-chev {
    flex: none;
    width: 16px; height: 16px;
    display: grid;
    place-items: center;
    color: var(--c-faint);
    border-radius: 4px;
    transition: transform .16s var(--ease), color .12s;
}
.r-chev:hover { color: var(--c-text); }
.node.open > .row > .r-chev { transform: rotate(90deg); }
.r-chev.leaf { visibility: hidden; }

.r-ico { flex: none; display: grid; place-items: center; color: var(--c-muted); }

.r-label {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.r-count {
    flex: none;
    font-size: 11px;
    color: var(--c-faint);
    font-variant-numeric: tabular-nums;
}
.row.active .r-count { color: rgba(26, 109, 255, .65); }

/* 公开笔记标识 */
.r-pub {
    flex: none;
    display: inline-grid;
    place-items: center;
    color: #1a9e5e;
    opacity: .8;
}
.row:hover .r-pub { opacity: 1; }

.children {
    margin-left: 13px;
    padding-left: 5px;
    border-left: 1px solid var(--c-border);
}
.node:not(.open) > .children { display: none; }

.tree-empty {
    padding: 26px 16px;
    text-align: center;
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--c-muted);
}

/* ---------- 搜索结果 ---------- */
.results { padding: 2px 0; }
.res-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 8px;
    font-size: 11.5px;
    color: var(--c-muted);
}
.res-head b { color: var(--c-text); font-weight: 600; }
.res-item {
    padding: 9px 10px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background .1s;
}
.res-item:hover { background: var(--c-hover); }
.res-item.active { background: var(--c-accent-soft); }
.res-t {
    font-size: 13px;
    font-weight: 560;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.res-s {
    margin-top: 3px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--c-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.res-s em { font-style: normal; background: #fff2ba; color: #7a5c00; border-radius: 2px; }
.res-p {
    margin-top: 4px;
    font-size: 11px;
    color: var(--c-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 侧栏底部 ---------- */
.side-foot {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-top: 1px solid var(--c-border);
}
.foot-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 9px;
    font-size: 12.5px;
    color: var(--c-text-2);
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .12s, color .12s;
}
.foot-btn:hover { background: var(--c-hover); color: var(--c-text); }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 132px;
    height: 30px;
    padding: 0 8px 0 4px;
    color: var(--c-text-2);
    border-radius: 15px;
    cursor: pointer;
    transition: background .12s;
}
.user-chip:hover { background: var(--c-hover); color: var(--c-text); }
/* 顶栏里的账号 chip 是 <button>，抹掉浏览器的默认外观 */
button.user-chip {
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    border: 0;
}
button.user-chip:hover { background: var(--c-hover); }
/* 顶栏右侧分隔线 */
.topbar-sep {
    flex: none;
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: var(--c-border-2);
}
.user-chip .avatar {
    flex: none;
    width: 22px; height: 22px;
    display: grid;
    place-items: center;
    font-size: 11.5px;
    font-weight: 640;
    color: #fff;
    background: linear-gradient(135deg, #5b8def, #1a6dff);
    border-radius: 50%;
}
.user-chip .uname {
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
    flex: none;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px 0 18px;
    border-bottom: 1px solid var(--c-border);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(160%) blur(8px);
}
.crumb {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--c-text-2);
    white-space: nowrap;
    overflow: hidden;
}
.crumb-empty { color: var(--c-muted); }
.crumb .c-seg { color: var(--c-muted); }
.crumb .c-seg.link { cursor: pointer; }
.crumb .c-seg.link:hover { color: var(--c-accent); }
.crumb .c-sep { color: var(--c-faint); font-size: 12px; }
.crumb .c-cur {
    color: var(--c-text);
    font-weight: 580;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right { flex: none; display: flex; align-items: center; gap: 6px; }

.save-state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: 4px;
    font-size: 12px;
    color: var(--c-muted);
    white-space: nowrap;
    transition: opacity .2s;
}
.save-state .dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
}
.save-state.saving { color: #b8860b; }
.save-state.saved { color: #4d9a5f; }
.save-state.error { color: var(--c-danger); }

.tbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-text-2);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}
.tbtn:hover { background: var(--c-hover); color: var(--c-text); }
.tbtn.on {
    color: var(--c-accent);
    background: var(--c-accent-soft);
    border-color: rgba(26, 109, 255, .18);
}
.tbtn:disabled { opacity: .4; cursor: default; background: transparent; color: var(--c-text-2); }

/* 公开开关：开启时用绿色，与「预览」的蓝色区分开 */
#btn-public.on {
    color: #0f7b4f;
    background: #e9f7f0;
    border-color: rgba(15, 123, 79, .2);
}
#btn-public.on:hover { background: #e0f2ea; color: #0b6240; }

/* ============================================================
   文档区
   ============================================================ */
.stage {
    flex: 1;
    min-height: 0;
    display: flex;
    position: relative;
}
.doc-scroll {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}
.doc-scroll::-webkit-scrollbar { width: 11px; }
.doc-scroll::-webkit-scrollbar-track { background: transparent; }
.doc-scroll::-webkit-scrollbar-thumb {
    background: rgba(31, 35, 41, .13);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: 7px;
}
.doc-scroll::-webkit-scrollbar-thumb:hover { background: rgba(31, 35, 41, .25); background-clip: content-box; }

.doc {
    max-width: 772px;
    margin: 0 auto;
    padding: 44px 40px 22vh;
}
.editor-wrap { position: relative; }

#editor {
    outline: none;
    min-height: 46vh;
    caret-color: var(--c-accent);
}
#editor:empty::before {
    content: attr(data-placeholder);
    color: var(--c-faint);
    pointer-events: none;
}
#editor[contenteditable="false"] { cursor: default; }
#editor[contenteditable="false"] a { cursor: pointer; }

/* 空块也能落光标（零宽占位，不写入正文） */
#editor :is(p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, div):empty::before {
    content: "\200B";
}

/* 编辑态微调：选中代码块/表格更清晰 */
#editor:focus .markdown-body,
#editor:focus { --md-border: #e6e8eb; }
#editor hr { cursor: default; }
#editor li.task input[type="checkbox"] { cursor: pointer; pointer-events: auto; }
#editor img { cursor: default; }
#editor img.selected,
#editor .md-selected { outline: 2px solid var(--c-accent); outline-offset: 2px; border-radius: 6px; }

/* 代码块 / 表格 / 图片 的编辑态轻提示 */
#editor pre:hover,
#editor table:hover,
#editor blockquote:hover { border-color: #e0e3e8; }

/* ---------- 大纲 ---------- */
.outline {
    flex: none;
    width: 256px;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.outline::-webkit-scrollbar { width: 0; }
.ol-t {
    font-size: 11px;
    font-weight: 620;
    letter-spacing: .09em;
    color: var(--c-faint);
    text-transform: uppercase;
    margin-bottom: 10px;
}
.ol-list { position: relative; border-left: 1px solid var(--c-border); }
.ol-item {
    display: block;
    text-decoration: none; /* 未登录只读页的大纲是 <a>，去掉浏览器默认下划线 */
    padding: 4px 0 4px 12px;
    margin-left: -1px;
    border-left: 2px solid transparent;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--c-muted);
    cursor: pointer;
    transition: color .12s, border-color .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ol-item:hover { color: var(--c-text); }
.ol-item.active { color: var(--c-accent); border-left-color: var(--c-accent); font-weight: 540; }
.ol-item.lv1 { padding-left: 12px; }
.ol-item.lv2 { padding-left: 12px; }
.ol-item.lv3 { padding-left: 22px; font-size: 12px; }
.ol-item.lv4, .ol-item.lv5, .ol-item.lv6 { padding-left: 32px; font-size: 12px; }

/* ---------- 空态 ---------- */
.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding-bottom: 8vh;
    color: var(--c-muted);
    pointer-events: none;
}
.empty-state .empty-t { font-size: 15px; font-weight: 560; color: var(--c-text-2); }
.empty-state .empty-s { font-size: 13px; }
.empty-state .tool-btn {
    flex: none;
    height: 34px;
    padding: 0 16px;
    margin-top: 12px;
    font-size: 13.5px;
    pointer-events: auto;
}
.app.has-doc .empty-state { display: none; }
.app:not(.has-doc) .doc { display: none; }
.app.has-doc .doc { display: block; }

/* ---------- 状态栏 ---------- */
.statusbar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 7px;
    height: 28px;
    padding: 0 18px;
    font-size: 11.5px;
    color: var(--c-faint);
    border-top: 1px solid var(--c-border);
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
}
.st-path { overflow: hidden; text-overflow: ellipsis; }
.st-sep { color: #dfe2e6; }

/* ============================================================
   悬浮格式工具栏
   ============================================================ */
.bubble {
    position: fixed;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: var(--c-shadow);
    animation: pop .12s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.97); } }
.bubble button {
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    font-size: 12.5px;
    color: var(--c-text-2);
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .1s, color .1s;
}
.bubble button:hover { background: var(--c-hover); color: var(--c-text); }
.bubble button.active { background: var(--c-accent-soft); color: var(--c-accent); }
.bubble button b, .bubble button i, .bubble button s { font-size: 13px; }
.bub-sep { width: 1px; height: 17px; margin: 0 4px; background: var(--c-border); }

/* ============================================================
   斜杠命令
   ============================================================ */
.slash {
    position: fixed;
    z-index: 62;
    width: 252px;
    max-height: 318px;
    overflow-y: auto;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    box-shadow: var(--c-shadow);
    animation: pop .13s var(--ease) both;
}
.slash-h {
    padding: 6px 9px 7px;
    font-size: 11px;
    font-weight: 620;
    letter-spacing: .07em;
    color: var(--c-faint);
    text-transform: uppercase;
}
.slash-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border-radius: var(--r-md);
    cursor: pointer;
}
.slash-item:hover, .slash-item.active { background: var(--c-hover); }
.slash-item .si-ico {
    flex: none;
    width: 28px; height: 28px;
    display: grid;
    place-items: center;
    font-size: 12px;
    color: var(--c-text-2);
    background: var(--c-side);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
}
.slash-item .si-t { font-size: 13px; color: var(--c-text); }
.slash-item .si-d { font-size: 11.5px; color: var(--c-muted); margin-top: 1px; }

/* ============================================================
   弹窗
   ============================================================ */
.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(24, 28, 33, .3);
    backdrop-filter: blur(2px);
    animation: fade .14s ease both;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
    width: 100%;
    max-width: 420px;
    padding: 24px 24px 18px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 48px rgba(24, 28, 33, .18);
    animation: rise .17s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.m-title { margin: 0 0 6px; font-size: 16.5px; font-weight: 620; letter-spacing: -.01em; }
.m-desc { margin: 0 0 18px; font-size: 13px; line-height: 1.7; color: var(--c-muted); }
.m-desc code {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 1px 5px;
    background: var(--c-side);
    border-radius: 4px;
    color: var(--c-text-2);
}
.m-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-side);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    outline: none;
    transition: background .14s, border-color .14s, box-shadow .14s;
}
.m-input:focus {
    background: #fff;
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(26, 109, 255, .12);
}
.m-list {
    max-height: 320px;
    overflow-y: auto;
    margin: -6px -6px 0;
    padding: 0 6px;
}
.m-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    cursor: pointer;
}
.m-item:hover { background: var(--c-hover); }
.m-item .mi-ico { flex: none; color: var(--c-muted); display: grid; place-items: center; width: 18px; }
.m-item .mi-t { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-item .mi-d { font-size: 11.5px; color: var(--c-faint); }
.m-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.m-btn {
    height: 34px;
    padding: 0 15px;
    font-size: 13.5px;
    font-weight: 520;
    color: var(--c-text-2);
    background: transparent;
    border: 1px solid var(--c-border-2);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.m-btn:hover { background: var(--c-hover); color: var(--c-text); }
.m-btn.primary {
    color: #fff;
    background: var(--c-accent);
    border-color: var(--c-accent);
}
.m-btn.primary:hover { background: #0f5ce0; border-color: #0f5ce0; }
.m-btn.danger { color: #fff; background: var(--c-danger); border-color: var(--c-danger); }
.m-btn.danger:hover { background: #cf3b40; border-color: #cf3b40; }
.m-drop {
    margin: 14px 0 0;
    padding: 22px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--c-muted);
    background: var(--c-side);
    border: 1.5px dashed var(--c-border-2);
    border-radius: var(--r-lg);
    transition: background .15s, border-color .15s, color .15s;
}
.m-drop.hot { background: var(--c-accent-soft); border-color: var(--c-accent); color: var(--c-accent); }
.m-check {
    display: flex; align-items: center; gap: 8px;
    margin-top: 14px; font-size: 13px; color: var(--c-text-2); cursor: pointer;
}

/* ============================================================
   右键菜单
   ============================================================ */
.ctx-menu {
    position: fixed;
    z-index: 90;
    min-width: 178px;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 10px;
    box-shadow: var(--c-shadow);
    animation: pop .11s var(--ease) both;
}
.ctx-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    font-size: 13px;
    color: var(--c-text-2);
    border-radius: var(--r-sm);
    cursor: pointer;
}
.ctx-item:hover { background: var(--c-hover); color: var(--c-text); }
.ctx-item.danger { color: var(--c-danger); }
.ctx-item.danger:hover { background: rgba(229, 72, 77, .08); color: var(--c-danger); }
.ctx-item.disabled { opacity: .38; pointer-events: none; }
.ctx-sep { height: 1px; margin: 5px 7px; background: var(--c-border); }
.ctx-item .ci-k { margin-left: auto; font-size: 11px; color: var(--c-faint); }

/* ============================================================
   Toast
   ============================================================ */
.toast-wrap {
    position: fixed;
    left: 50%;
    bottom: 30px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 460px;
    padding: 9px 15px;
    font-size: 13px;
    color: #f2f3f5;
    background: rgba(29, 33, 38, .93);
    border-radius: 9px;
    box-shadow: 0 6px 22px rgba(24, 28, 33, .2);
    animation: toastIn .2s var(--ease) both;
    backdrop-filter: blur(6px);
}
.toast.ok { background: rgba(35, 92, 58, .94); }
.toast.err { background: rgba(140, 36, 40, .94); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.toast.leaving { animation: toastOut .18s ease both; }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ============================================================
   拖拽上传遮罩
   ============================================================ */
.drop-veil {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: grid;
    place-items: center;
    background: rgba(26, 109, 255, .06);
    backdrop-filter: blur(1.5px);
}
.drop-veil .dv-in {
    padding: 26px 36px;
    font-size: 14px;
    font-weight: 560;
    color: var(--c-accent);
    background: #fff;
    border: 2px dashed var(--c-accent);
    border-radius: 14px;
    box-shadow: var(--c-shadow);
}

/* ============================================================
   加载态
   ============================================================ */
.loading-bar {
    position: fixed;
    top: 0; left: 0;
    height: 2px;
    width: 0;
    z-index: 120;
    background: var(--c-accent);
    box-shadow: 0 0 6px rgba(26, 109, 255, .5);
    transition: width .3s var(--ease), opacity .3s;
}
.loading-bar.done { opacity: 0; }

.shimmer {
    background: linear-gradient(90deg, rgba(31,35,41,.05) 25%, rgba(31,35,41,.09) 37%, rgba(31,35,41,.05) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease infinite;
    border-radius: 5px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ============================================================
   响应式
   ============================================================ */
.only-mobile { display: none; }
/* 侧栏收起后，顶栏左侧出现「展开侧栏」按钮 */
.only-collapsed { display: none; }
.app.side-collapsed .only-collapsed { display: grid; }
.scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(24, 28, 33, .32);
    animation: fade .16s ease both;
}

@media (max-width: 1180px) {
    .outline { display: none !important; }
}
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        z-index: 50;
        width: 286px;
        box-shadow: 0 0 40px rgba(24, 28, 33, .16);
        transform: translateX(-102%);
        transition: transform .24s var(--ease);
        margin-left: 0;
    }
    .app.drawer-open .sidebar { transform: translateX(0); }
    .app.side-collapsed .sidebar { margin-left: 0; }
    .only-mobile { display: grid; }
    #collapse-btn { display: none; }
    /* 手机端侧栏是抽屉，不存在「收起」状态 */
    .app.side-collapsed .only-collapsed { display: none; }
    .doc { padding: 30px 22px 22vh; }
    .statusbar { padding: 0 14px; }
}
@media (max-width: 560px) {
    .doc { padding: 24px 16px 24vh; }
    .topbar { padding: 0 8px 0 6px; }
    .tbtn span { display: none; }
    .tbtn { padding: 0 8px; }
    .save-state { display: none; }
    .user-chip .uname { display: none; }
    .user-chip { max-width: none; padding: 0 6px 0 4px; }
}

/* 打印 / 导出预览 */
@media print {
    .sidebar, .topbar, .statusbar, .outline, .bubble, .slash { display: none !important; }
    html, body { overflow: visible; height: auto; }
    .doc-scroll { overflow: visible; }
    .doc { padding: 0; max-width: none; }
}

/* ============================================================
   公开只读视图（未登录首页 · guest.php）
   ------------------------------------------------------------
   与登录后的应用外壳共用同一套布局，只是去掉了所有写操作入口。
   ============================================================ */

/* 目录树与搜索结果里的条目改成链接后，去掉下划线 */
.tree a.row { text-decoration: none; }
.results a.res-item { display: block; text-decoration: none; color: inherit; }

/* 「只读浏览」提示条 */
.guest-bar {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 12px 8px;
    padding: 7px 10px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--c-muted);
    background: rgba(31, 35, 41, .035);
    border-radius: var(--r-md);
}
.guest-bar svg { flex: none; color: var(--c-faint); }

/* 侧栏底部的登录入口 */
.foot-hint { flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.4; color: var(--c-faint); }
.side-foot a.foot-btn { text-decoration: none; color: var(--c-accent); flex: none; }
.side-foot a.foot-btn:hover { background: var(--c-accent-soft); color: var(--c-accent); }

/* 顶栏登录状态 */
.login-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    font-size: 12.5px;
    color: var(--c-muted);
    background: rgba(31, 35, 41, .045);
    border-radius: 999px;
    white-space: nowrap;
}
.login-state .dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: #c9ced6; }

/* 顶栏登录入口 */
a.tbtn.login-btn {
    text-decoration: none;
    color: var(--c-accent);
    background: var(--c-accent-soft);
    border-color: rgba(26, 109, 255, .18);
}
a.tbtn.login-btn:hover { background: rgba(26, 109, 255, .15); color: #0f5ce0; }

/* 正文区：标题 / 公开标识 / 页脚 */
.doc-head-line { margin-bottom: 12px; }
.g-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    font-size: 11.5px;
    color: #0f7b4f;
    background: #e9f7f0;
    border: 1px solid rgba(15, 123, 79, .2);
    border-radius: 999px;
}
.guest-title {
    margin: 0 0 20px;
    padding-bottom: .35em;
    font-size: 1.72em;
    font-weight: 680;
    letter-spacing: -.02em;
    line-height: 1.32;
    border-bottom: 1px solid var(--c-border);
}
.guest-foot {
    margin-top: 44px;
    padding-top: 16px;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--c-muted);
    border-top: 1px solid var(--c-border);
}
.guest-foot a { color: var(--c-accent); }

@media (max-width: 560px) {
    .login-state { display: none; }
    a.tbtn.login-btn { padding: 0 10px; }
    a.tbtn.login-btn span { display: inline; }
    .guest-bar { font-size: 11px; }
}
