/*
 * Nota 的网页。宽屏是侧栏(收件箱、最近、文件夹树)+ 主区;手机上(< 900px)一层一层往里走:首页是
 * 侧栏,其余页面占满整屏、顶栏带返回,和系统的「文件」一样。
 *
 * 样子(Note UI 设计稿,2026-10-23 定):暖色的纸。象牙白的底、暖灰的字和线、读的时候一张白纸;标题
 * 用衬线,界面用系统无衬线;主按钮是墨色,只有「要你处理」的地方用一点赤陶色。字体全用系统自带的,
 * 不从别处下载。颜色跟随系统的浅色 / 深色。
 *
 * 手机上的几条(sites/nodal-web 踩过的):输入框在触屏上 16px,不然 Safari 聚焦时放大整页;顶栏让出
 * 状态栏(safe-area-inset-top);编辑页按 visualViewport 摆(js/viewport.js),键盘弹起时不把整页推走。
 */

:root {
  --bg: #FAF9F5;
  --side: #F5F4ED;
  --surface: #FFFFFF;
  --surface-2: #F0EEE6;
  --hover: rgba(115, 114, 108, 0.1);
  --selected: rgba(115, 114, 108, 0.16);
  --text: #1F1E1D;
  --text-2: #3D3D3A;
  --muted: #73726C;
  --faint: #B0AEA5;
  --line: rgba(31, 30, 29, 0.12);
  --line-strong: rgba(31, 30, 29, 0.22);
  --ink: #1F1E1D;
  --on-ink: #FAF9F5;
  --attention: #9C4421;
  --attention-soft: #F5E6DD;
  --ok: #4D7A3A;
  --danger: #B3261E;
  --radius: 12px;
  --sidebar: 280px;
  --serif: ui-serif, "New York", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", system-ui, "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --vv-height: 100dvh;
  --vv-top: 0px;
  color-scheme: light dark;
  /* 渲染库的变量:正文背景跟着所在的纸,不画自己的底色。 */
  --chat-background: transparent;
  --chat-link-color: var(--text);
  --markdown-font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624;
    --side: #1F1E1D;
    --surface: #30302E;
    --surface-2: #3D3D3A;
    --hover: rgba(250, 249, 245, 0.06);
    --selected: rgba(250, 249, 245, 0.11);
    --text: #F5F4ED;
    --text-2: #DEDCD1;
    --muted: #B0AEA5;
    --faint: #73726C;
    --line: rgba(250, 249, 245, 0.1);
    --line-strong: rgba(250, 249, 245, 0.2);
    --ink: #F5F4ED;
    --on-ink: #1F1E1D;
    --attention: #EBA488;
    --attention-soft: rgba(217, 119, 87, 0.18);
    --ok: #9DC08B;
    --danger: #F2B8B5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* `hidden` 要赢过组件自己的 display(口令那一行是 flex)。 */
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* 三个点是三段零长的线,圆头画成圆点:线宽就是点的直径。 */
.icon.icon-more { width: 22px; height: 22px; stroke-width: 3; }

/* ---------- 按钮与输入 ---------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.button:disabled { opacity: 0.5; cursor: default; }
.button.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.button.ghost { background: transparent; border-color: transparent; color: var(--text); }
.button.small { min-height: 32px; padding: 0 11px; font-size: 13px; }
.button .icon { width: 16px; height: 16px; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer;
}
.icon-button.small { width: 28px; height: 28px; }
.icon-button.small .icon { width: 15px; height: 15px; }
.input, .textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; padding: 9px 12px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--text-2); box-shadow: 0 0 0 3px var(--hover); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px;
  background: var(--attention-soft); color: var(--attention); font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* 悬停只给有鼠标的设备:触屏上 :hover 在点过之后一直留着,像按钮卡住了。触屏用按下时的样子。 */
@media (hover: hover) {
  .button:hover { background: var(--hover); }
  .button.primary:hover { opacity: 0.88; background: var(--ink); }
  .icon-button:hover, .tree-toggle:hover { background: var(--hover); }
  .search-link:hover, .nav-link:hover, .tree-link:hover, .file-row:hover, .folder-row:hover, .revision-row:hover, .hit:hover { background: var(--hover); }
  .sheet-item:hover, .picker-item:hover { background: var(--hover); }
  .crumb:hover, .back:hover { color: var(--text); }
}
.button:active, .icon-button:active, .sheet-item:active, .nav-link:active, .tree-link:active, .search-link:active, .file-main:active, .folder-row:active { opacity: 0.6; }

/* ---------- 启动、空状态、提示 ---------- */

.boot, .state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 40vh; padding: 32px 24px; text-align: center; }
.boot { min-height: 100dvh; }
.state p { max-width: 440px; margin: 0; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--text-2); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font: 14px/1.5 var(--sans); }
.form-error { margin: 12px 0 0; color: var(--danger); }
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 11px 16px; border-radius: 10px; background: var(--ink); color: var(--on-ink); font-size: 14px; text-align: center; box-shadow: 0 8px 24px rgba(31, 30, 29, 0.18); }

