/* ==========================================================================
   黑钢笔 · 墨与纸的设计系统
   ========================================================================== */

:root {
  --paper: #f4efe4;
  --paper-2: #fbf7ee;
  --card: #fffdf7;
  --ink: #191a1c;
  --ink-soft: #575146;
  --muted: #8b8272;
  --line: #e3dac8;
  --line-strong: #d2c5ac;
  --accent: #191a1c;
  --accent-contrast: #f8f1e1;
  --gold: #8f6a2f;
  --gold-soft: #c8ab74;
  --danger: #b23a28;
  --shadow-sm: 0 1px 2px rgba(45, 35, 15, 0.05);
  --shadow-md: 0 2px 4px rgba(45, 35, 15, 0.04), 0 14px 34px rgba(45, 35, 15, 0.07);
  --shadow-lg: 0 30px 80px rgba(24, 18, 8, 0.28);
  --radius: 14px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --font-serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --font-title: "Microsoft YaHei", "微软雅黑", "SimHei", "黑体", "PingFang SC", "Noto Sans SC",
    "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d0f13;
    --paper-2: #111419;
    --card: #161a20;
    --ink: #eee8da;
    --ink-soft: #b6afa1;
    --muted: #8b8477;
    --line: #262c35;
    --line-strong: #343c48;
    --accent: #ecdcb8;
    --accent-contrast: #14161b;
    --gold: #d9b672;
    --gold-soft: #b08d4d;
    --danger: #ef8b7a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.28), 0 16px 40px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0d0f13;
  --paper-2: #111419;
  --card: #161a20;
  --ink: #eee8da;
  --ink-soft: #b6afa1;
  --muted: #8b8477;
  --line: #262c35;
  --line-strong: #343c48;
  --accent: #ecdcb8;
  --accent-contrast: #14161b;
  --gold: #d9b672;
  --gold-soft: #b08d4d;
  --danger: #ef8b7a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.28), 0 16px 40px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 12% -8%, color-mix(in srgb, var(--paper-2) 70%, transparent), transparent 70%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--gold) 7%, transparent), transparent 65%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.small {
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
}

.spacer {
  flex: 1;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-soft);
  background: var(--paper-2);
}

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

::selection {
  background: color-mix(in srgb, var(--gold) 28%, transparent);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

/* ==========================================================================
   按钮与表单
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn.primary:hover {
  filter: brightness(1.12);
  background: var(--accent);
}

.btn.ghost {
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn.ghost:hover {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn.icon {
  width: 34px;
  padding: 0;
}

.btn.danger {
  color: var(--danger);
}

.btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 9%, transparent);
}

.btn.block {
  width: 100%;
  height: 42px;
  font-size: 14.5px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.link {
  border: 0;
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--gold);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.field input {
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent);
}

.form-error {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 13px;
}

.tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold);
  font-size: 0.92em;
}

/* ==========================================================================
   登录
   ========================================================================== */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: clamp(36px, 6vw, 84px);
  overflow: hidden;
  color: #f2ebdc;
  background:
    radial-gradient(600px 420px at 18% 22%, rgba(214, 178, 106, 0.22), transparent 62%),
    radial-gradient(700px 500px at 90% 110%, rgba(120, 96, 58, 0.28), transparent 60%),
    #111318;
}

.auth-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(70% 60% at 30% 40%, #000, transparent);
  pointer-events: none;
}

.auth-mark img {
  width: clamp(88px, 11vw, 124px);
  height: auto;
  border-radius: 26px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

.auth-name {
  font-family: var(--font-serif);
  font-size: clamp(34px, 4vw, 46px);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.2;
}

.auth-tagline {
  max-width: 22em;
  font-size: 16px;
  color: rgba(242, 235, 220, 0.72);
}

.auth-points {
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  font-size: 13.5px;
  color: rgba(242, 235, 220, 0.66);
}

.auth-points li {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.auth-points li::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--gold-soft);
}

.auth-points kbd {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
  color: rgba(242, 235, 220, 0.85);
}

.auth-points .tag {
  background: rgba(214, 178, 106, 0.16);
  color: #dfbd80;
}

.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 15px;
  width: min(420px, 100%);
  margin: 0 auto;
  padding: clamp(30px, 6vw, 72px) 24px;
}

.auth-form h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  letter-spacing: 0.06em;
}

/* ==========================================================================
   应用外壳
   ========================================================================== */

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 62px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex: none;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 420px;
  max-width: 520px;
  height: 36px;
  margin: 0 auto;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search:focus-within {
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 15%, transparent);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: var(--ink);
}

