:root {
    --bg: #f4f1eb;
    --paper: #fffdf8;
    --ink: #1d1b18;
    --muted: #69625b;
    --line: #ddd4c7;
    --accent: #b02f2f;
    --accent-strong: #8b2020;
    --green: #247a55;
    --shadow: 0 24px 70px rgba(42, 31, 18, 0.22);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
}

button,
input,
textarea {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px clamp(18px, 4vw, 46px);
    border-bottom: 1px solid rgba(29, 27, 24, 0.1);
}

.shelf-page .topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 20;
    justify-content: flex-start;
    min-height: 72px;
    background: rgba(244, 241, 235, 0.88);
    box-shadow: 0 14px 36px rgba(42, 31, 18, 0.12);
    transform: translateY(-100%);
    transition: transform 260ms ease;
    backdrop-filter: blur(14px);
}

.shelf-page.shelf-topbar-visible .topbar,
.shelf-page .topbar:hover,
.shelf-page .topbar:focus-within {
    transform: translateY(0);
}

.archive-page .topbar,
.archive-page.shelf-topbar-visible .topbar {
    position: sticky;
    justify-content: space-between;
    background: rgba(244, 241, 235, 0.96);
    transform: none;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 2px solid var(--ink);
    border-radius: 6px;
    background: var(--paper);
    font-size: 13px;
    letter-spacing: 0;
}

.brand-logo-wrap {
    display: grid;
    place-items: center;
    width: 54px;
    height: 42px;
}

.brand-logo {
    display: block;
    max-width: 54px;
    max-height: 42px;
    object-fit: contain;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ghost-button,
.primary-button,
.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 16px;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    max-width: 100%;
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.ghost-button:hover,
.primary-button:hover,
.small-button:hover {
    transform: translateY(-1px);
    border-color: rgba(29, 27, 24, 0.35);
}

.primary-button {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.page-build-panel progress {
    display: block;
    width: 100%;
    height: 14px;
    margin: 18px 0 10px;
    accent-color: var(--accent);
}

.page-build-panel.is-running .primary-button {
    opacity: .65;
}

.small-button {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.small-button.danger {
    border-color: rgba(176, 47, 47, 0.35);
    color: var(--accent-strong);
}

.shelf-wrap,
.admin-wrap {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.shelf-wrap {
    width: min(1320px, calc(100% - 32px));
    padding-top: 40px;
}

.archive-wrap {
    padding-top: 34px;
}

.archive-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(170px, 260px);
    align-items: center;
    gap: clamp(24px, 5vw, 72px);
    margin-bottom: 32px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--line);
}

.archive-hero-copy {
    max-width: 820px;
    min-width: 0;
}

.archive-hero-copy h1 {
    margin-bottom: 12px;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(34px, 6vw, 76px);
    line-height: 0.98;
    letter-spacing: 0;
}

.archive-hero-copy p:not(.eyebrow) {
    max-width: 720px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.5;
}

.archive-hero-mark {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 18px;
}

.archive-hero-mark img {
    display: block;
    width: min(210px, 100%);
    height: auto;
}

.archive-hero-mark span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255, 253, 248, 0.72);
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
}

.archive-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    margin-top: 24px;
}

.archive-search {
    display: grid;
    flex: 1 1 320px;
    gap: 7px;
}

.archive-search span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.archive-search input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 13px;
    background: #fff;
    color: var(--ink);
}

.archive-tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.archive-layout {
    display: grid;
    grid-template-columns: minmax(170px, 230px) minmax(0, 1fr);
    align-items: start;
    gap: clamp(22px, 4vw, 48px);
}

.year-panel {
    position: sticky;
    top: 96px;
    display: grid;
    gap: 8px;
}

