/* 笔记页：Memos 式时间线。全部样式挂在 #notes-page 下，避免污染全局；只用 style.css 设计令牌。
   N5：正文（标题/引用/代码/列表/表格/任务清单/链接/图片）的排版统一交给 notes-rich.css，
   与所见即所得编辑器共用同一套样式；本文件只负责页面骨架、卡片、表单、按钮、状态。 */
#notes-page .notes-wrap { display: grid; gap: var(--space-5); max-width: 860px; margin: 0 auto; padding: var(--space-2) 0 var(--space-8); }

/* ── 三栏：标签 | 列表 | 编辑区；按笔记区宽度在三栏 / 两栏 / 一栏之间切换（见下面的容器查询）；一栏时点开后编辑区占满（data-pane-open） ── */
#notes-page .notes-wrap.notes-workspace { max-width: 1360px; }
#notes-page .notes-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
#notes-page .notes-layout { display: grid; gap: var(--space-4); align-items: start; }
#notes-page .notes-rail { display: grid; gap: var(--space-2); min-width: 0; }
#notes-page .notes-rail-title { display: none; margin: 0; color: var(--ink-2); font-size: var(--text-xs); font-weight: 600; letter-spacing: .08em; }
#notes-page .notes-col { display: grid; gap: var(--space-3); min-width: 0; }
#notes-page .notes-col-head { display: flex; gap: var(--space-2); align-items: center; }
#notes-page .notes-col-head .notes-search { flex: 1 1 auto; min-width: 0; }
#notes-page .notes-new-menu { position: relative; flex: 0 0 auto; }
#notes-page .notes-new-button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--space-4); border: 1px solid var(--accent); border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent); font-size: var(--text-sm); font-weight: 600; list-style: none; cursor: pointer; white-space: nowrap; }
#notes-page .notes-new-button::-webkit-details-marker { display: none; }
#notes-page .notes-new-button:focus-visible { outline: 3px solid var(--azurite); outline-offset: 2px; }
#notes-page .notes-new-options { position: absolute; right: 0; z-index: 5; display: grid; min-width: 168px; margin-top: var(--space-1); padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); box-shadow: 0 var(--space-2) var(--space-5) rgba(var(--shadow-rgb), .14); }
#notes-page .notes-new-option { min-height: 40px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-size: var(--text-sm); text-align: left; }
#notes-page .notes-new-option:hover:not(:disabled), #notes-page .notes-new-option:focus-visible { background: var(--paper-2); transform: none; }
#notes-page .notes-pane { display: grid; gap: var(--space-3); min-width: 0; }
#notes-page .notes-pane-bar { display: none; align-items: center; gap: var(--space-3); }
#notes-page .notes-pane-back { min-height: 44px; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font-size: var(--text-sm); }
#notes-page .notes-pane-label { min-width: 0; overflow: hidden; color: var(--ink-2); font-size: var(--text-sm); text-overflow: ellipsis; white-space: nowrap; }
#notes-page .notes-pane-note[hidden], #notes-page .notes-composer[hidden] { display: none; }
#notes-page .notes-template-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
#notes-page .notes-template-label { color: var(--ink-2); font-size: var(--text-xs); }

/* 按笔记区实际有多宽来排（容器查询），不按整个窗口：左边侧栏会吃掉一块，
   1024px 的窗口里笔记区只剩 780px 左右，三栏会把右边编辑区挤成一条。
   宽 ≥ 1040：标签 / 列表 / 右侧 三栏；700–1039：标签变成列表上方一排可横滑的小标签，列表 + 右侧两栏；< 700：一栏，右侧盖在列表上（手机同款）。 */
#notes-page { container: notes-page / inline-size; }
@container notes-page (min-width: 700px) {
  #notes-page .notes-pane { position: sticky; top: calc(64px + var(--space-3)); max-height: calc(100dvh - 64px - var(--space-6)); overflow-y: auto; padding: var(--space-5) var(--space-6); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  #notes-page .notes-pane .notes-composer { padding: 0; border: 0; background: transparent; }
  #notes-page .notes-col .notes-list { max-height: calc(100dvh - 64px - 140px); overflow-y: auto; padding-right: var(--space-1); }
}
@container notes-page (min-width: 1040px) {
  #notes-page .notes-layout { grid-template-columns: minmax(120px, 160px) minmax(240px, 320px) minmax(0, 1fr); }
  #notes-page .notes-rail { position: sticky; top: calc(64px + var(--space-3)); }
  #notes-page .notes-rail-title { display: block; }
  #notes-page .notes-rail .notes-tag-row { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
  #notes-page .notes-rail .notes-chip { text-align: left; border-radius: var(--radius-sm); }
}
@container notes-page (min-width: 700px) and (max-width: 1039px) {
  #notes-page .notes-layout { grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); grid-template-rows: auto 1fr; }
  #notes-page .notes-rail { grid-column: 1; grid-row: 1; }
  #notes-page .notes-col { grid-column: 1; grid-row: 2; }
  #notes-page .notes-pane { grid-column: 2; grid-row: 1 / span 2; }
  #notes-page .notes-col .notes-list { max-height: calc(100dvh - 64px - 200px); }
}
@container notes-page (max-width: 1039px) {
  #notes-page .notes-rail .notes-tag-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: var(--space-1); }
  #notes-page .notes-rail .notes-chip { flex: 0 0 auto; }
}
@container notes-page (max-width: 699px) {
  #notes-page .notes-layout[data-pane-open="false"] .notes-pane { display: none; }
  #notes-page .notes-layout[data-pane-open="true"] .notes-rail,
  #notes-page .notes-layout[data-pane-open="true"] .notes-col { display: none; }
  #notes-page .notes-pane-bar { display: flex; }
}


