/* ============================================================
   E-Paper — Public frontend styles
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
    --ep-ink: #0f172a;
    --ep-paper: #f4f7fb;
    --ep-surface: #ffffff;
    --ep-accent: #2563eb;
    --ep-accent-dark: #1d4ed8;
    --ep-navy: #0f172a;
    --ep-navy-2: #1e3a5f;
    --ep-muted: #64748b;
    --ep-rule: rgba(15, 23, 42, 0.1);
    --ep-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
    --ep-shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.08);
    --ep-radius: 12px;
    --ep-radius-sm: 8px;
    --ep-primary-rgb: 15, 23, 42;
    --ep-secondary-rgb: 30, 58, 95;
    --ep-accent-rgb: 37, 99, 235;
    --font-display: "Libre Baskerville", Georgia, serif;
    --font-body: "Source Sans 3", "Segoe UI", sans-serif;
    --nav-height: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html, body {
    min-height: 100%;
}

.epaper-body {
    font-family: var(--font-body);
    color: var(--ep-ink);
    background:
        radial-gradient(900px 420px at 8% -8%, rgba(var(--ep-accent-rgb), 0.1), transparent 55%),
        radial-gradient(700px 360px at 96% 0%, rgba(var(--ep-primary-rgb), 0.08), transparent 50%),
        linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

.epaper-main {
    flex: 1 0 auto;
}

.epaper-navbar {
    background: linear-gradient(90deg, var(--ep-navy), var(--ep-navy-2));
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.22);
    min-height: var(--nav-height);
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.epaper-navbar .nav-link {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.55rem 0.85rem !important;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.86) !important;
    transition: background 0.15s ease, color 0.15s ease;
}

.epaper-navbar .nav-link:hover,
.epaper-navbar .nav-link:focus,
.epaper-navbar .nav-link.show {
    background: rgba(255, 255, 255, 0.1);
    color: #fff !important;
}

.nav-date-chip {
    align-items: center;
    gap: 0.4rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.btn-nav-icon {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    padding: 0;
}

.btn-nav-icon:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.epaper-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.28);
    padding: 0.35rem 0.5rem;
}

.epaper-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.15);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* Logo-only brand: uses the space previously taken by logo + site name */
.navbar-brand-logo-only {
    gap: 0;
}

.site-logo {
    height: 42px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
    display: block;
}

.navbar-brand-logo-only .site-logo {
    height: 48px;
    max-width: min(260px, 55vw);
}

@media (max-width: 575.98px) {
    .navbar-brand-logo-only .site-logo {
        height: 40px;
        max-width: min(180px, 48vw);
    }
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    background: var(--ep-accent);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    border-radius: 4px;
}

.brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Hero */
.hero-section {
    padding: 2rem 0 1.5rem;
}

.hero-front {
    background: #fff;
    border: 1px solid var(--ep-rule);
    box-shadow: var(--ep-shadow);
    overflow: hidden;
}

.hero-front img {
    width: 100%;
    height: auto;
    display: block;
}

.hero-copy h1 {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 4vw, 2.6rem);
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.btn-epaper {
    background: var(--ep-accent);
    border-color: var(--ep-accent);
    color: #fff;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(var(--ep-accent-rgb), 0.28);
}

.btn-epaper:hover {
    background: var(--ep-accent-dark);
    border-color: var(--ep-accent-dark);
    color: #fff;
}

.btn-outline-dark,
.btn-outline-secondary {
    border-radius: 999px;
}

.form-select.paper-jump,
.paper-controls .form-select {
    border-radius: 999px;
    border-color: var(--ep-rule);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Ticker */
.headline-ticker {
    background: var(--ep-ink);
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

.ticker-track {
    display: inline-block;
    padding: 0.55rem 0;
    animation: ticker 40s linear infinite;
}

.ticker-track span {
    margin-right: 2.5rem;
}

.ticker-track span::before {
    content: "•";
    margin-right: 0.6rem;
    color: var(--ep-accent);
}

@keyframes ticker {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Edition cards */
.edition-card {
    background: #fff;
    border: 1px solid var(--ep-rule);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}

.edition-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--ep-shadow);
}

.edition-card img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: #ddd;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    padding-bottom: 0.4rem;
}

.section-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 48px;
    height: 3px;
    background: var(--ep-accent);
}

/* Viewer — shares homepage light reader UI */
.viewer-desk {
    padding-bottom: 2rem;
}

