/* commaplace — 小紅書 feed × Medium reading × pure B&W × scroll animations */

/* Source Han Serif TC — unicode-range-split chunks (cn-font-split). Browser
   fetches only chunks with glyphs on the page (~0.5–2MB/page vs the 19.7MB
   monolith). Was previously a single @font-face pointing at /static/… which
   404'd (assets mount at /assets/) — so the font silently fell back to system
   serif. Loaded via <link> in _base.html so it parallelizes with this file. */

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg: #efe6cc;
  --bg-2: #fdf8e0;
  --bg-3: #f5eedd;

  /* Text — WCAG AA (≥4.5:1) on --bg.
     --text-4 is sub-AA: decoration / disabled / placeholder ONLY. */
  --text: #1a1a1a;
  --text-2: #5f5544; /* ~5.9:1 */
  --text-3: #6f6450; /* ~4.6:1 */
  --text-4: #b0a48f;

  /* Borders */
  --border: #d8cebc;
  --border-2: #c4b8a4;

  /* Role tokens — names describe role, not value; they invert in dark mode */
  --ink: #1a1a1a;
  --paper: #ffffff;

  /* Danger (only for destructive actions) */
  --danger: #cc0000;
  --danger-bg: #fff5f5;
  --danger-border: #fcc;

  /* Success (external vault status, callouts) */
  --success: #1a7a4a;
  --success-border: #b8e8d0;
  --success-bg: #f0fdf8;

  /* Frosted glass nav */
  --bg-glass: color-mix(in srgb, var(--bg) 88%, transparent);

  /* Radius */
  --r-card: 16px;
  --r-btn: 8px;
  --r-pill: 999px;
  --r-input: 10px;
  --r-sm: 6px;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --dur-fast: 0.18s;
  --dur-base: 0.35s;
  --dur-slow: 0.6s;

  /* Layout */
  --maxw: 900px;
  --maxw-article: 680px;
  --gap: 1rem;

  /* Typography */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    sans-serif;
  --font-serif:
    "Source Han Serif", "Iowan Old Style", "Apple Garamond", Baskerville,
    "Times New Roman", Georgia, serif;
  --font-mono:
    "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale — every font-size maps to one of these; never literal px */
  --fs-2xs: 0.6875rem; /* 11px — mono micro-labels */
  --fs-xs: 0.75rem; /*   12px — tags, counts       */
  --fs-sm: 0.8125rem; /* 13px — meta, captions     */
  --fs-base: 0.9375rem; /* 15px — UI / small body  */
  --fs-md: 1.0625rem; /* 17px — card / note titles */
  --fs-lg: 1.1875rem; /* 19px — h3, entry titles   */
  --fs-xl: 1.5rem; /*    24px — h2                 */
  --fs-2xl: 2rem; /*     32px — h1                 */
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-2: #262626;
  --bg-3: #323232;
  --text: #efe6cc;
  --text-2: #a89e8e;
  --text-3: #968a72; /* ~5.1:1 on dark --bg */
  --text-4: #5a5040;
  --border: #2c2822;
  --border-2: #3a342c;
  --ink: #efe6cc;
  --paper: #1a1a1a;
  --danger: #ff6b6b;
  --danger-bg: #1a0a0a;
  --danger-border: #4a1515;
  --success: #4ade80;
  --success-border: #1a3a2a;
  --success-bg: #0a1f14;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem 5rem;
}
.page.page-wide {
  max-width: 1400px;
}
.page-wide .topbar {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  grid-template-rows: 60px;
  align-items: center;
  gap: 2.5rem;
}
.page-wide .topbar .brand {
  justify-self: start;
}
.page-wide .topbar .search-form {
  max-width: 26rem;
  flex: none;
  justify-self: start;
  width: 100%;
}
.page-wide .topbar .nav {
  justify-self: end;
}

/* ── Scroll reveal — horizontal clip-path sweep (逐行排版 feel) ─────────── */
[data-reveal] {
  opacity: 0;
  /* ponytail: no clip-path here — clip-path: inset(0 100% 0 0) clips to 0 width, blocking IntersectionObserver. Applied inline via JS before reveal. */
  transition:
    opacity 0.3s ease,
    clip-path 0.5s var(--ease);
}
[data-reveal].revealed {
  opacity: 1;
  clip-path: inset(0 0% 0 0);
}
[data-reveal-delay="1"] {
  transition-delay: 0.06s;
}
[data-reveal-delay="2"] {
  transition-delay: 0.12s;
}
[data-reveal-delay="3"] {
  transition-delay: 0.18s;
}
[data-reveal-delay="4"] {
  transition-delay: 0.24s;
}
[data-reveal-delay="5"] {
  transition-delay: 0.3s;
}
[data-reveal-delay="6"] {
  transition-delay: 0.36s;
}

/* Page fade-in */
.content {
  animation: pageFadeIn 0.4s var(--ease) both;
}
@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Reduce motion — OS preference or the nav toggle (html[data-motion]) ── */
@media (prefers-reduced-motion: reduce) {
  .content {
    animation: none;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] {
    transition-duration: 0.001ms;
    transition-delay: 0s;
    /* !important beats the inline clip-path reveal.js sets pre-reveal; with
       near-zero durations Chromium never fires transitionend, so reveal.js's
       own clip-path cleanup can't be relied on here */
    clip-path: none !important;
  }
}
html[data-motion="reduced"] .content {
  animation: none;
  /* !important beats the inline transition reveal.js sets on every htmx swap
     (content.style.transition = "opacity 0.15s ease") — without it the htmx
     page-fade ignores this toggle */
  transition-duration: 0.001ms !important;
}
html[data-motion="reduced"] [data-reveal] {
  transition-duration: 0.001ms;
  transition-delay: 0s;
  /* !important beats the inline clip-path reveal.js sets pre-reveal; with
     near-zero durations Chromium never fires transitionend, so reveal.js's
     own clip-path cleanup can't be relied on here */
  clip-path: none !important;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: 60px;
  padding: 0;
  position: sticky;
  top: 0;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  margin-bottom: 1.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}
.brand-logo {
  height: 96px;
  width: auto;
  display: block;
}
.brand-name {
  line-height: 1;
}

.search-form {
  margin: 0;
  flex: 1;
  max-width: 26rem;
}
.search-form input {
  width: 100%;
  height: 32px;
  padding: 0 0.85rem;
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font-sans);
  transition:
    border-color var(--dur-fast) ease,
    background var(--dur-fast) ease;
}
.search-form input::placeholder {
  color: var(--text-4);
}
.search-form input:focus {
  outline: none;
  border-color: var(--border-2);
  background: var(--bg);
}

