/* ----- Base ----- */
:root {
  --fg: #1a1a1a;
  --fg-muted: #555;
  --bg: #ffffff;
  --bg-muted: #f5f5f7;
  --border: #e2e2e6;
  --accent: #2e5fdc;
  --accent-fg: #ffffff;
  --code-bg: #f3f4f6;
  --code-fg: #1f2937;
  --quote-bar: #c4c9d4;
  --mark-bg: #fff3a3;
  --mark-fg: #1a1a1a;
  --row-alt: #fafafa;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e8e8ea;
    --fg-muted: #a8a8b2;
    --bg: #101114;
    --bg-muted: #17181c;
    --border: #2a2b31;
    --accent: #8ab0ff;
    --accent-fg: #0b0c0f;
    --code-bg: #1a1b20;
    --code-fg: #e6e6ea;
    --quote-bar: #3a3b44;
    --mark-bg: #a98b00;
    --mark-fg: #0b0c0f;
    --row-alt: #15161a;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: 72ch;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.site-header,
.site-footer {
  max-width: 72ch;
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  letter-spacing: -0.01em;
}

.site-header .tagline {
  margin: 0;
  color: var(--fg-muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* ----- Links ----- */
a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ----- Loading / error ----- */
#content .loading,
#content .error {
  color: var(--fg-muted);
  font-style: italic;
}

#content .error {
  color: #b00020;
  background: #fdecec;
  border: 1px solid #f5c2c2;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-style: normal;
}

@media (prefers-color-scheme: dark) {
  #content .error {
    color: #ff9b9b;
    background: #2a1315;
    border-color: #5a2a2d;
  }
}

/* ----- Rendered markdown ----- */
#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6 {
  line-height: 1.25;
  margin: 1.8em 0 0.6em;
  font-weight: 650;
  letter-spacing: -0.01em;
}

#content h1 {
  font-size: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}

#content h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25em;
}

#content h3 {
  font-size: 1.25rem;
}

#content h4 {
  font-size: 1.05rem;
}

#content h5 {
  font-size: 0.95rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#content h6 {
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#content p {
  margin: 0.9em 0;
}

#content strong {
  font-weight: 700;
}

#content em {
  font-style: italic;
}

#content del {
  text-decoration: line-through;
  color: var(--fg-muted);
}

#content mark {
  background: var(--mark-bg);
  color: var(--mark-fg);
  padding: 0 0.2em;
  border-radius: 2px;
}

#content kbd {
  display: inline-block;
  padding: 0.1em 0.45em;
  margin: 0 0.1em;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--fg);
}

/* Lists */
#content ul,
#content ol {
  padding-left: 1.6em;
  margin: 0.9em 0;
}

#content li + li {
  margin-top: 0.25em;
}

#content li > ul,
#content li > ol {
  margin: 0.35em 0;
}

/* GFM task lists */
#content li.task-list-item,
#content li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.4em;
  padding-left: 0;
}

#content input[type="checkbox"] {
  margin-right: 0.5em;
  transform: translateY(1px);
}

/* Blockquotes */
#content blockquote {
  margin: 1em 0;
  padding: 0.25em 1em;
  border-left: 4px solid var(--quote-bar);
  color: var(--fg-muted);
  background: var(--bg-muted);
  border-radius: 0 4px 4px 0;
}

#content blockquote blockquote {
  margin: 0.5em 0;
  background: transparent;
  border-left-color: var(--border);
}

/* Code */
#content code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

#content pre {
  margin: 1em 0;
  padding: 1rem;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9em;
  line-height: 1.5;
}

#content pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-size: inherit;
}

/* Horizontal rule */
#content hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 2em 0;
}

/* Tables */
#content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
}

#content thead {
  background: var(--bg-muted);
}

#content th,
#content td {
  padding: 0.55em 0.8em;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#content tbody tr:nth-child(even) {
  background: var(--row-alt);
}

#content tbody tr:last-child td {
  border-bottom: 0;
}

/* Images */
#content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1em auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}
