/* ==========================================================================
   神奇粘板 · styles
   概念：一块搁在木桌上的粘板。暖纸、墨字、一方朱红印章。
   明暗两套不是简单反色：暗色是「灯关掉之后的纸」，偏暖褐，不是灰蓝。
   ========================================================================== */

/* ---------------------------------- 变量 ---------------------------------- */

:root {
  /* 纸与墨 */
  --paper: #e9dfcc;
  --paper-deep: #e1d5bd;
  --sheet: #faf4e6;
  --sheet-hover: #fdf8ee;
  --ink: #241f18;
  --ink-2: #4e4435;
  --ink-3: #6b5b44;
  --rule: #d7c8ad;
  --rule-strong: #bfab89;

  /* 朱红印泥 */
  --accent: #a8362a;
  --accent-strong: #8b281d;
  --accent-soft: rgba(168, 54, 42, 0.09);
  --accent-fill: #a8362a;
  --accent-fill-strong: #8b281d;
  --on-accent: #fff5e7;
  --on-fill: #fff5e7;
  --danger: #9b2c1e;
  --danger-fill: #9b2c1e;
  --on-danger: #fff5e7;

  /* 胶带、订书钉、阴影 */
  --tape: rgba(191, 158, 96, 0.5);
  --tape-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(84, 58, 20, 0.06));
  --staple: #8d867a;
  --card-inset: rgba(255, 255, 255, 0.3);
  --sheet-inset: rgba(255, 255, 255, 0.42);
  --grain:
    repeating-linear-gradient(0deg, rgba(96, 72, 38, 0.018) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(96, 72, 38, 0.012) 0 1px, transparent 1px 4px);
  --shadow-1: rgba(74, 52, 22, 0.09);
  --shadow-2: rgba(74, 52, 22, 0.24);
  --topbar: rgba(233, 223, 204, 0.84);
  --overlay: rgba(233, 223, 204, 0.9);
  --backdrop: rgba(36, 31, 24, 0.42);
  --toast-bg: #241f18;
  --toast-ink: #f5ecdc;
  --desk-glow: rgba(255, 252, 242, 0.55);

  /* Markdown 预览 */
  --code-bg: #f1e6d2;
  --code-border: #ddcfb4;
  --code-ink: #3b3226;
  --fill-soft: rgba(96, 72, 38, 0.055);

  /* 字体 */
  --font-display: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun",
    "Songti TC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", "Segoe UI Mono", "Consolas", "Liberation Mono",
    monospace;

  /* 尺寸 */
  --topbar-h: 64px;
  --rail-w: 340px;
  --tap: 38px;
  --radius: 3px;

  color-scheme: light;
}

/* 暗色：同一套语义，换成「夜里的纸」。
   改这里的值时，记得同步下面 @media 里那份。 */
