:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-strong: #ffffff;
    --text: #171717;
    --muted: #5f615b;
    --line: #171717;
    --primary: #ffe05c;
    --primary-strong: #171717;
    --primary-soft: #fff1a6;
    --accent: #e84f2f;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --block-text-color: #171717;
    --block-background-color: #ffffff;
    --block-accent-color: #ffe05c;
    --block-shadow-color: #171717;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111111;
    --surface: #181818;
    --surface-strong: #202020;
    --text: #fff8df;
    --muted: #c5bea6;
    --line: #fff8df;
    --primary: #7cf0c3;
    --primary-strong: #fff8df;
    --primary-soft: #224f42;
    --accent: #ffb86b;
    --block-text-color: #fff8df;
    --block-background-color: #181818;
    --block-accent-color: #7cf0c3;
    --block-shadow-color: #fff8df;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
}

body,
button,
input,
select {
    font: inherit;
}

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

button,
select,
input {
    border: 0;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

::selection {
    background: var(--primary);
    color: #171717;
}

:root[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text);
}

:root[data-theme="dark"] .block {
    --block-background-color: var(--surface);
    --block-text-color: var(--text);
    --block-shadow-color: var(--line);
}

.site-shell {
    min-height: calc(100vh - 92px);
}

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

.nav-wrap,
.footer-wrap,
.search-page,
.docs-page,
.stats-page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    gap: 20px;
}

.brand,
.nav-actions,
.footer-links,
.result-topline,
.metric-list {
    display: flex;
    align-items: center;
}

.brand {
    min-width: 0;
    gap: 10px;
    font-weight: 760;
}

.brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    background: var(--text);
    color: var(--bg);
    font-size: 0.9rem;
}

.nav-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.nav-link {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 650;
}

.nav-link:hover,
.footer-links a:hover,
.result-card h3 a:hover,
.text-link {
    color: var(--primary-strong);
}

.text-link {
    font-weight: 760;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.theme-toggle {
    display: grid;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    place-items: center;
    background: var(--surface);
    color: var(--text);
}

.theme-toggle svg {
    color: currentColor;
    stroke: currentColor;
}

.theme-toggle__sun {
    display: block;
}

.theme-toggle__moon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle {
    background: #fff8df !important;
    color: #111111 !important;
    border-color: #fff8df !important;
}

:root[data-theme="dark"] .theme-toggle__sun {
    display: none !important;
}

:root[data-theme="dark"] .theme-toggle__moon {
    display: block !important;
    color: #fff8df !important;
    stroke: #fff8df !important;
}

:root[data-theme="dark"] .theme-toggle__moon path {
    stroke: #fff8df !important;
    fill: none !important;
}

.search-page,
.docs-page,
.stats-page {
    padding: 56px 0 72px;
}

.hero-section {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1.05fr);
    gap: 32px;
    align-items: end;
}

.docs-hero {
    max-width: 760px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 780;
    text-transform: uppercase;
}

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

h1 {
    max-width: 720px;
    margin-bottom: 18px;
    font-size: clamp(2.7rem, 6vw, 5.2rem);
    line-height: 0.95;
    letter-spacing: 0;
}

.hero-lede {
    max-width: 620px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 1.08rem;
}

.search-panel,
.empty-state,
.start-state,
.result-card,
.docs-card,
.stat-card {
    min-width: 0;
    background: var(--surface);
    color: var(--text);
}

.search-panel {
    overflow: hidden;
    padding: 22px;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 14px;
    align-items: end;
}

.search-input-wrap,
.field {
    display: grid;
    min-width: 0;
    gap: 8px;
}

.search-input-wrap:focus-within,
.field:focus-within {
    outline: none;
}

.control-label,
.field span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.search-input-wrap input,
.field input,
.field select {
    width: 100%;
    min-width: 0;
    border: 2px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
}

.search-input-wrap input {
    height: 52px;
    padding: 0 16px;
}

.field input,
.field select {
    height: 46px;
    padding: 0 14px;
}

.primary-action {
    height: 52px;
    padding: 0 22px;
    background: var(--primary);
    color: #171717;
    font-weight: 760;
    white-space: nowrap;
}

