/* =========================================================
   FLIPBOOK STUDIO — Phase 2B Complete Stylesheet
   Features: Dark/Light themes, progress bar, shimmer,
             info & help modals, spine shadow, animations
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* ==========================================================
   THEME VARIABLES
   Dark theme is the default — light theme overrides via [data-theme="light"]
   ========================================================== */
:root {
    /* Upload page (always light) */
    --bg:           #f5f6fa;
    --bg-gradient:  linear-gradient(180deg, #f8f9fc 0%, #eef1f8 100%);
    --surface:      #ffffff;
    --surface-alt:  #fafbfd;
    --border:       #e4e7ef;
    --text:         #1a1d2e;
    --text-muted:   #6b7285;
    --text-soft:    #9099ac;
    --primary:      #5b5fef;
    --primary-dark: #4548d4;
    --primary-soft: #eef0ff;
    --accent:       #ff6b6b;
    --success:      #10b981;
    --danger:       #ef4444;
    --shadow-sm:    0 1px 2px rgba(17,24,39,0.05);
    --shadow:       0 4px 20px rgba(17,24,39,0.08);
    --shadow-lg:    0 20px 60px rgba(17,24,39,0.15);
    --radius:       14px;
    --radius-sm:    8px;
    --radius-lg:    20px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* VIEWER — Dark theme (default) */
    --viewer-bg:           #2a2d3a;
    --viewer-bg-gradient:  radial-gradient(ellipse at center, #353849 0%, #1e2029 100%);
    --viewer-chrome:       rgba(20,22,32,0.92);
    --viewer-chrome-hover: rgba(20,22,32,0.95);
    --viewer-text:         #ffffff;
    --viewer-text-muted:   rgba(255,255,255,0.65);
    --viewer-text-dim:     rgba(255,255,255,0.5);
    --viewer-border:       rgba(255,255,255,0.08);
    --viewer-btn-hover:    rgba(255,255,255,0.15);
    --viewer-shadow:       rgba(0,0,0,0.5);
    --page-bg:             #ffffff;
    --page-shimmer-base:   #f5f5f5;
    --page-shimmer-shine:  #ffffff;
    --modal-bg:            #1e2029;
    --kbd-bg:              rgba(255,255,255,0.1);
    --kbd-border:          rgba(255,255,255,0.15);
}

/* Light theme for viewer */
[data-theme="light"] {
    --viewer-bg:           #eef0f5;
    --viewer-bg-gradient:  radial-gradient(ellipse at center, #f5f6fa 0%, #d8dce6 100%);
    --viewer-chrome:       rgba(255,255,255,0.92);
    --viewer-chrome-hover: rgba(255,255,255,0.98);
    --viewer-text:         #1a1d2e;
    --viewer-text-muted:   rgba(26,29,46,0.7);
    --viewer-text-dim:     rgba(26,29,46,0.5);
    --viewer-border:       rgba(0,0,0,0.08);
    --viewer-btn-hover:    rgba(0,0,0,0.08);
    --viewer-shadow:       rgba(0,0,0,0.15);
    --page-bg:             #ffffff;
    --page-shimmer-base:   #eeeef2;
    --page-shimmer-shine:  #ffffff;
    --modal-bg:            #ffffff;
    --kbd-bg:              rgba(0,0,0,0.06);
    --kbd-border:          rgba(0,0,0,0.1);
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ==========================================================
   SITE HEADER (upload page)
   ========================================================== */
.site-header {
    padding: 22px 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 17px;
}
.brand-icon { font-size: 22px; }
.nav-badge {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 20px;
    font-weight: 600;
}

/* ==========================================================
   UPLOAD PAGE
   ========================================================== */
.page-upload { background: var(--bg-gradient); min-height: 100vh; display: flex; flex-direction: column; }
.upload-main { flex: 1; padding: 60px 0 40px; }

.hero { text-align: center; margin-bottom: 48px; max-width: 700px; margin-left: auto; margin-right: auto; }
.hero-title { font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 18px; }
.hero-accent { background: linear-gradient(135deg, var(--primary) 0%, #8b5fef 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-subtitle { font-size: 18px; color: var(--text-muted); margin: 0; }

.upload-card { max-width: 640px; margin: 0 auto; background: var(--surface); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow); border: 1px solid var(--border); }

.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-alt); padding: 48px 28px; text-align: center; transition: all 0.2s ease; cursor: pointer; position: relative; min-height: 280px; display: flex; align-items: center; justify-content: center; }
.upload-zone.drag-over { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.01); }

.upload-zone-inner { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.upload-zone-inner[hidden] { display: none !important; }

.upload-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.upload-icon svg { width: 30px; height: 30px; }

.upload-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.upload-hint { color: var(--text-muted); margin: 0 0 8px; font-size: 14px; }

.file-preview { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); width: 100%; max-width: 480px; }
.file-icon { width: 48px; height: 48px; background: var(--primary); color: white; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.file-info { flex: 1; text-align: left; overflow: hidden; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 22px; border-radius: 10px; border: none; font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; transition: all 0.15s ease; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 14px rgba(91,95,239,0.35); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(91,95,239,0.45); }
.btn-large { padding: 14px 28px; font-size: 16px; }
.btn-arrow { transition: transform 0.2s ease; }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }
.btn-ghost { background: transparent; border: none; color: var(--text-muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; transition: background 0.15s ease; }
.btn-ghost:hover { background: var(--border); color: var(--text); }

.upload-meta { display: flex; justify-content: center; gap: 24px; margin-top: 24px; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.meta-dot { width: 6px; height: 6px; background: var(--success); border-radius: 50%; }

.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner { max-width: 640px; margin: 20px auto 0; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; }

.site-footer { padding: 30px 0; text-align: center; color: var(--text-soft); font-size: 13px; border-top: 1px solid var(--border); margin-top: 40px; }

/* ==========================================================
   VIEWER PAGE
   ========================================================== */
.page-viewer {
    background: var(--viewer-bg);
    background-image: var(--viewer-bg-gradient);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--viewer-text);
    transition: background 0.3s ease;
}

.viewer-header {
    height: 44px;
    background: var(--viewer-chrome);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--viewer-border);
    color: var(--viewer-text);
    gap: 16px;
    flex-shrink: 0;
    z-index: 10;
    transition: background 0.3s ease, color 0.3s ease;
}
.viewer-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--viewer-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--viewer-btn-hover);
    transition: background 0.15s ease, color 0.15s ease;
}
.viewer-back:hover { background: var(--viewer-btn-hover); color: var(--viewer-text); }
.viewer-title {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--viewer-text);
}
.viewer-meta {
    font-size: 13px;
    color: var(--viewer-text-dim);
}

