*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light dark;
}

body {
    margin: 0;
    padding: 0;
    background: #0f172a;
    color: #e5e7eb;
}

.page {
    max-width: 1120px;
    /* wider so hashes wrap less often */
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem;
}

.subtitle {
    color: #9ca3af;
    font-size: 0.95rem;
}

/* Always vertical: featured first, history underneath */
.grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.card {
    background: rgba(15, 23, 42, 0.9);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.8);
}

.card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.beta-heading {
    margin-top: 0.5rem;
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-left: 0.5rem;
}

.tag-stable {
    background: #22c55e33;
    color: #bbf7d0;
    border: 1px solid #22c55e;
}

.tag-beta {
    background: #f9731633;
    color: #fed7aa;
    border: 1px solid #f97316;
}

.muted {
    color: #9ca3af;
    font-size: 0.85rem;
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.05s ease,
        box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
    background: #38bdf8;
    color: #0f172a;
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.35);
}

.btn-primary:hover {
    background: #0ea5e9;
    transform: translateY(-1px);
    box-shadow: 0 16px 35px rgba(56, 189, 248, 0.45);
}

.btn-secondary {
    background: transparent;
    color: #e5e7eb;
    border-color: #4b5563;
}

.btn-secondary:hover {
    border-color: #9ca3af;
    background: rgba(31, 41, 55, 0.8);
}

.btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
}

