/* ===========================================================
   CAPTAIN'S LOG — standalone blog
   A ship's-log conceit: dated entries, a wave-line divider,
   an "Ex Libris" plate at the foot of each post. Warm paper by
   day, deep ink by night.
   =========================================================== */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,500;0,9..144,600;1,9..144,500&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --paper: #faf8f2;
  --ink: #1b1f2a;
  --ink-soft: #5b6273;
  --line: #e3e0d3;
  --mist: #f1eff9;
  --surface: #ffffff;
  --accent: #6e62d6;
  --accent-deep: #4b3fa0;
  --danger: #c1443a;
  --good: #2f7a52;

  --display: "Fraunces", Georgia, serif;
  --body-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --max-width: 760px;
  --shadow: 0 20px 48px -20px rgba(27, 31, 42, 0.25);
}

[data-theme="dark"] {
  --paper: #10121b;
  --ink: #f1f1f6;
  --ink-soft: #a7acc2;
  --line: #2b2e42;
  --mist: #1c1e30;
  --surface: #171927;
  --accent: #9b90f2;
  --accent-deep: #c2b8ff;
  --shadow: 0 20px 48px -16px rgba(0, 0, 0, 0.65);
}

/* ---------- midnight sky (dark mode only) ----------
   A fixed, full-viewport starfield behind everything: a drifting nebula
   glow, ~320 twinkling stars, and a handful of shooting stars. Hidden
   entirely in light mode — see toggle rule at the bottom of this block. */

#night-sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  display: none;
  background: radial-gradient(ellipse at 30% 30%, #0e1a2b, #020408 85%);
}
[data-theme="dark"] #night-sky { display: block; }
[data-theme="dark"] html, [data-theme="dark"] body { background: #05080e; }

#nebula {
  position: absolute;
  width: 70%;
  height: 70%;
  top: -10%;
  left: -5%;
  background:
    radial-gradient(ellipse at 60% 40%, rgba(70, 100, 180, 0.16), transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(140, 100, 200, 0.10), transparent 50%);
  filter: blur(60px);
  mix-blend-mode: screen;
  animation: nebulaDrift 30s ease-in-out infinite alternate;
}
@keyframes nebulaDrift {
  0% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  100% { transform: translate(3%, 2%) scale(1.2); opacity: 1; }
}

.star-layer { position: absolute; inset: 0; }
.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--d, 5s) ease-in-out infinite alternate;
  box-shadow: 0 0 6px rgba(255, 255, 240, 0.3);
}
@keyframes twinkle {
  0% { opacity: 0.15; transform: scale(0.7); }
  100% { opacity: 0.95; transform: scale(1.3); }
}
.star-bright { box-shadow: 0 0 14px 2px rgba(200, 210, 255, 0.35); }