mark {
  background: var(--bg-2);
  color: var(--text);
  padding: 0 0.15em;
  border-radius: 3px;
}

.nav {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  margin-right: 0.25rem;
}
.nav-links a,
.nav-links .link-btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  color: var(--text-3);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  transition: color var(--dur-fast) ease;
}
.nav-links a:hover,
.nav-links .link-btn:hover {
  color: var(--text);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-3);
  cursor: pointer;
  transition:
    color var(--dur-fast) ease,
    background var(--dur-fast) ease;
}
.icon-btn:hover {
  color: var(--text);
  background: var(--bg-2);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 8px);
  background: var(--text);
  color: var(--bg);
  padding: 0.6em 1.1em;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
  z-index: 1000;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.icon-btn .theme-icon {
  display: none;
}
#theme-toggle[data-theme-current="dark"] .theme-icon-moon {
  display: block;
}
#theme-toggle[data-theme-current="light"] .theme-icon-sun {
  display: block;
}
#script-toggle,
#motion-toggle {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
}
#motion-toggle[aria-pressed="true"] {
  color: var(--text);
  background: var(--bg-2);
  text-decoration: line-through;
}

.nav .avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--text);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  text-decoration: none;
  font-family: var(--font-sans);
  flex-shrink: 0;
  overflow: hidden;
  transition: border-color var(--dur-fast) ease;
}
.nav .avatar:hover {
  border-color: var(--text);
}
.nav .avatar .avatar-img {
  position: absolute;
  inset: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  border: 0;
  border-radius: 50%;
}
.nav .avatar:has(.avatar-img) .avatar-initial {
  display: none;
}

.mobile-menu {
  display: none;
}
.mobile-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  list-style: none;
  border-radius: var(--r-sm);
}
.mobile-menu summary::-webkit-details-marker {
  display: none;
}
.mobile-menu summary:hover {
  color: var(--text);
  background: var(--bg-2);
}

@media (max-width: 600px) {
  .nav-links {
    display: none;
  }
  .mobile-menu {
    display: inline-flex;
  }
  .search-form {
    max-width: 10rem;
  }
  .brand-name {
    display: none;
  }
}

.inline-form {
  display: inline;
  margin: 0;
}
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-3);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: color var(--dur-fast) ease;
}
.link-btn:hover {
  color: var(--text);
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1 {
  font-size: var(--fs-2xl);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0.2em 0 0.6em;
  font-family: var(--font-serif);
}
h2 {
  font-size: var(--fs-xl);
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 1.5em 0 0.5em;
}
h3 {
  font-size: var(--fs-lg);
  line-height: 1.3;
  font-weight: 600;
  margin: 1.25em 0 0.4em;
}
p {
  margin: 0 0 1em;
}
ul,
ol {
  margin: 0 0 1em 1.25em;
  padding: 0;
}
li {
  margin: 0.15em 0;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-2);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--dur-fast) ease;
}
a:hover {
  text-decoration-color: var(--text);
}

blockquote {
  border-left: 3px solid var(--border-2);
  padding: 0.1em 0 0.1em 1em;
  margin: 1.2em 0;
  color: var(--text-2);
  font-style: italic;
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-3);
  padding: 0.1em 0.38em;
  border-radius: var(--r-sm);
}
pre {
  background: var(--bg-3);
  padding: 1em 1.1em;
  border-radius: var(--r-card);
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.5;
  border: 1px solid var(--border);
}
pre code {
  background: none;
  padding: 0;
}
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

/* Wiki links */
.wiki-resolved {
  color: var(--text);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.wiki-resolved:hover {
  text-decoration-style: solid;
}
.wiki-unresolved {
  color: var(--text-3);
  text-decoration: underline dashed;
  text-underline-offset: 3px;
}
/* Cross-vault [[@user/note]] — ↗ inverted pill capsule */
.wiki-cross-resolved,
.wiki-cross-unresolved,
.wikilink-cross {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--text);
  color: var(--bg);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  text-decoration: none;
  vertical-align: baseline;
  transition:
    transform 0.15s var(--ease),
    background 0.15s var(--ease);
}
.wiki-cross-resolved:hover,
.wikilink-cross:hover {
  transform: translateY(1px);
  background: var(--text-2);
  color: var(--bg);
}
.wiki-cross-unresolved {
  background: var(--text-3);
  opacity: 0.75;
}
.wikilink-cross .arrow {
  margin-right: 2px;
  opacity: 0.7;
}

/* Collapsed local ego-graph under connected-notes mini-cards. */
.local-graph-toggle {
  margin-top: 0.75em;
}
.local-graph-toggle summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: var(--fs-sm);
  padding: 0.4em 0;
  list-style: none;
  user-select: none;
}
.local-graph-toggle summary::-webkit-details-marker {
  display: none;
}
.local-graph-toggle summary::before {
  content: "▸ ";
}
.local-graph-toggle[open] summary::before {
  content: "▾ ";
}
.local-graph {
  margin-top: 0.5em;
  height: 280px;
  max-width: 100%;
}

/* Note metadata */
.note-meta {
  color: var(--text-3);
  font-size: var(--fs-sm);
  margin: -0.4em 0 1.25em;
}
.note-meta a {
  color: var(--text-3);
}
.crumb-sep {
  margin: 0 0.25em;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}

input[type="text"],
input[type="email"],
input[type="search"],
textarea {
  width: 100%;
  font: inherit;
  padding: 0.65em 0.85em;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  background: var(--bg);
  color: var(--text);
  transition:
    border-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease;
  font-family: var(--font-serif);
}
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

input[type="file"] {
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-3);
  width: 100%;
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 0.45em 0.9em;
  margin-right: 0.75em;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: var(--bg-3);
}
textarea {
  min-height: 18rem;
  line-height: 1.6;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.92em;
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-2);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

button {
  font: inherit;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 0.6em 1.2em;
  border: none;
  border-radius: var(--r-btn);
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  align-self: flex-start;
  transition:
    opacity var(--dur-fast) ease,
    transform var(--dur-fast) ease;
  font-size: var(--fs-sm);
}
button:hover {
  opacity: 0.85;
}
button:active {
  transform: scale(0.97);
}

