/* 手记 · note.rboot.cc
   flomo 的形：浅灰底、白卡片、时间在左上、首行加粗、标签蓝胶囊、底部一条输入条。
   写、改、删都在这一页。 */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2329;
  --text: #1f2329;
  --muted: #9aa0a8;
  --faint: #c2c6cd;
  --line: #e8eaee;
  --line-soft: #f0f1f4;
  --blue: #5b7cfa;
  --blue-weak: #eef3ff;
  --danger: #f04e4e;
  --danger-weak: #fff1f1;
  --card-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
  --card-hover: 0 3px 12px rgba(17, 24, 39, 0.07);
  --font: -apple-system, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --feed-w: 680px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113;
    --card: #1a1c1f;
    --ink: #eceef1;
    --text: #e3e5e8;
    --muted: #868b93;
    --faint: #4a4f57;
    --line: #26292e;
    --line-soft: #212428;
    --blue: #7e9bff;
    --blue-weak: #1c2438;
    --danger: #ff6b6b;
    --danger-weak: #2a1a1a;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --card-hover: 0 3px 14px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--blue); color: #fff; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

button { font: inherit; color: inherit; }

@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: rgba(127, 127, 127, 0.28);
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: content-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: rgba(127, 127, 127, 0.42); background-clip: content-box; }
}

/* ── 顶栏 ─────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
}

.topbar-inner {
  max-width: var(--feed-w);
  margin: 0 auto;
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.icon-btn {
  margin-left: auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.icon-btn:hover { background: rgba(127, 127, 127, 0.1); color: var(--ink); }

.icon-btn svg { width: 21px; height: 21px; }

.searchbar {
  max-width: var(--feed-w);
  margin: 0 auto;
  padding: 2px 12px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.searchbar-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  color: var(--muted);
}

.searchbar-field svg { width: 18px; height: 18px; flex: none; }

.searchbar-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  outline: none;
}

.searchbar-field input::placeholder { color: var(--muted); }
.searchbar-field input::-webkit-search-cancel-button { display: none; }

.q-clear {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
  color: #6b7280;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.q-clear:hover { background: rgba(127, 127, 127, 0.22); }

.text-btn {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 15px;
  padding: 7px 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.16s ease, opacity 0.16s ease;
}

.text-btn.muted { color: #6b7280; }
.text-btn.strong { font-weight: 600; }
.text-btn:hover { background: var(--blue-weak); }
.text-btn.muted:hover { background: rgba(127, 127, 127, 0.1); }
.text-btn:disabled { color: var(--muted); background: transparent; cursor: default; opacity: 0.75; }

/* ── 年份快捷条 ───────────────────────────────────── */

