/* ============================================================================
   docex — overdrive edition
   Editorial typography + warm palette + scroll-driven motion
   Font loading moved to <link> in HTML for non-blocking rendering
   ============================================================================ */

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

/* ---------- Design Tokens ---------- */
:root {
  /* Palette — academic: warm cream paper with dark ink */
  --bg:              #faf8f5;
  --bg-warm:         #f5f0ea;
  --bg-card:         #ffffff;
  --bg-code:         #eae5dd;
  --bg-surface:      #ede8e1;
  --border:          #d6cfc5;
  --border-subtle:   #e8e2da;

  --text:            #3d3833;
  --text-dim:        #6b6560;
  --text-muted:      #9a938b;
  --heading:         #1a1714;

  /* Accent: warm terracotta — readable on cream */
  --accent:          #b45309;
  --accent-hover:    #92400e;
  --accent-dim:      rgba(180, 83, 9, 0.08);
  --accent-glow:     rgba(180, 83, 9, 0.04);

  /* Semantic */
  --green:           #2e7d32;
  --red:             #c62828;
  --yellow:          #f9a825;
  --purple:          #7b1fa2;
  --orange:          #e65100;
  --cyan:            #00838f;

  /* Preview (light paper — used in Word previews) */
  --paper:           #ffffff;
  --paper-text:      #1a1a1a;
  --paper-heading:   #0c0a09;
  --paper-dim:       #78716c;
  --paper-border:    #e7e5e4;
  --paper-comment:   #fef3c7;

  /* Spacing */
  --max-width:       1200px;
  --gutter:          clamp(16px, 4vw, 48px);

  /* Type scale (fluid) */
  --text-xs:    clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm:    clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  --text-base:  clamp(0.9375rem, 0.9rem + 0.18vw, 1rem);
  --text-lg:    clamp(1.0625rem, 1rem + 0.3vw, 1.125rem);
  --text-xl:    clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);
  --text-2xl:   clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
  --text-3xl:   clamp(2rem, 1.5rem + 2.5vw, 3rem);
  --text-hero:  clamp(3rem, 2rem + 5vw, 6rem);

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration:    0.5s;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration: 0.01s;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color .2s var(--ease-out); }
a:hover { color: var(--accent-hover); }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  font-size: var(--text-sm);
  z-index: 9999;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: 'Source Serif 4', 'Georgia', serif;
  color: var(--heading);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
h1 { font-size: var(--text-3xl); }
h2 {
  font-size: var(--text-2xl);
  margin-top: 0;
  margin-bottom: 1.5rem;
}
h3 {
  font-size: var(--text-xl);
  margin-top: 0;
  margin-bottom: 0.75rem;
}
h4 { font-size: var(--text-lg); margin-top: 1.5rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; font-size: var(--text-base); }

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--gutter);
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
}
.nav-logo {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--heading);
  margin-right: 24px;
  letter-spacing: -0.03em;
}
.nav-logo span { color: var(--accent); }
.nav-logo-icon {
  vertical-align: -4px;
  margin-right: 6px;
  color: var(--accent);
  flex-shrink: 0;
}
.nav-links { display: flex; gap: 2px; flex-wrap: wrap; }
.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-dim);
  transition: all .2s var(--ease-out);
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--heading);
  background: var(--bg-surface);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
}

@media (max-width: 768px) {
  .nav-toggle { display: block; margin-left: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 16px; font-size: var(--text-sm); }
}

/* ---------- Container ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Section ---------- */
.section {
  padding: clamp(40px, 6vw, 72px) 0;
  border-top: 1px solid var(--border-subtle);
}
.section:first-of-type { border-top: none; }

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duration) var(--ease-out),
              transform var(--duration) var(--ease-out);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.35s; }
.reveal-delay-5 { transition-delay: 0.4s; }
.reveal-delay-6 { transition-delay: 0.45s; }

/* ============================================================================
   HERO
   ============================================================================ */
.hero {
  padding: clamp(60px, 10vw, 120px) 0 clamp(40px, 6vw, 80px);
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 800px;
  height: 600px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(180, 83, 9, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}
.hero-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
}
.hero-title {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: var(--text-hero);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 1rem;
  color: var(--heading);
}
.hero-title span {
  color: var(--accent);
}
.hero-desc {
  font-size: var(--text-lg);
  max-width: 600px;
  color: var(--text-dim);
  margin-bottom: 2rem;
  line-height: 1.6;
}
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  font-size: var(--text-sm);
  border: none;
  cursor: pointer;
  transition: all .2s var(--ease-out);
  text-decoration: none;
  font-family: inherit;
  line-height: 1;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(180, 83, 9, 0.2);
}
.btn-secondary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); color: #fff; }
.btn-accent:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { padding: 6px 14px; font-size: var(--text-xs); }