button.secondary {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover {
  border-color: var(--border-2);
  background: var(--bg-3);
}

.btn-primary {
  display: inline-block;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 0.6em 1.2em;
  border-radius: var(--r-btn);
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: opacity var(--dur-fast) ease;
}
.btn-primary:hover {
  opacity: 0.8;
  text-decoration: none;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.7em 1.2em;
  border-radius: var(--r-btn);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  transition:
    border-color var(--dur-fast) ease,
    background var(--dur-fast) ease;
}
.btn-google:hover {
  border-color: var(--border-2);
  background: var(--bg-2);
  text-decoration: none;
}

.login-divider {
  text-align: center;
  color: var(--text-3);
  margin: 0.5em 0;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}

.field-error {
  color: var(--danger);
  font-size: var(--fs-sm);
  margin-top: 0.25rem;
  font-family: var(--font-sans);
}

.flash {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-2);
  padding: 0.8em 1.1em;
  border-radius: var(--r-btn);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
}
.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-left: 3px solid var(--danger);
  padding: 0.8em 1.1em;
  border-radius: var(--r-btn);
  color: var(--danger);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
}

/* ── Vault masthead ─────────────────────────────────────────────────────── */
.vault-masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--text);
  padding-bottom: 8px;
  margin-bottom: 20px;
}
.vault-name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0;
  font-style: normal;
}
.vault-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--text-3);
}
.profile-notes-heading {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 0.5px solid var(--border);
  padding-bottom: 0.6em;
  margin-bottom: 0;
}

/* ── 小紅書 Feed Cards ──────────────────────────────────────────────────── */
.masonry {
  column-count: 2;
  column-gap: 14px;
}
.feed-shell .masonry {
  column-count: 3;
}
@media (max-width: 800px) {
  .feed-shell .masonry {
    column-count: 2;
  }
}
.masonry-card {
  display: block;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 12px;
  padding: 1.1em 1.15em 0.9em;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-card);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 2px 6px rgba(0, 0, 0, 0.06);
  text-decoration: none;
  color: inherit;
  transition:
    transform var(--dur-base) var(--ease),
    box-shadow var(--dur-base) var(--ease);
  position: relative;
  overflow: hidden;
}
html[data-theme="dark"] .masonry-card {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.4);
}
.masonry-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.06),
    0 8px 20px rgba(0, 0, 0, 0.08);
  text-decoration: none;
}
html[data-theme="dark"] .masonry-card:hover {
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.5),
    0 8px 20px rgba(0, 0, 0, 0.5);
}

/* One note-title voice: every list/card surface renders the same object
   the same way (serif / 600 / --fs-md / upright). */
.card-title,
.note-card .note-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-style: normal;
  font-size: var(--fs-md);
  line-height: 1.3;
  color: var(--text);
}
.card-title {
  margin: 0 0 0.5em;
}
.card-image {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--r-btn);
  margin: 0 0 0.7em;
}
.card-excerpt {
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
  margin: 0 0 0.7em;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-list {
  list-style: disc;
  margin: 0 0 0.7em;
  padding-left: 1.1em;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.65;
}
.card-list li {
  margin: 0;
}
.card-quote {
  font-family: var(--font-serif);
  margin: 0 0 0.7em;
  padding: 0 0 0 0.75em;
  border-left: 2.5px solid var(--border-2);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1.6;
  font-style: italic;
}
.card-connections {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin: 0 0 0.7em;
  padding: 0.6em 0.8em;
  background: var(--bg-3);
  border-radius: var(--r-btn);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.connection {
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.connection-more {
  color: var(--text-3);
  font-style: italic;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.45em;
  margin-top: 0.5em;
  padding-top: 0.6em;
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-3);
  flex-wrap: wrap;
  font-family: var(--font-sans);
}
.card-meta .meta-handle {
  color: var(--text);
  font-weight: 600;
}
.card-meta .meta-spacer {
  flex: 1;
}
.card-meta .meta-like,
.card-meta .meta-links {
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.card-meta .meta-cross {
  color: var(--text-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.card-tags {
  display: flex;
  gap: 0.4em;
  flex-wrap: wrap;
  margin: 0 0 0.5em;
}
.card-tag {
  color: var(--text-2);
  background: var(--bg-3);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: var(--fs-2xs);
  font-family: var(--font-sans);
}

.avatar-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3em;
  height: 1.3em;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Note-card list (profile page) ─────────────────────────────────────── */
.note-card {
  display: block;
  padding: 1.1em 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background var(--dur-fast) ease;
}
.note-card:hover .note-title {
  text-decoration: underline;
  text-decoration-color: var(--border-2);
}
.note-card .note-excerpt {
  color: var(--text-2);
  font-size: var(--fs-base);
  margin-top: 0.25em;
}
.note-card .note-foot {
  color: var(--text-3);
  font-size: var(--fs-sm);
  margin-top: 0.4em;
  font-family: var(--font-sans);
}
.note-card-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
}
.note-card-row .note-card {
  flex: 1;
  min-width: 0;
}

/* ── Older / load more ──────────────────────────────────────────────────── */
.older-link {
  display: inline-block;
  padding: 0.55em 1.2em;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  transition:
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease;
}
.older-link:hover {
  border-color: var(--border-2);
  color: var(--text);
  text-decoration: none;
}

/* ── Tag chips ──────────────────────────────────────────────────────────── */
.tag-row {
  margin: 0.4em 0 1em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
}
.tag-chip {
  display: inline-block;
  padding: 0.22em 0.75em;
  background: var(--bg-2);
  color: var(--text-2);
  text-decoration: none;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  transition:
    background var(--dur-fast) ease,
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease;
}
.tag-chip:hover {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  text-decoration: none;
}

/* The like button now reuses .action-btn (matching its share/save siblings),
   so the old .heart button rules were removed here. .heart-static below was
   already unused before that change — left as-is (pre-existing dead code). */
.heart-static {
  color: var(--text-3);
  font-size: var(--fs-base);
}

/* ── Follow button ──────────────────────────────────────────────────────── */
.follow-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}
.follow-btn {
  background: var(--text);
  color: var(--bg);
  border: 1.5px solid var(--text);
  padding: 0.42em 1.2em;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  align-self: auto;
  transition: opacity var(--dur-fast) ease;
}
.follow-btn:hover {
  opacity: 0.8;
}
.follow-btn.following {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.follow-btn.following:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.follower-count {
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}

/* ── Feed shell (sidebar + main) ────────────────────────────────────────── */
.feed-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2.5rem;
  align-items: start;
}
.feed-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
}
.feed-main {
  min-width: 0;
}
@media (max-width: 800px) {
  .feed-shell {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .feed-sidebar {
    position: static;
  }
}

/* ── Feed tabs (vertical inside sidebar, horizontal as fallback) ────────── */
.feed-tabs {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 1.25rem;
}
.feed-tab {
  padding: 0.55em 0.9em;
  font-size: var(--fs-base);
  color: var(--text-3);
  text-decoration: none;
  border-left: 2px solid transparent;
  font-family: var(--font-sans);
  font-weight: 500;
  transition:
    color var(--dur-fast) ease,
    border-color var(--dur-fast) ease;
}
.feed-tab.active {
  color: var(--text);
  border-left-color: var(--text);
}
.feed-tab:hover {
  color: var(--text-2);
  text-decoration: none;
}

/* ── Filter chips ───────────────────────────────────────────────────────── */
.chip-count {
  opacity: 0.5;
  font-size: var(--fs-2xs);
  margin-left: 0.1em;
}
.filter-chips {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4em;
  margin: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.35em 0.9em;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  white-space: nowrap;
  transition:
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    background var(--dur-fast) ease;
}
.filter-chip:hover {
  color: var(--text);
  border-color: var(--border-2);
  text-decoration: none;
}
.filter-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ── Backlinks ──────────────────────────────────────────────────────────── */
.backlinks {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
}
.backlinks h2 {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin: 0 0 0.6em;
  font-weight: 500;
  font-family: var(--font-sans);
}

/* ── Editor ─────────────────────────────────────────────────────────────── */
.md-upload {
  margin-bottom: 0.75rem;
}
.md-upload label {
  cursor: pointer;
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  transition: color var(--dur-fast) ease;
}
.md-upload label:hover {
  color: var(--text);
}
.md-upload input[type="file"] {
  display: none;
}
.editor-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.editor-actions .download-link {
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.editor-actions .copy-md {
  font-size: var(--fs-sm);
}

/* Live preview pane */
.preview {
  position: relative;
  margin-top: 2rem;
  padding: 1.5rem 1.6rem 1.25rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
#preview {
  transition: opacity 0.15s ease;
}
#preview.preview-loading {
  opacity: 0.35;
}
.preview > h2 {
  position: absolute;
  top: -0.6rem;
  left: 1.1rem;
  margin: 0;
  padding: 0 0.5em;
  background: var(--bg-2);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.08em;
  font-weight: 600;
  font-family: var(--font-sans);
}
#preview {
  line-height: 1.85;
}
#preview > :first-child {
  margin-top: 0;
}
#preview > :last-child {
  margin-bottom: 0;
}
#preview h1 {
  font-size: var(--fs-xl);
  margin: 0 0 0.7em;
}
#preview h2 {
  font-size: var(--fs-lg);
  margin: 1.6em 0 0.5em;
}
#preview h3 {
  font-size: var(--fs-md);
  margin: 1.3em 0 0.4em;
}
#preview p {
  margin: 0 0 1.1em;
}
#preview ul,
#preview ol {
  margin: 0 0 1.1em 1.4em;
}
#preview li {
  margin: 0.35em 0;
}
#preview blockquote {
  margin: 1.1em 0;
}
#preview hr {
  margin: 1.6em 0;
}
#preview:empty::before {
  content: "開始打字，這裡會顯示渲染結果";
  display: block;
  color: var(--text-3);
  font-style: italic;
  font-size: var(--fs-base);
}