:root[data-theme="dark"] {
  --paper: #191612;
  --paper-deep: #211d17;
  --sheet: #272117;
  --sheet-hover: #2e271c;
  --ink: #eee4d2;
  --ink-2: #c9bda7;
  --ink-3: #a3937a;
  --rule: #3a3227;
  --rule-strong: #4e4435;

  --accent: #e07a63;
  --accent-strong: #f0937d;
  --accent-soft: rgba(224, 122, 99, 0.14);
  --accent-fill: #b23a2b;
  --accent-fill-strong: #c94a37;
  --on-accent: #201510;
  --on-fill: #fff3e4;
  --danger: #c9563f;
  --danger-fill: #a83526;
  --on-danger: #fff3e4;

  --tape: rgba(216, 164, 88, 0.3);
  --tape-sheen: linear-gradient(180deg, rgba(255, 232, 190, 0.1), rgba(0, 0, 0, 0.08));
  --staple: #7d7568;
  --card-inset: rgba(255, 255, 255, 0.04);
  --sheet-inset: rgba(255, 255, 255, 0.05);
  --grain:
    repeating-linear-gradient(0deg, rgba(255, 226, 180, 0.016) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 226, 180, 0.01) 0 1px, transparent 1px 4px);
  --shadow-1: rgba(0, 0, 0, 0.32);
  --shadow-2: rgba(0, 0, 0, 0.62);
  --topbar: rgba(25, 22, 18, 0.84);
  --overlay: rgba(25, 22, 18, 0.9);
  --backdrop: rgba(0, 0, 0, 0.55);
  --toast-bg: #eee4d2;
  --toast-ink: #1b1712;
  --desk-glow: rgba(255, 214, 160, 0.035);

  /* Markdown 预览 */
  --code-bg: #16120e;
  --code-border: #3a3227;
  --code-ink: #e7dcc9;
  --fill-soft: rgba(255, 255, 255, 0.045);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191612;
    --paper-deep: #211d17;
    --sheet: #272117;
    --sheet-hover: #2e271c;
    --ink: #eee4d2;
    --ink-2: #c9bda7;
    --ink-3: #a3937a;
    --rule: #3a3227;
    --rule-strong: #4e4435;

    --accent: #e07a63;
    --accent-strong: #f0937d;
    --accent-soft: rgba(224, 122, 99, 0.14);
    --accent-fill: #b23a2b;
    --accent-fill-strong: #c94a37;
    --on-accent: #201510;
    --on-fill: #fff3e4;
    --danger: #c9563f;
    --danger-fill: #a83526;
    --on-danger: #fff3e4;

    --tape: rgba(216, 164, 88, 0.3);
    --tape-sheen: linear-gradient(180deg, rgba(255, 232, 190, 0.1), rgba(0, 0, 0, 0.08));
    --staple: #7d7568;
    --card-inset: rgba(255, 255, 255, 0.04);
    --sheet-inset: rgba(255, 255, 255, 0.05);
    --grain:
      repeating-linear-gradient(0deg, rgba(255, 226, 180, 0.016) 0 1px, transparent 1px 3px),
      repeating-linear-gradient(90deg, rgba(255, 226, 180, 0.01) 0 1px, transparent 1px 4px);
    --shadow-1: rgba(0, 0, 0, 0.32);
    --shadow-2: rgba(0, 0, 0, 0.62);
    --topbar: rgba(25, 22, 18, 0.84);
    --overlay: rgba(25, 22, 18, 0.9);
    --backdrop: rgba(0, 0, 0, 0.55);
    --toast-bg: #eee4d2;
    --toast-ink: #1b1712;
    --desk-glow: rgba(255, 214, 160, 0.035);

    /* Markdown 预览 */
    --code-bg: #16120e;
    --code-border: #3a3227;
    --code-ink: #e7dcc9;
    --fill-soft: rgba(255, 255, 255, 0.045);

    color-scheme: dark;
  }
}

/* ---------------------------------- 基础 ---------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 80% at 8% 0%, var(--desk-glow), transparent 62%),
    repeating-linear-gradient(0deg, rgba(96, 72, 38, 0.022) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(96, 72, 38, 0.016) 0 1px, transparent 1px 4px);
  overflow: hidden;
}

::selection {
  background: rgba(168, 54, 42, 0.22);
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

/* 细滚动条：linux/windows 上都别抢戏 */
.rail__body,
.note-list,
.dialog,
.login {
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

.rail__body::-webkit-scrollbar {
  width: 10px;
}

.rail__body::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 4px;
}

.rail__body::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------------------------------- 工具类 -------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 印章：整套视觉的落款 */
.seal {
  --seal-size: 28px;
  display: inline-grid;
  place-items: center;
  width: var(--seal-size);
  height: var(--seal-size);
  flex: none;
  border-radius: 3px;
  background: var(--accent-fill);
  color: var(--on-fill);
  font-family: var(--font-display);
  font-size: calc(var(--seal-size) * 0.56);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  transform: rotate(-3.5deg);
  box-shadow:
    inset 0 0 0 1px rgba(255, 246, 233, 0.42),
    0 1px 2px rgba(60, 30, 10, 0.18);
  user-select: none;
}