.yearbar {
  max-width: var(--feed-w);
  margin: 0 auto;
  padding: 0 12px 10px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.yearbar::-webkit-scrollbar { display: none; }

.year-chip {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.year-chip:hover { background: rgba(127, 127, 127, 0.08); color: var(--text); }

.year-chip[aria-current="true"] {
  background: var(--blue-weak);
  color: var(--blue);
  font-weight: 600;
}

/* ── 搜索统计 ─────────────────────────────────────── */

.list-note {
  max-width: var(--feed-w);
  margin: 0 auto;
  padding: 4px 16px 8px;
  font-size: 13px;
  color: var(--muted);
}

/* ── 手记卡片 ─────────────────────────────────────── */

.feed {
  max-width: var(--feed-w);
  margin: 0 auto;
  padding: 6px 12px 122px;
}

.note {
  position: relative;
  margin: 0 0 12px;
  padding: 15px 16px 16px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.18s ease;
  cursor: pointer;
  overflow: hidden;
}

@media (hover: hover) {
  .note:hover { box-shadow: var(--card-hover); }
}

.note-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.note-time {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.note-more {
  flex: none;
  width: 28px;
  height: 22px;
  margin: -3px -7px 0 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
  font-size: 16px;
  line-height: 1;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.note-more:hover { background: rgba(127, 127, 127, 0.12); color: #6b7280; }

.note-title {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-width: 0;
}

.tag {
  max-width: 100%;
  min-width: 0;
  border: 0;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--blue-weak);
  color: var(--blue);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.15;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter 0.15s ease;
}

.tag:hover { filter: brightness(0.97); }

.note-body {
  margin: 8px 0 0;
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}

.note-head + .note-body { margin-top: 6px; }

/* Markdown 正文 */
.note-md {
  margin: 6px 0 0;
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  color: var(--text);
  overflow-wrap: anywhere;
  cursor: text;
}

.note-md.is-collapsed { max-height: 10.5em; overflow: hidden; }

.note-md > :first-child { margin-top: 0; }
.note-md > :last-child { margin-bottom: 0; }

.note-md p { margin: 0 0 0.72em; }
.note-md p:last-child { margin-bottom: 0; }

.note-md h1,
.note-md h2,
.note-md h3,
.note-md h4 {
  margin: 0.55em 0 0.5em;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
}

.note-md h1 { font-size: 19px; }
.note-md h2 { font-size: 18px; }
.note-md h3 { font-size: 17.5px; }
.note-md h4 { font-size: 17px; }

.note-md strong { font-weight: 700; color: var(--ink); }
.note-md em { font-style: italic; }
.note-md del { color: var(--muted); }

.note-md ul,
.note-md ol { margin: 0.35em 0 0.8em; padding-left: 1.4em; }
.note-md li { margin: 0.18em 0; }
.note-md li::marker { color: var(--muted); }

.note-md blockquote {
  margin: 0.7em 0;
  padding: 0.05em 0 0.05em 0.9em;
  border-left: 3px solid var(--line);
  color: #4b5563;
}

.note-md blockquote p { margin: 0.2em 0; }

.note-md pre {
  margin: 0.8em 0;
  padding: 12px 14px;
  background: rgba(127, 127, 127, 0.08);
  border-radius: 10px;
  overflow-x: auto;
}

.note-md code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(127, 127, 127, 0.1);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.note-md pre code {
  background: none;
  padding: 0;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre;
}

.note-md hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 1.1em 0;
}

.note-md a { color: var(--blue); text-decoration: none; }
.note-md a:hover { text-decoration: underline; }

.note-md img {
  display: block;
  max-width: 100%;
  margin: 0.6em 0;
  border-radius: 10px;
}

.md-tag { color: var(--blue); cursor: pointer; }
.md-tag:hover { text-decoration: underline; }

.note-md mark {
  background: #ffeaa0;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

@media (prefers-color-scheme: dark) {
  .note-md blockquote { color: #b4b8bf; }
  .note-md mark { background: #574713; }
}

.note-body.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
}

.note-body mark {
  background: #ffeaa0;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

@media (prefers-color-scheme: dark) {
  .note-body mark { background: #574713; }
}

.note-expand {
  display: inline-block;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 15px;
  cursor: pointer;
}

/* ── 列表状态 ─────────────────────────────────────── */

.feed-status {
  max-width: var(--feed-w);
  margin: 0 auto;
  padding: 2px 16px 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.feed-status button {
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 13px;
  padding: 0 2px;
  cursor: pointer;
}

.sentinel { height: 1px; }

.empty-pad {
  padding: 72px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.empty-pad strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.skeleton-card {
  margin: 0 0 12px;
  padding: 15px 16px 16px;
  background: var(--card);
  border-radius: 16px;
}

.skeleton-card i {
  display: block;
  height: 11px;
  margin-bottom: 11px;
  border-radius: 6px;
  background: var(--line-soft);
}

.skeleton-card i:nth-child(1) { width: 30%; }
.skeleton-card i:nth-child(2) { width: 62%; height: 16px; margin-bottom: 13px; }
.skeleton-card i:nth-child(3) { width: 86%; margin-bottom: 0; }

/* ── 底部输入条 ───────────────────────────────────── */

.composer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 58%, rgba(0, 0, 0, 0));
  pointer-events: none;
}

.composer-shell {
  width: 100%;
  max-width: var(--feed-w);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.composer-fake {
  flex: 1;
  min-width: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.06);
  color: var(--muted);
  font-size: 15.5px;
  cursor: text;
  transition: box-shadow 0.18s ease;
}

.composer-fake:hover { box-shadow: 0 4px 14px rgba(17, 24, 39, 0.09); }

.composer-fake svg { width: 18px; height: 18px; flex: none; color: var(--faint); }

.composer-fab {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--blue);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.08);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.composer-fab:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(17, 24, 39, 0.12); }
.composer-fab:active { transform: none; }
.composer-fab svg { width: 22px; height: 22px; }

@media (prefers-color-scheme: dark) {
  .composer-fake { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); }
  .composer-fab { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); }
}

/* ── 下拉 / 菜单 ──────────────────────────────────── */

.note-menu {
  position: fixed;
  z-index: 80;
  min-width: 132px;
  padding: 6px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.16), 0 0 0 1px rgba(17, 24, 39, 0.04);
  animation: pop-in 0.14s ease;
}

.note-menu button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.note-menu button:hover { background: rgba(127, 127, 127, 0.09); }

.note-menu button.danger { color: var(--danger); }
.note-menu button.danger:hover { background: var(--danger-weak); }

/* ── 写 / 编辑 ────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.38);
  animation: fade-in 0.16s ease;
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  padding: 12px 18px 12px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 30px 70px rgba(17, 24, 39, 0.26);
  animation: pop-in 0.18s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
}

.modal-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.composer-text {
  width: 100%;
  min-height: 120px;
  max-height: 56vh;
  padding: 8px 0;
  border: 0;
  outline: none;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.8;
  caret-color: var(--blue);
}

.composer-text::placeholder { color: var(--faint); }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.modal-hint,
.modal-count { font-size: 12px; color: var(--muted); }

.modal-count { font-variant-numeric: tabular-nums; }

/* ── 删除确认 ─────────────────────────────────────── */

.confirm { z-index: 85; }

.confirm-card {
  width: min(330px, 100%);
  padding: 20px;
  border-radius: 16px;
  gap: 0;
}

.confirm-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink);
}