.viewer-controls {
    position: sticky;
    top: calc(var(--nav-height) + 4px);
    z-index: 30;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ep-rule);
    border-radius: 999px;
    padding: 0.45rem 0.65rem;
    margin-top: 0 !important;
    box-shadow: var(--ep-shadow-sm);
}

.viewer-stage img#mainPageImage {
    cursor: grab;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.16);
    border-radius: 2px;
}

.paper-page-frame {
    max-width: min(920px, 100%);
}

.thumb-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.75rem 0;
}

.thumb-strip .thumb-item,
.reader-thumbs .thumb-item,
.reader-thumbs .home-thumb {
    flex: 0 0 auto;
    width: 72px;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.75;
    position: relative;
    padding: 0;
    background: transparent;
    text-decoration: none;
    display: block;
}

.thumb-strip .thumb-item.active,
.thumb-strip .thumb-item:hover,
.reader-thumbs .thumb-item.active,
.reader-thumbs .thumb-item:hover,
.reader-thumbs .home-thumb.active,
.reader-thumbs .home-thumb:hover {
    border-color: var(--ep-accent);
    opacity: 1;
}

.thumb-strip img,
.reader-thumbs img {
    width: 100%;
    display: block;
}

.thumb-strip .thumb-item canvas,
.reader-thumbs .thumb-item canvas {
    display: block;
    width: 72px;
    height: auto;
}

.thumb-label {
    position: absolute;
    left: 4px;
    top: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    line-height: 1.2;
}

/* Left thumbs + right reader */
.reader-layout {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.02)),
        #e8edf3;
    border: 1px solid var(--ep-rule);
    border-radius: 14px;
    padding: 0.75rem;
    min-height: 0;
}

.reader-layout-dark {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.08);
}

.reader-thumbs {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    overflow-y: auto;
    position: sticky;
    top: calc(var(--nav-height, 64px) + 12px);
    max-height: calc(100vh - 100px);
    padding-right: 0.25rem;
    scrollbar-width: thin;
    align-self: start;
}

.reader-thumbs-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ep-muted);
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
    padding-bottom: 0.15rem;
}

.reader-layout-dark .reader-thumbs-title {
    color: rgba(255, 255, 255, 0.55);
}

.reader-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    height: auto;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.reader-main > .paper-controls {
    margin-top: 0;
    flex: 0 0 auto;
}

/* Full page visible by default — no fixed viewport box / inner scrollbar */
.reader-stage,
.viewer-stage,
.home-pdf-stage,
#homePaperStage,
#viewerStage {
    position: relative;
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    text-align: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    touch-action: manipulation;
}

.reader-layout-dark .reader-stage,
.reader-layout-dark .viewer-stage {
    background: transparent;
}

.reader-stage .paper-sheet {
    display: block;
    width: 100%;
    max-width: min(960px, 100%);
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
    overflow: visible;
    height: auto;
}

.reader-stage .paper-sheet img,
.reader-stage #homePaperImage,
.viewer-stage img#mainPageImage {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: none !important;
    height: auto !important;
    transform-origin: top center;
    transition: width 0.15s ease, opacity 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.paper-sheet-frame {
    width: 100%;
}

.paper-sheet-frame .hotspot {
    z-index: 3;
}

.reader-stage .paper-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.reader-stage .paper-nav-prev { left: 8px; }
.reader-stage .paper-nav-next { right: 8px; }

.reader-empty {
    color: inherit;
    opacity: 0.85;
}

.pdf-page-canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    background: #fff;
    cursor: grab;
    margin: 0 auto;
    display: block;
}

.viewer-stage.is-loading {
    min-height: 50vh;
}

.hotspot {
    position: absolute;
    border: 2px solid rgba(var(--ep-accent-rgb), 0.7);
    background: rgba(var(--ep-accent-rgb), 0.12);
    cursor: pointer;
}

.hotspot:hover {
    background: rgba(var(--ep-accent-rgb), 0.28);
}

/* Cropped article lightbox */
.article-crop-modal .modal-body {
    background: #f4f6f8;
}

.article-crop-zoom-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.article-crop-zoom-label {
    min-width: 3.2rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.article-crop-wrap {
    background: #0f172a;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    overflow: auto;
    max-height: min(72vh, 820px);
    touch-action: pan-x pan-y pinch-zoom;
}

.article-crop-canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    background: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    transform-origin: center center;
}

.article-crop-text {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--ep-ink, #1e293b);
}

