/* ============================================================
   Red Lotus — Blog stylesheet
   Shared by blog.html (listing) and blog/*.html (posts).
   Mirrors the design system inlined in index.html / contact.html
   so the blog inherits the same look without a build step.
   ============================================================ */

:root {
  --red: #ca4d4d;
  --red-bright: #e05555;
  --red-glow: rgba(202, 77, 77, 0.3);
  --dark: #0a0a0f;
  --dark-surface: #111118;
  --dark-card: #16161f;
  --dark-border: rgba(255, 255, 255, 0.06);
  --light: #faf9f7;
  --light-warm: #f5f2ee;
  --text-primary: #e8e6e3;
  --text-muted: #8a8a9a;
  --text-dark: #1a1a2e;
  --serif: 'DM Serif Display', Georgia, serif;
  --sans: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--red) var(--dark);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--red); border-radius: 3px; }

body {
  font-family: var(--sans);
  color: var(--text-primary);
  background: var(--dark);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ===== Grain Overlay ===== */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px;
}

/* ===== Navigation ===== */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0 clamp(24px, 4vw, 60px);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--dark-border);
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #fff;
}

.nav-brand img {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1);
}

.nav-brand span {
  font-family: var(--serif);
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 40px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 36px;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: color 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
}

.lang-toggle {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 3px;
  gap: 2px;
}

.lang-toggle a {
  border: none;
  background: transparent;
  padding: 6px 16px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--text-muted);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.lang-toggle a.active {
  background: var(--red);
  color: #fff;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 30px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
}

.hamburger span {
  display: block;
  height: 1.5px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  transform-origin: center;
}

.hamburger span:first-child { width: 100%; }
.hamburger span:nth-child(2) { width: 70%; margin-left: auto; }
.hamburger span:last-child { width: 100%; }

.hamburger.open span:first-child { transform: translateY(7.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:last-child { transform: translateY(-7.5px) rotate(-45deg); }

/* ===== Shared bits ===== */
.section-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--red-bright);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-label::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--red);
}

main {
  flex: 1;
  position: relative;
}

/* Soft background orbs reused on blog pages */
.page-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.page-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.22;
}

.page-orb--1 {
  width: 520px;
  height: 520px;
  background: var(--red);
  top: -12%;
  right: -8%;
}

.page-orb--2 {
  width: 360px;
  height: 360px;
  background: #e07356;
  bottom: 6%;
  left: -6%;
}

/* ============================================================
   Blog listing (blog.html)
   ============================================================ */
.blog-head {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 140px clamp(24px, 4vw, 60px) 60px;
}

.blog-head h1 {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 400;
  color: #fff;
  line-height: 1.1;
  letter-spacing: -1.5px;
  margin-bottom: 24px;
}

.blog-head h1 em {
  font-style: italic;
  color: var(--red-bright);
}

.blog-head p {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--text-muted);
  max-width: 560px;
  line-height: 1.8;
  font-weight: 300;
}

.blog-grid {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 60px) clamp(80px, 10vw, 120px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--dark-surface);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
  padding: clamp(28px, 3vw, 40px);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.post-card:hover {
  transform: translateY(-4px);
  background: var(--dark-card);
  border-color: rgba(202, 77, 77, 0.25);
}

.post-card:hover::before { transform: scaleX(1); }

/* Optional cover image at the top of a card (bleeds to the card edges) */
.post-card .post-thumb {
  margin: calc(-1 * clamp(28px, 3vw, 40px));
  margin-bottom: 26px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--dark-card);
  border-bottom: 1px solid var(--dark-border);
}
.post-card .post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.post-card:hover .post-thumb img { transform: scale(1.04); }

.post-card .post-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.post-tag {
  color: var(--red-bright);
  border: 1px solid rgba(202, 77, 77, 0.35);
  border-radius: 20px;
  padding: 4px 12px;
}

.post-card h2 {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: #fff;
  line-height: 1.25;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}

.post-card .post-excerpt {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 24px;
  flex: 1;
}

.post-card .post-readmore {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #fff;
}

.post-card .post-readmore svg {
  width: 15px;
  height: 15px;
  transition: transform 0.3s;
}

.post-card:hover .post-readmore svg { transform: translateX(4px); }

.post-readtime {
  margin-left: auto;
}

/* ============================================================
   Blog post / article (blog/*.html)
   ============================================================ */
.article-head {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 130px clamp(24px, 4vw, 40px) 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 36px;
  transition: color 0.3s;
}

.back-link:hover { color: var(--red-bright); }
.back-link svg { width: 15px; height: 15px; transition: transform 0.3s; }
.back-link:hover svg { transform: translateX(-3px); }

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 26px;
}

.article-head h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 400;
  color: #fff;
  line-height: 1.12;
  letter-spacing: -1.5px;
  margin-bottom: 24px;
}

.article-head h1 em {
  font-style: italic;
  color: var(--red-bright);
}

.article-lede {
  font-size: clamp(1.1rem, 1.8vw, 1.3rem);
  color: var(--text-primary);
  line-height: 1.7;
  font-weight: 300;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--dark-border);
}