.shooting-star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 20px 6px rgba(200, 220, 255, 0.3);
  animation: shoot linear infinite;
  opacity: 0;
}
@keyframes shoot {
  0% { transform: translate(0, 0) scale(0.3); opacity: 0; }
  8% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(-70vw, 70vh) scale(0.1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #nebula, .star, .shooting-star { animation: none !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; display: block; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 24px 64px; position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; margin: 0 0 12px; }

/* ---------- header ---------- */

.page-header { padding: 48px 0 20px; }
.header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.back-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.back-link:hover { color: var(--accent-deep); text-decoration: none; }

.brand-mark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-mark:hover { text-decoration: none; color: var(--accent-deep); }
.brand-mark-icon {
  width: 24px; height: 24px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.page-header h1 {
  font-size: clamp(36px, 7vw, 56px);
  margin: 14px 0 0;
  background: linear-gradient(100deg, var(--ink) 55%, var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.blog-header-icons { display: flex; align-items: center; gap: 6px; }
.blog-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.blog-icon-btn svg { width: 17px; height: 17px; }
.blog-icon-btn:hover { border-color: var(--accent); color: var(--accent-deep); transform: translateY(-1px); }

/* ---------- nav ---------- */

.site-nav { margin: 6px 0 28px; }
.site-nav ul { list-style: none; display: flex; gap: 22px; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.site-nav a {
  display: inline-block; padding: 10px 0; font-family: var(--mono); font-size: 12.5px;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav a.active { color: var(--ink); border-bottom-color: var(--accent); }

.log-wave-divider { width: 100%; height: 12px; color: var(--line); margin: 10px 0 26px; }

/* ---------- topic cards ---------- */

.topic-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 6px; }
.topic-card {
  --accent: var(--accent);
  text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--radius); padding: 16px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; gap: 4px; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.topic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.topic-card.is-active { border-color: var(--accent); background: var(--mist); }
.topic-card-emoji { font-size: 22px; }
.topic-card-name { font-family: var(--display); font-size: 16px; font-weight: 600; margin: 2px 0 0; }
.topic-card-blurb { font-size: 12.5px; color: var(--ink-soft); margin: 0; line-height: 1.4; }
.topic-card-count { font-family: var(--mono); font-size: 11px; color: var(--accent-deep); margin-top: 4px; }

.topic-cards-reset {
  display: none; margin: 14px 0 6px; background: none; border: none; color: var(--ink-soft);
  font-family: var(--mono); font-size: 12px; cursor: pointer; padding: 0;
}
.topic-cards-reset.show { display: inline-block; }
.topic-cards-reset:hover { color: var(--accent-deep); }

/* ---------- tag filter ---------- */

.tag-filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filter-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 5px 13px; font-family: var(--mono); font-size: 11.5px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.filter-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- post list ---------- */

.post-list { display: flex; flex-direction: column; }
.post-row {
  display: grid; grid-template-columns: 82px 1fr; gap: 20px; padding: 26px 0; border-top: 1px solid var(--line);
}
.post-row:last-child { border-bottom: 1px solid var(--line); }
.blog-date { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.log-entry-no {
  display: inline-block; font-family: var(--mono); font-size: 11px; color: var(--accent-deep);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-bottom: 4px;
}
.post-row h2 { font-size: 21px; margin: 0 0 6px; }
.post-row h2 a { color: var(--ink); }
.post-row h2 a:hover { color: var(--accent-deep); text-decoration: none; }
.post-row p { margin: 0 0 8px; color: var(--ink-soft); font-size: 14.5px; }
.tag-chip {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft);
  background: var(--mist); border-radius: 4px; padding: 2px 7px; margin: 0 6px 6px 0;
}
.read-more { font-family: var(--mono); font-size: 12.5px; }

.empty-state {
  padding: 60px 20px; text-align: center; color: var(--ink-soft); font-family: var(--display);
  font-style: italic; font-size: 17px; border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ---------- search overlay ---------- */

.blog-search-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 30, 0.5); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60;
}
.blog-search-backdrop.open { opacity: 1; pointer-events: auto; }
.blog-search-panel {
  position: fixed; top: 12vh; left: 50%; transform: translateX(-50%) translateY(-12px);
  width: min(560px, 92vw); max-height: 68vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 61;
}
.blog-search-panel.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.blog-search-input {
  border: none; border-bottom: 1px solid var(--line); padding: 18px 20px; font-size: 16px;
  font-family: var(--body-font); background: transparent; color: var(--ink); outline: none;
}
.blog-search-results { overflow-y: auto; padding: 6px 0; }
.blog-search-result { display: block; padding: 12px 20px; }
.blog-search-result:hover { background: var(--mist); text-decoration: none; }
.blog-search-result-title { font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--ink); }
.blog-search-result-date { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.blog-search-empty { padding: 20px; color: var(--ink-soft); font-size: 14px; }

/* ---------- email signup ---------- */

.email-signup { margin: 48px 0 24px; padding: 32px; background: var(--mist); border-radius: var(--radius); }
.email-signup-inner { max-width: 480px; }
.email-signup-heading { font-size: 22px; margin-bottom: 6px; }
.email-signup-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.email-signup-form { display: flex; gap: 10px; flex-wrap: wrap; }
.email-signup-input {
  flex: 1; min-width: 200px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--body-font); font-size: 14px; background: var(--surface); color: var(--ink);
}
.email-signup-btn {
  padding: 11px 20px; border: none; border-radius: var(--radius-sm); background: var(--accent); color: #fff;
  font-family: var(--body-font); font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s;
}
.email-signup-btn:hover { background: var(--accent-deep); }
.email-signup-btn:disabled { opacity: 0.6; cursor: default; }
.email-signup-status { font-size: 13px; margin: 10px 0 0; color: var(--ink-soft); }
.email-signup-status.error { color: var(--danger); }

.signup-popup {
  position: fixed; bottom: 24px; right: 24px; max-width: 300px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; transform: translateY(120%);
  opacity: 0; transition: transform .3s, opacity .3s; z-index: 70;
}
.signup-popup.open { transform: translateY(0); opacity: 1; }
.signup-popup-close { position: absolute; top: 8px; right: 10px; border: none; background: none; font-size: 18px; color: var(--ink-soft); cursor: pointer; }
.signup-popup-check { width: 34px; height: 34px; border-radius: 50%; background: var(--good); color: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.signup-popup-msg { margin: 0; font-size: 14px; color: var(--ink); }

/* ---------- footer ---------- */

.site-footer { margin-top: 56px; padding: 28px 0 20px; border-top: 1px solid var(--line); text-align: center; }
.contact-bar { display: flex; justify-content: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.contact-icon {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center; transition: border-color .15s, color .15s;
}
.contact-icon svg { width: 16px; height: 16px; }
.contact-icon:hover { border-color: var(--accent); color: var(--accent-deep); text-decoration: none; }
.site-footer-copyright { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); }

.back-to-top {
  position: fixed; bottom: 20px; right: 20px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; z-index: 40;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top svg { width: 18px; height: 18px; }

/* ---------- drawer ---------- */

.drawer-trigger {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.drawer-trigger:hover { border-color: var(--accent); color: var(--accent-deep); }
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 30, 0.5); opacity: 0; pointer-events: none;
  transition: opacity .2s; z-index: 80;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: min(300px, 84vw); background: var(--surface);
  box-shadow: var(--shadow); transform: translateX(100%); transition: transform .25s ease; z-index: 81;
  padding: 24px; display: flex; flex-direction: column; gap: 4px;
}
.drawer-panel.open { transform: translateX(0); }
.drawer-close { align-self: flex-end; border: none; background: none; font-size: 22px; color: var(--ink-soft); cursor: pointer; margin-bottom: 10px; }
.drawer-nav a {
  display: block; padding: 12px 4px; color: var(--ink); font-family: var(--display); font-size: 17px;
  border-bottom: 1px solid var(--line);
}
.drawer-nav a:hover { color: var(--accent-deep); text-decoration: none; }
.drawer-theme-row { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 16px; border-top: 1px solid var(--line); }
.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); border-radius: 999px;
  padding: 7px 14px; font-family: var(--mono); font-size: 12px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---------- post page ---------- */

.reading-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--accent); width: 0%; z-index: 90; transition: width .1s linear; }
.topbar-sticky { padding-top: 20px; }
.post-page { padding-top: 6px; }
.post-media { margin: 20px 0; border-radius: var(--radius); overflow: hidden; }
.reading-time { font-style: normal; }

.share-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 24px; }
.share-btn, .reading-mode-toggle {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); border-radius: 999px; padding: 7px 13px; font-family: var(--mono); font-size: 11.5px;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.share-btn svg, .reading-mode-toggle svg { width: 14px; height: 14px; }
.share-btn:hover, .reading-mode-toggle:hover { border-color: var(--accent); color: var(--accent-deep); }
.reading-mode-toggle.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.post-body { font-size: 18px; line-height: 1.75; }
.post-body p { margin: 0 0 22px; }
.post-body h2 { font-size: 26px; margin: 36px 0 14px; }
.post-body h3 { font-size: 21px; margin: 28px 0 12px; }
.post-body blockquote {
  margin: 26px 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--ink-soft);
  font-family: var(--display); font-style: italic; font-size: 19px;
}
.post-body img { border-radius: var(--radius); margin: 20px 0; }
.post-body a { text-decoration: underline; }
.post-body ul, .post-body ol { margin: 0 0 22px; padding-left: 22px; }

