/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

body, h1, h2, h3, h4, h5, h6,
p, ul, ol, li, dl, dd,
figure, figcaption, blockquote, pre, hr {
  margin: 0;
  padding: 0;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

/* ── Base (mobile-first) ─────────────────────────────── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background-color: #e0e0e0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #000;
  background: #fff;
  padding: 1rem;
}

/* ── Typography ──────────────────────────────────────── */
h1 { font-size: 1.5rem; margin: 0.6em 0 0.2em; }
h2 { font-size: 1.25rem; margin: 0.6em 0 0.2em; }
h3 { font-size: 1.1rem; margin: 0.5em 0 0.15em; }
h4, h5, h6 { font-size: 1rem; margin: 0.4em 0 0.15em; }

p, ul, ol, dl {
  margin-bottom: 0.6em;
}

li {
  margin-left: 1.25em;
}

blockquote {
  border-left: 3px solid #ccc;
  margin: 0.8em 0;
  padding: 0.1em 0 0.1em 1em;
}

hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 0 0 0.6em 0;
}

/* ── Code ────────────────────────────────────────────── */
pre {
  margin: 0.8em 0;
  padding: 0.8em;
  overflow-x: auto;
  font-size: 0.85rem;
  background: #f5f5f5;
  border: 1px solid #ddd;
  white-space: pre-wrap;
  word-break: break-all;
}

code {
  font-family: "SF Mono", Menlo, Monaco, "Courier New", monospace;
  font-size: 0.85em;
  background: #f5f5f5;
  padding: 0.1em 0.3em;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  border: none;
  word-break: normal;
}

/* ── Tables ──────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 0.9rem;
}

th, td {
  border: 1px solid #ddd;
  padding: 0.4em 0.6em;
  text-align: left;
}

th {
  background: #f5f5f5;
  font-weight: 700;
}

/* ── Mermaid diagrams ────────────────────────────────── */
.mermaid-diagram {
  margin: 1em 0;
  text-align: center;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

.mermaid-diagram svg text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.mermaid-caption {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.3em;
}

.mermaid-error {
  border: 2px solid #c00;
  background: #fff5f5;
  padding: 0.8em;
  font-size: 0.85rem;
  overflow-x: auto;
}

.mermaid-error-msg {
  color: #c00;
  font-size: 0.85rem;
}

/* ── Subtext (nav, meta, etc.) ───────────────────────── */
.subtext {
  color: #333;
  font-size: 0.85rem;
  font-style: italic;
}

a.subtext, .subtext a {
  text-decoration: none;
}

a.unreviewed, a.unreviewed:visited {
  color: #000;
}

nav a.active {
  color: #000;
  font-style: normal;
  font-weight: 600;
}

nav {
  display: block;
  margin: 0 0 0.6em 0;
}

/* ── Post layout (promoted posts) ────────────────────── */
.post {
  display: flex;
  flex-direction: column;
  margin-top: -0.3em;
}

.post-title {
  order: -1;
  margin-top: 0;
}

.post-content > h1:first-child {
  display: none;
}

.post-meta-row {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: #333;
  font-style: italic;
  margin-bottom: 0.6em;
}

.post-meta-row a {
  text-decoration: none;
}

.meta-rule {
  flex: 1;
  border-top: 1px solid #ccc;
  margin: 0 0.5em;
}

.meta-right {
  white-space: nowrap;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid #ddd;
  font-size: 0.85rem;
  color: #666;
}

footer p {
  margin-bottom: 0;
}

/* ── Desktop (≥768px) ────────────────────────────────── */
@media (min-width: 768px) {
  body {
    padding: 2rem;
  }

  h1 { font-size: 1.75rem; margin: 0.8em 0 0.2em; }
  h2 { font-size: 1.35rem; margin: 0.8em 0 0.2em; }
  h3 { font-size: 1.15rem; margin: 0.7em 0 0.15em; }

  pre {
    font-size: 0.9rem;
  }
}

/* ── Wide screen (≥1400px) ───────────────────────────── */
@media (min-width: 1400px) {
  body {
    max-width: 60rem;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 30px rgba(0,0,0,0.06);
  }
}