/* ── Pinned card ────────────────────────────────────────────────────────── */
.pinned-card {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 0.9em 1.1em;
  margin: 1em 0 1.5em;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.pinned-label {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-family: var(--font-sans);
}
.pinned-link {
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}
.pinned-link:hover {
  text-decoration: underline;
}

/* ── Report ─────────────────────────────────────────────────────────────── */
.report-mount {
  margin-left: 0.6em;
}
.report-thanks {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* ── Autocomplete popup ─────────────────────────────────────────────────── */
.ac-popup {
  position: fixed;
  z-index: 200;
  min-width: 200px;
  max-width: min(320px, 90vw);
  max-height: min(360px, 60vh);
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}
html[data-theme="dark"] .ac-popup {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.ac-popup ul {
  list-style: none;
  padding: 0.4em;
  margin: 0;
}
.ac-item {
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  padding: 0.5em 0.85em;
  cursor: pointer;
  font-size: var(--fs-base);
  border-radius: var(--r-sm);
}
.ac-item.active,
.ac-item:hover {
  background: var(--bg-2);
}
.ac-item .ac-primary {
  font-weight: 500;
  color: var(--text);
}
.ac-item .ac-secondary {
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
}

/* ── Note page — Author bar ─────────────────────────────────────────────── */
.author-bar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  margin: 0 0 1.5rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.author-bar .author-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 600;
  text-transform: uppercase;
  text-decoration: none;
  font-family: var(--font-sans);
}
.author-bar .author-info {
  flex: 1;
  min-width: 0;
}
.author-bar .author-name-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: var(--fs-base);
  flex-wrap: wrap;
}
.author-bar .author-name {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-sans);
}
.author-bar .author-name:hover {
  text-decoration: underline;
}
.author-bar .author-context {
  color: var(--text-3);
  font-family: var(--font-sans);
}
.author-bar .author-stats {
  color: var(--text-3);
  font-size: var(--fs-sm);
  margin-top: 0.2em;
  font-family: var(--font-sans);
}