.seal--sm {
  --seal-size: 28px;
}

.seal--lg {
  --seal-size: 46px;
}

.seal--xl {
  --seal-size: 62px;
}

.seal--outline {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  border: 1px dashed var(--accent);
  opacity: 0.85;
  transform: rotate(-6deg);
}

/* --------------------------------- 启动占位 ------------------------------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--paper);
}

.boot__text {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.boot .seal {
  animation: seal-breathe 1.9s ease-in-out infinite;
}

@keyframes seal-breathe {
  0%,
  100% {
    opacity: 0.55;
    transform: rotate(-3.5deg) scale(0.96);
  }
  50% {
    opacity: 1;
    transform: rotate(-3.5deg) scale(1);
  }
}

/* ---------------------------------- 按钮 ---------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--tap);
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.12s ease,
    box-shadow 0.16s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn--primary {
  background: var(--accent-fill);
  color: var(--on-fill);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 2px 6px -3px var(--shadow-2);
}

.btn--primary:hover {
  background: var(--accent-fill-strong);
}

.btn--ghost {
  background: transparent;
  border-color: var(--rule-strong);
  color: var(--ink-2);
}

.btn--ghost:hover {
  background: var(--sheet);
  color: var(--ink);
}

.btn--danger {
  background: var(--danger-fill);
  color: var(--on-danger);
}

.btn--danger:hover {
  filter: brightness(1.08);
}

.btn--block {
  width: 100%;
  height: 46px;
  font-size: 14px;
}

.btn--sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-2);
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.icon-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.icon-btn[aria-pressed="true"] .icon {
  fill: currentColor;
  stroke-width: 1.2;
}

/* 预览按钮切换图标时不要填充，否则会变成一团色块 */
.icon-btn[data-preview-toggle][aria-pressed="true"] .icon {
  fill: none;
  stroke-width: 1.7;
}

.icon-btn--danger:hover {
  background: var(--accent-fill);
  color: var(--on-fill);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn:disabled:hover {
  background: transparent;
  color: var(--ink-2);
}

.icon-btn--danger:disabled:hover {
  background: transparent;
  color: var(--ink-2);
}

/* ---------------------------------- 登录 ---------------------------------- */

.login {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 44px 20px calc(28px + env(safe-area-inset-bottom));
}

.login__sheet {
  position: relative;
  width: min(432px, 100%);
  padding: 42px 38px 30px;
  background-color: var(--sheet);
  background-image: var(--grain);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 var(--sheet-inset),
    0 2px 4px -2px var(--shadow-1),
    0 44px 70px -52px var(--shadow-2);
}

.login__tape {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 124px;
  height: 27px;
  transform: translateX(-50%) rotate(-2.2deg);
  background-color: var(--tape);
  background-image: var(--tape-sheen);
  clip-path: polygon(2% 12%, 14% 2%, 86% 0, 100% 16%, 98% 84%, 84% 96%, 12% 100%, 0 88%);
  box-shadow: 0 1px 2px rgba(60, 40, 10, 0.07);
}

.login__mark {
  display: flex;
  justify-content: center;
}

.login__title {
  margin-top: 20px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4.4vw, 38px);
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.25;
  text-align: center;
  text-indent: 0.1em;
}

.login__tagline {
  margin: 10px 0 30px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  text-align: center;
}

.login__form {
  display: block;
}

.login__error {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  line-height: 1.65;
}

.login__hint {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px dashed var(--rule);
  font-size: 12px;
  line-height: 1.9;
  color: var(--ink-3);
}

.login__foot {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  opacity: 0.85;
}

/* 表单基础 */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field__label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}

.field__label em {
  font-style: normal;
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--ink);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}

