:root {
  --bg: #0d1117;
  --bg-sidebar: #161b22;
  --bg-content: #0d1117;
  --bg-code: #161b22;
  --bg-hover: #1f2937;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #6e7681;
  --text-heading: #e6edf3;
  --text-code: #79c0ff;
  --accent: #388bfd;
  --accent-soft: rgba(56, 139, 253, 0.12);
  --accent-active: rgba(56, 139, 253, 0.2);
  --tag-bg: #21262d;
  --tag-text: #8b949e;
  --good: #3fb950;
  --font-sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

#header .header-logo {
  height: 26px;
  width: 26px;
  border-radius: 5px;
  flex-shrink: 0;
}

#header .wordmark {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

#header .tagline {
  font-size: 12px;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

#search-wrap {
  margin-left: auto;
  position: relative;
}

#search {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 6px 12px 6px 32px;
  width: 260px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}

#search::placeholder { color: var(--text-muted); }

#search:focus {
  border-color: var(--accent);
  width: 320px;
}

#search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

/* ── Layout ─────────────────────────────────────────── */
#layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────── */
#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}

.nav-section { margin-bottom: 8px; }

.nav-category {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 16px 4px;
}

.nav-link {
  display: block;
  padding: 5px 16px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-heading);
}

.nav-link.active {
  background: var(--accent-active);
  border-left-color: var(--accent);
  color: var(--text-heading);
}

/* ── Main content ─────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  padding: 36px 48px;
  max-width: 860px;
}

/* ── Search results ──────────────────────────────────── */
#search-results {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 48px;
}

#search-results.visible { display: block; }
#main.hidden { display: none; }

.search-result {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.search-result:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.search-result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 4px;
}

.search-result-snippet {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.search-result-snippet mark {
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 2px;
  padding: 0 2px;
}

.no-results {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0;
}

/* ── Article typography ──────────────────────────────── */
.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.article-updated::before { content: "Updated "; }

.article-category-badge {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
}

h1.article-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
  margin-bottom: 6px;
}

.article-summary {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.section { margin-bottom: 32px; }

.section h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.section p { margin-bottom: 10px; }
.section p:last-child { margin-bottom: 0; }

.section ul, .section ol {
  padding-left: 20px;
  margin-bottom: 10px;
}

.section li { margin-bottom: 4px; }

.section code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-code);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.section pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-code);
}

.section pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.section table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
}

.section th {
  background: var(--bg-sidebar);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.section td {
  padding: 7px 12px;
  border: 1px solid var(--border);
}

.section tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* ── Home page ───────────────────────────────────────── */
#home-page h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
}

#home-page .home-subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.home-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.home-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.home-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 4px;
}

.home-card-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.home-category-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 24px 0 10px;
}

.home-category-label:first-of-type { margin-top: 0; }

/* ── Scrollbars ──────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 700px) {
  #sidebar { display: none; }
  #main, #search-results { padding: 20px 20px; }
  #search { width: 180px; }
  #search:focus { width: 200px; }
  #header .tagline { display: none; }
}
