
:root {
    --bg: #f8fafc;
    --surface: #fff;
    --surface-2: #f1f5f9;
    --text: #172033;
    --muted: #667085;
    --line: #e4e7ec;
    --brand: #f98012;
    --brand-soft: #fff2e3;
    --code: #111827;
    --code-text: #e5e7eb;
    --shadow: 0 12px 34px rgba(15, 23, 42, .08);
    --content: 860px;
    --sidebar: 292px;
    --toc: 250px;
    font-size: 16px;
    color-scheme: light
}

html[data-theme="dark"] {
    --bg: #0b0f14;
    --surface: #10161d;
    --surface-2: #161d26;
    --text: #e7edf5;
    --muted: #98a2b3;
    --line: #26313e;
    --brand: #ff8d26;
    --brand-soft: #2a1b0c;
    --code: #080b0f;
    --code-text: #e5e7eb;
    --shadow: 0 12px 34px rgba(0, 0, 0, .28);
    color-scheme: dark
}

* {
    box-sizing: border-box
}

html {
    scroll-behavior: smooth
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 16px/1.72 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased
}

a {
    color: inherit
}

.skip {
    position: fixed;
    left: 12px;
    top: -100px;
    z-index: 999;
    background: var(--text);
    color: var(--surface);
    padding: 8px 12px;
    border-radius: 8px
}

.skip:focus {
    top: 12px
}

.progress {
    position: fixed;
    z-index: 90;
    left: 0;
    top: 0;
    height: 3px;
    width: 0;
    background: var(--brand);
    transition: width .08s linear
}

.topbar {
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 80;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line)
}

.topbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 0 28px
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    white-space: nowrap
}

.brand-mark {
    font: 700 19px/1 JetBrains Mono, monospace;
    color: var(--brand)
}

.brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.08
}

.brand-name {
    display: block;
    font-weight: 800;
    letter-spacing: -.02em
}

.brand-by {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    letter-spacing: .14em;
    color: var(--muted);
    font-weight: 700
}

.edition {
    margin-left: auto;
    font-size: 11px;
    letter-spacing: .12em;
    color: var(--muted);
    font-weight: 700
}

.icon-btn, .font-btn {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    min-width: 40px;
    height: 40px;
    padding: 0 11px;
    cursor: pointer;
    font: 600 14px Inter
}

.icon-btn:hover, .font-btn:hover {
    border-color: color-mix(in srgb, var(--brand) 65%, var(--line));
    background: var(--brand-soft)
}

.menu-btn {
    display: none
}

.layout {
    display: grid;
    grid-template-columns:var(--sidebar) minmax(0, 1fr) var(--toc);
    max-width: 1540px;
    margin: 0 auto;
    min-height: calc(100vh - 72px)
}

.sidebar {
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow: auto;
    padding: 28px 18px 40px;
    border-right: 1px solid var(--line);
    background: var(--surface)
}

.sidebar-title {
    font-size: 11px;
    letter-spacing: .15em;
    font-weight: 800;
    color: var(--muted);
    margin: 0 10px 12px;
    display: flex;
    justify-content: space-between
}

.chapter-list {
    list-style: none;
    margin: 0;
    padding: 0
}

.chapter-link {
    display: grid;
    grid-template-columns:31px 1fr;
    gap: 9px;
    align-items: start;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 9px;
    text-decoration: none;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35
}

.chapter-link .num {
    font: 600 11px/1.55 JetBrains Mono;
    color: color-mix(in srgb, var(--muted) 75%, transparent)
}

.chapter-link:hover {
    background: var(--surface-2);
    color: var(--text)
}

.chapter-link.active {
    background: var(--brand-soft);
    color: var(--text);
    font-weight: 650
}

.chapter-link.active .num {
    color: var(--brand)
}

.main {
    min-width: 0;
    padding: 42px 56px 90px
}

.article {
    max-width: var(--content);
    margin: 0 auto
}

.chapter-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 4px
}

.tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    margin: 0
}

.chapter-label {
    color: var(--brand);
    font-size: 12px;
    letter-spacing: .15em;
    font-weight: 800;
    margin: 0
}