.input::placeholder {
  color: var(--ink-3);
  opacity: 0.85;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--sheet);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check__text em {
  margin-left: 7px;
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* --------------------------------- 主界面 --------------------------------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* 顶栏 */
.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 520px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  min-height: var(--topbar-h);
  padding: 10px clamp(14px, 2vw, 24px);
  border-bottom: 1px solid var(--rule);
  background: var(--topbar);
  backdrop-filter: blur(12px) saturate(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.brand__name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.brand__sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  white-space: nowrap;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.search__icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--ink-3);
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 40px;
  padding: 0 44px 0 36px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.search__input::-webkit-search-cancel-button,
.search__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search__input::placeholder {
  color: var(--ink-3);
  opacity: 0.85;
}

.search__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__kbd {
  position: absolute;
  right: 10px;
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ink-3);
  pointer-events: none;
}

.search__clear {
  position: absolute;
  right: 34px;
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
}

.search__clear:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.search.is-filled .search__clear {
  display: grid;
}

.search.is-filled .search__kbd {
  display: none;
}

.topbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* 工作区 */
.workspace {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* --------------------------------- 左栏 ---------------------------------- */

.rail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper-deep);
  border-right: 1px solid var(--rule);
}

.rail__head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 16px 10px;
}

.rail__head .chips {
  max-height: 92px;
  overflow-y: auto;
  scrollbar-width: none;
}

.rail__head .chips::-webkit-scrollbar {
  display: none;
}

.rail__count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.rail__body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 10px 14px 26px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* 标签芯片 */
.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 27px;
  padding: 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: transparent;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-2);
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.chip:hover {
  background: var(--sheet);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-fill);
}

.chip__count {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.65;
}

/* 便签卡片 */
.note-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  padding: 13px 15px 11px;
  text-align: left;
  background-color: var(--sheet);
  background-image: var(--grain);
  border: 1px solid var(--rule);
  border-radius: 2px;
  transform: rotate(var(--tilt, 0deg));
  box-shadow:
    0 1px 0 var(--card-inset) inset,
    0 6px 14px -12px var(--shadow-2);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.card:nth-child(3n + 1) {
  --tilt: -0.32deg;
}

.card:nth-child(3n + 2) {
  --tilt: 0.26deg;
}

.card:nth-child(3n + 3) {
  --tilt: -0.1deg;
}

.card:hover {
  transform: rotate(0deg) translateY(-1px);
  background-color: var(--sheet-hover);
  box-shadow:
    0 1px 0 var(--card-inset) inset,
    0 10px 20px -14px var(--shadow-2);
}

.card[aria-selected="true"] {
  z-index: 1;
  transform: translateY(-2px) rotate(0deg);
  background-color: var(--sheet-hover);
  border-color: var(--rule-strong);
  box-shadow:
    0 1px 0 var(--card-inset) inset,
    0 14px 26px -18px var(--shadow-2),
    0 1px 2px -1px var(--shadow-1);
}