.year-panel-head,
.year-panel a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.year-panel-head {
    padding: 6px 2px 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.year-panel a {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--muted);
    text-decoration: none;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.year-panel a:hover {
    border-color: var(--line);
    background: rgba(255, 253, 248, 0.72);
    color: var(--ink);
}

.year-panel b,
.year-panel-head b {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #fff;
    color: var(--accent-strong);
    font-size: 13px;
}

.archive-result {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.archive-year {
    border-top: 1px solid var(--line);
}

.archive-year:last-child {
    border-bottom: 1px solid var(--line);
}

.archive-year summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 78px;
    cursor: pointer;
    list-style: none;
}

.archive-year summary::-webkit-details-marker {
    display: none;
}

.archive-year summary::after {
    content: "+";
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    color: var(--accent-strong);
    font-size: 22px;
    line-height: 1;
}

.archive-year[open] summary::after {
    content: "-";
}

.archive-year-title {
    font-size: clamp(28px, 4vw, 48px);
    font-weight: 900;
    line-height: 1;
}

.archive-year-meta {
    margin-left: auto;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.archive-issues {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    padding: 0 0 24px;
}

.archive-issue {
    display: grid;
    align-content: start;
    gap: 9px;
    min-height: 132px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 13px;
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
    text-decoration: none;
}

.archive-issue-link {
    display: grid;
    align-content: start;
    gap: 9px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.archive-issue.is-available {
    border-left: 4px solid var(--accent);
    box-shadow: 0 12px 28px rgba(42, 31, 18, 0.08);
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.archive-issue.is-available:hover {
    border-color: rgba(176, 47, 47, 0.55);
    box-shadow: 0 18px 36px rgba(42, 31, 18, 0.14);
    transform: translateY(-2px);
}

.archive-issue-empty {
    border-style: dashed;
    background: rgba(255, 253, 248, 0.42);
    color: rgba(105, 98, 91, 0.78);
}

.archive-issue strong {
    overflow-wrap: anywhere;
    font-size: 17px;
    line-height: 1.18;
}

.issue-cover {
    display: block;
    aspect-ratio: 0.714;
    overflow: hidden;
    border-radius: 4px;
    background: #e7dfd3;
    box-shadow: 0 10px 24px rgba(42, 31, 18, 0.14);
}

.issue-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.archive-issue small {
    color: var(--muted);
    line-height: 1.35;
}

.issue-number {
    width: max-content;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(176, 47, 47, 0.1);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 900;
}

.issue-open {
    align-self: end;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 900;
}

.issue-actions {
    align-self: end;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 2px;
}

.issue-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 10px;
    background: #fff;
    color: var(--ink);
    font-size: 11px;
    font-weight: 800;
    text-decoration: none;
}

.issue-download:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.archive-extra {
    display: grid;
    gap: 8px;
    padding: 0 0 24px;
}

.archive-extra h2 {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 14px;
}

.archive-extra a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
    background: var(--paper);
    text-decoration: none;
}

.archive-extra b {
    color: var(--accent-strong);
    font-size: 13px;
}

.archive-empty {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.archive-empty .primary-button {
    width: 100%;
}

.archive-empty p {
    overflow-wrap: anywhere;
}

.shelf-intro,
.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 30px;
}

.shelf-intro {
    display: block;
    max-width: 720px;
}

.shelf-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.shelf-head h1 {
    margin-bottom: 0;
    font-size: clamp(26px, 3vw, 42px);
    line-height: 1.05;
    letter-spacing: 0;
}

.shelf-count {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(255, 253, 248, 0.72);
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.shelf-copy {
    max-width: 760px;
    margin-bottom: 28px;
}

.shelf-copy h1 {
    margin-bottom: 10px;
    font-size: clamp(28px, 4vw, 54px);
    line-height: 1.02;
    letter-spacing: 0;
}

.shelf-copy p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.5;
}

.shelf-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 250px);
    align-items: start;
    gap: clamp(22px, 5vw, 70px);
}

.rubric-panel {
    position: sticky;
    top: 96px;
    display: grid;
    gap: 8px;
    justify-self: stretch;
}

