:root {
  --text: #292929;
  --text-light: #6b6b6b;
  --bg: #fff;
  --sidebar-bg: #fafafa;
  --sidebar-w: 280px;
  --accent: #1a8917;
  --border: #e6e6e6;
  --code-bg: #f6f6f6;
  --article-w: 680px;
}

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

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.sidebar-title {
  padding: 0 20px 16px;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

/* ── Tree ────────────────────────────────────────────── */

.tree ul { list-style: none; padding-left: 16px; }
.tree > ul { padding-left: 8px; }

.tree-folder > span {
  cursor: pointer;
  display: block;
  padding: 4px 12px;
  font-weight: 600;
  color: var(--text-light);
  user-select: none;
}
.tree-folder > span:hover { color: var(--text); }

.tree-folder > span::before {
  content: "▸";
  display: inline-block;
  width: 16px;
  transition: transform 0.15s;
}
.tree-folder.open > span::before { transform: rotate(90deg); }
.tree-folder > ul { display: none; }
.tree-folder.open > ul { display: block; }

.tree-file a {
  display: block;
  padding: 4px 12px 4px 28px;
  color: var(--text-light);
  text-decoration: none;
}
.tree-file a:hover,
.tree-file a.active {
  color: var(--accent);
  background: rgba(26, 137, 23, 0.06);
}

/* ── Content area ────────────────────────────────────── */

.content {
  margin-left: var(--sidebar-w);
  padding: 48px 32px;
}

article {
  max-width: var(--article-w);
  margin: 0 auto;
}

/* ── Typography (Medium-inspired) ────────────────────── */

article h1 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 2.5em;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

article h2 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 48px;
  margin-bottom: 12px;
}

article h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1.2em;
  font-weight: 700;
  margin-top: 36px;
  margin-bottom: 8px;
}

article p {
  margin-bottom: 24px;
  font-size: 1.125em;
}

article a { color: var(--accent); }

article blockquote {
  border-left: 3px solid var(--text);
  padding-left: 20px;
  margin: 32px 0;
  font-style: italic;
  color: var(--text-light);
}

article code {
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}

article pre {
  background: var(--code-bg);
  padding: 20px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 32px 0;
  line-height: 1.5;
}

article pre code {
  background: none;
  padding: 0;
  font-size: 0.875em;
}

article ul, article ol {
  margin-bottom: 24px;
  padding-left: 28px;
  font-size: 1.125em;
}

article li { margin-bottom: 8px; }

article img {
  max-width: 100%;
  margin: 32px 0;
  border-radius: 4px;
}

article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

article table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 1em;
}

article th, article td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

article th {
  background: var(--code-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 600;
}

/* ── Article metadata ────────────────────────────────── */

.article-meta {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.875em;
  color: var(--text-light);
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.article-tags span {
  display: inline-block;
  background: var(--code-bg);
  padding: 2px 10px;
  border-radius: 12px;
  margin-right: 4px;
}

.article-related a {
  color: var(--accent);
  text-decoration: none;
}
.article-related a:hover { text-decoration: underline; }

/* ── Welcome state ───────────────────────────────────── */

.welcome {
  text-align: center;
  padding-top: 120px;
  color: var(--text-light);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.welcome h1 {
  font-size: 1.5em;
  margin-bottom: 8px;
  color: var(--text);
}
