:root {
  --bg: #faf9f6; --surface: #ffffff; --surface-2: #f3f1ec; --border: #e4e0d8;
  --text: #1f1e1b; --muted: #6b675f; --accent: #c4623f; --accent-soft: #f6e3da;
  --ok: #2f7d4f; --ok-soft: #dff0e5; --warn: #9a6a12; --warn-soft: #f8ecd0;
  --code-bg: #1f2227; --code-text: #e8e6e1;
  --radius: 10px; --sidebar: 280px; --toc: 220px; --top: 56px;
  --logo-light: block; --logo-dark: none;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171a; --surface: #1f1f23; --surface-2: #26262b; --border: #33333a;
    --text: #ececea; --muted: #a09d96; --accent: #e08a68; --accent-soft: #3a2a23;
    --ok: #6cc08a; --ok-soft: #1f3327; --warn: #e0b45a; --warn-soft: #3a3020;
    --code-bg: #101114;
    --logo-light: none; --logo-dark: block;
  }
}
:root[data-theme="dark"] {
  --bg: #17171a; --surface: #1f1f23; --surface-2: #26262b; --border: #33333a;
  --text: #ececea; --muted: #a09d96; --accent: #e08a68; --accent-soft: #3a2a23;
  --ok: #6cc08a; --ok-soft: #1f3327; --warn: #e0b45a; --warn-soft: #3a3020;
  --code-bg: #101114;
  --logo-light: none; --logo-dark: block;
}
:root[data-theme="light"] { --logo-light: block; --logo-dark: none; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

.topbar { position: sticky; top: 0; z-index: 30; height: var(--top); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand img { height: 22px; width: auto; }
.logo-light { display: var(--logo-light); } .logo-dark { display: var(--logo-dark); }
.brand-name { font-weight: 600; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); }
.icon-btn { width: 38px; height: 38px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 18px; }
.icon-btn:hover, .search-btn:hover { background: var(--surface-2); }
#menu-btn { display: none; }
.search-btn { flex: 1; max-width: 420px; margin: 0 auto 0 12px; display: flex; justify-content: space-between; align-items: center;
  height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--muted); cursor: pointer; font: inherit; font-size: 14px; }
kbd { white-space: nowrap; font: 12px var(--mono); padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); }
.stage-chip { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; text-decoration: none;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc); max-width: 1500px; margin: 0 auto; }
.sidebar { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 20px 12px 40px 16px;
  border-right: 1px solid var(--border); }
.sidebar h2 { margin: 18px 8px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sidebar a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px;
  color: var(--text); text-decoration: none; font-size: 14.5px; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar a.soon { color: var(--muted); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

main { padding: 36px clamp(20px, 4vw, 56px) 80px; min-width: 0; outline: none; }
main h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.02em; }
main h2 { font-size: 1.5rem; margin: 2.4rem 0 .6rem; padding-top: .4rem; border-top: 1px solid var(--border); }
main h3 { font-size: 1.15rem; margin: 1.6rem 0 .4rem; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 1.6rem; max-width: 70ch; }
main p, main li { max-width: 75ch; }
code { font: .88em var(--mono); background: var(--surface-2); padding: .12em .4em; border-radius: 5px; }
.codeblock { position: relative; margin: 1rem 0; }
.codeblock pre { margin: 0; padding: 16px; background: var(--code-bg); color: var(--code-text); border-radius: var(--radius); overflow-x: auto; }
.codeblock pre code { background: none; padding: 0; font-size: 13.5px; color: inherit; }
.copy { position: absolute; top: 8px; right: 8px; font: 12px var(--font); padding: 3px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid #3a3d44; background: #2a2d33; color: #d8d6d0; }
.copy:hover { background: #34373e; }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 14.5px; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.callout { margin: 1.2rem 0; padding: 14px 16px; border-radius: var(--radius); border-left: 4px solid var(--accent); background: var(--accent-soft); max-width: 75ch; }
.callout.ok { border-color: var(--ok); background: var(--ok-soft); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout > :first-child { margin-top: 0; } .callout > :last-child { margin-bottom: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 1rem 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.card p { margin: 6px 0; color: var(--muted); font-size: 14.5px; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
a.card { display: block; color: inherit; text-decoration: none; } a.card:hover { border-color: var(--accent); }

.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 10px 0 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.stages { display: grid; gap: 14px; margin: 1.2rem 0; }
.stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stage.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stage header { display: flex; gap: 12px; align-items: center; }
.num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); font-weight: 700; flex: none; }
.stage.done .num { background: var(--ok); color: #fff; }
.stage h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.stage ul { margin: 8px 0 0; padding-left: 1.2rem; }
.stage .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 0; }
.cell-ok { color: var(--ok); font-weight: 700; } .cell-pending { color: var(--muted); } .cell-part { color: var(--warn); font-weight: 600; }

.toc { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 36px 16px; font-size: 13.5px; }
.toc h2 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.toc a { display: block; padding: 3px 0 3px 10px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--border); }
.toc a.sub { padding-left: 22px; }
.toc a.active { color: var(--accent); border-color: var(--accent); }

.search { width: min(640px, 92vw); margin-top: 12vh; padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); }
.search::backdrop { background: rgba(0,0,0,.45); }
#search-input { width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; font: inherit; font-size: 17px; outline: none; }
#search-results { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
#search-results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
#search-results a small { display: block; color: var(--muted); }
#search-results li.sel a, #search-results a:hover { background: var(--accent-soft); }
.search-hint { margin: 0; padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }
.scrim { display: none; }

@media (max-width: 1180px) { .layout { grid-template-columns: var(--sidebar) minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  #menu-btn { display: block; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: var(--top); width: min(320px, 86vw); background: var(--surface);
    transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 35; background: rgba(0,0,0,.4); }
  .search-btn span { display: none; } .search-btn { max-width: 56px; justify-content: center; }
  .stage-chip { font-size: 12px; padding: 5px 9px; }
}
@media print { .topbar, .sidebar, .toc, .copy { display: none; } .layout { display: block; } }

/* Barras de rolagem discretas */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 40%, transparent) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 60%, transparent); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }
.codeblock pre { scrollbar-color: #4a4d55 transparent; }
.codeblock pre::-webkit-scrollbar-thumb { background: #4a4d55; background-clip: content-box; }

/* Diagramas e checklists */
.diagram { margin: 1.4rem 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; color: var(--muted); }
.diagram svg { display: block; min-width: 760px; width: 100%; height: auto; }
.diagram .box { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.2; }
.diagram .box.core { fill: var(--accent-soft); stroke: var(--accent); }
.diagram .box.ext { fill: none; stroke-dasharray: 4 3; }
.diagram text { fill: var(--text); font: 600 13px var(--font); }
.diagram text.sub { fill: var(--muted); font-weight: 400; font-size: 11.5px; }
.diagram .line { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.diagram .line.dash { stroke-dasharray: 5 4; }
.diagram .lbl { fill: var(--muted); font: 400 11px var(--font); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; max-width: 75ch; }
.check input { margin-top: 6px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check label { cursor: pointer; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 1rem 0; }
.steps > li { counter-increment: step; position: relative; padding: 4px 0 14px 46px; max-width: 75ch; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 2px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
dl.terms dt { font-weight: 700; margin-top: 1.1rem; }
dl.terms dd { margin: 2px 0 0; max-width: 75ch; color: var(--text); }
dl.terms dd small { display: block; color: var(--muted); }

/* Imagem de abertura da página inicial */
.hero { margin: 0 0 1.6rem; max-width: 880px; }
.hero img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); background: #0b1a2b; }
.hero + .callout { max-width: 880px; }