.rubric-panel a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--muted);
    text-decoration: none;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.rubric-panel a:hover,
.rubric-panel a.active {
    border-color: var(--line);
    background: rgba(255, 253, 248, 0.72);
    color: var(--ink);
}

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

.rubric-panel b {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #fff;
    color: var(--accent-strong);
    font-size: 13px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.shelf-intro h1,
.admin-head h1 {
    margin-bottom: 12px;
    font-size: clamp(34px, 5vw, 64px);
    line-height: 0.98;
    letter-spacing: 0;
}

.shelf-intro p,
.admin-head p,
.muted {
    color: var(--muted);
}

.empty-state,
.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 253, 248, 0.76);
    padding: clamp(18px, 4vw, 34px);
}

.empty-state {
    width: min(620px, 100%);
    max-width: 620px;
}

.magazine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.magazine-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: 0 16px 38px rgba(42, 31, 18, 0.1);
}

.cover-link {
    display: block;
    padding: 12px;
    background: #d8d0c4;
    text-decoration: none;
}

.cover-art {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 0.72;
    border-radius: 4px;
    overflow: hidden;
    padding: 14px;
    background:
        linear-gradient(135deg, rgba(176, 47, 47, 0.95), rgba(28, 28, 30, 0.92)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 18px);
    color: #fff;
    box-shadow: 0 18px 42px rgba(28, 25, 21, 0.28);
}

.cover-canvas {
    position: relative;
    z-index: 4;
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 16px 34px rgba(28, 25, 21, 0.24);
    opacity: 0;
    transition: opacity 180ms ease;
}

.cover-frame {
    position: absolute;
    inset: 14px;
    z-index: 3;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
    border: 0;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 16px 34px rgba(28, 25, 21, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.cover-fallback {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px;
}

.cover-rendered {
    background: linear-gradient(135deg, #d7d0c5, #eee9de);
}

.cover-rendered .cover-canvas {
    opacity: 1;
}

.cover-rendered .cover-fallback,
.cover-native .cover-fallback {
    opacity: 0;
}

.cover-native {
    background: linear-gradient(135deg, #d7d0c5, #eee9de);
}

.cover-native .cover-frame {
    opacity: 1;
}

.cover-locked {
    background:
        linear-gradient(135deg, rgba(70, 63, 55, 0.96), rgba(24, 24, 26, 0.94)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 18px);
}

.cover-art strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 30px;
    line-height: 1.04;
}

.cover-kicker,
.cover-art span:last-child {
    font-size: 13px;
    font-weight: 700;
    opacity: 0.82;
}

.magazine-card-body {
    padding: 14px 16px 16px;
}

.magazine-card-body h2 {
    margin-bottom: 6px;
    overflow-wrap: anywhere;
    font-size: 18px;
    line-height: 1.18;
}

.magazine-card-body p {
    color: var(--muted);
}

.card-meta,
.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    color: var(--muted);
    font-size: 14px;
}

.card-meta a,
.admin-links a {
    color: var(--accent-strong);
    font-weight: 700;
}

.admin-head {
    align-items: flex-start;
}

.admin-limit {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    background: var(--paper);
    color: var(--muted);
    font-size: 14px;
}

.notice {
    margin-bottom: 14px;
    border-radius: 6px;
    padding: 12px 14px;
    font-weight: 700;
}

.notice.success {
    border: 1px solid rgba(36, 122, 85, 0.24);
    background: rgba(36, 122, 85, 0.1);
    color: var(--green);
}

.notice.error {
    border: 1px solid rgba(176, 47, 47, 0.22);
    background: rgba(176, 47, 47, 0.09);
    color: var(--accent-strong);
}

.panel + .panel {
    margin-top: 22px;
}

.panel h2 {
    font-size: 24px;
}

.upload-form {
    display: grid;
    gap: 18px;
}

.upload-form label {
    display: grid;
    gap: 8px;
}

.upload-form label span {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.upload-form input[type="text"],
.upload-form input[type="number"],
.upload-form input[type="password"],
.upload-form input[type="url"],
.upload-form input[type="file"],
.upload-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 12px 13px;
    color: var(--ink);
}

.upload-form textarea {
    resize: vertical;
}

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

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 22px;
    color: var(--muted);
}

.check-row label {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
}

.admin-list {
    display: grid;
    gap: 12px;
}

.admin-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 16px;
}