/* ── Note page — Article meta row ──────────────────────────────────────── */
.article-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap;
}
.article-info {
  font-size: var(--fs-sm);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex-wrap: wrap;
  font-family: var(--font-sans);
}
.article-info .article-tag {
  color: var(--text-3);
  text-decoration: none;
}
.article-info .article-tag:hover {
  color: var(--text);
}
.article-actions {
  display: flex;
  gap: 0.4em;
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.42em 0.9em;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  border-radius: var(--r-btn);
  font-size: var(--fs-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  text-decoration: none;
  font: inherit;
  font-family: var(--font-sans);
  transition:
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    background var(--dur-fast) ease;
}
/* Icon-only action buttons (⋯ menu, share) — square instead of
   content-width, so they don't look narrower than each other. */
.action-menu summary.action-btn,
.article-actions .share-btn {
  aspect-ratio: 1 / 1;
  justify-content: center;
}
.action-btn:hover {
  border-color: var(--border-2);
  color: var(--text);
  text-decoration: none;
}
.action-btn.primary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-2);
}
.action-btn.primary:hover {
  background: var(--bg-2);
  border-color: var(--text);
}
.action-btn.liked {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
.action-btn.save-btn.saved {
  color: var(--bg);
  background: var(--text-2);
  border-color: var(--text-2);
}
.action-btn.danger {
  color: var(--danger);
}
.action-btn.danger:hover {
  border-color: var(--danger);
}
.action-btn .count {
  font-variant-numeric: tabular-nums;
}

.action-menu {
  position: relative;
}
.action-menu summary {
  list-style: none;
  cursor: pointer;
}
.action-menu summary::-webkit-details-marker {
  display: none;
}
.action-menu[open] .action-menu-list {
  display: flex;
}
.action-menu-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  flex-direction: column;
  min-width: 12em;
  padding: 0.4em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 10;
}
html[data-theme="dark"] .action-menu-list {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Reader settings (Aa) popover */
.reader-menu summary {
  font-family: var(--font-serif);
  font-weight: 600;
}
.reader-panel {
  min-width: 13em;
  gap: 0.55em;
  padding: 0.6em;
}
.reader-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em;
}
.reader-label {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.reader-seg {
  display: inline-flex;
  border: 1px solid var(--border-2);
  border-radius: var(--r-btn);
  overflow: hidden;
}
.reader-opt {
  border: 0;
  background: var(--bg-2);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  padding: 0.32em 0.7em;
  cursor: pointer;
}
.reader-opt + .reader-opt {
  border-left: 1px solid var(--border-2);
}
.reader-opt[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}
.reader-opt[data-reader-set="font"][data-val="serif"] {
  font-family: var(--font-serif);
}
.reader-opt[data-reader-set="font"][data-val="sans"] {
  font-family: var(--font-sans);
}

/* ── Legal pages + site footer ──────────────────────────────────────────── */
.legal {
  max-width: var(--maxw-article);
  margin: 0 auto;
}
.legal h1 {
  font-size: var(--fs-2xl);
  letter-spacing: -0.02em;
}
.legal h2 {
  font-size: var(--fs-lg);
  margin: 1.6em 0 0.4em;
}
.legal p,
.legal li {
  color: var(--text-2);
  line-height: 1.8;
}
.legal ul {
  padding-left: 1.3em;
}
.legal-updated {
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.legal-contact {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.site-footer {
  max-width: var(--maxw);
  margin: 3rem auto 1.5rem;
  padding: 1.2rem 1rem 0;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  text-align: center;
}
.site-footer a {
  color: var(--text-3);
}
.site-footer a:hover {
  color: var(--text);
}

/* ── Change-handle form (owner profile) ─────────────────────────────────── */
.handle-edit {
  display: inline-block;
}
.handle-edit summary {
  cursor: pointer;
  color: var(--text-2);
}
.handle-edit summary:hover {
  color: var(--text);
}
.handle-form {
  display: flex;
  /* the global `form` rule stacks column; this one is a single row */
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-top: 0.6em;
}
.handle-form .handle-at {
  color: var(--text-3);
  font-family: var(--font-sans);
}
.handle-form input {
  width: 12em;
  padding: 0.35em 0.6em;
  border: 1px solid var(--border-2);
  border-radius: var(--r-input);
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
.handle-save {
  padding: 0.35em 0.9em;
  border: 1px solid var(--border-2);
  border-radius: var(--r-btn);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  cursor: pointer;
}
/* ── RSVP fast-reader overlay ────────────────────────────────────────────── */
.rsvp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: var(--bg);
  padding: 1.5rem;
}
.rsvp-close {
  position: absolute;
  top: 1rem;
  right: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Esc is the other way out, and touch has no Esc — keep the 44px target. */
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-lg);
  cursor: pointer;
  line-height: 1;
}
.rsvp-close:hover {
  color: var(--text);
}
.rsvp-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4em;
}
.rsvp-word {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 9vw, 4.5rem);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
  text-align: center;
}
.rsvp-bar {
  width: min(90%, 640px);
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--border);
  overflow: hidden;
}
.rsvp-bar-fill {
  height: 100%;
  width: 0;
  background: var(--text-2);
}
.rsvp-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.rsvp-btn {
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text);
  border-radius: var(--r-pill);
  width: 2.6em;
  height: 2.6em;
  font-size: var(--fs-base);
  cursor: pointer;
}
.rsvp-btn:hover {
  background: var(--bg-3);
}
.rsvp-speed {
  display: inline-flex;
  /* the global `label` rule stacks column; this one is a single row */
  flex-direction: row;
  align-items: center;
  gap: 0.5em;
}
.rsvp-range {
  accent-color: var(--text-2);
}
.action-menu-list a,
.action-menu-list button {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.48em 0.85em;
  font-size: var(--fs-sm);
  color: var(--text);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--dur-fast) ease;
}
.action-menu-list a:hover,
.action-menu-list button:hover {
  background: var(--bg-2);
}
.action-menu-sep {
  border-top: 1px solid var(--border);
  margin: 0.3em 0.4em;
}
.action-menu-danger {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.48em 0.85em;
  font-size: var(--fs-sm);
  color: var(--danger);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--dur-fast) ease;
  width: 100%;
}
.action-menu-danger:hover {
  background: var(--bg-2);
}
.action-menu-disabled {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.48em 0.85em;
  font-size: var(--fs-sm);
  color: var(--text-4);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  text-align: left;
  cursor: not-allowed;
  font-family: var(--font-sans);
  width: 100%;
}

/* ── Article body ───────────────────────────────────────────────────────── */
.article {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 1.6rem 1.8rem 2rem;
}
.article-title {
  font-size: calc(var(--fs-2xl) * var(--reader-scale, 1));
  font-weight: 700;
  margin: 0 0 0.3em;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--text);
}

/* Reader preference (Aa popover on note pages) — scales the article body
   and swaps its font. Defaults leave every value at its design token. */
html[data-reader-size="s"] {
  --reader-scale: 0.9;
}
html[data-reader-size="l"] {
  --reader-scale: 1.16;
}
html[data-reader-font="sans"] {
  --reader-font: var(--font-sans);
}
.note-image {
  display: block;
  max-width: 100%;
  border-radius: var(--r-btn);
  margin-top: 0.75em;
}
.image-preview {
  display: block;
  max-width: 200px;
  border-radius: var(--r-btn);
  margin: 0.4em 0;
}
.article-body {
  font-size: calc(var(--fs-md) * var(--reader-scale, 1));
  font-family: var(--reader-font, var(--font-serif));
  line-height: 1.82;
  margin-top: 0.75em;
  color: var(--text-2);
}
.article-body > :first-child {
  margin-top: 0;
}
.article-body h2 {
  font-size: calc(var(--fs-lg) * var(--reader-scale, 1));
  margin: 1.8em 0 0.55em;
  color: var(--text);
}
.article-body h3 {
  font-size: calc(var(--fs-md) * var(--reader-scale, 1));
  margin: 1.5em 0 0.4em;
  color: var(--text);
}
.article-body p {
  margin: 0 0 1.1em;
}
.article-body hr {
  margin: 1.8em 0;
}
.article-body
  a:not(.wikilink-cross):not(.wiki-cross-resolved):not(.wiki-cross-unresolved) {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-2);
}
.article-body
  a:not(.wikilink-cross):not(.wiki-cross-resolved):not(
    .wiki-cross-unresolved
  ):hover {
  text-decoration-color: var(--text);
}