.filter-grid {
    display: grid;
    grid-template-columns: minmax(170px, 1.35fr) minmax(170px, 1.35fr) repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.field select {
    color-scheme: light;
    appearance: auto;
}

.field select option {
    background: #ffffff;
    color: #171717;
}

:root[data-theme="dark"] .search-panel,
:root[data-theme="dark"] .start-state,
:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .result-card,
:root[data-theme="dark"] .docs-card,
:root[data-theme="dark"] .stat-card {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

:root[data-theme="dark"] .control-label,
:root[data-theme="dark"] .field span,
:root[data-theme="dark"] .hero-lede,
:root[data-theme="dark"] .metric-list dt,
:root[data-theme="dark"] .rating-pill,
:root[data-theme="dark"] .footer-wrap,
:root[data-theme="dark"] .nav-link {
    color: var(--muted) !important;
}

:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .search-input-wrap input {
    border-color: var(--line) !important;
    background: var(--surface-strong) !important;
    color: var(--text) !important;
}

:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field select option {
    color-scheme: dark;
    background: var(--surface-strong) !important;
    color: var(--text) !important;
}

.loading-line {
    position: relative;
    height: 3px;
    margin-top: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--primary-soft);
}

.loading-line span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 42%;
    border-radius: inherit;
    background: var(--primary);
    animation: loading-line 1.05s ease-in-out infinite;
}

@keyframes loading-line {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(240%);
    }
}

.results-section {
    margin-top: 44px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.section-heading h2,
.start-state h2,
.empty-state h3 {
    margin-bottom: 0;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    line-height: 1.1;
}

.result-count {
    flex: 0 0 auto;
    padding: 8px 12px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 0.88rem;
    font-weight: 760;
}

.result-grid,
.docs-grid,
.stat-grid,
.severity-grid,
.stats-sections {
    display: grid;
    gap: 16px;
}

.result-grid,
.docs-grid,
.stats-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.severity-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.result-card {
    display: grid;
    grid-template-columns: 124px minmax(0, 1fr);
    min-height: 164px;
    overflow: hidden;
}

.thumb-link {
    display: block;
    min-height: 100%;
    background: var(--primary-soft);
}

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

.result-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    padding: 16px;
}

.result-topline {
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.type-pill,
.rating-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 760;
}

.type-pill {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.rating-pill {
    color: var(--muted);
}

.result-card h3 {
    margin-bottom: 18px;
    font-size: 1.12rem;
    line-height: 1.25;
}

.metric-list {
    justify-content: space-between;
    gap: 14px;
    margin: 0;
}

.metric-list dt {
    color: var(--muted);
    font-size: 0.73rem;
    font-weight: 700;
}

.metric-list dd {
    margin: 2px 0 0;
    font-weight: 760;
}

.empty-state,
.start-state {
    padding: 34px;
    text-align: center;
}

.empty-state p,
.start-state p {
    max-width: 500px;
    margin: 10px auto 0;
    color: var(--muted);
}

.start-icon {
    display: inline-grid;
    width: 52px;
    height: 52px;
    place-items: center;
    margin-bottom: 16px;
    background: var(--text);
    color: var(--bg);
    font-weight: 800;
}

:root[data-theme="dark"] .start-icon {
    background: var(--text) !important;
    color: var(--bg) !important;
}

.docs-card {
    margin-bottom: 16px;
    padding: 24px;
}

.docs-page,
.docs-page * {
    user-select: text;
}

.docs-card h2 {
    margin-bottom: 14px;
    font-size: 1.45rem;
}

.docs-card p:last-child {
    margin-bottom: 0;
}

.docs-card pre {
    max-width: 100%;
    overflow-x: auto;
    margin: 0 0 14px;
    padding: 16px;
    border: 2px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
}

.docs-card code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.9em;
    user-select: text;
}

.code-tab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.code-tab {
    min-height: 40px;
    padding: 0 16px;
    color: var(--text);
    font-weight: 760;
}

.code-tab.is-active {
    background: var(--primary);
    color: #171717;
}

.code-panel[hidden] {
    display: none;
}

.docs-table-wrap,
.vulnerability-table-wrap {
    overflow-x: auto;
}

.docs-table {
    width: 100%;
    border-collapse: collapse;
}

