:root {
    /* Palette (6 tokens) */
    --bg:         #252446;  /* page background            */
    --surface:    #201533;  /* sidebar, code blocks, cards */
    --text:       #0098db;  /* body text                  */
    --muted:      #908e8b;  /* secondary / disabled text  */
    --accent:     #0098db;  /* highlight, links, badges   */
    --on-surface: #ffffff;  /* text on dark surfaces      */

    /* Typography (3 tokens) */
    --font-body:    'Sawarabi Mincho', serif;
    --font-heading: 'Playpen Sans', cursive;
    --font-mono:    'JetBrains Mono', monospace;
}

/* Light Theme
--bg:        #eddbc4;
--surface:   #333333;
--text:      #333333;
--muted:     #908e8b;
--accent:    #bd5a63;
--on-surface: #ffffff;
*/

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
    scroll-margin: 20px;
    text-align: justify;
}

body {
    background-color: var(--bg);
    font-family: var(--font-body);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--text);
}

a {
    color: var(--muted);
}

.highlight {
    color: var(--accent);
    font-weight: bold;
}

.comment {
    color: var(--muted);
    font-weight: lighter;
}

.tag{
    background-color: var(--accent);
}

/* SIDEBAR */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--surface);
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 1.5em 1.2em 1em;
    border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 15%, transparent);
}

.sidebar-logo a {
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6em;
}

.sidebar-logo .logo-moon {
    font-size: 1.6em;
}

.sidebar-logo h1 {
    font-family: var(--font-heading);
    font-size: 1em;
    color: var(--on-surface);
    line-height: 1.2;
}

.sidebar-logo h1 span {
    color: var(--accent);
}

.sidebar-logo .version-badge {
    display: inline-block;
    background-color: var(--accent);
    color: var(--on-surface);
    font-size: 0.65em;
    padding: 2px 7px;
    border-radius: 20px;
    font-family: var(--font-body);
    margin-top: 4px;
}

.sidebar nav {
    padding: 1em 0;
    flex: 1;
}

.nav-group {
    margin-bottom: 0.5em;
}

.nav-group-title {
    font-family: var(--font-heading);
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    padding: 0.6em 1.2em 0.3em;
}

.sidebar nav a {
    display: block;
    padding: 0.45em 1.2em 0.45em 1.5em;
    color: color-mix(in srgb, var(--on-surface) 70%, transparent);
    text-decoration: none;
    font-size: 0.88em;
    font-family: var(--font-body);
    border-left: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    color: var(--on-surface);
    border-left-color: var(--accent);
    background-color: color-mix(in srgb, var(--accent) 8%, transparent);
}

.sidebar-back {
    padding: 1em 1.2em;
    border-top: 1px solid color-mix(in srgb, var(--on-surface) 15%, transparent);
    margin-top: auto;
}

.sidebar-back a {
    color: var(--muted);
    font-size: 0.82em;
    text-decoration: none;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    gap: 0.4em;
    transition: color 0.2s;
}

.sidebar-back a:hover {
    color: var(--accent);
}

/* MAIN CONTENT */

.main {
    flex: 1;
    padding: 1.5em 2.5em;
    overflow-x: hidden;
}

.dropdown {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.dropbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background-color: var(--surface);
    color: var(--on-surface);
    text-decoration: none;
    font-size: 12px;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: 0.2s ease;
}

.dropbtn:hover {
    border-color: var(--accent);
    background-color: rgba(0, 152, 219, 0.12);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 90px;
    background-color: var(--surface);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    overflow: hidden;
    display: none;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 10px;
    text-align: center;
    text-decoration: none;
    color: var(--on-surface);
    font-size: 12px;
    transition: background 0.2s ease;
}

.dropdown-content a:hover {
    background-color: rgba(0, 152, 219, 0.15);
}

/* SECTIONS */

.doc-section {
    margin-bottom: 2em;
    padding-bottom: 2em;
    border-bottom: 1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}

.doc-section:last-child {
    border-bottom: none;
}

.doc-section > h2 {
    font-size: 1.8em;
    margin-bottom: 0.4em;
    display: flex;
    align-items: center;
    gap: 0.4em;
}

.doc-section > h2 .section-icon {
    font-size: 0.8em;
    opacity: 0.6;
}

.section-desc {
    color: var(--muted);
    font-size: 0.9em;
    margin-bottom: 1.5em;
    line-height: 1.7;
}

.subsection {
    margin-top: 2em;
}

.subsection h3 {
    font-size: 1.15em;
    margin-bottom: 0.8em;
    padding-bottom: 0.3em;
    border-bottom: 1px dashed color-mix(in srgb, var(--muted) 40%, transparent);
}

.subsection h4 {
    font-size: 0.95em;
    margin: 1.2em 0 0.4em;
    color: var(--accent);
}

.subsection p {
    font-size: 0.9em;
    line-height: 1.7;
    margin-bottom: 0.8em;
    color: var(--muted);
}

/* PLACEHOLDER */