/* ── Connected notes ────────────────────────────────────────────────────── */
.connected-section {
  margin-top: 1.25rem;
  padding: 1.2rem 1.2rem 1.3rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.section-header {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: 0.75em;
  color: var(--text);
  font-family: var(--font-sans);
}
.section-header .section-count {
  color: var(--text-3);
  font-weight: 400;
  font-size: var(--fs-sm);
  margin-left: 0.2em;
}
.subsection-label {
  display: flex;
  align-items: center;
  gap: 0.45em;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin: 0.9em 0 0.5em;
  letter-spacing: 0.01em;
  font-family: var(--font-sans);
}
.subsection-label .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-2);
}
.connected-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
@media (min-width: 560px) {
  .connected-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.mini-card {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 0.7em 0.85em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  text-decoration: none;
  color: inherit;
  transition:
    border-color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease);
}
.mini-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  text-decoration: none;
}
.mini-card .mini-card-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  display: flex;
  gap: 0.4em;
  align-items: flex-start;
  flex-wrap: wrap;
}
.mini-card .mini-card-meta {
  font-size: var(--fs-2xs);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 0.35em;
  margin-top: auto;
  font-family: var(--font-sans);
}
.mini-card-author-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.55rem;
  font-weight: 600;
  flex-shrink: 0;
}
.cross-badge {
  display: inline-block;
  font-size: 0.62rem;
  color: var(--text-3);
  background: var(--bg-3);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  margin-left: auto;
  font-weight: 500;
  border: 1px solid var(--border);
  font-family: var(--font-sans);
}

/* ── Backlinks section ──────────────────────────────────────────────────── */
.backlinks-section {
  margin-top: 1rem;
  padding: 1.2rem 1.2rem 0.6rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}
.backlinks-list {
  display: flex;
  flex-direction: column;
}
.backlink-row {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.75em 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  text-decoration: none;
  color: inherit;
  transition: background var(--dur-fast) ease;
}
.backlink-row:last-child {
  border-bottom: none;
}
.backlink-row:hover .backlink-title {
  text-decoration: underline;
}
.backlink-icon {
  color: var(--text-3);
  font-size: var(--fs-base);
  flex-shrink: 0;
}
.backlink-title {
  font-weight: 500;
  flex: 1;
  color: var(--text);
}
.backlink-author {
  font-size: var(--fs-xs);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font-sans);
}

/* ── Graph view ─────────────────────────────────────────────────────────── */
#graph-wrap,
.local-graph-wrap {
  position: relative;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg-2);
  overflow: hidden;
}
html[data-theme="dark"] #graph-wrap,
html[data-theme="dark"] .local-graph-wrap {
  background: #080808;
}
#graph-wrap canvas,
.local-graph-wrap canvas {
  display: block;
  width: 100%;
  touch-action: none;
}
.graph-empty {
  padding: 2.5rem;
  color: var(--text-3);
  text-align: center;
}
.graph-fit {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  padding: 0.15rem 0.6rem;
  font-size: 0.72rem;
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.graph-fit:hover {
  color: var(--text);
  border-color: var(--text-3);
}
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  color: var(--bg);
  padding: 0.28rem 0.55rem;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  white-space: nowrap;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 5;
  font-family: var(--font-sans);
}
html[data-theme="dark"] .graph-tooltip {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}
.local-graph-wrap {
  margin-top: 2rem;
}
.local-graph-heading {
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin: 1.5rem 0 0.3rem;
  letter-spacing: 0.04em;
  font-family: var(--font-sans);
}

/* ── External ───────────────────────────────────────────────────────────── */
.external-badge {
  display: inline-block;
  font-size: var(--fs-2xs);
  padding: 0.06em 0.55em;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-3);
  background: var(--bg-3);
  margin-right: 0.45em;
  vertical-align: middle;
  font-family: var(--font-sans);
}
.add-vault-form {
  display: flex;
  gap: 0.5em;
  align-items: center;
  flex-wrap: wrap;
  margin: 1em 0;
}
.add-vault-form input[type="url"] {
  padding: 0.55em 0.8em;
  border-radius: var(--r-input);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast) ease;
}
.add-vault-form input[type="url"]:focus {
  outline: none;
  border-color: var(--border-2);
}
.add-vault-form button {
  padding: 0.55em 1.1em;
  border-radius: var(--r-input);
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border-2);
}

/* ── Admin table ────────────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.65em 0.5em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table th {
  font-weight: 600;
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.row-actions {
  white-space: nowrap;
}
.row-actions .link-btn {
  font-size: var(--fs-sm);
}
.row-actions .link-btn.danger:hover {
  color: var(--danger);
}

.status {
  font-size: var(--fs-sm);
  padding: 0.12em 0.65em;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-family: var(--font-sans);
}
.status-active {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-bg);
}
.status-pending {
  color: var(--text-2);
}
.status-crawling {
  color: var(--text-2);
}
.status-error {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

/* ── Callouts ───────────────────────────────────────────────────────────── */
.callout {
  border-left: 3px solid var(--border-2);
  border-radius: var(--r-btn);
  background: var(--bg-2);
  margin: 1em 0;
  padding: 0.8em 1.1em;
}
.callout-title {
  font-weight: 600;
  font-size: var(--fs-base);
  margin-bottom: 0.4em;
  opacity: 0.9;
  font-family: var(--font-sans);
}
.callout-body > :last-child {
  margin-bottom: 0;
}
details.callout > summary {
  list-style: none;
  cursor: pointer;
}
details.callout > summary::-webkit-details-marker {
  display: none;
}
details.callout > summary.callout-title {
  margin-bottom: 0;
}
details.callout[open] > summary.callout-title {
  margin-bottom: 0.4em;
}
.callout-note {
  border-color: var(--border-2);
}
.callout-tip,
.callout-hint,
.callout-success,
.callout-check,
.callout-done {
  border-color: var(--text-3);
}
.callout-warning,
.callout-caution,
.callout-attention {
  border-color: var(--text-4);
}
.callout-danger,
.callout-error,
.callout-bug,
.callout-failure,
.callout-fail,
.callout-missing {
  border-color: var(--danger);
}
.callout-info,
.callout-todo {
  border-color: var(--border-2);
}

/* ── Math ───────────────────────────────────────────────────────────────── */
.math-inline {
  font-style: italic;
}
.math-block {
  text-align: center;
  margin: 1.2em 0;
  overflow-x: auto;
}

/* ── Mermaid ────────────────────────────────────────────────────────────── */
pre.mermaid {
  background: var(--bg-2);
  border-radius: var(--r-card);
  padding: 1.2em;
  text-align: center;
  border: 1px solid var(--border);
}

