:root {
    color-scheme: dark;
    --bg: #08090d;
    --bg-2: #11131a;
    --panel: rgba(18, 21, 29, 0.92);
    --panel-2: rgba(24, 29, 38, 0.94);
    --line: rgba(255, 255, 255, 0.13);
    --line-strong: rgba(255, 255, 255, 0.23);
    --text: #f5f7fb;
    --muted: #98a1b3;
    --muted-2: #c0c7d5;
    --accent: #2cf296;
    --accent-2: #2cb5ff;
    --danger: #ff4d68;
    --warning: #ffb547;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
    --radius: 8px;
    --radius-sm: 6px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(135deg, var(--bg), var(--bg-2));
    font-family: var(--font);
    letter-spacing: 0;
}

a {
    color: inherit;
}

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

button {
    cursor: pointer;
}

img {
    display: block;
    max-width: 100%;
}

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

h1 {
    font-size: clamp(2.2rem, 7vw, 5.8rem);
    line-height: 0.95;
}

h2 {
    font-size: clamp(1.35rem, 3vw, 2.5rem);
    line-height: 1.05;
}

h3 {
    font-size: 1rem;
}

p {
    line-height: 1.65;
}

.site-header {
    position: sticky;
    top: 12px;
    z-index: 20;
    width: min(1440px, calc(100% - 32px));
    margin: 14px auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel), transparent 4%);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.site-logo,
.site-nav,
.admin-access-row,
.admin-user-main,
.admin-badges,
.status-row,
.footer-links {
    display: flex;
    align-items: center;
}

.site-logo {
    gap: 10px;
    text-decoration: none;
    font-weight: 800;
}

.site-logo-bars {
    width: 34px;
    height: 34px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 6px;
    border: 1px solid color-mix(in srgb, var(--accent), transparent 40%);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 16px color-mix(in srgb, var(--accent), transparent 62%);
}

.site-logo-bars i {
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}

.site-logo-bars i:nth-child(1) {
    height: 50%;
    align-self: end;
}

.site-logo-bars i:nth-child(2) {
    height: 100%;
}

.site-logo-bars i:nth-child(3) {
    height: 70%;
    align-self: end;
    background: var(--accent-2);
    box-shadow: 0 0 12px var(--accent-2);
}

.site-nav {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-nav a,
.site-secondary,
.text-button,
.status-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
    padding: 8px 11px;
    text-decoration: none;
    line-height: 1.1;
}

.site-nav a.active,
.site-nav a:hover,
.site-secondary:hover,
.text-button:hover,
.status-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.site-primary {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-sm);
    color: #06100b;
    background: var(--accent);
    box-shadow: 0 0 22px color-mix(in srgb, var(--accent), transparent 55%);
    font-weight: 800;
    padding: 10px 14px;
    text-decoration: none;
}

.site-primary.full {
    width: 100%;
}

.detail-hero p,
.site-section-heading p {
    color: var(--muted-2);
}

.site-eyebrow {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.1;
}

figcaption a {
    color: var(--accent);
}

.detail-hero,
.detail-grid,
.admin-public-shell,
.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 14px auto 0;
}

.admin-public-shell,
.site-footer {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: clamp(18px, 4vw, 36px);
}

.site-section-heading {
    max-width: 780px;
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

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

.feature-grid article,
.detail-grid article,
.term-table article,
.library-row,
.record-field,
.empty-state,
.admin-denied,
.admin-stat,
.admin-user-card,
.admin-editor {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel-2), transparent 4%);
    padding: 14px;
}

.feature-grid article {
    min-height: 190px;
}

.feature-grid article,
.detail-grid article,
.term-table article,
.library-row,
.record-field,
.empty-state,
.source-links,
.library-row-main {
    min-width: 0;
    overflow-wrap: anywhere;
}

.feature-grid span {
    display: inline-flex;
    color: var(--accent);
    margin-bottom: 20px;
    font-weight: 800;
}

.feature-grid p,
.detail-grid p,
.term-table p,
.details-line,
.timeline-meta {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.term-table {
    display: grid;
    gap: 10px;
}

.term-table article {
    display: grid;
    grid-template-columns: minmax(180px, 0.34fr) minmax(0, 0.4fr) minmax(0, 0.4fr) auto;
    gap: 12px;
    align-items: start;
}

.term-table span {
    color: var(--accent);
    font-size: 0.78rem;
}

.term-table a,
.source-links a {
    color: var(--accent);
    text-decoration: none;
}

.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.source-links a {
    border: 1px solid var(--line);
    border-radius: 999px;
    max-width: 100%;
    padding: 4px 8px;
    font-size: 0.78rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

.library-list {
    display: grid;
    gap: 10px;
}

.library-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
}

.library-row-main {
    display: grid;
    gap: 7px;
}

.library-row-main h3 {
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.library-row-main p,
.record-field p,
.empty-state p {
    color: var(--muted);
    font-size: 0.9rem;
}

.library-row-meta,
.record-meta,
.record-actions,
.library-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.library-row-meta {
    min-width: 0;
}

.library-row-meta span,
.record-meta span {
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted-2);
    background: rgba(255, 255, 255, 0.035);
    padding: 5px 8px;
    font-size: 0.76rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.library-row-actions {
    justify-content: flex-end;
    min-width: 0;
}

.record-shell {
    display: grid;
    gap: 16px;
}

.record-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.record-heading > div:first-child {
    display: grid;
    gap: 10px;
    min-width: 0;
    max-width: 820px;
}

.record-heading h1 {
    overflow-wrap: anywhere;
}

.record-actions {
    justify-content: flex-end;
}

.record-meta {
    min-width: 0;
}

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

.record-field {
    display: grid;
    gap: 8px;
}

.record-field.wide {
    grid-column: 1 / -1;
}

.record-field > span {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
}

.empty-state {
    display: grid;
    gap: 8px;
}

.library-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: end;
    margin: 12px 0 18px;
}

.library-search label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.library-search input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel-2), transparent 6%);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
}