.search input::placeholder {
  color: var(--muted);
}

.search-kbd {
  flex: none;
  opacity: 0.8;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  cursor: pointer;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 190px;
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}

.menu-pop a,
.menu-pop button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  text-align: left;
  text-decoration: none;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.menu-pop a:hover,
.menu-pop button:hover {
  background: var(--paper);
  color: var(--ink);
}

.menu-pop .who {
  padding: 4px 10px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.nav {
  display: grid;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  font-size: 13.5px;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
}

.nav-item.active {
  color: var(--ink);
  background: var(--card);
  border-color: var(--line);
  box-shadow: inset 2px 0 0 var(--gold), var(--shadow-sm);
}

.nav-item .count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.nav-item.mobile-only {
  display: none;
}

.rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  margin-bottom: 10px;
}

.rail-head h2 {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0 8px;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.chip .count {
  font-size: 10.5px;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

.chip .hash {
  opacity: 0.55;
}

#tag-empty {
  padding: 0 10px;
  line-height: 1.7;
}

.rail-foot {
  margin-top: auto;
  padding: 0 10px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

/* 左侧时间归档：年 → 月 → 日 */
.archive-tree {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.archive-node {
  display: flex;
  flex-direction: column;
}

.archive-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.archive-toggle,
.archive-spacer {
  flex: none;
  width: 20px;
}

.archive-toggle {
  display: grid;
  place-items: center;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.archive-toggle:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
}

.archive-toggle[aria-expanded="true"] {
  transform: rotate(90deg);
}

.archive-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.archive-label:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
}

.archive-label.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--gold), var(--shadow-sm);
}

.archive-label .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.archive-year > .archive-row .archive-label {
  font-weight: 600;
}

.archive-months,
.archive-days {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-left: 12px;
}

.archive-day .archive-label {
  padding: 4px 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.archive-day .archive-label.active {
  color: var(--ink);
}

.archive-weekday {
  color: var(--muted);
  font-size: 10.5px;
}

.archive-empty {
  padding: 0 10px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

/* 手机上侧栏被收成横向导航，标签用这条单独的横向标签栏 */
.mobile-tags {
  display: none;
}

.main {
  overflow-y: auto;
  scroll-behavior: smooth;
}

.main-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 26px 30px 96px;
}

/* ==========================================================================
   快速记录
   ========================================================================== */

.composer {
  padding: 14px 16px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.18s ease;
}

.composer:focus-within {
  border-color: var(--gold-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 12%, transparent), var(--shadow-md);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  max-height: 40vh;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--ink);
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* ==========================================================================
   卡片流
   ========================================================================== */

.stream-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 2px 16px;
}

.stream-head h2 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stream {
  column-width: 320px;
  column-gap: 20px;
}

.card {
  display: block;
  width: 100%;
  margin: 0 0 20px;
  padding: 17px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  break-inside: avoid;
  cursor: pointer;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.card.pinned::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, var(--gold), color-mix(in srgb, var(--gold) 30%, transparent));
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card-title {
  flex: 1;
  min-width: 0;
  max-height: 4.35em;
  overflow: hidden;
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.pin-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -3px -6px 0 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.card:hover .pin-toggle,
.card.pinned .pin-toggle,
.pin-toggle:focus-visible {
  opacity: 1;
}

.pin-toggle:hover {
  background: var(--paper);
  color: var(--gold);
}

.card.pinned .pin-toggle {
  color: var(--gold);
}

.pin-toggle .icon {
  width: 16px;
  height: 16px;
}

.card-body {
  margin-top: 8px;
  max-height: 330px;
  overflow: hidden;
  color: var(--ink-soft);
}

.card-body.clamped {
  mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
}

.card-body.md {
  font-size: 14.5px;
}

.card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.card-tags .chip {
  padding: 2px 8px;
  border: 0;
  background: color-mix(in srgb, var(--gold) 11%, transparent);
  color: color-mix(in srgb, var(--gold) 80%, var(--ink));
  font-size: 11.5px;
}

.card-tags .chip:hover {
  background: color-mix(in srgb, var(--gold) 20%, transparent);
}

.card-time {
  flex: none;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 70px 20px;
  text-align: center;
}

.empty img {
  border-radius: 20px;
  opacity: 0.92;
  margin-bottom: 4px;
}

.empty p:first-of-type {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.loading {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ==========================================================================
   Markdown 排版
   ========================================================================== */

.md {
  font-size: 15px;
  line-height: 1.78;
  color: var(--ink);
  overflow-wrap: anywhere;
}

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

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

.md p {
  margin: 0 0 0.7em;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  font-family: var(--font-serif);
  line-height: 1.4;
  margin: 1.1em 0 0.45em;
}

.md h1 {
  font-size: 1.5em;
}

.md h2 {
  font-size: 1.3em;
}

.md h3 {
  font-size: 1.14em;
}

.md h4 {
  font-size: 1em;
}

.md ul,
.md ol {
  margin: 0.2em 0 0.8em;
  padding-left: 1.4em;
}

.md li {
  margin: 0.18em 0;
}

.md li input[type="checkbox"] {
  margin-right: 5px;
  accent-color: var(--gold);
}

.md blockquote {
  margin: 0.4em 0 0.8em;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--gold-soft);
  color: var(--ink-soft);
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.2em 0;
}

.md code {
  padding: 0.12em 0.36em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
}

.md pre {
  margin: 0.5em 0 0.9em;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  overflow-x: auto;
}

.md pre code {
  padding: 0;
  background: none;
  font-size: 13px;
  line-height: 1.65;
}

.md a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.55em 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-2);
}