.docs-table th,
.docs-table td {
    padding: 14px;
    border: 2px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.docs-table th {
    background: var(--primary-soft);
}

:root[data-theme="dark"] .docs-card pre,
:root[data-theme="dark"] .docs-table th,
:root[data-theme="dark"] .docs-table td {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

:root[data-theme="dark"] .docs-card pre {
    background: var(--surface-strong) !important;
}

:root[data-theme="dark"] .docs-table th {
    background: var(--primary-soft) !important;
}

.stat-card {
    padding: 24px;
}

.stat-card span {
    display: block;
    margin-bottom: 6px;
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 860;
    line-height: 1;
}

.stat-card p {
    margin: 0;
    color: var(--muted);
    font-weight: 760;
}

.severity-item,
.stat-list-item {
    border: 2px solid var(--line);
    background: var(--surface-strong);
}

.severity-item {
    padding: 16px;
}

.severity-item span,
.severity-item strong {
    display: block;
}

.severity-item span {
    margin-bottom: 8px;
    color: var(--muted);
    font-weight: 760;
}

.severity-item strong {
    font-size: 1.45rem;
}

.stat-list {
    display: grid;
    gap: 12px;
}

.stat-list-item {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-width: 0;
    padding: 10px;
}

.stat-list-item img {
    width: 58px;
    height: 58px;
    object-fit: cover;
    background: var(--primary-soft);
}

.stat-list-item span {
    min-width: 0;
    overflow: hidden;
    font-weight: 760;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-list-item strong {
    color: var(--muted);
    font-size: 0.86rem;
    white-space: nowrap;
}

:root[data-theme="dark"] .severity-item,
:root[data-theme="dark"] .stat-list-item {
    background: var(--surface-strong) !important;
    color: var(--text) !important;
    border-color: var(--line) !important;
}

.pagination-nav {
    margin-top: 24px;
}

.pagination-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 0;
    margin: 0;
    list-style: none;
}

.page-button {
    display: grid;
    min-width: 40px;
    height: 40px;
    place-items: center;
    padding: 0 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 720;
}

.page-button:hover:not(:disabled),
.page-button.is-active {
    background: var(--primary);
    color: #171717;
}

.page-button:disabled,
.page-gap {
    opacity: 0.48;
}

.site-footer {
    border-top: 1px solid var(--line);
}

.footer-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 92px;
    color: var(--muted);
    font-size: 0.9rem;
}

.footer-wrap p {
    margin: 0;
}

.footer-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.footer-links a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .hero-section,
    .filter-grid,
    .result-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .site-header {
        position: static;
    }

    .nav-wrap {
        align-items: stretch;
        flex-direction: column;
        min-height: 0;
        padding: 12px 0;
        gap: 12px;
    }

    .brand,
    .nav-actions {
        justify-content: center;
        width: 100%;
    }

    .nav-actions {
        gap: 8px;
    }

    .nav-link {
        font-size: 0.9rem;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
    }

    .search-page,
    .docs-page,
    .stats-page {
        padding-top: 34px;
        padding-bottom: 48px;
    }

    .search-panel,
    .docs-card,
    .stat-card,
    .empty-state,
    .start-state {
        padding: 18px;
    }

    .search-row,
    .filter-grid,
    .result-grid,
    .result-card,
    .docs-grid,
    .stat-grid,
    .severity-grid,
    .stats-sections {
        grid-template-columns: 1fr;
    }

    .primary-action {
        width: 100%;
    }

    .docs-card pre {
        padding: 12px;
        font-size: 0.82rem;
    }

    .docs-table th,
    .docs-table td {
        padding: 10px;
        font-size: 0.88rem;
    }

    .code-tab {
        flex: 1 1 auto;
        min-width: 92px;
        padding: 0 10px;
    }
}

@media (max-width: 640px) {
    .nav-wrap,
    .footer-wrap,
    .search-page,
    .docs-page,
    .stats-page {
        width: min(100% - 24px, 1120px);
    }

    h1 {
        font-size: 2.25rem;
        line-height: 1;
    }

    .thumb-link {
        aspect-ratio: 16 / 9;
    }

    .result-body {
        padding: 14px;
    }

    .result-topline,
    .metric-list,
    .section-heading,
    .footer-wrap {
        align-items: flex-start;
        flex-direction: column;
    }

    .metric-list {
        gap: 10px;
    }

    .footer-wrap {
        align-items: center;
        gap: 10px;
        min-height: 0;
        padding: 20px 0;
        text-align: center;
    }

    .footer-wrap p {
        width: 100%;
        line-height: 1.4;
    }

    .footer-links {
        display: flex;
        flex-wrap: nowrap;
        justify-content: center;
        width: 100%;
        gap: 14px;
        overflow-x: auto;
        padding: 2px 0 6px;
        scrollbar-width: none;
    }

    .footer-links::-webkit-scrollbar {
        display: none;
    }

    .footer-links a {
        flex: 0 0 auto;
        min-height: 28px;
        font-size: 0.88rem;
    }
}

@media (max-width: 420px) {
    .nav-wrap,
    .footer-wrap,
    .search-page,
    .docs-page,
    .stats-page {
        width: min(100% - 18px, 1120px);
    }

    .nav-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr)) 38px;
        align-items: center;
    }

    .nav-link {
        overflow: hidden;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    h1 {
        font-size: 2rem;
    }

    .hero-lede {
        font-size: 0.98rem;
    }

    .search-panel,
    .docs-card,
    .stat-card,
    .empty-state,
    .start-state {
        padding: 14px;
    }

    .stat-list-item {
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 10px;
    }

    .stat-list-item img {
        width: 44px;
        height: 44px;
    }

    .stat-list-item strong {
        grid-column: 2;
    }

    .page-button {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
    }
}