body.reading-mode { background: #f6f1e7; }
body.reading-mode .post-body { max-width: 640px; margin: 0 auto; }
body.reading-mode .topbar-sticky, body.reading-mode .site-footer, body.reading-mode .share-bar,
body.reading-mode .reaction-bar, body.reading-mode .comments-section, body.reading-mode .post-nav,
body.reading-mode .related-posts { opacity: 0.18; transition: opacity .2s; }
body.reading-mode .topbar-sticky:hover, body.reading-mode .site-footer:hover, body.reading-mode .share-bar:hover,
body.reading-mode .reaction-bar:hover, body.reading-mode .comments-section:hover, body.reading-mode .post-nav:hover,
body.reading-mode .related-posts:hover { opacity: 1; }

.ex-libris {
  margin: 56px 0 32px; padding: 28px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius);
  opacity: 0; transform: translateY(10px); transition: opacity .5s, transform .5s;
}
.ex-libris.visible { opacity: 1; transform: translateY(0); }
.ex-libris-boat { color: var(--accent); margin-bottom: 10px; }
.ex-libris-boat svg { width: 44px; height: 44px; margin: 0 auto; }
.ex-libris-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft); }
.ex-libris-title { font-family: var(--display); font-style: italic; font-size: 19px; margin: 8px 0 4px; }
.ex-libris-meta { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); }

