* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

:root {
    --header-height: calc(100vh / 16);
    --footer-height: calc(100vh / 16);
    --side-width: calc(100vw / 8);
    --bg: #f3f3f3;
    --ink: #000000;
    --accent: #ff611a;
    --line: #000000;
    --vh: 1vh;
}

body {
    font-family:
        'Inter',
        system-ui,
        -apple-system,
        'Segoe UI',
        sans-serif;
    font-weight: 600;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    user-select: none;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-rows: var(--header-height) 1fr var(--footer-height);
}

.viewer-layout {
    min-height: 100vh;
    display: grid;
    grid-template-rows: var(--header-height) 1fr var(--footer-height);
}

.band {
    display: flex;
    align-items: center;
    padding: 0 2.5vw;
    font-weight: 600;
    font-size: 1rem;
    border-bottom: 2px solid var(--line);
    background: var(--bg);
    position: sticky;
    z-index: 10;
}

.header {
    top: 0;
}

.footer {
    border-top: 2px solid var(--line);
    border-bottom: none;
    justify-content: flex-start;
    bottom: 0;
}

.viewer-header {
    justify-content: space-between;
    gap: 1rem;
}

.viewer-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.viewer-back {
    color: inherit;
    text-decoration: none;
    font-size: 0.9rem;
}

.viewer-title {
    font-size: inherit;
    display: inline-flex;
    align-items: center;
}

.viewer-download {
    font-size: 0.75rem;
    text-decoration: none;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    border: 2px solid var(--viewer-accent, var(--accent));
    color: var(--viewer-accent, var(--accent));
    background: transparent;
    letter-spacing: 0.01em;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.viewer-download:hover {
    background: var(--viewer-accent, var(--accent));
    color: var(--bg);
}

.viewer-main {
    padding: 1.2rem 2.5vw 1.6rem;
}

.viewer-frame {
    height: 100%;
    border: none;
    background: var(--bg);
    overflow: hidden;
}

.viewer-pages {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem 0;
    display: block;
    background: var(--bg);
    position: relative;
}

.viewer-page {
    width: calc(100% - 3rem);
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6a6a6a;
    font-size: 0.9rem;
}

.viewer-canvas {
    max-width: calc(100% - 3rem);
    height: auto;
    box-shadow: 0 0 0 1px #d8d8d8;
    background: #ffffff;
}

.viewer-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.5rem;
    font-size: 4.4rem;
    color: #6a6a6a;
    pointer-events: none;
}

.viewer-status::after {
    content: '';
    width: min(30vw, 240px);
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--ink), transparent);
    background-size: 200% 100%;
    opacity: 0.35;
    animation: loadingSweep 1.2s ease-in-out infinite;
}

@keyframes loadingSweep {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.viewer-footer {
    justify-content: flex-start;
}

.main {
    display: grid;
    grid-template-columns: var(--side-width) minmax(0, 1fr) var(--side-width);
    min-height: 0;
}

.side {
    padding: 1.5rem 0.75rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #6a6357;
}

.left {
    border-right: 2px solid var(--line);
    text-align: left;
}

.right {
    border-left: 2px solid var(--line);
    text-align: right;
}

.content {
    padding: 0;
    display: grid;
    grid-template-rows: repeat(4, minmax(0, 1fr));
    height: 100%;
}

.note-link {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    position: relative;
    --dot-color: var(--accent);
    --dot-color-rgb: 214 61 49;
    text-decoration: none;
    color: var(--ink);
    font-size: clamp(2.6rem, 4.6vw, 4.2rem);
    border-bottom: 2px solid var(--line);
    transition:
        background-color 160ms ease,
        color 160ms ease;
    padding: 0.8rem 0.8rem;
    gap: 0.35rem;
}

.note-link::before {
    content: '';
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 10px;
    height: 10px;
    border: 2px solid var(--dot-color);
    border-radius: 50%;
    background-color: var(--dot-color);
}

.note-link--stats {
    --dot-color: #3742cc;
    --dot-color-rgb: 55 66 204;
}

.note-link--topology {
    --dot-color: #e9aa4a;
    --dot-color-rgb: 233 170 74;
}

.note-link--fields {
    --dot-color: #d63d31;
    --dot-color-rgb: 214 61 49;
}

.note-link--networks {
    --dot-color: #2a8f74;
    --dot-color-rgb: 42 143 116;
}

.note-title {
    font-size: 1em;
    line-height: 1.05;
}

.note-meta {
    font-size: 0.33em;
}

.note-link:last-child {
    border-bottom: none;
}

.note-link:hover,
.note-link:focus-visible {
    background: rgb(var(--dot-color-rgb) / 0.08);
    color: var(--dot-color);
}

@media (max-width: 720px) {
    :root {
        --side-width: 2.25rem;
        --header-height: calc(var(--vh) * 100 / 16);
        --footer-height: 2.4rem;
    }

    body.index-page {
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.index-page .layout {
        height: calc(var(--vh) * 100);
        max-height: calc(var(--vh) * 100);
        min-height: calc(var(--vh) * 100);
    }

    .band {
        padding: 0 1.2rem;
        font-size: 1.35rem;
    }

    .viewer-header {
        font-size: 1rem;
    }

    .viewer-main {
        padding: 0.4rem 0.4rem 0.6rem;
    }

    .viewer-pages {
        padding: 0.6rem 0;
    }

    .viewer-page {
        width: 100%;
        margin: 0 0 1rem;
    }

    .viewer-canvas {
        max-width: 100%;
    }

    .viewer-frame {
        overflow: visible;
    }

    .viewer-pages {
        overflow-x: visible;
    }

    .viewer-canvas {
        box-shadow: none;
    }

    .side {
        font-size: 0.65rem;
        padding: 1.2rem 0.4rem;
    }

    .note-link {
        font-size: 1.65rem;
        padding: 0.45rem 0.55rem;
        gap: 0.2rem;
    }

    .note-link::before {
        top: auto;
        left: auto;
        right: 0.55rem;
        bottom: 0.55rem;
        z-index: 2;
    }

    .note-meta {
        font-size: 0.4em;
    }

    .footer > * {
        display: none;
    }

}