.article h1 {
    font-size: clamp(34px, 5vw, 54px);
    line-height: 1.08;
    letter-spacing: -.045em;
    margin: 12px 0 12px
}

.meta {
    font-size: 13px;
    color: var(--muted);
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 34px
}

.chapter-body {
    font-size: var(--reader-size, 17px)
}

.chapter-body h1 {
    display: none
}

.chapter-body h2 {
    font-size: 1.65em;
    line-height: 1.25;
    letter-spacing: -.025em;
    margin: 2.2em 0 .7em;
    scroll-margin-top: 96px
}

.chapter-body h3 {
    font-size: 1.22em;
    line-height: 1.35;
    margin: 1.8em 0 .6em;
    scroll-margin-top: 96px
}

.chapter-body p {
    margin: 0 0 1.2em
}

.chapter-body ul, .chapter-body ol {
    padding-left: 1.6em;
    margin: 0 0 1.25em
}

.chapter-body li {
    margin: .38em 0
}

.chapter-body a {
    color: var(--brand);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px
}

.chapter-body img {
    max-width: 100%;
}

.chapter-body img.image-zoomable {
    cursor: zoom-in;
}

.image-modal {
    width: min(96vw, 1600px);
    max-width: none;
    height: min(94vh, 1000px);
    max-height: none;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .4);
    overflow: hidden;
}

.image-modal::backdrop {
    background: rgba(0, 0, 0, .78);
    backdrop-filter: blur(3px);
}

.image-modal-toolbar {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.image-modal-original {
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.image-modal-original:hover {
    color: var(--brand);
}

.image-modal-close {
    appearance: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font: 400 26px/1 Inter, sans-serif;
}

.image-modal-close:hover {
    border-color: color-mix(in srgb, var(--brand) 65%, var(--line));
    background: var(--brand-soft);
}

.image-modal-body {
    height: calc(100% - 52px);
    display: grid;
    place-items: center;
    padding: 0;
    overflow: auto;
    background: var(--surface-2);
}

.image-modal-body img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.chapter-body code:not(pre code) {
    font: 500 .88em JetBrains Mono, monospace;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: .14em .35em
}

.code-wrap {
    margin: 1.45em 0 1.7em;
    border: 1px solid #26313e;
    border-radius: 13px;
    overflow: hidden;
    background: var(--code);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12)
}

.code-head {
    height: 38px;
    display: flex;
    align-items: center;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid #202a36;
    color: #8d9aaa;
    font: 600 11px JetBrains Mono, monospace;
    text-transform: uppercase
}

.copy-code {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: #9ba8b7;
    cursor: pointer;
    font: 600 11px Inter;
    padding: 5px 7px;
    border-radius: 6px
}

.copy-code:hover {
    background: #18202a;
    color: #fff
}

.code-wrap pre {
    margin: 0;
    padding: 17px 19px;
    overflow: auto;
    color: var(--code-text);
    font: 400 13px/1.62 JetBrains Mono, Consolas, monospace;
    tab-size: 4
}

.tok-key {
    color: #c792ea
}

.tok-str {
    color: #c3e88d
}

.tok-num {
    color: #f78c6c
}

.tok-com {
    color: #718096;
    font-style: italic
}

.tok-var {
    color: #82aaff
}

.tok-tag {
    color: #f07178
}

.tok-attr {
    color: #ffcb6b
}

.quote {
    border-left: 3px solid var(--brand);
    padding: .2em 0 .2em 1.1em;
    color: var(--muted)
}

.chapter-nav {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 14px;
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid var(--line)
}

.nav-card {
    display: block;
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 16px;
    background: var(--surface)
}

.nav-card:hover {
    border-color: color-mix(in srgb, var(--brand) 60%, var(--line));
    box-shadow: var(--shadow)
}

.nav-card.next {
    text-align: right
}

.nav-card small {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .09em
}

.nav-card strong {
    display: block;
    margin-top: 3px;
    font-size: 14px
}

.right-toc {
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow: auto;
    padding: 34px 22px
}

.toc-label {
    font-size: 11px;
    letter-spacing: .12em;
    font-weight: 800;
    color: var(--muted);
    margin-bottom: 12px
}

.toc a {
    display: block;
    text-decoration: none;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    padding: 5px 0;
    border-left: 1px solid var(--line);
    padding-left: 12px
}

.toc a.sub {
    padding-left: 24px
}

.toc a:hover,
.toc a.active {
    color: var(--text);
    border-left-color: var(--brand);
    background: var(--brand-soft);
}

.loading {
    padding: 80px 0;
    text-align: center;
    color: var(--muted)
}

.loading-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand);
    animation: pulse 1s infinite alternate;
    margin-right: 7px
}