/* 选中的便签像被拎起来：一张胶带 */
.card::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 20px;
  width: 64px;
  height: 15px;
  background-color: var(--tape);
  background-image: var(--tape-sheen);
  clip-path: polygon(2% 12%, 14% 2%, 86% 0, 100% 16%, 98% 84%, 84% 96%, 12% 100%, 0 88%);
  transform: rotate(-2.6deg);
  filter: drop-shadow(0 1px 1px rgba(74, 52, 22, 0.22));
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.card[aria-selected="true"]::before {
  opacity: 1;
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--ink);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__pin {
  width: 7px;
  height: 7px;
  margin-top: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.card__preview {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-3);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__preview:empty {
  display: none;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
}

.card__time {
  white-space: nowrap;
}

.card__tags {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-align: right;
  color: var(--ink-3);
}

.card__tag {
  color: var(--ink-2);
  white-space: nowrap;
}

/* 井号只用 CSS 画出来，卡片文本里保持干净 */
.card__tag::before {
  content: "#";
  margin-right: 1px;
  opacity: 0.55;
}

/* 骨架屏 */
.list-skeleton {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.skel {
  height: 92px;
  border-radius: 2px;
  background: linear-gradient(
    100deg,
    var(--paper-deep) 20%,
    var(--sheet) 42%,
    var(--paper-deep) 64%
  );
  background-size: 220% 100%;
  animation: skel-sweep 1.6s linear infinite;
  opacity: 0.85;
}

.skel--short {
  height: 72px;
}

@keyframes skel-sweep {
  from {
    background-position: 130% 0;
  }
  to {
    background-position: -30% 0;
  }
}

/* 列表空 / 错误 */
.list-empty,
.list-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 18px 2px;
  padding: 18px 16px;
  border: 1px dashed var(--rule-strong);
  border-radius: 2px;
  background: transparent;
}

.list-empty__title,
.list-error__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.list-empty__text,
.list-error__text {
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

/* 左栏底部工具 */
.rail__foot {
  display: flex;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}

.rail-btn {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 46px;
  padding: 4px 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.rail-btn .icon {
  width: 17px;
  height: 17px;
}

.rail-btn:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.rail-btn[aria-pressed="true"] {
  color: var(--accent);
}

/* --------------------------------- 右栏 ---------------------------------- */

.desk {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 2vw, 28px);
  overflow: hidden;
  background-image: radial-gradient(80% 50% at 50% 0%, var(--desk-glow), transparent 70%);
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: 820px;
  min-height: 0;
  margin: 0 auto;
  padding: 24px clamp(20px, 3vw, 34px) 18px;
  background-color: var(--sheet);
  background-image: var(--grain);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 var(--sheet-inset),
    0 2px 6px -3px var(--shadow-1),
    0 28px 50px -38px var(--shadow-2);
  overflow: hidden;
}

/* 一枚订书钉，把纸拧在桌上 */
.sheet__staple {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 34px;
  height: 7px;
  transform: translateX(-50%) rotate(-2.4deg);
  border-radius: 1px;
  background: linear-gradient(
    180deg,
    #d7d2c7 0%,
    #8d877c 42%,
    #b9b3a6 58%,
    #6f6a61 100%
  );
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
  opacity: 0.8;
}

.sheet__staple::before,
.sheet__staple::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 2px;
  background: rgba(30, 26, 20, 0.35);
}

.sheet__staple::before {
  left: 7px;
}

.sheet__staple::after {
  right: 7px;
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.sheet__back {
  display: none;
  flex: none;
}

.sheet__title-wrap {
  flex: 1;
  min-width: 0;
}

.sheet__title {
  display: block;
  width: 100%;
  padding: 1px 0 2px;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.2vw, 27px);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.015em;
  color: var(--ink);
}

.sheet__title::placeholder {
  color: var(--ink-3);
  opacity: 0.55;
}

.sheet__title:focus {
  outline: none;
}

.sheet__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.save-status {
  transition: color 0.2s ease;
}

.save-status[data-state="dirty"],
.save-status[data-state="saving"] {
  color: var(--accent);
}

.save-status[data-state="error"] {
  color: var(--danger);
}

.sheet__dot {
  opacity: 0.55;
}

.sheet__tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  margin-top: 1px;
}

.sheet__rule {
  position: relative;
  height: 1px;
  margin-top: 12px;
  background: var(--rule);
}

.sheet__rule::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 54px;
  height: 2px;
  background: var(--accent);
  opacity: 0.55;
}

.sheet__body {
  flex: 1;
  min-height: 120px;
  width: 100%;
  margin-top: 12px;
  padding: 4px 2px 20px 20px;
  border: none;
  border-left: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  resize: none;
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.85;
  letter-spacing: 0.01em;
  color: var(--ink);
  transition: border-color 0.2s ease;
}

.sheet__body::placeholder {
  color: var(--ink-3);
  opacity: 0.6;
}

.sheet__body:focus {
  outline: none;
  border-left-color: var(--accent);
}

/* ------------------------------ Markdown 预览 ------------------------------ */

.markdown-preview {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin-top: 12px;
  padding: 4px 2px 24px 20px;
  border-left: 1px solid var(--rule);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.85;
  letter-spacing: 0.01em;
  color: var(--ink);
  overflow-wrap: anywhere;
  transition: border-color 0.2s ease;
}