/* ============================================================================
   CODE + OUTPUT PANELS — the signature pattern
   ============================================================================ */
.code-output {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 1.5rem 0;
  background: var(--bg-code);
  transition: border-color .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.code-output:hover {
  border-color: rgba(180, 83, 9, 0.3);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Slide-in reveal for code-output panels */
.code-output.reveal {
  opacity: 0;
  transform: translateY(20px);
}
.code-output.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (max-width: 768px) {
  .code-output { grid-template-columns: 1fr; }
}

.code-output-code {
  padding: 20px 24px;
  overflow-x: auto;
  position: relative;
  border-right: 1px solid var(--border);
}
@media (max-width: 768px) {
  .code-output-code { border-right: none; border-bottom: 1px solid var(--border); }
}

.code-output-code pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  border-radius: 0;
}
.code-output-code code {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--text);
  background: none;
  padding: 0;
}
.code-output-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.code-output-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.code-output-result {
  background: var(--paper);
  padding: 24px 28px;
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--paper-text);
  position: relative;
}
.code-output-result .result-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--paper-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.code-output-result .result-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

/* ============================================================================
   WORD-LIKE DOCUMENT PREVIEW
   ============================================================================ */

/* Page container — looks like a Word document page */
.word-page {
  background: #f0f0f0;
  padding: 16px;
}
.word-page .result-label {
  margin-bottom: 8px;
}

/* The document body — white page with shadow */
.word-body {
  background: #fff;
  border: 1px solid #d4d4d4;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 28px 32px;
  font-family: 'Calibri', 'Carlito', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #1a1a1a;
  position: relative;
  min-height: 80px;
}
.word-body p {
  margin: 0 0 8px;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  text-indent: 0;
}
.word-body-centered {
  text-align: left;
}

/* Layout with comment margin */
.word-body-with-margin {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 0;
  padding: 0;
}
@media (max-width: 600px) {
  .word-body-with-margin { grid-template-columns: 1fr; }
}
.word-text-col {
  padding: 28px 24px;
  position: relative;
}
.word-margin-col {
  border-left: 1px solid #e5e5e5;
  padding: 20px 12px;
  background: #fafafa;
  font-size: 12px;
}

/* Revision bar — the red line in the left margin */
.word-revision-bar {
  position: absolute;
  left: 4px;
  top: 24px;
  bottom: 24px;
  width: 3px;
  background: #c0392b;
  border-radius: 2px;
}

/* Tracked changes — Word style */
.word-del {
  color: #c0392b;
  text-decoration: line-through;
}
.word-ins {
  color: #c0392b;
  text-decoration: underline;
}

/* Inserted paragraph — green left bar like Word */
.word-inserted-para {
  border-left: 3px solid #27ae60;
  padding-left: 12px;
  color: #27ae60;
}

/* Comment anchor highlight */
.word-comment-anchor {
  background: #fff2cc;
  border-bottom: 1px solid #e6c200;
  padding: 0 1px;
}

/* Comment balloon — Word-style margin comment */
.word-comment-balloon {
  background: #fff;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  padding: 10px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.word-comment-connector {
  position: absolute;
  left: -13px;
  top: 14px;
  width: 12px;
  height: 1px;
  background: #d4d4d4;
}
.word-comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.word-comment-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4472c4;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Calibri', 'Segoe UI', sans-serif;
}
.word-comment-author {
  font-size: 11px;
  font-weight: 600;
  color: #4472c4;
  display: block;
  font-family: 'Calibri', 'Segoe UI', sans-serif;
}
.word-comment-time {
  font-size: 10px;
  color: #999;
  display: block;
  font-family: 'Calibri', 'Segoe UI', sans-serif;
}
.word-comment-text {
  font-size: 12px;
  color: #333;
  line-height: 1.5;
  font-family: 'Calibri', 'Segoe UI', sans-serif;
}

/* Hover-reveal comment popup — highlight in text, balloon on hover */
.word-comment-hover-wrap {
  position: relative;
  display: inline;
  cursor: pointer;
}
.word-comment-popup {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  max-width: 260px;
  background: #fff;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: commentFadeIn 0.2s ease;
}
.word-comment-hover-wrap:hover .word-comment-popup,
.word-comment-hover-wrap:focus-within .word-comment-popup {
  display: block;
}
@keyframes commentFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Hide the connector in popup mode */
.word-comment-popup .word-comment-connector { display: none; }