/* ── Feed sentinel / infinite scroll ───────────────────────────────────── */
.feed-sentinel,
.feed-end {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}
.feed-sentinel span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-3);
  margin: 0 2px;
  animation: dotBlink 1.4s infinite;
}
.feed-sentinel span:nth-child(2) {
  animation-delay: 0.2s;
}
.feed-sentinel span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes dotBlink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

/* ── Skeleton loading ───────────────────────────────────────────────────── */
.htmx-indicator {
  display: none;
}
.htmx-indicator.htmx-request,
.htmx-request .htmx-indicator {
  display: block;
}
.skeleton-group {
  margin: 0.4em 0 1em;
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-2) 0%,
    var(--bg-3) 50%,
    var(--bg-2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-btn);
}
.skeleton-line {
  height: 0.9em;
  margin: 0.55em 0;
}
.skeleton-line.short {
  width: 55%;
}
.skeleton-line.medium {
  width: 80%;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  body {
    /* Root type ramp (15 -> 15.5 -> 16px), deliberately off the --fs-* scale. */
    font-size: 0.96875rem;
  }
  .page {
    padding: 0 1.5rem 5rem;
  }
}
@media (min-width: 900px) {
  body {
    font-size: 1rem;
  }
  .masonry {
    column-count: 3;
    column-gap: 14px;
  }
  .masonry-card {
    margin-bottom: 14px;
  }
  .article {
    padding: 2rem 2.4rem 2.5rem;
  }
  .article-title {
    font-size: calc(var(--fs-2xl) * var(--reader-scale, 1));
  }
  .article-body {
    font-size: calc(var(--fs-md) * var(--reader-scale, 1));
  }
}

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-wrap {
  max-width: 400px;
  margin: 6vh auto;
  padding: 2.5rem 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
html[data-theme="dark"] .login-wrap {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* ── Avatar builder ─────────────────────────────────────────────────── */
.avatar-builder {
  max-width: 980px;
}
.avatar-builder-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5em;
  align-items: start;
  margin-top: 1.5em;
}
@media (max-width: 720px) {
  .avatar-builder-grid {
    grid-template-columns: 1fr;
  }
}
.avatar-preview-col {
  position: sticky;
  top: 1.5em;
}
.avatar-preview {
  position: relative;
  width: 256px;
  height: 256px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg-2);
  overflow: hidden;
}
.avatar-preview canvas,
.avatar-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.avatar-save-btn {
  margin-top: 1em;
  width: 100%;
  padding: 0.65em 1em;
  font-size: var(--fs-md);
  font-family: var(--font-sans);
  border-radius: var(--r-input);
  border: 1px solid var(--border-2);
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}
.picker-row {
  margin-bottom: 1.4em;
}
.picker-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-family: var(--font-sans);
  font-weight: 600;
  margin: 0 0 0.5em;
}
.picker-strip {
  display: flex;
  gap: 0.55em;
  overflow-x: auto;
  padding: 0.25em 0;
}
.picker-thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--r-input);
  background: var(--bg-2);
  cursor: pointer;
  overflow: hidden;
  transition:
    border-color var(--dur-fast) ease,
    transform var(--dur-fast) ease;
}
.picker-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.picker-thumb:hover {
  transform: translateY(-1px);
}
.picker-thumb.is-selected {
  border-color: var(--text);
}
.skin-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  max-width: 480px;
}
.skin-swatch {
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition:
    transform var(--dur-fast) ease,
    border-color var(--dur-fast) ease;
}
.skin-swatch:hover {
  transform: scale(1.1);
}
.skin-swatch.is-selected {
  border-color: var(--text);
  transform: scale(1.15);
}

/* ── Avatar image display (profile, /me, topbar) ────────────────────── */
.avatar-img-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-2);
  vertical-align: middle;
  object-fit: cover;
}
.avatar-img-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border-2);
  background: var(--bg-3);
  object-fit: cover;
  display: block;
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-bottom: 0.5em;
}
.profile-header h1 {
  margin: 0;
}

/* ── EasyMDE note editor ────────────────────────────────────────────────── */
.editor-page {
  max-width: var(--maxw-article);
  margin: 0 auto;
}
.editor-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.editor-back-btn {
  margin-right: auto;
}
.editor-delete-btn {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.48em 0.85em;
  font-size: var(--fs-sm);
  color: var(--danger);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--dur-fast) ease;
}
.editor-delete-btn:hover {
  background: var(--bg-2);
}
.save-status {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* Match the editor to the site theme (EasyMDE ships a light-only skin). */
.EasyMDEContainer .CodeMirror {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  font-family: var(--font-serif); /* prose feel, not a code box */
  font-size: var(--fs-md);
  line-height: 1.7;
  min-height: calc(100vh - 160px);
  height: auto;
}
.EasyMDEContainer .CodeMirror-scroll {
  overflow-x: hidden !important;
  overflow-y: hidden !important;
  /* hide ugly scrollbars */
}
.EasyMDEContainer .CodeMirror-hscrollbar,
.EasyMDEContainer .CodeMirror-vscrollbar {
  display: none !important;
}
.EasyMDEContainer .CodeMirror-cursor {
  border-color: var(--text);
}
.EasyMDEContainer .CodeMirror-selected {
  background: var(--bg-3);
}
.EasyMDEContainer .editor-toolbar {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-input) var(--r-input) 0 0;
  opacity: 1;
}
.editor-toolbar button {
  color: var(--text) !important;
  font-weight: 600;
  min-width: 2.2em;
}
.editor-toolbar button:hover,
.editor-toolbar button.active {
  background: var(--bg-3);
  border-color: var(--border);
}
.editor-toolbar i.separator {
  border-left-color: var(--border);
  border-right-color: var(--bg-2);
}