.reaction-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0 36px; }
.reaction-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.reaction-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-deep); }
.reaction-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.reaction-btn:disabled { cursor: default; }
.reaction-btn.reaction-pulse { transform: scale(1.2); }
.reaction-viewed {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono);
  font-size: 11.5px; color: var(--ink-soft); opacity: 0; transition: opacity .2s;
}
.reaction-viewed svg { width: 15px; height: 15px; }
.reaction-viewed.is-active { opacity: 1; }

.comments-section { margin: 32px 0; }
.comments-heading { font-size: 19px; }
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.comment-form input, .comment-form textarea {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 13px;
  font-family: var(--body-font); font-size: 14px; background: var(--surface); color: var(--ink); resize: vertical;
}
.comment-form textarea { min-height: 90px; }
.comment-submit {
  align-self: flex-start; border: none; background: var(--accent); color: #fff; padding: 10px 20px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; cursor: pointer;
}
.comment-submit:hover { background: var(--accent-deep); }
.comment-submit:disabled { opacity: 0.6; cursor: default; }
.comment-list { display: flex; flex-direction: column; gap: 16px; }
.comment-item { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.comment-meta { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.comment-name { font-weight: 600; font-size: 13.5px; }
.comment-date { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.comment-text { font-size: 14.5px; color: var(--ink); white-space: pre-wrap; }
.comment-empty { color: var(--ink-soft); font-size: 14px; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 40px 0; }
.post-nav-link { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.post-nav-link:hover { border-color: var(--accent); text-decoration: none; }
.post-nav-next { text-align: right; align-items: flex-end; }
.post-nav-label { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.post-nav-title { font-family: var(--display); font-weight: 600; font-size: 14.5px; color: var(--ink); }

.related-posts { margin: 40px 0; }
.related-heading { font-size: 17px; margin-bottom: 14px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.related-card { display: block; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.related-card:hover { border-color: var(--accent); text-decoration: none; }
.related-card-date { font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft); }
.related-card-title { font-family: var(--display); font-weight: 600; font-size: 14.5px; margin-top: 4px; color: var(--ink); }

.quote-share-popover {
  position: absolute; transform: translateX(-50%); display: flex; gap: 6px; background: var(--ink); color: #fff;
  border-radius: 999px; padding: 6px; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 55;
}
.quote-share-popover.visible { opacity: 1; pointer-events: auto; }
.quote-share-popover button { border: none; background: none; color: #fff; font-size: 11.5px; padding: 5px 10px; border-radius: 999px; cursor: pointer; }
.quote-share-popover button:hover { background: rgba(255,255,255,0.15); }

@media (max-width: 640px) {
  .post-row { grid-template-columns: 1fr; gap: 6px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; align-items: flex-start; }
}

/* ===========================================================
   ADMIN
   =========================================================== */

.admin-login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at top, var(--mist), var(--paper) 60%);
}
.admin-login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow);
}
.admin-login-card h1 { font-size: 22px; margin-bottom: 4px; }
.admin-login-card p.sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 24px; }
.admin-login-card label { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft); margin-bottom: 6px; }
.admin-login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--body-font); font-size: 14.5px; margin-bottom: 16px; background: var(--paper); color: var(--ink);
}
.admin-login-card button {
  width: 100%; padding: 12px; border: none; border-radius: var(--radius-sm); background: var(--accent); color: #fff;
  font-weight: 600; font-size: 14.5px; cursor: pointer;
}
.admin-login-card button:hover { background: var(--accent-deep); }
.admin-login-error { color: var(--danger); font-size: 13px; margin: 0 0 14px; min-height: 1em; }