/* Word status bar */
/* Word figure placeholder */
.word-figure-placeholder {
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  padding: 24px;
  text-align: center;
  margin: 8px 0;
}
.word-figure-icon { margin-bottom: 8px; opacity: 0.5; }
.word-figure-label {
  font-size: 11px;
  color: #999;
  font-family: 'Calibri', sans-serif;
}
.word-caption {
  font-size: 12px;
  color: #444;
  text-align: center;
  margin: 4px 0 0;
  font-family: 'Calibri', sans-serif;
}

/* Word booktabs table */
.word-table-booktabs {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Calibri', 'Carlito', sans-serif;
  font-size: 13px;
  margin: 8px 0;
}
.word-table-booktabs thead tr {
  border-top: 2px solid #1a1a1a;
  border-bottom: 1px solid #1a1a1a;
}
.word-table-booktabs th {
  padding: 6px 12px;
  font-weight: 600;
  text-align: left;
  background: none;
  color: #1a1a1a;
  border: none;
  border-bottom: 1px solid #1a1a1a;
}
.word-table-booktabs td {
  padding: 5px 12px;
  border: none;
  border-bottom: none;
  color: #333;
}
.word-table-booktabs tbody tr:last-child {
  border-bottom: 2px solid #1a1a1a;
}
.word-table-booktabs tbody tr:hover td {
  background: rgba(0,0,0,0.02);
}

/* Word footnote */
.word-footnote-ref {
  color: #4472c4;
  font-size: 10px;
  font-weight: 600;
  cursor: default;
}
.word-footnote-area {
  margin-top: 20px;
  padding-top: 0;
}
.word-footnote-rule {
  border: none;
  border-top: 1px solid #999;
  width: 33%;
  margin: 0 0 6px;
}
.word-footnote-text {
  font-size: 10px;
  color: #555;
  line-height: 1.4;
  margin: 0;
  font-family: 'Calibri', sans-serif;
}
.word-footnote-text sup {
  color: #4472c4;
  font-weight: 600;
  margin-right: 4px;
}

.word-status-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  background: #f0f0f0;
  font-size: 10px;
  color: #888;
  font-family: 'Segoe UI', 'Calibri', sans-serif;
  margin-top: 4px;
}

/* Word typography helpers */
.word-heading-1 {
  font-family: 'Calibri', 'Carlito', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 6px;
  line-height: 1.3;
  border: none;
  padding: 0;
}
.word-heading-3 {
  font-family: 'Calibri', 'Carlito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 8px 0 4px;
  line-height: 1.3;
}
.word-draft-text {
  font-style: italic;
  color: #999;
  font-size: 12px;
  margin: 0 0 8px;
}
.word-pagebreak {
  border: none;
  border-top: 1px dashed #ccc;
  margin: 10px 0;
}

