:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-code: #0f172a;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --bg-code: #020617;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --accent: #60a5fa;
  --accent-soft: #1e293b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand svg { width: 24px; height: 24px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.92rem;
}
.nav-links a { color: var(--text-muted); font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }

.theme-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.layout {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2.5rem;
  padding: 2rem 1.5rem 4rem;
}

.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
}

.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 0 0 0.5rem;
}
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 0.25rem 0; }
.sidebar a {
  display: block;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.sidebar a:hover, .sidebar a.active {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.main { min-width: 0; }

.hero {
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.hero h1 { margin: 0 0 0.6rem; font-size: 2rem; letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--text-muted); font-size: 1.05rem; max-width: 640px; }

.search-box {
  margin-top: 1.25rem;
  max-width: 420px;
}
.search-box input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.95rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.15rem;
  margin-bottom: 2.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.card-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.card h3 { margin: 0 0 0.45rem; font-size: 1.08rem; color: var(--text); }
.card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
.card-meta { margin-top: auto; padding-top: 0.85rem; font-size: 0.8rem; color: var(--text-muted); }

article h1 { font-size: 1.9rem; margin-top: 0; letter-spacing: -0.02em; }
article h2 { margin-top: 2rem; font-size: 1.35rem; border-bottom: 1px solid var(--border); padding-bottom: 0.35rem; }
article h3 { margin-top: 1.5rem; font-size: 1.1rem; }
.article-meta { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }

pre {
  position: relative;
  background: var(--bg-code);
  color: #e2e8f0;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
}
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
}
p code, li code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  border: none;
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.22); }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.85rem 1.1rem;
  border-radius: 0 8px 8px 0;
  margin: 1.25rem 0;
  font-size: 0.94rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.85rem;
  text-align: left;
}
th { background: var(--bg-subtle); font-weight: 600; }

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .sidebar { position: static; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
}
