:root {
    color-scheme: dark;
    --bg: #0a0b0d;
    --sidebar: #0f1216;
    --surface: #15191f;
    --surface-2: #1b2027;
    --surface-3: #101318;
    --line: rgba(229, 234, 240, 0.1);
    --line-strong: rgba(229, 234, 240, 0.18);
    --text: #f4f7fb;
    --soft: #c6ced8;
    --muted: #8994a2;
    --accent: #5ee0a4;
    --accent-2: #68b8ff;
    --gold: #e7be62;
    --danger: #ff7380;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.4);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at top left, rgba(94, 224, 164, 0.08), transparent 34rem),
        linear-gradient(135deg, #090a0c 0%, #10131a 48%, #0b0d10 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

code,
pre {
    font-family: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

code {
    color: #dff2ff;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    height: 100vh;
    min-height: 0;
}

.app-sidebar {
    position: relative;
    z-index: 20;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    background: rgba(15, 18, 22, 0.96);
    backdrop-filter: blur(18px);
}

.brand {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    margin: 2px 4px 18px;
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.035);
}

.brand img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: contain;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
    line-height: 1.1;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.nav-stack {
    display: grid;
    gap: 5px;
}

.nav-item,
.nav-menu summary {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--soft);
    font-size: 13px;
    line-height: 1.25;
}

.nav-item i,
.nav-menu summary i {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--accent-2);
    font-size: 13px;
}

.nav-item span,
.nav-menu summary span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-item em {
    min-width: 24px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
    text-align: center;
}

.nav-item:hover,
.nav-menu summary:hover,
.nav-item.active {
    border-color: rgba(94, 224, 164, 0.16);
    background: rgba(94, 224, 164, 0.09);
    color: var(--text);
}

.nav-item.active i {
    background: rgba(94, 224, 164, 0.16);
    color: var(--accent);
}

.nav-menu {
    margin-top: 8px;
}

.nav-menu summary {
    cursor: pointer;
    list-style: none;
    color: #e5ebf2;
    font-weight: 700;
}

.nav-menu summary::-webkit-details-marker {
    display: none;
}

.nav-menu summary::after {
    content: "\f078";
    color: var(--muted);
    font-family: "Font Awesome 6 Free";
    font-size: 10px;
    font-weight: 900;
    transition: transform 140ms ease;
}

.nav-menu[open] summary::after {
    transform: rotate(180deg);
}

.nav-menu > div {
    display: grid;
    gap: 4px;
    margin: 5px 0 0 14px;
    padding: 3px 0 3px 9px;
    border-left: 1px solid var(--line);
}

.nav-item.sub {
    min-height: 34px;
    padding: 5px 7px;
    font-size: 12.5px;
}

.nav-item.sub i {
    width: 25px;
    height: 25px;
    font-size: 12px;
}

.app-main {
    display: grid;
    grid-template-rows: 68px minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
}

.topbar {
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) minmax(240px, 420px) auto;
    gap: 16px;
    align-items: center;
    min-width: 0;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 11, 13, 0.76);
    backdrop-filter: blur(18px);
}

