:root {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --text: #1f2328;
  --text-secondary: #656d76;
  --border: #d0d7de;
  --link: #0969da;
  --code-bg: #f6f8fa;
  --header-bg: #f6f8fa;
  --header-border: #d0d7de;
  --table-stripe: #f6f8fa;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --border: #30363d;
  --link: #58a6ff;
  --code-bg: #161b22;
  --header-bg: #161b22;
  --header-border: #30363d;
  --table-stripe: #161b22;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* Header */
header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0.75rem 1.5rem;
}

.header-inner {
  max-width: 52rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.wordmark {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}

nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  flex: 1;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
}

nav a:hover,
nav a.active {
  color: var(--link);
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
}

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* Main content */
main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Typography */
h1 { font-size: 2rem; margin: 0 0 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h2 { font-size: 1.5rem; margin: 2rem 0 0.75rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
h3 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
h4 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }

p { margin: 0.75rem 0; }

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

/* Code */
code {
  background: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

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

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

th { background: var(--bg-secondary); font-weight: 600; }
tr:nth-child(even) { background: var(--table-stripe); }

/* Lists */
ul, ol { padding-left: 1.5rem; margin: 0.5rem 0; }
li { margin: 0.25rem 0; }

/* Mermaid SVGs */
svg { max-width: 100%; height: auto; margin: 1rem 0; }

/* View as Markdown link */
.view-markdown {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

.footer-inner {
  max-width: 52rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}

/* Responsive */
@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; }
  nav { order: 3; width: 100%; }
  main { padding: 1rem; }
}
