* {
    box-sizing: border-box;
}
:root {
    color-scheme: dark;
    --bg: #0e1422;
    --panel: #172033;
    --panel2: #202c42;
    --text: #eef3fb;
    --muted: #aab7cc;
    --accent: #6aa9ff;
}
html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, sans-serif;
}
body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
button {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: var(--accent);
    color: #081323;
    font-weight: 700;
    cursor: pointer;
}
button.secondary {
    background: var(--panel2);
    color: var(--text);
    border: 1px solid #34435e;
}
button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    background: #121b2d;
    border-bottom: 1px solid #2a3650;
}
.brand {
    font-weight: 800;
    white-space: nowrap;
}
.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
main {
    flex: 1;
    padding: 18px;
}
.library {
    max-width: 1100px;
    margin: auto;
}
.intro {
    padding: 20px;
    background: var(--panel);
    border-radius: 16px;
    margin-bottom: 18px;
}
h1 {
    margin: 0 0 8px;
    font-size: clamp(22px, 3vw, 32px);
}
p {
    color: var(--muted);
    line-height: 1.5;
}
.status {
    color: #c7ddff;
}
.pdf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}
.pdf-card {
    background: var(--panel);
    border: 1px solid #2c3a55;
    border-radius: 14px;
    padding: 16px;
    text-align: left;
    color: var(--text);
    min-height: 110px;
}
.pdf-card strong {
    display: block;
    overflow-wrap: anywhere;
    margin: 8px 0;
}
.pdf-card small {
    color: var(--muted);
    font-weight: 400;
}
.empty {
    color: var(--muted);
    padding: 28px;
    border: 1px dashed #34435e;
    border-radius: 14px;
    grid-column: 1/-1;
}
.reader {
    height: calc(100dvh - 118px);
    min-height: 400px;
    display: none;
    flex-direction: column;
    gap: 10px;
}
.reader:not([hidden]) {
    display: flex;
}
.reader-head,
.reader-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.reader-head {
    justify-content: space-between;
}
.current-title {
    font-weight: 700;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.page-info {
    color: var(--muted);
    white-space: nowrap;
}
.book-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.book {
    max-width: 100%;
    max-height: 100%;
}
.book .stf__parent {
    margin: auto;
}
.book canvas {
    display: block;
    max-width: 100%;
}
.reader-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}
.reader-controls input {
    width: 68px;
    padding: 9px;
    border-radius: 8px;
    border: 1px solid #34435e;
    background: var(--panel);
    color: var(--text);
}
.loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: #0e1422cc;
    font-weight: 700;
}
footer {
    text-align: center;
    padding: 10px;
    color: var(--muted);
    font-size: 12px;
}
[hidden] {
    display: none !important;
}
@media (orientation: landscape) and (max-height: 600px) {
    .topbar {
        padding: 6px 12px;
    }
    main {
        padding: 8px 12px;
    }
    .reader {
        height: calc(100dvh - 82px);
        min-height: 250px;
        gap: 6px;
    }
    .reader-controls button {
        padding: 7px 10px;
    }
    .intro {
        padding: 12px;
        margin-bottom: 10px;
    }
}
@media (max-width: 700px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .toolbar {
        justify-content: flex-start;
    }
    .reader-head {
        gap: 6px;
    }
    .current-title {
        flex: 1;
    }
}