.admin-item h3 {
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.admin-item p {
    margin-bottom: 8px;
    color: var(--muted);
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.admin-meta-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.admin-meta-form label {
    display: grid;
    gap: 5px;
}

.admin-meta-form span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.admin-meta-form input {
    min-height: 34px;
    max-width: 180px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 9px;
}

.admin-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    color: var(--muted);
}

.admin-inline-check input {
    min-height: auto;
}

.reader-page {
    min-height: 100vh;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(20, 20, 22, 0.92), rgba(38, 35, 31, 0.95)),
        #242220;
    color: #fff;
}

.unlock-page {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(20, 20, 22, 0.92), rgba(38, 35, 31, 0.95)),
        #242220;
    color: #fff;
}

.unlock-wrap {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.unlock-box {
    display: grid;
    gap: 16px;
    width: min(430px, 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: clamp(20px, 5vw, 34px);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(14px);
}

.unlock-box h1 {
    margin-bottom: 0;
    overflow-wrap: anywhere;
    font-size: clamp(26px, 6vw, 42px);
    line-height: 1.04;
}

.unlock-box label {
    display: grid;
    gap: 8px;
}

.unlock-box label span {
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    font-weight: 800;
}

.unlock-box input {
    min-height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--ink);
}

.unlock-back {
    color: rgba(255, 255, 255, 0.72);
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}

.reader-shell {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
}

.reader-toolbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 12;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: calc(12px + env(safe-area-inset-top, 0px)) clamp(12px, 2vw, 22px) 12px;
    background: rgba(20, 19, 18, 0.86);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
    transform: translateY(-110%);
    transition: transform 260ms ease, opacity 220ms ease;
    opacity: 0;
    backdrop-filter: blur(14px);
}

.reader-shell.top-controls-visible .reader-toolbar,
.reader-toolbar:hover,
.reader-toolbar:focus-within {
    opacity: 1;
    transform: translateY(0);
}

.reader-title {
    min-width: 0;
}

.reader-title strong,
.reader-title span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-title strong {
    font-size: 16px;
}

.reader-title span {
    color: rgba(255, 255, 255, 0.62);
    font-size: 13px;
}

.reader-actions {
    display: flex;
    gap: 8px;
}

.icon-button,
.small-icon {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
}

.icon-button:hover,
.small-icon:hover {
    background: rgba(255, 255, 255, 0.16);
}

.back-link {
    font-size: 30px;
    line-height: 1;
}

.reader-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    overflow: auto;
    padding: 20px 72px 26px;
}

.book-frame {
    position: relative;
    display: grid;
    place-items: center;
    width: min(1580px, 100%);
    height: 100%;
    min-height: 340px;
}

.book-spread {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 0;
    align-items: center;
    justify-items: stretch;
    isolation: isolate;
    width: 100%;
    height: 100%;
    perspective: 1800px;
    transform-style: preserve-3d;
}

.book-spread.single {
    grid-template-columns: minmax(0, 1fr);
    width: min(720px, 100%);
}

.book-spread:not(.single)::after {
    content: "";
    position: absolute;
    top: var(--spine-top, 0);
    left: 50%;
    z-index: 3;
    width: 18px;
    height: var(--spine-height, 100%);
    pointer-events: none;
    transform: translateX(-50%);
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.2) 48%, rgba(0, 0, 0, 0.22)),
        linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.18), transparent);
    opacity: 0.62;
    mix-blend-mode: multiply;
}

