/* MiracleFarms — Notion editorial style */
:root {
  --bg:             #faf7f0;
  --bg-soft:        #f1ead7;
  --bg-hover:       #ece3cd;
  --ink:            #2c2a26;
  --ink-soft:       rgba(44,42,38,0.70);
  --ink-faint:      rgba(44,42,38,0.45);
  --rule:           rgba(44,42,38,0.14);
  --rule-soft:      rgba(44,42,38,0.08);
  --tag-bg:         rgba(104,143,78,0.12);
  --accent:         #3a5a40;
  --accent-soft:    #688f4e;
  --accent-warm:    #b08d3a;
  --accent-warm-soft: #e9c46a;

  /* ── Section color tokens (default = briefs / home) ──────────────── */
  --sec-accent: #3a5a40;
  --sec-soft:   #688f4e;
  --sec-tint:   #eaf0e3;
  --sec-qt:     #4a5a48;

  --font-default: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                  "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
                  "Microsoft YaHei", sans-serif;
  --font-serif:   "Source Serif 4", "Source Serif Pro", "Noto Serif SC",
                  "Source Han Serif SC", Georgia, "Songti SC", serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular,
                  Menlo, Consolas, monospace;

  --content-width: 680px;
  --base-size: 17px;
}

/* Font style overrides (data-style on <html>) */
html[data-style="default"] body { font-family: var(--font-default); }
html[data-style="serif"]   body { font-family: var(--font-serif); }
html[data-style="mono"]    body { font-family: var(--font-mono); }