/* Cover image at the top of an article */
.article-hero {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 40px auto 8px;
  padding: 0 clamp(24px, 4vw, 40px);
}
.article-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--dark-border);
  background: var(--dark-card);
}

.article-body {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 48px clamp(24px, 4vw, 40px) clamp(80px, 10vw, 120px);
}

.article-body > p,
.article-body > ul,
.article-body > ol,
.article-body > h2,
.article-body > h3,
.article-body > blockquote,
.article-body > figure {
  max-width: 720px;
}

.article-body h2 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 400;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin: 56px 0 20px;
}

.article-body h3 {
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  margin: 40px 0 14px;
}

.article-body p {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.9;
  margin-bottom: 24px;
}

.article-body strong { color: var(--text-primary); font-weight: 600; }
.article-body em { color: var(--text-primary); }

.article-body a {
  color: var(--red-bright);
  text-decoration: none;
  border-bottom: 1px solid rgba(202, 77, 77, 0.4);
  transition: border-color 0.3s;
}
.article-body a:hover { border-color: var(--red-bright); }

.article-body ul,
.article-body ol {
  color: var(--text-muted);
  line-height: 1.9;
  font-size: 1.05rem;
  margin: 0 0 24px 1.2em;
}

.article-body li { margin-bottom: 10px; padding-left: 6px; }
.article-body li::marker { color: var(--red); }

.article-body blockquote {
  border-left: 2px solid var(--red);
  padding: 8px 0 8px 28px;
  margin: 40px 0;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.4vw, 1.7rem);
  font-style: italic;
  color: #fff;
  line-height: 1.5;
}

.article-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--red-bright);
}

.article-body pre {
  background: var(--dark-surface);
  border: 1px solid var(--dark-border);
  border-radius: 12px;
  padding: 24px;
  overflow-x: auto;
  margin: 0 0 28px;
  max-width: 820px;
}

.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1.7;
}

/* Figures (used to wrap interactive diagrams) */
.article-body figure {
  margin: 48px 0;
  max-width: 820px;
}

.article-body figcaption {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  margin-top: 18px;
}

/* Photographic / raster images embedded in the body */
.article-body figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--dark-border);
}
.article-body figure.figure--narrow { max-width: 560px; margin-left: auto; margin-right: auto; }

/* Book list with a small cover per item */
.article-body ul.book-list {
  list-style: none;
  padding-left: 0;
}
.book-list .book-item {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
  padding-left: 0;
}
.book-list .book-item::marker { content: none; }
.book-list .book-cover {
  width: 64px;
  flex-shrink: 0;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--dark-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.book-list .book-item > div { flex: 1; }
@media (max-width: 480px) {
  .book-list .book-cover { width: 52px; }
}

/* Original-source note (e.g. cross-posted from LinkedIn) */
.article-source {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 820px;
  margin: 48px 0 0;
  padding: 16px 20px;
  background: var(--dark-card);
  border: 1px solid var(--dark-border);
  border-radius: 12px;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.article-source svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--red-bright); }
.article-source a { color: var(--red-bright); }

/* Article footer / next steps */
.article-footer {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 40px);
}

.article-cta {
  background: var(--dark-surface);
  border: 1px solid var(--dark-border);
  border-radius: 16px;
  padding: clamp(28px, 4vw, 44px);
  text-align: center;
}

.article-cta h3 {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 400;
  color: #fff;
  margin-bottom: 14px;
  line-height: 1.2;
}

.article-cta p {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 1rem;
}

.article-cta .cta-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--red);
  color: #fff;
  padding: 15px 34px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.article-cta .cta-button:hover {
  background: var(--red-bright);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--red-glow);
}

.article-cta .cta-button svg { width: 16px; height: 16px; }

/* ===== Footer ===== */
footer {
  background: var(--dark);
  border-top: 1px solid var(--dark-border);
  padding: 60px clamp(24px, 4vw, 60px) 40px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--dark-border);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.footer-brand img { height: 28px; filter: brightness(0) invert(1); }
.footer-brand span { font-family: var(--serif); font-size: 1.1rem; }

.footer-email a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.3s;
}