.viewer-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0;
    overflow: hidden;
}

/* ==========================================================
   LOADING SCREEN WITH PROGRESS BAR
   ========================================================== */
.viewer-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    z-index: 500;
    background: var(--viewer-bg-gradient);
    transition: opacity 0.4s ease;
}
.viewer-loading.fading-out {
    opacity: 0;
    pointer-events: none;
}

.loading-logo {
    color: var(--primary);
    opacity: 0.85;
    animation: logo-pulse 2s ease-in-out infinite;
}
@keyframes logo-pulse {
    0%, 100% { opacity: 0.5; transform: scale(0.96); }
    50%      { opacity: 0.95; transform: scale(1); }
}

.loading-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 280px;
    max-width: 80vw;
}

.loading-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--viewer-border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, #8b5fef 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(91,95,239,0.5);
}

.loading-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--viewer-text-muted);
}
.loading-percent {
    font-weight: 600;
    color: var(--viewer-text);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================
   FLIPBOOK + SPINE
   ========================================================== */
.flipbook-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 20px 40px var(--viewer-shadow));
    isolation: isolate;    /* ADD THIS LINE */
}

#flipbook {
    opacity: 0;
    transition: opacity 0.6s ease;
    position: relative;
    overflow: hidden; /*new */
}
#flipbook.ready { opacity: 1; }

#flipbook .page {
    background: var(--page-bg);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.03);
}

#flipbook .page canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    position: relative;
    z-index: 1;
}

/* Shimmer placeholder (elegant loading) */
.page-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        var(--page-shimmer-base) 0%,
        var(--page-shimmer-shine) 50%,
        var(--page-shimmer-base) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Spine shadow overlay */
