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

:root {
  --bg: #ffffff;
  --bg-secondary: #f5f4f4;
  --text-primary: #171717;
  --text-secondary: #6f6f6f;
  --hover-bg: #f5f4f4;
  --border: #e5e5e5;
  --code-bg: #1a1a2e;
  --code-text: #e4e4e7;
  --code-inline-bg: #f0f0f0;
  --code-inline-text: #171717;
  --quote-border: #171717;
  --quote-bg: transparent;
  --demo-bg: #fafafa;
  --demo-border: #e5e5e5;
  --table-border: #e5e5e5;
  --table-header-bg: #f5f4f4;
  --footnote-color: #6f6f6f;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 16px;
}

/* Article container */
.container {
  max-width: 692px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

@media (min-width: 640px) {
  .container {
    padding: 64px 24px 120px;
  }
}

/* Back navigation */
.back-link {
  display: inline-block;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 48px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--text-primary);
}

/* Article header */
.article-header {
  margin-bottom: 48px;
}

.article-header h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

@media (min-width: 640px) {
  .article-header h1 {
    font-size: 32px;
  }
}

.article-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Article content — prose */
.article-content p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}

.article-image-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 24px 0 0;
}

.article-image-grid img {
  display: block;
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 12px;
}

@media (min-width: 640px) {
  .article-image-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .article-image-grid img {
    height: 180px;
  }
}

.article-content a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-content a:hover {
  text-decoration: none;
}

/* Headings */
.article-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.article-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

/* Code blocks */
.code-block {
  position: relative;
  margin: 24px 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}

.code-block-label {
  display: block;
  padding: 10px 16px 0;
  font-size: 12px;
  font-weight: 500;
  color: #71717a;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-block pre {
  padding: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--code-text);
  tab-size: 2;
}

/* Inline code */
.article-content code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
  font-size: 14px;
  background: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Don't double-style code inside code blocks */
.code-block code {
  background: none;
  color: var(--code-text);
  padding: 0;
  border-radius: 0;
}

/* Blockquotes */
.article-content blockquote {
  border-left: 2px solid var(--quote-border);
  padding-left: 20px;
  margin: 32px 0;
}

.article-content blockquote p {
  font-style: italic;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.7;
}

.article-content blockquote cite,
.article-content blockquote .quote-attribution {
  display: block;
  font-style: normal;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* Pull quotes — larger, centered */
.pull-quote {
  border-left: none;
  padding: 0;
  margin: 40px 0;
  text-align: center;
}

.pull-quote p {
  font-style: italic;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-primary);
}

@media (min-width: 640px) {
  .pull-quote p {
    font-size: 20px;
  }
}

.pull-quote .quote-attribution {
  text-align: center;
}

/* Tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}

.article-content th,
.article-content td {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--table-border);
  color: var(--text-secondary);
}

.article-content th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--table-header-bg);
}

.article-content .table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  -webkit-overflow-scrolling: touch;
}

/* Demo placeholders */
.demo-placeholder {
  margin: 32px 0;
  border: 1px dashed var(--demo-border);
  border-radius: 10px;
  padding: 32px 24px;
  background: var(--demo-bg);
  text-align: center;
}

.demo-placeholder .demo-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.demo-placeholder .demo-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Video placeholders */
.video-placeholder {
  margin: 32px 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--demo-bg);
  border: 1px solid var(--demo-border);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.video-placeholder .video-icon {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  opacity: 0.5;
}

.video-placeholder .video-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Footnotes */
.footnotes {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.footnotes ol {
  padding-left: 20px;
}

.footnotes li {
  font-size: 14px;
  color: var(--footnote-color);
  line-height: 1.6;
  margin-bottom: 8px;
}

.footnotes li a {
  color: var(--text-primary);
}

sup a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
}

sup a:hover {
  text-decoration: underline;
}

/* Code block caption */
.code-caption {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: -16px;
  margin-bottom: 24px;
}

/* Lists */
.article-content ul,
.article-content ol {
  padding-left: 24px;
  margin-bottom: 24px;
}

.article-content li {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.article-content li strong {
  color: var(--text-primary);
}

/* Bold text */
.article-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* Emphasis */
.article-content em {
  font-style: italic;
}

/* Horizontal rule / section divider */
.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

/* Article footer navigation */
.article-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.article-nav a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.article-nav a:hover {
  color: var(--text-primary);
}

.article-nav .nav-next {
  margin-left: auto;
}

/* Flowchart / ASCII art blocks */
.flowchart {
  margin: 24px 0;
  background: var(--code-bg);
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
}

.flowchart pre {
  font-family: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--code-text);
  white-space: pre;
}

/* Image styling */
.article-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 24px 0;
}

.article-content .image-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 24px 0;
}

.article-content .image-pair img {
  width: 100%;
  margin: 0;
}

@media (min-width: 640px) {
  .article-content .image-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Definition block */
.definition-block {
  margin: 24px 0;
  padding: 20px 24px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.definition-block .term {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.definition-block .phonetic {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 12px;
}

.definition-block .part-of-speech {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.definition-block .etymology {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 12px;
}

.definition-block ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.definition-block li {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.definition-block .examples {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}