@media (max-width: 575.98px) {
    .article-crop-modal .modal-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .article-crop-zoom-bar {
        order: 3;
        width: 100%;
        justify-content: center;
        margin: 0 !important;
    }
}

/* Clip tool */
.clip-canvas-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.clip-canvas-wrap img,
.clip-canvas-wrap canvas {
    max-width: 100%;
    display: block;
}

#clipOverlay {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}

.clip-selection {
    position: absolute;
    border: 2px dashed var(--ep-accent);
    background: rgba(var(--ep-accent-rgb), 0.15);
    pointer-events: none;
}

/* Archive calendar */
.cal-day {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px solid var(--ep-rule);
    background: #fff;
    color: inherit;
    text-decoration: none;
}

.cal-day.has-issue {
    background: rgba(var(--ep-accent-rgb), 0.15);
    font-weight: 700;
    color: var(--ep-accent-dark);
}

.cal-day.today {
    outline: 2px solid var(--ep-navy);
}

.cal-day.muted {
    opacity: 0.35;
    pointer-events: none;
}

.row-cols-7 > * {
    flex: 0 0 auto;
    width: 14.2857%;
}

/* Footer */
.epaper-footer {
    background: var(--ep-navy);
    color: rgba(255, 255, 255, 0.85);
}

.footer-title {
    font-family: var(--font-display);
    color: #fff;
}

.footer-links a,
.social-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
}

.footer-links a:hover,
.social-links a:hover {
    color: #fff;
}

/* Ad placements — clear, readable sizes */
.ad-slot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.85rem;
}

.ad-slot a {
    display: block;
    max-width: 100%;
}

.ad-slot img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: var(--ep-shadow-sm);
    background: #fff;
}

.ad-header,
.ad-footer {
    padding: 0.75rem 0;
}

.ad-header img,
.ad-footer img {
    width: 100%;
    max-width: 1200px;
    max-height: 180px;
    object-fit: contain;
}

.ad-band {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--ep-rule);
    border-radius: var(--ep-radius);
    box-shadow: var(--ep-shadow-sm);
}

.ad-band-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ep-muted);
    margin-bottom: 0.75rem;
}

.ad-band .ad-slot {
    gap: 1rem;
}

.ad-band img,
.ad-inline img {
    width: 100%;
    max-width: 336px;
    max-height: 280px;
    object-fit: contain;
}

@media (max-width: 767.98px) {
    .viewer-stage,
    .reader-stage,
    .home-pdf-stage {
        max-height: none;
        overflow: visible;
        padding: 0.5rem;
    }
    .hero-section {
        padding-top: 1.25rem;
    }
}

/* ============================================================
   Newspaper desk homepage
   ============================================================ */
.paper-desk {
    padding: 1.25rem 0 1.5rem;
}

.paper-desk-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.paper-desk-kicker {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--ep-muted);
    font-weight: 600;
}

.paper-desk-title {
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 3vw, 1.9rem);
    margin: 0.2rem 0 0;
    line-height: 1.25;
}

.paper-desk-title span {
    color: var(--ep-muted);
    font-weight: 400;
}

.paper-desk-note {
    font-size: 0.85rem;
    color: var(--ep-muted);
    margin-top: 0.35rem;
}

.edition-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.edition-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--ep-rule);
    background: #fff;
    color: var(--ep-ink);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 999px;
}

.edition-pill.active,
.edition-pill:hover {
    background: var(--ep-navy);
    border-color: var(--ep-navy);
    color: #fff;
}

.paper-stage {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.02)),
        #e8edf3;
    border: 1px solid var(--ep-rule);
    border-radius: 14px;
    padding: 0.75rem;
    min-height: 58vh;
}

.paper-sheet-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.paper-sheet {
    background: #fff;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(15, 23, 42, 0.08);
    max-width: min(960px, 100%);
    width: 100%;
    overflow: visible;
    height: auto;
}

.paper-sheet img {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity 0.15s ease;
    user-select: none;
}

.paper-page-badge {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.paper-nav {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--ep-rule);
    background: #fff;
    color: var(--ep-ink);
    display: grid;
    place-items: center;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
    z-index: 2;
}

.paper-nav:hover {
    background: var(--ep-navy);
    border-color: var(--ep-navy);
    color: #fff;
}

.paper-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.85rem;
}

.paper-controls-left,
.paper-controls-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.paper-jump {
    width: auto;
    min-width: 140px;
}