.book-spread.turn-next .page-slot[data-slot="right"] canvas {
    transform-origin: left center;
    animation: pageRevealRight 640ms cubic-bezier(0.18, 0.84, 0.2, 1);
}

.book-spread.turn-next .page-slot[data-slot="left"] canvas {
    animation: pageSettleLeft 520ms cubic-bezier(0.2, 0.82, 0.22, 1);
}

.book-spread.turn-prev .page-slot[data-slot="left"] canvas {
    transform-origin: right center;
    animation: pageRevealLeft 640ms cubic-bezier(0.18, 0.84, 0.2, 1);
}

.book-spread.turn-prev .page-slot[data-slot="right"] canvas {
    animation: pageSettleRight 520ms cubic-bezier(0.2, 0.82, 0.22, 1);
}

.book-spread.turning-next .page-slot[data-slot="left"] canvas,
.book-spread.turning-prev .page-slot[data-slot="right"] canvas {
    opacity: 0.42;
    filter: brightness(0.82) saturate(0.82);
    transform: scale(0.992);
    transition: opacity 220ms ease, filter 220ms ease, transform 220ms ease;
}

.book-spread.turning-next .page-slot[data-slot="right"] canvas,
.book-spread.turning-prev .page-slot[data-slot="left"] canvas {
    opacity: 0.68;
    filter: brightness(0.92);
    transition: opacity 220ms ease, filter 220ms ease;
}

.page-slot {
    position: relative;
    display: grid;
    align-items: center;
    justify-items: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    overflow: visible;
}

.page-slot[data-slot="left"] {
    justify-items: end;
}

.page-slot[data-slot="right"] {
    justify-items: start;
}

.page-slot.hidden {
    display: none;
}

.page-slot canvas {
    display: block;
    background: var(--paper);
    box-shadow: var(--shadow);
    backface-visibility: hidden;
    transform-origin: center center;
}

.page-slot:first-child canvas {
    border-radius: 4px 0 0 4px;
}

.page-slot:last-of-type canvas {
    border-radius: 0 4px 4px 0;
}

.book-spread.single canvas {
    border-radius: 4px;
}

.turn-preview {
    position: absolute;
    top: var(--turn-top);
    left: 50%;
    z-index: 7;
    width: var(--turn-width);
    height: var(--turn-height);
    pointer-events: none;
    transform-style: preserve-3d;
    perspective: 1200px;
}

.turn-preview-next {
    transform: translateX(-6px);
}

.turn-preview-prev {
    transform: translateX(calc(-100% + 6px));
}

.turn-curl,
.turn-edge {
    position: absolute;
    inset: 0;
    display: block;
    border-radius: 4px;
}

.turn-curl {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.94), rgba(244, 241, 235, 0.96) 38%, rgba(208, 201, 190, 0.78) 58%, rgba(255, 255, 255, 0.9)),
        radial-gradient(circle at 18% 50%, rgba(255, 255, 255, 0.9), transparent 44%);
    box-shadow:
        0 26px 70px rgba(0, 0, 0, 0.36),
        inset 18px 0 28px rgba(255, 255, 255, 0.55),
        inset -28px 0 42px rgba(0, 0, 0, 0.2);
    opacity: 0.92;
}

.turn-preview-next .turn-curl {
    transform-origin: left center;
    animation: pageCurlHoldNext 900ms ease-in-out infinite alternate;
}

.turn-preview-prev .turn-curl {
    transform-origin: right center;
    animation: pageCurlHoldPrev 900ms ease-in-out infinite alternate;
}

.turn-preview.is-opening-next .turn-curl {
    animation: pageCurlOpenNext 860ms cubic-bezier(0.16, 0.84, 0.2, 1) forwards;
}

.turn-preview.is-opening-prev .turn-curl {
    animation: pageCurlOpenPrev 860ms cubic-bezier(0.16, 0.84, 0.2, 1) forwards;
}

