/* GoClipboard 个人笔记 — 素雅、克制的浅色/深色主题 */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --primary: #3b6ea5;
  --primary-soft: #e8f0f8;
  --danger: #b4453f;
  --ok: #3f7a52;
  --warn: #9a6b1f;
  /* Markdown 编辑器语法高亮配色（浅色主题）。 */
  --md-heading: #1f4f82;
  --md-link: #2f6db3;
  --md-code: #8a4b1f;
  --md-quote: #5f6b7a;
  --md-emphasis: #1f2430;
  --md-strong: #1f2430;
  --md-keyword: #7a3f9c;
  --md-string: #2f7d4f;
  --md-comment: #7a8794;
  --md-number: #9a5a1f;
  --md-type: #2f6f8f;
  --md-function: #2f5f9e;
  --md-invalid: #b4453f;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.10);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, 0.18);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161a;
  --panel: #1b1e24;
  --panel-2: #20242b;
  --text: #e6e8ec;
  --muted: #9aa3af;
  --line: #2b3038;
  --line-strong: #3a414b;
  --primary: #7aa7d4;
  --primary-soft: #223142;
  --danger: #e07a72;
  --ok: #7bbd91;
  --warn: #d6a95d;
  /* Markdown 编辑器语法高亮配色（深色主题）。 */
  --md-heading: #a8c7ea;
  --md-link: #8ab4f8;
  --md-code: #e0b080;
  --md-quote: #a0a9b4;
  --md-emphasis: #e6e8ec;
  --md-strong: #f2f4f7;
  --md-keyword: #c9a7e8;
  --md-string: #9ed3ac;
  --md-comment: #8b95a1;
  --md-number: #e6b98a;
  --md-type: #8fd0e0;
  --md-function: #a9c7f0;
  --md-invalid: #e07a72;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161a;
    --panel: #1b1e24;
    --panel-2: #20242b;
    --text: #e6e8ec;
    --muted: #9aa3af;
    --line: #2b3038;
    --line-strong: #3a414b;
    --primary: #7aa7d4;
    --primary-soft: #223142;
    --danger: #e07a72;
    --ok: #7bbd91;
    --warn: #d6a95d;
    /* Markdown 编辑器语法高亮配色（深色主题）。 */
    --md-heading: #a8c7ea;
    --md-link: #8ab4f8;
    --md-code: #e0b080;
    --md-quote: #a0a9b4;
    --md-emphasis: #e6e8ec;
    --md-strong: #f2f4f7;
    --md-keyword: #c9a7e8;
    --md-string: #9ed3ac;
    --md-comment: #8b95a1;
    --md-number: #e6b98a;
    --md-type: #8fd0e0;
    --md-function: #a9c7f0;
    --md-invalid: #e07a72;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
/* hidden 属性必须始终生效，避免被组件的 display 规则覆盖。 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
/* 原生复选框/单选框跟随主题主色，避免深色模式下保持系统亮色。 */
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- 图标按钮与通用控件 ---------- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.icon-btn.is-active { background: var(--primary-soft); color: var(--primary); }
.text-btn {
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 4px;
}
.text-btn:hover { color: var(--text); background: var(--panel-2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
/* 没有 .field 容器包裹的独立输入框（面板搜索、弹窗搜索）。 */
.text-input {
  padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text); outline: none;
}
.text-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.panel-head-actions .text-input { width: 220px; }
/* 有效期输入：数值框占据剩余宽度，单位选择器保持紧凑。 */
.duration-row { display: flex; gap: 8px; }
.duration-row input { width: auto; flex: 1; min-width: 0; }
.duration-row select { width: auto; flex: none; }
/* 自定义分享链接：/s/ 前缀与输入框拼成整体，前缀不参与输入。 */
.slug-row { display: flex; align-items: stretch; }
.slug-row .slug-prefix {
  display: flex; align-items: center; padding: 0 10px;
  border: 1px solid var(--line-strong); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--panel); color: var(--muted); font-size: 12px; white-space: nowrap;
}
.slug-row input {
  width: auto; flex: 1; min-width: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.form-error { color: var(--danger); font-size: 13px; margin: 4px 0 10px; }

/* ---------- 应用骨架 ---------- */
.app-body { overflow: hidden; }
.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.brand {
  font-weight: 650; letter-spacing: 0.2px; font-size: 15px;
  color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--primary); }
