/* Design tokens: colors are shared by every component in the hub. */
:root {
    color-scheme: dark;
    --background: #0b1220;
    --sidebar: #0d1525;
    --surface: #111c2e;
    --surface-hover: #17253a;
    --text: #e9eef6;
    --muted: #96a5bc;
    --subtle: #74869f;
    --border: #223047;
    --accent: #8ce0c5;
    --accent-surface: #182f32;
    --input: #0e1828;
    --shadow: 0 12px 32px rgb(0 0 0 / 10%);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
}

:root[data-theme="light"] {
    color-scheme: light;
    --background: #f6f8fb;
    --sidebar: #ffffff;
    --surface: #ffffff;
    --surface-hover: #edf2f7;
    --text: #15253c;
    --muted: #53657b;
    --subtle: #60728a;
    --border: #dce3ec;
    --accent: #176b55;
    --accent-surface: #e4f3ed;
    --input: #ffffff;
    --shadow: 0 12px 32px rgb(22 40 64 / 5%);
}

/* Base and accessibility. */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

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

button,
input {
    font: inherit;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

[hidden] {
    display: none !important;
}

.sr-only,
.skip-link:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link:focus {
    position: fixed;
    z-index: 10;
    top: 12px;
    left: 12px;
    padding: 12px 20px;
    background: var(--surface);
}

/* Persistent navigation. */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: 248px;
    padding: 34px 22px 22px;
    border-right: 1px solid var(--border);
    background: var(--sidebar);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.8px;
}

.brand-mark {
    display: inline-flex;
    flex-shrink: 0;
    width: 42px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    font-size: 28px;
    letter-spacing: -3px;
    line-height: 1;
}

.brand-mark span,
.footer-dot {
    color: var(--accent);
}

.brand-caption {
    display: block;
    margin-top: 1px;
    color: var(--subtle);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1.5px;
}

.workspace-label {
    margin: 55px 12px 14px;
    color: var(--subtle);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.3px;
}

.nav-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--accent-surface);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}

.nav-item > span:first-child {
    font-size: 20px;
    line-height: 1;
}

.nav-count {
    margin-left: auto;
    font-size: 11px;
}

.sidebar-note {
    margin: auto 12px 36px;
    padding-top: 36px;
}

.note-icon {
    color: var(--accent);
    font-size: 28px;
}

.sidebar-note h2 {
    margin: 10px 0;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.6;
}

.sidebar-note p {
    color: var(--subtle);
    font-size: 12px;
    line-height: 1.9;
}

.sidebar-bottom {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 20px 8px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.version {
    margin-left: auto;
    color: var(--subtle);
    font-family: monospace;
}

/* Main workspace and introductory panel. */
.workspace {
    margin-left: 248px;
}

.topbar {
    display: flex;
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 44px;
    border-bottom: 1px solid var(--border);
}

.breadcrumb {
    color: var(--subtle);
    font-size: 12px;
}

.breadcrumb span {
    margin: 0 12px;
    color: var(--subtle);
}

.breadcrumb strong {
    color: var(--muted);
    font-weight: 500;
}

.theme-button {
    display: flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
}

#theme-icon {
    font-size: 19px;
    line-height: 1;
}

main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 48px 44px 0;
}

.intro {
    position: relative;
    overflow: hidden;
    padding: 0 0 42px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.8px;
}

.eyebrow > span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

h1 {
    position: relative;
    z-index: 1;
    margin: 22px 0 16px;
    font-size: clamp(30px, 3.2vw, 44px);
    font-weight: 600;
    letter-spacing: -1.8px;
    line-height: 1.3;
}

h1 > span {
    color: var(--muted);
    font-weight: 400;
}

.intro > p {
    position: relative;
    z-index: 1;
    max-width: 65%;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.mobile-break {
    display: none;
}

.intro-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 27px;
    color: var(--subtle);
    font-size: 11px;
}

.intro-meta strong {
    color: var(--text);
    font-weight: 500;
}

.meta-divider {
    width: 1px;
    height: 10px;
    background: var(--border);
}

