:root {
    --nw-bg: #20262b;
    --nw-panel: #171c20;
    --nw-panel-2: #22292f;
    --nw-border: rgba(255,255,255,.10);
    --nw-text: #f4f7f8;
    --nw-muted: #aeb8bf;
    --nw-button: rgba(255,255,255,.08);
    --nw-button-hover: rgba(255,255,255,.16);
    --nw-stage: #2b3339;
    --nw-accent: #dfe7eb;
}

* { box-sizing: border-box; }

[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
}

body {
    background: var(--nw-bg);
    color: var(--nw-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button,
select {
    color: inherit;
}

.nw-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.nw-reader {
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: 54px minmax(0, 1fr) auto;
    background: var(--nw-bg);
    outline: none;
}

.nw-reader__header,
.nw-reader__toolbar {
    display: flex;
    align-items: center;
    border-color: var(--nw-border);
    background: var(--nw-panel);
    z-index: 50;
}

.nw-reader__header {
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    border-bottom: 1px solid var(--nw-border);
}

.nw-reader__title {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 600;
}

.nw-reader__header-actions {
    display: flex;
    gap: 7px;
}

.nw-reader__body {
    min-width: 0;
    min-height: 0;
    display: flex;
    position: relative;
}

.nw-reader__stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 45%, rgba(255,255,255,.055), transparent 48%),
        var(--nw-stage);
}

.nw-view {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.nw-view--flipbook {
    overflow: hidden;
}

.nw-view--flipbook.is-scrollable {
    overflow: auto;
}

.nw-book-wrap {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 24px;
    overflow: visible;
}

.nw-book {
    margin: auto;
    filter: drop-shadow(0 18px 25px rgba(0,0,0,.30));
    transition: transform .16s ease;
}

.nw-page {
    position: relative;
    background: #fff;
    overflow: hidden;
}

.nw-page__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
    user-select: none;
    -webkit-user-drag: none;
}

.nw-page__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #9ba4aa;
}

.nw-page.is-rendered .nw-page__placeholder {
    display: none;
}

.nw-page__mini-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid #e5e9ec;
    border-top-color: #8b969d;
    animation: nw-spin .8s linear infinite;
}

/* Header / navigation controls */

.nw-icon-btn,
.nw-nav-btn,
.nw-tool-btn,
.nw-panel-close {
    appearance: none;
    border: 1px solid var(--nw-border);
    background: var(--nw-button);
    color: var(--nw-text);
    cursor: pointer;
    transition:
        background .15s ease,
        border-color .15s ease,
        opacity .15s ease,
        transform .15s ease;
}

.nw-icon-btn:hover,
.nw-nav-btn:hover,
.nw-tool-btn:hover,
.nw-panel-close:hover,
.nw-icon-btn.is-active {
    background: var(--nw-button-hover);
}

.nw-icon-btn:focus-visible,
.nw-nav-btn:focus-visible,
.nw-tool-btn:focus-visible,
.nw-panel-close:focus-visible,
.nw-page-input:focus-visible,
.nw-view-select:focus-visible,
.nw-thumb:focus-visible,
.nw-grid-page:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.nw-icon-btn:disabled,
.nw-nav-btn:disabled,
.nw-tool-btn:disabled {
    opacity: .32;
    cursor: default;
}

.nw-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    line-height: 1;
    font-size: 19px;
}

.nw-reader__toolbar {
    min-height: 62px;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 16px;
    border-top: 1px solid var(--nw-border);
}

.nw-toolbar__group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.nw-toolbar__group--navigation {
    flex: 1 1 auto;
    justify-content: center;
}

.nw-toolbar__group--tools {
    flex: 0 0 auto;
}

.nw-nav-btn {
    min-width: 44px;
    height: 42px;
    border-radius: 7px;
    padding: 0 10px;
    font-size: 30px;
    line-height: 32px;
}

.nw-nav-btn--edge {
    min-width: 54px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -2px;
}

.nw-page-jump {
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--nw-muted);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.nw-page-input {
    width: 58px;
    height: 36px;
    border: 1px solid var(--nw-border);
    border-radius: 6px;
    background: rgba(255,255,255,.06);
    color: var(--nw-text);
    text-align: center;
    appearance: textfield;
}

.nw-page-input::-webkit-inner-spin-button,
.nw-page-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.nw-page-total {
    white-space: nowrap;
}

.nw-spread-status {
    min-width: 72px;
    margin-left: 5px;
    color: #859199;
    font-size: 12px;
    white-space: nowrap;
}

.nw-view-select-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nw-toolbar-label {
    color: var(--nw-muted);
    font-size: 12px;
}

.nw-view-select {
    height: 36px;
    border: 1px solid var(--nw-border);
    border-radius: 6px;
    padding: 0 30px 0 9px;
    background: #252c31;
    color: var(--nw-text);
}

.nw-zoom-controls {
    display: flex;
    align-items: center;
}

.nw-tool-btn {
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
    border-radius: 0;
    font-size: 18px;
}

.nw-tool-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.nw-tool-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.nw-tool-btn + .nw-tool-btn {
    margin-left: -1px;
}

.nw-tool-btn--zoom {
    min-width: 66px;
    font-size: 12px;
}

/* Loading / errors */

.nw-reader__loading,
.nw-reader__error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    text-align: center;
    z-index: 40;
}

.nw-reader__loading-title {
    font-weight: 600;
}

.nw-reader__loading-progress {
    color: var(--nw-muted);
    font-size: 13px;
}

