:root {
    --bg: #0b0c10;
    --panel: #111218;
    --muted: #a9b0c0;
    --text: #e8ecf1;
    --brand: #7aa2ff;
    --brand-2: #9a7cff;
    --ok: #24c19e;
    --bad: #f76d6d;
    --card: #0f1016;
    --border: rgba(255, 255, 255, .08);
    --shadow: 0 10px 30px rgba(0, 0, 0, .25);
    --radius: 16px;
    --nav-h: 64px;
}

[data-theme="light"] {
    --bg: #f7f8fb;
    --panel: #ffffff;
    --card: #ffffff;
    --text: #0f1222;
    --muted: #5a6272;
    --border: rgba(0, 0, 0, .08);
    --shadow: 0 10px 30px rgba(0, 0, 0, .08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a {
    color: var(--brand);
    text-decoration: none
}

a:hover {
    opacity: .85
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px
}

/* Header / nav */
header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: saturate(180%) blur(12px);
    background: linear-gradient(180deg, rgba(15, 16, 22, .85), rgba(15, 16, 22, .6));
    border-bottom: 1px solid var(--border);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-h)
}

.nav .left {
    display: flex;
    gap: 14px;
    align-items: center
}

.logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: conic-gradient(from 40deg, var(--brand), var(--brand-2));
    box-shadow: var(--shadow)
}

/* Image logo variant */
.logo-img {
    height: 28px;
    width: auto;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: block;
}

.brand {
    font-weight: 700;
    letter-spacing: .2px
}

.nav .right {
    display: flex;
    gap: 8px
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: transform .08s ease, background .2s ease;
    border-bottom-width: 2px
}

.btn:hover {
    transform: translateY(-1px)
}

.btn.primary {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-color: transparent;
    color: white
}

.pill {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px
}

/* horizontally scrollable nav to prevent wrapping / misalignment */
.nav-links {
    max-width: 58vw;
    /* keep left group compact */
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-links::-webkit-scrollbar {
    display: none
}

/* Hero */
.hero {
    padding: 64px 0 28px;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: -200px -40px auto -40px;
    height: 320px;
    background: radial-gradient(600px 220px at 50% 0%, rgba(122, 162, 255, .15), transparent 60%),
        radial-gradient(600px 220px at 30% 0%, rgba(154, 124, 255, .15), transparent 60%);
    pointer-events: none;
    z-index: -1;
}

.title {
    font-size: 40px;
    line-height: 1.15;
    margin: 8px 0 10px;
    font-weight: 800;
    letter-spacing: .2px
}

.subtitle {
    color: var(--muted);
    max-width: 820px;
    margin-bottom: 18px
}

.hero-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 22px
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow)
}

.card h4 {
    margin: 6px 0
}

.badge {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--muted)
}

/* Layout utilities */
section {
    padding: 32px 0;
    border-top: 1px solid var(--border)
}

h2 {
    font-size: 26px;
    margin: 0 0 14px
}

.lead {
    color: var(--muted)
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 20px;
    align-items: start
}

/* align start to avoid misalignment */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px
}

.row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap
}

.figure {
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    color: var(--muted)
}

/* Optional column layout for figures that include captions/badges below the image */
.figure.column { flex-direction: column; gap: 8px }

.chip {
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 8px;
    color: var(--muted)
}

.caption {
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap
}

.tab {
    cursor: pointer;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: transparent;
    color: var(--text)
}

.tab.active {
    background: linear-gradient(135deg, rgba(122, 162, 255, .18), rgba(154, 124, 255, .18));
    border-color: transparent
}

.tab:hover { opacity: .95 }

.tab:focus { outline: 2px solid rgba(122,162,255,.5); outline-offset: 2px }

.tabpanes>div {
    display: none
}

.tabpanes>div.active {
    display: block
}

/* Table */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px
}

th,
td {
    padding: 12px 14px;
    text-align: left
}

thead th {
    font-weight: 700;
    color: var(--muted);
    border-bottom: 1px solid var(--border)
}

tbody tr {
    background: var(--panel);
    border: 1px solid var(--border)
}

tbody tr td:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px
}

tbody tr td:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px
}

.sort {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px
}

/* Mini bars */
.bars {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px
}

.bar {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 10px;
    align-items: center
}

.bar .track {
    height: 10px;
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
    overflow: hidden
}

.bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    width: 0%
}

/* Compare slider */
.compare {
    position: relative;
    isolation: isolate;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    aspect-ratio: 16/9;
    /* fixed ratio to avoid jumping/misalignment */
}

.compare img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover
}

.compare .top {
    position: absolute;
    inset: 0;
    overflow: hidden
}

.compare input[type=range] {
    position: absolute;
    inset: auto 0 10px 0;
    width: 60%;
    margin: 0 auto;
    left: 0;
    right: 0
}

/* Examples images */
.figure img.example {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Smooth hover zoom and responsive max-height for overview/example images */
.figure img.example {
    transition: transform .22s ease, box-shadow .22s ease;
    max-height: 520px;
    object-fit: contain;
}

.figure img.example:hover {
    transform: scale(1.02);
    box-shadow: 0 14px 40px rgba(0,0,0,.35);
}

/* Lightbox */
.lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.lightbox-backdrop.active { display: flex; }

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* Code */
pre {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    overflow: auto
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace
}

/* Floating tools */
.sticky-tools {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50
}

.tooltip {
    position: relative
}

.tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    right: 100%;
    margin-right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--muted);
    white-space: nowrap
}

/* Light theme navbar contrast tweaks */
[data-theme="light"] header {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(140%) blur(6px);
}

[data-theme="light"] .pill:hover {
    background: rgba(0, 0, 0, .04);
}

[data-theme="light"] .btn.ghost {
    background: rgba(0, 0, 0, .035);
    border-color: var(--border);
}

[data-theme="light"] .logo {
    box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
}

[data-theme="light"] header .brand,
[data-theme="light"] header .pill,
[data-theme="light"] header .btn {
    color: var(--text);
}

/* Responsive */
@media (max-width:940px) {
    .hero-cards {
        grid-template-columns: 1fr
    }

    .grid-2 {
        grid-template-columns: 1fr
    }

    header .brand {
        display: none
    }

    .nav-links {
        max-width: 50vw;
    }
}