/* First line of the document is the note title. */
.EasyMDEContainer .CodeMirror .cm-title-line {
  font-size: 1.7em;
  font-weight: 700;
  line-height: 1.3;
}
/* Dim markdown syntax marks — visible but subordinate to content. */
.EasyMDEContainer .cm-formatting,
.EasyMDEContainer .cm-formatting-strong,
.EasyMDEContainer .cm-formatting-em,
.EasyMDEContainer .cm-formatting-strikethrough,
.EasyMDEContainer .cm-formatting-code,
.EasyMDEContainer .cm-formatting-quote,
.EasyMDEContainer .cm-formatting-list,
.EasyMDEContainer .cm-formatting-header {
  opacity: 0.35;
}
/* Keep code spans/blocks monospace even though prose is serif. */
.EasyMDEContainer .cm-comment {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.publish-btn {
  white-space: nowrap;
}

/* ── Markdown embeds ![[note]] ──────────────────────────────────────────── */
blockquote.embed {
  margin: 1.2em 0;
  padding: 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-3);
  border-radius: var(--r-card);
  background: var(--bg-2);
  overflow: hidden;
}
blockquote.embed .embed-header {
  padding: 0.4em 0.85em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-family: var(--font-sans);
}
blockquote.embed .embed-header a {
  color: var(--text-2);
  text-decoration: none;
}
blockquote.embed .embed-header a:hover { color: var(--text); text-decoration: underline; }
blockquote.embed .embed-body {
  padding: 0.6em 0.85em;
}
blockquote.embed .embed-body > :first-child { margin-top: 0; }
blockquote.embed .embed-body > :last-child { margin-bottom: 0; }
blockquote.embed.embed-missing {
  border-left-color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
  padding: 0.5em 0.85em;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
/* ── Command palette (Cmd/Ctrl+K) ──────────────────────────────────────── */
dialog.palette {
  margin: 8vh auto 0;
  width: min(40rem, 92vw);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 16px 50px rgba(0,0,0,0.35);
  overflow: hidden;
}
dialog.palette::backdrop {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.palette-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  outline: none;
}
.palette-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 60vh;
  overflow-y: auto;
}
.palette-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.palette-item.active {
  background: var(--bg-2);
  border-left-color: var(--text);
}
.palette-item:hover { background: var(--bg-2); }
.palette-item-title {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.palette-item-handle {
  font-size: var(--fs-sm);
  color: var(--text-3);
  font-family: var(--font-sans);
  flex-shrink: 0;
}
.palette-empty {
  padding: 1.2rem 1rem;
  color: var(--text-3);
  text-align: center;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}
.palette-hint {
  padding: 0.45rem 1rem;
  font-size: var(--fs-2xs);
  color: var(--text-3);
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  background: var(--bg-2);
}
/* ── Calendar view ─────────────────────────────────────────────────────── */
.calendar-page { max-width: 64rem; margin: 0 auto; }
.calendar-head { display: flex; align-items: baseline; gap: 1rem; margin: 0 0 1rem; }
.calendar-month { margin: 0; font-size: var(--fs-xl); letter-spacing: 0.04em; }
.calendar-nav { font-size: var(--fs-xl); text-decoration: none; color: var(--text-2); padding: 0 0.4rem; }
.calendar-nav:hover { color: var(--text); }
.calendar-today { margin-left: auto; font-size: var(--fs-sm); color: var(--text-3); text-decoration: none; }
.calendar-today:hover { color: var(--text); }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
}
.calendar-dayname {
  background: var(--bg-2);
  padding: 0.4rem 0.5rem;
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: center;
  font-family: var(--font-sans);
}
.calendar-cell {
  background: var(--bg);
  min-height: 6rem;
  padding: 0.35rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.calendar-cell-out { background: var(--bg-2); }
.calendar-cell-out .calendar-cell-day { color: var(--text-3); opacity: 0.45; }
.calendar-cell-today .calendar-cell-day {
  background: var(--text);
  color: var(--bg);
  border-radius: 50%;
  width: 1.4em;
  height: 1.4em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.calendar-cell-day { font-size: var(--fs-sm); color: var(--text-2); font-family: var(--font-sans); }
.calendar-cell-notes { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.calendar-cell-notes li { font-size: var(--fs-sm); line-height: 1.25; }
.calendar-cell-notes a {
  display: block;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  background: var(--bg-2);
}
.calendar-cell-out .calendar-cell-notes a { background: transparent; opacity: 0.55; }
.calendar-cell-notes a:hover { background: var(--text); color: var(--bg); }
@media (max-width: 720px) {
  .calendar-cell { min-height: 4rem; padding: 0.25rem 0.3rem; }
  .calendar-cell-notes a { font-size: var(--fs-2xs); }
}

/* ── Batch import editor ───────────────────────────────────────────────── */
.batch-head { margin-bottom: 1.5rem; }
.batch-head h1 { display: flex; align-items: baseline; gap: 0.7rem; margin: 0 0 0.4em; }
.batch-count {
  font-size: var(--fs-sm);
  font-weight: normal;
  color: var(--text-3);
  font-family: var(--font-sans);
  letter-spacing: 0.04em;
}
.batch-hint { font-size: var(--fs-sm); }
.batch-toolbar { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.8rem; }
.batch-list { display: flex; flex-direction: column; gap: 0; }
.batch-item {
  padding: 1.4rem 0;
  border-top: 1px solid var(--border);
}
.batch-item:first-child { border-top: 0; padding-top: 0.4rem; }
.batch-item-form { display: flex; flex-direction: column; gap: 0.7rem; }
.batch-field { display: flex; flex-direction: column; gap: 0.25rem; }
.batch-field-label { font-size: var(--fs-sm); color: var(--text-3); font-family: var(--font-sans); letter-spacing: 0.04em; }
.batch-field input,
.batch-body {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  background: var(--bg-2);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-base);
}
.batch-field input { font-family: var(--font-sans); }
.batch-body { font-family: var(--font-mono); min-height: 14rem; resize: vertical; line-height: 1.55; }
.batch-body-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.batch-preview {
  padding: 0.6rem 0.85rem;
  border: 1px dashed var(--border);
  border-radius: var(--r-input);
  background: var(--bg);
  min-height: 14rem;
  max-height: 36rem;
  overflow-y: auto;
  font-size: var(--fs-base);
}
.batch-preview:empty::before {
  content: '預覽會顯示在這裡';
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}
.batch-preview > :first-child { margin-top: 0; }
.batch-preview > :last-child { margin-bottom: 0; }
@media (max-width: 720px) {
  .batch-body-row { grid-template-columns: 1fr; }
  .batch-preview { min-height: 6rem; max-height: 16rem; }
}
.batch-item-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.batch-item-status { font-size: var(--fs-sm); color: var(--text-3); font-family: var(--font-sans); }
.batch-item-error {
  margin: 0.4rem 0 0;
  padding: 0.45rem 0.7rem;
  background: rgba(185, 28, 28, 0.08);
  border-left: 3px solid #b91c1c;
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-sm);
}
.batch-item-saved {
  padding: 1rem 1.2rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-2);
  border-radius: var(--r-card);
  margin: 0.8rem 0;
}
.batch-saved-row { display: flex; align-items: center; gap: 0.7rem; }
.batch-saved-mark { font-size: var(--fs-lg); color: var(--text-2); }
.batch-saved-title { flex: 1; color: var(--text); }
.batch-saved-link { font-size: var(--fs-sm); color: var(--text-2); text-decoration: none; }
.batch-saved-link:hover { color: var(--text); text-decoration: underline; }
.batch-foot { margin: 2rem 0 4rem; display: flex; gap: 0.6rem; }