.spine-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 100;
    background:
        linear-gradient(
            to right,
            transparent 0%,
            rgba(0,0,0,0) 15%,
            rgba(0,0,0,0.15) 35%,
            rgba(0,0,0,0.45) 48%,
            rgba(0,0,0,0.65) 50%,
            rgba(0,0,0,0.45) 52%,
            rgba(0,0,0,0.15) 65%,
            rgba(0,0,0,0) 85%,
            transparent 100%
        );
    opacity: 0.9;
    transition: opacity 0.3s ease;
}
.flipbook-wrap.flipping .spine-overlay { opacity: 0.3; }
.flipbook-wrap.portrait-mode .spine-overlay { display: none; }

/* ==========================================================
   WATERMARK (semi-transparent diagonal text)
   ========================================================== */
.watermark-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 150;
    overflow: hidden;
    opacity: 0.08;
    user-select: none;
}
[data-theme="light"] .watermark-overlay { opacity: 0.1; }
.watermark-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    white-space: nowrap;
    font-size: 36px;
    font-weight: 700;
    color: var(--viewer-text);
    letter-spacing: 0.1em;
}

/* ==========================================================
   CONTENT PROTECTION
   ========================================================== */
.no-select, .no-select * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.no-select input {
    -webkit-user-select: text;
    user-select: text;
}

#flipbook img, #flipbook canvas {
    -webkit-user-drag: none;
    user-drag: none;
}

@media print {
    body.page-viewer * { display: none !important; }
    body.page-viewer::before {
        content: "This content is protected and cannot be printed.";
        display: block !important;
        font-size: 20px;
        padding: 40px;
        text-align: center;
    }
}

/* ==========================================================
   TOOLBAR (floating, auto-hide)
   ========================================================== */
.viewer-toolbar {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    background: var(--viewer-chrome);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--viewer-border);
    border-radius: 50px;
    box-shadow: 0 6px 24px var(--viewer-shadow);
    opacity: 1;
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.3s ease;
    max-width: 95vw;
}
.viewer-toolbar.toolbar-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
}
.viewer-toolbar:hover {
    background: var(--viewer-chrome-hover);
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tool-divider {
    width: 1px;
    height: 24px;
    background: var(--viewer-border);
    margin: 0 6px;
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--viewer-text-muted);
    width: 34px; height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:hover:not(:disabled) {
    background: var(--viewer-btn-hover);
    color: var(--viewer-text);
    transform: scale(1.05);
}
.tool-btn:active:not(:disabled) {
    transform: scale(0.95);
}
.tool-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tool-page-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--viewer-text);
    font-size: 13px;
    font-weight: 500;
    padding: 0 10px;
    margin: 0 2px;
    background: var(--viewer-btn-hover);
    border-radius: 20px;
    height: 28px;
}
.tool-page-indicator input {
    width: 36px;
    background: transparent;
    border: none;
    color: var(--viewer-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-align: right;
    padding: 2px;
    -moz-appearance: textfield;
}
.tool-page-indicator input::-webkit-outer-spin-button,
.tool-page-indicator input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tool-page-indicator input:focus { outline: none; }
.page-separator { color: var(--viewer-text-dim); font-size: 12px; }
.page-total { color: var(--viewer-text-muted); font-weight: 500; font-size: 12px; }

.tool-zoom-level {
    color: var(--viewer-text-muted);
    font-size: 12px;
    font-weight: 500;
    padding: 0 8px;
    min-width: 48px;
    text-align: center;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================
   SIDE NAVIGATION ARROWS
   ========================================================== */
.side-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 80;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--viewer-chrome);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--viewer-border);
    color: var(--viewer-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--viewer-shadow);
    opacity: 1;
    transition: opacity 0.3s ease, background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}
.side-nav:hover {
    background: var(--viewer-chrome-hover);
    color: var(--viewer-text);
    transform: translateY(-50%) scale(1.08);
}
.side-nav:active { transform: translateY(-50%) scale(0.95); }
.side-nav-prev { left: 20px; }
.side-nav-next { right: 20px; }
.side-nav.toolbar-hidden { opacity: 0; pointer-events: none; }

/* ==========================================================
   ZOOM CONTAINER
   ========================================================== */