#notes-page .notes-head h2 { margin: 0; font: 500 clamp(22px, 3vw, 30px)/var(--lh-heading) var(--serif); }
#notes-page .notes-sub { margin: var(--space-2) 0 0; color: var(--ink-2); font-size: var(--text-sm); line-height: var(--lh-prose); }

/* ── composer（新建区） ── */
#notes-page .notes-composer { display: grid; gap: var(--space-3); padding: var(--space-5) var(--space-6); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
#notes-page .notes-composer-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
#notes-page .notes-field { display: block; min-width: 0; }
#notes-page .notes-content-field { display: grid; gap: var(--space-2); }
#notes-page .notes-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#notes-page #notes-content { width: 100%; min-height: 120px; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font-size: var(--text-base); line-height: var(--lh-prose); resize: vertical; }
#notes-page #notes-content:focus { outline: 2px solid var(--azurite); outline-offset: 1px; }
#notes-page #notes-content[hidden] { display: none; }
#notes-page .notes-tags-field { flex: 1 1 220px; }
#notes-page #notes-tags-input { width: 100%; min-height: 40px; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
#notes-page #notes-tags-input:focus, #notes-page .notes-edit-title:focus, #notes-page .notes-edit-tags:focus { outline: 2px solid var(--azurite); outline-offset: 1px; }
#notes-page .notes-problem-field { flex: 1 1 180px; }
#notes-page #notes-problem { width: 100%; min-height: 40px; padding: 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
#notes-page #notes-save { min-height: 40px; padding: 0 var(--space-5); }
#notes-page .notes-notice { margin: 0; color: var(--danger); font-size: var(--text-sm); }
#notes-page .notes-notice[hidden] { display: none; }

/* ── 工具栏：搜索 + 标签筛选 ── */
#notes-page .notes-toolbar { display: grid; gap: var(--space-3); }
#notes-page .notes-search { display: block; }
#notes-page #notes-search { width: 100%; min-height: 40px; padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); }
#notes-page #notes-search:focus { outline: 2px solid var(--azurite); outline-offset: 1px; }
#notes-page .notes-tag-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
#notes-page .notes-chip { min-height: 32px; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--paper-2); color: var(--ink-2); font-size: var(--text-sm); cursor: pointer; }
#notes-page .notes-chip.is-active { border-color: var(--azurite); background: var(--soft); color: var(--ink); font-weight: 600; }
#notes-page .notes-chip-sm { min-height: 28px; font-size: var(--text-xs); }

/* ── 列表：一篇一行（标题 / 两行预览 / 时间与标签），点开在右边编辑 ── */
#notes-page .notes-list { display: grid; gap: var(--space-1); }
#notes-page .notes-card { border: 1px solid transparent; border-radius: var(--radius-sm); }
#notes-page .notes-card.is-current { border-color: var(--azurite); background: var(--soft); }
#notes-page .notes-card-open { display: grid; gap: 2px; width: 100%; min-height: 44px; padding: var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-weight: 400; text-align: left; cursor: pointer; }
#notes-page .notes-card-open:hover:not(:disabled) { background: var(--paper-2); transform: none; }
#notes-page .notes-card.is-current .notes-card-open:hover:not(:disabled) { background: transparent; }
#notes-page .notes-card-open:focus-visible { outline: 3px solid var(--azurite); outline-offset: -3px; }
#notes-page .notes-card-title { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: var(--text-md); color: var(--ink); }
#notes-page .notes-card-title strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
#notes-page .notes-pin { flex: none; font-size: var(--text-sm); line-height: 1; }
#notes-page .notes-card-preview { display: -webkit-box; overflow: hidden; color: var(--ink-2); font-size: var(--text-sm); line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
#notes-page .notes-card-preview:empty { display: none; }
#notes-page .notes-card-foot { display: flex; flex-wrap: wrap; gap: var(--space-2); color: var(--ink-2); font-size: var(--text-xs); }
#notes-page .notes-time { flex: none; color: var(--ink-2); font-size: var(--text-xs); white-space: nowrap; }
#notes-page .notes-card-problem { overflow: hidden; max-width: 12em; text-overflow: ellipsis; white-space: nowrap; }
#notes-page .notes-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
#notes-page .notes-action { min-height: 36px; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); font-size: var(--text-sm); cursor: pointer; }
#notes-page .notes-action.is-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── 编辑区里的一篇：标题 + 操作、标签与关联题、目录、正文 ── */
#notes-page .notes-pane-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
#notes-page .notes-pane-head .notes-edit-title { flex: 1 1 16rem; min-width: 0; min-height: 48px; border-color: transparent; background: transparent; font: 500 clamp(20px, 2.2vw, 26px)/1.3 var(--serif); }
#notes-page .notes-pane-head .notes-edit-title:hover { border-color: var(--line); }
#notes-page .notes-pane-tools { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: var(--space-2); }
#notes-page .notes-pane-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
#notes-page .notes-pane-meta .notes-edit-tags { flex: 1 1 14rem; min-width: 0; }
#notes-page .notes-pane-toc[hidden] { display: none; }
#notes-page .notes-toc > summary { min-height: 36px; color: var(--ink-2); font-size: var(--text-sm); cursor: pointer; }
#notes-page .notes-toc ol { display: grid; gap: 2px; margin: var(--space-1) 0 0; padding: 0; list-style: none; }
#notes-page .notes-toc button { width: 100%; min-height: 36px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-size: var(--text-sm); text-align: left; }
#notes-page .notes-toc button:hover:not(:disabled) { background: var(--paper-2); transform: none; }
#notes-page .notes-toc .notes-toc-l2 button { padding-left: var(--space-4); }
#notes-page .notes-toc .notes-toc-l3 button { padding-left: var(--space-6); }
#notes-page .notes-pane .notes-edit-body { max-width: 72ch; }