/* Green avatar variant */
.word-comment-avatar-green { background: #548235; }
.word-comment-author-green { color: #548235; }

/* Legacy aliases (keep for playground/other pages) */
.output-tracked-del { color: #c0392b; text-decoration: line-through; }
.output-tracked-ins { color: #c0392b; text-decoration: underline; }
.output-comment {
  display: block;
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid #d97706;
  background: var(--paper-comment);
  font-size: var(--text-xs);
  color: #92400e;
  font-style: italic;
  border-radius: 0 6px 6px 0;
}
.output-comment strong {
  font-style: normal;
  color: #78350f;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Standalone code blocks */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1rem 0;
  line-height: 1.6;
  position: relative;
}
pre code {
  background: none;
  padding: 0;
  font-size: var(--text-xs);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

/* ============================================================================
   HERO DEMO — mini interactive .dex preview
   ============================================================================ */
.hero-demo {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-code);
}
.hero-demo-bar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.hero-demo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}
.hero-demo-dot:nth-child(1) { background: #f87171; }
.hero-demo-dot:nth-child(2) { background: #facc15; }
.hero-demo-dot:nth-child(3) { background: #4ade80; }
.hero-demo-title {
  margin-left: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.hero-demo-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 320px;
}
@media (max-width: 768px) {
  .hero-demo-panes { grid-template-columns: 1fr; }
}
.hero-demo-editor {
  padding: 20px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
  border-right: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}
@media (max-width: 768px) {
  .hero-demo-editor { border-right: none; border-bottom: 1px solid var(--border); min-height: 200px; }
}
.hero-demo-preview {
  background: #fff;
  padding: 24px 28px;
  font-family: 'Calibri', 'Carlito', 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #1a1a1a;
  overflow: hidden;
  border-left: 1px solid #e5e5e5;
}
@media (max-width: 768px) {
  .hero-demo-preview { border-left: none; border-top: 1px solid #e5e5e5; }
}
/* Hero Word preview — text + margin layout */
.hero-word-preview {
  font-family: 'Calibri', 'Carlito', 'Segoe UI', sans-serif;
  font-size: 12px;
  line-height: 1.5;
  color: #1a1a1a;
}
.hero-word-preview h1 {
  font-family: 'Calibri', 'Carlito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 8px;
  line-height: 1.3;
  border: none;
  padding: 0;
}
.hero-word-preview h2 {
  font-family: 'Calibri', 'Carlito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 10px 0 4px;
  line-height: 1.3;
}
.hero-word-preview p {
  font-family: inherit;
  color: #1a1a1a;
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 6px;
  text-align: left;
  text-indent: 0;
}
.hero-word-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 0;
}
@media (max-width: 900px) {
  .hero-word-row { grid-template-columns: 1fr; }
  .hero-word-margin { display: none; }
}
.hero-word-text {
  position: relative;
  padding-right: 8px;
}
.hero-word-text .word-revision-bar {
  left: -8px;
  top: 0;
  bottom: 0;
}
.hero-word-margin {
  border-left: 1px solid #e5e5e5;
  padding-left: 8px;
  font-size: 10px;
}
.hero-word-margin .word-comment-balloon {
  padding: 6px 8px;
  font-size: 10px;
}
.hero-word-margin .word-comment-avatar {
  width: 16px;
  height: 16px;
  font-size: 6px;
}
.hero-word-margin .word-comment-author { font-size: 10px; }
.hero-word-margin .word-comment-text { font-size: 10px; }
.hero-word-margin .word-comment-connector { display: none; }

/* Syntax highlighting (editor side) */
.sh-heading   { color: var(--accent); font-weight: 700; }
.sh-comment   { background: rgba(180, 83, 9, 0.08); color: #92400e; border-radius: 2px; padding: 0 2px; }
.sh-del       { color: var(--red); }
.sh-ins       { color: var(--green); }
.sh-tag       { color: var(--purple); }
.sh-id        { color: var(--text-muted); }
.sh-pagebreak { color: var(--orange); font-weight: 600; }
.sh-front     { color: var(--text-muted); }
.sh-font      { color: var(--text-muted); font-style: italic; }

/* ============================================================================
   FEATURES — asymmetric layout, not card grid
   ============================================================================ */
.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  margin: 2rem 0;
}
@media (max-width: 900px) {
  .features-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .features-grid { grid-template-columns: 1fr; }
}
.feature-cell {
  background: var(--bg-warm);
  padding: clamp(24px, 3vw, 40px);
  transition: background .3s var(--ease-out);
}
.feature-cell:hover {
  background: var(--bg-surface);
}
.feature-cell h3 {
  font-family: 'Source Serif 4', serif;
  font-size: var(--text-lg);
  margin-bottom: 0.5rem;
}
.feature-cell p {
  color: var(--text-dim);
  font-size: var(--text-sm);
  line-height: 1.6;
  margin: 0;
}
.feature-cell .feature-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  display: block;
}

/* ============================================================================
   WORKFLOW DIAGRAM
   ============================================================================ */
.workflow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: clamp(24px, 4vw, 48px) 0;
  flex-wrap: wrap;
}
.workflow-node {
  text-align: center;
  padding: 20px 32px;
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 140px;
  transition: all .3s var(--ease-out);
}
.workflow-node:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.workflow-node-ext {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--heading);
  display: block;
}
.workflow-node-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}
.workflow-arrow {
  font-size: 1.5rem;
  color: var(--accent);
  padding: 0 12px;
  font-weight: 700;
  animation: arrowPulse 2s ease-in-out infinite;
}
@keyframes arrowPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============================================================================
   DEX FORMAT PREVIEW — full width showcase
   ============================================================================ */
.dex-showcase {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 2rem 0;
  min-height: 360px;
}
@media (max-width: 768px) {
  .dex-showcase { grid-template-columns: 1fr; }
}
.dex-showcase-code {
  background: var(--bg-code);
  padding: 24px;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
}
.dex-showcase-render {
  background: #f0f0f0;
  padding: 16px;
  overflow: auto;
}
.dex-showcase-render .result-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dex-showcase-render .result-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}
.dex-showcase-render .word-body { font-size: 13px; }
.dex-showcase-render .word-text-col { padding: 20px 18px; }
.dex-showcase-render .word-margin-col { padding: 16px 10px; }

/* ============================================================================
   CARDS (for "Everything you need")
   ============================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  transition: border-color .2s var(--ease-out), transform .2s var(--ease-out);
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 1.5rem 0;
}
.card h3 { margin-top: 0; }

/* ============================================================================
   TABLES
   ============================================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: var(--text-sm);
}
th {
  text-align: left;
  padding: 10px 16px;
  background: var(--bg-code);
  color: var(--heading);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
tr:hover td { background: rgba(180, 83, 9, 0.04); }

/* ============================================================================
   TABS
   ============================================================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 500;
  font-size: var(--text-sm);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--heading); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================================
   SYNTAX HIGHLIGHTING in dex code blocks
   ============================================================================ */
.dex-heading   { color: var(--accent); font-weight: 700; }
.dex-comment   { background: rgba(250, 204, 21, 0.1); color: var(--yellow); }
.dex-del       { color: var(--red); text-decoration: line-through; }
.dex-ins       { color: var(--green); }
.dex-tag       { color: var(--purple); }
.dex-id        { color: var(--text-muted); }
.dex-pagebreak { color: var(--orange); font-weight: 600; }
.dex-frontmatter { color: var(--text-muted); }
.dex-font      { color: var(--text-muted); font-style: italic; }

/* ============================================================================
   PLAYGROUND
   ============================================================================ */
.playground-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  flex-wrap: wrap;
}
.playground-header h2 { margin: 0; flex-shrink: 0; }

