/* Single article */
.preview-bar { background: #FEF3C7; color: #78350F; text-align: center; padding: 10px 16px; font-size: 0.88rem; font-weight: 600; }
.preview-bar a { text-decoration: underline; margin-left: 8px; }

.article-hero { background: linear-gradient(135deg, #1a1a4e 0%, #303078 60%, #1a1a4e 100%); color: var(--white); padding: 40px 0 56px; border-bottom: 3px solid rgba(255,255,255,0.08); position: relative; overflow: hidden; }
.article-hero::after { content: ''; position: absolute; top: -50%; right: -10%; width: 500px; height: 500px; background: radial-gradient(circle, rgba(156,155,232,0.2) 0%, transparent 70%); pointer-events: none; }
.article-hero .wrap { position: relative; z-index: 1; }
.article-hero .category-badge { display: inline-block; color: #303078; background: #e8e8fb; margin-bottom: 12px; }
.article-hero h1 { font-size: 2.5rem; max-width: 850px; line-height: 1.2; }
.article-dek { color: rgba(255,255,255,0.75); font-size: 1.1rem; max-width: 760px; margin-top: 14px; }

.article-meta { display: flex; align-items: center; gap: 12px; margin-top: 22px; color: var(--slate-light); font-size: 0.88rem; flex-wrap: wrap; }
.article-meta .author-avatar { width: 32px; height: 32px; font-size: 0.75rem; }

/* Separators are generated here rather than written into the markup as their
   own <span>. As a standalone element a separator became an independent flex
   item, so when the row wrapped on a phone it could land at the end of one line
   with nothing after it, leaving a stray dot. Attached to the item it can
   never be orphaned. */
.article-meta > * + *::before {
  content: '\2022';
  margin-right: 12px;
  color: rgba(148, 163, 184, 0.55);
}
.article-meta .author-avatar::before { content: none; }

@media (max-width: 640px) {
  /* On a phone this row wraps onto two or three lines. Drop the separators
     there and separate the items with spacing instead, so no line can begin or
     end with a floating dot. */
  .article-meta > * + *::before { content: none; }
  .article-meta { gap: 8px 18px; }
}
.single-share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  /* 44px on touch: at 28px this was well under a comfortable tap target. */
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); color: var(--slate-light); padding: 0; margin-left: 2px;
}
@media (hover: hover) and (pointer: fine) {
  .single-share-btn { width: 28px; height: 28px; }
}
/* The separator rule above draws a "•" in ::before of every item after the
   first. On the share button that bullet landed inside the 28px circle and
   pushed the icon off-centre to the right. The button gets its own gap
   instead. */
.article-meta > .single-share-btn::before { content: none; }
.article-meta > .single-share-btn { margin-left: 4px; flex: 0 0 auto; }
.single-share-btn {
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.single-share-btn:hover {
  background: var(--accent); color: var(--white);
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(108, 107, 216, 0.4);
}
.single-share-btn svg { width: 16px; height: 16px; fill: currentColor; }

.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; padding: 48px 0 80px; }

.article-main, .sidebar { min-width: 0; }
.featured-image-wrap { margin: 0 0 32px; border-radius: var(--radius-lg); overflow: hidden; background: var(--panel); }
.featured-image-wrap img { display: block; width: 100%; height: auto; max-height: 460px; object-fit: cover; }

.toc-inline { display: none; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 28px; }
.toc-inline summary { font-weight: 700; cursor: pointer; }
.toc-inline ol { margin: 10px 0 0; padding-left: 20px; }
.toc-inline li { margin: 6px 0; }
.toc-inline a:hover { color: var(--primary-ink); }

/* Article typography */
.article-body { font-size: 1.07rem; color: var(--ink); line-height: 1.8; overflow-wrap: break-word; }
.article-body > * + * { margin-top: 0; }
.article-body p { margin: 0 0 24px; }
.article-body h2 { font-size: 1.6rem; margin: 40px 0 16px; color: var(--navy); line-height: 1.3; }
.article-body h3 { font-size: 1.3rem; margin: 32px 0 12px; color: var(--navy); line-height: 1.35; }
.article-body h4 { font-size: 1.1rem; margin: 24px 0 10px; }
.article-body ul, .article-body ol { margin: 0 0 24px; padding-left: 24px; }
.article-body li { margin-bottom: 8px; }
.article-body a { color: var(--primary-ink); text-decoration: underline; text-underline-offset: 3px; }
.article-body a:hover { color: var(--primary); }
.article-body blockquote {
  margin: 0 0 24px; padding: 16px 22px; border-left: 4px solid var(--primary);
  background: var(--primary-light); border-radius: 0 var(--radius-md) var(--radius-md) 0; color: var(--navy-card);
}
.article-body blockquote p:last-child { margin-bottom: 0; }
.article-body img { border-radius: var(--radius-md); display: block; margin: 8px auto; }
.article-body figure { margin: 0 0 24px; }
.article-body figcaption { text-align: center; font-size: 0.85rem; color: var(--slate); margin-top: 8px; }
.article-body :not(pre) > code {
  font-family: var(--mono); background: rgba(59,130,246,0.1); color: var(--primary-ink);
  padding: 2px 6px; border-radius: 4px; font-size: 0.88em;
}
.article-body .code-block-wrapper { margin: 0 0 24px; }
.article-body hr { border: none; border-top: 1px solid var(--line); margin: 36px 0; }
.article-body table { width: 100%; border-collapse: collapse; margin: 0 0 24px; font-size: 0.95rem; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; }
.article-body th { background: var(--panel); }
.article-body iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--radius-md); margin-bottom: 24px; }

