/* 云笺 · 云笔记本 —— 界面样式 */

:root {
  /* iOS 系统色板（light）：底色中性灰、白卡片浮起、靠 hairline 分隔，
     不用「实色边框 + 暖调阴影」那种容易显脏的组合 */
  --bg: #f2f2f7;            /* systemGroupedBackground */
  --sidebar: #f2f2f7;       /* 与底色同档，白卡片才浮得起来（两端统一） */
  --surface: #ffffff;
  --line: rgba(60, 60, 67, .12);        /* hairline 分隔线 */
  --line-soft: rgba(60, 60, 67, .07);
  --ink: #1c1c1e;           /* label */
  --ink-2: #3c3c43;         /* secondary label */
  --muted: #8e8e93;         /* tertiary */
  --accent: #007aff;        /* systemBlue */
  --accent-soft: rgba(0, 122, 255, .12);
  --danger: #ff3b30;        /* systemRed */
  --danger-soft: rgba(255, 59, 48, .10);
  --fill: rgba(118, 118, 128, .10);     /* iOS 浅灰填充：hover / 搜索框 / 次要底 */
  --orange: #ff9500;        /* systemOrange：保存中状态 */
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 14px;         /* iOS 弹窗圆角是 14，不是大圆角 */
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .035);
  --shadow-m: 0 6px 22px rgba(0, 0, 0, .08);
  --shadow-l: 0 24px 60px rgba(0, 0, 0, .14);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* 必须强于作者样式里的 display（如 .login / .app 的 flex），否则 hidden 不生效 */
[hidden] { display: none !important; }

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

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; padding: 0; }
::selection { background: rgba(0,122,255,.20); }