.footer-email a:hover { color: var(--red-bright); }
.footer-email svg { width: 16px; height: 16px; }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-bottom p {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.footer-links { display: flex; gap: 20px; }

.footer-links a,
.footer-links button {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  opacity: 0.7;
  transition: opacity 0.3s;
}

.footer-links a:hover,
.footer-links button:hover { opacity: 1; }

/* ===== Scroll reveals ===== */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger blog cards as they appear */
.blog-grid .post-card:nth-child(2) { transition-delay: 0.06s; }
.blog-grid .post-card:nth-child(3) { transition-delay: 0.12s; }
.blog-grid .post-card:nth-child(4) { transition-delay: 0.18s; }
.blog-grid .post-card:nth-child(5) { transition-delay: 0.24s; }
.blog-grid .post-card:nth-child(6) { transition-delay: 0.30s; }

/* ===== Language ===== */
/* Portuguese is the default; blog.js flips to English on demand */
.content.en { display: none; }

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* ===== Responsive ===== */
.menu-backdrop { display: none; }

@media (max-width: 768px) {
  body.menu-open { overflow: hidden; }

  .menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 998;
  }

  .menu-backdrop.open { opacity: 1; visibility: visible; }

  .nav-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    width: min(85vw, 320px);
    background: #0d0d14;
    flex-direction: column;
    align-items: flex-start;
    padding: 100px 32px 32px;
    gap: 32px;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 1px solid var(--dark-border);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 999;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .nav-right.open { transform: translateX(0); }

  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    width: 100%;
  }

  .nav-links a { font-size: 1rem; }

  .hamburger { display: flex; z-index: 1001; }

  .blog-grid { grid-template-columns: 1fr; }

  .footer-top, .footer-bottom {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .blog-head { padding-left: 20px; padding-right: 20px; }
  .blog-grid { padding-left: 20px; padding-right: 20px; }
}

/* ============================================================
   Reader features — created at runtime by blog.js on post pages.
   Progress bar, table of contents, text-to-speech, highlights.
   ============================================================ */

/* ----- 1. Reading progress bar ----- */
.reading-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 1100;
  pointer-events: none;
}
.reading-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--red), var(--red-bright));
  box-shadow: 0 0 10px var(--red-glow);
  transition: transform 0.1s linear;
}

/* ----- 2. Table of contents ----- */
.toc {
  position: fixed;
  top: 50%;
  left: max(20px, calc((100vw - 1320px) / 2));
  transform: translateY(-50%);
  width: 210px;
  max-height: 72vh;
  overflow: auto;
  z-index: 900;
  display: none;
}
@media (min-width: 1280px) {
  .toc.toc-ready { display: block; }
}
.toc-title {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.toc ul { list-style: none; border-left: 1px solid var(--dark-border); }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  line-height: 1.4;
  transition: color 0.2s, border-color 0.2s;
}
/* top-level (h2) entries read as section titles */
.toc-h2 a { color: var(--text-primary); font-weight: 600; }
.toc-h2 ~ .toc-h2 a { margin-top: 6px; }
/* nested (h3) entries: indented, smaller, lighter, with a tick */
.toc-h3 a {
  padding-left: 30px;
  font-size: 0.74rem;
  font-weight: 400;
  position: relative;
}
.toc-h3 a::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 50%;
  width: 7px;
  height: 1px;
  background: var(--dark-border);
}
.toc a:hover { color: var(--text-primary); }
.toc a.active { color: var(--red-bright); border-left-color: var(--red); }
.toc-h3 a.active::before { background: var(--red); }

/* anchored headings clear the fixed nav */
.article-body h2, .article-body h3 { scroll-margin-top: 90px; }

/* ----- 3. Text-to-speech ----- */
.tts-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(17, 17, 24, 0.92);
  border: 1px solid var(--dark-border);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.tts-bar.tts-ready { display: flex; }
.tts-bar button {
  font-family: var(--sans);
  color: var(--text-primary);
  background: transparent;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, color 0.2s;
}
.tts-bar button:hover { background: rgba(255, 255, 255, 0.06); }
.tts-play { background: var(--red) !important; color: #fff !important; font-weight: 600; }
.tts-play:hover { background: var(--red-bright) !important; }
.tts-bar.is-active .tts-play { background: rgba(255, 255, 255, 0.06) !important; color: var(--text-primary) !important; }
.tts-ico { font-size: 0.72rem; line-height: 1; }
.tts-rate { min-width: 44px; justify-content: center; font-variant-numeric: tabular-nums; }
.tts-stop { display: none; font-size: 0.7rem; }
.tts-bar.is-active .tts-stop { display: inline-flex; }

/* karaoke follow */
.tts-reading {
  background: linear-gradient(90deg, rgba(202, 77, 77, 0.12), transparent 92%);
  border-radius: 6px;
  transition: background 0.3s;
}
::highlight(rl-reading) { background-color: rgba(202, 77, 77, 0.38); color: #fff; }

/* ----- 4. User highlights + selection toolbar ----- */
::highlight(rl-mark) { background-color: rgba(202, 77, 77, 0.32); color: #fff; }
.rl-user-mark { background: rgba(202, 77, 77, 0.32); color: #fff; border-radius: 2px; }

.sel-toolbar {
  position: fixed;
  z-index: 1200;
  display: none;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
  background: #16161f;
  border: 1px solid var(--dark-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.sel-toolbar button {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px 11px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.sel-toolbar button:hover { background: rgba(255, 255, 255, 0.07); color: var(--red-bright); }
.sel-toolbar .sel-sep { width: 1px; background: var(--dark-border); }

/* ----- toast ----- */
.rl-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 12px);
  z-index: 1300;
  background: #16161f;
  color: var(--text-primary);
  border: 1px solid var(--dark-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.rl-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .reading-progress > span { transition: none; }
  .tts-reading { transition: none; }
}
@media (max-width: 680px) {
  .tts-bar { bottom: 14px; }
  .rl-toast { bottom: 72px; }
}