.intro-art {
    position: absolute;
    top: 5px;
    right: 16px;
    width: 240px;
    height: 240px;
}

.art-grid {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--subtle) 0.7px, transparent 0.7px);
    background-size: 18px 18px;
    opacity: 0.2;
    mask-image: radial-gradient(ellipse, black, transparent 70%);
}

.art-sheet {
    position: absolute;
    width: 112px;
    height: 144px;
    padding: 23px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.sheet-back {
    top: 29px;
    left: 43px;
    transform: rotate(-15deg);
}

.sheet-front {
    top: 50px;
    left: 93px;
    transform: rotate(12deg);
}

.art-sheet > span {
    color: var(--accent);
    font-size: 29px;
}

.art-sheet i {
    display: block;
    height: 4px;
    margin-top: 12px;
    border-radius: 3px;
    background: var(--border);
}

.art-sheet i:last-child {
    width: 55%;
}

.art-spark {
    position: absolute;
    top: 24px;
    right: 14px;
    color: var(--accent);
    font-size: 28px;
}

.art-caption {
    position: absolute;
    right: 28px;
    bottom: 10px;
    color: var(--subtle);
    font: 8px monospace;
    letter-spacing: 2px;
}

/* Collection filters and cards. */
.library {
    padding-top: 35px;
    scroll-margin-top: 20px;
}

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

.section-eyebrow {
    color: var(--subtle);
    font-size: 9px;
}

.section-heading h2 {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 8px 0 0;
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.5px;
}

#heading-count {
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
    font: 11px/23px monospace;
}

.section-hint {
    margin-bottom: 4px;
    color: var(--subtle);
    font-size: 11px;
}

.toolbar {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.filters button {
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
}

.filters button[aria-pressed="true"] {
    border-color: var(--border);
    background: var(--surface-hover);
    color: var(--text);
}

.search-box {
    display: flex;
    width: 240px;
    gap: 9px;
    align-items: center;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--input);
    color: var(--subtle);
}

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

.search-box svg {
    flex-shrink: 0;
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 12px;
}

.search-box input::placeholder {
    color: var(--subtle);
}

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

.collection-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color 160ms ease, transform 160ms ease;
}

.collection-card:hover {
    transform: translateY(-3px);
    border-color: var(--subtle);
}

.card-art {
    position: relative;
    height: 174px;
    padding: 20px 24px;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    background: radial-gradient(ellipse at 70% 90%, #214546 0%, transparent 70%), #14282e;
    color: #b2e3d9;
}

[data-appearance="pages"] .card-art {
    background: radial-gradient(ellipse at 70% 90%, #334b75 0%, transparent 70%), #1a2b47;
    color: #b4cafa;
}

.art-kicker {
    font: 9px monospace;
    letter-spacing: 2px;
}

.diagram {
    display: flex;
    height: 78px;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
}

.diagram-node {
    display: grid;
    width: 56px;
    height: 51px;
    place-items: center;
    border: 1px solid rgb(177 225 216 / 28%);
    border-radius: 10px;
    background: rgb(13 31 40 / 50%);
    box-shadow: 0 6px 15px rgb(0 0 0 / 10%);
    font: 23px monospace;
}

.node-end {
    font-size: 34px;
}

.diagram-connector {
    position: relative;
    width: 82px;
    border-top: 1px dashed currentColor;
    opacity: 0.7;
}

.diagram-connector::after {
    position: absolute;
    top: -4px;
    left: 37px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 14px currentColor;
    content: "";
}

[data-appearance="pages"] .node-start {
    transform: rotate(-8deg);
}

[data-appearance="pages"] .node-end {
    transform: rotate(8deg);
}

.art-description {
    font-size: 10px;
    opacity: 0.75;
}

.art-number {
    position: absolute;
    right: 22px;
    bottom: -22px;
    font-size: 93px;
    font-weight: 600;
    letter-spacing: -7px;
    opacity: 0.055;
}

.card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 23px 24px 19px;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
}

.category-badge {
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-surface);
    color: var(--accent);
}

.page-total {
    color: var(--subtle);
}