/* Preset selector */
.preset-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preset-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.preset-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: border-color .15s;
}
.preset-select:hover { border-color: var(--accent); }
.preset-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-select option { background: var(--bg-warm); color: var(--text); }

/* Button actions row */
.playground-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.playground-actions-right {
  margin-left: auto;
}
.playground-actions .btn-small {
  padding: 7px 14px;
  font-size: var(--text-xs);
  border-radius: 6px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  opacity: 0.7;
}
.btn-ghost:hover {
  opacity: 1;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-viewer {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-viewer:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-group-viewer {
  display: inline-flex;
  gap: 8px;
  align-items: flex-start;
}

/* Button spinner for upload state */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
  vertical-align: -1px;
}
@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 32px;
  text-align: center;
  margin-bottom: 20px;
  cursor: pointer;
  transition: all .3s var(--ease-out);
  color: var(--text-dim);
  background: var(--bg-warm);
  position: relative;
}
.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: radial-gradient(ellipse at center, var(--accent-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity .3s var(--ease-out);
  pointer-events: none;
}
.drop-zone:hover::before,
.drop-zone.drag-over::before {
  opacity: 1;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(180, 83, 9, 0.08);
}
.drop-zone-icon {
  margin-bottom: 10px;
  display: block;
  color: var(--text-muted);
  transition: color .3s var(--ease-out), transform .3s var(--ease-out);
}
.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
  color: var(--accent);
  transform: translateY(-2px);
}
.drop-zone p { margin-bottom: 4px; }
.drop-zone-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}
.drop-zone input[type="file"] { display: none; }

/* Drop zone file landing effect */
@keyframes dropLand {
  0% { transform: scale(1); }
  30% { transform: scale(0.97); }
  100% { transform: scale(1); opacity: 0; }
}
.drop-zone.file-landed {
  animation: dropLand 0.4s var(--ease-out) forwards;
}

/* Editor panes */
.editor-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 280px);
  min-height: 500px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  /* Smooth entry on first load */
  animation: panesEntry 0.8s var(--ease-out) 0.2s both;
}
@keyframes panesEntry {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 768px) {
  .editor-panes { grid-template-columns: 1fr; height: auto; }
}
.editor-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-card);
}
.editor-pane:first-child { background: var(--bg-code); }
.editor-pane + .editor-pane { border-left: 1px solid var(--border); }
@media (max-width: 768px) {
  .editor-pane + .editor-pane { border-left: none; border-top: 1px solid var(--border); }
}
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.pane-header-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: 1px;
}
.pane-header-dot.dot-green { background: var(--green); }
.pane-header-meta {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.pane-body { flex: 1; overflow: auto; position: relative; }

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-height: 32px;
  margin-bottom: 24px;
}
.status-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.status-bar-right {
  flex-shrink: 0;
  font-size: 10px;
}

/* Compile spinner */
.compile-spinner {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  flex-shrink: 0;
}
.compile-spinner.active {
  display: inline-block;
  animation: btnSpin 0.6s linear infinite;
}