.home-thumb-strip {
    display: flex;
    gap: 0.55rem;
    overflow-x: auto;
    padding: 0.85rem 0 0.25rem;
    scrollbar-width: thin;
}

.reader-thumbs .home-thumb,
.reader-thumbs .thumb-item {
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
    width: 84px;
}

.reader-layout-dark .reader-thumbs .thumb-item {
    background: #0b1220;
}

.reader-thumbs .home-thumb img,
.reader-thumbs .thumb-item img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    object-position: top center;
    display: block;
    background: #e2e8f0;
    min-height: 96px;
}

.paper-empty-card {
    background: #fff;
    border: 1px solid var(--ep-rule);
    border-radius: 14px;
    padding: 3rem 1.5rem;
}

.edition-card.is-active {
    outline: 2px solid var(--ep-accent);
    outline-offset: 2px;
}

.edition-card-empty {
    aspect-ratio: 3/4;
    display: grid;
    place-items: center;
    background: #eef2f7;
    color: var(--ep-muted);
    font-weight: 700;
    overflow: hidden;
}

.edition-card-empty.has-pdf-cover {
    padding: 0;
    display: block;
}

.edition-card-pdf-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    aspect-ratio: 3/4;
}

.other-editions-section {
    border-top: 1px solid var(--ep-rule);
    background: rgba(255, 255, 255, 0.35);
}


/* CMS pages */
.cms-page-section {
    background: rgba(255, 255, 255, 0.45);
}

.cms-side-nav {
    background: #fff;
    border: 1px solid var(--ep-rule);
    border-radius: 12px;
    padding: 1rem 0.75rem;
    position: sticky;
    top: 80px;
}

.cms-side-label {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ep-muted);
    padding: 0 0.75rem 0.5rem;
    font-weight: 700;
}

.cms-side-nav a {
    display: block;
    padding: 0.55rem 0.75rem;
    color: var(--ep-ink);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
}

.cms-side-nav a:hover,
.cms-side-nav a.active {
    background: rgba(var(--ep-accent-rgb), 0.1);
    color: var(--ep-accent-dark);
}

.cms-article {
    background: #fff;
    border: 1px solid var(--ep-rule);
    border-radius: 14px;
    padding: 1.5rem 1.5rem 2rem;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.05);
}

.cms-kicker {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.72rem;
    color: var(--ep-muted);
    font-weight: 700;
}

.cms-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.cms-content {
    line-height: 1.7;
    color: #1f2937;
}

.cms-content h2 {
    font-family: var(--font-display);
    margin-top: 1.25rem;
}

.cms-contact-meta {
    display: grid;
    gap: 0.35rem;
    color: var(--ep-muted);
}

.paper-stage-pdf {
    display: block;
    padding: 0.75rem;
    background: #e8edf3;
}

.home-pdf-stage {
    background: transparent;
    padding: 0.5rem;
}

.home-pdf-stage .pdf-page-canvas,
.pdf-page-canvas {
    margin: 0 auto;
    display: block;
    width: auto;
    max-width: 100%;
    max-height: none !important;
    height: auto !important;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
}

.home-pdf-stage .pdf-loading {
    color: var(--ep-ink) !important;
}

.home-pdf-stage .spinner-border {
    color: var(--ep-accent) !important;
}

.paper-controls-pdf {
    margin-top: 0;
}

/* ============================================================
   Editions navbar panel (enterprise)
   ============================================================ */
.editions-dropdown .dropdown-toggle::after {
    margin-left: 0.35rem;
    vertical-align: 0.15em;
}

.editions-panel {
    --bs-dropdown-min-width: 300px;
    width: min(320px, calc(100vw - 1.5rem));
    padding: 0;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    margin-top: 0.65rem !important;
    background: #fff;
}

.editions-panel-head {
    padding: 0.95rem 1rem 0.75rem;
    background:
        linear-gradient(135deg, rgba(var(--ep-accent-rgb), 0.08), rgba(var(--ep-primary-rgb), 0.04));
    border-bottom: 1px solid var(--ep-rule);
}

.editions-panel-kicker {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ep-muted);
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.editions-panel-head strong {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--ep-ink);
}

.editions-panel-list {
    padding: 0.45rem;
    max-height: min(52vh, 360px);
    overflow-y: auto;
}

.editions-panel-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.7rem;
    border-radius: 12px;
    text-decoration: none;
    color: var(--ep-ink);
    transition: background 0.15s ease, transform 0.15s ease;
}