.placeholder {
    background: repeating-linear-gradient(
        -45deg,
        color-mix(in srgb, var(--accent) 4%, transparent),
        color-mix(in srgb, var(--accent) 4%, transparent) 8px,
        transparent 8px,
        transparent 16px
    );
    border: 1.5px dashed color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 6px;
    padding: 1.2em 1.4em;
    color: var(--muted);
    font-size: 0.88em;
    font-style: italic;
    margin-bottom: 1em;
}

.placeholder::before {
    content: "✏️  ";
}

/* CODE BLOCKS */

pre {
    background-color: var(--surface);
    border: 1px solid var(--code-border);
    border-radius: 8px;
    padding: 1.2em 1.4em;
    overflow-x: auto;
    margin-bottom: 1em;
    position: relative;
    max-width: 750px;
}

pre code {
    font-family: var(--font-mono);
    font-size: 0.8em;
    color: color-mix(in srgb, var(--on-surface) 85%, transparent);
    line-height: 1.7;
}

.lang-label {
    position: absolute;
    top: 0.7em;
    right: 1em;
    font-family: var(--font-mono);
    font-size: 0.65em;
    color: color-mix(in srgb, var(--on-surface) 85%, transparent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.copy-btn {
    position: absolute;
    top: 0.5em;
    right: 4em;
    background: none;
    border: 1px solid color-mix(in srgb, var(--on-surface) 35%, transparent);
    border-radius: 4px;
    color: color-mix(in srgb, var(--on-surface) 85%, transparent);
    font-family: var(--font-mono);
    font-size: 0.65em;
    padding: 2px 8px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: border-color 0.2s, color 0.2s;
}

.copy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

code {
    font-family: var(--font-mono);
    font-size: 0.82em;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 3px;
}

pre code {
    background: none;
    color: color-mix(in srgb, var(--on-surface) 85%, transparent);
    padding: 0;
}

/* API TABLE */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.api-table {
    border-collapse: collapse;
    font-size: 0.85em;
    margin-bottom: 1.5em;
    background-color: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    min-width: 700px;
}

.api-table th {
    background-color: var(--accent);
    color: var(--on-surface);
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 0.7em 1em;
    text-align: left;
    font-size: 0.85em;
}

.api-table td {
    padding: 0.65em 1em;
    border-bottom: 1px solid color-mix(in srgb, var(--on-surface) 15%, transparent);
    color: color-mix(in srgb, var(--on-surface) 80%, transparent);
    line-height: 1.5;
}

.api-table tr:last-child td {
    border-bottom: none;
}

.api-table td:first-child {
    font-family: var(--font-mono);
    color: color-mix(in srgb, var(--on-surface) 85%, transparent);
    font-size: 0.82em;
    white-space: nowrap;
}

.api-table td code {
    background: color-mix(in srgb, var(--on-surface) 8%, transparent);
    color: color-mix(in srgb, var(--accent) 70%, var(--on-surface));
    padding: 1px 5px;
    border-radius: 3px;
}

.tag.tag-gray {
    background-color: var(--muted);
}

/* ARCH DIAGRAM */

.arch-diagram {
    background-color: var(--surface);
    border-radius: 10px;
    padding: 2em;
    margin-bottom: 1.5em;
    font-family: var(--font-mono);
    font-size: 0.8em;
    color: color-mix(in srgb, var(--on-surface) 80%, transparent);
    line-height: 2;
    white-space: pre;
    overflow-x: auto;
}

.arch-diagram .highlight {
    color: var(--accent);
    font-weight: bold;
}

.arch-diagram .dim {
    color: color-mix(in srgb, var(--on-surface) 35%, transparent);
}

/* CALLOUT */

.callout {
    display: flex;
    gap: 0.8em;
    background-color: color-mix(in srgb, var(--accent) 8%, transparent);
    border-left: 4px solid var(--accent);
    border-radius: 0 6px 6px 0;
    padding: 0.9em 1.1em;
    margin-bottom: 1.2em;
    font-size: 0.88em;
    color: var(--text);
    line-height: 1.6;
    max-width: 750px;
}

.callout .callout-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}

/* LIST */

.doc-list {
    list-style: none;
    padding: 0;
    margin-bottom: 1em;
}

.doc-list li {
    padding: 0.35em 0 0.35em 1.2em;
    position: relative;
    font-size: 0.9em;
    color: var(--muted);
    line-height: 1.6;
}

.doc-list li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* PAGE HEADER */

.page-header {
    margin-bottom: 3em;
    padding-bottom: 1.5em;
    border-bottom: 2px solid var(--text);
}

.page-header h1 {
    font-size: 2.5em;
    margin-bottom: 0.3em;
}

.page-header h1 span {
    color: var(--accent);
}

.page-header p {
    color: var(--muted);
    font-size: 0.95em;
    line-height: 1.7;
}

.header-meta {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    margin-top: 0.8em;
}

/* MOBILE TOGGLE */

.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 1.5em;
    right: 1.5em;
    background: var(--accent);
    color: var(--on-surface);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.3em;
    cursor: pointer;
    z-index: 100;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 50;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .main {
        padding: 2em 1.5em;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}