.turn-edge {
    opacity: 0.88;
    mix-blend-mode: multiply;
}

.turn-preview-next .turn-edge {
    left: auto;
    width: 34px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.28));
}

.turn-preview-prev .turn-edge {
    right: auto;
    width: 34px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.28), transparent);
}

.turn-sheet {
    position: absolute;
    z-index: 6;
    display: block;
    background: var(--paper);
    pointer-events: none;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
    filter: brightness(1);
}

.turn-sheet::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.2));
}

.turn-sheet-next {
    transform-origin: left center;
    animation: pageFlipNext 720ms cubic-bezier(0.16, 0.8, 0.18, 1) forwards;
}

.turn-sheet-prev {
    transform-origin: right center;
    animation: pageFlipPrev 720ms cubic-bezier(0.16, 0.8, 0.18, 1) forwards;
}

.page-label {
    position: absolute;
    right: 12px;
    bottom: 10px;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.54);
    color: rgba(255, 255, 255, 0.86);
    font-size: 12px;
}

.loader {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    padding: 18px;
    background: radial-gradient(circle at 50% 48%, rgba(0, 0, 0, 0.26), transparent 42%);
}

.loader.hidden {
    display: none;
}

.loader.compact {
    place-items: start center;
    padding-top: 18px;
    background: transparent;
}

.loader-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
    width: min(440px, 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 14px 16px;
    background: rgba(20, 19, 18, 0.84);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(12px);
}

.loader.compact .loader-card {
    width: min(360px, 100%);
    padding: 10px 12px;
    background: rgba(20, 19, 18, 0.72);
}

.loader-spinner {
    grid-row: 1 / span 2;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-top-color: #fff;
    border-radius: 50%;
    animation: loaderSpin 820ms linear infinite;
}

.loader-card strong {
    color: #fff;
    font-size: 15px;
    line-height: 1.25;
}

.loader-card small {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    line-height: 1.35;
}

.nav-button {
    position: fixed;
    top: 50%;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 52px;
    height: 74px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 6px;
    background: rgba(20, 19, 18, 0.64);
    color: #fff;
    cursor: pointer;
    font-size: 42px;
    transform: translateY(-50%);
}

.nav-button:hover {
    background: rgba(20, 19, 18, 0.86);
}

.nav-prev {
    left: 14px;
}

.nav-next {
    right: 14px;
}

.reader-bottom {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9;
    display: grid;
    gap: 10px;
    padding: 18px 16px 14px;
    background: rgba(20, 19, 18, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -20px 48px rgba(0, 0, 0, 0.34);
    opacity: 0.7;
    transform: translateY(calc(100% - 18px));
    transition: transform 260ms ease, opacity 220ms ease;
    backdrop-filter: blur(14px);
}

.reader-bottom::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
        linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
    cursor: ns-resize;
}

.reader-shell.controls-visible .reader-bottom,
.reader-bottom:hover,
.reader-bottom:focus-within {
    opacity: 1;
    transform: translateY(0);
}

.page-controls {
    display: grid;
    grid-template-columns: auto minmax(90px, 1fr) auto auto;
    align-items: center;
    gap: 10px;
}

.small-icon {
    width: 32px;
    height: 32px;
    font-size: 24px;
}

#pageRange {
    width: 100%;
    accent-color: var(--accent);
}

#pageCounter {
    min-width: 86px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 13px;
    text-align: right;
}

.thumb-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.thumb-button {
    position: relative;
    flex: 0 0 auto;
    width: 58px;
    height: 76px;
    border: 2px solid transparent;
    border-radius: 5px;
    padding: 0;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.thumb-button canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 3px;
    object-fit: cover;
    background: #fff;
}

.thumb-button span {
    position: absolute;
    right: 3px;
    bottom: 3px;
    border-radius: 999px;
    padding: 1px 5px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 10px;
}