.library-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 76%);
    outline: none;
}

.library-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.library-stats article {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel-2), transparent 6%);
    padding: 12px;
}

.library-stats strong {
    display: block;
    color: var(--accent);
    font-size: 1.4rem;
}

.library-stats span {
    color: var(--muted);
    font-size: 0.82rem;
}

.detail-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
    gap: 18px;
    align-items: center;
}

.detail-hero > div {
    display: grid;
    gap: 14px;
}

.detail-hero {
    align-items: center;
}

.detail-hero figure {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.detail-hero img {
    width: 100%;
    height: 480px;
    object-fit: cover;
}

figcaption {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.35;
    padding: 10px;
}

.site-field,
.field {
    display: grid;
    gap: 6px;
}

.site-field span,
.field span {
    color: var(--muted-2);
    font-size: 0.76rem;
    line-height: 1;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--panel-2), transparent 8%);
    padding: 9px 10px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 78%);
}

.admin-access-row {
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.admin-access-row .site-field {
    width: min(360px, 100%);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.admin-stat span {
    display: block;
    color: var(--muted);
    font-size: 0.76rem;
    margin-bottom: 8px;
}

.admin-stat strong {
    font-size: 1.5rem;
}

.admin-source-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel-2), transparent 5%);
    padding: 14px;
    margin-bottom: 14px;
}

.admin-source-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px auto;
    gap: 10px;
    align-items: end;
}

.source-refresh-result {
    color: var(--muted);
    font-size: 0.88rem;
    margin-top: 12px;
}

.source-refresh-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.source-refresh-list article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel), transparent 10%);
    display: grid;
    gap: 4px;
    padding: 10px;
}

.source-refresh-list span,
.source-refresh-list small {
    color: var(--muted);
}

.admin-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    gap: 12px;
    align-items: start;
}

.admin-user-list {
    display: grid;
    gap: 9px;
    max-height: 680px;
    overflow: auto;
    padding-right: 4px;
}

.admin-user-card {
    display: grid;
    gap: 10px;
}

.admin-user-main {
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.admin-badges,
.status-row {
    gap: 7px;
    flex-wrap: wrap;
}

.admin-badges {
    justify-content: flex-end;
}

.admin-user-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.admin-user-metrics span,
.badge {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted-2);
    padding: 4px 8px;
    font-size: 0.76rem;
}

.badge.active,
.badge.admin {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent), transparent 50%);
}

.badge.inactive {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger), transparent 50%);
}

.badge.member {
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning), transparent 50%);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.form-grid {
    display: grid;
    gap: 10px;
}

.form-grid.two {
    grid-template-columns: 1fr 1fr;
}

.field.wide {
    grid-column: 1 / -1;
}

.danger-action {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger), transparent 55%);
}

.status-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.site-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    max-width: min(360px, calc(100vw - 36px));
    padding: 12px 14px;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    transform: translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.site-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.site-footer p {
    color: var(--muted);
}

.footer-links {
    gap: 10px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
}

@media (max-width: 1020px) {
    .site-header,
    .site-footer,
    .footer-links {
        align-items: stretch;
        flex-direction: column;
    }

    .site-nav {
        justify-content: flex-start;
    }

    .feature-grid,
    .detail-grid,
    .admin-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-hero,
    .admin-layout,
    .admin-source-form {
        grid-template-columns: 1fr;
    }

    .detail-hero.reverse figure {
        order: 2;
    }
}

@media (max-width: 640px) {
    .site-header,
    .detail-hero,
    .detail-grid,
    .admin-public-shell,
    .site-footer {
        width: min(100% - 20px, 620px);
    }

    .feature-grid,
    .detail-grid,
    .admin-stats,
    .library-stats,
    .form-grid.two {
        grid-template-columns: 1fr;
    }

    .library-search {
        grid-template-columns: 1fr;
    }

    .library-row,
    .record-detail-grid {
        grid-template-columns: 1fr;
    }

    .admin-access-row,
    .admin-user-main,
    .panel-heading,
    .record-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .record-actions,
    .library-row-actions {
        justify-content: flex-start;
    }

    .admin-badges {
        justify-content: flex-start;
    }

    .term-table article {
        grid-template-columns: 1fr;
    }

    .detail-hero img {
        height: 320px;
    }
}
