:root,
:root[data-theme="dark"] {
  --bg: #0b1110;
  --surface: #111c18;
  --surface-2: #142e24;
  --ink: #e6f2eb;
  --muted: #9eb8ad;
  --line: #2d4a3f;
  --brand: #4de0ac;
}

:root[data-theme="light"] {
  --bg: #f8faf9;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --ink: #1f2b24;
  --muted: #5c6e63;
  --line: #d4ddd8;
  --brand: #0d8a63;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Inter", "Segoe UI", sans-serif; }
a { color: var(--brand); }

/* Top bar */
.top {
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.top-left { display: flex; align-items: center; gap: 0.4rem; }
.brand-link { color: var(--ink); text-decoration: none; font-weight: 700; }
.brand-sep { color: var(--muted); font-weight: 300; }
.top a { color: var(--ink); text-decoration: none; margin-left: 0.8rem; font-size: 0.9rem; }
.top a:hover { color: var(--brand); }
.top-actions { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; justify-content: flex-end; }

/* Theme toggle */
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  padding: 0.36rem 0.52rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.theme-toggle:hover { border-color: var(--brand); }

/* Layout */
.wrap { display: grid; grid-template-columns: 240px 1fr; max-width: 1200px; margin: 0 auto; }
aside {
  border-right: 1px solid var(--line);
  min-height: calc(100vh - 52px);
  padding: 1.2rem 1rem;
  background: var(--surface);
  position: sticky;
  top: 52px;
  align-self: start;
  max-height: calc(100vh - 52px);
  overflow-y: auto;
}
aside h3 {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
aside h3:first-child { margin-top: 0; }
aside a {
  display: block;
  padding: 0.35rem 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 4px;
}
aside a:hover { background: var(--surface-2); color: var(--brand); }
aside a.active { color: var(--brand); background: var(--surface-2); font-weight: 500; }

/* Main content */
main { padding: 2rem 2rem 3rem; max-width: 820px; }
h1 { margin-top: 0; font-size: 2rem; font-weight: 700; }
h2 { margin-top: 2.5rem; font-size: 1.3rem; font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; }
h3 { margin-top: 1.5rem; font-size: 1.1rem; font-weight: 600; }
p, li { line-height: 1.7; color: var(--muted); }
li { margin-bottom: 0.3rem; }
strong { color: var(--ink); }
code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.88em; }
p code, li code, td code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
}

/* Code blocks */
pre {
  background: #0d1614;
  color: #d7ffed;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  border: 1px solid #224238;
  border-radius: 6px;
  line-height: 1.6;
  font-size: 0.88rem;
}
pre code { background: none; border: none; padding: 0; color: inherit; }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0;
}
thead { border-bottom: 2px solid var(--line); }
th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
td { padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--line); color: var(--muted); }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--brand); }
.card h3 { margin: 0 0 0.4rem; font-size: 1rem; color: var(--ink); }
.card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.small { color: var(--muted); font-size: 0.88rem; }
.credit { margin-top: 3rem; color: var(--muted); font-size: 0.88rem; border-top: 1px solid var(--line); padding-top: 1rem; }

@media (max-width: 880px) {
  .wrap { grid-template-columns: 1fr; }
  aside { border-right: none; border-bottom: 1px solid var(--line); min-height: 0; position: static; max-height: none; }
  .top { align-items: flex-start; flex-direction: column; gap: 0.45rem; }
  .top-actions { justify-content: flex-start; }
  main { padding: 1.5rem 1rem 2rem; }
}