/* 滚动条 */
.scroll, .note-list, .attach-list, .content { scrollbar-width: thin; scrollbar-color: #c7c7cc transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d1d6; border: 3px solid transparent; border-radius: 8px; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aeaeb2; background-clip: content-box; }

/* 图标 ------------------------------------------------------------ */
.ico { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

/* 按钮 ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; letter-spacing: .01em;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(.5px); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }

/* iOS 的主要按钮就是 tint 蓝填充、无阴影，墨黑块太重 */
.btn-primary { background: var(--accent); color: #fff; box-shadow: none; }
.btn-primary:hover { background: #0a6ed1; }
.btn-primary:disabled { opacity: .45; box-shadow: none; }

.btn-ghost { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.btn-ghost:hover { background: rgba(118,118,128,.08); border-color: rgba(60,60,67,.22); color: var(--ink); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d92c22; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; color: var(--ink-2);
  transition: background .16s ease, color .16s ease, opacity .16s ease;
}
.icon-btn:hover { background: var(--fill); background: var(--fill); }
.icon-btn.subtle { opacity: .62; }
.icon-btn.subtle:hover { opacity: 1; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); opacity: 1; }

/* 详情页返回键：默认隐藏，只在手机单栏模式出现（见响应式段） */
.m-back { display: none; }

/* 输入 ------------------------------------------------------------ */
.input {
  width: 100%; height: 42px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fafafa; color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  outline: none;
}
.input::placeholder { color: #aeaeb2; }
.input:focus { border-color: rgba(0,122,255,.35); background: #fff; box-shadow: 0 0 0 3px rgba(0,122,255,.14); }

/* 登录 ------------------------------------------------------------ */
.login {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 480px at 20% 12%, rgba(0,122,255,.07), transparent 62%),
    radial-gradient(760px 420px at 86% 88%, rgba(88,86,214,.06), transparent 60%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: 380px; max-width: calc(100vw - 40px);
  padding: 44px 40px 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-l);
  animation: rise .38s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.login-mark {
  width: 46px; height: 46px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: center;
}
.login-mark img { width: 100%; height: 100%; display: block; }  /* 直接用 v4 app 图标，与桌面/标签页统一 */
.login-title { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.login-sub { margin: 6px 0 26px; color: var(--muted); font-size: 13.5px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
.login-error {
  margin: 0 0 12px; padding: 9px 12px; font-size: 13px; color: var(--danger);
  background: var(--danger-soft); border-radius: 9px;
}
.login-card .btn { height: 42px; margin-top: 6px; }
.login-tip { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.login-tip b { color: var(--ink-2); font-weight: 600; }

/* 布局 ------------------------------------------------------------ */
/* 100dvh：手机浏览器地址栏收起/展开时 100vh 会算错，dvh 跟着可视区走 */
.app {
  display: flex; height: 100vh; height: 100dvh; overflow: hidden;
  /* 配合 viewport-fit=cover：内容避开刘海 / 状态栏 / 底部横条 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.sidebar {
  width: 300px; flex: none;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 14px; }
.brand {
  display: flex; align-items: center; gap: 9px;
  /* 按钮化后要抹掉浏览器默认样式，负 margin 让 hover 底色不撑动布局 */
  appearance: none; border: none; background: none; font: inherit; color: inherit;
  padding: 4px 8px; margin: -4px -8px; border-radius: 10px;
  cursor: pointer; transition: background .16s ease;
}
.brand:hover { background: var(--fill); }
.brand:focus-visible { outline: 2px solid rgba(0,122,255,.45); outline-offset: 1px; }
.brand-mark { width: 26px; height: 26px; }
.brand-mark svg { width: 100%; height: 100%; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.brand-mark rect { fill: none; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .02em; }

.sb-search { position: relative; margin: 0 14px 4px; }
.sb-search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
.sb-search-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.sb-search-input {
  width: 100%; height: 36px; padding: 0 32px 0 34px;
  border: 1px solid transparent; border-radius: 10px;
  background: rgba(118,118,128,.12); outline: none;   /* 侧栏底色压深后，rgba(118,118,128,.10) 会糊进背景，这里跟着加深 */
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.sb-search-input::placeholder { color: #aeaeb2; }
.sb-search-input:focus { background: #fff; border-color: var(--line); box-shadow: 0 0 0 3px rgba(0,122,255,.12); }
.sb-search-input::-webkit-search-cancel-button { display: none; }
.sb-search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 6px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.sb-search-clear:hover { background: rgba(118,118,128,.18); }
.sb-search-clear svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.sb-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 8px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}

.note-list { flex: 1; overflow-y: auto; padding: 0 12px 12px; }

/* 列表条目卡片化：白底浮在侧栏底色上，条目边界一眼可见。
   hover / 选中只调边框和阴影、不换底色——底色一闪会显廉价。
   外圈柔光 2.5px 会溢出卡片，靠 .note-list 的 12px 内边距兜住，不会被滚动区裁掉。 */
.note-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 13px 11px; margin-bottom: 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(0,0,0,.035);
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
  position: relative;
  user-select: none;
  cursor: pointer;
}
.note-item:hover {
  background: var(--surface);
  border-color: rgba(60,60,67,.18);
  box-shadow: 0 1px 2px rgba(0,0,0,.045), 0 2px 10px rgba(0,0,0,.04);
}
.note-item:active { background: rgba(118,118,128,.09); }   /* 按下有反馈；放在 hover 之后才压得住 */
.note-item:focus-visible { outline: 2px solid rgba(0,122,255,.45); outline-offset: 1px; }
.note-item[draggable="true"] { cursor: grab; }
.note-item.dragging { opacity: .35; cursor: grabbing; }
/* 拖拽时的插入位置指示线（::before 已被置顶竖线占用，这里用 ::after） */
.note-item.drop-before::after,
.note-item.drop-after::after {
  content: ''; position: absolute; left: 10px; right: 10px; height: 2px;
  background: var(--accent); border-radius: 2px;
  box-shadow: 0 0 0 3px rgba(0,122,255,.16);
}
.note-item.drop-before::after { top: -2px; }
.note-item.drop-after::after { bottom: -2px; }
.note-item.active {
  background: var(--surface);
  border-color: rgba(0,122,255,.45);
  box-shadow: 0 1px 2px rgba(0,0,0,.045), 0 0 0 2.5px var(--accent-soft);
}
/* 选中竖线：卡片化后从列表外挪进卡片左缘，跟着卡片内边距走 */
.note-item.active::before {
  content: ''; position: absolute; left: 0; top: 11px; bottom: 11px;
  width: 2.5px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.ni-line { display: flex; align-items: center; gap: 6px; }
.ni-title {
  flex: 1; min-width: 0; font-size: 15.5px; font-weight: 600; color: var(--ink);
  line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.012em;
}
.ni-pin { color: var(--accent); width: 15px; height: 15px; flex: none; opacity: .85; }
.ni-pin svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ni-excerpt {
  display: block; margin-top: 5px; font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ni-foot { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.ni-tag { display: inline-flex; align-items: center; gap: 3px; }
.ni-tag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.list-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 13px; }

.sb-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-top: 1px solid var(--line);
}
.user-chip {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 10px; min-width: 0;
  transition: background .16s ease;
}
.user-chip:hover { background: var(--fill); }
.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-meta { flex: 1; min-width: 0; text-align: left; line-height: 1.35; }
.user-meta b { display: block; font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }
.chip-arrow { width: 14px; height: 14px; color: var(--muted); flex: none; }
.chip-arrow svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 内容区 ---------------------------------------------------------- */
.content { flex: 1; overflow-y: auto; background: var(--surface); position: relative; }

.empty {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 40px; text-align: center; user-select: none;
}
.empty-art { width: 76px; height: 76px; margin-bottom: 18px; color: rgba(60,60,67,.16); }
.empty-art svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.empty h2 { margin: 0; font-size: 19px; font-weight: 550; letter-spacing: -.01em; }
.empty p { margin: 8px 0 22px; color: var(--muted); font-size: 13.5px; line-height: 1.8; }

.note { max-width: 860px; margin: 0 auto; padding: 26px 56px 120px; }

.note-top {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; margin-bottom: 26px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(to bottom, var(--surface) 70%, rgba(255,255,255,0));
}
.crumb { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.note-actions { display: flex; align-items: center; gap: 2px; }
.divider-v { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.save-state { font-size: 12px; color: var(--muted); margin-right: 8px; min-width: 62px; text-align: right; }
.save-state.saving { color: var(--orange); }
.save-state.saved { color: var(--accent); }

.note-title {
  width: 100%; border: none; outline: none; background: transparent;
  font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3;
  padding: 0; margin-bottom: 10px;
}
.note-title::placeholder { color: rgba(60,60,67,.26); font-weight: 500; }

.note-time { font-size: 12.5px; color: var(--muted); margin-bottom: 26px; }

.note-body {
  width: 100%; min-height: 380px; border: none; outline: none; resize: none;
  background: transparent; overflow: hidden;
  font-size: 15.5px; line-height: 1.85; color: var(--ink);
  letter-spacing: .005em; padding: 0 0 8px;
}
.note-body::placeholder { color: rgba(60,60,67,.28); }

.markdown { font-size: 15.5px; line-height: 1.85; color: var(--ink); }
.markdown h1 { font-size: 26px; margin: 30px 0 14px; letter-spacing: -.015em; }
.markdown h2 { font-size: 21px; margin: 26px 0 12px; }
.markdown h3 { font-size: 17px; margin: 22px 0 10px; }
.markdown h1:first-child, .markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown p { margin: 0 0 16px; }
.markdown ul, .markdown ol { margin: 0 0 16px; padding-left: 22px; }
.markdown li { margin: 4px 0; }
.markdown blockquote {
  margin: 0 0 16px; padding: 2px 0 2px 16px; border-left: 2px solid var(--line);
  color: var(--ink-2);
}
.markdown code {
  font-family: var(--mono); font-size: .88em; padding: 2px 5px; border-radius: 5px;
  background: rgba(118,118,128,.09); color: var(--ink-2);
}
.markdown pre {
  margin: 0 0 18px; padding: 16px 18px; border-radius: 12px; overflow-x: auto;
  background: #f9f9f9; border: 1px solid var(--line-soft);
}
.markdown pre code { background: none; padding: 0; color: var(--ink); font-size: 13.5px; }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 26px 0; }
.markdown a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(0,122,255,.35); }
.markdown table { border-collapse: collapse; margin-bottom: 16px; }
.markdown td, .markdown th { border: 1px solid var(--line); padding: 7px 12px; }
.markdown-empty { color: var(--muted); }

/* 代码块（预览）：语言标签 + 一键复制 ---------------------------- */
.code-block {
  margin: 0 0 18px; border-radius: 12px; overflow: hidden;
  background: #f9f9f9; border: 1px solid var(--line-soft);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line-soft);
  background: rgba(118,118,128,.06);
}
.code-lang {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em;
  color: var(--muted); text-transform: lowercase;
}
.code-copy {
  appearance: none; border: none; background: none; font: inherit; cursor: pointer;
  font-size: 11.5px; color: var(--muted); padding: 3px 9px; border-radius: 7px;
  transition: background .15s ease, color .15s ease;
}
.code-copy:hover { background: rgba(118,118,128,.14); color: var(--ink); }
.code-copy:focus-visible { outline: 2px solid rgba(0,122,255,.45); outline-offset: 1px; }
.code-copy.done { color: var(--accent); }
.code-block .code-pre {
  margin: 0; padding: 14px 18px 16px; border: none; border-radius: 0;
  background: none; overflow-x: auto;
}
.code-block .code-pre code { font-size: 13px; line-height: 1.7; color: var(--ink); }

/* 语法着色：低饱和，跟着暖白底走，不抢正文视觉 */
.tok-comment { color: #8e8e93; font-style: italic; }
.tok-string  { color: #248a3d; }
.tok-number  { color: #b2500e; }
.tok-keyword { color: #7b46c1; }
.tok-fn      { color: #0a6ed1; }
.tok-key     { color: #9a5b0c; }
.tok-attr    { color: #b2500e; }
.tok-tag     { color: #c9254d; }
.tok-var     { color: #248a3d; }

/* 附件 ------------------------------------------------------------ */
.attach { margin-top: 46px; padding-top: 26px; border-top: 1px solid var(--line-soft); }
.attach-head { display: flex; align-items: center; margin-bottom: 14px; }
.attach-head h3 {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.attach-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: rgba(118,118,128,.10); color: var(--ink-2); font-size: 11px; letter-spacing: 0;
}
.attach-actions { margin-left: auto; }

.dropzone {
  margin-top: 12px; padding: 22px; text-align: center;
  border: 1px dashed rgba(60,60,67,.20); border-radius: var(--radius);
  color: var(--muted); font-size: 13px;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.dropzone.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.attach-list { display: flex; flex-direction: column; gap: 8px; }

.att-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fafafa; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.att-item:hover { border-color: rgba(60,60,67,.18); box-shadow: var(--shadow-s); background: #fff; }
.att-icon {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(118,118,128,.08); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.att-icon.is-image { background: rgba(52,199,89,.13); color: var(--accent); }
.att-icon.is-pdf { background: rgba(255,59,48,.10); color: var(--danger); }
.att-icon.is-doc { background: rgba(0,122,255,.10); color: #0a6ed1; }
.att-icon.is-sheet { background: rgba(52,199,89,.11); color: #248a3d; }
.att-icon.is-media { background: rgba(175,82,222,.12); color: #8944ab; }
.att-icon.is-zip { background: rgba(255,149,0,.13); color: #b2500e; }
.att-main { flex: 1; min-width: 0; }
.att-name {
  display: block; font-size: 13.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.att-ops { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .16s ease; }
.att-item:hover .att-ops, .att-item:focus-within .att-ops { opacity: 1; }

.upload-queue { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.up-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px dashed var(--line); border-radius: var(--radius); }
.up-bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(118,118,128,.10); overflow: hidden; }
.up-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .2s ease; }
.up-pct { font-size: 12px; color: var(--muted); width: 40px; text-align: right; font-variant-numeric: tabular-nums; }

.drop-mask {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(242,242,247,.78); backdrop-filter: blur(2px);
  /* 关键：遮罩只是个提示，绝不能吃掉拖拽事件。
     它在 #content 之外，一旦参与命中测试，dragover/drop 就不会冒泡到 #content，
     那句 preventDefault() 不执行，浏览器就会走默认行为——把文件打开/下载掉。 */
  pointer-events: none;
}
.drop-mask-inner {
  padding: 46px 66px; border: 1.5px dashed var(--accent); border-radius: 22px;
  background: rgba(255,255,255,.9); color: var(--accent); font-size: 15px; font-weight: 500;
}

/* 弹窗 ------------------------------------------------------------ */
.modal-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.modal-mask {
  position: absolute; inset: 0; pointer-events: auto;
  background: rgba(0,0,0,.26); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 560px; max-width: 100%; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-l);
  animation: pop .24s cubic-bezier(.2,.7,.3,1) both; overflow: hidden;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; flex: none;
}
.modal-head h2 { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 18px 24px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 24px; border-top: 1px solid var(--line-soft); background: #f9f9f9; flex: none;
}

.tabs { display: flex; gap: 4px; padding: 14px 24px 0; }
.tab {
  padding: 7px 12px; border-radius: 8px; font-size: 13.5px; color: var(--muted); font-weight: 500;
  transition: background .16s ease, color .16s ease;
}
.tab:hover { color: var(--ink-2); }
.tab.active { background: rgba(118,118,128,.08); color: var(--ink); }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.7; }
.hint.warn { color: #b2500e; }

.section-title {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  margin: 22px 0 10px;
}

.backup-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.backup-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .16s ease, background .16s ease;
}
.backup-item:hover { border-color: rgba(60,60,67,.18); background: #fafafa; }
.bi-main { flex: 1; min-width: 0; }
.bi-title { font-size: 13.5px; font-weight: 500; }
.bi-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.bi-ops { display: flex; gap: 2px; }
.empty-inline { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: var(--radius); }

.restore-drop {
  padding: 20px; border: 1px dashed rgba(60,60,67,.20); border-radius: var(--radius);
  text-align: center; color: var(--muted); font-size: 13px;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
.restore-drop.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.viewer {
  position: absolute; inset: 0; pointer-events: auto;
  background: rgba(0,0,0,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fade .2s ease both;
  padding: 32px;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.viewer pre {
  max-width: 900px; max-height: 100%; width: 100%; overflow: auto;
  background: #1c1c1e; color: #e5e5ea; padding: 24px 28px; border-radius: 14px;
  font-family: var(--mono); font-size: 13px; line-height: 1.7; margin: 0;
}
.viewer-bar {
  position: absolute; top: 20px; right: 24px; display: flex; align-items: center; gap: 8px;
}
.viewer-bar .icon-btn { color: #fff; background: rgba(255,255,255,.12); }
.viewer-bar .icon-btn:hover { background: rgba(255,255,255,.22); }
.viewer-name { color: rgba(255,255,255,.8); font-size: 13px; margin-right: 8px; }

/* 手动保存反馈 ---------------------------------------------------- */
/* 只在 Ctrl/⌘+S 时出现；打字时的自动保存不打扰 */
.save-flash {
  position: fixed; top: 20px; left: 50%;
  /* 居中必须落在基础样式里：以前只靠 flashIn/flashOut 的动画帧撑着，
     退场时 .show 被移除的瞬间底层 transform 变回 none，卡片会右跳半个宽度再飘回来 */
  transform: translateX(-50%);
  z-index: 90;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 17px 9px 11px; border-radius: 15px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-m);
  pointer-events: none;
}
/* 入场动画单独放 .show：万一动画没跑起来，卡片也仍然可见，不会停在透明状态 */
.save-flash.show { animation: flashIn .26s cubic-bezier(.2,.8,.2,1) both; }
.save-flash .sf-chip {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  animation: chipPop .34s cubic-bezier(.2,.9,.25,1) both;
}
.save-flash.is-idle .sf-chip { background: rgba(118,118,128,.08); color: var(--ink-2); }
.save-flash .sf-chip svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.sf-main { display: flex; flex-direction: column; gap: 1px; }
.sf-title { font-size: 13.5px; font-weight: 600; color: var(--ink); letter-spacing: -.005em; }
.sf-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.save-flash.out { animation: flashOut .28s ease both; }

@keyframes flashIn {
  from { opacity: 0; transform: translate(-50%, -14px) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes flashOut {
  /* 显式写 from：起点锁定在居中位，不依赖底层 transform（防右跳） */
  from { opacity: 1; transform: translate(-50%, 0) scale(1); }
  to { opacity: 0; transform: translate(-50%, -10px) scale(.98); }
}
@keyframes chipPop {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

/* 提示条 ---------------------------------------------------------- */
.toast-root {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 11px; font-size: 13.5px;
  background: rgba(28,28,30,.92); color: #f9f9f9; box-shadow: 0 10px 34px rgba(0,0,0,.22);
  animation: toastIn .24s cubic-bezier(.2,.7,.3,1) both;
  display: flex; align-items: center; gap: 8px;
}
.toast.ok::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #34c759; }
.toast.err::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #ff6961; }
.toast.out { animation: toastOut .2s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* 屏幕正中的确认卡片：删除等操作收尾用，比底部提示条显眼得多 ---------- */
.toast-center {
  position: fixed; inset: 0; z-index: 110;   /* 高于 modal(80)/save-flash(90)/toast(100) */
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .05);
  opacity: 0; transition: opacity .2s ease;
  pointer-events: none;                      /* 只是提示，绝不能挡住点击 */
}
.toast-center.show { opacity: 1; }
.toast-center-card {
  display: flex; align-items: center; gap: 10px;
  max-width: min(78vw, 420px);
  padding: 15px 24px; border-radius: 15px;
  font-size: 15px; font-weight: 560; letter-spacing: .2px; line-height: 1.35;
  background: rgba(28, 28, 30, .93); color: #fff;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .28);
  transform: scale(.92); transition: transform .2s cubic-bezier(.2,.7,.3,1);
}
.toast-center.show .toast-center-card { transform: scale(1); }
.tcc-icon { display: flex; flex: none; width: 19px; height: 19px; }
.tcc-icon svg { width: 100%; height: 100%; }
.toast-center-card.ok .tcc-icon { color: #34c759; }
.toast-center-card.err .tcc-icon { color: #ff6961; }

/* 响应式 ---------------------------------------------------------- */
@media (max-width: 980px) {
  .sidebar { width: 250px; }
  .ni-title { font-size: 15px; }        /* 窄侧栏时略收，避免过早截断 */
  .note { padding: 22px 32px 100px; }
}

/* 手机：整屏单栏 -------------------------------------------------
   不做弹窗/抽屉，而是「列表页 / 详情页」两屏整页切换：
   · 弹窗里塞 textarea + 自增高很脆弱（隐藏元素 scrollHeight 为 0）；
   · 抽屉会让滚动容器嵌套，输入法弹起时高度难算；
   · 整页切换还能接住安卓的物理返回键 / 侧滑返回。
   由 .app[data-view] 决定当前显示哪一屏，切换逻辑在 app.js。      */
@media (max-width: 760px) {
  .app { flex-direction: column; }

  .sidebar, .content {
    width: 100%; height: 100%; min-height: 0;
    flex: 1 1 auto; border-right: none; border-bottom: none;
  }
  /* 一次只显示一屏；被隐藏的那个不占空间，可见的那个自然撑满 */
  .app[data-view="list"]   .content { display: none; }
  .app[data-view="detail"] .sidebar { display: none; }

  /* —— 列表页 —— */
  /* 卡片样式是两端共用的基础样式，这里只按手机尺寸放大一档 */
  .sb-head { padding: 12px 14px 10px; }
  .sb-search { margin: 0 12px 8px; }
  .sb-search-input { height: 40px; font-size: 16px; }  /* <16px iOS 聚焦会强制放大页面 */
  .sb-label { padding: 14px 16px 8px; }
  .note-list { padding: 0 12px 14px; overscroll-behavior: contain; }
  .note-item { padding: 13px 14px 12px; margin-bottom: 10px; border-radius: 13px; }
  .note-item.active::before { top: 14px; bottom: 14px; width: 3px; }
  .ni-title { font-size: 16px; }
  .ni-pin { width: 16px; height: 16px; }
  .ni-excerpt { font-size: 12.5px; }
  .ni-foot { margin-top: 9px; justify-content: space-between; }  /* 附件标签靠左、时间靠右 */
  .ni-foot time { margin-left: auto; }   /* 没附件时时间也不至于孤零零贴左 */
  .sb-foot { padding: 10px 12px; }

  /* —— 详情页 —— */
  .note { max-width: none; padding: 12px 16px 80px; }
  .note-top {
    height: 46px; margin-bottom: 16px;
    background: var(--surface);        /* 手机上不用渐变，滚起来不会糊 */
  }
  .crumb { display: none; }            /* 返回键取代面包屑 */
  .m-back { display: inline-flex; }
  .save-state { min-width: 0; margin-right: 2px; font-size: 11.5px; }
  .note-title { font-size: 22px; margin-bottom: 8px; }
  .note-time { font-size: 12px; margin-bottom: 18px; }
  /* 16px 起，避免 iOS 聚焦缩放；min-height 也要跟着 app.js 的 autosize 下限 */
  .note-body { font-size: 16px; line-height: 1.8; min-height: 160px; }
  .markdown { font-size: 16px; }
  .markdown h1 { font-size: 23px; }
  .markdown h2 { font-size: 19.5px; }
  .markdown h3 { font-size: 16.5px; }
  .attach { margin-top: 34px; padding-top: 20px; }
  .dropzone { display: none; }         /* 手机没有拖拽，留着纯占位 */
  .att-ops { opacity: 1; }             /* 没有 hover，操作按钮常显 */

  /* —— 弹窗 / 浮层：贴底、留安全区 —— */
  .modal-mask { padding: 14px; align-items: flex-end; }
  .modal { max-height: 88vh; max-height: 88dvh; border-radius: 18px; }
  .modal-head { padding: 18px 18px 0; }
  .modal-body { padding: 16px 18px 20px; }
  .modal-foot { padding: 12px 18px; }
  .tabs { padding: 12px 18px 0; overflow-x: auto; }
  .viewer { padding: 14px; }
  .viewer-bar { top: 12px; right: 14px; }
  .toast-root { bottom: 26px; }
  .empty { padding: 24px; }
}

/* 超窄屏（≤360px）：顶栏再收一档，避免操作按钮被挤出 */
@media (max-width: 360px) {
  .save-state { display: none; }
  .note-actions { gap: 0; }
  .note { padding: 10px 12px 72px; }
  .note-title { font-size: 20px; }
}

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