.sidebar-search { padding: 0 12px 8px; }
.sidebar-search input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); outline: none;
}
.sidebar-search input:focus { border-color: var(--primary); }
.sidebar-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 14px 6px;
}
.sidebar-tool-actions { display: flex; align-items: center; gap: 2px; }
.sidebar-tool-actions .icon-btn { min-width: 26px; height: 26px; padding: 0 5px; }
.batch-bar { display: flex; align-items: center; gap: 8px; padding: 0 14px 8px; }
.batch-count { flex: 1; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.text-btn.danger-text { color: var(--danger); }
.note-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 8px 10px; }
.note-item {
  display: block; padding: 9px 10px; margin: 2px 0;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent;
}
.note-item.selectable {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 8px;
}
.note-item.selectable .note-select { grid-row: 1 / span 3; align-self: center; margin: 0; accent-color: var(--primary); }
.note-item.selected { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.note-item:hover { background: var(--panel-2); }
.note-item.active { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.note-item-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item-preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.note-item-meta { color: var(--muted); font-size: 11px; margin-top: 3px; display: flex; gap: 8px; }
.note-empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 13px; }
.note-more {
  width: 100%; margin: 8px 0; padding: 8px; border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong); background: transparent;
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.note-more:hover { border-color: var(--primary); color: var(--primary); }
.note-more:disabled { cursor: default; opacity: 0.7; }

/* ---------- 滚动条 ---------- */
/* 纤细、无箭头、半透明圆角滑块；轨道透明，避免出现灰色块。 */
.note-list, .preview-pane, .panel-view, .modal, .cm-scroller {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}
.note-list:hover, .preview-pane:hover, .panel-view:hover,
.modal:hover, .cm-scroller:hover {
  scrollbar-color: color-mix(in srgb, var(--muted) 60%, transparent) transparent;
}
.note-list::-webkit-scrollbar, .preview-pane::-webkit-scrollbar,
.panel-view::-webkit-scrollbar, .modal::-webkit-scrollbar,
.cm-scroller::-webkit-scrollbar { width: 9px; height: 9px; }
.note-list::-webkit-scrollbar-track, .preview-pane::-webkit-scrollbar-track,
.panel-view::-webkit-scrollbar-track, .modal::-webkit-scrollbar-track,
.cm-scroller::-webkit-scrollbar-track { background: transparent; }
.note-list::-webkit-scrollbar-thumb, .preview-pane::-webkit-scrollbar-thumb,
.panel-view::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb,
.cm-scroller::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 32%, transparent);
  border: 2px solid transparent; border-radius: 999px;
  background-clip: padding-box;
}
.note-list::-webkit-scrollbar-thumb:hover, .preview-pane::-webkit-scrollbar-thumb:hover,
.panel-view::-webkit-scrollbar-thumb:hover, .modal::-webkit-scrollbar-thumb:hover,
.cm-scroller::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 55%, transparent);
  background-clip: padding-box;
}
.note-list::-webkit-scrollbar-button, .preview-pane::-webkit-scrollbar-button,
.panel-view::-webkit-scrollbar-button, .modal::-webkit-scrollbar-button,
.cm-scroller::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.note-list::-webkit-scrollbar-corner, .preview-pane::-webkit-scrollbar-corner,
.panel-view::-webkit-scrollbar-corner, .modal::-webkit-scrollbar-corner,
.cm-scroller::-webkit-scrollbar-corner { background: transparent; }
.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--line);
  font-size: 12px;
}
.sidebar-links { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-links a { display: inline-flex; align-items: center; gap: 6px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; padding: 4px 10px 10px; min-height: 0; overflow-y: auto; }
.settings-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; text-decoration: none;
}
.settings-nav a:hover { background: var(--panel-2); color: var(--text); }
.settings-nav a.active { background: var(--primary-soft); color: var(--primary); }
.settings-nav svg { flex: none; }
.sidebar-footer-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.sidebar-footer-tools .icon-btn { min-width: 26px; height: 26px; padding: 0 5px; }
.sidebar-footer a { color: var(--muted); white-space: nowrap; }
.sidebar-footer a:hover, .sidebar-footer a.active { color: var(--primary); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.title-input {
  flex: 1; min-width: 0; border: 1px solid transparent; background: transparent;
  font-size: 16px; font-weight: 600; padding: 5px 8px; border-radius: var(--radius-sm); outline: none;
}
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--primary); background: var(--panel); }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.sync-status { font-size: 12px; color: var(--muted); margin-right: 8px; white-space: nowrap; }
.sync-status[data-state="saving"] { color: var(--warn); }
.sync-status[data-state="offline"] { color: var(--danger); }