/* ── Section colour overrides (data-section on <html>) ───────────────── */
html[data-section="readings"]    { --sec-accent:#3d5168; --sec-soft:#6b7e98; --sec-tint:#e3e8ef; --sec-qt:#3a4a5e; --tag-bg:rgba(61,81,104,.12); }
html[data-section="fields"]      { --sec-accent:#b08d3a; --sec-soft:#cba961; --sec-tint:#f4ead0; --sec-qt:#7a5c2e; --tag-bg:rgba(176,141,58,.12); }
html[data-section="essays"]      { --sec-accent:#322a50; --sec-soft:#5e5478; --sec-tint:#e6e3f0; --sec-qt:#26203e; --tag-bg:rgba(50,42,80,.12); }
html[data-section="foundations"] { --sec-accent:#9c5a3c; --sec-soft:#c0845f; --sec-tint:#f1e4d8; --sec-qt:#7a4226; --tag-bg:rgba(156,90,60,.12); }
html[data-section="search"]      { --sec-accent:#2f4a52; --sec-soft:#6f8790; --sec-tint:#e4ecee; --sec-qt:#263d44; --tag-bg:rgba(47,74,82,.12); }
/* briefs + home use :root defaults (emerald-green) */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: var(--base-size);
  line-height: 1.7;
  font-family: var(--font-default);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Serif for display headings and brand */
.pg-title, .h2, .h3, .h2-sub-serif, .ornament, .pull,
.pagelink .pl-title, .brand-name {
  font-family: var(--font-serif);
}
.pg-title, .h2, .h3 { font-weight: 600; }

a { color: inherit; text-decoration: none; }
a:hover { background: var(--rule-soft); }
::selection { background: rgba(233,196,106,0.38); color: var(--ink); }

img { max-width: 100%; border-radius: 6px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Topbar ──────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250,247,240,0.88);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule-soft);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 12px 32px;
  display: flex; align-items: center; gap: 16px;
  font-family: var(--font-default); font-size: 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 6px; margin-left: -6px;
  border-radius: 4px; font-weight: 600; color: var(--ink);
}
.brand:hover { background: var(--bg-hover); }
.brand-mark { font-size: 16px; line-height: 1; user-select: none; }
.brand-name { font-family: var(--font-serif); letter-spacing: -0.005em; }
.brand-tag { color: var(--ink-faint); font-weight: 400; margin-left: 2px; white-space: nowrap; }
.nav-spacer { flex: 1; }
.nav-links { display: flex; align-items: center; gap: 1px; flex-wrap: nowrap; }
.nav-links a {
  padding: 6px 5px; border-radius: 4px; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 4px;
}
.nav-links a span { white-space: nowrap; }
.nav-links a:hover { background: var(--bg-hover); color: var(--ink); }
.nav-links a.active { color: var(--ink); background: var(--bg-hover); }
.nav-links svg { flex: 0 0 auto; }
.nav-sep { width: 1px; height: 14px; background: var(--rule); margin: 0 6px; }

@media (max-width: 1100px) { .brand-tag { display: none; } }
/* When labels no longer fit, keep one line and fall back to icons. */
@media (max-width: 960px) {
  .nav-links a span { display: none; }
  .nav-links a { padding: 6px; gap: 0; }
  .nav-links svg { width: 16px; height: 16px; }
  .nav-sep { display: none; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 10px 16px; gap: 8px; }
  .brand-tag { display: none; }
}
@media (max-width: 460px) {
  .topbar-inner { padding: 10px 12px; }
  .brand-name { display: none; }
}

/* ── Page shell ──────────────────────────────────────────────────────── */
.page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 32px 120px;
}
@media (max-width: 720px) {
  .page { padding: 0 20px 80px; }
}

.pg-meta {
  font-family: var(--font-default);
  font-size: 12px; color: var(--ink-faint);
  padding: 24px 0 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  letter-spacing: 0.01em;
}
.pg-meta .dot { opacity: 0.5; }
.pg-meta a {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 2px;
}

.pg-icon {
  margin-top: 40px;
  display: inline-flex; align-items: center; justify-content: flex-start;
  font-size: 32px; line-height: 1; user-select: none;
  opacity: 0.85;
}

.pg-title {
  font-weight: 600; font-size: 44px; line-height: 1.18;
  letter-spacing: -0.012em; margin: 14px 0 10px; color: var(--ink);
}
.pg-sub {
  color: var(--ink-soft); font-size: 18px; line-height: 1.55;
  margin: 4px 0 6px; font-family: var(--font-serif); font-style: italic;
  font-weight: 400;
}
.pg-sub-small { color: var(--ink-faint); font-size: 14px; margin: 2px 0 28px; }

/* ── Pills ───────────────────────────────────────────────────────────── */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; font-family: var(--font-default); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--rule); border-radius: 4px;
  font-size: 13px; color: var(--ink-soft); background: var(--bg);
  cursor: pointer; transition: background 0.1s;
}
.pill:hover { background: var(--bg-soft); color: var(--ink); }
.pill.primary { background: var(--sec-accent); color: #faf7f0; border-color: var(--sec-accent); }
.pill.primary:hover { background: var(--sec-qt); color: #faf7f0; }

/* ── Callout ─────────────────────────────────────────────────────────── */
.callout {
  display: flex; gap: 14px; margin: 28px 0;
  padding: 18px 20px 18px 18px; background: var(--bg-soft);
  border-radius: 2px; font-size: 15px; line-height: 1.65;
  border-left: 2px solid var(--sec-accent);
}
.callout .ico { flex: 0 0 auto; font-size: 16px; line-height: 1.6; user-select: none; opacity: 0.85; }
.callout p { margin: 0; }
.callout p + p { margin-top: 8px; }
.callout strong { font-weight: 600; }

/* ── Section headings ────────────────────────────────────────────────── */
.h2 {
  font-weight: 600; font-size: 26px; line-height: 1.3;
  letter-spacing: -0.005em; margin: 48px 0 6px; color: var(--ink);
}
.h2-sub {
  font-family: var(--font-default); color: var(--sec-soft);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.18em;
  margin: 40px 0 -4px; font-weight: 500;
}
.h3 { font-weight: 600; font-size: 19px; line-height: 1.4; margin: 28px 0 4px; color: var(--ink); }
p { margin: 10px 0; color: var(--ink); }
p.muted { color: var(--ink-soft); }

/* ── Divider & ornament ──────────────────────────────────────────────── */
.divider { height: 1px; background: var(--rule-soft); margin: 36px 0; border: 0; }
.ornament {
  display: flex; align-items: center; justify-content: center;
  margin: 56px 0; color: var(--sec-soft);
  font-size: 14px; letter-spacing: 0.6em; user-select: none; opacity: 0.85;
  font-family: var(--font-serif);
}
.ornament::before, .ornament::after {
  content: ""; flex: 0 0 36px; height: 1px; background: var(--rule);
  margin: 0 18px;
}
.pull {
  font-style: italic; font-size: 22px; line-height: 1.5;
  color: var(--ink); margin: 36px 0;
  padding-left: 20px; border-left: 2px solid var(--sec-accent);
}

/* ── Page-link list ──────────────────────────────────────────────────── */
.pagelist { margin: 8px 0 0; display: flex; flex-direction: column; }
.pagelink {
  display: grid; grid-template-columns: 24px 1fr auto;
  align-items: start; gap: 10px;
  padding: 10px 8px 10px 6px; margin: 0 -8px;
  border-radius: 4px; cursor: pointer; position: relative; color: inherit;
}
.pagelink:hover { background: var(--bg-soft); }
.pagelink .pl-ico {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 1px; color: var(--sec-soft); flex: 0 0 auto;
}
.pagelink .pl-body { min-width: 0; }
.pagelink .pl-title {
  font-family: var(--font-serif); font-weight: 500; font-size: 16px;
  line-height: 1.45; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--rule);
  text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.pagelink:hover .pl-title { text-decoration-color: var(--ink-faint); }
.pagelink .pl-meta {
  font-family: var(--font-default); font-size: 12px; color: var(--ink-faint);
  margin-top: 4px; display: flex; flex-wrap: wrap; gap: 0 8px; align-items: center;
}
.pagelink .pl-meta .tag {
  background: var(--tag-bg); border-radius: 3px; padding: 1px 6px;
  color: var(--sec-accent); font-size: 11px;
}
.pagelink .pl-meta .tag-kind {
  background: rgba(44,42,38,0.08); border-radius: 3px; padding: 1px 6px;
  color: var(--ink-soft); font-size: 11px; font-weight: 500;
}
.pagelink .pl-excerpt { font-size: 14px; color: var(--ink-soft); line-height: 1.55; margin-top: 4px; }
.pagelink .pl-date {
  font-family: var(--font-default); font-size: 12px; color: var(--ink-faint);
  white-space: nowrap; padding-top: 3px;
}
.pagelink .pl-handle {
  position: absolute; left: -28px; top: 12px;
  width: 18px; height: 18px; color: var(--ink-faint);
  opacity: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; pointer-events: none; transition: opacity 0.1s;
}
.pagelink:hover .pl-handle { opacity: 0.55; }
@media (max-width: 720px) {
  .pagelink { grid-template-columns: 22px 1fr; }
  .pagelink .pl-date { grid-column: 2; padding-top: 0; }
  .pagelink .pl-handle { display: none; }
}

/* ── Toggle ──────────────────────────────────────────────────────────── */
details.toggle { margin: 8px -6px; padding: 4px 6px; border-radius: 4px; }
details.toggle > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; margin: 0 -6px; border-radius: 4px;
  font-size: 15px; color: var(--ink);
}
details.toggle > summary::-webkit-details-marker { display: none; }
details.toggle > summary:hover { background: var(--bg-soft); }
details.toggle > summary::before {
  content: "▶"; font-size: 10px; color: var(--ink-faint);
  transition: transform 0.15s ease; width: 14px; display: inline-block;
}
details.toggle[open] > summary::before { transform: rotate(90deg); }
details.toggle > .toggle-body {
  padding: 4px 0 8px 20px; color: var(--ink-soft);
  font-size: 14px; line-height: 1.6;
}
details.toggle > .toggle-body p { color: var(--ink-soft); margin: 6px 0; }

/* ── Property grid ───────────────────────────────────────────────────── */
.props {
  display: grid; grid-template-columns: max-content 1fr;
  gap: 6px 24px; font-family: var(--font-default); font-size: 14px; margin: 16px 0 0;
}
.props dt {
  color: var(--ink-faint); font-size: 13px; padding: 6px 6px 6px 0;
  display: flex; align-items: center; gap: 6px;
}
.props dd { margin: 0; color: var(--ink); padding: 6px 0; }
.props dd .tag {
  background: var(--tag-bg); border-radius: 3px; padding: 2px 7px;
  font-size: 12px; margin-right: 4px; display: inline-block;
}
@media (max-width: 560px) {
  .props { grid-template-columns: 1fr; gap: 0; }
  .props dt { padding-bottom: 0; }
  .props dd { padding-top: 2px; padding-bottom: 10px; }
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.pg-footer {
  margin-top: 80px; padding-top: 24px;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--font-default); font-size: 12px; color: var(--ink-faint);
  display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: space-between;
}

/* ── Filter bar ──────────────────────────────────────────────────────── */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin: 16px 0 8px; font-family: var(--font-default);
}
.filterbar .lbl { font-size: 12px; color: var(--ink-faint); margin-right: 2px; }
.fchip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 3px; font-size: 12px;
  background: var(--tag-bg); color: var(--ink-soft); cursor: pointer;
  border: 1px solid transparent;
}
.fchip:hover { background: var(--bg-hover); }
.fchip.on { background: var(--sec-accent); color: #faf7f0; }
.fchip .count { opacity: 0.6; font-size: 11px; }

/* ── Year group ──────────────────────────────────────────────────────── */
.year-row {
  display: flex; align-items: center; gap: 10px;
  margin: 24px 0 4px;
  font-family: var(--font-default);
  color: var(--ink-faint); font-size: 12px; letter-spacing: 0.06em;
  white-space: nowrap;
}
.year-row > span { flex: 0 0 auto; }
.year-row .yr { font-weight: 600; color: var(--ink-soft); letter-spacing: 0.02em; }
.year-row .ln { flex: 1 1 auto; height: 1px; background: var(--rule-soft); min-width: 0; }

/* ── View tabs ───────────────────────────────────────────────────────── */
.viewtabs {
  display: inline-flex;
  border: 1px solid var(--rule); border-radius: 4px;
  font-family: var(--font-default); font-size: 12px;
  overflow: hidden;
}
.viewtabs button {
  background: transparent; border: 0; padding: 5px 10px;
  color: var(--ink-soft); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  border-right: 1px solid var(--rule);
}
.viewtabs button:last-child { border-right: 0; }
.viewtabs button:hover { background: var(--bg-soft); color: var(--ink); }
.viewtabs button.on { background: var(--bg-soft); color: var(--ink); }

/* ── Search page ─────────────────────────────────────────────────────── */
.search-page {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 120px;
}
.search-console {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule-soft);
  padding: 26px 0 28px;
}
.search-console-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.search-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.search-console h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 7vw, 4.8rem);
  line-height: 0.95;
  font-weight: 600;
  color: var(--ink);
}
.search-form {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: stretch;
  gap: 10px;
  font-family: var(--font-default);
}
.search-mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255,255,255,0.18);
}
.search-mode-tabs button,
.search-kind-filter button,
.search-submit {
  font: inherit;
  border: 0;
  cursor: pointer;
}
.search-mode-tabs button {
  min-height: 46px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-soft);
  background: transparent;
  border-right: 1px solid var(--rule);
}
.search-mode-tabs button:last-child { border-right: 0; }
.search-mode-tabs button.is-active {
  background: var(--sec-accent);
  color: #faf7f0;
}
.search-mode-tabs svg,
.search-input-shell svg,
.search-submit svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.search-input-shell {
  min-height: 46px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  background: rgba(255,255,255,0.36);
  color: var(--ink-faint);
}
.search-input-shell:focus-within {
  border-color: var(--sec-accent);
  box-shadow: 0 0 0 3px rgba(47,74,82,0.10);
}
.search-input-shell input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.search-input-shell input::placeholder { color: var(--ink-faint); }
.search-submit {
  min-height: 46px;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: #faf7f0;
}
.search-submit:hover { background: var(--sec-accent); }
.search-kind-filter {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-family: var(--font-default);
}
.search-kind-filter button {
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--rule-soft);
  background: transparent;
  color: var(--ink-soft);
}
.search-kind-filter button:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.search-kind-filter button.is-active {
  background: var(--sec-tint);
  border-color: rgba(47,74,82,0.18);
  color: var(--sec-qt);
}
.search-results-zone {
  margin-top: 26px;
  font-family: var(--font-default);
}
.search-status {
  min-height: 24px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.search-result {
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  padding: 16px 18px 17px;
  background: rgba(255,255,255,0.24);
}
.search-result:hover {
  border-color: rgba(47,74,82,0.22);
  background: rgba(255,255,255,0.38);
}
.search-result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.search-result-kind,
.search-result-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.search-result-kind {
  color: var(--sec-qt);
  background: var(--sec-tint);
  border-radius: 4px;
  padding: 1px 6px;
}
.search-result-title {
  display: inline;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.35;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 4px;
}
.search-result-title:hover { text-decoration-color: var(--ink-faint); }
.search-result-excerpt,
.search-result-tags,
.search-google-result p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}
.search-result-tags {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.search-google-result h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
}
.search-google-link {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 12px;
  border-radius: 5px;
  background: var(--sec-accent);
  color: #faf7f0;
  font-size: 13px;
}
.search-google-link:hover { background: var(--ink); }