/* ---------- 登录 ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); }
.login-card { width: min(100%, 380px); text-align: center; }
.login-card h1 { font: 500 30px/1.2 var(--serif); margin: 14px 0 6px; }
.login-mark { border-radius: 14px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; text-align: left; }
.login-form label { font-size: 13px; color: var(--muted); }
.login-form .button { margin-top: 6px; min-height: 44px; }
.input.code { letter-spacing: 0.3em; font-size: 20px; text-align: center; }

/* ---------- 外框 ---------- */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 2px;
  padding: calc(14px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  border-right: 1px solid var(--line); background: var(--side); overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; padding: 2px 8px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font: 500 20px/1 var(--serif); }
.brand img { border-radius: 6px; }
.search-link {
  display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px; margin-bottom: 10px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 14px;
}
.search-link .icon { width: 16px; height: 16px; }
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-link, .tree-link {
  display: flex; align-items: center; gap: 9px; min-height: 32px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: 14px;
}
.nav-link .icon, .tree-link .icon { width: 17px; height: 17px; color: var(--muted); }
.nav-link.current, .tree-row.current .tree-link { background: var(--selected); color: var(--text); font-weight: 600; }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: var(--muted); font-weight: 400; }
.nav-badge { font-size: 12px; font-weight: 600; color: var(--attention); }
.folders { flex: 1; margin-top: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 4px 10px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.tree { display: flex; flex-direction: column; gap: 1px; }
.tree-row { display: flex; align-items: center; padding-left: calc(var(--depth) * 14px); }
.tree-row .tree-link { flex: 1; min-width: 0; padding-left: 4px; }
.tree-toggle, .tree-toggle-spacer { flex: none; width: 22px; height: 28px; }
.tree-toggle { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.tree-toggle .icon { width: 14px; height: 14px; }
/* 宽屏的树不写数字:数字在文件夹页里。 */
.tree .nav-count { display: none; }
.drop-over { background: var(--selected) !important; box-shadow: inset 0 0 0 1.5px var(--text-2); }
.nav-empty { margin: 0; padding: 2px 10px 8px; font-size: 13px; line-height: 1.5; }
.sidebar-foot { display: flex; flex-direction: column; gap: 1px; padding-top: 10px; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 0; }
.account-email { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; }

/* ---------- 页面 ---------- */

.page { max-width: 1100px; margin: 0 auto; padding: 0 40px 56px; }
.page.reading { max-width: 860px; }
.page-head {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 12px;
  padding: calc(22px + env(safe-area-inset-top)) 0 14px; background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.back, .back-spacer { display: none; }
.page-title { min-width: 0; }
.page-title h1 { font: 500 28px/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-subtitle { margin: 3px 0 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 2px; font-size: 13px; color: var(--muted); }
.crumb { color: var(--muted); }
.crumb-sep { color: var(--faint); }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding-bottom: 2px; }
.page-body { padding-top: 6px; }
.more { display: flex; margin: 16px auto 0; }

/* ---------- 一列文件 ---------- */

.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list + .list, .bulk + .list, .folders-list + .state { margin-top: 14px; }
.group-label { padding: 10px 14px 4px 46px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--line); }
.group:first-child .group-label { border-top: 0; }
.group + .group .group-label { border-top: 1px solid var(--line); }
.file-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 84px 104px 112px; align-items: center; gap: 12px;
  min-height: 46px; padding: 0 14px; border-bottom: 1px solid var(--line);
}
.files:has(.col-place) .file-row { grid-template-columns: 28px minmax(0, 1fr) 84px minmax(0, 0.6fr) 104px 112px; }
.file-row:last-child, .group .file-row:last-child { border-bottom: 0; }
.file-row:has(.trash-tail) { grid-template-columns: minmax(0, 1fr) 84px minmax(0, 0.6fr) 104px 112px auto; }
.file-row.selected { background: var(--selected); }
.check { display: flex; align-items: center; justify-content: center; height: 100%; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.file-main { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 0; }
.file-main .icon { color: var(--muted); }
.file-text { display: flex; flex-direction: column; min-width: 0; }
.file-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 宽屏上这几样在各自的列里,不在标题下面重复。 */
.files .file-sub { display: none; }
.col { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-tail { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.folder-row { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.folder-row:last-child { border-bottom: 0; }
.folder-row .icon { color: var(--muted); }
.folder-row .file-title { flex: 1; }
.folder-row .icon:last-child { width: 15px; height: 15px; color: var(--faint); }

.bulk {
  position: sticky; top: 92px; z-index: 4; display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px 0 14px;
  border-radius: var(--radius); background: var(--ink); color: var(--on-ink);
}
.bulk-count { font-weight: 600; margin-right: 10px; }
.bulk-action { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: inherit; font-size: 13px; cursor: pointer; }
.bulk-action .icon { width: 15px; height: 15px; }
.bulk-action:hover { background: rgba(127, 127, 127, 0.2); }
.bulk-hint { flex: 1; text-align: right; font-size: 12px; opacity: 0.6; margin-right: 6px; }
.bulk-clear { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: inherit; cursor: pointer; }

/* 收件箱:一行文件,下面(宽屏在右边)是 Agent 的建议。 */
/* 建议那一栏定宽:每一行各是一个网格,宽度不定的话前面几列就对不齐。 */
.inbox-item { display: grid; grid-template-columns: minmax(0, 1fr) 400px; align-items: center; border-bottom: 1px solid var(--line); }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item .file-row { border-bottom: 0; grid-template-columns: 28px minmax(0, 1fr) 84px 104px; }
.inbox-item .col-source { display: none; }
.suggestion { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 6px 14px; font-size: 13px; min-width: 0; }
.suggestion-path { display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--text-2); overflow: hidden; white-space: nowrap; }
.suggestion-path > span:not(.tag) { overflow: hidden; text-overflow: ellipsis; }
.suggestion.none { justify-content: space-between; }
.suggestion-path .icon { width: 15px; height: 15px; color: var(--muted); }

.revision-row, .hit { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.revision-row:last-child, .hit:last-child { border-bottom: 0; }
.revision-number { width: 34px; font-weight: 600; color: var(--text-2); }
.hit .icon { color: var(--muted); }
.snippet { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }

/* ---------- 整理建议 ---------- */

.tidy-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin-bottom: 14px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.tidy-card-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 17px; background: var(--surface-2); color: var(--text-2); flex: none; }
.tidy-card-text { display: flex; flex-direction: column; flex: 1 1 260px; min-width: 0; font-size: 14px; }
.tidy-card-title { font-weight: 600; }
.tidy-card-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.tidy-card-go { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; font-size: 14px; }
.tidy-card-go .icon { width: 16px; height: 16px; }

.page.tidy { max-width: 920px; }
.tidy-summary { margin: 0 0 4px; font: 500 17px/1.5 var(--serif); }
.tidy-note { margin: 0 0 16px; font-size: 14px; }
.tidy-section { margin-bottom: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.tidy-section.confirm { border-color: color-mix(in srgb, var(--attention) 40%, transparent); }
.tidy-section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tidy-section-head h2 { font-size: 15px; font-weight: 600; }
.tidy-section-head .muted { font-size: 13px; flex: 1 1 300px; }
.tidy-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tidy-row:last-child { border-bottom: 0; }
.tidy-row.off .tidy-text { opacity: 0.55; }
.tidy-check { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--ink); flex: none; cursor: pointer; }
.tidy-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tidy-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.tidy-line .icon { width: 15px; height: 15px; color: var(--muted); }
.tidy-reason { font-size: 13px; color: var(--muted); }
.tidy-status { flex: none; font-size: 12px; font-weight: 600; white-space: nowrap; padding-top: 2px; }
.tidy-status.applied, .tidy-status.undone { color: var(--ok); }
.tidy-status.skipped, .tidy-status.kept { color: var(--attention); }
.tidy-banner { justify-content: space-between; }
.tidy-bar {
  position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 4; display: flex; align-items: center; gap: 12px;
  margin-top: 8px; padding: 10px 10px 10px 16px; border-radius: var(--radius); background: var(--ink); color: var(--on-ink);
  box-shadow: 0 10px 30px rgba(31, 30, 29, 0.2);
}
.tidy-bar-hint { flex: 1; font-size: 12px; opacity: 0.65; }
.tidy-apply { background: var(--on-ink); border-color: var(--on-ink); color: var(--ink); font-weight: 600; }

/* ---------- 读:一张纸 ---------- */

/*
 * 读的时候是一张白纸:衬线正文、舒展的行距,不给区块加框、不贴标签。渲染库的变量(--md-*)在这里
 * 收小一号 —— 它的默认值是给聊天气泡里的长回答定的。
 */
.paper {
  margin-top: 4px; padding: 44px 56px 52px; border-radius: 4px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(31, 30, 29, 0.06), 0 12px 32px rgba(31, 30, 29, 0.05);
}
.paper-meta { margin: 0 0 22px; font-size: 13px; color: var(--muted); }
.revision-title { font: 500 22px/1.3 var(--serif); margin: 0 0 14px; }
.note-body { display: flex; flex-direction: column; }
.md-body {
  --md-h1-size: 1.35em;
  --md-h2-size: 1.16em;
  --md-h3-size: 1.04em;
  --md-h4-size: 1em;
  --md-heading-weight: 600;
  --md-heading-line-height: 1.35;
  --md-body-line-height: 1.85;
  --md-paragraph-margin: 0.7em;
  --md-list-indent: 1.35em;
  --md-list-item-margin: 0.2em;
  --md-code-radius: 8px;
  font: 17px/1.85 var(--serif); color: var(--text); overflow-wrap: anywhere;
}
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body :is(h1, h2, h3, h4) { margin: 1.5em 0 0.45em; font-family: var(--serif); }
.md-body :is(h1, h2, h3, h4) + :is(ul, ol, p) { margin-top: 0.2em; }
.md-body > :is(h1, h2, h3, h4):first-child { margin-top: 0.2em; }
.md-body :is(table, th, td) { font-family: var(--sans); font-size: 14px; }
.md-body code:not(pre code) { font-family: var(--mono); font-size: 0.8em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }
.md-body pre code { font-family: var(--mono); }
.md-body pre { font-size: 13.5px; line-height: 1.55; }
.md-body blockquote { border-left-width: 3px; border-radius: 0 8px 8px 0; color: var(--muted); }
.md-body hr { margin: 1.8em 0; }
.md-body a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
/* 只有一行斜体的段落是一条说明(「更新于 … · Claude Code」):小一号、淡一些。 */
.md-body p:has(> em:only-child) { font: 13px/1.5 var(--sans); color: var(--muted); margin-top: 0.3em; }
.md-body p:has(> em:only-child) em { font-style: normal; color: inherit; }
/* 勾选框在左,折行的字和第一行的字对齐。 */
.md-body .task-list-item { margin-left: -1.35em; padding-left: 1.5em; text-indent: -1.5em; }
.md-body .task-list-item > :is(ul, ol, p, div) { text-indent: 0; }
.md-body .task-list-item > input[type="checkbox"] { margin: 0 0.55em 0 0; width: 0.95em; height: 0.95em; vertical-align: -0.12em; accent-color: var(--ink); }
.md-body li:has(> input[type="checkbox"]:checked) { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.md-plain { white-space: pre-wrap; font: inherit; margin: 0; }

/* ---------- 设置 ---------- */

.settings .section-label { display: block; margin: 26px 4px 8px; }
.settings .section-label:first-child { margin-top: 6px; }
.how { padding: 16px 18px; gap: 12px; }
.how p { margin: 0; font-size: 14px; }
.commands { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.commands li { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.commands code { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); }
.commands.soon code { color: var(--muted); }
.icon-choices { display: flex; gap: 12px; margin: 0; padding: 0; border: 0; }
.icon-choice { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.icon-choice img { border-radius: 11px; }
.icon-choice input { position: absolute; opacity: 0; pointer-events: none; }
.icon-choice.current { border-color: var(--text-2); box-shadow: inset 0 0 0 1px var(--text-2); font-weight: 600; }
.icon-choice:has(input:focus-visible) { outline: 2px solid var(--text-2); outline-offset: 2px; }

/* ---------- 编辑 ---------- */

.editor-page { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: 16px; }
.editor-head { align-items: center; }
.editor-head .page-title h1 { font: 600 17px/1.3 var(--sans); text-align: center; }
.editor-head > a { justify-self: start; }
.editor-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.editor-new { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.type-select { max-width: 200px; }
.title-input { font: 500 22px/1.3 var(--serif); }
.body-input { flex: 1; min-height: 60vh; resize: vertical; font: 15px/1.65 var(--mono); }
.editor-error { margin: 0 0 10px; }
.conflict { margin: 0 0 14px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--attention-soft); }
.conflict h2 { font-size: 16px; }
.conflict p { margin: 6px 0 12px; }
.conflict-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.conflict-side h3 { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.conflict-text { margin: 0; max-height: 280px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; font: 13px/1.5 var(--mono); }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- 搜索 ---------- */

.search-box { position: relative; margin-bottom: 14px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input { padding-left: 40px; min-height: 44px; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

/* ---------- 对话框 ---------- */

dialog {
  border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text);
  width: min(92vw, 420px); box-shadow: 0 24px 60px rgba(31, 30, 29, 0.24);
}
dialog::backdrop { background: rgba(31, 30, 29, 0.32); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.dialog-form h2, .picker-title { font: 500 19px/1.3 var(--serif); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet { display: flex; flex-direction: column; padding: 8px; }
.sheet-title { margin: 6px 12px 8px; font-size: 13px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-item { min-height: 46px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font-size: 16px; cursor: pointer; }
.sheet-item.danger { color: var(--danger); }
.sheet-item.cancel { margin-top: 4px; font-weight: 600; background: var(--surface-2); }
.sheet-item.current { font-weight: 600; }
.sheet-item.current::after { content: " ✓"; }
.picker { display: flex; flex-direction: column; gap: 12px; padding: 18px; max-height: min(80dvh, 640px); }
.picker-list { display: flex; flex-direction: column; overflow-y: auto; min-height: 120px; border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.picker-item { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 0 10px 0 calc(10px + var(--depth, 0) * 16px); border: 0; border-radius: 7px; background: transparent; color: var(--text-2); text-align: left; cursor: pointer; font-size: 14px; }
.picker-item .icon { width: 16px; height: 16px; color: var(--muted); }
.picker-item.current { background: var(--selected); color: var(--text); font-weight: 600; }
.picker-empty { margin: 12px; font-size: 13px; }

/* ---------- 分享(主人这一侧) ---------- */

/* 宽屏上纸的右边一栏:这份文件的分享链接(以后还有反馈、PDF、版本)。 */
.page.reading.with-aside { max-width: 1240px; }
.with-aside .reading-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: start; }
.reading-aside { position: sticky; top: 96px; padding-top: 6px; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.side-head h2 { margin: 0; font: 600 13px/1.4 var(--sans); color: var(--muted); }
.side-empty { margin: 4px 0 0; font-size: 13px; line-height: 1.6; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.link-button.strong { font-weight: 500; }
.link-button.danger { color: var(--attention); text-decoration: none; }
.share-row { display: flex; gap: 10px; padding: 10px 0; }
.share-row + .share-row { border-top: 1px solid var(--line); }
.share-row > .icon { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--muted); }
.share-row.expired { opacity: 0.62; }
.share-text { flex: 1; min-width: 0; }
.share-name { font-weight: 600; overflow-wrap: anywhere; }
.share-scope { font-size: 13px; color: var(--text-2); }
.share-status { font-size: 13px; color: var(--muted); }
.share-alert { color: var(--attention); font-weight: 600; }
.share-actions { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }

dialog.wide { width: min(92vw, 540px); max-height: min(92dvh, 900px); overflow-y: auto; }
.share-form { gap: 18px; padding: 20px 24px; }
.share-form-sub { margin: 2px 0 0; font-size: 13px; }
.field { display: block; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-label { display: block; margin: 0 0 6px; padding: 0; font-size: 13px; font-weight: 600; }
.field-hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.share-options { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.share-option { display: flex; gap: 10px; padding: 12px 14px; cursor: pointer; }
.share-option + .share-option { border-top: 1px solid var(--line); }
.share-option:has(input:checked) { background: var(--hover); }
.share-option input { flex: none; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--ink); }
.share-option-text { display: flex; flex: 1; min-width: 0; flex-direction: column; font-size: 13px; }
.share-option-label { font-size: 14px; font-weight: 600; }
.share-option-label .small { font-size: 12px; font-weight: 500; }
.passcode-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.passcode { font: 600 15px/1.6 var(--mono); letter-spacing: 0.14em; padding: 1px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); }
.share-emails-box { margin-top: 8px; }
.share-emails { min-height: 64px; resize: vertical; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; padding: 3px; border-radius: 9px; background: var(--surface-2); }
.segment { position: relative; }
.segment input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segment span { display: block; height: 30px; border-radius: 7px; font-size: 13px; line-height: 30px; text-align: center; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.segment input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(31, 30, 29, 0.12); }
.segment input:focus-visible + span { outline: 2px solid var(--text-2); outline-offset: 1px; }
.share-done { gap: 16px; padding: 20px 24px; }
.share-facts { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); align-items: center; gap: 10px 12px; margin: 0; }
.share-facts dt { font-size: 13px; color: var(--muted); }
.share-facts dd { margin: 0; min-width: 0; }
.share-url { display: block; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font: 13px/1.5 var(--mono); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.login-cancel { margin-top: 6px; }
.name-form { display: flex; flex-direction: column; }
.name-row { display: flex; gap: 8px; }
.name-row .input { flex: 1; min-width: 0; }

/* ---------- 收件人页(`/s/{token}`) ---------- */

.shared { min-height: 100dvh; background: var(--bg); }
.shared-top { display: flex; align-items: center; gap: 8px; height: 54px; padding: env(safe-area-inset-top) 24px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.shared-top img { border-radius: 6px; }
.shared-brand { font: 16px/1 var(--serif); }
.shared-page { max-width: 860px; margin: 0 auto; padding: 30px 40px 56px; }
.shared-head { margin-bottom: 18px; }
.shared-head p { margin: 0; }
.shared-head h1 { margin: 2px 0 6px; font: 500 30px/1.25 var(--serif); }
.shared-meta { font-size: 13px; color: var(--muted); }
.shared-update { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 20px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); }
.shared-update > .icon { width: 18px; height: 18px; color: var(--text-2); }
.shared-update-text { display: flex; flex: 1; min-width: 0; flex-direction: column; font-size: 14px; }
.shared-update-text .muted { font-size: 13px; }
.shared-changes { flex-basis: 100%; margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.shared-changes li { display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto; gap: 8px; font-size: 14px; }
.shared-foot { margin: 18px 0 0; font-size: 12px; text-align: center; }
.gate { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 420px; margin: 0 auto; padding: 96px 24px calc(32px + env(safe-area-inset-bottom)); text-align: center; }
.gate p { margin: 0; }
.gate h1 { margin: 0; font: 500 26px/1.3 var(--serif); }
.gate-mark { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; margin-bottom: 10px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); }
.gate-mark .icon { width: 26px; height: 26px; }
.gate-form { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 22px; }
.gate-code { height: 52px; font-size: 22px; letter-spacing: 0.3em; text-align: center; }
.gate-code::placeholder { font-size: 16px; letter-spacing: normal; }
.gate-form .button { min-height: 50px; font-size: 16px; }
.gate > .button { margin-top: 18px; min-width: 200px; min-height: 46px; }
.gate .form-error { margin-top: 10px; }
.gate-hint { margin-top: 16px !important; font-size: 13px; line-height: 1.6; }
.gate-foot { margin-top: 40px !important; font-size: 12px; }

/* ---------- 手机 ---------- */

@media (max-width: 899px) {
  .app { display: block; }
  .app:not([data-page="home"]) .sidebar { display: none; }
  .app[data-page="home"] .main { display: none; }
  /* 首页:和系统的「文件」一样,几组圆角的列表;树只列顶层,往里点进文件夹页。 */
  .sidebar { position: static; height: auto; min-height: 100dvh; border-right: 0; background: var(--bg); padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); gap: 0; }
  .sidebar-head { padding: 4px 2px 14px; }
  .brand { font-size: 30px; }
  .brand img { width: 32px; height: 32px; border-radius: 8px; }
  .search-link { min-height: 40px; background: var(--surface-2); border-color: transparent; font-size: 16px; margin-bottom: 14px; }
  .nav-list, .tree, .sidebar-foot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; gap: 0; padding: 0; }
  .nav-link, .tree-link { min-height: 48px; border-radius: 0; padding: 0 14px; font-size: 16px; border-bottom: 1px solid var(--line); color: var(--text); }
  .nav-link .icon, .tree-link .icon { width: 19px; height: 19px; }
  .nav-list > :last-child, .tree > :last-child .tree-link, .sidebar-foot > a:last-of-type { border-bottom: 0; }
  .nav-link.current, .tree-row.current .tree-link { background: transparent; font-weight: 400; }
  .folders { flex: none; margin-top: 20px; }
  .tree-row .tree-link { padding-left: 14px; }
  .section-head { padding: 0 4px 8px; }
  .section-label { font: 500 20px/1.2 var(--serif); color: var(--text); }
  .tree-row:not([data-depth="0"]) { display: none; }
  .tree-row { padding-left: 0; }
  .tree-toggle, .tree-toggle-spacer { display: none; }
  .tree .nav-count { display: inline; font-size: 15px; }
  .sidebar-foot { margin-top: 20px; padding: 0; }
  .account { padding: 14px; border-top: 1px solid var(--line); }
  .page { padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
  .page-head { margin: 0 -16px; padding: calc(6px + env(safe-area-inset-top)) 8px 8px; align-items: center; gap: 4px; }
  .back { display: inline-flex; align-items: center; gap: 2px; height: 40px; max-width: 120px; color: var(--text-2); font-size: 16px; }
  .back .icon { width: 24px; height: 24px; }
  .back-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crumbs { display: none; }
  .page-title h1 { font: 600 17px/1.3 var(--sans); text-align: center; }
  .page-subtitle { display: none; }
  /* 手机的标题栏和 iOS 一样:动作都是图标,不带底色和边框。 */
  .button .label { display: none; }
  .page-actions .button:has(.icon) { width: 38px; min-height: 38px; padding: 0; border-color: transparent; background: transparent; color: var(--text); }
  .page-actions .button.primary:has(.icon) { color: var(--text); }
  .page-actions .button .icon { width: 21px; height: 21px; }
  .page-actions { min-width: 40px; padding-bottom: 0; }
  /* 一行文件:标题下面一行小字,不分列。 */
  .file-row, .files:has(.col-place) .file-row, .inbox-item .file-row { grid-template-columns: minmax(0, 1fr); padding: 0 14px; }
  .file-row:has(.check) { grid-template-columns: 28px minmax(0, 1fr); }
  .file-row:has(.trash-tail) { grid-template-columns: minmax(0, 1fr) auto; }
  .col { display: none; }
  .files .file-sub { display: block; }
  .file-main { padding: 11px 0; }
  .group-label { padding-left: 14px; }
  .inbox-item { grid-template-columns: minmax(0, 1fr); }
  .suggestion { padding: 0 14px 12px 52px; flex-wrap: wrap; }
  .suggestion-path { flex-basis: 100%; max-width: none; }
  .page-actions .button.keep-label { width: auto; padding: 0 12px; margin-right: 4px; }
  .page-actions .button.keep-label.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
  .button.keep-label .label { display: inline; }
  .page-actions .button.keep-label .icon { width: 16px; height: 16px; }
  .bulk { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20; flex-wrap: wrap; box-shadow: 0 10px 30px rgba(31, 30, 29, 0.25); }
  .bulk-hint { display: none; }
  .bulk-clear { margin-left: auto; }
  /* 读的时候整屏是一张白纸,标题栏也是。 */
  .paper { margin: 0 -16px; padding: 14px 20px 32px; border-radius: 0; box-shadow: none; }
  body:has(.app[data-page="artifact"]), body:has(.app[data-page="revision"]) { background: var(--surface); }
  .app[data-page="artifact"] .page-head, .app[data-page="revision"] .page-head { background: color-mix(in srgb, var(--surface) 90%, transparent); }
  .md-body { font-size: 17px; }
  .conflict-columns { grid-template-columns: 1fr; }
  /* 编辑页贴着看得见的那块(键盘以上),工具栏不被推走。 */
  .editor-page { position: fixed; left: 0; right: 0; top: var(--vv-top); height: var(--vv-height); min-height: 0; padding: 0 12px; overflow: hidden; }
  .editor-page .page-head { margin: 0 -12px; padding-left: 12px; padding-right: 12px; flex: none; }
  .editor-fields { min-height: 0; padding-bottom: 8px; }
  .body-input { min-height: 0; resize: none; }
  .conflict { flex: none; max-height: 45%; overflow: auto; }
  dialog.as-sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

@media (pointer: coarse) {
  .input, .textarea, .search-input { font-size: 16px; }
  .body-input { font-size: 16px; }
}

/* 手机上的分享和收件人页:链接列在纸的下面;收件人页整屏是一张白纸,和读自己的文件一样。 */
@media (max-width: 899px) {
  .with-aside .reading-layout { display: block; }
  .reading-aside { position: static; margin-top: 24px; padding: 0 4px; }
  .shared-top { height: 48px; padding: env(safe-area-inset-top) 16px 0; border-bottom: 0; }
  .shared-page { padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
  .shared-head { margin: 6px 2px 4px; }
  .shared-head h1 { font-size: 25px; }
  body:has(.shared .paper) { background: var(--surface); }
  body:has(.shared .paper) .shared { background: var(--surface); }
  .shared-update { margin: 2px 0 14px; }
  .gate { padding-top: 72px; }
  .share-form, .share-done { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
}