.card-body h3 {
    margin: 16px 0 7px;
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.6px;
}

.card-title:hover,
.related-pages a:hover {
    color: var(--accent);
}

.card-description {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.9;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 25px;
    padding: 0;
    list-style: none;
}

.tags li {
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted);
    font-size: 9px;
}

.related-pages {
    margin-bottom: 22px;
}

.related-label {
    color: var(--subtle);
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1.3px;
}

.related-pages ul {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
}

.related-pages a {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--muted);
    font-size: 11px;
}

.related-pages a span {
    color: var(--subtle);
}

.open-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
}

.open-link span {
    font-size: 19px;
}

.empty-state {
    padding: 60px 20px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    text-align: center;
}

.empty-state > span {
    color: var(--accent);
    font-size: 40px;
}

.empty-state h3 {
    margin-bottom: 6px;
    font-size: 20px;
}

.empty-state p {
    color: var(--muted);
}

.reset-button {
    margin-top: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--accent-surface);
    color: var(--accent);
}

.library-note {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 28px 0 45px;
    color: var(--subtle);
    font-size: 10px;
}

.library-note > span:first-child {
    color: var(--accent);
    font-size: 17px;
}

.note-line {
    flex: 1;
    height: 1px;
    margin-left: 12px;
    background: var(--border);
}

footer {
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 21px 0 25px;
    border-top: 1px solid var(--border);
    color: var(--subtle);
    font-size: 10px;
}

footer > span:first-child {
    color: var(--muted);
    font-weight: 600;
}

.footer-label {
    margin-left: 14px;
    color: var(--subtle);
    font-weight: 400;
}

/* Responsive layouts: navigation condenses before content becomes cramped. */
@media (min-width: 1600px) {
    main {
        padding-top: 64px;
    }

    .intro {
        padding-bottom: 58px;
    }
}

@media (max-width: 1150px) {
    .sidebar {
        width: 210px;
        padding-inline: 16px;
    }

    .workspace {
        margin-left: 210px;
    }

    .topbar {
        padding-inline: 28px;
    }

    main {
        padding-inline: 28px;
    }

    .intro-art {
        right: -45px;
        opacity: 0.45;
    }

    .section-hint {
        display: none;
    }

    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .card-body {
        padding-inline: 20px;
    }
}

@media (max-width: 800px) {
    .sidebar {
        position: static;
        width: auto;
        padding: 17px 24px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .brand {
        font-size: 20px;
    }

    .brand-mark {
        width: 36px;
        height: 38px;
    }

    .workspace-label,
    .nav-item,
    .sidebar-note,
    .sidebar-bottom {
        display: none;
    }

    .workspace {
        margin-left: 0;
    }

    .topbar {
        min-height: 65px;
        padding-inline: 24px;
    }

    main {
        padding: 36px 24px 0;
    }

    .intro-art {
        right: 0;
        opacity: 0.7;
    }

    h1 {
        font-size: 34px;
    }
}

@media (max-width: 560px) {
    .sidebar,
    .topbar {
        padding-inline: 20px;
    }

    main {
        padding-inline: 20px;
    }

    .breadcrumb {
        font-size: 10px;
    }

    .breadcrumb span {
        margin-inline: 6px;
    }

    .intro-art {
        display: none;
    }

    h1 {
        font-size: 31px;
        letter-spacing: -1.3px;
    }

    .intro > p {
        max-width: 100%;
        font-size: 12px;
        line-height: 1.9;
    }

    .mobile-break {
        display: block;
    }

    .intro-meta {
        gap: 10px;
        font-size: 10px;
    }

    .section-heading h2 {
        font-size: 21px;
    }

    .filters {
        gap: 2px;
    }

    .filters button {
        min-height: 40px;
        padding-inline: 10px;
        font-size: 11px;
    }

    .search-box {
        min-height: 42px;
    }

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

    .related-pages a {
        min-height: 36px;
        align-items: center;
    }

    .open-link {
        min-height: 48px;
    }

    .library-note p > span,
    .note-line {
        display: none;
    }

    footer {
        flex-direction: column;
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