.markdown-preview:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.markdown-preview::-webkit-scrollbar {
  width: 10px;
}

.markdown-preview::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 4px;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.55em 0 0.55em;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.markdown-body h1 {
  font-size: 1.65em;
  padding-bottom: 0.28em;
  border-bottom: 1px solid var(--rule);
}

.markdown-body h2 {
  font-size: 1.36em;
  padding-bottom: 0.22em;
  border-bottom: 1px dashed var(--rule);
}

.markdown-body h3 {
  font-size: 1.18em;
}

.markdown-body h4 {
  font-size: 1.05em;
}

.markdown-body h5 {
  font-size: 0.98em;
  color: var(--ink-2);
}

.markdown-body h6 {
  font-size: 0.9em;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.markdown-body p {
  margin: 0.85em 0;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.markdown-body a:hover {
  text-decoration-thickness: 2px;
}

.markdown-body strong {
  font-weight: 700;
  color: var(--ink);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  color: var(--ink-3);
}

.markdown-body ul,
.markdown-body ol {
  margin: 0.75em 0;
  padding-left: 1.45em;
}

.markdown-body ul {
  list-style: disc;
}

.markdown-body ol {
  list-style: decimal;
}

.markdown-body li {
  margin: 0.3em 0;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin: 0.25em 0;
}

.markdown-body li::marker {
  color: var(--ink-3);
}

/* 任务列表：checkbox 由渲染器输出，样式只做对齐 */
.markdown-body li:has(> input[type="checkbox"]) {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  margin-left: -1.25em;
  list-style: none;
}

.markdown-body li:has(> input[type="checkbox"]) > input[type="checkbox"] {
  margin-top: 0.46em;
}

.markdown-body input[type="checkbox"] {
  flex: none;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  opacity: 1;
  pointer-events: none;
}

.markdown-body blockquote {
  margin: 1em 0;
  padding: 0.45em 1em 0.45em 1.05em;
  border-left: 3px solid var(--accent);
  border-radius: 0 2px 2px 0;
  background: var(--fill-soft);
  color: var(--ink-2);
}

.markdown-body blockquote > :first-child {
  margin-top: 0.4em;
}

.markdown-body blockquote > :last-child {
  margin-bottom: 0.4em;
}

.markdown-body blockquote blockquote {
  margin-left: 0.2em;
}

.markdown-body hr {
  margin: 1.9em 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.markdown-body code {
  padding: 0.12em 0.4em;
  border: 1px solid var(--code-border);
  border-radius: 2px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.markdown-body pre {
  max-width: 100%;
  margin: 1em 0;
  padding: 14px 16px;
  border: 1px solid var(--code-border);
  border-radius: 3px;
  background: var(--code-bg);
  overflow-x: auto;
  overflow-y: hidden;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

.markdown-body pre code {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--code-ink);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre;
  overflow-wrap: normal;
  tab-size: 2;
}

/* 表格：外面包一层滚动容器（渲染后由 app.js 包好），窄屏只在容器内横向滚动 */
.markdown-body .table-wrap {
  max-width: 100%;
  margin: 1em 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

.markdown-body .table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.markdown-body .table-wrap::-webkit-scrollbar {
  height: 8px;
}

.markdown-body .table-wrap::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 4px;
}

.markdown-body table {
  width: max-content;
  max-width: none;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.92em;
}

.markdown-body thead {
  background: var(--fill-soft);
}

.markdown-body th,
.markdown-body td {
  padding: 7px 11px;
  border: 1px solid var(--rule-strong);
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

/* 空正文时的预览提示 */
.markdown-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 520px;
  margin: 26px 0;
  padding: 22px 22px 20px;
  border: 1px dashed var(--rule-strong);
  border-radius: 2px;
  color: var(--ink-3);
}

.markdown-empty__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-2);
}

.markdown-empty__hint {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.8;
  letter-spacing: 0.03em;
}

.markdown-empty .btn {
  margin-top: 4px;
}

.sheet__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.chips--edit {
  gap: 6px;
}

.chip--edit {
  height: 26px;
  padding: 0 5px 0 9px;
  border-style: dashed;
  font-size: 11.5px;
  color: var(--ink-2);
  background: transparent;
}

.chip--edit:hover {
  background: transparent;
  color: var(--ink);
}

.chip__remove {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 13px;
  line-height: 1;
  color: var(--ink-3);
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.chip__remove:hover {
  background: var(--accent-fill);
  color: var(--on-fill);
}

.tag-editor__input {
  flex: 1;
  min-width: 130px;
  height: 30px;
  padding: 0 2px;
  border: none;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink);
}

.tag-editor__input::placeholder {
  color: var(--ink-3);
  opacity: 0.9;
}

.tag-editor__input:focus {
  outline: none;
}

/* 右栏空状态 */
.desk-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  margin: auto;
  padding: 28px 24px;
  text-align: center;
}

.desk-empty .seal--outline {
  --seal-size: 70px;
  margin-bottom: 10px;
}

.desk-empty__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.desk-empty__text {
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-3);
}