/* Author + prev/next */
.author-box { display: flex; gap: 16px; align-items: flex-start; margin-top: 40px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); }
.author-avatar.lg { width: 52px; height: 52px; font-size: 1rem; }
.author-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--slate); font-weight: 700; }
.author-name { font-weight: 700; font-size: 1.05rem; }
.author-bio { color: var(--slate); font-size: 0.92rem; margin-top: 4px; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.post-nav-link { display: flex; flex-direction: column; gap: 4px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); transition: all 0.2s ease; }
.post-nav-link:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.post-nav-link span { font-size: 0.8rem; color: var(--slate); font-weight: 600; }
.post-nav-link strong { font-size: 0.95rem; line-height: 1.4; }
.post-nav-link.next { text-align: right; grid-column: 2; }

/* Sidebar */
.sticky-sidebar { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 24px; }
.sidebar-widget { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.widget-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--slate);
  margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.toc-widget ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc-widget li { counter-increment: toc; margin: 0 0 10px; font-size: 0.88rem; line-height: 1.4; display: flex; gap: 8px; }
.toc-widget li::before { content: counter(toc, decimal-leading-zero); font-family: var(--mono); font-size: 0.75rem; color: var(--slate-light); padding-top: 2px; }
.toc-widget a { color: var(--slate); }
.toc-widget a:hover, .toc-widget a.active { color: var(--primary-ink); font-weight: 600; }

.ad-box { background: linear-gradient(135deg, var(--navy), var(--navy-card)); color: var(--white); border: none; }
.ad-tag { font-size: 0.65rem; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.ad-title { font-size: 1.1rem; font-weight: 700; margin-top: 8px; }
.ad-copy { font-size: 0.85rem; color: var(--slate-light); margin-top: 8px; line-height: 1.4; }
.ad-btn {
  margin-top: 16px; background: var(--primary); color: var(--white); font-weight: 600; font-size: 0.85rem;
  padding: 10px 16px; border-radius: var(--radius-sm); width: 100%; display: block; text-align: center;
}
.ad-btn:hover { background: var(--primary-hover); }
.ad-slot { padding: 12px; }

.related-post-card { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; position: relative; }
.related-post-card:last-child { margin-bottom: 0; }
.related-thumb { width: 64px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; background: var(--line); display: block; }
.related-info { min-width: 0; }
.related-title {
  font-size: 0.88rem; font-weight: 600; color: var(--ink); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.related-title::after { content: ''; position: absolute; inset: 0; }
.related-post-card:hover .related-title { color: var(--primary-ink); }
.related-date { display: block; font-size: 0.75rem; color: var(--slate); margin-top: 4px; }

@media (max-width: 900px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 32px; }
  .sticky-sidebar { position: static; }
  .toc-widget { display: none; }
  .toc-inline { display: block; }
  .article-hero { padding: 32px 0 40px; }
  .article-hero h1 { font-size: 1.8rem; }
}
@media (max-width: 560px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link.next { grid-column: auto; }
}