.menu-button {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

.view-title {
    min-width: 0;
}

.view-title span,
.eyebrow {
    color: var(--gold);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.view-title span {
    display: block;
    margin-bottom: 3px;
}

.view-title strong {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 20px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-wrap {
    position: relative;
    min-width: 0;
}

.search-wrap i {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13px;
}

.search-wrap input {
    width: 100%;
    height: 42px;
    padding: 0 13px 0 37px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    outline: none;
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
    font-size: 13px;
}

.search-wrap input::placeholder {
    color: #788391;
}

.search-wrap input:focus {
    border-color: rgba(94, 224, 164, 0.6);
    box-shadow: 0 0 0 3px rgba(94, 224, 164, 0.12);
}

.language-wrap {
    position: relative;
    display: grid;
    align-items: center;
    min-width: 150px;
}

.language-wrap i {
    position: absolute;
    left: 12px;
    color: var(--muted);
    font-size: 13px;
    pointer-events: none;
}

.language-wrap select {
    width: 100%;
    height: 42px;
    padding: 0 34px 0 36px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    outline: none;
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) 18px / 6px 6px no-repeat,
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) 18px / 6px 6px no-repeat,
        rgba(255, 255, 255, 0.045);
    color: var(--text);
    font-size: 13px;
}

.language-wrap select:focus {
    border-color: rgba(104, 184, 255, 0.62);
    box-shadow: 0 0 0 3px rgba(104, 184, 255, 0.12);
}

.language-wrap option {
    background: var(--surface);
    color: var(--text);
}

.language-wrap.custom-select-wrap {
    min-width: 150px;
}

.view-stack {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.view-panel {
    display: none;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
}

.view-panel.active {
    display: block;
}

.view-panel::after {
    content: "";
    display: block;
    height: 24px;
}

.hero-panel,
.panel-head {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(21, 25, 31, 0.88);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 24px;
    align-items: end;
    padding: 28px;
}

.eyebrow {
    margin-bottom: 9px;
}

.hero-panel h1 {
    max-width: 780px;
    margin-bottom: 12px;
    font-size: 42px;
    line-height: 1.05;
}

.hero-panel p:not(.eyebrow),
.panel-head p:not(.eyebrow),
.example-head p,
.api-detail p {
    color: var(--muted);
    line-height: 1.55;
}

.hero-panel p:not(.eyebrow) {
    max-width: 680px;
    margin-bottom: 0;
    font-size: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stats-grid div {
    min-height: 98px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #101318;
}

.stats-grid i {
    color: var(--accent);
    font-size: 17px;
}

.stats-grid strong,
.stats-grid span {
    display: block;
}

.stats-grid strong {
    margin-top: 11px;
    font-size: 28px;
    line-height: 1;
}

.stats-grid span {
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.category-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    min-height: 112px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(21, 25, 31, 0.72);
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.category-card:hover {
    transform: translateY(-1px);
    border-color: rgba(104, 184, 255, 0.34);
    background: rgba(27, 32, 39, 0.92);
}

.category-card > i,
.panel-head > i {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: rgba(104, 184, 255, 0.12);
    color: var(--accent-2);
}

.category-card strong,
.category-card small {
    display: block;
}

.category-card strong {
    margin-bottom: 5px;
    font-size: 15px;
}

.category-card small {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.45;
}

.category-card em {
    min-width: 27px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(94, 224, 164, 0.11);
    color: var(--accent);
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    text-align: center;
}

.panel-head {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    margin-bottom: 14px;
    padding: 18px;
}

.panel-head h2 {
    margin-bottom: 6px;
    font-size: 26px;
    line-height: 1.12;
}

.panel-head p:not(.eyebrow) {
    max-width: 820px;
    margin-bottom: 0;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.example-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(21, 25, 31, 0.76);
}

.example-head h3 {
    margin-bottom: 6px;
    font-size: 17px;
}

.example-head p {
    margin-bottom: 0;
    font-size: 13px;
}

.code-frame {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(104, 184, 255, 0.2);
    border-radius: var(--radius);
    background: #07090c;
}

.code-frame pre {
    min-height: 100%;
    margin: 0;
    padding: 42px 16px 16px;
    overflow-x: auto;
    color: #dbe8f3;
    font-size: 12.5px;
    line-height: 1.65;
}

.copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #141920;
    color: var(--soft);
    font-size: 12px;
}

.copy-button:hover {
    border-color: rgba(104, 184, 255, 0.58);
    color: var(--text);
}

.api-table {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(16, 19, 24, 0.82);
}

.api-row {
    display: grid;
    grid-template-columns: minmax(180px, 0.72fr) minmax(0, 2.1fr) minmax(96px, 0.36fr);
    gap: 14px;
    align-items: start;
    padding: 13px 15px;
    border-bottom: 1px solid var(--line);
}

.api-row:last-child {
    border-bottom: 0;
}

.api-row:hover {
    background: rgba(94, 224, 164, 0.045);
}

.api-name code {
    color: #93d9ff;
    font-weight: 800;
}

.api-name span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.api-detail code {
    display: inline-block;
    margin-bottom: 7px;
    color: #eef7ff;
    overflow-wrap: anywhere;
}

.api-detail p {
    margin-bottom: 0;
    font-size: 13px;
}

.api-return span {
    display: inline-block;
    max-width: 100%;
    padding: 4px 7px;
    border-radius: 6px;
    background: rgba(94, 224, 164, 0.09);
    color: var(--accent);
    font-family: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.constant-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
}

.constant-card {
    display: grid;
    gap: 8px;
    min-height: 74px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(21, 25, 31, 0.76);
}

.constant-card code {
    color: #93d9ff;
    overflow-wrap: anywhere;
}

.constant-card strong {
    color: var(--gold);
    font-size: 18px;
}

.lua-comment {
    color: #7f8b96;
}

.lua-string {
    color: #e8c275;
}

.lua-keyword {
    color: #68b8ff;
    font-weight: 700;
}

.lua-number {
    color: #b79cff;
}

.lua-builtin {
    color: #5ee0a4;
}

.is-hidden {
    display: none !important;
}

.empty-state {
    position: absolute;
    top: 108px;
    left: 24px;
    right: 24px;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    margin: 0;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: rgba(16, 19, 24, 0.94);
    color: var(--muted);
    text-align: center;
}

.empty-state[hidden] {
    display: none !important;
}

.empty-state i {
    color: var(--danger);
}

body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.5);
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(316px, calc(100vw - 38px));
        transform: translateX(-105%);
        transition: transform 170ms ease;
        box-shadow: var(--shadow);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .menu-button {
        display: inline-grid;
        place-items: center;
    }
}

@media (max-width: 980px) {
    .hero-panel {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .category-grid,
    .constant-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .example-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-main {
        grid-template-rows: auto minmax(0, 1fr);
    }

    .topbar {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 10px;
        padding: 10px 12px;
    }

    .search-wrap,
    .language-wrap {
        grid-column: 1 / -1;
    }

    .language-wrap {
        min-width: 0;
    }

    .view-panel {
        padding: 14px;
    }

    .hero-panel,
    .panel-head,
    .example-card {
        padding: 14px;
    }

    .hero-panel h1 {
        font-size: 30px;
    }

    .stats-grid,
    .category-grid,
    .constant-grid {
        grid-template-columns: 1fr;
    }

    .category-card {
        min-height: 0;
    }

    .api-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .empty-state {
        top: 118px;
        left: 14px;
        right: 14px;
    }
}