/* ── 原地编辑 ── */
#notes-page .notes-editor { display: grid; gap: var(--space-2); }
#notes-page .notes-edit-body { min-width: 0; }
#notes-page .notes-edit-title, #notes-page .notes-edit-tags { min-height: 40px; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
#notes-page .notes-edit-content { width: 100%; min-height: 160px; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font-size: var(--text-base); line-height: var(--lh-prose); resize: vertical; }
#notes-page .notes-edit-content:focus { outline: 2px solid var(--azurite); outline-offset: 1px; }
#notes-page .notes-editor-row { display: flex; gap: var(--space-2); }

/* ── 状态与分页 ── */
#notes-page .notes-status { margin: 0; padding: var(--space-5) var(--space-4); color: var(--ink-2); font-size: var(--text-sm); text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
#notes-page .notes-status[hidden] { display: none; }
#notes-page .notes-foot { display: flex; justify-content: center; }
#notes-page #notes-more { min-height: 40px; padding: 0 var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); cursor: pointer; }
#notes-page #notes-more[hidden] { display: none; }

/* ---------------- 悬停反馈仅在精确指针设备上启用 ---------------- */
@media (hover: hover) and (pointer: fine) {
  #notes-page .notes-chip:hover { border-color: var(--azurite); color: var(--ink); }
  #notes-page .notes-action:hover { border-color: var(--azurite); color: var(--ink); }
  #notes-page #notes-more:hover { border-color: var(--azurite); }
}

/* ---------------- 手机宽度：收紧留白，表单纵向堆叠 ---------------- */
@media (max-width: 520px) {
  #notes-page .notes-wrap { gap: var(--space-4); padding: var(--space-2) 0 var(--space-6); }
  #notes-page .notes-composer { padding: var(--space-4); gap: var(--space-3); }
  #notes-page .notes-card { padding: var(--space-4); }
  #notes-page .notes-composer-row { flex-direction: column; align-items: stretch; }
  #notes-page .notes-tags-field, #notes-page .notes-problem-field { flex: 1 1 auto; }
  #notes-page #notes-save { width: 100%; }
  #notes-page .notes-editor-row { flex-direction: row; }
  #notes-page .notes-card-head { align-items: flex-start; }
}

/* ---------------- 动效仅在用户未要求减少动态时播放 ---------------- */
@media (prefers-reduced-motion: no-preference) {
  #notes-page .notes-chip, #notes-page .notes-action, #notes-page #notes-more, #notes-page .notes-card { transition: border-color var(--motion-fast) var(--motion-ease), color var(--motion-fast) var(--motion-ease), background var(--motion-fast) var(--motion-ease); }
}

/* 搜索命中：列表里的标题/片段和打开后的正文，荧光笔同色；当前命中加一道下划线。 */
#notes-page mark.notes-search-hit {
  padding: 0 .1em;
  border-radius: var(--radius-xs, 4px);
  background: color-mix(in srgb, var(--gamboge) 38%, transparent);
  color: var(--ink);
}
#notes-page mark.notes-search-hit.is-current { box-shadow: 0 2px 0 var(--accent); }
#notes-page .notes-card-preview.is-snippet { -webkit-line-clamp: 3; }

/* 编辑时“看效果”：正文下面的排版预览，和阅读视图同一套样式，用虚线框和编辑区分开。 */
#notes-page .notes-edit-preview { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--paper-2, var(--surface)); }
#notes-page .notes-edit-preview[hidden] { display: none; }
#notes-page .notes-preview-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); }