.admin-shell { display: flex; min-height: 100vh; background: var(--paper); }
.admin-sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.admin-brand { font-family: var(--display); font-weight: 600; font-size: 18px; margin-bottom: 20px; padding: 0 8px; }
.admin-brand span { color: var(--accent-deep); }
.admin-nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: none; background: none; text-align: left; color: var(--ink-soft); font-family: var(--body-font);
  font-size: 14px; cursor: pointer; width: 100%;
}
.admin-nav-btn:hover { background: var(--mist); color: var(--ink); }
.admin-nav-btn.active { background: var(--accent); color: #fff; }
.admin-sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.admin-view-link { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); padding: 0 12px; }
.admin-logout-btn {
  border: 1px solid var(--line); background: none; color: var(--ink-soft); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; cursor: pointer; text-align: left;
}
.admin-logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.admin-main { flex: 1; padding: 32px 40px 80px; max-width: 900px; }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-panel h2 { font-size: 24px; margin-bottom: 4px; }
.admin-panel-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 28px; }

.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.admin-card h3 { font-size: 16px; margin-bottom: 16px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 6px; text-transform: uppercase; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--body-font); font-size: 14px; background: var(--paper); color: var(--ink);
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: var(--radius-sm); padding: 9px 16px; font-family: var(--body-font);
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: none; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-empty { color: var(--ink-soft); font-size: 14px; padding: 20px 0; }

.post-editor-overlay {
  position: fixed; inset: 0; background: rgba(20,20,30,0.55); display: none; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.post-editor-overlay.open { display: flex; }
.post-editor {
  background: var(--surface); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 680px;
  box-shadow: var(--shadow); margin-bottom: 40px;
}
.post-editor h3 { margin-bottom: 18px; }

.rte-toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; border: 1px solid var(--line); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 6px; background: var(--paper); }
.rte-toolbar button {
  border: 1px solid transparent; background: none; width: 30px; height: 30px; border-radius: 5px; cursor: pointer;
  color: var(--ink-soft); font-family: var(--display); font-weight: 700; font-size: 14px;
}
.rte-toolbar button:hover { background: var(--mist); border-color: var(--line); color: var(--ink); }
.rte-body {
  min-height: 220px; border: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 14px; font-size: 15px; line-height: 1.6; background: var(--paper); color: var(--ink); overflow-y: auto;
}
.rte-body:focus { outline: none; border-color: var(--accent); }
.rte-body p { margin: 0 0 12px; }

.thumb-preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 8px; display: none; }
.thumb-preview.show { display: block; }

.admin-toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: var(--paper); padding: 12px 20px;
  border-radius: var(--radius-sm); font-size: 13.5px; box-shadow: var(--shadow); transform: translateY(20px);
  opacity: 0; transition: transform .2s, opacity .2s; z-index: 200;
}
.admin-toast.show { transform: translateY(0); opacity: 1; }
.admin-toast.error { background: var(--danger); }

.admin-comments-post { margin-bottom: 26px; }
.admin-comments-post h4 { font-size: 15px; margin-bottom: 4px; }
.admin-stat-row { display: flex; gap: 16px; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-bottom: 10px; }
.admin-comment-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.admin-comment-row .txt { flex: 1; font-size: 13.5px; }
.admin-comment-row .meta { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .admin-sidebar-footer { margin-top: 0; padding-top: 0; border-top: none; flex-direction: row; }
  .admin-main { padding: 24px; }
  .form-grid { grid-template-columns: 1fr; }
}
