
:root {
  --bg: #faf9f6;
  --bg-surface: #ffffff;
  --bg-sidebar: #f3f1ec;
  --text-main: #1c1917;
  --text-muted: #57534e;
  --text-dim: #78716c;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --accent: #0f172a;
  --accent-blue: #1e3a8a;
  --accent-gold: #b45309;
  --code-bg: #18181b;
  --code-text: #f4f4f5;
  --card-hover: #f5f5f4;
  --font-serif: 'Newsreader', Georgia, Cambria, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
  --font-brand: 'Cinzel', 'Times New Roman', serif;
}

[data-theme="dark"] {
  --bg: #09090b;
  --bg-surface: #121215;
  --bg-sidebar: #0f0f12;
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --border: #27272a;
  --border-strong: #3f3f46;
  --accent: #f8fafc;
  --accent-blue: #60a5fa;
  --accent-gold: #f59e0b;
  --code-bg: #09090b;
  --code-text: #f4f4f5;
  --card-hover: #18181b;
}

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

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.reading-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-gold));
  width: 0%;
  z-index: 1000;
  transition: width 0.1s ease;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 900;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-name {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.12em;
}

.brand-divider {
  color: var(--border-strong);
  font-weight: 300;
}

.brand-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-link {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.header-link:hover, .header-link.active {
  color: var(--text-main);
  background-color: var(--bg);
}

.header-cta {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background-color: var(--accent);
  padding: 0.45rem 0.95rem;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

[data-theme="dark"] .header-cta {
  color: #000;
  background-color: #fff;
}

.header-cta:hover {
  opacity: 0.9;
}

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  color: var(--text-main);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.theme-icon.dark { display: none; }
[data-theme="dark"] .theme-icon.light { display: none; }
[data-theme="dark"] .theme-icon.dark { display: inline; }

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Layout */
.layout-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  min-height: calc(100vh - 65px);
}

/* Sidebar */
.site-sidebar {
  width: 320px;
  flex-shrink: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-date {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.series-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.series-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
  transition: all 0.15s ease;
}

.series-nav a:hover {
  background-color: var(--card-hover);
  color: var(--text-main);
}

.series-nav li.active a {
  background-color: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  border: 1px solid var(--border);
}

.nav-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-gold);
  flex-shrink: 0;
}

