:root {
    --bg: #0f0f12;
    --surface: #17171b;
    --surface-2: #1d1d22;
    --border: #2b2b31;
    --text: #e8e8ec;
    --muted: #969696;
    --faint: #6f6f76;
    --accent: #26bbff;
    --accent-text: #7ad0ff;
    --warn: #f6ad55;
    --danger: #ff6b78;
    --ok: #34d399;
    --code-bg: #121216;
    --radius: 10px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #fbfbfc;
        --surface: #ffffff;
        --surface-2: #f3f3f6;
        --border: #e2e2e8;
        --text: #1d1d24;
        --muted: #5f5f6b;
        --faint: #8a8a95;
        --accent: #0a84c6;
        --accent-text: #0a6ea6;
        --code-bg: #f5f5f8;
        color-scheme: light;
    }
}

* { box-sizing: border-box; }

html { scroll-padding-top: 76px; }

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

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

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; padding: 8px 12px; background: var(--surface); }

/* ---------- górny pasek ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 1440px;
    height: 58px;
    margin: 0 auto;
    padding: 0 20px;
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { color: var(--accent); }
.brand b { font-weight: 650; }

.topnav { display: flex; gap: 18px; font-size: 13.5px; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--text); text-decoration: none; }

.menu-button { display: none; padding: 4px 8px; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--text); font-size: 16px; cursor: pointer; }

.search { position: relative; margin-left: auto; width: min(320px, 40vw); }

.search input {
    width: 100%;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

.search input:focus { outline: none; border-color: var(--accent); }

.search-results {
    position: absolute;
    top: 40px;
    right: 0;
    width: min(440px, 92vw);
    max-height: 60vh;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}

.search-result { display: block; padding: 9px 10px; border-radius: 7px; color: var(--text); }
.search-result:hover, .search-result.active { background: var(--surface-2); text-decoration: none; }
.search-result small { display: block; color: var(--muted); font-size: 12px; }
.search-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---------- układ dokumentacji ---------- */

.docs {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 220px;
    gap: 40px;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
}

.sidebar {
    position: sticky;
    top: 58px;
    align-self: start;
    max-height: calc(100vh - 58px);
    overflow-y: auto;
    padding: 28px 0;
}

.nav-section { margin-bottom: 22px; }
.nav-title { margin-bottom: 8px; color: var(--faint); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.nav-link { display: block; padding: 6px 10px; border-radius: 7px; color: var(--muted); font-size: 13.5px; }
.nav-link:hover { color: var(--text); text-decoration: none; background: var(--surface); }
.nav-link.active { color: var(--text); background: var(--surface-2); font-weight: 550; }

.article { min-width: 0; max-width: 780px; padding: 36px 0 60px; }

.breadcrumb { margin-bottom: 6px; color: var(--accent-text); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.article h1 { margin: 0 0 12px; font-size: 32px; line-height: 1.2; letter-spacing: -.02em; }
.lead { margin: 0 0 28px; color: var(--muted); font-size: 17px; }

.article h2 { margin: 44px 0 12px; padding-top: 8px; font-size: 22px; letter-spacing: -.01em; }
.article h3 { margin: 30px 0 8px; font-size: 17px; }
.article p, .article ul, .article ol { margin: 0 0 16px; }
.article li { margin: 4px 0; }

.anchor { margin-left: 8px; color: var(--faint); font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

.toc { position: sticky; top: 58px; align-self: start; padding: 36px 0; font-size: 12.5px; }
.toc-title { margin-bottom: 8px; color: var(--faint); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.toc-link { display: block; padding: 3px 0; color: var(--muted); }
.toc-link.level-3 { padding-left: 12px; }
.toc-link.active { color: var(--accent-text); }

/* ---------- elementy treści ---------- */

code { padding: 1px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--code-bg); font-family: var(--mono); font-size: .87em; }

pre {
    position: relative;
    margin: 0 0 18px;
    padding: 16px 18px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--code-bg);
    font-size: 13px;
    line-height: 1.6;
}

pre code { padding: 0; border: 0; background: none; font-size: inherit; white-space: pre; }

.copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

pre:hover .copy, .copy:focus { opacity: 1; }

.code-tabs { margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; }
.code-tabs pre { margin: 0; border: 0; border-radius: 0; }
.tab-list { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.tab { padding: 7px 12px; border: 0; border-radius: 7px 7px 0 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--code-bg); color: var(--text); }

table { width: 100%; margin: 0 0 18px; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; font-weight: 600; }

.callout { position: relative; margin: 0 0 18px; padding: 12px 16px 12px 19px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); overflow: hidden; }
.callout::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--accent); }
.callout.warn::before { background: var(--warn); }
.callout.danger::before { background: var(--danger); }
.callout strong { color: var(--text); }
.callout p:last-child { margin-bottom: 0; }

.endpoint { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-family: var(--mono); font-size: 13px; overflow-x: auto; }
.endpoint code { padding: 0; border: 0; background: none; }
.method { padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.method.post { background: rgba(38, 187, 255, .15); color: var(--accent-text); }
.method.get { background: rgba(52, 211, 153, .15); color: var(--ok); }
.method.delete { background: rgba(255, 107, 120, .15); color: var(--danger); }

.steps { counter-reset: step; padding-left: 0; list-style: none; }
.steps > li { position: relative; margin: 0 0 18px; padding-left: 40px; }
.steps > li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--accent-text); font-size: 13px; font-weight: 650; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.pager-link { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 550; }
.pager-link:hover { border-color: var(--accent); text-decoration: none; }
.pager-link span { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.pager-link.next { text-align: right; }

/* ---------- strona główna ---------- */

.home { max-width: 1120px; margin: 0 auto; padding: 64px 20px 80px; }
.hero { max-width: 720px; margin-bottom: 52px; }
.hero h1 { margin: 0 0 14px; font-size: clamp(32px, 5vw, 48px); line-height: 1.1; letter-spacing: -.03em; }
.hero p { margin: 0 0 24px; color: var(--muted); font-size: 18px; }

.button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 9px; background: var(--accent); color: #04121a; font-weight: 650; font-size: 14px; }
.button:hover { text-decoration: none; filter: brightness(1.08); }
.button.ghost { border: 1px solid var(--border); background: transparent; color: var(--text); }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .tag { align-self: flex-start; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; }
.card .tag.live { border-color: rgba(52, 211, 153, .4); color: var(--ok); }
.section-title { margin: 48px 0 14px; font-size: 13px; color: var(--faint); font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }

.footer { padding: 28px 20px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12.5px; text-align: center; }

/* ---------- węższe ekrany ---------- */

@media (max-width: 1180px) {
    .docs { grid-template-columns: 240px minmax(0, 1fr); }
    .toc { display: none; }
}

@media (max-width: 860px) {
    .docs { display: block; }
    .menu-button { display: block; }
    .topnav { display: none; }
    .sidebar { position: fixed; top: 58px; left: 0; bottom: 0; z-index: 40; width: 280px; max-height: none; padding: 20px; border-right: 1px solid var(--border); background: var(--bg); transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .article { padding-top: 24px; }
    .article h1 { font-size: 26px; }
    .pager { grid-template-columns: 1fr; }
}
