:root {
  /* Paleta dark inspirada no Frontend Interview Handbook */
  --bg: #0c0d10;
  --surface: #14161b;
  --surface-2: #1a1d23;
  --fg: #e7e9ee;
  --muted: #9aa1ad;
  --border: #232730;
  --accent: #e0138c;
  --accent-soft: rgba(224, 19, 140, 0.14);
  --accent-fg: #ff5cb8;
  --code-bg: #161922;
  --sidebar-w: 16rem;
  --toc-w: 14rem;
  --content-max: 46rem;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", "Inter var", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(12, 13, 16, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fg);
}
.brand:hover {
  text-decoration: none;
}
.search-link {
  font-size: 0.9rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
}
.search-link:hover {
  color: var(--fg);
  border-color: var(--accent);
  text-decoration: none;
}

/* ---------- Layout 3 colunas ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 2rem;
  max-width: 84rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding: 1.5rem 0;
}
.nav-group {
  margin: 1.25rem 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar ul,
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar li a {
  display: block;
  padding: 0.35rem 0.7rem;
  margin: 0.1rem 0;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.sidebar li a:hover {
  color: var(--fg);
  background: var(--surface);
  text-decoration: none;
}
.sidebar li a.active {
  color: var(--accent-fg);
  background: var(--accent-soft);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ---------- Conteúdo ---------- */
main {
  min-width: 0;
  padding: 2rem 0 3rem;
}
.note {
  max-width: var(--content-max);
}
.note h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1.5rem;
  letter-spacing: -0.02em;
}
.note h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 5rem;
}
.note h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.75rem 0 0.75rem;
  scroll-margin-top: 5rem;
}
.note a.wikilink {
  color: var(--accent-fg);
  border-bottom: 1px dashed var(--accent);
}
.note ul,
.note ol {
  padding-left: 1.3rem;
}
.note li {
  margin: 0.3rem 0;
}
.note strong {
  color: #fff;
}

/* Código */
pre,
code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.12em 0.4em;
  font-size: 0.85em;
  color: #f1b3da;
}
pre,
pre[class*="language-"] {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  line-height: 1.55;
  tab-size: 2;
}
pre code,
pre[class*="language-"] code,
code[class*="language-"] {
  background: none;
  border: 0;
  padding: 0;
  color: #d6deeb;
  font-size: 0.86rem;
  text-shadow: none;
}

/* ---------- Tokens do PrismJS (tema dark) ---------- */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6b7280;
  font-style: italic;
}
.token.punctuation {
  color: #8b94a3;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #ff8cc8;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #7ee787;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #9ecbff;
}
.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--accent-fg);
}
.token.function,
.token.class-name {
  color: #d2a8ff;
}
.token.regex,
.token.important,
.token.variable {
  color: #ffab70;
}
.token.important,
.token.bold {
  font-weight: 600;
}
.token.italic {
  font-style: italic;
}

blockquote {
  margin: 1.25rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  color: var(--fg);
}

/* ---------- Backlinks ---------- */
.backlinks {
  max-width: var(--content-max);
  margin-top: 3rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.backlinks h2 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-fg);
}
.backlinks ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.backlinks li {
  margin: 0.25rem 0;
}

/* ---------- TOC (direita) ---------- */
.toc {
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding: 2rem 0;
  font-size: 0.85rem;
}
.toc li a {
  display: block;
  padding: 0.2rem 0;
  color: var(--muted);
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
}
.toc li a:hover {
  color: var(--fg);
  text-decoration: none;
}
.toc .toc-sub a {
  padding-left: 1.5rem;
  font-size: 0.8rem;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--content-max);
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Busca ---------- */
#search-input {
  width: 100%;
  max-width: var(--content-max);
  padding: 0.8rem 1rem;
  font-size: 1rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
#search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#search-results {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  max-width: var(--content-max);
}
#search-results li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
#search-results .snippet {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}
@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }
}
