:root {
    color-scheme: light;

    --primary: #7c5cfc;
    --primary-light: #ede9fe;
    --primary-lighter: #f5f3ff;
    --primary-hover: #6a4be0;
    --primary-dark: #5b3fd4;

    --bg-page: #f3f0ff;
    --bg-panel: #ffffff;
    --bg-hover: #f9f8ff;

    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-inverse: #ffffff;

    --border: #eee9f5;
    --border-light: #f3f0fa;

    --shadow-sm: 0 1px 3px rgba(100, 70, 180, 0.04);
    --shadow-md: 0 4px 24px rgba(100, 70, 180, 0.07);
    --shadow-card: 0 2px 8px rgba(100, 70, 180, 0.05);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --accent-green-bg: #d1fae5;
    --accent-green-text: #059669;

    --docs-code-bg: #faf8ff;
    --docs-hero-gradient: linear-gradient(135deg, #7c5cfc 0%, #5b3fd4 45%, #3b2a7a 100%);
}

html[data-theme="dark"] {
    color-scheme: dark;

    --primary: #9b87ff;
    --primary-light: #2f2650;
    --primary-lighter: #241d3d;
    --primary-hover: #b09cff;
    --primary-dark: #c4b5fd;

    --bg-page: #0c0a14;
    --bg-panel: #15121f;
    --bg-hover: #252135;

    --text-primary: #f0eef6;
    --text-secondary: #aaa5bc;
    --text-tertiary: #7f788e;
    --text-inverse: #0f0b18;

    --border: #2a2538;
    --border-light: #1f1b2c;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 28px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.35);

    --accent-green-bg: #052e16;
    --accent-green-text: #6ee7b7;

    --docs-code-bg: #1a1628;
    --docs-hero-gradient: linear-gradient(135deg, #5b3fd4 0%, #3d2d7a 50%, #0c0a14 100%);
}

* { box-sizing: border-box; }

body.noteapi-docs {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;

    --docs-sidebar-width: 260px;
    --docs-content-max: 880px;
    --docs-topbar-height: 64px;
}

code, pre {
    font-family: var(--font-mono);
    font-size: 12px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Top bar */
.noteapi-docs__topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.noteapi-docs__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.noteapi-docs__brand:hover {
    opacity: 0.92;
    text-decoration: none;
}

.noteapi-docs__logo {
    display: block;
    height: 40px;
    width: auto;
    max-width: 220px;
}

html[data-theme="dark"] .noteapi-docs__logo {
    filter: brightness(0) invert(1);
}

.noteapi-docs__topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.noteapi-docs__theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.noteapi-docs__theme-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-lighter);
}

.noteapi-docs__theme-btn svg {
    width: 18px;
    height: 18px;
}

.noteapi-docs__theme-btn .icon-sun { display: none; }
html[data-theme="dark"] .noteapi-docs__theme-btn .icon-moon { display: none; }
html[data-theme="dark"] .noteapi-docs__theme-btn .icon-sun { display: block; }

/* Shell + sidebar */
.noteapi-docs__shell {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - var(--docs-topbar-height));
}

.noteapi-docs__sidebar {
    flex: 0 0 var(--docs-sidebar-width);
    width: var(--docs-sidebar-width);
    position: sticky;
    top: var(--docs-topbar-height);
    height: calc(100vh - var(--docs-topbar-height));
    overflow-y: auto;
    border-right: 1.5px solid var(--border);
    background: var(--bg-panel);
    padding: 24px 16px;
}

.noteapi-docs__sidebar-label {
    margin: 0 0 12px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.noteapi-docs__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.noteapi-docs__content {
    flex: 1;
    min-width: 0;
}

.noteapi-docs__hero {
    background: var(--docs-hero-gradient);
    border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
    padding: 40px 32px 48px;
    color: #fff;
}

.noteapi-docs__main {
    max-width: var(--docs-content-max);
    padding: 28px 32px 48px;
}

.noteapi-docs__hero-inner {
    max-width: var(--docs-content-max);
}

.noteapi-docs__hero h1 {
    margin: 0 0 12px;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #fff;
}

.noteapi-docs__lead {
    max-width: 640px;
    margin: 0 0 20px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 15px;
    line-height: 1.55;
}

.noteapi-docs__hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.78);
}

.noteapi-docs__hero-meta code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    color: #fff;
}

.noteapi-docs__nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.noteapi-docs__nav a:hover {
    background: var(--primary-lighter);
    color: var(--primary);
    text-decoration: none;
}

.noteapi-docs__nav a.is-active {
    background: var(--primary-lighter);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary);
}

/* Sections */
.noteapi-docs__section {
    margin-bottom: 32px;
    padding: 24px;
    background: var(--bg-panel);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.noteapi-docs__section h2 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.noteapi-docs__section h3 {
    margin: 20px 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.noteapi-docs__section p,
.noteapi-docs__section li {
    color: var(--text-secondary);
    font-size: 14px;
}

.noteapi-docs__callout {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--primary-lighter);
    border: 1.5px solid color-mix(in srgb, var(--primary) 22%, transparent);
    color: var(--text-secondary);
    font-size: 13px;
}

.noteapi-docs__callout strong {
    color: var(--primary-dark);
}

html[data-theme="dark"] .noteapi-docs__callout strong {
    color: var(--primary);
}

.noteapi-docs__endpoint {
    margin-top: 20px;
    padding: 18px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-hover);
}

.noteapi-docs__method {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 8px;
    border-radius: var(--radius-sm);
    background: var(--accent-green-bg);
    color: var(--accent-green-text);
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
}

.noteapi-docs__table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 13px;
}

.noteapi-docs__table th,
.noteapi-docs__table td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.noteapi-docs__table th {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 600;
}

.noteapi-docs__table td {
    color: var(--text-secondary);
}

.noteapi-docs__table code {
    font-size: 11px;
    color: var(--primary-dark);
}

html[data-theme="dark"] .noteapi-docs__table code {
    color: var(--primary);
}

.noteapi-docs__example {
    margin-top: 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.noteapi-docs__example-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
}

.noteapi-docs__copy {
    border: 1.5px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    transition: all 0.2s;
}

.noteapi-docs__copy:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-lighter);
}

pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: var(--docs-code-bg);
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-primary);
}

.noteapi-docs__footer {
    max-width: var(--docs-content-max);
    text-align: left;
    padding: 0 32px 32px;
    color: var(--text-tertiary);
    font-size: 13px;
    background: transparent;
    border-top: none;
}

@media (max-width: 900px) {
    .noteapi-docs__shell {
        flex-direction: column;
    }

    .noteapi-docs__sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
        border-right: none;
        border-bottom: 1.5px solid var(--border);
        padding: 16px;
    }

    .noteapi-docs__sidebar-label {
        display: none;
    }

    .noteapi-docs__nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
    }

    .noteapi-docs__hero {
        padding: 32px 20px 40px;
    }

    .noteapi-docs__main {
        padding: 20px 20px 40px;
    }

    .noteapi-docs__footer {
        padding: 0 20px 24px;
    }
}

@media print {
    .noteapi-docs__sidebar,
    .noteapi-docs__copy,
    .noteapi-docs__topbar,
    .noteapi-docs__theme-btn {
        display: none;
    }

    body.noteapi-docs {
        background: #fff;
        color: #111;
    }

    .noteapi-docs__hero {
        background: #7c5cfc;
    }
}