.zoom-container {
    transform-origin: center center;
    transition: transform 0.25s ease;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zoom-container.zoomed { cursor: grab; }
.zoom-container.zoomed.panning { cursor: grabbing; transition: none; }

/* ==========================================================
   TOAST
   ========================================================== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 500;
    background: var(--viewer-chrome);
    color: var(--viewer-text);
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid var(--viewer-border);
    box-shadow: 0 6px 24px var(--viewer-shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.toast.toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast-icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--success);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
}

/* ==========================================================
   MODAL OVERLAY (help + info)
   ========================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal-overlay.visible { opacity: 1; }
.modal-overlay[hidden] { display: none !important; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-panel {
    position: relative;
    background: var(--modal-bg);
    border: 1px solid var(--viewer-border);
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--viewer-text);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    transform: translateY(10px) scale(0.98);
    transition: transform 0.2s ease;
}
.modal-overlay.visible .modal-panel {
    transform: translateY(0) scale(1);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--viewer-border);
}
.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--viewer-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover {
    background: var(--viewer-btn-hover);
    color: var(--viewer-text);
}
.modal-body {
    padding: 16px 24px 24px;
    overflow-y: auto;
}

/* Help-specific */
.help-section { margin-bottom: 20px; }
.help-section:last-child { margin-bottom: 0; }
.help-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--viewer-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 10px;
}
.help-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 14px;
}
.help-row kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    background: var(--kbd-bg);
    border: 1px solid var(--kbd-border);
    border-radius: 6px;
    color: var(--viewer-text);
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 12px;
    font-weight: 500;
}
.help-row span {
    color: var(--viewer-text-muted);
    margin-left: 6px;
}

/* Info-specific */
.info-book-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--viewer-text);
}
.info-details {
    margin: 0 0 20px;
    padding: 0;
}
.info-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--viewer-border);
    font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row dt {
    color: var(--viewer-text-muted);
    font-weight: 500;
    margin: 0;
}
.info-row dd {
    margin: 0;
    color: var(--viewer-text);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
    max-width: 60%;
}
.info-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}
.info-action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.info-action-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* ==========================================================
   FULLSCREEN MODE
   ========================================================== */
body.fullscreen-mode .viewer-header { display: none; }

/* ==========================================================
   ERROR PAGE
   ========================================================== */
.page-error {
    min-height: 100vh;
    background: var(--bg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.error-screen { width: 100%; max-width: 480px; }
.error-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.error-icon { font-size: 56px; margin-bottom: 16px; }
.error-card h1 { font-size: 26px; margin: 0 0 10px; }
.error-card p { color: var(--text-muted); margin: 0 0 24px; }

/* ==========================================================
   RESPONSIVE — MOBILE
   ========================================================== */
@media (max-width: 768px) {
    .hero-title { font-size: 32px; }
    .hero-subtitle { font-size: 16px; }
    .upload-card { padding: 20px; }
    .upload-zone { padding: 32px 16px; min-height: 240px; }
    .upload-meta { gap: 14px; font-size: 12px; }

    .viewer-title { font-size: 13px; }
    .viewer-back span { display: none; }
    .viewer-back { padding: 6px; }
    .viewer-meta { font-size: 12px; }

    /* Hide side nav arrows on mobile — swipe works */
    .side-nav { display: none; }

    /* Compact toolbar on mobile */
    .viewer-toolbar {
        padding: 4px 6px;
        gap: 0;
    }
    .tool-btn { width: 32px; height: 32px; }
    .tool-btn svg { width: 14px; height: 14px; }
    .tool-divider { margin: 0 3px; height: 20px; }

    /* Hide less-critical buttons on mobile */
    #btnFirst, #btnLast, .tool-zoom-level, #btnHelp { display: none; }

    .tool-page-indicator {
        height: 26px;
        padding: 0 8px;
        font-size: 12px;
    }
    .tool-page-indicator input {
        width: 30px;
        font-size: 12px;
    }

    .watermark-text { font-size: 28px; }

    .loading-progress-wrap { width: 240px; }
}

@media (max-width: 480px) {
    .hero { margin-bottom: 32px; }
    .hero-title { font-size: 28px; }
    .container { padding: 0 16px; }

    .viewer-toolbar { padding: 3px 5px; }
    .tool-btn { width: 30px; height: 30px; }
    .tool-btn svg { width: 14px; height: 14px; }

    /* Very compact on phones */
    #btnShare, #btnInfo { display: none; }

    .viewer-header { padding: 0 10px; }
    .viewer-title { font-size: 12px; }

    .modal-panel { max-width: 100%; margin: 16px; }
    .modal-body { padding: 12px 16px 16px; }
}