.version-line {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.divider {
    border-color: rgba(55, 65, 81, 0.8);
    margin: 1rem 0;
}

/* History card & table */

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.history-filters {
    display: flex;
    gap: 0.35rem;
    font-size: 0.8rem;
}

.filter-chip {
    border-radius: 999px;
    border: 1px solid #4b5563;
    background: transparent;
    color: #e5e7eb;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    font-size: 0.78rem;
}

.filter-chip:hover {
    border-color: #9ca3af;
    background: rgba(31, 41, 55, 0.8);
}

.filter-chip-active {
    background: #4b5563;
    border-color: #9ca3af;
}

.history-card {
    overflow: hidden;
}

.history-table-wrap {
    margin-top: 0.75rem;
    overflow-x: auto;
    /* safety net on small screens */
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

th,
td {
    padding: 0.4rem 0.4rem;
    border-bottom: 1px solid rgba(55, 65, 81, 0.8);
    text-align: left;
}

th {
    font-weight: 600;
    color: #d1d5db;
    font-size: 0.8rem;
}

tr:last-child td {
    border-bottom: none;
}

/* prevent date column wrapping where possible */
.rh-date {
    white-space: nowrap;
}

/* channel pills */

.pill {
    display: inline-flex;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.7);
    color: #e5e7eb;
}

.pill-beta {
    border-color: #f97316;
    color: #fed7aa;
}

.pill-stable {
    border-color: #22c55e;
    color: #bbf7d0;
}

.footer-note {
    font-size: 0.75rem;
}

.error {
    margin-top: 0.5rem;
    color: #fecaca;
    font-size: 0.8rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid rgba(148, 163, 184, 0.5);
    border-top-color: #38bdf8;
    animation: spin 0.9s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* Hash display */

.hash-line {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: #9ca3af;
}

.hash-label {
    font-weight: 500;
}

.hash-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    word-break: break-all;
    font-size: 0.74rem;
}

.hash-lines {
    display: none;
}

/* when body has .show-hashes, reveal all hash sections */
.show-hashes .hash-lines {
    display: block;
}

.options-row {
    margin-bottom: 1rem;
    display: flex;
    justify-content: flex-end;
}

.hash-toggle {
    font-size: 0.78rem;
    color: #9ca3af;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;

    /* add prefixes for older browsers */
    -webkit-user-select: none;
    /* Safari / iOS Safari */
    -moz-user-select: none;
    /* old Firefox */
    -ms-user-select: none;
    /* old IE / Edge */
    user-select: none;
}

.hash-toggle input {
    accent-color: #38bdf8;
}

.note-signing {
    margin-top: 0.9rem;
    font-size: 0.75rem;
}

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

.header-left {
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.auth-status {
    color: #9ca3af;
}

.btn-auth {
    border-color: #4b5563;
    background: rgba(15, 23, 42, 0.8);
    padding-inline: 0.9rem;
}

.btn-auth:hover {
    border-color: #9ca3af;
    background: rgba(31, 41, 55, 0.9);
}

/* === Site-wide header (Pukka-J Support) =================== */
.site-auth {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.auth-status {
    color: #9ca3af;
    max-width: 260px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.btn-auth {
    border-color: #4b5563;
    background: rgba(15, 23, 42, 0.8);
    padding-inline: 0.9rem;
}

.btn-auth:hover {
    border-color: #9ca3af;
    background: rgba(31, 41, 55, 0.9);
}

/* === Site-wide header ====================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: #020617;
    border-bottom: 1px solid #1f2937;
}

.site-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0.6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    color: #e5e7eb;
}

.site-logo {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: radial-gradient(circle at 25% 20%, #38bdf8, #a3e635);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #020617;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    margin-left: 1.5rem;
    flex-wrap: wrap;
}

.site-nav a {
    color: #9ca3af;
    text-decoration: none;
    padding-bottom: 0.15rem;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover {
    color: #e5e7eb;
    border-bottom-color: #38bdf8;
}

.site-nav a.site-nav-active {
    color: #f9fafb;
    border-bottom-color: #a3e635;
}

/* Account area / pill */

.site-auth {
    margin-left: auto;
    position: relative;
    display: flex;
    align-items: center;
}

.account-pill {
    border-radius: 999px;
    border: 1px solid #4b5563;
    background: #020617;
    color: #e5e7eb;
    padding: 0.3rem 0.95rem;
    font-size: 0.8rem;
    cursor: pointer;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-pill.account-signed-in {
    border-color: #22c55e;
}

/* Dropdown menu for account */

.account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 240px;
    padding: 0.75rem 0.85rem 0.7rem;
    border-radius: 0.75rem;
    background: #020617;
    border: 1px solid #1f2937;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
    display: none;
}

.account-menu-inner {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.account-menu-primary {
    font-size: 0.85rem;
    color: #e5e7eb;
    font-weight: 500;
}

.account-menu-secondary {
    font-size: 0.78rem;
    color: #9ca3af;
}

.account-menu-actions {
    margin-top: 0.4rem;
    display: flex;
    justify-content: flex-end;
}

.account-menu-actions .btn {
    font-size: 0.8rem;
    padding-inline: 0.85rem;
}

/* When menu is open */
.site-auth.menu-open .account-menu {
    display: block;
}

/* Hamburger button */

.site-menu-toggle {
    display: none;
    /* shown only on mobile */
    position: relative;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.6rem;
    border: 1px solid #4b5563;
    background: #020617;
    padding: 0;
    margin-left: auto;
    cursor: pointer;
}

/* three horizontal bars */
.site-menu-toggle span {
    position: absolute;
    left: 0.55rem;
    right: 0.55rem;
    height: 2px;
    border-radius: 999px;
    background: #e5e7eb;
    transition: transform 0.15s ease, opacity 0.15s ease, top 0.15s ease;
}

.site-menu-toggle span:nth-child(1) {
    top: 0.75rem;
}

.site-menu-toggle span:nth-child(2) {
    top: 1.15rem;
}

.site-menu-toggle span:nth-child(3) {
    top: 1.55rem;
}

/* X state when menu open */
.site-header.is-open .site-menu-toggle span:nth-child(1) {
    top: 1.15rem;
    transform: rotate(45deg);
}

.site-header.is-open .site-menu-toggle span:nth-child(2) {
    opacity: 0;
}

.site-header.is-open .site-menu-toggle span:nth-child(3) {
    top: 1.15rem;
    transform: rotate(-45deg);
}

/* Make page header sit nicely below site header */
.site-header+.page header {
    margin-top: 1.5rem;
}

.manual-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.3fr) minmax(0, 1.1fr);
    gap: 1.5rem;
    align-items: flex-start;
}

@media (max-width: 900px) {
    .manual-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.manual-body {
    max-width: 52rem;
    margin: 0 auto;
    line-height: 1.7;
    font-size: 0.96rem;
}

.manual-body p {
    margin: 0 0 0.8rem;
    color: #e5e7eb;
}

.manual-body h1,
.manual-body h2,
.manual-body h3,
.manual-body h4 {
    color: #f9fafb;
    margin-top: 1.8rem;
    margin-bottom: 0.6rem;
    scroll-margin-top: 96px;
}

.manual-body h1 {
    font-size: 1.6rem;
}

.manual-body h2 {
    font-size: 1.3rem;
}

.manual-body h3 {
    font-size: 1.1rem;
}

.manual-body ul,
.manual-body ol {
    padding-left: 1.4rem;
    margin-bottom: 0.9rem;
}

.manual-body li {
    margin-bottom: 0.25rem;
}

.manual-body pre {
    padding: 0.75rem 0.9rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.35);
    overflow-x: auto;
    font-size: 0.85rem;
}

.manual-body table {
    border-collapse: collapse;
    margin: 1rem 0;
    width: 100%;
    font-size: 0.88rem;
}

.manual-body th,
.manual-body td {
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: 0.45rem 0.6rem;
}

.manual-body th {
    background: rgba(15, 23, 42, 0.9);
    font-weight: 600;
}

.manual-body tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.65);
}

.manual-body a {
    color: #38bdf8;
}

.manual-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0.4rem;
    margin: 0.75rem 0;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.manual-meta p {
    margin-bottom: 0.4rem;
}

.manual-meta .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

/* Sidebar TOC styles */

.manual-toc {
    font-size: 0.9rem;
    color: #e5e7eb;
    max-height: 60vh;
    overflow: auto;
    padding-right: 0.25rem;
}

.manual-toc-intro {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.7rem;
}

.manual-toc-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.manual-toc-list li {
    margin-bottom: 0.3rem;
}

.manual-toc-list li.toc-sub {
    padding-left: 0.75rem;
    font-size: 0.85rem;
}

.manual-toc-list a {
    text-decoration: none;
    color: #e5e7eb;
}

.manual-toc-list a:hover {
    color: #38bdf8;
}

.manual-body figure {
    margin: 1.8rem auto;
    text-align: center;
}

.manual-body figure img {
    margin-bottom: 0.6rem;
}

.manual-body figcaption {
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: #9ca3af;
    font-style: italic;
    letter-spacing: 0.02em;
}

@media (min-width: 900px) {
    .manual-sidebar {
        position: sticky;
        top: 88px;
        /* space under the fixed header */
        align-self: flex-start;
        max-height: calc(100vh - 104px);
        /* keep the card fully on screen */
        display: flex;
        flex-direction: column;
    }

    .manual-toc {
        flex: 1 1 auto;
        overflow: auto;
        /* TOC scrolls inside the card */
        max-height: none;
        /* let the card control height */
    }
}

.rn-archive-list {
    margin-top: 0.5rem;
    padding-left: 1.1rem;
}

.rn-archive-list li {
    margin-bottom: 0.25rem;
}


/* === Mobile header behaviour ================================ */

@media (max-width: 768px) {
    .site-header-inner {
        padding-inline: 1rem;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .site-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide nav & account by default on small screens */
    .site-nav,
    .site-auth {
        display: none;
        width: 100%;
        margin-left: 0;
    }

    /* When header is open, show nav + account stacked */
    .site-header.is-open .site-nav,
    .site-header.is-open .site-auth {
        display: flex;
    }

    .site-header.is-open .site-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
        margin-top: 0.4rem;
    }

    .site-header.is-open .site-auth {
        justify-content: flex-start;
        margin-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .site-nav a {
        border-bottom-width: 1px;
        padding-bottom: 0.05rem;
    }

    .site-auth {
        position: relative;
    }

    .account-pill {
        max-width: 100%;
    }

    .site-auth.menu-open .account-menu {
        position: static;
        width: 100%;
        margin-top: 0.4rem;
    }
}


@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}