.thumb-button.active {
    border-color: #fff;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 54px;
    z-index: 10;
    max-width: min(420px, calc(100% - 24px));
    border-radius: 6px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@keyframes pageFlipNext {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
        filter: brightness(1);
    }
    42% {
        transform: translateX(-18px) rotateY(-78deg) skewY(-1deg);
        opacity: 0.96;
        filter: brightness(0.82);
    }
    100% {
        transform: translateX(-54px) rotateY(-168deg) skewY(-2deg);
        opacity: 0;
        filter: brightness(0.7);
    }
}

@keyframes pageFlipPrev {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
        filter: brightness(1);
    }
    42% {
        transform: translateX(18px) rotateY(78deg) skewY(1deg);
        opacity: 0.96;
        filter: brightness(0.82);
    }
    100% {
        transform: translateX(54px) rotateY(168deg) skewY(2deg);
        opacity: 0;
        filter: brightness(0.7);
    }
}

@keyframes pageCurlHoldNext {
    0% {
        transform: translateX(0) rotateY(-20deg) skewY(-0.8deg);
        opacity: 0.78;
        filter: brightness(0.98);
    }
    100% {
        transform: translateX(-18px) rotateY(-54deg) skewY(-1.8deg);
        opacity: 0.94;
        filter: brightness(0.86);
    }
}

@keyframes pageCurlHoldPrev {
    0% {
        transform: translateX(0) rotateY(20deg) skewY(0.8deg);
        opacity: 0.78;
        filter: brightness(0.98);
    }
    100% {
        transform: translateX(18px) rotateY(54deg) skewY(1.8deg);
        opacity: 0.94;
        filter: brightness(0.86);
    }
}

@keyframes pageCurlOpenNext {
    0% {
        transform: translateX(-16px) rotateY(-42deg) skewY(-1.5deg);
        opacity: 0.94;
        filter: brightness(0.9);
    }
    54% {
        transform: translateX(-72px) rotateY(-118deg) skewY(-2.4deg);
        opacity: 0.88;
        filter: brightness(0.78);
    }
    100% {
        transform: translateX(-116px) rotateY(-174deg) skewY(-2deg);
        opacity: 0;
        filter: brightness(0.68);
    }
}

@keyframes pageCurlOpenPrev {
    0% {
        transform: translateX(16px) rotateY(42deg) skewY(1.5deg);
        opacity: 0.94;
        filter: brightness(0.9);
    }
    54% {
        transform: translateX(72px) rotateY(118deg) skewY(2.4deg);
        opacity: 0.88;
        filter: brightness(0.78);
    }
    100% {
        transform: translateX(116px) rotateY(174deg) skewY(2deg);
        opacity: 0;
        filter: brightness(0.68);
    }
}

@keyframes pageRevealRight {
    0% {
        opacity: 0.35;
        filter: brightness(0.86);
        transform: perspective(1200px) rotateY(18deg) translateX(-18px);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
        transform: perspective(1200px) rotateY(0deg) translateX(0);
    }
}

@keyframes pageRevealLeft {
    0% {
        opacity: 0.35;
        filter: brightness(0.86);
        transform: perspective(1200px) rotateY(-18deg) translateX(18px);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
        transform: perspective(1200px) rotateY(0deg) translateX(0);
    }
}

@keyframes pageSettleLeft {
    0% {
        opacity: 0.54;
        filter: brightness(0.92);
        transform: translateX(8px) scale(0.994);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
        transform: translateX(0) scale(1);
    }
}

@keyframes pageSettleRight {
    0% {
        opacity: 0.54;
        filter: brightness(0.92);
        transform: translateX(-8px) scale(0.994);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
        transform: translateX(0) scale(1);
    }
}