.confirm-text {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  flex: 1;
  height: 40px;
  border: 0;
  border-radius: 10px;
  font-size: 14.5px;
  cursor: pointer;
  transition: filter 0.16s ease, background-color 0.16s ease;
}

.btn-ghost { background: rgba(127, 127, 127, 0.1); color: #4b5563; }
.btn-ghost:hover { background: rgba(127, 127, 127, 0.16); }

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

/* ── 钥匙门 ───────────────────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.gate-card {
  width: min(342px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 24px 24px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.08);
  text-align: center;
}

.gate-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  font-size: 26px;
  font-weight: 600;
}

.gate-card h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}

.gate-desc { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }

.gate-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  text-align: center;
  outline: none;
  transition: border-color 0.16s ease;
}

.gate-input:focus { border-color: var(--blue); }

.gate-submit {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.gate-submit:disabled { opacity: 0.6; cursor: default; }

.gate-hint { margin: 8px 0 0; font-size: 12px; line-height: 1.7; color: var(--muted); }
.gate-hint.is-error { color: var(--danger); }

/* ── toast ────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  z-index: 100;
  transform: translateX(-50%);
  max-width: calc(100vw - 48px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
  animation: toast-in 0.18s ease;
}

@media (prefers-color-scheme: dark) {
  .toast { background: rgba(232, 234, 237, 0.95); color: #111214; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── 窄屏 ─────────────────────────────────────────── */

@media (max-width: 640px) {
  .topbar-inner { height: 56px; padding: 0 12px; gap: 8px; }

  .brand { font-size: 19px; }

  .searchbar { padding: 2px 12px 10px; }

  .yearbar { padding: 0 10px 8px; gap: 4px; }

  .year-chip { padding: 7px 10px; font-size: 12.5px; }

  .list-note { padding: 2px 16px 6px; }

  .feed { padding: 4px 12px 116px; }

  .note { padding: 14px 16px 15px; border-radius: 15px; }

  .note-title { font-size: 17px; }

  .note-body { font-size: 16.5px; line-height: 1.75; }

  .note-md { font-size: 16.5px; }

  .note-md h1 { font-size: 18px; }
  .note-md h2 { font-size: 17.5px; }
  .note-md h3 { font-size: 17px; }
  .note-md h4 { font-size: 16.5px; }

  .composer-bar { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }

  .composer-shell { gap: 8px; }

  .composer-fake { height: 50px; padding: 0 16px; font-size: 15px; }

  .composer-fab { width: 50px; height: 50px; }

  /* 写笔记在手机上占满整屏 */
  .modal { align-items: stretch; padding: 0; }

  .modal-card {
    width: 100%;
    height: 100%;
    border-radius: 0;
    padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 10px);
    animation: sheet-up 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .composer-text { min-height: 40vh; max-height: none; flex: 1; }

  .modal.confirm {
    align-items: center;
    padding: 24px;
  }

  .modal.confirm .modal-card {
    height: auto;
    border-radius: 16px;
    padding: 20px;
  }

  .toast { bottom: 88px; }
}

@keyframes sheet-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
