/* 备忘录 · 仿 Apple Notes 风格 */
:root {
  --accent: #e0a800;
  --accent-strong: #d29b00;
  --select: #fce59a;
  --select-blur: #e6e6e8;
  --sidebar: #f2f2f4;
  --sidebar-sel: #dcdcdf;
  --sidebar-border: #d9d9dc;
  --text: #1d1d1f;
  --muted: #86868b;
  --sep: #e5e5e7;
  --danger: #ff3b30;
  --bg: #fff;
  --bg-elevated: #fff;
  --surface-2: #ededf0;
  --surface-hover: rgba(0, 0, 0, .04);
  --surface-hover-strong: rgba(0, 0, 0, .06);
  --surface-active: rgba(0, 0, 0, .05);
  --surface-active-strong: rgba(0, 0, 0, .09);
  --icon: #6e6e73;
  --icon-hover: #333;
  --meta-time: #3a3a3c;
  --placeholder: #c7c7cc;
  --input-border: #d2d2d7;
  --btn-secondary: #ececf0;
  --modal-bg: #fff;
  --modal-text: #555;
  --menu-bg: rgba(250, 250, 250, .97);
  --menu-border: rgba(0, 0, 0, .12);
  --menu-sep: rgba(0, 0, 0, .1);
  --menu-disabled: #b0b0b5;
  --trash-banner-bg: #fff6d6;
  --trash-banner-text: #8a6d00;
  --mark-bg: #ffe680;
  --guest-bg: linear-gradient(180deg, #f7f7f9, #ececf0);
  --auth-card-bg: rgba(255, 255, 255, .85);
  --folders-foot-border: #e0e0e3;
  --new-folder-color: #555;
  --todo-border: #c7c7cc;
  --todo-border-hover: #a1a1a6;
  --todo-bg: #fff;
  --accent-ring: rgba(224, 168, 0, .2);
  --accent-ring-strong: rgba(224, 168, 0, .25);
  --link: #0a66d6;
  --link-hover: #0550ae;
  --link-underline: rgba(10, 102, 214, .45);
  --code-bg: #f6f6f8;
  --code-border: #e2e2e6;
  --code-text: #24292f;
  /* 文字颜色预设（span.fc-*）：浅色模式用较深的色值保证对比度 */
  --fc-red: #d93025;
  --fc-orange: #d35400;
  --fc-green: #1e8e3e;
  --fc-blue: #1a73e8;
  --fc-purple: #8e44ad;
  --fc-gray: #8e8e93;
  /* 高亮（span.hl-*） */
  --hl-yellow: #fff1a8;
  --hl-green: #c8f0c4;
  --hl-pink: #ffd3e2;
  --hl-blue: #c7e0ff;
  --hl-purple: #e2d4ff;
  --hl-orange: #ffe0b5;
  --quote-bar: #d6d6db;
  --quote-text: #515154;
  --list-marker: #86868b;
  --table-border: #d9d9de;
  --table-head-bg: #f6f6f8;
  --table-focus: rgba(224, 168, 0, .55);
  --tag-bg: rgba(224, 168, 0, .14);
  --tag-text: #8a6500;
  --tag-bg-hover: rgba(224, 168, 0, .24);
  --font-mono: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --accent: #f0c14a;
  --accent-strong: #e8b020;
  --select: #5c4a12;
  --select-blur: #3a3a3c;
  --sidebar: #1c1c1e;
  --sidebar-sel: #2c2c2e;
  --sidebar-border: #38383a;
  --text: #f5f5f7;
  --muted: #98989d;
  --sep: #38383a;
  --danger: #ff453a;
  --bg: #000;
  --bg-elevated: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-hover: rgba(255, 255, 255, .06);
  --surface-hover-strong: rgba(255, 255, 255, .1);
  --surface-active: rgba(255, 255, 255, .08);
  --surface-active-strong: rgba(255, 255, 255, .12);
  --icon: #98989d;
  --icon-hover: #f5f5f7;
  --meta-time: #e5e5ea;
  --placeholder: #636366;
  --input-border: #48484a;
  --btn-secondary: #3a3a3c;
  --modal-bg: #2c2c2e;
  --modal-text: #aeaeb2;
  --menu-bg: rgba(44, 44, 46, .96);
  --menu-border: rgba(255, 255, 255, .12);
  --menu-sep: rgba(255, 255, 255, .1);
  --menu-disabled: #636366;
  --trash-banner-bg: #3a3000;
  --trash-banner-text: #f0c14a;
  --mark-bg: #5c4a12;
  --guest-bg: linear-gradient(180deg, #1c1c1e, #000);
  --auth-card-bg: rgba(44, 44, 46, .92);
  --folders-foot-border: #38383a;
  --new-folder-color: #aeaeb2;
  --todo-border: #636366;
  --todo-border-hover: #8e8e93;
  --todo-bg: #2c2c2e;
  --accent-ring: rgba(240, 193, 74, .25);
  --accent-ring-strong: rgba(240, 193, 74, .35);
  --link: #6cb4ff;
  --link-hover: #9ccbff;
  --link-underline: rgba(108, 180, 255, .5);
  --code-bg: #2a2a2e;
  --code-border: #424248;
  --code-text: #e6e6e9;
  /* 深色模式提亮，保证在黑底上可读 */
  --fc-red: #ff6b60;
  --fc-orange: #ff9f45;
  --fc-green: #4cd964;
  --fc-blue: #5eb0ff;
  --fc-purple: #c58af9;
  --fc-gray: #a1a1a6;
  /* 高亮在深色下用半透明色，文字保持浅色可读 */
  --hl-yellow: rgba(255, 214, 10, .34);
  --hl-green: rgba(52, 199, 89, .32);
  --hl-pink: rgba(255, 55, 135, .32);
  --hl-blue: rgba(10, 132, 255, .34);
  --hl-purple: rgba(175, 82, 222, .34);
  --hl-orange: rgba(255, 149, 0, .34);
  --quote-bar: #5a5a5f;
  --quote-text: #c7c7cc;
  --list-marker: #98989d;
  --table-border: #48484a;
  --table-head-bg: #232326;
  --table-focus: rgba(240, 193, 74, .6);
  --tag-bg: rgba(240, 193, 74, .16);
  --tag-text: #f0c14a;
  --tag-bg-hover: rgba(240, 193, 74, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 提示 ---------- */
.flash {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 100; padding: 8px 16px; border-radius: 10px;
  background: rgba(30,30,30,.86); color: #fff; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); transition: opacity .4s;
}
.flash-error { background: rgba(200,40,30,.92); }
.flash-hide { opacity: 0; }

/* ---------- 登录 ---------- */
body.is-guest { background: var(--guest-bg); }
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 340px; text-align: center; background: var(--auth-card-bg);
  border-radius: 18px; padding: 36px 32px 28px; box-shadow: 0 12px 40px rgba(0,0,0,.08);
}
.auth-card h1 { margin: 12px 0 4px; font-size: 22px; font-weight: 600; }
.auth-card .muted { color: var(--muted); margin: 0 0 22px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  height: 38px; border: 1px solid var(--input-border); border-radius: 9px; padding: 0 12px;
  font-size: 14px; outline: none; background: var(--bg-elevated); color: var(--text);
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.auth-form button {
  height: 38px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; margin-top: 6px;
}
.auth-form button:hover { background: var(--accent-strong); }
.auth-form button:disabled { opacity: .6; cursor: default; }
.auth-form .code-input { text-align: center; font-size: 22px; letter-spacing: 8px; height: 46px; font-variant-numeric: tabular-nums; }
.auth-form .code-input::placeholder { font-size: 14px; letter-spacing: normal; }
.auth-hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin: -10px 0 16px; word-break: break-all; }
.auth-form + .auth-hint { margin: 12px 0 0; font-size: 12px; }
.auth-hint strong { color: var(--text); font-weight: 600; }
.auth-resend { margin-top: 12px; }
.auth-resend .link-btn { font-size: 13px; }
.auth-resend .link-btn:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.auth-links { display: flex; justify-content: center; gap: 18px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-links a { color: var(--accent-strong); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ---------- 三栏布局 ---------- */
.notes-app { display: flex; height: 100vh; overflow: hidden; }
.pane-folders {
  width: 220px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; user-select: none;
}
.pane-list {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--sep); display: flex; flex-direction: column; background: var(--bg-elevated);
}
.pane-editor { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-elevated); }

/* ---------- 文件夹栏 ---------- */
.folders-head { padding: 18px 16px 6px; }
.folders-title { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.folder-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.folder-item {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 6px;
  cursor: default; font-size: 13px;
}
.folder-item:hover { background: var(--surface-hover); }
.folder-item.active { background: var(--sidebar-sel); }
.folder-item.drop-over { background: var(--select); box-shadow: inset 0 0 0 2px var(--accent); }
.folder-item .f-icon { color: var(--accent); flex-shrink: 0; display: flex; }
.folder-item .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .f-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.folder-item .f-more {
  display: none; border: 0; background: none; padding: 0 2px; color: var(--muted); cursor: pointer; line-height: 1;
}
.folder-item.user:hover .f-more { display: block; }
.folder-item.user:hover .f-count { display: none; }
.folder-item input.f-rename {
  flex: 1; min-width: 0; font: inherit; border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px;
  outline: none; background: var(--bg-elevated); color: var(--text);
}
.folder-sep { height: 10px; }
.folders-foot { padding: 8px; border-top: 1px solid var(--folders-foot-border); }
.new-folder-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; color: var(--new-folder-color);
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.new-folder-btn:hover { background: var(--surface-hover-strong); }
.theme-toggle-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; color: var(--new-folder-color);
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; margin-bottom: 2px;
}
.theme-toggle-btn:hover { background: var(--surface-hover-strong); }
.theme-toggle-btn .theme-icon { display: inline-flex; flex-shrink: 0; }
.theme-toggle-btn .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle-btn .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle-btn .theme-icon-sun { display: inline-flex; }
.user-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 2px; font-size: 12px; color: var(--muted); }
.user-name { display: inline-flex; align-items: center; gap: 4px; min-width: 0; margin-right: 8px; }
.user-name svg { flex-shrink: 0; }
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row form { flex-shrink: 0; }
.user-row form { margin: 0; }
.link-btn { border: 0; background: none; color: var(--accent-strong); cursor: pointer; padding: 0; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---------- 列表栏 ---------- */
.list-toolbar { display: flex; align-items: center; gap: 6px; padding: 12px 10px 6px 16px; min-height: 52px; }
.list-title-wrap { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.list-title { margin: 0; font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.icon-btn {
  border: 0; background: none; width: 32px; height: 30px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--icon); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-hover-strong); color: var(--icon-hover); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.on { color: var(--accent-strong); }
.search-box {
  margin: 0 12px 8px; display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 8px;
  padding: 0 8px; height: 30px; color: var(--muted);
}
.search-box input { flex: 1; border: 0; background: none; outline: none; font: inherit; font-size: 13px; color: var(--text); min-width: 0; }
.search-box input::placeholder { color: var(--muted); }
.search-box:focus-within { box-shadow: 0 0 0 3px var(--accent-ring-strong); background: var(--bg-elevated); }
.trash-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 16px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--sep); }
.note-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; outline: none; }
.group-head { font-size: 12px; font-weight: 700; color: var(--text); padding: 14px 10px 6px; position: sticky; top: 0; background: var(--bg-elevated); z-index: 1; }
.note-item { position: relative; padding: 9px 10px 9px 12px; border-radius: 8px; cursor: default; user-select: none; }
.note-item + .note-item::before { content: ""; position: absolute; left: 12px; right: 12px; top: 0; border-top: 1px solid var(--sep); }
.note-item.active, .note-item.active + .note-item { }
.note-item.active::before, .note-item.active + .note-item::before { border-color: transparent; }
.note-item.active { background: var(--select-blur); }
.note-list:focus-within .note-item.active, .note-list.focused .note-item.active { background: var(--select); }
.note-item .n-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.note-item .n-title .pin { color: var(--accent); flex-shrink: 0; display: inline-flex; }
.note-item .n-meta { font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.note-item .n-time { color: var(--meta-time); margin-right: 8px; }
.note-item .n-folder { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 3px; }
.note-item mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }
.note-item.dragging { opacity: .5; }
.list-empty { text-align: center; color: var(--muted); padding: 60px 16px; font-size: 13px; }

/* ---------- 编辑区 ---------- */
.editor-toolbar { display: flex; align-items: center; gap: 4px; padding: 11px 16px 6px; min-height: 52px; }
.tb-group { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tb-sep { width: 1px; height: 18px; background: var(--sep); margin: 0 6px; flex-shrink: 0; }
.fmt-btn .fmt-label { font-size: 14px; line-height: 1; font-family: Georgia, "Times New Roman", serif; }
.color-btn { position: relative; flex-direction: column; gap: 1px; }
.color-btn .color-glyph { font-size: 15px; font-weight: 600; line-height: 1; font-family: Georgia, "Times New Roman", serif; }
.color-btn .color-bar { width: 14px; height: 3px; border-radius: 2px; background: var(--fc, var(--text)); }
.color-btn.on { color: var(--icon); }
.hl-btn { position: relative; flex-direction: column; gap: 1px; }
.hl-btn .hl-glyph { display: block; }
.hl-btn .hl-bar { width: 14px; height: 3px; border-radius: 2px; background: var(--hl, var(--text)); opacity: .9; }
.hl-btn.on { color: var(--icon); }
.font-size-wrap {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 2px;
  background: var(--surface-hover); border-radius: 8px; padding: 2px 8px 2px 10px; height: 30px;
}
.font-size-label { font-size: 12px; color: var(--muted); white-space: nowrap; user-select: none; }
.font-size-select {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text); outline: none; cursor: pointer; padding: 0; max-width: 4.5em;
}
.font-size-select option { background: var(--bg-elevated); color: var(--text); }
.font-size-select:disabled { opacity: .35; cursor: default; }
.save-status { margin-left: auto; font-size: 12px; color: var(--muted); }
.text-btn { border: 0; background: var(--surface-active); border-radius: 7px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.text-btn:hover { background: var(--surface-active-strong); }
.text-btn.danger { color: var(--danger); }
.menu-anchor { position: relative; }
.editor-scroll { flex: 1; overflow-y: auto; position: relative; }
.editor-date { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0 14px; }
.trash-banner { margin: 6px auto 0; max-width: 720px; text-align: center; font-size: 12.5px; color: var(--trash-banner-text); background: var(--trash-banner-bg); border-radius: 8px; padding: 6px 10px; }
.note-title-input {
  display: block; max-width: 760px; width: 100%; margin: 0 auto; padding: 0 40px 8px;
  border: 0; outline: none; background: transparent; font: inherit;
  font-size: 26px; font-weight: 700; line-height: 1.35; color: var(--text);
  caret-color: var(--accent-strong);
}
.note-title-input::placeholder { color: var(--placeholder); font-weight: 700; }
.note-title-input:disabled, .note-title-input[readonly] { color: var(--text); opacity: 1; cursor: default; }
.editor {
  max-width: 760px; margin: 0 auto; padding: 0 40px 40vh; outline: none;
  font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; min-height: 200px; caret-color: var(--accent-strong);
}
.editor .ln { min-height: 1.65em; position: relative; }
/* 图片行 */
.editor .ln.img { margin: 8px 0; min-height: 0; white-space: normal; -webkit-user-select: none; user-select: none; }
.editor .ln.img img {
  display: block; max-width: 100%; height: auto; border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
}
.editor .ln.img img[data-w="25"] { width: 25%; }
.editor .ln.img img[data-w="50"] { width: 50%; }
.editor .ln.img img[data-w="75"] { width: 75%; }
.editor .ln.img img[data-w="100"] { width: 100%; }
.editor .ln.img.is-selected img {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 附件行 */
.editor .ln.file { margin: 6px 0; min-height: 0; white-space: normal; -webkit-user-select: none; user-select: none; }
.editor .ln.file .note-att {
  display: flex; align-items: center; gap: 10px; max-width: 100%;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-muted, rgba(127,127,127,.08));
  color: inherit; text-decoration: none; cursor: pointer;
  box-sizing: border-box;
}
.editor .ln.file .note-att::before {
  content: ''; flex: 0 0 18px; width: 18px; height: 22px;
  border: 1.5px solid currentColor; border-radius: 2px; opacity: .7;
  background:
    linear-gradient(135deg, transparent 50%, currentColor 50%) no-repeat top right / 8px 8px,
    linear-gradient(currentColor, currentColor) no-repeat 4px 10px / 10px 1.5px,
    linear-gradient(currentColor, currentColor) no-repeat 4px 14px / 10px 1.5px;
  box-shadow: inset -1px 1px 0 0 var(--bg-elevated, #fff);
}
.editor .ln.file .note-att-name {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 560;
}
.editor .ln.file .note-att::after {
  content: attr(data-meta);
  flex: 0 0 auto; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.editor .ln.file.is-selected .note-att {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.share-body .ln.file .note-att { cursor: pointer; }

.editor.is-empty .ln:first-child:not(.todo):not(.code):not(.ul):not(.ol):not(.quote):not(.tbl):not(.img):not(.file):not(.h1):not(.h2):not(.h3):not(.hr)::before {
  content: "正文"; color: var(--placeholder); position: absolute; pointer-events: none;
}
.editor .ln.todo { padding-left: 30px; }
.editor .ln.todo::before {
  content: ""; position: absolute; left: 2px; top: .22em; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--todo-border); background: var(--todo-bg); cursor: pointer; box-sizing: border-box;
}
.editor .ln.todo:hover::before { border-color: var(--todo-border-hover); }
.editor .ln.todo[data-done="1"]::before {
  border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.3 6.8 11 12 5.2' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.editor .ln.todo[data-done="1"] { color: var(--muted); }
.editor .ln.todo + .ln.todo { margin-top: 2px; }
.editor b, .editor strong { font-weight: 700; }
.editor i, .editor em { font-style: italic; }
.editor u { text-decoration: underline; }
.editor s, .editor strike, .editor del { text-decoration: line-through; }
.editor a {
  color: var(--link); text-decoration: underline; text-decoration-color: var(--link-underline);
  text-underline-offset: 2px; text-decoration-thickness: 1px; cursor: pointer;
}
.editor a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
.editor .ln.todo[data-done="1"] a { color: var(--muted); text-decoration-color: currentColor; }
.editor .fs-sm { font-size: 12px; }
.editor .fs-lg { font-size: 18px; }
.editor .fs-xl { font-size: 24px; line-height: 1.4; }
/* 标题行（Markdown # / ## / ### → .ln.h1|.h2|.h3） */
.editor .ln.h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin: .35em 0 .15em; }
.editor .ln.h2 { font-size: 22px; font-weight: 700; line-height: 1.35; margin: .3em 0 .1em; }
.editor .ln.h3 { font-size: 18px; font-weight: 650; line-height: 1.4; margin: .25em 0 .08em; }
.editor .ln.h1:first-child, .editor .ln.h2:first-child, .editor .ln.h3:first-child { margin-top: 0; }
/* 分隔线 --- */
.editor .ln.hr { min-height: 1.2em; margin: .55em 0; }
.editor .ln.hr::after {
  content: ""; display: block; border-top: 1px solid var(--sep); position: absolute;
  left: 0; right: 0; top: 50%; pointer-events: none;
}
/* 行内代码 */
.editor code {
  font-family: var(--font-mono); font-size: .92em; background: var(--code-bg);
  border: 1px solid var(--code-border); border-radius: 4px; padding: .05em .35em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.editor .ln.code code { background: none; border: 0; padding: 0; font-size: inherit; }
.editor[contenteditable="false"] { cursor: default; }
/* 文字颜色（存储为 span.fc-*；swatch 用于工具栏/菜单色块） */
.fc-red { --fc: var(--fc-red); }
.fc-orange { --fc: var(--fc-orange); }
.fc-green { --fc: var(--fc-green); }
.fc-blue { --fc: var(--fc-blue); }
.fc-purple { --fc: var(--fc-purple); }
.fc-gray { --fc: var(--fc-gray); }
.editor span[class^="fc-"] { color: var(--fc); }
/* 彩色文字里的链接仍跟随文字颜色，用下划线区分 */
.editor span[class^="fc-"] a, .editor a span[class^="fc-"] { color: var(--fc); text-decoration-color: currentColor; }
.editor .ln.todo[data-done="1"] span[class^="fc-"] { color: var(--muted); }
/* 高亮（荧光笔） */
.hl-yellow { --hl: var(--hl-yellow); }
.hl-green { --hl: var(--hl-green); }
.hl-pink { --hl: var(--hl-pink); }
.hl-blue { --hl: var(--hl-blue); }
.hl-purple { --hl: var(--hl-purple); }
.hl-orange { --hl: var(--hl-orange); }
.editor span[class^="hl-"] { background: var(--hl); border-radius: 3px; padding: 0 1px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.ctx-menu .mi .swatch[class*="hl-"] { background: var(--hl); border-radius: 3px; }
/* 引用：连续的 .ln.quote 行左侧一条竖线 */
.editor .ln.quote { border-left: 3px solid var(--quote-bar); padding-left: 12px; color: var(--quote-text); }
.editor .ln:not(.quote) + .ln.quote, .editor .ln.quote:first-child { margin-top: 4px; padding-top: 2px; }
.editor .ln.quote:has(+ .ln:not(.quote)), .editor .ln.quote:last-child { margin-bottom: 4px; padding-bottom: 2px; }
/* 列表：连续的 .ln.ul / .ln.ol；编号用 CSS 计数器，非 ol 行之后重新从 1 开始 */
.editor .ln.ul, .editor .ln.ol { padding-left: 28px; }
.editor .ln.ul::before {
  content: "•"; position: absolute; left: 9px; top: 0; color: var(--list-marker); font-weight: 700; pointer-events: none;
}
.editor .ln.ol:first-child, .editor .ln:not(.ol) + .ln.ol { counter-reset: memo-ol; }
.editor .ln.ol { counter-increment: memo-ol; }
.editor .ln.ol::before {
  content: counter(memo-ol) "."; position: absolute; left: 0; width: 22px; text-align: right; top: 0;
  color: var(--list-marker); font-variant-numeric: tabular-nums; pointer-events: none;
}
/* 表格：外层不可编辑，单元格可编辑 */
.editor .ln.tbl { margin: 8px 0; overflow-x: auto; white-space: normal; }
.editor .ln.tbl table { border-collapse: collapse; width: 100%; table-layout: fixed; min-width: 240px; }
.editor .ln.tbl td {
  border: 1px solid var(--table-border); padding: 5px 8px; vertical-align: top; min-width: 48px;
  white-space: pre-wrap; word-break: break-word; outline: none; line-height: 1.5;
}
.editor .ln.tbl tr:first-child td { background: var(--table-head-bg); }
.editor .ln.tbl td:focus { box-shadow: inset 0 0 0 2px var(--table-focus); }
/* 代码块：连续的 .ln.code 行拼成一个块（首行上圆角，末行下圆角） */
.editor .ln.code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 1.6em;
  color: var(--code-text);
  background: var(--code-bg);
  border-left: 1px solid var(--code-border);
  border-right: 1px solid var(--code-border);
  padding: 0 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
  -moz-tab-size: 4;
  font-variant-ligatures: none;
}
.editor .ln.code:first-child,
.editor .ln:not(.code) + .ln.code {
  border-top: 1px solid var(--code-border);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  padding-top: 8px;
  margin-top: 6px;
}
.editor .ln.code:last-child,
.editor .ln.code:has(+ .ln:not(.code)) {
  border-bottom: 1px solid var(--code-border);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  padding-bottom: 8px;
  margin-bottom: 6px;
}
.editor .ln.code::selection, .editor .ln.code *::selection { background: var(--select); }
.editor-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 15px; pointer-events: none; }
.editor-empty p { margin: 0; }

/* ---------- 菜单 / 弹窗 / toast ---------- */
.ctx-menu {
  /* above sheet-drawer(61), modal/backdrop(80), toast/cmd(90); below flash(100) only if needed — menus must win overlays */
  position: fixed; z-index: 110; min-width: 190px; background: var(--menu-bg); border: 1px solid var(--menu-border);
  border-radius: 9px; box-shadow: 0 10px 32px rgba(0,0,0,.18); padding: 5px; font-size: 13px; backdrop-filter: blur(16px);
  color: var(--text);
}
.ctx-menu .mi { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 5px; cursor: default; white-space: nowrap; }
.ctx-menu .mi:hover:not(.disabled) { background: var(--accent); color: #fff; }
.ctx-menu .mi.disabled { color: var(--menu-disabled); }
.ctx-menu .mi.danger:not(:hover) { color: var(--danger); }
.ctx-menu .mi .check { width: 12px; display: inline-block; }
.ctx-menu .msep { height: 1px; background: var(--menu-sep); margin: 4px 6px; }
.ctx-menu .mi .mlabel { flex: 1; }
.ctx-menu .mi .swatch {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: var(--fc);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.ctx-menu .mi .swatch-none { background: var(--text); }
.ctx-menu .mi:hover:not(.disabled) .swatch { box-shadow: 0 0 0 1.5px #fff; }
.ctx-menu .mi.disabled .swatch { opacity: .4; }
.ctx-menu .mi.has-sub { position: relative; }
.ctx-menu .mi .sub-arrow { margin-left: 12px; opacity: .7; }
.ctx-menu .ctx-sub {
  display: none; position: absolute; left: calc(100% + 4px); top: -6px; min-width: 150px;
  background: var(--menu-bg); border: 1px solid var(--menu-border); border-radius: 9px;
  box-shadow: 0 10px 32px rgba(0,0,0,.18); padding: 5px; color: var(--text); z-index: 1;
}
.ctx-menu .mi.has-sub.open:not(.disabled) { background: var(--accent); color: #fff; }
.ctx-menu .mi.has-sub.open:not(.disabled) > .ctx-sub { display: block; }
.ctx-menu .mi.has-sub.flip > .ctx-sub { left: auto; right: calc(100% + 4px); }
.ctx-menu .mi.has-sub.up > .ctx-sub { top: auto; bottom: -6px; }
.ctx-menu .mhead { padding: 4px 10px 2px; font-size: 11px; color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 130; display: flex; align-items: center; justify-content: center; }
.modal { width: 300px; background: var(--modal-bg); border-radius: 14px; padding: 20px 20px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); text-align: center; color: var(--text); }
.modal-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.modal-text { font-size: 12.5px; color: var(--modal-text); line-height: 1.5; white-space: pre-line; }
.modal input {
  width: 100%; margin-top: 12px; height: 30px; border: 1px solid var(--input-border); border-radius: 6px;
  padding: 0 8px; font: inherit; outline: none; background: var(--bg-elevated); color: var(--text);
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions button { flex: 1; height: 30px; border-radius: 7px; border: 0; background: var(--btn-secondary); color: var(--text); cursor: pointer; }
.modal-actions button.primary { background: var(--accent); color: #fff; font-weight: 600; }
.modal-actions button.primary.danger { background: var(--danger); }
.modal-actions button.danger-text { color: var(--danger); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(30,30,30,.88); color: #fff; padding: 8px 16px; border-radius: 10px; font-size: 13px; z-index: 90; }

.mobile-only { display: none; }

/* ---------- 窄屏：单栏切换 ---------- */
@media (max-width: 1000px) {
  .pane-folders { width: 190px; }
  .pane-list { width: 260px; }
  .editor { padding-left: 24px; padding-right: 24px; }
  .note-title-input { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  .pane-folders, .pane-list, .pane-editor { width: 100%; flex: 1; border: 0; }
  .notes-app .pane-folders, .notes-app .pane-list, .notes-app .pane-editor { display: none; }
  .notes-app.show-folders .pane-folders,
  .notes-app.show-list .pane-list,
  .notes-app.show-editor .pane-editor,
  .notes-app.show-daily .pane-daily { display: flex; }
  .editor { padding: 0 18px 40vh; }
  .note-title-input { padding-left: 18px; padding-right: 18px; }
}

/* ================= Phase 2：备忘录锁 ================= */
.lock-btn .lock-open { display: none; }
.lock-btn.is-open .lock-closed { display: none; }
.lock-btn.is-open .lock-open { display: block; }
.note-item .n-title .n-title-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.note-item .n-title .lock-ico { color: var(--muted); flex-shrink: 0; display: inline-flex; margin-left: auto; padding-left: 4px; }
.note-item .n-title .lock-ico.open { color: var(--accent-strong); }
.lock-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 70px 20px 40px; color: var(--muted); text-align: center; }
.lock-panel[hidden] { display: none; }
.lock-panel svg { color: var(--icon); margin-bottom: 4px; }
.lock-panel-title { font-size: 17px; font-weight: 700; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock-panel-text { margin: 0 0 10px; font-size: 13px; }
.lock-panel-btn { border: 0; border-radius: 8px; padding: 7px 18px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.lock-panel-btn:hover { background: var(--accent-strong); }
.modal-fields { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.modal-fields[hidden] { display: none; }
.modal-fields input { margin-top: 0 !important; }
.modal-error { margin-top: 10px; font-size: 12.5px; color: var(--danger); line-height: 1.4; }
.modal-error[hidden] { display: none; }
.modal-actions button:disabled { opacity: .6; cursor: default; }

/* ================= Phase 2：标签 ================= */
.tags-head { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; padding: 14px 10px 6px; }
.tag-grid { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 10px; }
.tag-pill {
  max-width: 100%; border: 0; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12px;
  background: var(--surface-2); color: var(--text); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-pill:hover { background: var(--surface-hover-strong); }
.tag-pill.active { background: var(--accent); color: #fff; }
.tag-pill.drop-over { box-shadow: inset 0 0 0 2px var(--accent); background: var(--select); }
.note-item .n-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 3px; font-size: 11.5px; color: var(--tag-text); overflow: hidden; max-height: 1.5em; }
.note-item .n-tags span { white-space: nowrap; }
.note-list:focus-within .note-item.active .n-tags, .note-list.focused .note-item.active .n-tags { color: var(--text); }
.note-tags { max-width: 760px; margin: -4px auto 10px; padding: 0 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.note-tags[hidden] { display: none; }
.tag-chips { display: contents; }
.tag-chip { display: inline-flex; align-items: center; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text); font-size: 12.5px; line-height: 1; }
.tag-chip:hover { background: var(--tag-bg-hover); }
.tag-chip button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; padding: 4px 0 4px 10px; }
.tag-chip .tag-chip-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-tags.readonly .tag-chip .tag-chip-name { padding-right: 10px; }
.tag-chip .tag-chip-x { padding: 4px 8px 4px 5px; opacity: .6; font-size: 14px; }
.tag-chip .tag-chip-x:hover { opacity: 1; }
.tag-input {
  border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 12.5px;
  width: 100px; padding: 4px 6px; border-radius: 999px;
}
.tag-input::placeholder { color: var(--placeholder); }
.tag-input:focus { background: var(--surface-hover); width: 150px; }
.tag-suggest {
  position: fixed; z-index: 90; min-width: 150px; max-width: 280px; padding: 4px;
  background: var(--menu-bg); border: 1px solid var(--menu-border); border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); font-size: 13px; color: var(--text);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.tag-suggest[hidden] { display: none; }
.tag-suggest .ts-item { padding: 5px 10px; border-radius: 5px; cursor: default; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-suggest .ts-item:hover, .tag-suggest .ts-item.active { background: var(--accent); color: #fff; }
.tag-suggest .ts-new { font-size: 11px; opacity: .75; margin-right: 6px; }
@media (max-width: 1000px) { .note-tags { padding: 0 24px; } }
@media (max-width: 760px) { .note-tags { padding: 0 18px; } }

/* ---------- Phase 3：嵌套文件夹 / 拖拽排序 / 排序方式 / 搜索命中 ---------- */
.folder-item .f-toggle, .folder-item .f-toggle-sp {
  width: 16px; height: 20px; flex-shrink: 0; margin-right: -4px;
}
.folder-item .f-toggle {
  border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 4px;
}
.folder-item .f-toggle:hover { color: var(--text); background: var(--surface-hover-strong); }
.folder-item .f-toggle svg { transition: transform .15s ease; }
.folder-item .f-toggle.open svg { transform: rotate(90deg); }
.folder-item { position: relative; }
.folder-item.dragging { opacity: .45; }
.folder-item.drop-before::after, .folder-item.drop-after::after,
.note-item.drop-before::after, .note-item.drop-after::after {
  content: ""; position: absolute; left: 8px; right: 8px; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; z-index: 2;
}
.folder-item.drop-before::after, .note-item.drop-before::after { top: -1px; }
.folder-item.drop-after::after, .note-item.drop-after::after { bottom: -1px; }
#btnSort.on { color: var(--accent-strong); }
#btnSort[hidden] { display: none; }
.note-item .n-tags mark { background: var(--mark-bg); color: inherit; border-radius: 2px; }
::highlight(search-hit) { background-color: var(--mark-bg); color: inherit; }
.ctx-menu .ctx-sub { max-height: calc(100vh - 24px); overflow-y: auto; }

/* ================= 版本历史 ================= */
.rev-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 24px; }
.rev-backdrop[hidden] { display: none; }
.rev-panel {
  width: min(980px, 100%); height: min(680px, 100%); display: flex; flex-direction: column; overflow: hidden;
  background: var(--modal-bg); color: var(--text); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
.rev-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--sep); }
.rev-heading-wrap { flex: 1; min-width: 0; }
.rev-heading { font-weight: 700; font-size: 15px; }
.rev-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rev-body { flex: 1; min-height: 0; display: flex; }
.rev-timeline { width: 300px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid var(--sep); padding: 4px 8px 12px; outline: none; }
.rev-loading { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 12px; line-height: 1.6; }
.rev-group { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 12px 8px 4px 28px; }
.rev-item { position: relative; display: flex; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 8px; cursor: pointer; }
.rev-item:hover { background: var(--select-blur); }
.rev-item.active { background: var(--select); }
.rev-item::before { content: ""; position: absolute; left: 13px; top: 0; bottom: 0; width: 2px; background: var(--sep); }
.rev-group + .rev-item::before { top: 14px; }
.rev-item:last-child::before { bottom: calc(100% - 14px); }
.rev-dot { position: relative; z-index: 1; flex-shrink: 0; width: 12px; height: 12px; margin-top: 3px; border-radius: 50%; background: var(--modal-bg); border: 2px solid var(--muted); }
.rev-dot.src-manual { border-color: var(--accent); background: var(--accent); }
.rev-dot.src-restore { border-color: #5ac8fa; }
.rev-item-main { flex: 1; min-width: 0; }
.rev-item-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rev-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rev-badge { font-size: 10.5px; line-height: 16px; padding: 0 6px; border-radius: 8px; background: var(--btn-secondary); color: var(--muted); white-space: nowrap; }
.rev-badge.src-manual { color: var(--accent-strong); }
.rev-badge.src-restore { color: #2a9fd6; }
.rev-badge.cur { background: var(--accent); color: #fff; }
.rev-item-title { font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rev-item-snippet { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rev-item-ago { font-size: 11px; color: var(--muted); margin-top: 1px; }
.rev-preview-wrap { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 32px 28px; background: var(--bg-elevated); }
.rev-preview-meta { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 12px; }
.rev-preview-title { font-size: 22px; font-weight: 700; line-height: 1.35; margin-bottom: 6px; word-break: break-word; }
.rev-preview.editor { padding: 0; min-height: 0; cursor: default; }
.rev-preview .ln.todo::before { cursor: default; }
.rev-locked { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 80px 20px; color: var(--muted); text-align: center; font-size: 13px; }
.rev-locked[hidden], .rev-empty[hidden], .rev-preview[hidden], .rev-preview-title[hidden], .rev-preview-meta[hidden] { display: none; }
.rev-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 80px 20px; }
.rev-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--sep); }
.rev-hint { flex: 1; font-size: 12px; color: var(--muted); }
.rev-btn { height: 30px; padding: 0 14px; border: 0; border-radius: 7px; background: var(--btn-secondary); color: var(--text); cursor: pointer; font-size: 13px; }
.rev-btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.rev-btn:disabled { opacity: .5; cursor: default; }
@media (max-width: 760px) {
  .rev-backdrop { padding: 0; }
  .rev-panel { width: 100%; height: 100%; border-radius: 0; }
  .rev-body { flex-direction: column; }
  .rev-timeline { width: auto; max-height: 38%; border-right: 0; border-bottom: 1px solid var(--sep); }
  .rev-preview-wrap { padding: 12px 18px 24px; }
}


/* ================= Spotlight 快速搜索 ================= */
.cmd-palette-backdrop {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 24px;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
html[data-theme="dark"] .cmd-palette-backdrop { background: rgba(0, 0, 0, .55); }
.cmd-palette {
  width: min(560px, 100%); max-height: min(520px, 76vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-elevated); color: var(--text);
  border-radius: 14px; border: 1px solid var(--sep);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28), 0 0 0 0.5px rgba(0,0,0,.06);
}
html[data-theme="dark"] .cmd-palette {
  background: #2c2c2e; border-color: rgba(255,255,255,.1);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .65), 0 0 0 0.5px rgba(255,255,255,.08);
}
.cmd-palette-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--sep);
}
.cmd-palette-ico { flex-shrink: 0; color: var(--muted); }
.cmd-palette-input-wrap input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 16px; color: var(--text); padding: 0;
}
.cmd-palette-input-wrap input::placeholder { color: var(--placeholder); }
.cmd-palette-input-wrap input::-webkit-search-cancel-button { -webkit-appearance: none; }
.cmd-palette-esc {
  flex-shrink: 0; font: inherit; font-size: 11px; line-height: 1;
  padding: 4px 6px; border-radius: 5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--sep);
}
.cmd-palette-results { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.cmd-palette-empty, .cmd-palette-hint {
  color: var(--muted); font-size: 13px; text-align: center; padding: 36px 16px; line-height: 1.5;
}
.cmd-palette-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.cmd-palette-item:hover { background: var(--surface-hover); }
.cmd-palette-item.active { background: var(--select); }
.cmd-palette-item .cp-title {
  font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.cmd-palette-item .cp-title .pin { color: var(--accent-strong); display: inline-flex; }
.cmd-palette-item .cp-title .lock-ico { color: var(--muted); display: inline-flex; }
.cmd-palette-item .cp-snippet {
  font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmd-palette-item .cp-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
}
.cmd-palette-item .cp-folder { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.cmd-palette-item .cp-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cmd-palette-item .cp-tags span {
  background: var(--surface-2); border-radius: 6px; padding: 1px 6px; font-size: 11px;
}
.cmd-palette-item mark { background: var(--mark-bg); color: inherit; border-radius: 2px; padding: 0 1px; }
.cmd-palette-foot {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  padding: 8px 14px; border-top: 1px solid var(--sep);
  font-size: 11.5px; color: var(--muted);
}
.cmd-palette-foot kbd {
  font: inherit; font-size: 11px; line-height: 1;
  padding: 2px 5px; margin-right: 2px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--sep); color: var(--text);
}

/* ================= 通用对话框（设置 / 共享） ================= */
.dlg-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 75; display: flex; align-items: center; justify-content: center; padding: 24px; }
html[data-theme="dark"] .dlg-backdrop { background: rgba(0,0,0,.55); }
.dlg {
  width: min(560px, 100%); max-height: min(760px, 100%); display: flex; flex-direction: column; overflow: hidden;
  background: var(--modal-bg); color: var(--text); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
html[data-theme="dark"] .dlg { border: 1px solid rgba(255,255,255,.08); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 18px; border-bottom: 1px solid var(--sep); }
.dlg-heading-wrap { flex: 1; min-width: 0; }
.dlg-heading { font-weight: 700; font-size: 15px; }
.dlg-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; }
.dlg-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--sep); }
.dlg-status { flex: 1; font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-btn {
  display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 14px; border: 0; border-radius: 7px;
  background: var(--btn-secondary); color: var(--text); cursor: pointer; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.dlg-btn:hover:not(:disabled) { filter: brightness(.97); }
html[data-theme="dark"] .dlg-btn:hover:not(:disabled) { filter: brightness(1.15); }
.dlg-btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.dlg-btn.danger { color: var(--danger); }
.dlg-btn:disabled { opacity: .5; cursor: default; }
.dlg-btn:focus-visible, .sc-add:focus-visible, .sc-reset:focus-visible, .sc-del:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 760px) {
  .dlg-backdrop { padding: 0; }
  .dlg { width: 100%; height: 100%; max-height: none; border-radius: 0; }
}

/* ---------- 设置（左侧导航 + 右侧面板） ---------- */
.settings-dlg { width: min(760px, 100%); height: min(560px, 92vh); max-height: min(640px, 100%); }
.settings-layout {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
.settings-nav {
  width: 148px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 8px; overflow-y: auto; border-right: 1px solid var(--sep);
  background: var(--surface-hover);
}
.settings-nav-item {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 13px;
  cursor: pointer; line-height: 1.3;
}
.settings-nav-item:hover { background: var(--surface-hover-strong); }
.settings-nav-item.on {
  background: var(--bg-elevated); color: var(--accent-strong); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
html[data-theme="dark"] .settings-nav-item.on { background: #48484a; box-shadow: none; }
.settings-nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.settings-panels {
  flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 14px 18px 18px;
}
.settings-panel[hidden] { display: none !important; }
.settings-section h3 {
  margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: .01em;
}
.settings-hint { margin: -4px 0 12px; font-size: 12px; color: var(--muted); line-height: 1.55; }
.settings-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
}
.settings-row-label {
  font-size: 13px; color: var(--text); min-width: 4.5em; flex-shrink: 0;
}
@media (max-width: 560px) {
  .settings-dlg { height: 100%; max-height: none; }
  .settings-layout { flex-direction: column; }
  .settings-nav {
    width: auto; flex-direction: row; flex-wrap: nowrap; gap: 4px;
    overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--sep);
    padding: 8px; -webkit-overflow-scrolling: touch;
  }
  .settings-nav-item { width: auto; white-space: nowrap; flex-shrink: 0; }
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; gap: 2px; }
.seg.seg-wrap { flex-wrap: wrap; max-width: 100%; }
.seg button { border: 0; background: none; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.seg button.on { background: var(--bg-elevated); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
html[data-theme="dark"] .seg button.on { background: #48484a; }
.sc-table { border: 1px solid var(--sep); border-radius: 10px; overflow: hidden; }
.sc-group { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 8px 12px 4px; background: var(--surface-hover); }
.sc-row {
  display: grid; grid-template-columns: minmax(130px, 1fr) minmax(0, 1.5fr) 28px; align-items: center; gap: 4px 10px;
  padding: 8px 8px 8px 12px; border-top: 1px solid var(--sep);
}
.sc-group + .sc-row { border-top: 0; }
.sc-row.recording { background: var(--accent-ring); }
.sc-label { min-width: 0; }
.sc-name { font-size: 13px; }
.sc-badge { margin-left: 6px; font-size: 10.5px; padding: 0 6px; line-height: 16px; border-radius: 8px; background: var(--tag-bg); color: var(--tag-text); vertical-align: 1px; }
.sc-default { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.sc-keys { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.sc-keys kbd, .sc-fixed kbd {
  font: inherit; font-size: 12px; line-height: 20px; padding: 0 7px; border-radius: 5px; white-space: nowrap;
  background: var(--bg-elevated); border: 1px solid var(--input-border); border-bottom-width: 2px; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sc-chip { display: inline-flex; align-items: center; gap: 1px; }
.sc-del {
  border: 0; background: none; color: var(--muted); cursor: pointer; width: 18px; height: 18px; border-radius: 50%;
  font-size: 14px; line-height: 1; padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.sc-del:hover { background: var(--surface-hover-strong); color: var(--danger); }
.sc-none { font-size: 12px; color: var(--muted); }
.sc-add {
  border: 1px dashed var(--input-border); background: none; color: var(--muted); cursor: pointer; height: 22px; min-width: 26px;
  border-radius: 5px; font-size: 13px; line-height: 1; padding: 0 6px;
}
.sc-add:hover { color: var(--accent-strong); border-color: var(--accent); }
.sc-capture {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 5px; font-size: 12px;
  border: 1px solid var(--accent); color: var(--accent-strong); background: var(--bg-elevated); animation: sc-pulse 1.2s ease-in-out infinite;
}
@keyframes sc-pulse { 50% { box-shadow: 0 0 0 3px var(--accent-ring-strong); } }
.sc-mini { border: 0; background: var(--btn-secondary); color: var(--text); border-radius: 5px; font-size: 12px; height: 22px; padding: 0 8px; cursor: pointer; }
.sc-reset {
  border: 0; background: none; color: var(--icon); cursor: pointer; width: 26px; height: 26px; border-radius: 6px; font-size: 15px; padding: 0;
}
.sc-reset:hover:not(:disabled) { background: var(--surface-hover-strong); color: var(--icon-hover); }
.sc-reset:disabled { opacity: .25; cursor: default; }
.sc-msg { grid-column: 1 / -1; font-size: 12px; line-height: 1.5; color: var(--danger); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sc-fixed { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 14px; }
.sc-fixed-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--modal-text); min-width: 0; }
.sc-fixed-row kbd { flex-shrink: 0; }
@media (max-width: 560px) {
  .sc-row { grid-template-columns: minmax(0, 1fr) 28px; }
  .sc-keys { grid-column: 1 / 2; }
}

/* ---------- 共享对话框 ---------- */
.share-btn.on { color: var(--accent-strong); }
.note-item .n-title .share-ico { color: var(--accent-strong); flex-shrink: 0; display: inline-flex; margin-left: auto; padding-left: 4px; }
.share-dlg { width: min(520px, 100%); }
.share-locked { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 18px 8px 8px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.share-locked p { margin: 0; }
.share-locked strong { color: var(--text); }
.share-switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.share-switch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.share-switch-text strong { font-size: 14px; }
.share-switch-text small { font-size: 12px; color: var(--muted); }
.switch {
  -webkit-appearance: none; appearance: none; flex-shrink: 0; width: 42px; height: 25px; border-radius: 13px; margin: 0;
  background: var(--input-border); position: relative; cursor: pointer; transition: background .18s; outline: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s;
}
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(17px); }
.switch:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring-strong); }
.switch:disabled { opacity: .5; cursor: default; }
.share-warn {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 9px 11px; border-radius: 9px;
  background: var(--trash-banner-bg); color: var(--trash-banner-text); font-size: 12.5px; line-height: 1.55;
}
.share-warn svg { flex-shrink: 0; margin-top: 2px; }
.share-on { margin-top: 14px; }
.share-link-row { display: flex; gap: 8px; }
.share-link-row input {
  flex: 1; min-width: 0; height: 30px; border: 1px solid var(--input-border); border-radius: 7px; padding: 0 9px;
  font: inherit; font-size: 12.5px; font-family: var(--font-mono); background: var(--bg-elevated); color: var(--text); outline: none;
}
.share-link-row input:focus { border-color: var(--accent); }
.share-since { font-size: 12px; color: var(--muted); margin-top: 8px; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ================= 公开只读共享页（/s/{token}） ================= */
body.share-page { height: auto; min-height: 100%; background: var(--bg-elevated); }
.share-top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  max-width: 840px; margin: 0 auto; padding: 12px 24px; background: var(--bg-elevated);
}
.share-brand { font-size: 12px; color: var(--muted); letter-spacing: .02em; user-select: none; }
.share-theme {
  border: 0; background: none; width: 32px; height: 30px; border-radius: 7px; color: var(--icon); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.share-theme:hover { background: var(--surface-hover-strong); color: var(--icon-hover); }
.share-theme .theme-icon-sun { display: none; }
html[data-theme="dark"] .share-theme .theme-icon-moon { display: none; }
html[data-theme="dark"] .share-theme .theme-icon-sun { display: inline; }
.share-main { max-width: 840px; margin: 0 auto; padding: 8px 24px 80px; }
.share-meta { text-align: left; color: var(--muted); font-size: 12px; padding: 0 0 14px; }
.share-title { margin: 0 0 8px; font-size: 28px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.share-body.editor { max-width: none; padding: 0; min-height: 0; cursor: auto; caret-color: auto; }
.share-body .ln.todo::before, .share-body .ln.todo:hover::before { cursor: default; border-color: var(--todo-border); }
.share-body .ln.todo[data-done="1"]::before { border-color: var(--accent); }
/* 不可用 / 链接已关闭：居中空状态 */
.share-main.share-missing {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px);
  padding: 24px 24px 12vh; text-align: center; color: var(--muted);
}
.share-empty { display: flex; flex-direction: column; align-items: center; max-width: 380px; }
.share-empty-icon {
  width: 76px; height: 76px; border-radius: 22px; margin-bottom: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-hover-strong); color: var(--icon);
}
.share-missing .share-title { color: var(--text); font-size: 22px; margin: 0 0 10px; }
.share-empty-text { margin: 0; font-size: 15px; line-height: 1.7; color: var(--text); opacity: .82; }
.share-empty-hint { margin: 8px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
@media (max-width: 760px) {
  .share-top { padding: 10px 18px; }
  .share-main { padding: 4px 18px 60px; }
  .share-title { font-size: 24px; }
  .share-main.share-missing { padding: 16px 18px 10vh; }
}
@media print {
  .share-top { display: none; }
  .share-main { padding: 0; }
}

/* ================= 在线表格（右侧抽屉） ================= */
.sheet-mode-btn.on { color: var(--accent-strong); }
.note-item .n-title .sheet-ico {
  color: var(--accent-strong); flex-shrink: 0; display: inline-flex;
  margin-left: 4px; font-size: 12px; opacity: .9; padding-left: 2px;
}
.sheet-header-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text); cursor: pointer; user-select: none;
  padding: 0 2px; white-space: nowrap;
}
.sheet-header-toggle input { accent-color: var(--accent-strong); }
.sheet-drawer-hint {
  font-size: 11px; color: var(--muted); padding: 0 6px; white-space: nowrap;
  user-select: none;
}
#tbSheet .text-btn { min-width: 0; padding: 4px 8px; font-size: 12px; }

/* 抽屉遮罩 + 面板（方向：上/下/左/右/独立弹窗，data-dir） */
.sheet-drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .32);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
html[data-theme="dark"] .sheet-drawer-backdrop { background: rgba(0, 0, 0, .55); }
.sheet-drawer-backdrop.is-open {
  opacity: 1; pointer-events: auto;
}
.sheet-drawer-backdrop[hidden] { display: none; }

.sheet-drawer {
  position: fixed; z-index: 61;
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
  box-sizing: border-box;
}
html[data-theme="dark"] .sheet-drawer {
  box-shadow: 0 0 28px rgba(0, 0, 0, .45);
}
.sheet-drawer.is-open { pointer-events: auto; }
.sheet-drawer[hidden] { display: none; }
.sheet-drawer.is-open[hidden] { display: flex; } /* safety: is-open wins once unhidden */
.sheet-drawer.is-resizing { transition: none !important; user-select: none; }

/* 右 */
.sheet-drawer[data-dir="right"] {
  top: 0; right: 0; bottom: 0; left: auto;
  width: min(560px, 100vw); max-width: 92vw; min-width: 280px;
  border-left: 1px solid var(--sep);
  box-shadow: -10px 0 28px rgba(0, 0, 0, .12);
  transform: translateX(100%);
}
.sheet-drawer[data-dir="right"].is-open { transform: translateX(0); }

/* 左 */
.sheet-drawer[data-dir="left"] {
  top: 0; left: 0; bottom: 0; right: auto;
  width: min(560px, 100vw); max-width: 92vw; min-width: 280px;
  border-right: 1px solid var(--sep);
  box-shadow: 10px 0 28px rgba(0, 0, 0, .12);
  transform: translateX(-100%);
}
.sheet-drawer[data-dir="left"].is-open { transform: translateX(0); }

/* 上 */
.sheet-drawer[data-dir="top"] {
  top: 0; left: 0; right: 0; bottom: auto;
  width: 100%; max-width: none; min-width: 0;
  height: min(420px, 70vh); max-height: 88vh; min-height: 200px;
  border-bottom: 1px solid var(--sep);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
  transform: translateY(-100%);
}
.sheet-drawer[data-dir="top"].is-open { transform: translateY(0); }

/* 下 */
.sheet-drawer[data-dir="bottom"] {
  bottom: 0; left: 0; right: 0; top: auto;
  width: 100%; max-width: none; min-width: 0;
  height: min(420px, 70vh); max-height: 88vh; min-height: 200px;
  border-top: 1px solid var(--sep);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, .12);
  transform: translateY(100%);
}
.sheet-drawer[data-dir="bottom"].is-open { transform: translateY(0); }

/* 独立弹窗 */
.sheet-drawer[data-dir="modal"] {
  top: 50%; left: 50%; right: auto; bottom: auto;
  width: min(720px, 92vw); height: min(640px, 84vh);
  max-width: 96vw; max-height: 92vh;
  min-width: 320px; min-height: 240px;
  border: 1px solid var(--sep); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
  transform: translate(-50%, -46%) scale(.97);
  opacity: 0;
}
.sheet-drawer[data-dir="modal"].is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
html[data-theme="dark"] .sheet-drawer[data-dir="right"],
html[data-theme="dark"] .sheet-drawer[data-dir="left"] {
  box-shadow: 0 0 28px rgba(0, 0, 0, .45);
}
html[data-theme="dark"] .sheet-drawer[data-dir="top"],
html[data-theme="dark"] .sheet-drawer[data-dir="bottom"],
html[data-theme="dark"] .sheet-drawer[data-dir="modal"] {
  box-shadow: 0 0 40px rgba(0, 0, 0, .55);
}

/* 拖拽柄：贴在打开边的对侧（上抽屉 → 底边；独立弹窗 → 右下角） */
.sheet-drawer-resize {
  position: absolute; z-index: 5; touch-action: none;
}
.sheet-drawer-resize::after {
  content: ''; position: absolute; background: transparent; transition: background .15s;
}
.sheet-drawer-resize:hover::after,
.sheet-drawer.is-resizing .sheet-drawer-resize::after {
  background: var(--accent-strong);
}

.sheet-drawer[data-dir="right"] .sheet-drawer-resize {
  left: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize;
}
.sheet-drawer[data-dir="right"] .sheet-drawer-resize::after {
  left: 0; top: 0; bottom: 0; width: 2px;
}

.sheet-drawer[data-dir="left"] .sheet-drawer-resize {
  right: 0; top: 0; bottom: 0; width: 6px; cursor: ew-resize;
}
.sheet-drawer[data-dir="left"] .sheet-drawer-resize::after {
  right: 0; top: 0; bottom: 0; width: 2px;
}

.sheet-drawer[data-dir="top"] .sheet-drawer-resize {
  left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize;
}
.sheet-drawer[data-dir="top"] .sheet-drawer-resize::after {
  left: 0; right: 0; bottom: 0; height: 2px;
}

.sheet-drawer[data-dir="bottom"] .sheet-drawer-resize {
  left: 0; right: 0; top: 0; height: 6px; cursor: ns-resize;
}
.sheet-drawer[data-dir="bottom"] .sheet-drawer-resize::after {
  left: 0; right: 0; top: 0; height: 2px;
}

.sheet-drawer[data-dir="modal"] .sheet-drawer-resize {
  right: 2px; bottom: 2px; width: 18px; height: 18px; cursor: nwse-resize;
}
.sheet-drawer[data-dir="modal"] .sheet-drawer-resize::after {
  right: 3px; bottom: 3px; width: 10px; height: 10px;
  border-right: 2px solid transparent; border-bottom: 2px solid transparent;
  background: transparent; border-radius: 0 0 2px 0;
}
.sheet-drawer[data-dir="modal"] .sheet-drawer-resize:hover::after,
.sheet-drawer[data-dir="modal"].is-resizing .sheet-drawer-resize::after {
  background: transparent;
  border-right-color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
}

.sheet-drawer-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--sep);
  flex-shrink: 0; min-height: 52px;
  background: var(--bg-elevated);
}
.sheet-drawer-title {
  font-size: 15px; font-weight: 650; color: var(--text);
  flex-shrink: 0; margin-right: 4px;
}
.sheet-drawer-actions {
  display: flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0; justify-content: flex-end; flex-wrap: wrap;
}
.sheet-drawer-body {
  flex: 1; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.sheet-host {
  flex: 1; min-height: 0; padding: 12px 14px 20px;
  overflow: hidden; display: flex; flex-direction: column;
}
.sheet-wrap {
  border: 1px solid var(--table-border); border-radius: 10px;
  overflow: hidden; background: var(--bg-elevated);
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.sheet-scroll {
  overflow: auto; flex: 1; min-height: 0;
  max-height: none;
  -webkit-overflow-scrolling: touch;
}
.sheet-grid {
  border-collapse: separate; border-spacing: 0;
  table-layout: fixed;
  width: max-content; /* grow with columns; horizontal scroll in .sheet-scroll */
  min-width: 100%;
  font-size: 14px; color: var(--text);
}
.sheet-grid col { min-width: 60px; }
.sheet-grid col.sheet-rowhead-col { min-width: 40px; width: 40px; }
.sheet-corner, .sheet-colhead, .sheet-rowhead {
  background: var(--table-head-bg); color: var(--muted);
  font-weight: 600; font-size: 11px; letter-spacing: .02em;
  border-bottom: 1px solid var(--table-border); border-right: 1px solid var(--table-border);
  position: sticky; z-index: 2; user-select: none;
}
.sheet-corner { left: 0; top: 0; z-index: 4; width: 40px; min-width: 40px; }
.sheet-rowhead {
  left: 0; z-index: 1; width: 40px; min-width: 40px; max-width: 40px;
  text-align: center; padding: 4px 2px; vertical-align: middle;
  cursor: context-menu;
}
/* 行高拖拽柄：行号单元格下边缘 */
.sheet-row-resize {
  position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  cursor: row-resize; z-index: 2;
}
.sheet-row-resize:hover, .sheet-row-resize.is-active { background: var(--accent-ring); }
.sheet-wrap.is-row-resizing, .sheet-wrap.is-row-resizing * { cursor: row-resize !important; user-select: none; }
.sheet-colhead {
  top: 0; text-align: center; padding: 6px 4px; position: sticky;
  height: 28px; box-sizing: border-box; cursor: context-menu;
}
.sheet-colhead.is-sel, .sheet-rowhead.is-sel {
  background: var(--select); color: var(--text);
}
.sheet-col-label { pointer-events: none; display: inline-flex; align-items: center; gap: 3px; }
.sheet-col-type { font-size: 10px; opacity: .75; }
.sheet-col-resize {
  position: absolute; right: 0; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 2;
}
.sheet-col-resize:hover { background: var(--accent-ring); }
.sheet-td {
  border-bottom: 1px solid var(--table-border); border-right: 1px solid var(--table-border);
  padding: 0; vertical-align: top; background: var(--bg-elevated);
  cursor: cell;
}
.sheet-td.is-header, .sheet-wrap.has-header tbody tr:first-child .sheet-td {
  background: var(--table-head-bg); font-weight: 600;
}
.sheet-td.is-sel { background: var(--select); }
.sheet-td.is-active { box-shadow: inset 0 0 0 2px var(--table-focus); }
.sheet-td.is-merged { vertical-align: middle; }
/* 单元格对齐（data.aligns）：覆盖默认（文本左上、数字右对齐、合并格垂直居中） */
.sheet-td.al-v-t { vertical-align: top; }
.sheet-td.al-v-m { vertical-align: middle; }
.sheet-td.al-v-b { vertical-align: bottom; }
.sheet-td.al-h-l .sheet-display, .sheet-td.al-h-l .sheet-disp-text.is-num { text-align: left; }
.sheet-td.al-h-c .sheet-display, .sheet-td.al-h-c .sheet-disp-text.is-num { text-align: center; }
.sheet-td.al-h-r .sheet-display, .sheet-td.al-h-r .sheet-disp-text.is-num { text-align: right; }
.sheet-td.al-h-l .sheet-dd-disp { justify-content: flex-start; }
.sheet-td.al-h-c .sheet-dd-disp { justify-content: center; }
.sheet-td.al-h-r .sheet-dd-disp { justify-content: flex-end; }

/* 表格工具栏：对齐 / 行高 */
.sheet-toolbar {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  padding: 4px 6px; min-height: 34px; box-sizing: border-box;
  border-bottom: 1px solid var(--table-border); background: var(--table-head-bg);
}
.sheet-tb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 26px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.sheet-tb-btn:hover { background: var(--surface-hover); color: var(--text); }
.sheet-tb-btn.is-on { background: var(--select); color: var(--accent-strong); }
.sheet-tb-btn svg { display: block; }
.sheet-tb-sep { width: 1px; height: 16px; background: var(--sep); margin: 0 4px; flex-shrink: 0; }
.sheet-tb-hint {
  margin-left: auto; padding-left: 8px; font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.sheet-display {
  min-height: 32px; padding: 6px 8px; line-height: 1.35;
  white-space: pre-wrap; word-break: break-word;
  box-sizing: border-box; pointer-events: none;
}
.sheet-type-checkbox .sheet-display,
.sheet-type-rating .sheet-display,
.sheet-type-dropdown .sheet-display { pointer-events: auto; }
.sheet-disp-text { display: inline; }
.sheet-disp-text.is-num { display: block; text-align: right; font-variant-numeric: tabular-nums; }
.sheet-disp-text.is-long { white-space: pre-wrap; }
.sheet-ph { color: var(--muted); opacity: .55; font-weight: 400; }
.sheet-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; font-size: 16px; cursor: pointer;
  border-radius: 4px; user-select: none;
}
.sheet-check:hover { background: var(--surface-hover); }
.sheet-check.is-on { color: var(--accent-strong); }
.sheet-stars { display: inline-flex; gap: 1px; cursor: pointer; user-select: none; }
.sheet-star { font-size: 14px; color: var(--muted); padding: 0 1px; }
.sheet-star.is-on { color: #e6a700; }
.sheet-star:hover { transform: scale(1.12); }
.sheet-dd-disp {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  cursor: pointer; min-height: 20px;
}
.sheet-dd-caret { opacity: .45; font-size: 11px; flex-shrink: 0; }
.sheet-link { color: var(--accent-strong); text-decoration: underline; pointer-events: auto; }
.sheet-td.is-editing { position: relative; z-index: 3; }
.sheet-editor {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 32px;
  margin: 0; padding: 6px 8px; border: 0; outline: none;
  box-shadow: inset 0 0 0 2px var(--table-focus);
  background: var(--bg-elevated); color: var(--text); font: inherit;
  line-height: 1.35; box-sizing: border-box; resize: none;
  z-index: 2;
}
/* 编辑态与显示态一致：自动换行、保留换行；高度由 JS 随内容增高（可溢出单元格下方） */
textarea.sheet-editor {
  bottom: auto; min-height: 100%; overflow: hidden;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  box-shadow: inset 0 0 0 2px var(--table-focus), 0 6px 18px rgba(0,0,0,.12);
}
textarea.sheet-editor.is-long { min-height: max(100%, 64px); }
html[data-theme="dark"] textarea.sheet-editor { box-shadow: inset 0 0 0 2px var(--table-focus), 0 6px 18px rgba(0,0,0,.4); }
input.sheet-editor[type="date"],
input.sheet-editor[type="datetime-local"] { cursor: pointer; }

/* dropdown popover */
.sheet-dd-pop {
  position: fixed; z-index: 120;
  max-height: min(280px, 50vh); overflow: auto;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--sep); border-radius: 8px;
  box-shadow: 0 10px 32px rgba(0,0,0,.2);
  padding: 4px; font-size: 13px;
}
.sheet-dd-list { display: flex; flex-direction: column; gap: 1px; }
.sheet-dd-item {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; color: inherit;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font: inherit;
}
.sheet-dd-item:hover, .sheet-dd-item.is-on { background: var(--select); }
.sheet-dd-item.is-orphan { font-style: italic; opacity: .85; }
.sheet-dd-foot {
  border-top: 1px solid var(--sep); margin-top: 4px; padding-top: 4px;
}
.sheet-dd-manage {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--accent-strong);
  padding: 7px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600;
}
.sheet-dd-manage:hover { background: var(--surface-hover); }

/* format / options dialog */
.sheet-dlg-backdrop {
  position: fixed; inset: 0; z-index: 125;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
html[data-theme="dark"] .sheet-dlg-backdrop { background: rgba(0,0,0,.55); }
.sheet-dlg {
  width: min(440px, 100%); max-height: min(84vh, 640px);
  overflow: auto; display: flex; flex-direction: column;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--sep); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.sheet-dlg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--sep); font-size: 15px;
}
.sheet-dlg-x {
  border: 0; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 8px; border-radius: 6px;
}
.sheet-dlg-x:hover { background: var(--surface-hover); color: var(--text); }
.sheet-dlg-body { padding: 12px 14px; overflow: auto; flex: 1; }
.sheet-dlg-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 14px; border-top: 1px solid var(--sep);
}
.sheet-dlg-actions button {
  border: 1px solid var(--sep); background: var(--bg-elevated); color: var(--text);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; font: inherit;
}
.sheet-dlg-actions button.primary {
  background: var(--accent-strong); color: #fff; border-color: transparent; font-weight: 600;
}
.sheet-fmt-types {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.sheet-fmt-type {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--sep); background: var(--bg-elevated); color: var(--text);
  border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; font-size: 13px;
}
.sheet-fmt-type .ico { width: 18px; text-align: center; opacity: .85; }
.sheet-fmt-type:hover { background: var(--surface-hover); }
.sheet-fmt-type.is-on {
  border-color: var(--accent-strong); background: var(--select);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
}
.sheet-fmt-extra { margin-top: 14px; }
.sheet-opts-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-weight: 600; font-size: 13px;
}
.sheet-opts-add {
  border: 0; background: transparent; color: var(--accent-strong);
  cursor: pointer; font: inherit; font-weight: 600; padding: 4px 6px; border-radius: 6px;
}
.sheet-opts-add:hover { background: var(--surface-hover); }
.sheet-opts-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sheet-opts-item { display: flex; align-items: center; gap: 4px; }
.sheet-opts-input {
  flex: 1; min-width: 0; border: 1px solid var(--sep); border-radius: 6px;
  padding: 6px 8px; background: var(--bg); color: var(--text); font: inherit;
}
.sheet-opts-move, .sheet-opts-del {
  border: 1px solid var(--sep); background: var(--bg-elevated); color: var(--text);
  border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font: inherit; line-height: 1;
}
.sheet-opts-move:disabled { opacity: .35; cursor: default; }
.sheet-opts-del:hover { color: #c0392b; }
.sheet-opts-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
.sheet-opts-hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.sheet-dec-label { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sheet-dec-input {
  width: 64px; border: 1px solid var(--sep); border-radius: 6px;
  padding: 6px 8px; background: var(--bg); color: var(--text); font: inherit;
}

.sheet-cell-ro {
  min-height: 28px; padding: 6px 8px; line-height: 1.35;
  white-space: pre-wrap; word-break: break-word;
}
.sheet-wrap.is-ro .sheet-td { cursor: default; }
.sheet-wrap:focus { outline: none; }
.sheet-wrap:focus-visible { box-shadow: 0 0 0 2px var(--accent-ring); }

.sheet-ctx-menu.ctx-menu {
  position: fixed; z-index: 110;
  min-width: 160px; max-width: 280px;
  padding: 6px; border-radius: 8px;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--sep);
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  font-size: 13px;
}

/* 公开只读表格页 */
.sheet-public { overflow: auto; margin-top: 8px; max-width: 100%; }
.sheet-public .sheet-table {
  border-collapse: collapse; width: max-content; min-width: 280px; max-width: none;
  table-layout: fixed; font-size: 14px; color: var(--text);
}
.sheet-public .sheet-table th,
.sheet-public .sheet-table td {
  border: 1px solid var(--table-border); padding: 8px 10px;
  vertical-align: top; word-break: break-word; line-height: 1.4;
  background: var(--bg-elevated);
}
.sheet-public .sheet-table th.sheet-th,
.sheet-public .sheet-table tr:first-child th {
  background: var(--table-head-bg); font-weight: 600;
}
.sheet-public .sheet-type-number,
.sheet-public .sheet-type-currency,
.sheet-public .sheet-type-percent { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-public .sheet-table .al-h-l { text-align: left; }
.sheet-public .sheet-table .al-h-c { text-align: center; }
.sheet-public .sheet-table .al-h-r { text-align: right; }
.sheet-public .sheet-table .al-v-t { vertical-align: top; }
.sheet-public .sheet-table .al-v-m { vertical-align: middle; }
.sheet-public .sheet-table .al-v-b { vertical-align: bottom; }
.sheet-public .sheet-check.is-on { color: var(--accent-strong); }
.sheet-public .sheet-rating { letter-spacing: 1px; color: #e6a700; }
.sheet-public a { color: var(--accent-strong); }
body.share-sheet .share-main { max-width: 1100px; }
.share-sheet-block { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--sep); }
.share-sheet-heading {
  font-size: 13px; font-weight: 650; color: var(--muted);
  margin: 0 0 10px; letter-spacing: .02em;
}

@media (max-width: 760px) {
  .sheet-drawer[data-dir="right"],
  .sheet-drawer[data-dir="left"],
  .sheet-drawer[data-dir="top"],
  .sheet-drawer[data-dir="bottom"],
  .sheet-drawer[data-dir="modal"] {
    top: 0 !important; right: 0 !important; bottom: 0 !important; left: 0 !important;
    width: 100vw !important; height: 100% !important;
    max-width: 100vw !important; max-height: none !important;
    min-width: 0 !important; min-height: 0 !important;
    border: 0 !important; border-radius: 0 !important;
    box-shadow: none;
    transform: translateX(100%);
    opacity: 1;
  }
  .sheet-drawer[data-dir="left"] { transform: translateX(-100%); }
  .sheet-drawer[data-dir="top"] { transform: translateY(-100%); }
  .sheet-drawer[data-dir="bottom"] { transform: translateY(100%); }
  .sheet-drawer[data-dir="modal"] { transform: translateY(12px); opacity: 0; }
  .sheet-drawer[data-dir="right"].is-open,
  .sheet-drawer[data-dir="left"].is-open,
  .sheet-drawer[data-dir="top"].is-open,
  .sheet-drawer[data-dir="bottom"].is-open {
    transform: none;
  }
  .sheet-drawer[data-dir="modal"].is-open {
    transform: none; opacity: 1;
  }
  .sheet-drawer-resize { display: none; }
  .sheet-drawer-head { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .sheet-drawer-title { width: 100%; margin: 0; }
  .sheet-drawer-actions { width: 100%; justify-content: flex-start; }
  .sheet-drawer-hint { display: none; }
  .sheet-host { padding: 10px 10px 16px; }
}

.tb-fmt { display: inline-flex; align-items: center; gap: inherit; }
.tb-fmt[hidden], .tb-fmt-sep[hidden] { display: none !important; }


/* ---- 待办汇总 / 文内统计 ---- */
.todo-stats {
  margin-left: auto;
  margin-right: 8px;
  border: 0;
  background: var(--sidebar-sel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1.4;
}
.todo-stats:hover { color: var(--text); }
.todo-stats:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.editor-toolbar:has(.todo-stats:not([hidden])) .save-status { margin-left: 0; }
.todo-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--sep);
}
.todo-item:hover { background: var(--hover, rgba(0,0,0,.04)); }
.todo-item.active { background: var(--sidebar-sel); }
.todo-item .todo-check {
  flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px;
  border: 1.5px solid var(--todo-border); border-radius: 50%;
  background: var(--todo-bg); cursor: pointer; appearance: none;
  -webkit-appearance: none; position: relative;
}
.todo-item .todo-check:checked {
  border-color: var(--accent); background: var(--accent);
}
.todo-item .todo-check:checked::after {
  content: ""; position: absolute; left: 4px; top: 2px;
  width: 6px; height: 9px; border: solid #fff; border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}
.todo-item .todo-body { min-width: 0; flex: 1; }
.todo-item .todo-text {
  font-size: 13.5px; font-weight: 500; line-height: 1.35;
  word-break: break-word;
}
.todo-item .todo-note {
  margin-top: 3px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.todo-list-hint {
  padding: 10px 16px 4px; font-size: 12px; color: var(--muted); line-height: 1.4;
}

.editor .ln.todo-flash {
  animation: todoFlash 1.1s ease;
}
@keyframes todoFlash {
  0%, 100% { background: transparent; }
  30% { background: color-mix(in srgb, var(--accent) 18%, transparent); }
}

/* ===== 每日计划（immersive calendar + day plan）===== */
.notes-app.daily-mode .pane-list,
.notes-app.daily-mode .pane-editor { display: none !important; }
.notes-app.daily-mode .pane-daily { display: flex; }
.pane-daily {
  display: none; flex: 1; min-width: 0; background: var(--bg-elevated);
  border-right: 0;
}
.daily-cal {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--sep);
  display: flex; flex-direction: column; padding: 16px 14px 12px;
  background: var(--sidebar, var(--bg-elevated)); user-select: none;
}
.daily-cal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin-bottom: 10px;
}
.daily-cal-title {
  flex: 1; text-align: center; font-size: 15px; font-weight: 700; color: var(--text);
}
.daily-cal-nav {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
}
.daily-cal-nav:hover { background: var(--hover, rgba(0,0,0,.06)); color: var(--text); }
.daily-cal-chips {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.daily-cal-chip {
  flex: 1; height: 28px; border-radius: 999px; border: 1px solid var(--sep);
  background: transparent; color: var(--text); font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.daily-cal-chip:hover { background: var(--hover, rgba(0,0,0,.05)); }
.daily-cal-chip.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--sep));
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.daily-cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  margin-bottom: 4px;
}
.daily-cal-weekdays span {
  text-align: center; font-size: 11px; color: var(--muted); font-weight: 600;
  padding: 4px 0;
}
.daily-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.daily-cal-day {
  position: relative; aspect-ratio: 1; max-height: 46px;
  border: none; border-radius: 10px; background: transparent;
  color: var(--text); cursor: pointer; font-size: 13px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 0 0 9px; overflow: visible;
}
.daily-cal-day:hover { background: var(--hover, rgba(0,0,0,.06)); }
.daily-cal-day.muted { color: var(--muted); opacity: .55; }
/* 有计划：底色洗染，空日期保持安静 */
.daily-cal-day.has-plan:not(.is-selected) {
  background: color-mix(in srgb, var(--muted) 16%, transparent);
}
.daily-cal-day.has-open:not(.is-selected) {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent-strong);
  font-weight: 700;
}
.daily-cal-day.has-plan:not(.has-open):not(.is-selected):hover,
.daily-cal-day.has-open:not(.is-selected):hover {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}
.daily-cal-day.is-today {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent);
  font-weight: 700; color: var(--accent);
}
.daily-cal-day.is-today.has-open:not(.is-selected) {
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1.5px var(--accent-strong);
}
.daily-cal-day.is-selected {
  background: var(--accent); color: #fff; font-weight: 700;
  box-shadow: none;
}
.daily-cal-day.is-selected.is-today { box-shadow: none; }
.daily-cal-day.is-selected.has-open {
  background: var(--accent-strong);
}
/* 底部绝对定位圆点，避免被 max-height / flex 裁切 */
.daily-cal-day .cal-dot {
  position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; pointer-events: none;
}
.daily-cal-day .cal-dot.open {
  background: var(--accent-strong);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
}
.daily-cal-day .cal-dot.done {
  width: 7px; height: 7px;
  background: color-mix(in srgb, var(--muted) 85%, var(--text));
  opacity: 1;
}
.daily-cal-day.is-selected .cal-dot.open {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,.35);
}
.daily-cal-day.is-selected .cal-dot.done {
  background: rgba(255,255,255,.75);
  opacity: 1;
}
.daily-cal-day.is-today:not(.is-selected) .cal-dot.open {
  background: var(--accent-strong);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}
.daily-cal-foot {
  margin-top: auto; padding-top: 12px; font-size: 11.5px; color: var(--muted);
  line-height: 1.4;
}

.daily-plan {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--bg-elevated);
}
.daily-plan-head {
  padding: 18px 24px 8px; border-bottom: 1px solid var(--sep);
}
.daily-plan-kicker {
  font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .02em;
  margin-bottom: 4px;
}
.daily-plan-title {
  margin: 0; font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.25;
}
.daily-plan-progress {
  margin-top: 8px; font-size: 13px; color: var(--muted);
}
.daily-plan-progress strong { color: var(--text); font-weight: 600; }
.daily-plan-body {
  flex: 1; overflow: auto; padding: 8px 0 24px;
}
.daily-add {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 24px 12px; border-bottom: 1px solid var(--sep);
}
.daily-add-row {
  display: flex; align-items: center; gap: 8px;
}
.daily-add-row input[type="text"] {
  flex: 1; min-width: 0; height: 38px; padding: 0 12px;
  border: 1px solid var(--sep); border-radius: 10px;
  background: var(--bg, #fff); color: var(--text); font-size: 14px;
  outline: none;
}
.daily-add-row input[type="text"]:focus { border-color: var(--accent); }
.daily-add-row .daily-add-btn {
  flex-shrink: 0; height: 38px; padding: 0 16px; border: none;
  border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.daily-add-row .daily-add-btn:disabled { opacity: .5; cursor: default; }
.daily-add-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.daily-note-picker { position: relative; }
.daily-note-picker-toggle {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px dashed var(--sep); background: transparent;
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.daily-note-picker-toggle.has-note {
  border-style: solid; color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--sep));
}
.daily-note-picker-toggle .chip-x {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1;
}
.daily-note-picker-menu {
  position: absolute; left: 0; top: calc(100% + 4px); width: min(320px, 70vw);
  z-index: 50; max-height: 260px; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg, #fff); border: 1px solid var(--sep);
  border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14);
  padding: 6px;
}
.daily-note-picker-menu input[type="search"] {
  width: 100%; height: 30px; padding: 0 8px; margin-bottom: 4px;
  border: 1px solid var(--sep); border-radius: 6px;
  background: var(--bg, #fff); color: var(--text); font-size: 12px;
  box-sizing: border-box;
  flex-shrink: 0;
}
.daily-note-picker-menu .dnp-list {
  flex: 1; min-height: 0; overflow-y: auto;
}
.daily-note-picker-menu .dnp-item {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent; color: var(--text);
  padding: 7px 8px; border-radius: 6px; font-size: 12.5px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.daily-note-picker-menu .dnp-item:hover { background: var(--hover, rgba(0,0,0,.06)); }
.daily-note-picker-menu .dnp-empty {
  padding: 10px 8px; font-size: 12px; color: var(--muted);
}
.daily-from-note-btn {
  border: none; background: transparent; color: var(--accent);
  font-size: 12px; cursor: pointer; padding: 4px 2px;
}
.daily-from-note-btn:hover { text-decoration: underline; }

.daily-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 24px; border-bottom: 1px solid var(--sep);
}
.daily-item:hover { background: var(--hover, rgba(0,0,0,.03)); }
.daily-item.done .daily-title-input {
  text-decoration: line-through; color: var(--muted); font-weight: 400;
}
.daily-item .todo-check { margin-top: 4px; flex-shrink: 0; }
.daily-item .daily-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.daily-title-input {
  width: 100%; border: none; background: transparent; color: var(--text);
  font-size: 14.5px; font-weight: 550; line-height: 1.4; padding: 2px 0;
  outline: none; font-family: inherit;
}
.daily-title-input:focus {
  border-radius: 4px;
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent);
  padding: 2px 4px;
}
.daily-item-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.daily-project-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 220px;
  padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); font-size: 12px; font-weight: 550;
  border: none; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.daily-project-chip:hover { filter: brightness(0.96); }
.daily-link-btn {
  border: 1px dashed var(--sep); background: transparent; color: var(--muted);
  font-size: 12px; padding: 2px 9px; border-radius: 999px; cursor: pointer;
}
.daily-link-btn:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--sep)); }
.daily-link-btn.ghost {
  border: none; padding: 2px 4px; color: var(--muted);
}
.daily-link-btn.ghost:hover { color: var(--text); text-decoration: underline; }
.daily-item .daily-del {
  flex-shrink: 0; border: none; background: transparent;
  color: var(--muted); width: 28px; height: 28px; border-radius: 8px;
  cursor: pointer; opacity: 0; font-size: 18px; line-height: 1; margin-top: 2px;
}
.daily-item:hover .daily-del { opacity: 1; }
.daily-item .daily-del:hover { background: var(--hover, rgba(0,0,0,.08)); color: var(--text); }
.daily-section-label {
  padding: 16px 24px 6px; font-size: 12px; font-weight: 650;
  color: var(--muted); letter-spacing: .02em;
}
.daily-empty {
  padding: 36px 24px; text-align: center; color: var(--muted); font-size: 13.5px;
}
.daily-item-picker-host { position: relative; display: inline-flex; }

@media (max-width: 860px) {
  .notes-app.daily-mode .pane-daily { flex-direction: column; }
  .daily-cal { width: 100%; border-right: 0; border-bottom: 1px solid var(--sep); max-height: 42vh; }
  .daily-cal-day { max-height: 42px; }
}
@media (max-width: 720px) {
  .notes-app.daily-mode .pane-folders { display: none; }
  .notes-app.daily-mode.show-folders .pane-folders { display: flex; }
  .notes-app.daily-mode.show-folders .pane-daily { display: none !important; }
}


/* TTS (read aloud) */
.tts-rate-wrap { margin-left: 2px; }
.tts-voice-select { max-width: 220px; }
#btnSpeak.on { color: var(--accent-strong); }