@media (max-width: 760px) {
  .search-page {
    width: min(100% - 32px, 920px);
    padding-top: 34px;
  }
  .search-console-head {
    display: block;
  }
  .search-kicker { margin-bottom: 10px; }
  .search-form {
    grid-template-columns: 1fr;
  }
  .search-mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .search-submit {
    width: 100%;
  }
}

/* ── Notion table view ───────────────────────────────────────────────── */
.ntable {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-default); font-size: 14px;
  margin: 8px 0 0;
}
.ntable thead th {
  text-align: left; font-weight: 500; font-size: 12px;
  color: var(--ink-faint); padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
}
.ntable thead th .col-ico { display: inline-block; margin-right: 6px; vertical-align: -2px; opacity: 0.6; }
.ntable tbody td {
  padding: 10px; border-bottom: 1px solid var(--rule-soft);
  vertical-align: top; color: var(--ink);
}
.ntable tbody tr:hover td { background: var(--bg-soft); }
.ntable td.col-title { font-family: var(--font-serif); font-weight: 500; }
.ntable td.col-title a {
  text-decoration: underline; text-decoration-color: var(--rule);
  text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.ntable tbody tr:hover td.col-title a { text-decoration-color: var(--ink-faint); }
.ntable td.col-date, .ntable th.col-date {
  white-space: nowrap; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.ntable td.col-tags .tag {
  background: var(--tag-bg); border-radius: 3px; padding: 1px 6px;
  color: var(--ink-soft); font-size: 11px; margin-right: 4px; display: inline-block;
}
@media (max-width: 720px) {
  .ntable thead { display: none; }
  .ntable, .ntable tbody, .ntable tr, .ntable td { display: block; width: 100%; }
  .ntable tbody tr { padding: 12px 0; border-bottom: 1px solid var(--rule-soft); }
  .ntable tbody td { padding: 2px 0; border: 0; }
  .ntable td.col-title { font-size: 16px; }
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty {
  padding: 40px 20px; text-align: center;
  color: var(--ink-faint); font-size: 14px;
  background: var(--bg-soft); border-radius: 4px;
  font-family: var(--font-default);
}

/* ── Post layout ─────────────────────────────────────────────────────── */
.post-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 32px 120px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 48px;
  align-items: start;
}
@media (max-width: 900px) {
  .post-shell { grid-template-columns: 1fr; gap: 0; }
  .post-toc { display: none; }
}
@media (max-width: 720px) {
  .post-shell { padding: 0 20px 80px; }
}

.post-article { min-width: 0; }

/* Post header */
.post-header { margin-bottom: 0; }
.post-breadcrumb {
  font-family: var(--font-default);
  font-size: 12px; color: var(--ink-faint);
  padding: 24px 0 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.post-breadcrumb a {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 2px;
}
.post-breadcrumb .dot { opacity: 0.5; }

.post-kind-tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-default); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.14em; font-weight: 500;
  color: var(--sec-soft); margin-top: 40px;
}

.post-title {
  font-family: var(--font-serif); font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.2;
  letter-spacing: -0.012em; margin: 12px 0 10px; color: var(--sec-accent);
}

.post-intro-block {
  color: var(--sec-qt); font-size: 18px; line-height: 1.55;
  margin: 4px 0 24px; font-family: var(--font-serif); font-style: italic;
  border-left: 3px solid var(--sec-accent); padding-left: 14px;
}

.post-meta-row {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  font-family: var(--font-default); font-size: 13px; color: var(--ink-faint);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 32px;
}
.post-meta-row .series-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 3px;
  background: var(--tag-bg); color: var(--ink-soft);
  font-size: 11px;
}
.post-updated-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 3px;
  background: var(--tag-bg); color: var(--ink-soft);
  font-size: 11px; font-family: var(--font-default);
}
.post-word-count-chip {
  display: inline-flex; align-items: center;
  color: var(--ink-faint);
  font-size: 13px; font-family: var(--font-default);
}
.post-lang-toggle {
  display: inline-flex; align-items: center;
  margin-left: auto;                 /* 推到 meta 行末尾，不挤压已有项 */
  border: 1px solid var(--rule-soft);
  border-radius: 4px; overflow: hidden;
  font-family: var(--font-default); font-size: 12px;
}
.post-lang-toggle .lang-opt {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; cursor: pointer;
  padding: 2px 9px; color: var(--ink-faint);
  text-decoration: none; line-height: 1.6;
  font: inherit;
}
.post-lang-toggle .lang-opt + .lang-opt { border-left: 1px solid var(--rule-soft); }
.post-lang-toggle .lang-opt:hover { color: var(--ink); }
.post-lang-toggle .lang-opt.is-active {
  background: var(--tag-bg); color: var(--ink-soft); cursor: default;
}
.post-lang-toggle .lang-opt[disabled] {
  color: var(--ink-faint); opacity: 0.45; cursor: not-allowed;
}
.pl-date-updated { color: var(--ink-soft); }
.pl-date-pip { font-size: 9px; margin-left: 3px; opacity: 0.6; }