@keyframes loaderSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 820px) {
    .shelf-intro h1,
    .admin-head h1 {
        font-size: 38px;
        line-height: 1.04;
    }

    .shelf-intro,
    .shelf-head,
    .shelf-layout,
    .archive-hero,
    .archive-layout,
    .admin-head,
    .admin-item {
        display: grid;
    }

    .archive-hero {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .archive-hero-mark {
        justify-items: start;
        padding: 0;
    }

    .archive-hero-mark img {
        width: 150px;
    }

    .archive-layout {
        grid-template-columns: 1fr;
    }

    .year-panel {
        position: static;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        order: -1;
    }

    .year-panel-head {
        grid-column: 1 / -1;
    }

    .archive-issues {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .archive-year summary {
        flex-wrap: wrap;
        padding: 12px 0;
    }

    .archive-year-meta {
        order: 3;
        width: 100%;
        margin-left: 0;
    }

    .rubric-panel {
        position: static;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        order: -1;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .admin-actions {
        justify-content: flex-start;
    }

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

    .reader-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }

    .reader-stage {
        padding: 12px 12px 18px;
    }

    .book-frame {
        height: 100%;
    }

    .book-spread {
        grid-template-columns: minmax(0, 1fr);
        width: min(680px, 100%);
    }

    .nav-button {
        display: none;
    }

    .page-slot:first-child canvas,
    .page-slot:last-of-type canvas {
        border-radius: 4px;
    }

    .page-slot[data-slot="left"],
    .page-slot[data-slot="right"] {
        justify-items: center;
    }

    .reader-bottom {
        max-height: min(48vh, 310px);
        padding: 16px 10px 10px;
        transform: translateY(calc(100% - 16px));
    }

    .reader-bottom::before {
        height: 16px;
    }

    .thumb-strip {
        gap: 7px;
    }

    .thumb-button {
        width: 48px;
        height: 66px;
    }

    .cover-art {
        min-height: 0;
    }
}

@media (max-width: 520px) {
    .topbar {
        padding-inline: 14px;
    }

    .brand span:last-child {
        display: inline;
    }

    .archive-page .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
        width: 100vw;
        max-width: 100vw;
        justify-content: flex-start;
        padding-inline: 12px;
    }

    .archive-page .brand {
        max-width: 100%;
        gap: 9px;
    }

    .archive-page .brand-logo-wrap {
        width: 44px;
        height: 34px;
    }

    .archive-page .brand-logo {
        max-width: 44px;
        max-height: 34px;
    }

    .archive-page .brand span:last-child {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .archive-page .topbar-actions {
        width: 100%;
        margin-left: 0;
    }

    .archive-page .topbar-actions .ghost-button {
        width: 100%;
    }

    .shelf-wrap,
    .admin-wrap {
        width: 366px;
        max-width: calc(100vw - 24px);
        margin-right: 12px;
        margin-left: 12px;
        padding-top: 28px;
    }

    .empty-state,
    .panel {
        width: 100%;
        max-width: 100%;
    }

    .archive-hero,
    .archive-tools,
    .archive-search,
    .archive-search input {
        max-width: 100%;
    }

    .archive-hero-copy h1 {
        font-size: 34px;
        line-height: 1.02;
    }

    .archive-tools {
        display: grid;
    }

    .archive-tool-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .archive-tool-actions .small-button {
        min-width: 0;
        padding-inline: 8px;
    }

    .archive-issues {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .archive-issue {
        min-height: 118px;
        padding: 11px;
    }

    .archive-year-title {
        font-size: 32px;
    }

    .magazine-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 14px;
    }

    .shelf-head {
        align-items: start;
    }

    .shelf-head h1 {
        font-size: 28px;
    }

    .magazine-card-body h2 {
        font-size: 16px;
    }

    .page-controls {
        grid-template-columns: auto minmax(80px, 1fr) auto;
    }

    #pageCounter {
        grid-column: 1 / -1;
        min-width: 0;
        text-align: center;
    }

    .reader-bottom {
        padding-inline: 10px;
    }
}
