:root {
    --chrome: #303030;
    --chrome-deep: #232323;
    --chrome-soft: #444;
    --chrome-hover: #555;
    --line: #777;
    --paper: #f4f1e9;
    --paper-edge: #d8d2c5;
    --ink: #161616;
    --white: #fff;
    --toolbar-height: 76px;
    --status-height: 34px;
    font-family: "Arial Narrow", "Roboto Condensed", Oswald, Arial, sans-serif;
    color: var(--white);
    background: var(--chrome);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background:
        radial-gradient(circle at 50% 0, #505050 0, transparent 38%),
        linear-gradient(145deg, var(--chrome-soft), var(--chrome-deep));
}

button,
select {
    font: inherit;
}

.reader-shell {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: var(--toolbar-height) minmax(0, 1fr) var(--status-height);
}

.toolbar {
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px clamp(12px, 2.2vw, 34px);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .05), transparent 42%),
        var(--chrome-deep);
    border-bottom: 1px solid #8a8a8a;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

.brand {
    min-width: max-content;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: #444;
    box-shadow: inset 0 0 0 3px #2c2c2c;
    font-weight: 800;
    font-size: 23px;
}

.brand-copy {
    display: grid;
    line-height: 1.05;
    letter-spacing: .035em;
}

.brand-copy strong {
    font-size: 18px;
    text-transform: uppercase;
}

.brand-copy small {
    max-width: 180px;
    margin-top: 5px;
    overflow: hidden;
    color: #bbb;
    font-family: Arial, sans-serif;
    font-size: 11px;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toolbar-controls {
    min-width: 0;
    flex: 1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.field {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.book-field {
    width: min(520px, 52vw);
}

.mode-field {
    width: min(260px, 28vw);
}

.field-label {
    color: #d8d8d8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

select {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 38px 0 13px;
    color: var(--white);
    background-color: var(--chrome-soft);
    border: 1px solid #8b8b8b;
    border-radius: 4px;
    outline: 0;
    cursor: pointer;
}

select:hover {
    background-color: var(--chrome-hover);
}

select:focus-visible,
.nav-arrow:focus-visible,
.brand:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

select:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse at center, #777 0, #5c5c5c 55%, #474747 100%);
}

.viewer {
    position: absolute;
    inset: clamp(10px, 2vw, 26px) clamp(56px, 6vw, 90px);
    overflow: hidden;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid #9c9c9c;
    border-radius: 3px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, .42);
}

.viewer::after {
    position: absolute;
    inset: 0;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, .45);
    pointer-events: none;
    content: "";
}

.viewer .epub-container {
    background: var(--paper);
}

.viewer iframe {
    background: var(--paper);
}

.nav-arrow {
    position: absolute;
    top: 50%;
    z-index: 10;
    width: clamp(48px, 5vw, 72px);
    height: 104px;
    padding: 0;
    display: grid;
    place-items: center;
    color: var(--white);
    background: rgba(35, 35, 35, .62);
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
    transform: translateY(-50%);
    cursor: pointer;
    transition: background-color .16s ease, opacity .16s ease, transform .16s ease;
}

.nav-arrow span {
    font-family: Arial, sans-serif;
    font-size: clamp(35px, 4vw, 54px);
    line-height: 1;
}

.nav-arrow:hover:not(:disabled) {
    background: rgba(68, 68, 68, .92);
}

.nav-arrow:active:not(:disabled) {
    transform: translateY(-50%) scale(.96);
}

.nav-arrow:disabled {
    opacity: .25;
    cursor: default;
}

.nav-arrow-left {
    left: clamp(4px, 1vw, 14px);
}

.nav-arrow-right {
    right: clamp(4px, 1vw, 14px);
}

.loading-panel,
.empty-state {
    position: absolute;
    inset: 50% auto auto 50%;
    z-index: 12;
    transform: translate(-50%, -50%);
}

.loading-panel {
    min-width: 230px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--white);
    background: rgba(35, 35, 35, .92);
    border: 1px solid #777;
    border-radius: 4px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .36);
}

.loading-panel[hidden] {
    display: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #777;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(1turn); }
}

.empty-state {
    width: min(540px, calc(100% - 40px));
    padding: clamp(24px, 4vw, 46px);
    text-align: center;
    background: rgba(35, 35, 35, .92);
    border: 1px solid #888;
    border-radius: 4px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .35);
}

.empty-state h1 {
    margin: 18px 0 10px;
    font-size: clamp(24px, 5vw, 38px);
}

.empty-state p {
    margin: 0;
    color: #d3d3d3;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

.empty-state code {
    color: #fff;
}

.empty-icon {
    display: inline-grid;
    place-items: center;
    width: 82px;
    height: 58px;
    background: #444;
    border: 1px solid #aaa;
    border-radius: 3px;
    font-weight: 800;
    letter-spacing: .08em;
}

.reader-error {
    position: absolute;
    inset: 50% auto auto 50%;
    width: min(520px, calc(100% - 48px));
    padding: 24px;
    color: #fff;
    background: #3d3d3d;
    border: 1px solid #999;
    border-radius: 4px;
    text-align: center;
    line-height: 1.6;
    transform: translate(-50%, -50%);
}

.statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 clamp(14px, 2.2vw, 34px);
    overflow: hidden;
    color: #ddd;
    background: #363636;
    border-top: 1px solid #888;
    font-family: Arial, sans-serif;
    font-size: 12px;
}

.statusbar span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.statusbar span:first-child {
    min-width: 0;
}

.statusbar span:last-child {
    flex: none;
}

@media (max-width: 780px) {
    :root {
        --toolbar-height: 126px;
    }

    .toolbar {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px 14px;
        padding-block: 9px;
    }

    .brand {
        height: 42px;
    }

    .brand-copy small {
        max-width: 210px;
    }

    .toolbar-controls {
        width: 100%;
        flex-basis: 100%;
        gap: 8px;
    }

    .field {
        display: block;
    }

    .field-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .book-field {
        width: 58%;
    }

    .mode-field {
        width: 42%;
    }

    select {
        height: 42px;
    }

    .viewer {
        inset: 8px 42px;
    }

    .nav-arrow {
        width: 38px;
        height: 84px;
        background: rgba(35, 35, 35, .75);
    }

    .nav-arrow span {
        font-size: 32px;
    }

    .nav-arrow-left {
        left: 2px;
    }

    .nav-arrow-right {
        right: 2px;
    }
}

@media (max-width: 430px) {
    .brand-copy small {
        display: none;
    }

    .book-field {
        width: 54%;
    }

    .mode-field {
        width: 46%;
    }

    select {
        padding-inline: 9px 25px;
        font-size: 13px;
    }

    .viewer {
        inset-inline: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