/* Post body (article content) */
.post-body {
  font-size: 1.06rem;
  line-height: 1.88;
  color: var(--ink);
}
.post-body > *:first-child { margin-top: 0; }
.post-body h2, .post-body h3, .post-body h4 {
  font-family: var(--font-serif); color: var(--ink); /* h3/h4 stay ink */
  line-height: 1.3; scroll-margin-top: 80px;
  letter-spacing: -0.02em;
}
.post-body h2 {
  font-weight: 600; font-size: 1.6rem;
  margin: 52px 0 16px; color: var(--sec-accent);
}
.post-body h3 {
  font-weight: 600; font-size: 1.2rem;
  margin: 32px 0 12px;
}
.post-body h4 {
  font-weight: 600; font-size: 1.05rem;
  margin: 24px 0 10px;
}
.post-body p { margin: 0 0 1.4em; }
.post-body ul, .post-body ol { padding-left: 1.4rem; margin: 0 0 1.2em; }
.post-body li + li { margin-top: 0.4em; }
.post-body a {
  color: var(--sec-accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--sec-accent) 30%, transparent);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
  overflow-wrap: anywhere;
}
.post-body a:hover {
  text-decoration-color: var(--sec-accent);
  background: transparent;
}
.post-body strong {
  font-weight: 650; color: var(--ink);
  /* Highlighter underline — ported from the WeChat render's bold style.
     A section-tinted band sits behind the lower third of the glyphs. */
  background: linear-gradient(180deg, transparent 62%, var(--sec-tint) 62%, var(--sec-tint) 92%, transparent 92%);
  padding: 0 2px;
}
.post-body em { color: var(--ink-soft); }
.post-body :not(pre) > code {
  display: inline; padding: 0.12em 0.36em;
  border-radius: 4px; background: var(--bg-soft);
  border: 1px solid var(--rule); font-size: 0.9em;
  font-family: var(--font-mono); overflow-wrap: anywhere;
}
.post-body pre {
  overflow-x: auto; margin: 22px 0 28px;
  padding: 16px 18px; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--bg-soft);
  line-height: 1.68;
}
.post-body pre code {
  display: block; white-space: pre;
  font-family: var(--font-mono); font-size: 0.92rem;
  background: none; border: 0; padding: 0; border-radius: 0;
}
.post-body hr {
  border: 0; border-top: 1px solid var(--rule-soft);
  margin: 44px 0 28px;
}
.post-body blockquote {
  margin: 28px 0; padding: 14px 16px 14px 18px;
  border-left: 3px solid var(--sec-accent);
  background: var(--sec-tint); border-radius: 0 4px 4px 0;
  color: var(--sec-qt);
}
.post-body blockquote p { margin-bottom: 0.8em; }
.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body table {
  width: 100%; border-collapse: collapse;
  margin: 22px 0 26px; font-size: 0.95rem;
  overflow-x: auto; display: block;
}
.post-body th, .post-body td {
  padding: 10px 12px; border-bottom: 1px solid var(--rule);
  text-align: left; vertical-align: top;
  /* Floor so a column can't collapse to ~1 char: CJK (and links with
     overflow-wrap:anywhere) have a 1-char min-content, so when other columns
     hold unbreakable Latin tokens, table-layout:auto would otherwise crush the
     CJK/link column. With a floor, wide tables scroll via the table's
     overflow-x:auto instead of squeezing. */
  min-width: 6.5em;
}
.post-body th {
  color: var(--ink); font-weight: 600;
  background: var(--sec-tint); font-size: 0.9rem;
  border-bottom-color: var(--sec-accent);
}
.post-body img { display: block; margin: 28px 0 8px; }
.post-body img + em {
  display: block; margin-top: 0; margin-bottom: 20px;
  font-size: 0.9rem; line-height: 1.5; color: var(--ink-faint);
  font-style: italic;
}