.desk-empty .btn {
  height: 42px;
  margin-top: 10px;
  padding: 0 20px;
}

.desk-empty__hint {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  opacity: 0.9;
}

/* ---------------------------------- 浮层 ---------------------------------- */

/* 拖拽遮罩 */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.drop-overlay::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 2px dashed var(--accent);
  border-radius: 6px;
  pointer-events: none;
  opacity: 0.75;
}

.drop-overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 34px 32px;
  text-align: center;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -40px var(--shadow-2);
}

.drop-overlay__icon {
  width: 38px;
  height: 38px;
  margin-bottom: 4px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-overlay__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.drop-overlay__text {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-3);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 460px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast__msg {
  padding: 10px 16px;
  border-left: 3px solid var(--accent-fill);
  border-radius: 2px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  box-shadow: 0 12px 26px -14px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.18s ease-out both;
}

.toast__msg--error {
  border-left-color: rgba(255, 246, 233, 0.45);
  background: var(--accent-fill);
  color: var(--on-fill);
}

.toast__msg--leaving {
  animation: toast-out 0.18s ease-in both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* 文件选择框：藏起来但仍可用 */
.file-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------- 对话框 -------------------------------- */

.dialog {
  width: min(442px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.5);
  overflow: auto;
}

.dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.dialog__form {
  display: flex;
  flex-direction: column;
}

.dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 0;
}

.dialog__title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.dialog__sub {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-3);
}

.dialog__body {
  padding: 20px 22px 2px;
}