/* Typing-dots indicator when compiler is working */
.compile-indicator {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
.compile-indicator span {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.3;
}
@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
.compile-indicator.active span:nth-child(1) { animation: typingDot 1.4s infinite 0s; }
.compile-indicator.active span:nth-child(2) { animation: typingDot 1.4s infinite 0.2s; }
.compile-indicator.active span:nth-child(3) { animation: typingDot 1.4s infinite 0.4s; }

/* Editor textarea */
.dex-editor {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  line-height: 1.65;
  resize: none;
  outline: none;
  tab-size: 4;
  transition: box-shadow 0.3s var(--ease-out);
}
/* Warm inner glow when editor is focused */
.dex-editor:focus {
  box-shadow: inset 0 0 60px rgba(180, 83, 9, 0.03);
}

.editor-container {
  position: relative;
  width: 100%;
  height: 100%;
}
.editor-highlight {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  pointer-events: none;
  color: transparent;
  border: none;
  margin: 0;
  /* CRITICAL: match textarea rendering exactly */
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  letter-spacing: normal;
  word-spacing: normal;
}

/* Make textarea text invisible — the overlay provides the colored version */
.editor-container .dex-editor {
  color: transparent;
  caret-color: var(--text);
  /* Prevent browser from adding its own text rendering adjustments */
  -webkit-text-fill-color: transparent;
}

/* Preview pane */
.preview-content {
  padding: 40px 48px;
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--paper-text);
  background: var(--paper);
  min-height: 100%;
}
.preview-content h1 { font-size: 1.75rem; color: var(--paper-heading); margin: 1.5rem 0 0.75rem; }
.preview-content h2 { font-size: 1.375rem; color: var(--paper-heading); margin: 1.25rem 0 0.625rem; }
.preview-content h3 { font-size: 1.125rem; color: var(--paper-heading); margin: 1rem 0 0.5rem; }
.preview-content p { margin-bottom: 0.875rem; text-align: justify; text-indent: 1.5em; }
.preview-content p:first-child { text-indent: 0; }
.preview-content del { color: #b91c1c; text-decoration: line-through; background: rgba(185,28,28,0.08); }
.preview-content ins { color: #15803d; text-decoration: none; background: rgba(21,128,61,0.08); }
.preview-content .preview-comment {
  display: block;
  margin: 8px 0 8px 24px;
  padding: 8px 12px;
  border-left: 3px solid #d97706;
  background: var(--paper-comment);
  font-size: var(--text-sm);
  color: #92400e;
  font-style: italic;
}
.preview-content .preview-comment strong { color: #78350f; font-style: normal; }
.preview-content hr.pagebreak {
  border: none;
  border-top: 2px dashed #d6d3d1;
  margin: 2rem 0;
}
.preview-content table {
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: var(--text-sm);
  color: var(--paper-text);
}
.preview-content th {
  background: #faf5ef;
  color: var(--paper-heading);
  font-weight: 600;
  border-bottom: 2px solid #44403c;
  padding: 8px 12px;
}
.preview-content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--paper-border);
}

/* ============================================================================
   API / CLI reference
   ============================================================================ */
.api-group { margin-bottom: 3rem; }
.api-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.api-entry-header {
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--heading);
  background: var(--bg-code);
  border-bottom: 1px solid var(--border);
}
.api-entry-body { padding: 16px; }
.api-entry-body p { margin-bottom: 0.5rem; font-size: var(--text-sm); }

/* ---------- Copy button ---------- */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Tags ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag-green  { background: rgba(46,125,50,0.1); color: var(--green); }
.tag-yellow { background: rgba(250,204,21,0.12); color: var(--yellow); }
.tag-red    { background: rgba(248,113,113,0.12); color: var(--red); }
.tag-blue   { background: rgba(0,131,143,0.1); color: var(--cyan); }

/* ============================================================================
   FOOTER
   ============================================================================ */
.footer {
  padding: 48px var(--gutter);
  border-top: 1px solid var(--border-subtle);
  margin-top: 0;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-brand {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--heading);
}
.footer-brand span { color: var(--accent); }
.footer-links {
  display: flex;
  gap: 24px;
  font-size: var(--text-sm);
}
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--accent); }
.footer-copy {
  width: 100%;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================================================
   SPEC, VISION
   ============================================================================ */
.spec-entry {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}
.spec-entry:last-child { border-bottom: none; }
.spec-entry h3 { margin-top: 0; }

.vision-step {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.vision-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.vision-step-content { flex: 1; }

/* ---------- Tooltip ---------- */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  transition: opacity .15s, transform .15s var(--ease-out);
}
.tooltip-wrap:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
  .hero-title { font-size: clamp(2.5rem, 8vw, 3.5rem); }
  .hero-desc { font-size: var(--text-base); }
  .stats { gap: 20px; }
  .stat-number { font-size: 1.25rem; }
  .workflow-diagram { flex-direction: column; gap: 8px; }
  .workflow-arrow { transform: rotate(90deg); padding: 4px 0; }
  .footer-inner { flex-direction: column; text-align: center; }
  .footer-links { justify-content: center; }
}

/* ============================================================================
   DOCX PREVIEW PANE (playground) — Living Document
   ============================================================================ */
