/* ===== ePaper — shared styles (public site + auth screens) ===== */

:root {
    --color-ink: #14161f;
    --color-ink-soft: #262a36;
    --color-text: #262a33;
    --color-muted: #6b7280;
    --color-border: #e7e4df;
    --color-bg: #f7f6f2;
    --color-surface: #ffffff;
    --color-surface-alt: #fbfaf7;
    --color-accent: #c8262f;
    --color-accent-dark: #971b22;
    --color-accent-light: #ff5a63;
    --color-accent-soft: #fdeceb;
    --color-success-bg: #eaf6ec;
    --color-success-text: #1e6b34;
    --color-error-bg: #fbeaea;
    --color-error-text: #a3272c;
    /* Header bar background — a light glass tint of this theme's accent
       color, so the top bar visibly changes color with the theme instead
       of staying plain white for every theme. See body[data-theme="..."]
       blocks below for each theme's matching values. */
    --color-header-bg: rgba(243,207,209,0.9);
    --color-header-bg-scrolled: rgba(239,190,193,0.95);
    /* Plain R,G,B triplet (no parens/hash) so accent-tinted shadows and
       overlays elsewhere in the sheet can build their own alpha via
       rgba(var(--color-accent-rgb), N) instead of being stuck with one
       hard-coded color for every theme. */
    --color-accent-rgb: 200,38,47;
    --gradient-accent: linear-gradient(135deg, var(--color-accent), var(--color-accent-light));
    --gradient-ink: linear-gradient(120deg, #0f1117, #1f2330 60%, #262a3a);
    --font-serif: 'Playfair Display', Georgia, 'Times New Roman', Times, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 22px;
    --shadow: 0 1px 3px rgba(20,22,31,0.07), 0 1px 2px rgba(20,22,31,0.05);
    --shadow-md: 0 12px 28px rgba(20,22,31,0.10), 0 2px 6px rgba(20,22,31,0.06);
    --shadow-lg: 0 24px 55px rgba(20,22,31,0.18), 0 6px 16px rgba(20,22,31,0.08);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ================= Designer themes =====================================
   Selected in Admin → Site Settings. "classic-red" is the default look
   (same values as :root above, no override block needed). Each of the
   other five re-declares the same custom-property set with a different
   palette; everything else in the stylesheet reads these variables, so a
   theme switch reaches the whole public site automatically. */
body[data-theme="royal-blue"] {
    --color-ink: #0f1720; --color-ink-soft: #1c2a3d; --color-text: #1c2430; --color-muted: #64748b;
    --color-border: #dde3ec; --color-bg: #f5f7fa; --color-surface: #ffffff; --color-surface-alt: #f0f3f8;
    --color-accent: #1d4ed8; --color-accent-dark: #1e3a8a; --color-accent-light: #3b82f6; --color-accent-soft: #e8effd;
    --color-header-bg: rgba(205,216,246,0.9); --color-header-bg-scrolled: rgba(187,202,243,0.95);
    --color-accent-rgb: 29,78,216; --gradient-accent: linear-gradient(135deg, #1d4ed8, #3b82f6);
    --gradient-ink: linear-gradient(120deg, #0b1220, #16233a 60%, #1c2b45);
}
body[data-theme="emerald-green"] {
    --color-ink: #0e1a15; --color-ink-soft: #1b3227; --color-text: #1c2620; --color-muted: #5f7268;
    --color-border: #dbe7de; --color-bg: #f5f8f5; --color-surface: #ffffff; --color-surface-alt: #eef6f0;
    --color-accent: #059669; --color-accent-dark: #047857; --color-accent-light: #34d399; --color-accent-soft: #e6f7ef;
    --color-header-bg: rgba(200,232,222,0.9); --color-header-bg-scrolled: rgba(180,224,210,0.95);
    --color-accent-rgb: 5,150,105; --gradient-accent: linear-gradient(135deg, #059669, #34d399);
    --gradient-ink: linear-gradient(120deg, #0b150f, #16281f 60%, #1d3327);
}
body[data-theme="sunset-amber"] {
    --color-ink: #201408; --color-ink-soft: #3a2612; --color-text: #2a2015; --color-muted: #7a6b56;
    --color-border: #ecdfcb; --color-bg: #faf6f0; --color-surface: #ffffff; --color-surface-alt: #f6efe4;
    --color-accent: #d97706; --color-accent-dark: #b45309; --color-accent-light: #f59e0b; --color-accent-soft: #fdf1e0;
    --color-header-bg: rgba(247,225,200,0.9); --color-header-bg-scrolled: rgba(244,214,180,0.95);
    --color-accent-rgb: 217,119,6; --gradient-accent: linear-gradient(135deg, #d97706, #f59e0b);
    --gradient-ink: linear-gradient(120deg, #180f07, #2a1b0d 60%, #3a2612);
}
body[data-theme="midnight-purple"] {
    --color-ink: #160c26; --color-ink-soft: #2a1c47; --color-text: #201731; --color-muted: #6f6480;
    --color-border: #e3dbf0; --color-bg: #f8f6fb; --color-surface: #ffffff; --color-surface-alt: #f1ecf9;
    --color-accent: #7c3aed; --color-accent-dark: #5b21b6; --color-accent-light: #a78bfa; --color-accent-soft: #f1eafd;
    --color-header-bg: rgba(226,212,251,0.9); --color-header-bg-scrolled: rgba(216,196,250,0.95);
    --color-accent-rgb: 124,58,237; --gradient-accent: linear-gradient(135deg, #7c3aed, #a78bfa);
    --gradient-ink: linear-gradient(120deg, #100a1c, #1e1433 60%, #2a1c47);
}
body[data-theme="monochrome-slate"] {
    --color-ink: #101114; --color-ink-soft: #202329; --color-text: #1a1c20; --color-muted: #6b7078;
    --color-border: #e2e4e8; --color-bg: #f7f7f8; --color-surface: #ffffff; --color-surface-alt: #f0f1f3;
    --color-accent: #334155; --color-accent-dark: #1e293b; --color-accent-light: #64748b; --color-accent-soft: #eef1f4;
    --color-header-bg: rgba(210,213,218,0.9); --color-header-bg-scrolled: rgba(194,198,204,0.95);
    --color-accent-rgb: 51,65,85; --gradient-accent: linear-gradient(135deg, #334155, #64748b);
    --gradient-ink: linear-gradient(120deg, #0b0c0e, #17191d 60%, #202329);
}
body[data-theme="navy-slate"] {
    --color-ink: #0a0f1a; --color-ink-soft: #16213d; --color-text: #1b2330; --color-muted: #6b7280;
    --color-border: #cfcfd2; --color-bg: #dcdcdc; --color-surface: #ffffff; --color-surface-alt: #eaeaea;
    --color-accent: #0a1a33; --color-accent-dark: #05101f; --color-accent-light: #2f4d7a; --color-accent-soft: #e6eaf1;
    --color-header-bg: rgba(201,205,210,0.9); --color-header-bg-scrolled: rgba(182,186,194,0.95);
    --color-accent-rgb: 10,26,51; --gradient-accent: linear-gradient(135deg, #0a1a33, #2f4d7a);
    --gradient-ink: linear-gradient(120deg, #05070d, #0f1830 60%, #16213d);
}

/* Reader-facing dark mode toggle (top bar moon/sun icon). Applies on top of
   whichever designer theme is active — only the surface/text/border tokens
   are overridden here, so each theme's accent color still comes through.
   Must stay AFTER the theme blocks above: same selector specificity as
   body[data-theme=...], so source order decides the winner per property. */
body[data-mode="dark"] {
    --color-ink: #f2f1ee; --color-ink-soft: #dcdad3; --color-text: #d9d7d2; --color-muted: #9b98a0;
    --color-border: #34333c; --color-bg: #121218; --color-surface: #1a1a22; --color-surface-alt: #212129;
    --gradient-ink: linear-gradient(120deg, #050508, #101019 60%, #1a1a24);
    --shadow: 0 1px 3px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 12px 28px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.32);
    --shadow-lg: 0 24px 55px rgba(0,0,0,0.6), 0 6px 16px rgba(0,0,0,0.4);
}
body[data-mode="dark"] .site-header { background: rgba(18,18,24,0.82); }
body[data-mode="dark"] .site-header.scrolled { background: rgba(18,18,24,0.95); }
body[data-mode="dark"] .cover-placeholder { background: linear-gradient(135deg, #26262f, #1c1c24); color: #6b6a73; }
/* The uploaded logo is typically a dark design on a transparent/white
   background, made for a light header -- invert it in dark mode so it
   doesn't just vanish against the near-black top bar. */
body[data-mode="dark"] .topbar-logo-img { filter: invert(1) hue-rotate(180deg); }

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }

a { color: var(--color-accent); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { text-decoration: none; color: var(--color-accent-dark); }

:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 4px; }

.container {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Wider container for the PDF viewer sections — the newspaper page itself
   should use as much of the browser width as possible, with only a small
   margin, rather than being capped at the same width as text content. */
.container-wide {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0;
}

h1, h2, h3 { font-family: var(--font-serif); color: var(--color-ink); margin: 0 0 0.5rem; letter-spacing: -0.01em; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1.3rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background-color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.btn:hover { background: var(--color-surface-alt); text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--gradient-accent); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(var(--color-accent-rgb),0.32); }
.btn-primary:hover { box-shadow: 0 12px 26px rgba(var(--color-accent-rgb),0.4); filter: brightness(1.04); }
.btn-sm { padding: 0.42rem 0.9rem; font-size: 0.82rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ---- Alerts ---- */
.alert { padding: 0.75rem 1.1rem; border-radius: var(--radius-sm); margin: 0 0 1rem; font-size: 0.92rem; border: 1px solid transparent; }
.alert-error { background: var(--color-error-bg); color: var(--color-error-text); border-color: rgba(163,39,44,0.15); }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); border-color: rgba(30,107,52,0.15); }

/* ---- Badge ---- */
.badge { display: inline-block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.28rem 0.7rem; border-radius: 999px; background: #eee; color: #555; font-weight: 700; }
.badge-category { background: var(--gradient-accent); color: #fff; box-shadow: 0 4px 10px rgba(var(--color-accent-rgb),0.25); }

/* ================= Header ================= */
.site-header {
    position: sticky; top: 0; z-index: 40;
    background: var(--color-header-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--color-border);
    transition: box-shadow 0.25s var(--ease), background-color 0.25s var(--ease);
}
.site-header.scrolled { box-shadow: var(--shadow-md); background: var(--color-header-bg-scrolled); }

/* ================= Top bar (single icon row) ================= */
.topbar-inner { display: flex; align-items: center; gap: 0.85rem; padding: 0.6rem 1.25rem; flex-wrap: wrap; }

.topbar-left { display: flex; align-items: center; gap: 0.65rem; flex: none; }
.topbar-brand { display: flex; align-items: center; gap: 0.55rem; color: inherit; }
.topbar-brand:hover { text-decoration: none; }
/* Sized with clamp() so the logo scales fluidly with the viewport instead of
   jumping between fixed sizes at breakpoints — flexible with the layout. */
.topbar-logo-text { font-family: var(--font-serif); font-size: clamp(1.05rem, 3vw, 1.45rem); font-weight: 800; color: var(--color-ink); letter-spacing: -0.01em; white-space: nowrap; }
.topbar-logo-img { height: clamp(24px, 5vw, 40px); width: auto; max-width: 40vw; display: block; }

/* No pill/box background — sits directly on the header itself, just icon +
   control, matching the rest of the plain header row. Focus is shown as an
   accent-color change rather than an outline/box. */
.topbar-pill {
    display: flex; align-items: center; gap: 0.35rem;
    color: var(--color-muted); font-size: 0.85rem; cursor: pointer;
}
.topbar-pill:focus-within { color: var(--color-accent); }
.topbar-pill svg { flex: none; }
.topbar-pill select, .topbar-pill input[type=date] {
    border: none; background: transparent; color: var(--color-text); font-family: var(--font-sans);
    font-size: 0.85rem; padding: 0; cursor: pointer; max-width: 9.5rem;
}
.topbar-pill select:focus, .topbar-pill input[type=date]:focus { outline: none; }
/* Hide the native dropdown arrow — just the location icon + city name. */
.topbar-pill select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
}

/* City/date pills + Download/share/dark-mode/account, all grouped on the
   right (wraps onto its own row on narrow screens rather than overflowing). */
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.topbar-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none;
    border-radius: 999px; background: var(--color-surface-alt); border: 1px solid var(--color-border);
    color: var(--color-text); cursor: pointer; position: relative;
    transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.topbar-icon-btn:hover { background: var(--color-accent-soft); color: var(--color-accent); text-decoration: none; transform: translateY(-1px); }
.topbar-icon-btn.copied::after {
    content: 'Link copied!'; position: absolute; top: 120%; right: 0; background: var(--color-ink); color: #fff;
    font-size: 0.68rem; padding: 0.3rem 0.6rem; border-radius: 6px; white-space: nowrap; box-shadow: var(--shadow-md);
}

/* ================= Hero (embedded PDF viewer on home page) ================= */
.hero-edition-embed {
    padding: 0; margin: 0 0 1.5rem;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 0; box-shadow: var(--shadow-md);
    overflow: hidden;
}
.hero-edition-embed .viewer-header { margin-top: 0; }

/* ================= Section / grid ================= */
.section { margin-bottom: 3rem; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.1rem; }
.section-title {
    font-size: 1.4rem; margin: 0 0 1.1rem; padding-left: 0.9rem;
    border-left: 4px solid transparent;
    border-image: var(--gradient-accent) 1;
}
.section-header .section-title { margin-bottom: 0; }
.section-link { font-size: 0.86rem; font-weight: 700; white-space: nowrap; }

.edition-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.5rem; }
.edition-card {
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    overflow: hidden; color: inherit; box-shadow: var(--shadow);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
    display: flex; flex-direction: column;
}
.edition-card:hover { text-decoration: none; transform: translateY(-6px) scale(1.01); box-shadow: var(--shadow-lg); border-color: transparent; }
.edition-cover { overflow: hidden; position: relative; }
.edition-cover img, .edition-cover .cover-placeholder { width: 100%; aspect-ratio: 3/4; object-fit: cover; transition: transform 0.4s var(--ease); }
.edition-card:hover .edition-cover img { transform: scale(1.07); }
.cover-placeholder { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #efece4, #e6e2d8); color: #a8a196; font-family: var(--font-serif); font-weight: bold; font-size: 1.4rem; }
.edition-meta { padding: 0.95rem 1rem 1.1rem; }
.edition-meta h3 { font-size: 1rem; margin: 0.4rem 0 0.2rem; line-height: 1.3; }
.edition-meta p { margin: 0; font-size: 0.8rem; color: var(--color-muted); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 0.4rem; margin-top: 1.75rem; flex-wrap: wrap; }
.pagination a { padding: 0.45rem 0.9rem; border: 1px solid var(--color-border); border-radius: 999px; color: var(--color-text); font-weight: 600; font-size: 0.88rem; transition: all 0.18s var(--ease); }
.pagination a:hover { border-color: var(--color-accent); color: var(--color-accent); text-decoration: none; transform: translateY(-1px); }

/* ================= Motion / tactile feedback ================= =
   Mobile has no :hover, so the lift/scale effects above only ever show up
   on desktop -- this adds an actual tap response (press-down + ripple) on
   touch, plus cards gently animating in as they scroll into view. All of it
   is skipped under prefers-reduced-motion so it never fights a reader who's
   asked their OS for less animation. */
@media (prefers-reduced-motion: no-preference) {
    .topbar-icon-btn:active, .topbar-brand:active { transform: scale(0.88); }
    .pdf-toolbar .btn:active { transform: scale(0.82); }
    .pdf-clip-btn:active, .btn-primary:active, .badge-category:active { transform: scale(0.94); }
    .pagination a:active { transform: scale(0.92); }
    .edition-card:active { transform: scale(0.98); box-shadow: var(--shadow); }

    /* Expanding "ripple" spot from the exact tap point -- span is created by
       app.js on pointerdown and removes itself once the animation ends. */
    .ripple-host { position: relative; overflow: hidden; }
    .ripple {
        position: absolute; border-radius: 50%; transform: scale(0);
        background: currentColor; opacity: 0.25; pointer-events: none;
        animation: rippleEffect 0.5s var(--ease) forwards;
    }
    @keyframes rippleEffect { to { transform: scale(1); opacity: 0; } }

    /* Cards fade/slide up into place as the reader scrolls to them (app.js
       adds/removes these via IntersectionObserver; cards already in view on
       load are left alone so nothing flashes on first paint). */
    .edition-card.reveal-init { opacity: 0; transform: translateY(18px); }
    .edition-card.reveal-in { opacity: 1; transform: translateY(0); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
}
.pagination a.active { background: var(--gradient-accent); border-color: transparent; color: #fff; }

/* ---- Page title / empty state ---- */
.page-title { font-size: clamp(1.5rem, 3vw, 1.9rem); margin: 1.75rem 0 1.1rem; }
.empty-state, .empty-state-page { color: var(--color-muted); padding: 2rem 0; }
.empty-state-page { text-align: center; padding: 5rem 1rem; background: var(--color-surface); border-radius: var(--radius-lg); border: 1px dashed var(--color-border); margin: 2rem 0; }
.empty-state-page h2 { font-size: 1.4rem; }

/* ================= Viewer ================= */
.viewer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin: 0 0 1.5rem; flex-wrap: wrap; }
.viewer-title { font-size: 1.75rem; margin: 0.35rem 0; }
.viewer-date { color: var(--color-muted); margin: 0; }
.pdf-viewer { background: var(--gradient-ink); border-radius: 0; overflow: hidden; box-shadow: var(--shadow-lg); position: relative; }

/* Clipping (crop tool) result -- shown as an in-page modal rather than a
   window.open() popup, which turned out to be unreliable in the field
   (blocked by some mobile browsers, backgrounded/ignored in in-app webviews
   like Facebook/Instagram/WhatsApp's built-in browser). This can't hit any
   of those failure modes since it's just a normal element on the page. */
.pdf-clip-modal {
    position: fixed; inset: 0; z-index: 500; display: none;
    align-items: center; justify-content: center;
    background: rgba(10,12,18,0.72); padding: 1rem;
}
.pdf-clip-modal.open { display: flex; }
.pdf-clip-card {
    position: relative; background: #fff; border-radius: 14px; max-width: 560px; width: 100%;
    max-height: 90vh; overflow-y: auto; padding: 1.5rem 1.25rem 1.25rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4); font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.pdf-clip-close {
    position: absolute; top: 0.6rem; right: 0.6rem; width: 32px; height: 32px; border-radius: 999px;
    border: none; background: #f1efe9; color: #1c1f2a; font-size: 1.4rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0;
}
.pdf-clip-close:hover { background: #e6e3da; }
.pdf-clip-body { text-align: center; }
.pdf-clip-loading { color: #6b7078; padding: 3rem 0; margin: 0; }
.pdf-clip-body img { width: 100%; height: auto; display: block; border-radius: 6px; border: 1px solid #e7e4df; box-shadow: 0 2px 10px rgba(20,22,31,0.12); }
.pdf-clip-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; margin-top: 1.1rem; }
.pdf-clip-btn {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1.15rem; border-radius: 999px;
    border: 1px solid #d8d4cc; background: #f7f6f2; color: #1c1f2a;
    font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.pdf-clip-btn:hover { background: #efece4; }

/* Two independently-docked floating pills, pinned to the browser viewport
   (not the page/container) so they stay on screen the whole time the
   reader is scrolling. Not stacked together as one unit any more -- view
   controls (zoom/fullscreen/crop) dock to the left-center edge, page nav
   (Prev/Page X of Y/Next) docks to the bottom-center, each positioned on
   its own (see .pdf-toolbar-group-view / -nav below). */
.pdf-toolbar {
    color: #eee;
}
.pdf-toolbar .btn {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
    padding: 0; border-radius: 999px; background: transparent; color: #eee; border: none; box-shadow: none;
}
.pdf-toolbar .btn:hover { background: rgba(255,255,255,0.16); transform: none; box-shadow: none; }
.pdf-toolbar .btn.active { background: rgba(255,255,255,0.28); }
.pdf-toolbar .btn svg { display: block; }
.pdf-toolbar-spacer { display: none; }
.pdf-toolbar-divider { height: 1px; align-self: stretch; margin: 0.15rem 0.3rem; background: rgba(255,255,255,0.14); flex: none; }
/* Fit-width, the page grid, First/Last-page, and the drag slider are
   hidden -- simple Prev/page-number/Next (see the reference screenshot the
   client sent) replaced the slider for page turning. Left in the markup/JS
   rather than removed so re-enabling any of them later is a one-line CSS
   change, not a rewire. */
#pdfFitWidth,
#pdfGridToggle,
#pdfFirst,
#pdfLast,
.pdf-toolbar-divider,
.pdf-toolbar-group.pdf-toolbar-group-slider {
    display: none;
}
/* Base pill look, shared by both groups; each group then docks itself to
   its own fixed spot on screen (see the two rules right below). */
.pdf-toolbar-group {
    display: flex; align-items: center; gap: 0.3rem; flex-wrap: nowrap;
    background: rgba(12,13,18,0.82); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-radius: 999px; border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 14px 34px rgba(0,0,0,0.45);
    z-index: 60;
}
/* View controls (zoom/fullscreen/crop) -- vertical pill docked to the
   bottom-right corner of the viewport. Inverted colours (light pill, dark
   icons) so it reads as visually distinct from the (still dark) page-nav
   pill, per the client's request. */
.pdf-toolbar-group.pdf-toolbar-group-view {
    position: fixed; right: calc(0.6rem + env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    top: auto; transform: none;
    flex-direction: column; padding: 0.55rem 0.4rem;
    max-height: calc(100vh - 1.5rem);
    background: rgba(250,250,248,0.92); color: #16161a;
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 14px 34px rgba(0,0,0,0.22);
}
.pdf-toolbar-group.pdf-toolbar-group-view .btn { color: #16161a; }
.pdf-toolbar-group.pdf-toolbar-group-view .btn:hover { background: rgba(0,0,0,0.08); }
.pdf-toolbar-group.pdf-toolbar-group-view .btn.active { background: rgba(0,0,0,0.14); }
.pdf-toolbar-group.pdf-toolbar-group-view #pdfZoomLevel { opacity: 0.75; }
/* Page nav (Prev / Page X of Y / Next) -- horizontal pill docked to the
   bottom-center of the viewport, entirely independent of the view pill. */
.pdf-toolbar-group.pdf-toolbar-group-nav {
    position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    flex-direction: row; padding: 0.4rem 0.55rem;
}
.pdf-page-indicator { font-size: 0.75rem; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.25rem 0; white-space: nowrap; }
.pdf-toolbar-group-nav .pdf-page-indicator { flex-direction: row; gap: 0.3rem; padding: 0 0.35rem; }
.pdf-page-indicator input {
    text-align: center; background: rgba(255,255,255,0.1); color: #eee; border: 1px solid rgba(255,255,255,0.16);
    border-radius: 6px; font-family: var(--font-sans); width: 2.6rem !important; padding: 0.15rem;
}
/* Doubles as a "reset to 100%" button (not just a label) -- wider than the
   round icon buttons around it, with its own subtle pill so it still reads
   as tappable. */
#pdfZoomLevel {
    font-size: 0.78rem; min-width: 2.6rem; width: auto; height: 26px;
    padding: 0 0.5rem; text-align: center; opacity: 0.85;
    font-family: inherit; cursor: pointer; border-radius: 999px;
    background: rgba(0,0,0,0.06);
}
#pdfZoomLevel:hover { opacity: 1; background: rgba(0,0,0,0.12); }

/* Drag-to-jump page slider -- accent-color tints the native thumb/track to
   match whichever site theme is active (same mechanism as everything else
   themed via --color-accent), so it doesn't need separate per-theme rules. */
.pdf-page-slider {
    width: 92px; height: 32px; margin: 0; accent-color: var(--color-accent);
    background: transparent; cursor: pointer;
}
.pdf-toolbar-group-slider .pdf-page-indicator { padding-left: 0; min-width: 3.4rem; }

.pdf-canvas-wrap {
    display: flex; justify-content: center; align-items: flex-start; padding: 0;
    /* auto (not visible) so a zoomed-in page — wider than the container —
       scrolls horizontally instead of being clipped by .pdf-viewer's own
       overflow:hidden with no way to reach the rest of it. */
    overflow-x: auto; overflow-y: visible; position: relative; min-height: 300px;
    touch-action: pan-y;
}
.pdf-canvas-wrap.crop-active:not(.crop-editing), .pdf-canvas-wrap.crop-active:not(.crop-editing) canvas { cursor: crosshair; }
/* Zoomed past 100% -- click-and-drag the page to pan around it (desktop;
   touch panning comes free from touch-action, set alongside this class). */
.pdf-canvas-wrap.zoomed-pannable:not(.crop-active), .pdf-canvas-wrap.zoomed-pannable:not(.crop-active) canvas { cursor: grab; }
.pdf-canvas-wrap.zoomed-pannable.panning, .pdf-canvas-wrap.zoomed-pannable.panning canvas { cursor: grabbing; }
.pdf-crop-overlay {
    position: absolute; display: none; border: 2px dashed var(--color-accent-light);
    background: rgba(var(--color-accent-rgb),0.14); pointer-events: none; z-index: 4; border-radius: 2px;
}
/* Edit step -- once a box is drawn, it stays on screen with resize handles
   and a confirm/cancel toolbar so the reader can fine-tune the area before
   anything is rendered, instead of the drag-release being final. */
.pdf-crop-overlay.editing {
    border-style: solid; pointer-events: auto; cursor: move; touch-action: none;
}
.pdf-crop-handles { position: absolute; inset: 0; pointer-events: none; }
.pdf-crop-handle {
    position: absolute; width: 16px; height: 16px; margin: -8px;
    background: var(--color-accent); border: 2px solid #fff; border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.45); pointer-events: auto; touch-action: none; z-index: 2;
}
.pdf-crop-handle-nw { left: 0; top: 0; cursor: nwse-resize; }
.pdf-crop-handle-ne { left: 100%; top: 0; cursor: nesw-resize; }
.pdf-crop-handle-sw { left: 0; top: 100%; cursor: nesw-resize; }
.pdf-crop-handle-se { left: 100%; top: 100%; cursor: nwse-resize; }
.pdf-crop-edit-toolbar {
    position: absolute; left: 50%; bottom: -46px; transform: translateX(-50%);
    display: flex; gap: 0.5rem; pointer-events: auto; z-index: 3;
}
.pdf-crop-edit-btn {
    width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 700; line-height: 1;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.pdf-crop-edit-confirm { background: var(--color-accent); color: #fff; }
.pdf-crop-edit-cancel { background: #fff; color: #b91c1c; }

/* "View all pages" thumbnail strip — no title/close bar, just the strip
   itself (~5 thumbnails wide) with arrows to slide left/right through the
   rest. Dismissed by clicking outside it or by picking a page. */
.pdf-grid-modal {
    display: none; position: fixed; inset: 0; z-index: 100;
    background: rgba(8,8,12,0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    /* Bottom of the screen, sitting just above the floating toolbar rather
       than dead center. */
    align-items: flex-end; justify-content: center; padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
}
.pdf-grid-modal.open { display: flex; }
.pdf-grid-modal-inner {
    background: var(--color-surface); border-radius: var(--radius-lg); max-width: 620px; width: 100%;
    display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem;
    overflow: hidden; box-shadow: var(--shadow-lg);
}
.pdf-grid-nav {
    display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex: none;
    border-radius: 999px; background: var(--color-surface-alt); border: 1px solid var(--color-border);
    color: var(--color-text); cursor: pointer; transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}
.pdf-grid-nav:hover { background: var(--color-accent-soft); color: var(--color-accent); }
/* One row showing ~5 thumbnails at a time; the arrows (and a swipe/drag)
   slide it left/right rather than wrapping into a multi-row grid. */
.pdf-grid-thumbs { padding: 0.4rem; overflow-x: auto; overflow-y: hidden; display: flex; gap: 0.65rem; scroll-behavior: smooth; flex: 1; }
.pdf-grid-thumb {
    border: 2px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
    background: var(--color-surface-alt); padding: 0; display: flex; flex-direction: column; align-items: stretch;
    transition: border-color 0.15s var(--ease), transform 0.15s var(--ease); font-family: var(--font-sans);
    flex: 0 0 90px;
}
.pdf-grid-thumb:hover { border-color: var(--color-accent); transform: translateY(-2px); }
.pdf-grid-thumb.active { border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent-soft); }
.pdf-grid-thumb canvas { width: 100%; display: block; }
.pdf-grid-thumb span { font-size: 0.72rem; text-align: center; padding: 0.3rem; color: var(--color-muted); font-weight: 600; }
.pdf-grid-loading { text-align: center; color: var(--color-muted); padding: 2rem 3rem; white-space: nowrap; }
/* No max-width cap here — Zoom In needs the canvas to actually render wider
   than the container (scrollable via overflow-x above); a 100% cap was
   silently shrinking it right back down, so only Zoom Out ever looked like
   it worked. "Full Size"/fit-width already sizes it to match exactly. */
.pdf-canvas-wrap canvas { box-shadow: 0 10px 34px rgba(0,0,0,0.45); background: #fff; opacity: 0; border-radius: 2px; }
.pdf-canvas-wrap canvas.page-enter { animation: pdfPageIn 0.24s var(--ease) forwards; }
@keyframes pdfPageIn { from { opacity: 0; transform: translateY(8px) scale(0.995); } to { opacity: 1; transform: translateY(0) scale(1); } }
/* Next/Prev (and anything with a direction — first/last, swipe, arrow keys,
   picking a page from the grid) slides the new page in from that side,
   clipped by .pdf-viewer's overflow:hidden so it can't cause a scrollbar. */
.pdf-canvas-wrap canvas.slide-in-right { animation: pdfSlideInRight 0.28s var(--ease) forwards; }
.pdf-canvas-wrap canvas.slide-in-left { animation: pdfSlideInLeft 0.28s var(--ease) forwards; }
@keyframes pdfSlideInRight { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pdfSlideInLeft { from { opacity: 0; transform: translateX(-48px); } to { opacity: 1; transform: translateX(0); } }
.pdf-loading { color: #ccc; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* Clickable link areas mapped in the admin "Map Areas" tool — invisible until hovered. */
.pdf-area-overlay { position: absolute; }
.pdf-area-box {
    position: absolute; display: block; border-radius: 4px;
    background: rgba(255,255,255,0); box-shadow: 0 0 0 0 transparent;
    transition: background-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.pdf-area-box:hover, .pdf-area-box:focus-visible {
    background: rgba(var(--color-accent-rgb),0.14); box-shadow: 0 0 0 2px rgba(var(--color-accent-rgb),0.6) inset; cursor: pointer;
}

/* Full Size / fullscreen mode: let the page use the whole available viewport. */
.pdf-viewer:fullscreen { display: flex; flex-direction: column; background: #0f1117; }
.pdf-viewer:fullscreen .pdf-canvas-wrap { max-height: none; flex: 1; align-items: center; }
.pdf-viewer:-webkit-full-screen { display: flex; flex-direction: column; background: #0f1117; }
.pdf-viewer:-webkit-full-screen .pdf-canvas-wrap { max-height: none; flex: 1; align-items: center; }


/* ================= Auth screens (login/install) ================= */
.auth-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: var(--gradient-ink);
    background-image: radial-gradient(circle at 15% 20%, rgba(200,38,47,0.18), transparent 40%),
                       radial-gradient(circle at 85% 80%, rgba(200,38,47,0.12), transparent 45%),
                       var(--gradient-ink);
    padding: 1.5rem;
}
.auth-card { background: var(--color-surface); padding: 2.4rem; border-radius: var(--radius-lg); width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.auth-card h1 { text-align: center; font-size: 1.55rem; }
.auth-subtitle { text-align: center; color: var(--color-muted); margin-top: -0.3rem; margin-bottom: 1.2rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-card label { font-size: 0.85rem; font-weight: 600; color: var(--color-text); display: flex; flex-direction: column; gap: 0.35rem; }
.auth-card input { padding: 0.65rem 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: normal; font-family: var(--font-sans); transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.auth-card input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.auth-back { text-align: center; margin-top: 1rem; font-size: 0.85rem; }
.auth-card code { background: var(--color-surface-alt); padding: 0.1rem 0.4rem; border-radius: 3px; }

/* ================= Responsive ================= */
@media (max-width: 780px) {
    /* Logo + city together on row 1 (both centered as one group); date/
       download/dark-mode stay together as one compact row 2 below, also
       centered -- instead of starting from the left edge. */
    .topbar-inner { flex-wrap: wrap; justify-content: center; row-gap: 0.5rem; }
    .topbar-pill-city { flex: none; }
    .topbar-pill-city select { max-width: none; width: auto; }

    .topbar-actions {
        flex-basis: 100%;
        flex-wrap: nowrap;
        justify-content: center;
        margin-left: 0;
    }
    /* The date pill only needs to fit a short date, not the same width as
       the city name -- keeping it compact is what leaves room for
       download/dark-mode to stay on this one row. */
    .topbar-pill-date { flex: 0 1 auto; min-width: 0; }
    .topbar-pill-date input[type=date] { max-width: 8rem; width: auto; }

    .viewer-title { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .edition-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
    .pdf-toolbar-group { gap: 0.15rem; padding: 0.35rem 0.4rem; }
}