@keyframes pulse {
    to {
        opacity: .25;
        transform: translateY(-2px)
    }
}

.error-box {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface)
}

footer {
    margin-top: 70px;
    color: var(--muted);
    font-size: 12px;
    text-align: center
}

@media (max-width: 1180px) {
    .layout {
        grid-template-columns:260px minmax(0, 1fr)
    }

    .right-toc {
        display: none
    }

    .main {
        padding: 38px 42px 80px
    }
}

@media (max-width: 820px) {
    .topbar {
        height: 64px
    }

    .topbar-inner {
        padding: 0 16px
    }

    .edition {
        display: none
    }

    .menu-btn {
        display: block
    }

    .layout {
        display: block
    }

    .sidebar {
        position: fixed;
        z-index: 70;
        left: 0;
        top: 64px;
        width: min(330px, 86vw);
        height: calc(100vh - 64px);
        transform: translateX(-102%);
        transition: transform .2s ease;
        box-shadow: var(--shadow)
    }

    body.menu-open .sidebar {
        transform: translateX(0)
    }

    body.menu-open:after {
        content: "";
        position: fixed;
        z-index: 60;
        inset: 64px 0 0;
        background: rgba(0, 0, 0, .35)
    }

    .main {
        padding: 28px 21px 70px
    }

    .article h1 {
        font-size: 36px
    }

    .chapter-heading-row {
        gap: 12px
    }

    .tools {
        justify-content: flex-end
    }

    .chapter-nav {
        grid-template-columns:1fr
    }

    .chapter-body {
        font-size: var(--reader-size, 16px)
    }

    .image-modal {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
    }

    .image-modal-toolbar {
        padding: 0 8px;
    }

    .image-modal-body {
        padding: 10px;
    }
}

/* Prism é carregado online apenas quando o capítulo possui PHP, Mustache ou HTML. */
.code-wrap pre[class*="language-"],
.code-wrap code[class*="language-"] {
    background: transparent;
    text-shadow: none;
}

.code-wrap pre[class*="language-"] {
    margin: 0;
    padding: 17px 19px;
}

.code-wrap code[class*="language-"] {
    font: inherit;
    white-space: pre;
}

.language-notice {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 9px 16px;
    background: #fff8c5;
    border-bottom: 1px solid #d4a72c;
    color: #3b2300;
    font-size: 14px;
    text-align: center;
}

.language-notice.visible {
    display: flex;
}

.language-notice a {
    color: inherit;
    font-weight: 700;
}

[data-theme="dark"] .language-notice {
    background: #3b2e08;
    border-bottom-color: #9e6a03;
    color: #f0e7c2;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 5px;
}

.language-switcher a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 20px;
    line-height: 1;
    transition: border-color .15s ease, background .15s ease, opacity .15s ease;
}

.language-switcher a:hover {
    border-color: color-mix(in srgb, var(--brand) 65%, var(--line));
    background: var(--brand-soft);
}

.language-switcher a.active {
    border-color: color-mix(in srgb, var(--brand) 70%, var(--line));
    background: var(--brand-soft);
}

.language-switcher a.unavailable {
    opacity: .35;
    cursor: not-allowed;
}

@media (max-width: 820px) {
    .topbar-inner {
        gap: 10px;
    }

    .language-switcher {
        gap: 3px;
    }

    .language-switcher a {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}