.editions-panel-item:hover {
    background: rgba(var(--ep-accent-rgb), 0.08);
    color: var(--ep-ink);
}

.editions-panel-item.active {
    background: rgba(var(--ep-accent-rgb), 0.12);
    box-shadow: inset 0 0 0 1px rgba(var(--ep-accent-rgb), 0.25);
}

.editions-panel-badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    background: linear-gradient(145deg, var(--ep-navy), var(--ep-navy-2));
    flex: 0 0 auto;
}

.editions-panel-item.active .editions-panel-badge {
    background: linear-gradient(145deg, var(--ep-accent), var(--ep-accent-dark));
}

.editions-panel-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.editions-panel-name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.editions-panel-meta {
    font-size: 0.75rem;
    color: var(--ep-muted);
}

.editions-panel-arrow {
    color: var(--ep-muted);
    font-size: 0.85rem;
}

.editions-panel-foot {
    border-top: 1px solid var(--ep-rule);
    padding: 0.65rem 1rem;
    background: #f8fafc;
}

.editions-panel-foot a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ep-accent-dark);
    text-decoration: none;
}

.editions-panel-foot a:hover {
    text-decoration: underline;
}

.ep-dropdown {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
    padding: 0.4rem;
    overflow: hidden;
}

.ep-dropdown .dropdown-item {
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.55rem 0.75rem;
}

.ep-dropdown .dropdown-item:hover,
.ep-dropdown .dropdown-item:focus {
    background: rgba(var(--ep-accent-rgb), 0.1);
    color: var(--ep-ink);
}

/* Keep any legacy dark reader classes on light theme */
.reader-layout-dark {
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.02)),
        #e8edf3;
    border-color: var(--ep-rule);
    color: var(--ep-ink);
}

.reader-layout-dark .reader-thumbs-title {
    color: var(--ep-muted);
}

.reader-layout-dark .reader-thumbs .thumb-item {
    background: #fff;
}

.edition-card {
    border-radius: var(--ep-radius);
    overflow: hidden;
    box-shadow: var(--ep-shadow-sm);
}

.paper-empty-card {
    box-shadow: var(--ep-shadow-sm);
}

.epaper-footer {
    margin-top: 1rem;
}

@media (max-width: 991.98px) {
    .editions-panel {
        width: 100%;
        max-width: none;
        margin-top: 0.4rem !important;
    }

    .epaper-navbar .navbar-nav {
        padding: 0.5rem 0 0.75rem;
        gap: 0.15rem;
    }

    .epaper-navbar .nav-link {
        border-radius: 10px;
    }
}

@media (max-width: 767.98px) {
    :root {
        --nav-height: 58px;
    }

    .paper-desk {
        padding: 0.85rem 0 1.25rem;
    }

    .paper-desk-title {
        font-size: 1.35rem;
    }

    .edition-pills {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.15rem;
        -webkit-overflow-scrolling: touch;
    }

    .edition-pill {
        flex: 0 0 auto;
    }

    .paper-stage {
        grid-template-columns: 1fr;
        padding: 0.5rem;
        min-height: auto;
    }

    .reader-layout {
        grid-template-columns: 1fr;
        padding: 0.55rem;
        min-height: auto;
        border-radius: 12px;
    }

    .reader-thumbs {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.35rem;
        order: 2;
        gap: 0.45rem;
    }

    .reader-thumbs-title {
        display: none;
    }

    .reader-main {
        order: 1;
    }

    .reader-stage,
    .viewer-stage,
    .home-pdf-stage,
    #homePaperStage,
    #viewerStage {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0.45rem;
    }

    .reader-thumbs {
        position: static;
        max-height: none;
    }

    .reader-stage .paper-sheet,
    .paper-sheet,
    .paper-page-frame,
    #homePageFrame,
    #pageFrame {
        max-width: 100%;
        width: 100%;
        height: auto !important;
        overflow: visible !important;
    }

    .viewer-controls {
        border-radius: 14px;
        position: static;
        backdrop-filter: none;
    }

    .paper-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 38px;
        height: 38px;
    }

    .paper-nav-prev { left: 6px; }
    .paper-nav-next { right: 6px; }

    .paper-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .paper-controls-left,
    .paper-controls-right {
        justify-content: center;
        flex-wrap: wrap;
    }

    .viewer-controls .paper-controls-right .btn,
    .viewer-controls .paper-controls-left .btn {
        font-size: 0.8rem;
    }
}