.nw-reader__error {
    color: #fff;
}

.nw-reader__error span {
    max-width: 720px;
    color: #d2d9dd;
    font-size: 14px;
}

.nw-spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,.18);
    border-top-color: #fff;
    animation: nw-spin .8s linear infinite;
}

/* Thumbnail drawer */

.nw-thumbs {
    width: 196px;
    flex: 0 0 196px;
    min-height: 0;
    background: var(--nw-panel-2);
    border-right: 1px solid var(--nw-border);
    z-index: 35;
}

.nw-thumbs__header {
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 14px;
    border-bottom: 1px solid var(--nw-border);
    font-size: 13px;
}

.nw-panel-close {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    font-size: 20px;
    line-height: 1;
}

.nw-thumbs__list {
    height: calc(100% - 46px);
    overflow: auto;
    padding: 12px;
}

.nw-thumb {
    width: 100%;
    display: block;
    margin: 0 0 13px;
    padding: 7px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--nw-text);
    cursor: pointer;
}

.nw-thumb:hover {
    background: rgba(255,255,255,.06);
}

.nw-thumb.is-current {
    border-color: rgba(255,255,255,.38);
    background: rgba(255,255,255,.08);
}

.nw-thumb__frame {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1.4142;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,.22);
}

.nw-thumb__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.nw-thumb__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8b969d;
    font-size: 12px;
}

.nw-thumb.is-rendered .nw-thumb__image {
    display: block;
}

.nw-thumb.is-rendered .nw-thumb__placeholder {
    display: none;
}

.nw-thumb__label {
    display: block;
    padding-top: 6px;
    color: var(--nw-muted);
    font-size: 11px;
    text-align: center;
}

/* Single page inspection */

.nw-view--single {
    overflow: hidden;
}

.nw-single-scroll {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 22px;
}

.nw-single-page {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    transition: width .14s ease;
}

.nw-single-page img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 18px 34px rgba(0,0,0,.30);
}

.nw-single-placeholder {
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

/* Grid / page sorter */

.nw-view--grid {
    overflow: auto;
}

.nw-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    padding: 24px;
}

.nw-grid-page {
    appearance: none;
    display: block;
    min-width: 0;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--nw-text);
    cursor: pointer;
}

.nw-grid-page:hover {
    background: rgba(255,255,255,.05);
}

.nw-grid-page.is-current {
    border-color: rgba(255,255,255,.45);
    background: rgba(255,255,255,.07);
}

.nw-grid-page__frame {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1.4142;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,.24);
}

.nw-grid-page__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.nw-grid-page__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nw-grid-page.is-rendered .nw-grid-page__image {
    display: block;
}

.nw-grid-page.is-rendered .nw-grid-page__placeholder {
    display: none;
}

.nw-grid-page__label {
    display: block;
    padding-top: 7px;
    color: var(--nw-muted);
    font-size: 12px;
    text-align: center;
}

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

.nw-reader:fullscreen,
.nw-reader:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}

/* Tablet / narrower layouts */

@media (max-width: 900px) {
    .nw-reader__toolbar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px 12px;
        padding: 7px 10px;
    }

    .nw-toolbar__group--navigation,
    .nw-toolbar__group--tools {
        flex: 0 1 auto;
        justify-content: center;
    }

    .nw-spread-status {
        display: none;
    }

    .nw-thumbs {
        position: absolute;
        inset: 0 auto 0 0;
        width: min(220px, 82vw);
        box-shadow: 12px 0 30px rgba(0,0,0,.28);
    }
}

@media (max-width: 700px) {
    .nw-reader {
        grid-template-rows: 48px minmax(0, 1fr) auto;
    }

    .nw-reader__header {
        padding: 0 10px;
    }

    .nw-reader__title {
        font-size: 14px;
    }

    .nw-book-wrap {
        padding: 10px 8px;
    }

    .nw-reader__toolbar {
        min-height: 104px;
    }

    .nw-nav-btn {
        min-width: 40px;
        height: 38px;
        padding: 0 8px;
    }

    .nw-nav-btn--edge {
        min-width: 46px;
        font-size: 15px;
    }

    .nw-page-jump {
        min-width: 116px;
    }

    .nw-page-input {
        width: 50px;
    }

    .nw-toolbar-label {
        display: none;
    }

    .nw-view-select {
        max-width: 122px;
    }

    .nw-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 14px;
        padding: 15px;
    }

    .nw-single-scroll {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .nw-nav-btn--edge {
        display: none;
    }

    .nw-reader__toolbar {
        min-height: 98px;
    }

    .nw-toolbar__group {
        gap: 5px;
    }

    .nw-page-jump {
        min-width: 108px;
    }

    .nw-zoom-controls .nw-tool-btn {
        min-width: 34px;
        padding: 0 8px;
    }

    .nw-tool-btn--zoom {
        min-width: 58px !important;
    }
}


/* PDF hyperlink annotation layer.
   Pages are rasterised for the flipbook, so PDF.js annotations must be
   recreated as transparent interactive elements above each page image. */
.nw-page__link-layer {
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
}

.nw-page__link {
    position: absolute;
    display: block;
    pointer-events: auto;
    cursor: pointer;
    background: transparent;
    border: 0;
    text-decoration: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

.nw-page__link:hover,
.nw-page__link:focus-visible {
    outline: 1px solid rgba(0, 102, 204, .45);
    background: rgba(0, 102, 204, .06);
}