/* Post endcap */
.post-endcap {
  margin-top: 48px;
  padding: 24px 28px;
  background: var(--sec-tint);
  border-radius: 8px;
  font-family: var(--font-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.endcap-text { flex: 1; min-width: 0; }
.endcap-thanks {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--sec-accent);
}
.endcap-links {
  margin: 0;
  font-size: 13px;
  color: var(--ink-faint);
}
.post-endcap a {
  color: var(--sec-accent); text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--sec-accent) 35%, transparent); text-underline-offset: 2px;
}
.endcap-qr {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.endcap-qr img {
  border-radius: 6px;
  border: 1px solid var(--rule);
}
.endcap-qr-label {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
@media (max-width: 480px) {
  .post-endcap {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 16px;
  }
  .endcap-qr {
    flex-direction: row;
    gap: 10px;
  }
  .endcap-qr img { width: 72px; height: 72px; }
}

/* Reader highlights */
::highlight(mf-reader-highlights) {
  background: rgba(233,196,106,0.42);
  color: inherit;
}
.reader-highlight-mark {
  background: rgba(233,196,106,0.42);
  color: inherit;
  border-radius: 2px;
  padding: 0 0.02em;
}
.reader-highlight-popover {
  position: absolute;
  z-index: 60;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: rgba(250,247,240,0.96);
  box-shadow: 0 12px 36px rgba(44,42,38,0.14);
  font-family: var(--font-default);
  font-size: 12px;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.reader-highlight-popover[hidden] { display: none; }
.reader-highlight-popover button {
  appearance: none;
  border: 0;
  border-radius: 4px;
  padding: 6px 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.reader-highlight-popover button:hover {
  background: var(--bg-hover);
}
.reader-highlight-status {
  min-width: 3.5em;
  padding: 0 5px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.post-reader-tools {
  margin: 30px 0 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--font-default);
  font-size: 12px;
  color: var(--ink-faint);
}
.post-reader-tools[hidden] { display: none; }
.post-reader-tools-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.post-reader-tools button {
  appearance: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 5px 9px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
}
.post-reader-tools button:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.reader-highlights-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reader-highlights-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--rule-soft);
}
.reader-highlights-quote {
  min-width: 0;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 560px) {
  .post-reader-tools-bar,
  .reader-highlights-item {
    align-items: flex-start;
  }
  .reader-highlights-quote {
    white-space: normal;
    line-height: 1.5;
  }
}

/* Post comments */
.post-comments {
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-soft);
}
.post-comments-header {
  margin-bottom: 6px;
}
.post-comments-label {
  margin: 0 0 4px;
  font-family: var(--font-default);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sec-soft);
}
.post-comments h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--ink);
}
.post-comments-note,
.post-comments-loading {
  margin: 8px 0 0;
  font-family: var(--font-default);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-faint);
}
.post-comments-frame {
  min-height: 80px;
  margin-top: 16px;
}