.sidebar-section-divider {
  margin: 1.25rem 0 0.6rem 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.nav-commercial a {
  border: 1px dashed var(--accent-gold);
  background-color: var(--bg-surface);
  font-weight: 600;
  color: var(--text-main);
}

.article-body details {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 2rem 0;
}

.article-body summary {
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-main);
  padding: 0.25rem 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.author-card {
  font-size: 0.8rem;
}

.author-name {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.author-bio {
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.4rem;
}

.author-email {
  color: var(--accent-blue);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Content Area */
.content-area {
  flex-grow: 1;
  padding: 3rem 4rem;
  display: flex;
  justify-content: center;
}

.prose-wrapper {
  max-width: 820px;
  width: 100%;
}

.article-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.article-title {
  font-family: var(--font-serif);
  font-size: 2.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.article-subtitle {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Executive reading guide */
.executive-brief {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-gold);
  border-radius: 10px;
  padding: 1.4rem 1.5rem;
  margin: 0 0 2.5rem 0;
}

.brief-label {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 1rem;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.5rem;
}

.brief-item {
  min-width: 0;
}

.brief-item dt {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.brief-item dd {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* Public proof link */
.proof-link-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-gold);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 3rem 0;
}

.proof-link-panel h2 {
  border: none;
  margin: 0 0 0.5rem 0;
  font-size: 1.35rem;
}

.proof-link-panel p {
  margin: 0;
  color: var(--text-muted);
}

.proof-link-panel .btn-primary {
  flex-shrink: 0;
}

.proof-actions {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0 2rem 0;
}

/* Prose Typography */
.article-body {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  line-height: 1.8;
  color: var(--text-main);
}

.article-body h2 {
  font-family: var(--font-sans);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 3rem 0 1rem 0;
  color: var(--text-main);
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.article-body h3 {
  font-family: var(--font-sans);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 2.25rem 0 0.85rem 0;
  color: var(--text-main);
}

.article-body h4 {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem 0;
  color: var(--text-muted);
}

.article-body p {
  margin-bottom: 1.5rem;
}

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

.article-body em {
  font-style: italic;
}

.article-body ul, .article-body ol {
  margin: 0 0 1.75rem 1.75rem;
}

.article-body li {
  margin-bottom: 0.5rem;
}

.article-body blockquote {
  border-left: 3px solid var(--accent-gold);
  background-color: var(--bg-surface);
  padding: 1.25rem 1.75rem;
  margin: 2rem 0;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-muted);
}

.article-body pre {
  background-color: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-strong);
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background-color: var(--card-hover);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--text-main);
}

.article-body pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.article-body th, .article-body td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.article-body th {
  font-weight: 600;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border-bottom: 2px solid var(--border-strong);
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* Pagination */
.article-pagination {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}

.pagination-link {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  background-color: var(--bg-surface);
  flex: 1;
  transition: all 0.15s ease;
}

.pagination-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.pagination-link.next {
  text-align: right;
}

.pagination-sub {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.pagination-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Footer CTA */
.article-footer-cta {
  margin-top: 4rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
}

.article-footer-cta h3 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.article-footer-cta p {
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto 1.75rem auto;
  line-height: 1.6;
}

.cta-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: opacity 0.15s ease;
}

[data-theme="dark"] .btn-primary {
  background-color: #fff;
  color: #000;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background-color 0.15s ease;
}

.btn-secondary:hover {
  background-color: var(--card-hover);
}

/* Homepage Styles */
.homepage-hero {
  text-align: center;
  padding: 4rem 1rem 3rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  background-color: var(--bg-surface);
  padding: 0.35rem 0.85rem;
  border-radius: 50px;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-main);
  margin-bottom: 1.5rem;
}

.hero-lead {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 auto 2.5rem auto;
}

.hero-cta-group {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.series-architecture-banner {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 3.5rem;
}

.banner-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 1rem;
  text-align: center;
}

.transitions-chain {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.chain-node {
  background-color: var(--bg);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.chain-node.active {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 600;
}

.chain-arrow {
  color: var(--border-strong);
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 4rem;
}

.article-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.article-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.05);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.card-theme {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

.card-title {
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

.card-link-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-blue);
}

.commercial-callout {
  background-color: var(--bg-surface);
  border: 2px solid var(--accent-gold);
  border-radius: 12px;
  padding: 3rem;
  margin-bottom: 2rem;
}

.commercial-callout h2 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.commercial-callout p {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.commercial-callout ul {
  margin: 0 0 2rem 1.5rem;
  color: var(--text-muted);
}

.commercial-callout li {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.callout-actions {
  display: flex;
  gap: 1rem;
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background-color: var(--bg-surface);
  padding: 2rem 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Responsive */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

.content-area, .prose-wrapper {
  min-width: 0;
}

.article-title, .article-subtitle, .article-meta, .hero-title, .hero-lead,
.article-body p, .article-body li, .article-body td, .article-body th {
  overflow-wrap: anywhere;
}

.article-meta {
  flex-wrap: wrap;
}

.article-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.article-body img, .article-body video, .article-body canvas, .article-body svg {
  max-width: 100%;
  height: auto;
}

@media (max-width: 1024px) {
  .site-sidebar {
    position: fixed;
    left: -320px;
    top: 57px;
    height: calc(100vh - 57px);
    z-index: 1000;
    transition: left 0.25s ease;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
  }
  .site-sidebar.open {
    left: 0;
  }
  .mobile-menu-btn {
    display: block;
  }
  .header-inner {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .brand {
    min-width: 0;
    flex-wrap: wrap;
  }
  .brand-tagline {
    overflow-wrap: anywhere;
  }
  .header-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .content-area {
    padding: 2rem 1.5rem;
  }
  .article-title {
    font-size: 2.2rem;
  }
  .hero-title {
    font-size: 2.5rem;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0.7rem 0.85rem;
    align-items: flex-start;
  }
  .brand {
    gap: 0.35rem;
  }
  .brand-name {
    font-size: 1rem;
  }
  .brand-tagline {
    font-size: 0.78rem;
  }
  .header-link {
    display: none;
  }
  .header-cta, .theme-btn, .mobile-menu-btn {
    flex-shrink: 0;
  }
  .content-area {
    padding: 1.5rem 1rem;
  }
  .executive-brief {
    padding: 1.1rem 1rem;
    margin-bottom: 2rem;
  }
  .brief-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .proof-link-panel {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.1rem 1rem;
  }
  .proof-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .article-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }
  .article-title {
    font-size: clamp(1.65rem, 8vw, 2.2rem);
    line-height: 1.22;
  }
  .article-subtitle {
    font-size: 1.12rem;
  }
  .hero-title {
    font-size: clamp(1.85rem, 9vw, 2.5rem);
  }
  .hero-lead {
    font-size: 1.15rem;
  }
  .homepage-hero {
    padding: 2.5rem 0.5rem 2rem 0.5rem;
  }
  .article-body {
    font-size: 1.05rem;
    line-height: 1.7;
  }
  .article-body h2 {
    font-size: 1.45rem;
  }
  .article-body h3 {
    font-size: 1.2rem;
  }
  .article-body table {
    font-size: 0.82rem;
  }
  .article-body th, .article-body td {
    padding: 0.6rem 0.65rem;
  }
  .article-body pre {
    padding: 1rem;
    font-size: 0.78rem;
  }
  .article-body code {
    overflow-wrap: anywhere;
  }
  .article-pagination {
    flex-direction: column;
  }
  .pagination-link.next {
    text-align: left;
  }
  .cta-actions, .callout-actions, .hero-cta-group {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary, .btn-secondary {
    text-align: center;
  }
  .article-footer-cta, .commercial-callout {
    padding: 1.5rem 1rem;
  }
  .article-footer-cta h3, .commercial-callout h2 {
    font-size: 1.65rem;
  }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}