#docxPreviewPane {
  padding: 12px !important;
  background: var(--paper) !important;
  overflow: auto !important;
  /* Paper texture: subtle grain + warm gradient */
  background-image:
    url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E"),
    linear-gradient(to bottom, var(--paper), color-mix(in oklch, var(--paper), #f5ebe0 5%)) !important;
  /* Realistic floating paper shadow */
  box-shadow:
    0 1px 3px rgba(0,0,0,0.06),
    0 4px 12px rgba(0,0,0,0.08),
    0 12px 36px rgba(0,0,0,0.12);
  transition: box-shadow 0.6s var(--ease-out);
}
#docxPreviewPane .docx-wrapper {
  background: transparent !important;
  padding: 0 !important;
}
#docxPreviewPane .docx-wrapper > section.docx {
  margin: 0 auto 12px auto !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12) !important;
  max-width: 100% !important;
  width: auto !important;
  padding: 40px 48px !important;
}

/* --- Amber glow pulse when edits land --- */
@keyframes editPulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3),
                    0 1px 3px rgba(0,0,0,0.06),
                    0 4px 12px rgba(0,0,0,0.08),
                    0 12px 36px rgba(0,0,0,0.12); }
  50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15),
                     0 1px 3px rgba(0,0,0,0.06),
                     0 4px 12px rgba(0,0,0,0.08),
                     0 12px 36px rgba(0,0,0,0.12); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0),
                      0 1px 3px rgba(0,0,0,0.06),
                      0 4px 12px rgba(0,0,0,0.08),
                      0 12px 36px rgba(0,0,0,0.12); }
}
.preview-pulse {
  animation: editPulse 0.6s var(--ease-out);
}

/* --- Spring-physics comment slide-in --- */
#docxPreviewPane .docx-wrapper [class*="comment"],
#docxPreviewPane .docx-wrapper aside {
  animation: commentSlideIn 0.5s var(--ease-spring) both;
  transform-origin: right center;
}
@keyframes commentSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* Stagger multiple comments */
#docxPreviewPane .docx-wrapper [class*="comment"]:nth-child(2) { animation-delay: 0.05s; }
#docxPreviewPane .docx-wrapper [class*="comment"]:nth-child(3) { animation-delay: 0.1s; }
#docxPreviewPane .docx-wrapper [class*="comment"]:nth-child(4) { animation-delay: 0.15s; }

/* ============================================================================
   ROUND 2: INSTALL SECTION
   ============================================================================ */
.install-block {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(32px, 4vw, 48px);
  text-align: center;
  margin: 2rem 0;
}
.install-block .install-cmd {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 24px;
  display: inline-block;
  margin: 1rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s var(--ease-out);
  position: relative;
}
.install-block .install-cmd:hover { border-color: var(--accent); }
.install-block .install-cmd.copied { border-color: var(--green); }
.install-block .install-cmd.copied code { color: var(--green); }
.install-block .install-cmd code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}
.install-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ============================================================================
   ROUND 2: RESULT PANEL UTILITY CLASSES (replacing inline styles)
   ============================================================================ */
.result-body {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 14px;
  line-height: 1.8;
}
.result-body p {
  margin: 0 0 8px;
  text-indent: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}
.result-body-sm {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 13px;
  line-height: 1.75;
}
.result-body-sm p {
  margin: 0 0 8px;
  text-indent: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}
.output-highlight {
  background: var(--paper-comment);
  border-bottom: 2px solid #d97706;
  padding: 1px 2px;
}
.output-inserted {
  border-left: 3px solid var(--green);
  padding-left: 12px;
  color: #15803d;
  font-size: 12px;
}

/* Journal-formatted title preview */
.output-journal-header {
  text-align: center;
  margin-bottom: 16px;
}
.output-journal-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--paper-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.output-journal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--paper-heading);
}
.output-journal-author {
  font-size: 12px;
  color: var(--paper-dim);
  margin-top: 4px;
}
.output-journal-body {
  border-top: 1px solid var(--paper-border);
  padding-top: 12px;
  text-align: justify;
  text-indent: 1.5em;
}

/* Agent capabilities list */
.capability-list {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.8;
  list-style: none;
  padding: 0;
  margin: 0;
}
.capability-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.capability-list li::before {
  content: '\2713';
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
}

/* ============================================================================
   ROUND 2: INTERACTION ANIMATIONS
   ============================================================================ */