/* Post ToC */
.post-toc { align-self: stretch; }
.post-toc-card {
  position: sticky; top: 80px;
  font-family: var(--font-default);
}
.post-toc-label {
  margin: 0 0 14px; font-weight: 600; font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint);
}
.post-toc-nav { display: flex; flex-direction: column; }
.toc-link {
  display: block; color: var(--ink-soft);
  font-size: 12px; line-height: 1.45;
  text-decoration: none; padding: 4px 0 4px 12px;
  transition: color 0.15s;
  border-left: 1.5px solid var(--rule-soft);
}
.toc-link:hover { color: var(--ink); }
.toc-link.active {
  color: var(--sec-accent); font-weight: 500;
  border-left-color: var(--sec-accent);
}
.toc-h3 { padding-left: 22px; font-size: 11px; }

/* Post references */
.post-body a[href^="https://"][id]::before,
.post-refs { font-family: var(--font-default); }

/* ── 404 / simple page ───────────────────────────────────────────────── */
.simple-page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 60px 32px 120px;
}
.simple-page h1 {
  font-family: var(--font-serif); font-size: 2.4rem;
  margin: 16px 0 12px; color: var(--ink);
}
.simple-page p { color: var(--ink-soft); font-size: 16px; }
.btn-primary {
  display: inline-flex; align-items: center;
  padding: 8px 16px; background: var(--accent); color: #faf7f0;
  border-radius: 4px; font-family: var(--font-default);
  font-size: 14px; font-weight: 500; margin-top: 16px;
}
.btn-primary:hover { background: #2d4732; }

/* ── Password gate ───────────────────────────────────────────────────── */
.password-gate {
  display: flex; flex-direction: column; align-items: center;
  padding: 64px 24px; text-align: center; gap: 16px;
}
.pg-icon { font-size: 2.2rem; }
.pg-hint { color: var(--ink-soft); font-size: 15px; margin: 0; max-width: 340px; }
.pg-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.pg-form input[type="password"] {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--font-default); font-size: 14px;
  background: var(--bg); color: var(--ink); width: 200px;
}
.pg-form input[type="password"]:focus { outline: none; border-color: var(--accent); }
.pg-form button {
  padding: 8px 18px; background: var(--accent); color: #faf7f0;
  border: none; border-radius: 4px; font-family: var(--font-default);
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.pg-form button:hover { background: #2d4732; }
.pg-form button:disabled { opacity: 0.6; cursor: default; }
.pg-error { color: #c0392b; font-size: 13px; margin: 0; }

/* ── List page lock badge ────────────────────────────────────────────── */
.pl-lock { font-size: 11px; margin-left: 5px; opacity: 0.45; vertical-align: middle; }