.dialog__text {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.dialog__error {
  margin-top: 4px;
  padding: 8px 11px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  line-height: 1.65;
}

.dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding: 15px 22px calc(17px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}

.dialog--confirm .dialog__body {
  padding-top: 14px;
}

.dialog--confirm .dialog__foot {
  margin-top: 8px;
}

/* ---------------------------------- 响应式 -------------------------------- */

/* 平板：左栏窄一点 */
@media (max-width: 1120px) {
  :root {
    --rail-w: 306px;
  }
}

/* 手机 / 窄窗口：单列，列表 ↔ 编辑 */
@media (max-width: 880px) {
  :root {
    --tap: 44px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    min-height: 0;
    padding: 9px 12px 10px;
    padding-top: calc(9px + env(safe-area-inset-top));
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .brand__sub {
    display: none;
  }

  .topbar__actions {
    grid-column: 2;
    grid-row: 1;
    gap: 6px;
  }

  .topbar__actions .btn {
    height: 44px;
    padding: 0 14px;
    font-size: 13px;
  }

  .search {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .search__input {
    height: 44px;
    font-size: 16px;
    padding-right: 44px;
  }

  .search__kbd {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .rail {
    border-right: none;
  }

  .desk {
    display: none;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .app.is-editing .rail {
    display: none;
  }

  .app.is-editing .desk {
    display: flex;
  }

  .rail__head {
    padding: 10px 12px 8px;
    gap: 8px;
  }

  .rail__head .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  }

  .rail__head .chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: none;
    height: 44px;
    padding: 0 15px;
    font-size: 13px;
  }

  .rail__body {
    padding: 8px 12px 22px;
  }

  .card {
    padding: 12px 14px 11px;
    transform: none;
  }

  .card::before {
    display: none;
  }

  .card[aria-selected="true"] {
    box-shadow:
      0 1px 0 var(--card-inset) inset,
      2px 0 0 var(--accent) inset,
      0 6px 14px -12px var(--shadow-2);
  }

  .card__title {
    font-size: 15px;
  }

  .rail__foot {
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }

  .rail-btn {
    min-height: 48px;
    font-size: 11px;
  }

  /* 编辑面板：单列铺满 */
  .sheet {
    max-width: none;
    height: 100%;
    padding: 14px 14px 10px;
  }

  .sheet__staple {
    display: none;
  }

  .sheet__head {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 0 6px;
    align-items: start;
  }

  .sheet__back {
    display: inline-grid;
    width: 44px;
    height: 44px;
    margin-left: -6px;
  }

  .sheet__title-wrap {
    padding-top: 6px;
  }

  .sheet__title {
    font-size: 21px;
  }

  .sheet__tools {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 2px;
  }

  .sheet__tools .icon-btn {
    width: 44px;
    height: 44px;
  }

  .sheet__rule {
    margin-top: 8px;
  }

  .sheet__body {
    padding: 4px 0 16px 14px;
    font-size: 16px;
    line-height: 1.75;
    min-height: 90px;
  }

  .markdown-preview {
    margin-top: 10px;
    padding: 2px 0 20px 14px;
    font-size: 16px;
    line-height: 1.78;
  }

  .markdown-body h1 {
    font-size: 1.5em;
  }

  .markdown-body h2 {
    font-size: 1.28em;
  }

  .markdown-body h3 {
    font-size: 1.14em;
  }

  .markdown-body pre {
    margin: 0.9em 0;
    padding: 12px 13px;
  }

  .markdown-body pre code {
    font-size: 12.5px;
  }

  .markdown-body blockquote {
    padding: 0.4em 0.8em 0.4em 0.85em;
  }

  .markdown-body table {
    font-size: 0.88em;
  }

  .markdown-body th,
  .markdown-body td {
    padding: 6px 9px;
  }

  .markdown-empty {
    margin: 18px 0;
    padding: 18px 16px;
  }

  .sheet__foot {
    padding-bottom: calc(2px + env(safe-area-inset-bottom));
  }

  .chip--edit {
    height: 44px;
    padding-left: 13px;
  }

  .chip__remove {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }

  .tag-editor__input {
    font-size: 16px;
    height: 44px;
    min-width: 110px;
  }

  .note-list {
    gap: 9px;
  }

  .toast {
    bottom: calc(14px + env(safe-area-inset-bottom));
    width: min(92vw, 460px);
    align-items: stretch;
  }

  .toast__msg {
    font-size: 13px;
    text-align: center;
  }

  .login {
    padding: 34px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .login__sheet {
    padding: 34px 24px 26px;
  }

  .check {
    min-height: 44px;
  }

  .check input {
    width: 20px;
    height: 20px;
  }

  .login__tagline {
    margin-bottom: 26px;
  }

  .dialog {
    width: calc(100vw - 28px);
  }
}

/* 极窄 */
@media (max-width: 380px) {
  .topbar__actions .btn span {
    display: none;
  }

  .topbar__actions .btn {
    width: 44px;
    padding: 0;
  }

  .topbar__actions .btn .icon {
    width: 18px;
    height: 18px;
  }

  .brand__name {
    font-size: 16px;
  }

  .sheet__tools {
    justify-content: space-between;
  }
}

/* --------------------------------- 动效克制 ------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
