html:not([data-page="site"]) {
    --accent: #e8e4dc;
    --accent-hover: #d6d1c6;
    --accent-contrast: #050505;
    --bg: #050505;
    --line: rgba(255, 255, 255, 0.1);
    --muted: #9ca3af;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    color-scheme: dark;
}

html:not([data-page="site"]) *,
html:not([data-page="site"]) *::before,
html:not([data-page="site"]) *::after {
    box-sizing: border-box;
}

html:not([data-page="site"]) {
    background: var(--bg);
}

html:not([data-page="site"]) body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(60rem 40rem at 15% -10%, rgba(127, 217, 63, 0.09), transparent 60%),
        radial-gradient(50rem 35rem at 110% 10%, rgba(232, 228, 220, 0.05), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

html:not([data-page="site"]) [hidden] {
    display: none !important;
}

html:not([data-page="site"]) button,
html:not([data-page="site"]) input {
    font: inherit;
}

.ghost-button {
    white-space: nowrap;
    height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: #e5e7eb;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}

.ghost-button:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.page {
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
    padding: 8rem 1.5rem 6rem;
}

.library__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.library__top .eyebrow {
    margin: 0;
}

.eyebrow {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.display {
    margin: 0;
    font-size: clamp(3.5rem, 12vw, 9rem);
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 0.9;
    background: linear-gradient(to bottom, #fff, #9ca3af);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lede {
    max-width: 38rem;
    margin: 1.5rem 0 0;
    color: #d1d5db;
    font-size: 1.05rem;
    font-weight: 300;
    line-height: 1.7;
}

.login {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 12rem);
}

.login__card {
    width: 100%;
    max-width: 34rem;
    padding: 2.5rem 2rem;
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.045);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 24px 70px -20px rgba(0, 0, 0, 0.8);
}

.login__card .display {
    font-size: clamp(3rem, 10vw, 5rem);
}

.login__form {
    display: grid;
    gap: 1.1rem;
    margin-top: 2rem;
}

.field {
    display: grid;
    gap: 0.5rem;
}

.field__label {
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.field__input {
    width: 100%;
    height: 3rem;
    padding: 0 1rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0.85rem;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 1rem;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
    transition: border-color 0.3s, background-color 0.3s;
}

.field__input:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.5);
}

.check {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #d1d5db;
    font-size: 0.9rem;
    cursor: pointer;
}

.check input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--accent);
}

.consent-gate__more {
    justify-self: center;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.3s;
}

.consent-gate__more:hover {
    color: #f5f5f4;
}

.login__error {
    min-height: 1.25rem;
    margin: 0;
    color: #fca5a5;
    font-size: 0.9rem;
}

.primary-button {
    height: 3.25rem;
    border: 0;
    background: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, opacity 0.3s;
}

.primary-button:hover {
    background: var(--accent-hover);
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.6);
}

.primary-button:disabled {
    opacity: 0.6;
    cursor: progress;
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.chip:focus-visible,
.doc:focus-visible,
.reader__close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.library__head {
    margin-bottom: 3rem;
}

.library__tools {
    position: sticky;
    top: 5rem;
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin: 0 -1.5rem 2rem;
    padding: 1rem 1.5rem;
    background: rgba(5, 5, 5, 0.92);
    box-shadow: 0 0 0 100vmax rgba(5, 5, 5, 0.92);
    clip-path: inset(0 -100vmax);
}

.search {
    position: relative;
    flex: 1 1 18rem;
    max-width: 26rem;
}

.search svg {
    position: absolute;
    top: 50%;
    left: 1rem;
    width: 1.1rem;
    height: 1.1rem;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 2.9rem;
    padding: 0 1rem 0 2.75rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
    transition: border-color 0.3s;
}

.search input:focus {
    border-color: var(--accent);
}

.chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

.chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex: none;
    height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: #d1d5db;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s, color 0.3s;
}

.chip:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.chip[aria-selected="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
}

.library__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
    gap: 1.25rem;
    align-items: start;
}

.subject {
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    background: rgba(255, 255, 255, 0.035);
    overflow: hidden;
}

.subject__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.4rem 1.5rem;
    cursor: pointer;
    outline: none;
    transition: background-color 0.3s;
}

.subject__head:hover {
    background: rgba(255, 255, 255, 0.04);
}

.subject__head:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent);
    border-radius: 1.5rem;
}

.subject__meta {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.subject__chevron {
    width: 1.1rem;
    height: 1.1rem;
    color: var(--muted);
    transition: transform 0.45s var(--ease), color 0.3s;
}

.subject__head:hover .subject__chevron,
.subject.is-open .subject__chevron {
    color: #fff;
}

.subject.is-open .subject__chevron {
    transform: rotate(180deg);
}

.subject__title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.subject__count {
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
}

.subject__list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--line);
}

.subject__list li + li {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.doc {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem 1.5rem;
    color: #e5e7eb;
    text-decoration: none;
    transition: background-color 0.3s, color 0.3s;
}

a.doc:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.doc__icon {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.6rem;
    color: var(--muted);
    transition: border-color 0.3s, color 0.3s, background-color 0.3s;
}

.doc__icon svg {
    width: 1rem;
    height: 1rem;
}

a.doc:hover .doc__icon {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-contrast);
}

.doc__title {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
}

.doc__tag {
    flex: none;
    color: var(--muted);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.doc--soon {
    opacity: 0.45;
    cursor: default;
}

.library__empty,
.status {
    margin: 3rem 0;
    color: var(--muted);
    text-align: center;
}

.reader {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    background: #0a0a0a;
}

.reader__bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: #050505;
}

.reader__close {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 2.25rem;
    padding: 0 1rem 0 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: #e5e7eb;
    font-size: 0.85rem;
    cursor: pointer;
}

.reader__close svg {
    width: 1rem;
    height: 1rem;
}

.reader__meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.reader__category {
    color: var(--muted);
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

.reader__title {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader__view {
    flex: 1;
    min-height: 0;
}

@media (min-width: 768px) {
    .page {
        padding: 9rem 3rem 8rem;
    }

    .library__tools {
        top: 5.25rem;
        margin: 0 -3rem 2.5rem;
        padding: 1rem 3rem;
    }

    .login__card {
        padding: 3rem;
    }
}