.card-body.md img {
  width: auto;
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.edit-preview.md img {
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.md del {
  opacity: 0.6;
}

.md-tag {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  color: var(--ink-soft);
  font-size: 0.95em;
}

/* ==========================================================================
   编辑抽屉
   ========================================================================== */

dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(14, 11, 6, 0.46);
  backdrop-filter: blur(3px);
}

dialog.editor {
  width: min(900px, calc(100vw - 40px));
  height: min(860px, calc(100dvh - 48px));
  border-radius: 18px;
  overflow: hidden;
}

.editor-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 22px 8px;
}

.editor-head-main {
  flex: 1;
  min-width: 0;
}

.edit-title {
  width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.edit-title::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.edit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  min-height: 20px;
}

.edit-tags .chip {
  padding: 1px 8px;
  font-size: 11.5px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 22px 10px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 输入 # 时弹出的已有标签 */
.tag-menu {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}

.tag-menu[hidden] {
  display: none;
}

.tag-menu-head {
  padding: 2px 8px 5px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.tag-menu-item {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.tag-menu-item:hover,
.tag-menu-item.active {
  background: var(--paper);
  color: var(--ink);
}

.tag-menu-item .hash {
  color: var(--gold);
}

.tag-menu-item .count {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.tag-menu-foot {
  margin-top: 4px;
  padding: 5px 8px 1px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
}

.seg {
  display: flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.seg button {
  padding: 4px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}

.seg button.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

#edit-status {
  min-width: 4.5em;
}

.edit-body {
  flex: 1;
  width: 100%;
  padding: 18px 22px;
  border: 0;
  outline: none;
  resize: none;
  background-color: transparent;
  /* 横格纸：行高 28px，让空白处也像一页本当 */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    color-mix(in srgb, var(--line) 60%, transparent) 27px,
    color-mix(in srgb, var(--line) 60%, transparent) 28px
  );
  background-position: 0 18px;
  background-attachment: local;
  font-size: 15.5px;
  line-height: 28px;
  color: var(--ink);
}

.edit-body::placeholder {
  color: var(--muted);
}

.edit-preview {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}

.ai-panel {
  max-height: 34%;
  overflow-y: auto;
  padding: 12px 22px 14px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-transform: uppercase;
}

.ai-head span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai-panel .md {
  font-size: 14px;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
}

/* ==========================================================================
   回顾
   ========================================================================== */

dialog.review {
  width: min(760px, calc(100vw - 40px));
  max-height: min(820px, calc(100dvh - 60px));
  border-radius: 18px;
  overflow: hidden;
}

.review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.review-head h2 {
  font-family: var(--font-serif);
  font-size: 21px;
  letter-spacing: 0.04em;
}

.review-head .row {
  display: flex;
  gap: 6px;
}

.review-body {
  max-height: min(660px, calc(100dvh - 190px));
  overflow-y: auto;
  padding: 8px 22px 24px;
}

.review-body section {
  margin-top: 16px;
}

.review-body h3 {
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* 手机端按时间查找 */
dialog.archive-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 48px));
  border-radius: 18px;
  overflow: hidden;
}

dialog.archive-dialog[open] {
  display: flex;
  flex-direction: column;
}

.archive-dialog-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.archive-dialog-head h2 {
  font-family: var(--font-title);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.archive-dialog-head p {
  margin-top: 3px;
}

.archive-dialog-body {
  flex: 1;
  min-height: 0;
  max-height: min(620px, calc(100dvh - 210px));
  overflow-y: auto;
  padding: 10px 16px 14px;
}

.archive-dialog-body .archive-tree {
  padding: 0;
}

.archive-dialog-foot {
  display: flex;
  flex: none;
  justify-content: flex-end;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.review-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.review-item {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.review-item:hover {
  border-color: var(--line-strong);
  background: var(--paper-2);
}

.review-item strong {
  display: block;
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.review-item span {
  display: block;
  max-width: 100%;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-empty {
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 2px;
}

/* ==========================================================================
   提示
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: min(90vw, 460px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.18s ease;
}

.fab.fab-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.9);
}

.fab .icon {
  width: 22px;
  height: 22px;
}

.fab:active {
  transform: scale(0.96);
}

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .main-inner {
    padding: 22px 22px 90px;
  }

  .rail {
    padding: 18px 10px;
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    gap: 8px;
    padding: 8px 14px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .brand {
    order: 1;
  }

  .brand img {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .brand-name {
    font-size: 17px;
  }

  .top-actions {
    order: 2;
    margin-left: auto;
    gap: 4px;
  }

  .top-actions .btn {
    height: 40px;
  }

  .top-actions .btn.icon {
    width: 40px;
  }

  /* 顶栏的「回顾」和底部导航重复，手机上只保留导航里的入口 */
  #review-btn {
    display: none;
  }

  .search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
    height: 42px;
    border-radius: 11px;
  }

  .search-kbd {
    display: none;
  }

  .hide-sm {
    display: none;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  .rail {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: none;
    gap: 4px;
    padding: 5px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

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

  .nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .nav-item {
    width: auto;
    flex: none;
    min-height: 40px;
    padding: 8px;
    gap: 8px;
    font-size: 12.5px;
    white-space: nowrap;
  }

  .nav-item.mobile-only {
    display: flex;
  }

  .nav-item.active {
    background: transparent;
    border-color: transparent;
    box-shadow: inset 0 -2px 0 var(--gold);
  }

  .nav-item .count,
  .rail-block,
  .rail-foot {
    display: none;
  }

  .mobile-tags {
    display: flex;
    flex: none;
    gap: 6px;
    padding: 1px 14px 9px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mobile-tags::-webkit-scrollbar {
    display: none;
  }

  .mobile-tags .chip {
    flex: none;
    min-height: 30px;
    padding: 4px 10px;
  }

  .main {
    flex: 0 0 auto;
    overflow: visible;
  }

  .main-inner {
    padding: 12px 14px 104px;
  }

  .composer {
    padding: 10px 12px 8px;
    border-radius: 14px;
  }

  .composer textarea {
    min-height: 44px;
    line-height: 1.55;
  }

  .composer-bar {
    margin-top: 4px;
  }

  .composer .hint {
    display: none;
  }

  .composer .btn {
    height: 40px;
  }

  .composer .btn.icon {
    width: 40px;
  }

  .composer-actions {
    margin-left: auto;
    gap: 8px;
  }

  .stream-head {
    margin: 18px 2px 12px;
  }

  .stream-head h2 {
    font-size: 20px;
  }

  .stream {
    column-width: auto;
    column-count: 1;
  }

  .card {
    margin-bottom: 14px;
    padding: 16px 16px 13px;
    border-radius: 14px;
  }

  .card-title {
    font-size: 18px;
    line-height: 1.45;
  }

  .card-body {
    max-height: 60vh;
    margin-top: 7px;
  }

  .card-body.md {
    font-size: 15.5px;
    line-height: 1.72;
  }

  .card-foot {
    margin-top: 10px;
  }

  .card-time {
    font-size: 11.5px;
  }

  .card-tags .chip {
    min-height: 28px;
    padding: 4px 9px;
  }

  .pin-toggle {
    width: 40px;
    height: 40px;
    margin: -9px -10px 0 0;
    opacity: 1;
  }

  .pin-toggle .icon {
    width: 18px;
    height: 18px;
  }

  .fab {
    display: grid;
  }

  .toast {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .auth {
    grid-template-columns: 1fr;
    align-content: start;
    min-height: 100dvh;
  }

  .auth-brand {
    gap: 8px;
    padding: 26px 24px 20px;
    text-align: left;
  }

  .auth-brand::after {
    display: none;
  }

  .auth-mark img {
    width: 64px;
    border-radius: 16px;
  }

  .auth-name {
    font-size: 28px;
  }

  .auth-tagline {
    font-size: 13.5px;
  }

  .auth-points {
    display: none;
  }

  .auth-form {
    width: 100%;
    justify-content: flex-start;
    gap: 13px;
    padding: 24px 24px calc(32px + env(safe-area-inset-bottom));
  }

  .auth-form h2 {
    font-size: 24px;
  }

  .auth-form .field input {
    height: 46px;
  }

  .auth-form .btn.block {
    height: 46px;
  }

  dialog.editor {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .editor-head {
    padding: 12px 16px 6px;
  }

  .editor-head .btn.icon {
    width: 40px;
    height: 40px;
  }

  .edit-title {
    font-size: 20px;
  }

  .editor-toolbar,
  .editor-foot {
    padding-inline: 16px;
  }

  .editor-toolbar {
    gap: 6px;
    padding-top: 6px;
    padding-bottom: 9px;
  }

  .editor-actions {
    width: 100%;
    margin-left: 0;
    padding-top: 2px;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .editor-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    height: 40px;
    padding: 0 4px;
    gap: 4px;
    font-size: 12px;
  }

  .editor-actions .btn .icon {
    width: 16px;
    height: 16px;
  }

  /* 置顶状态靠金色和 aria-pressed 表达，手机上不占一个三字标签的位置 */
  #pin-btn > span {
    display: none;
  }

  .editor-actions .hide-sm {
    display: inline;
  }

  /* AI 按钮在手机上只留图标，避免 5 个操作挤成两行 */
  .editor-actions .ai-label {
    display: none;
  }

  .editor-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .editor-foot .btn.primary {
    height: 40px;
    min-width: 72px;
  }

  #edit-meta {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
  }

  /* iOS / 鸿蒙浏览器聚焦小于 16px 的输入框会强制放大页面 */
  .composer textarea,
  .edit-body,
  .search input,
  .field input {
    font-size: 16px;
  }

  .edit-body,
  .edit-preview {
    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .edit-preview.md {
    font-size: 16px;
    line-height: 1.8;
  }

  dialog.review {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
  }

  .review-body {
    max-height: calc(100dvh - 150px);
    padding-inline: 16px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .review-item strong {
    font-size: 16px;
  }

  .review-item span {
    font-size: 13px;
  }

  .review-head .btn.icon {
    width: 40px;
    height: 40px;
  }

  .tag-menu {
    max-width: calc(100vw - 20px);
    max-height: 44vh;
  }

  .tag-menu-item {
    min-height: 40px;
    font-size: 14px;
  }

  .tag-menu-foot {
    display: none;
  }

  dialog.archive-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .archive-dialog-head {
    padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  }

  .archive-dialog-body {
    max-height: none;
    padding: 8px 12px 16px;
  }

  .archive-dialog-foot {
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .archive-dialog-foot .btn {
    width: 100%;
  }

  .archive-label {
    min-height: 38px;
    font-size: 14px;
  }

  .archive-day .archive-label {
    min-height: 36px;
    font-size: 13px;
  }

  .archive-toggle {
    width: 28px;
    height: 38px;
    font-size: 12px;
  }

  .archive-spacer {
    width: 28px;
  }
}

@media (max-width: 380px) {
  .nav-item {
    padding: 8px 6px;
    gap: 6px;
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .brand-name {
    font-size: 16px;
  }

  .theme-label {
    display: none;
  }
}

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

/* ==========================================================================
   修改密码对话框
   ========================================================================== */

.pass-dialog {
  width: min(420px, calc(100vw - 32px));
  border-radius: 16px;
  padding: 0;
}

.pass-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px 18px;
}

.pass-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pass-head h2 {
  font-size: 18px;
}

.pass-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ==========================================================================
   备案信息页脚（由服务端按 ICP_BEIAN / POLICE_BEIAN 注入）
   ========================================================================== */

.beian-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.beian-footer a {
  color: inherit;
  text-decoration: none;
}

.beian-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* 页脚固定时给主容器留出等高空间，避免遮住底部按钮 */
body.has-beian .app {
  padding-bottom: 38px;
}

body.has-beian .auth {
  padding-bottom: 38px;
}

@media (max-width: 640px) {
  .beian-footer {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    font-size: 11px;
    text-align: center;
  }

  /* 纵向排列后页脚更高，主容器要留更多空间 */
  body.has-beian .app,
  body.has-beian .auth {
    padding-bottom: 52px;
  }
}