.workspace {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px; background: var(--line);
}
.editor-column {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; background: var(--panel);
}
/* 编辑器工具栏独立于系统顶栏，分组排列；空间不足时整组换行，避免工具被遮住。 */
.editor-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px; flex: none;
  padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.editor-tool-group { display: flex; align-items: center; gap: 2px; flex: none; }
.editor-tool-sep { width: 1px; height: 18px; margin: 0 6px; background: var(--line); flex: none; }
.editor-toolbar .icon-btn { min-width: 27px; height: 28px; padding: 0 4px; }
.editor-pane, .preview-pane { min-height: 0; background: var(--panel); overflow: hidden; }
.editor-column > .editor-pane { flex: 1; }
.preview-pane { overflow-y: auto; }
.editor-pane .cm-editor { height: 100%; }
.editor-pane .cm-scroller { overflow: auto; font-family: var(--mono); font-size: 14px; }
.editor-pane .cm-content { padding: 18px 20px; }
.preview-pane .md-body { padding: 18px 24px 80px; max-width: 900px; margin: 0 auto; }
.workspace.preview-off { grid-template-columns: minmax(0, 1fr) 0; }
.workspace.preview-off .preview-pane { display: none; }
/* 单栏布局：只保留编辑区，Markdown 在光标外就地渲染，不再占用第二栏。 */
.workspace.single-column {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.workspace.single-column .preview-pane { display: none; }
.workspace.single-column.focus-mode .editor-pane .cm-content { max-width: 860px; margin: 0 auto; }
.workspace.focus-mode { grid-template-columns: minmax(0, 1fr) 0; }
.workspace.focus-mode .preview-pane { display: none; }
.workspace.focus-mode .editor-pane .cm-content { max-width: 860px; margin: 0 auto; }

/* ---------- 单栏实时预览（CodeMirror 装饰） ---------- */
.cm-live-preview .cm-gutters { display: none; }
.cm-live-preview .cm-activeLine { background: transparent; }
.cm-live-preview .cm-content { padding: 22px 28px 80px; }
.cm-lp-heading, .cm-live-preview .cm-lp-heading span {
  font-weight: 700; color: var(--text); text-decoration: none;
}
.cm-lp-h1 { font-size: 1.7em; line-height: 1.35; border-bottom: 1px solid var(--line); padding-bottom: 0.2em; }
.cm-lp-h2 { font-size: 1.42em; line-height: 1.4; border-bottom: 1px solid var(--line); padding-bottom: 0.18em; }
.cm-lp-h3 { font-size: 1.2em; }
.cm-lp-h4, .cm-lp-h5, .cm-lp-h6 { font-size: 1.05em; }
.cm-lp-strong { font-weight: 700; }
.cm-lp-em { font-style: italic; }
.cm-lp-strike { text-decoration: line-through; color: var(--muted); }
.cm-lp-inline-code {
  font-family: var(--mono); font-size: 0.92em; padding: 1px 5px;
  border-radius: 4px; background: var(--panel-2); color: var(--text);
}
.cm-lp-link { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.cm-lp-quote {
  border-left: 3px solid var(--line-strong); padding-left: 12px;
  color: var(--muted); background: var(--panel-2);
}
.cm-lp-bullet { color: var(--muted); padding-right: 2px; }
.cm-lp-hr { color: var(--line); letter-spacing: 1px; }
.cm-lp-code-line { background: var(--panel-2); font-family: var(--mono); font-size: 13px; }
/* CodeMirror 注入的 .cm-line 会覆盖低优先级的 display 规则，这里提高选择器权重。 */
.cm-content .cm-lp-code-fence,
.cm-content .cm-lp-hidden-line { display: none; }
.cm-lp-code-first { border-radius: 7px 7px 0 0; padding-top: 6px; }
.cm-lp-code-last { border-radius: 0 0 7px 7px; padding-bottom: 6px; }
.cm-lp-image-wrap { display: inline-block; max-width: 100%; }
.cm-lp-image {
  max-width: 100%; max-height: 420px; border-radius: 7px;
  vertical-align: middle; cursor: zoom-in;
}
.cm-code-copy {
  float: right; display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin: 0 0 2px 8px; padding: 0;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--muted); cursor: pointer;
}
.cm-code-copy:hover { color: var(--text); background: var(--panel-2); }
.cm-code-copy.is-copied { color: var(--primary); border-color: var(--primary); }

/* ---------- Markdown 正文 ---------- */
.md-body { line-height: 1.75; word-wrap: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { line-height: 1.3; margin: 1.4em 0 0.6em; }
.md-body h1 { font-size: 1.7em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
.md-body h2 { font-size: 1.4em; border-bottom: 1px solid var(--line); padding-bottom: 0.25em; }
.md-body h3 { font-size: 1.18em; }
.md-body p { margin: 0.7em 0; }
.md-body ul, .md-body ol { padding-left: 1.5em; margin: 0.7em 0; }
.md-body blockquote {
  margin: 0.9em 0; padding: 0.2em 1em; color: var(--muted);
  border-left: 3px solid var(--line-strong); background: var(--panel-2);
}
.md-body code { font-family: var(--mono); font-size: 0.92em; background: var(--panel-2); padding: 0.15em 0.35em; border-radius: 4px; }
.md-body pre { position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 44px 12px 14px; overflow-x: auto; }
.md-body pre code { background: transparent; padding: 0; }
.code-copy {
  position: absolute; top: 7px; right: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--muted); opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.md-body pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--text); }
.code-copy.is-copied { opacity: 1; color: var(--primary); border-color: var(--primary); }
.md-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md-body th { background: var(--panel-2); }
.md-body hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md-body img.md-media, .md-body video.md-media {
  display: block; max-width: 100%; max-height: 70vh; margin: 12px 0;
  border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: zoom-in;
}
.md-body video.md-media { cursor: default; }

/* ---------- 附件卡片 ---------- */
.file-card {
  display: inline-flex; align-items: center; gap: 10px;
  max-width: 100%; margin: 8px 0; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text); text-decoration: none;
  vertical-align: middle;
}
.file-card:hover { border-color: var(--primary); text-decoration: none; }
.file-card-icon {
  flex: none; width: 36px; height: 36px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.file-card-icon svg { display: block; }
.file-card-body { display: flex; flex-direction: column; min-width: 0; }
.file-card-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-meta { font-size: 11.5px; color: var(--muted); }
.file-card.is-deleted .file-card-name { text-decoration: line-through; color: var(--muted); }
.file-card.is-deleted { border-style: dashed; }
.file-card.is-missing { border-style: dashed; opacity: 0.75; cursor: default; }
.file-card-badge {
  padding: 1px 6px; border-radius: 999px; font-size: 10.5px;
  background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger);
}

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 14, 0.86); padding: 32px;
}
.lightbox img, .lightbox video { max-width: 94vw; max-height: 90vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.12); color: #fff; cursor: pointer;
}

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 14, 0.45); padding: 20px;
}
.modal {
  width: min(560px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.modal.modal-wide { width: min(760px, 100%); }
/* 弹窗内的分组标题，例如当前笔记的分享列表。 */
.modal-section-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.3px;
}
/* 历史版本预览：限制高度并内部滚动，保证底部操作按钮始终可见。 */
.version-meta { margin: 0 0 10px; font-size: 12px; }
.version-preview {
  max-height: 54vh; overflow-y: auto; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--line);
}
.modal-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: 6px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }
.share-url-row { display: flex; gap: 8px; }
.share-url-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel-2); }
.qr-wrap { display: flex; justify-content: center; padding: 16px 0; }
.qr-wrap canvas, .qr-wrap img { background: #fff; padding: 10px; border-radius: 8px; }

/* ---------- 面板（回收站 / 分享 / 设置） ---------- */
.panel-view { flex: 1; min-height: 0; overflow-y: auto; background: var(--panel); padding: 22px 28px 80px; }
.panel-header { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.panel-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-batch-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.panel-batch-bar .batch-count { flex: 1; }
.row-check { width: 15px; height: 15px; accent-color: var(--primary); flex: none; }
/* 笔记列表右键菜单 */
.context-menu {
  position: fixed; z-index: 95; min-width: 150px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 9px; box-shadow: var(--shadow-lg);
}
.context-menu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font-size: 13px; cursor: pointer;
}
.context-menu button:hover { background: var(--panel-2); }
.context-menu .danger-text { color: var(--danger); }

/* 设置模式：复用主布局，左侧栏切换为管理导航，右侧显示对应页面。 */
body.settings-mode .sidebar-search,
body.settings-mode .sidebar-tools,
body.settings-mode #batchBar,
body.settings-mode #noteList,
body.settings-mode .sidebar-links { display: none; }
body.settings-mode .sidebar-footer { justify-content: flex-end; }
body.settings-mode .title-input,
body.settings-mode .topbar-actions { display: none; }
.settings-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.panel-section { margin-bottom: 28px; }
.panel-section h2 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin: 0 0 10px; }
.panel-empty { color: var(--muted); padding: 24px 0; }
/* 附件管理面板：筛选标签与标题栏内的搜索框。 */
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-tab {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 5px 13px; font-size: 12.5px; cursor: pointer;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.is-active {
  background: var(--primary-soft); color: var(--primary); border-color: transparent;
}
#fileSearch {
  padding: 6px 10px; min-width: 190px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 13px; outline: none;
}
#fileSearch:focus { border-color: var(--primary); }
/* 二维码始终使用白底，保证深色主题下也能被扫描。 */
.qr-wrap {
  display: flex; justify-content: center; width: max-content; max-width: 100%;
  margin: 14px auto; padding: 10px; border-radius: 10px; background: #fff;
}
.qr-wrap svg { display: block; width: 180px; height: 180px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 8px; background: var(--panel-2);
}
.row.selectable { cursor: pointer; }
.row.selectable:hover { border-color: var(--line-strong); }
.row.selected {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 25%, transparent);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 12px; }
/* 分享内容摘要最多两行，避免长正文撑开管理列表。 */
.share-preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin: 2px 0; color: var(--text);
}

