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

/* === Light Theme (default) === */
:root {
  --bg: #fff;
  --text: #1a1a1a;
  --text-secondary: #555;
  --border: #ddd;
  --code-bg: #f4f4f4;
  --code-text: #1a1a1a;
  --link: #1a5f9a;
  --link-hover: #0d3d66;
  --table-stripe: #f8f8f8;
  --hr: #ccc;
  --blockquote-border: #ccc;
  --blockquote-text: #555;
}

/* === Dark Theme === */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111;
    --text: #e0e0e0;
    --text-secondary: #999;
    --border: #333;
    --code-bg: #1a1a1a;
    --code-text: #e0e0e0;
    --link: #6db3f2;
    --link-hover: #a0d0ff;
    --table-stripe: #1a1a1a;
    --hr: #333;
    --blockquote-border: #444;
    --blockquote-text: #999;
  }
}

/* === Typography === */
html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Courier New', monospace;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* === Headings === */
h1, h2, h3, h4 {
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  margin-top: 2.5rem;
}

h3 {
  font-size: 1.1rem;
}

/* === Links === */
a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* === Paragraphs & Inline === */
p {
  margin-bottom: 1.25rem;
}

strong {
  font-weight: 700;
}

em {
  font-style: italic;
}

/* === Horizontal Rules === */
hr {
  border: none;
  border-top: 1px solid var(--hr);
  margin: 2.5rem 0;
}

/* === Lists === */
ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

li > ul, li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

/* === Code === */
code {
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1rem 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  line-height: 1.5;
  font-size: 0.85rem;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

thead {
  border-bottom: 2px solid var(--border);
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 700;
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

/* === Blockquotes === */
blockquote {
  border-left: 3px solid var(--blockquote-border);
  padding-left: 1rem;
  color: var(--blockquote-text);
  margin-bottom: 1.25rem;
  font-style: italic;
}

/* === Header / Site Title === */
.site-header {
  margin-bottom: 3rem;
}

.site-header h1 {
  margin-top: 0;
  margin-bottom: 0.25rem;
}

.site-header .tagline {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* === Navigation === */
nav {
  margin-bottom: 2rem;
}

nav a {
  margin-right: 1rem;
  font-size: 0.85rem;
}

/* === Article List (Homepage) === */
.article-list {
  list-style: none;
  padding-left: 0;
}

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

.article-list li:last-child {
  border-bottom: none;
}

.article-list a {
  text-decoration: none;
}

.article-list .title {
  font-size: 1.1rem;
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
}

.article-list .subtitle {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.85rem;
  display: block;
  margin-bottom: 0.25rem;
}

.article-list .date {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* === Article Page === */
.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.article-header .subtitle {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.article-header .date {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

article section {
  margin-top: 0;
}

/* === Back Link === */
.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.85rem;
}

/* === Footer === */
footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

footer p {
  margin-bottom: 0.5rem;
}

footer a {
  color: var(--link);
}

/* === Cross-Post CTA === */
.cross-post {
  margin-top: 2.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: center;
}

.cross-post p {
  margin-bottom: 0.5rem;
}

.cross-post p:last-child {
  margin-bottom: 0;
}

/* === Author Bio === */
.bio {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.85rem;
  margin-top: 2rem;
}

/* === Responsive === */
@media (max-width: 480px) {
  html {
    font-size: 16px;
  }

  body {
    padding: 1.5rem 1rem 3rem;
  }

  h1 {
    font-size: 1.4rem;
  }

  table {
    font-size: 0.78rem;
  }

  th, td {
    padding: 0.4rem 0.5rem;
  }
}