.hero-demo {
  transition: box-shadow .4s var(--ease-out);
}
.hero-demo:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.dex-showcase {
  transition: box-shadow .4s var(--ease-out), border-color .3s var(--ease-out);
}
.dex-showcase:hover {
  border-color: rgba(180, 83, 9, 0.3);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Stagger reveal for feature cells */
.features-grid .feature-cell {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out), background .3s var(--ease-out);
}
.features-grid.visible .feature-cell { opacity: 1; transform: translateY(0); }
.features-grid.visible .feature-cell:nth-child(1) { transition-delay: 0.05s; }
.features-grid.visible .feature-cell:nth-child(2) { transition-delay: 0.1s; }
.features-grid.visible .feature-cell:nth-child(3) { transition-delay: 0.15s; }
.features-grid.visible .feature-cell:nth-child(4) { transition-delay: 0.2s; }
.features-grid.visible .feature-cell:nth-child(5) { transition-delay: 0.25s; }
.features-grid.visible .feature-cell:nth-child(6) { transition-delay: 0.3s; }

/* Copy button success state */
.copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
}

/* ---------- Upload confirmation modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card, #1c2128); border-radius: 12px;
  max-width: 440px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 12px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
  background: none; border: none; color: var(--text-dim); font-size: 1.5rem;
  cursor: pointer; padding: 0; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-body p { margin: 0 0 12px; color: var(--text-dim); }
.modal-details {
  margin: 0; padding: 0 0 0 20px; color: var(--text-dim);
  font-size: 0.875rem; line-height: 1.6;
}
.modal-details li { margin-bottom: 4px; }
.modal-details strong { color: var(--text); }
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 24px 20px;
}
.modal-icon {
  text-align: center; margin-bottom: 16px;
}
.modal-icon svg { width: 48px; height: 48px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* "Open in..." dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100;
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; background: none; border: none; color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: var(--text-sm);
  text-align: left;
}
.dropdown-item:hover { background: var(--bg-surface); }
.dropdown-item svg { flex-shrink: 0; }
.dropdown-hint {
  margin-left: auto; font-size: var(--text-xs); color: var(--text-muted);
}

/* ============================================================================
   MOBILE RESPONSIVE — playground (Fix 1)
   ============================================================================ */
@media (max-width: 768px) {
  .editor-panes {
    flex-direction: column;
  }
  .editor-pane {
    width: 100% !important;
    min-height: 300px;
  }
  .playground-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .btn-group-viewer {
    flex-direction: column;
    width: 100%;
  }
  .viewer-btn-wrapper {
    width: 100%;
  }
  .viewer-btn-wrapper .btn {
    width: 100%;
  }
  .drop-zone {
    padding: 24px 16px;
  }
  /* Touch targets >= 44x44px on mobile */
  .playground-actions .btn-small {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
  }
  .dropdown-item {
    min-height: 44px;
  }
  .modal-close {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============================================================================
   DELIGHT + POLISH
   ============================================================================ */

/* --- Toast notification --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 20px;
  color: var(--text);
  font-size: var(--text-sm);
  font-family: 'Inter', sans-serif;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 200;
  transition: transform 0.4s var(--ease-out), opacity 0.4s;
  opacity: 0;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* --- Green dot pulse (preview active) --- */
.dot-green {
  animation: dotPulse 2s infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Button hover polish --- */
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}

/* --- Copy button green flash --- */
.btn-copied {
  color: var(--green) !important;
  border-color: var(--green) !important;
  transition: color 0.15s, border-color 0.15s;
}

/* --- Download bounce animation --- */
@keyframes downloadBounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(3px); }
  50%  { transform: translateY(-1px); }
  70%  { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
.download-bounce svg {
  animation: downloadBounce 0.5s var(--ease-out);
}

/* --- Textarea selection color --- */
.dex-editor::selection {
  background: rgba(180, 83, 9, 0.3);
}
.dex-editor::-moz-selection {
  background: rgba(180, 83, 9, 0.3);
}

/* --- Scrollbar styling --- */
.dex-editor::-webkit-scrollbar,
#docxPreviewPane::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.dex-editor::-webkit-scrollbar-track,
#docxPreviewPane::-webkit-scrollbar-track {
  background: var(--bg-code);
}
.dex-editor::-webkit-scrollbar-thumb,
#docxPreviewPane::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.dex-editor::-webkit-scrollbar-thumb:hover,
#docxPreviewPane::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Drop zone hover refinement --- */
.drop-zone.drag-over {
  transform: scale(1.01);
}

/* --- Modal backdrop blur --- */
.modal-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* --- Status bar polish --- */
.status-bar {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-warm);
}

/* --- Nav active state --- */
.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
}

/* --- Empty state for preview pane --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--text-muted);
  text-align: center;
  padding: 48px 32px;
}
.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.35;
}
.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.6;
  text-indent: 0;
  text-align: center;
}

/* --- Line count polish --- */
.pane-header-meta {
  font-variant-numeric: tabular-nums;
}