/* ---------- 附件预览 ---------- */
.file-preview-meta { margin: 0 0 10px; font-size: 12px; }
.file-preview-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 180px; max-height: 65vh; overflow: auto;
}
.file-preview-media { max-width: 100%; max-height: 65vh; border-radius: 8px; }
audio.file-preview-media { width: 100%; }
.file-preview-frame {
  width: 100%; height: 65vh; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel);
}
.file-preview-text {
  width: 100%; max-height: 65vh; overflow: auto; margin: 0; padding: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.file-preview-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 系统设置表单：输入框与单位并排，宽度固定以免长地址撑破行布局。 */
.row-input {
  width: 180px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.row-input:focus { outline: none; border-color: var(--primary); }
.row-unit { color: var(--muted); font-size: 12px; align-self: center; }
.panel-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.pill.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; max-width: 90vw; padding: 9px 16px;
  background: var(--text); color: var(--panel);
  border-radius: 999px; font-size: 13px; box-shadow: var(--shadow-md);
}
.toast.is-error { background: var(--danger); color: #fff; }

/* ---------- 上传进度 ---------- */
.upload-status {
  position: fixed; right: 18px; bottom: 18px; z-index: 85;
  width: min(320px, calc(100vw - 36px)); padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: 12px;
}
.upload-status-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; margin-bottom: 4px;
}
.upload-row { margin-top: 8px; }
.upload-row-head { display: flex; align-items: center; gap: 8px; }
.upload-name {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.upload-percent { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-bar {
  height: 4px; margin-top: 5px; border-radius: 999px;
  background: var(--panel-2); overflow: hidden;
}
.upload-bar span {
  display: block; height: 100%; width: 0;
  background: var(--primary); transition: width 0.15s ease;
}
.upload-row.is-done .upload-percent { color: var(--ok); }
.upload-row.is-error .upload-percent { color: var(--danger); }
.upload-row.is-error .upload-bar span { background: var(--danger); }

/* ---------- 登录页 ---------- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--primary-soft), transparent 60%), var(--bg);
}
.auth-card {
  width: min(380px, 100%); padding: 28px 26px 24px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-weight: 700; letter-spacing: 0.5px;
}
.auth-brand h1 { font-size: 18px; margin: 0; }
.auth-brand p { margin: 0; font-size: 12.5px; }
.auth-foot { font-size: 12px; margin: 16px 0 0; text-align: center; }

/* ---------- 分享页 ---------- */
.share-body { background: var(--bg); min-height: 100vh; }
.share-shell { max-width: 820px; margin: 0 auto; padding: 32px 20px 80px; }
.share-card {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 26px 32px 40px;
}
.share-head { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.share-head h1 { margin: 0 0 4px; font-size: 20px; }
.share-head .muted { font-size: 12px; }
.share-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.share-invalid { text-align: center; padding: 70px 20px; }
.share-invalid h1 { font-size: 20px; margin-bottom: 6px; }
/* 分享页的主题切换按钮固定在右上角，不影响只读内容布局。 */
.share-theme-btn {
  position: fixed; top: 16px; right: 16px; z-index: 40;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; box-shadow: var(--shadow-sm);
}
.share-theme-btn:hover { color: var(--text); background: var(--panel-2); }
.share-theme-btn svg { display: block; }
.watermark-layer {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  display: flex; flex-wrap: wrap; align-content: flex-start;
  gap: 60px 80px; padding: 40px; overflow: hidden;
}
.watermark-layer span {
  color: var(--muted); opacity: 0.18; font-size: 15px;
  transform: rotate(-24deg); user-select: none; white-space: nowrap;
}
.share-file-hero {
  display: flex; align-items: center; gap: 16px; padding: 22px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2);
}
.share-file-hero .file-card-icon { width: 54px; height: 54px; }
.share-file-hero .file-card-name { font-size: 16px; white-space: normal; }
.share-file-hero .file-card-meta { font-size: 12.5px; margin-top: 2px; }

.fab { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    width: min(300px, 84vw); transform: translateX(-102%);
    transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 55; background: rgba(8,10,14,0.4);
  }
  .menu-btn { display: inline-flex; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .workspace .preview-pane { display: none; }
  /* 移动端快捷新建：无需先打开侧边栏 */
  .fab {
    display: inline-flex; position: fixed; z-index: 45;
    right: 18px; bottom: calc(20px + env(safe-area-inset-bottom));
    width: 52px; height: 52px; border-radius: 50%;
    align-items: center; justify-content: center;
    border: 1px solid var(--line); background: var(--primary); color: var(--panel);
    box-shadow: var(--shadow-md); cursor: pointer;
  }
  .fab:hover { filter: brightness(1.06); }
}
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 6px; }
  .title-input { font-size: 15px; }
  .sync-status { display: none; }
  .topbar-actions .icon-btn { min-width: 30px; height: 30px; }
  .panel-view { padding: 16px 14px 80px; }
  .share-card { padding: 20px 18px 30px; }
  .share-shell { padding: 16px 12px 60px; }
}

/* 拖拽上传高亮 */
.workspace.is-dragover { outline: 2px dashed var(--primary); outline-offset: -10px; }
.workspace.is-dragover .editor-pane::after {
  content: "松开以上传附件";
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  color: var(--primary); font-size: 15px; pointer-events: none;
}
.workspace { position: relative; }

/* 编辑锁提示：另一台设备正在编辑时悬浮在编辑区顶部。 */
.lock-banner {
  position: relative; flex: none; align-self: center;
  margin: 8px auto 0; width: max-content;
  z-index: 6; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 24px); padding: 6px 10px 6px 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow-md);
  color: var(--muted); font-size: 12.5px;
}
.lock-banner svg { flex: none; color: var(--warn); }
.lock-banner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock-banner .btn { flex: none; padding: 4px 10px; font-size: 12px; }
