/* ═══════════════════════════════════════════════════════════════════════════════
   EPISODE ONE — SCRIPT READER
   script_reader.css
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Hide navbar and footer on reader page ───────────────────────────────────── */
#nav-bar,
#mobile-nav-dropdown,
#mobile-search-bar,
#back-to-top,
.site-footer {
    display: none !important;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

main:has(.reader-page) {
    height: 100%;
    overflow: hidden;
    padding: 0 !important;
    margin: 0 !important;
}

.reader-page {
    background: #111;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */
.reader-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 24px;
    background: #1a1a1a;
    border-bottom: 1px solid #242424;
    flex-shrink: 0;
    z-index: 100;
}

.reader-back {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #aaa;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

.reader-back:hover { color: #D4AF37; }

.reader-toolbar-center {
    flex: 1;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.reader-progress-label {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #888;
}

.reader-progress-bar {
    width: 100%;
    height: 2px;
    background: #2a2a2a;
    border-radius: 1px;
    overflow: hidden;
}

.reader-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #B8960C, #D4AF37);
    border-radius: 1px;
    transition: width 0.3s ease;
}

.reader-toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.reader-page-indicator {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.reader-download-btn {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #D4AF37;
    text-decoration: none;
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 6px 14px;
    transition: border-color 0.2s, background 0.2s;
    white-space: nowrap;
}

.reader-download-btn:hover {
    border-color: #D4AF37;
    background: rgba(212, 175, 55, 0.05);
    color: #D4AF37;
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.reader-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── PDF Viewer ──────────────────────────────────────────────────────────────── */
.reader-viewer {
    flex: 1;
    overflow: hidden;
    background: #333;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#pdf-iframe {
    width: 100%;
    flex: 1;
    border: none;
    display: block;
    min-height: 0;
    background: #1a1a1a; /* dark bg while loading — prevents white flash */
}

/* ── Side Panel ──────────────────────────────────────────────────────────────── */
.reader-panel {
    width: 480px;
    flex-shrink: 0;
    background: #111;
    border-left: 1px solid #1e1e1e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.reader-panel-tabs {
    display: flex;
    border-bottom: 1px solid #1e1e1e;
    flex-shrink: 0;
}

.reader-panel-tab {
    flex: 1;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #888;
    background: transparent;
    border: none;
    padding: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.reader-panel-tab.active {
    color: #D4AF37;
    border-bottom-color: #D4AF37;
}

.reader-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Passages ────────────────────────────────────────────────────────────────── */
.reader-passages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reader-passage-item {
    background: #1a1a1a;
    border: 1px solid #242424;
    border-left: 2px solid #D4AF37;
    padding: 14px;
    border-radius: 2px;
}

.reader-passage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.reader-passage-page {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #D4AF37;
}

.reader-passage-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-weight: 400;
    color: #f0ece4;
    font-style: italic;
    line-height: 1.6;
    margin-bottom: 6px;
}

.reader-passage-note {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    color: #aaa;
    line-height: 1.5;
    margin-top: 6px;
}

.reader-passages-empty {
    text-align: center;
    padding: 40px 20px;
    color: #bbb;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    line-height: 1.8;
}

/* ── Avatar ──────────────────────────────────────────────────────────────────── */
.reader-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.reader-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #D4AF37;
    flex-shrink: 0;
}

/* ── Thread item ─────────────────────────────────────────────────────────────── */
.reader-thread-item {
    background: #1a1a1a;
    border: 1px solid #1e1e1e;
    border-radius: 4px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reader-thread-meta {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.reader-thread-meta-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.reader-thread-user {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #f0ece4;
    letter-spacing: 0.3px;
}

.reader-thread-handle {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    color: #888;
}

.reader-thread-date {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.reader-thread-pinned {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #D4AF37;
    background: rgba(212, 175, 55, 0.08);
    padding: 3px 8px;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 2px;
    flex-shrink: 0;
    align-self: flex-start;
}

/* ── Script quote card ───────────────────────────────────────────────────────── */
.reader-thread-quote-card {
    background: #111;
    border: 1px solid #2a2a2a;
    border-left: 3px solid #D4AF37;
    padding: 14px 16px;
    border-radius: 2px;
}

.reader-thread-quote-text {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #ccc;
    line-height: 1.8;
    letter-spacing: 0.3px;
    margin-bottom: 10px;
}

/* ── User comment ────────────────────────────────────────────────────────────── */
.reader-thread-comment {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    color: #888;
    line-height: 1.7;
    font-weight: 300;
}

/* ── Thread footer ───────────────────────────────────────────────────────────── */
.reader-thread-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 4px;
    border-top: 1px solid #1e1e1e;
}

.reader-like-btn {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 11px;
    color: #888;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.reader-like-btn:hover { color: #e07070; }
.reader-like-btn.liked { color: #e07070; }

.reader-thread-pin-btn {
    font-size: 14px;
    color: #bbb;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    margin-left: auto;
}

.reader-thread-pin-btn:hover { color: #D4AF37; }

/* ── Jump button ─────────────────────────────────────────────────────────────── */
.reader-jump-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #D4AF37;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding: 2px 0 1px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-top: 10px;
}

.reader-jump-btn:hover {
    color: #e8c84a;
    border-bottom-color: rgba(232, 200, 74, 0.5);
}

.reader-passage-jump { margin-top: 0; }

/* ── Replies ─────────────────────────────────────────────────────────────────── */
.reader-replies-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid #1e1e1e;
    margin-left: 16px;
}

.reader-reply-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: #161616;
    border-radius: 3px;
}

.reader-reply-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reader-reply-meta .reader-avatar,
.reader-reply-meta .reader-avatar-placeholder {
    width: 24px;
    height: 24px;
    font-size: 10px;
}

.reader-reply-body {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    color: #bbb;
    line-height: 1.6;
    font-weight: 300;
}

.reader-reply-to {
    color: #D4AF37;
    font-weight: 600;
}

.reader-reply-footer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reader-reply-footer .reader-like-btn { font-size: 10px; }

.reader-reply-to-btn {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #888;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.2s;
}

.reader-reply-to-btn:hover { color: #D4AF37; }

/* ── Reply compose ───────────────────────────────────────────────────────────── */
.reader-reply-compose {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.reader-reply-input {
    flex: 1;
    background: #161616;
    border: 1px solid #242424;
    color: #f0ece4;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
    border-radius: 2px;
    transition: border-color 0.2s;
}

.reader-reply-input:focus { border-color: #D4AF37; }

.reader-reply-btn {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 8px 14px;
    background: transparent;
    color: #D4AF37;
    border: 1px solid rgba(212, 175, 55, 0.3);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    border-radius: 2px;
}

.reader-reply-btn:hover { background: rgba(212, 175, 55, 0.08); }

/* ── Thread compose ──────────────────────────────────────────────────────────── */
.reader-thread-compose {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #1e1e1e;
    margin-top: auto;
}

.reader-thread-compose textarea {
    width: 100%;
    background: #161616;
    border: 1px solid #242424;
    color: #f0ece4;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    font-weight: 300;
    padding: 10px 12px;
    outline: none;
    resize: none;
    border-radius: 2px;
    line-height: 1.6;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.reader-thread-compose textarea:focus { border-color: #D4AF37; }

.reader-thread-submit {
    align-self: flex-end;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 8px 20px;
    background: #D4AF37;
    color: #111;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 2px;
}

.reader-thread-submit:hover { background: #e8c84a; }

.reader-no-threads {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    color: #bbb;
    font-style: italic;
    text-align: center;
    padding: 24px 0;
}

.reader-signin-prompt {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    color: #888;
    text-align: center;
    padding: 20px 0;
}

.reader-signin-prompt a { color: #D4AF37; text-decoration: none; }

/* ── Item actions ────────────────────────────────────────────────────────────── */
.reader-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.reader-passage-item:hover .reader-item-actions,
.reader-thread-item:hover .reader-item-actions { opacity: 1; }

.reader-item-edit,
.reader-item-delete,
.reader-reply-delete {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.2s;
}

.reader-item-edit { color: #888; }
.reader-item-edit:hover { color: #D4AF37; }
.reader-item-delete, .reader-reply-delete { color: #888; }
.reader-item-delete:hover, .reader-reply-delete:hover { color: #e07070; }

/* ── Inline delete confirm ───────────────────────────────────────────────────── */
.reader-delete-confirm-text {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    color: #e07070;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.reader-delete-yes {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: transparent;
    border: none;
    color: #e07070;
    cursor: pointer;
    padding: 2px 6px;
}

.reader-delete-no {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 2px 6px;
}

/* ── Inline edit form ────────────────────────────────────────────────────────── */
.reader-passage-edit-form {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reader-edit-textarea {
    width: 100%;
    background: #111;
    border: 1px solid #D4AF37;
    color: #f0ece4;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
    resize: none;
    border-radius: 2px;
    box-sizing: border-box;
    min-height: 60px;
    line-height: 1.5;
}

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

.reader-edit-save {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 14px;
    background: #D4AF37;
    color: #111;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 2px;
}

.reader-edit-save:hover { background: #e8c84a; }

.reader-edit-cancel {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 6px 12px;
    background: transparent;
    color: #888;
    border: 1px solid #242424;
    cursor: pointer;
    transition: color 0.2s;
    border-radius: 2px;
}

.reader-edit-cancel:hover { color: #bbb; }

/* ── Floating selection bar ──────────────────────────────────────────────────── */
.reader-selection-bar {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    border: 1px solid #D4AF37;
    border-top: 2px solid #D4AF37;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    transition: bottom 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    max-width: 700px;
    width: calc(100% - 520px);
    border-radius: 2px;
}

.reader-selection-bar.visible { bottom: 24px; }

.reader-selection-bar-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.9rem;
    font-style: italic;
    color: #888;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-selection-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.reader-selection-bar-save {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 16px;
    background: #D4AF37;
    color: #111;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    border-radius: 2px;
}

.reader-selection-bar-save:hover { background: #e8c84a; }

.reader-selection-bar-discuss {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 8px 16px;
    background: transparent;
    color: #D4AF37;
    border: 1px solid rgba(212, 175, 55, 0.4);
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    border-radius: 2px;
}

.reader-selection-bar-discuss:hover { background: rgba(212, 175, 55, 0.08); }

.reader-selection-bar-cancel {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    color: #888;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.reader-selection-bar-cancel:hover { color: #bbb; }

/* ── Passage save modal ──────────────────────────────────────────────────────── */
.reader-passage-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reader-passage-modal-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-top: 2px solid #D4AF37;
    padding: 32px;
    width: 480px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border-radius: 2px;
}

.reader-passage-modal-eyebrow {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #D4AF37;
}

.reader-passage-modal-quote {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #ccc;
    line-height: 1.8;
    background: #111;
    border-left: 3px solid #D4AF37;
    padding: 12px 16px;
    border-radius: 2px;
}

.reader-passage-modal-note {
    width: 100%;
    background: #111;
    border: 1px solid #2a2a2a;
    color: #f0ece4;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    resize: none;
    border-radius: 2px;
    box-sizing: border-box;
    line-height: 1.6;
    min-height: 80px;
    transition: border-color 0.2s;
}

.reader-passage-modal-note:focus { border-color: #D4AF37; }

.reader-passage-modal-public {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 11px;
    color: #999;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.reader-passage-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.reader-passage-modal-save {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 24px;
    background: #D4AF37;
    color: #111;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 2px;
}

.reader-passage-modal-save:hover { background: #e8c84a; }

.reader-passage-modal-cancel {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 10px 20px;
    background: transparent;
    color: #999;
    border: 1px solid #2a2a2a;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    border-radius: 2px;
}

.reader-passage-modal-cancel:hover { color: #888; border-color: #888; }

.reader-threads-hint {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 12px;
    color: #bbb;
    line-height: 1.7;
    text-align: center;
    padding: 24px 16px;
    border: 1px dashed #242424;
    border-radius: 2px;
}

.reader-threads-hint strong { color: #D4AF37; }

/* ═══════════════════════════════════════════════════════════════════════════════
   SCAN OVERLAY
   ═══════════════════════════════════════════════════════════════════════════════ */

.reader-scan-viewer {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #2a2a2a;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 24px 0 40px;
    scroll-behavior: smooth;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
}

.scan-page-wrap {
    position: relative;
    display: inline-block;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    line-height: 0;
    max-width: calc(100vw - 520px);
    user-select: none !important;
    -webkit-user-select: none !important;
    cursor: text;
}

.scan-page-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 900px;
    user-select: none !important;
    -webkit-user-select: none !important;
    pointer-events: none;
    -webkit-user-drag: none;
}

.scan-text-overlay {
    position: absolute;
    top: 0; left: 0;
    overflow: hidden;
    pointer-events: none;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.scan-word {
    position: absolute;
    color: transparent !important;
    background: transparent;
    white-space: pre;
    pointer-events: all;
    cursor: text;
    user-select: none !important;
    -webkit-user-select: none !important;
    font-family: 'Courier New', Courier, monospace;
    line-height: 1;
    overflow: hidden;
    transition: background 0.05s;
    border-radius: 2px;
}

.scan-word-selected {
    background: rgba(212, 175, 55, 0.45) !important;
    border-radius: 2px;
}

@keyframes scan-word-pulse-anim {
    0%   { background: rgba(212, 175, 55, 0.8); }
    100% { background: rgba(212, 175, 55, 0.45); }
}

.scan-word-pulse {
    animation: scan-word-pulse-anim 0.8s ease-out forwards;
}

.scan-page-number-label {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #888;
    pointer-events: none;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.scan-page-img[loading="lazy"] {
    min-height: 200px;
    background: #222;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   READER HELP OVERLAY
   ═══════════════════════════════════════════════════════════════════════════════ */

.reader-help-btn {
    font-family: 'Cormorant Garamond', serif;
    font-size: 13px;
    font-weight: 600;
    color: #D4AF37;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.35);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.reader-help-btn:hover {
    color: #e8c84a;
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.6);
}

@keyframes help-btn-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7); transform: scale(1); }
    40%  { box-shadow: 0 0 0 8px rgba(212, 175, 55, 0); transform: scale(1.15); }
    60%  { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); transform: scale(0.95); }
    80%  { box-shadow: 0 0 0 6px rgba(212, 175, 55, 0); transform: scale(1.08); }
    100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); transform: scale(1); }
}

.reader-help-btn-pulse { animation: help-btn-pulse 0.8s ease-out 3; }

.reader-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
    transition: background 0.3s;
}

.reader-help-overlay.visible {
    background: rgba(0, 0, 0, 0.65);
    pointer-events: all;
}

.reader-help-card {
    background: #1c1c1c;
    border: 1px solid #383838;
    border-top: 2px solid #D4AF37;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px 48px 36px;
    width: 580px;
    max-width: calc(100vw - 48px);
    display: flex;
    flex-direction: column;
    gap: 28px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(212, 175, 55, 0.08);
    transform: translateY(16px);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.35s ease;
}

.reader-help-overlay.visible .reader-help-card {
    transform: translateY(0);
    opacity: 1;
}

.reader-help-eyebrow {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #D4AF37;
}

.reader-help-items { display: flex; flex-direction: column; gap: 16px; }

.reader-help-item { display: flex; align-items: flex-start; gap: 14px; }

.reader-help-icon {
    font-size: 16px;
    color: #D4AF37;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    margin-top: 1px;
    opacity: 0.7;
}

.reader-help-title {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #f0ece4;
    margin-bottom: 4px;
}

.reader-help-desc {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    font-weight: 300;
    color: #999;
    line-height: 1.7;
}

.reader-help-dismiss {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 10px 0;
    background: #D4AF37;
    color: #111;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.reader-help-dismiss:hover { background: #e8c84a; }

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE OVERRIDES — max-width: 768px
   Zero impact on desktop.
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* ── Viewer fills screen ────────────────────────────────────────────────── */
    .reader-layout {
        flex-direction: column;
        position: relative;
        height: 100%;
        overflow: hidden;
    }

    .reader-viewer {
        position: absolute;
        inset: 0;
        height: 100% !important;
        z-index: 1;
        /* Enable native pinch-zoom on the viewer element itself */
        touch-action: pan-x pan-y pinch-zoom;
        overflow: hidden;
    }

    /* PDF iframe — full size, dark bg so grey gutters are invisible */
    #pdf-iframe {
        width: 100%;
        height: 100% !important;
        border: none;
        display: block;
        touch-action: pan-x pan-y pinch-zoom;
        background: #1a1a1a;
    }

    /* Dark viewer surround — hides any grey gutter outside the PDF page */
    .reader-viewer {
        background: #1a1a1a !important;
    }

    /* Scan viewer — scrollable, pinch zoom enabled */
    .reader-scan-viewer {
        height: 100% !important;
        padding: 8px 0 80px;
        gap: 12px;
        touch-action: pan-x pan-y pinch-zoom;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .scan-page-wrap {
        max-width: 100vw;
        width: 100%;
        touch-action: pan-x pan-y pinch-zoom;
    }

    /* ── Tap-to-reveal toolbar ──────────────────────────────────────────────── */
    .reader-toolbar {
        position: absolute;
        top: 0; left: 0; right: 0;
        z-index: 200;
        padding: 10px 14px;
        gap: 10px;
        background: linear-gradient(180deg, rgba(17,17,17,0.97) 0%, rgba(17,17,17,0.88) 100%);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-bottom: 1px solid rgba(255,255,255,0.06);
        transform: translateY(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
        opacity: 1;
    }

    .reader-toolbar.toolbar-hidden {
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .reader-toolbar-center {
        display: flex !important;
        flex: 1;
        max-width: none;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .reader-progress-label {
        font-size: 9px;
        white-space: nowrap;
        color: #ddd;
    }

    .reader-progress-bar { flex: 1; }

    .reader-toolbar-right { gap: 10px; }
    .reader-download-btn { display: none; }
    .reader-page-indicator { font-size: 11px; color: #ddd; }
    .reader-back {
        font-size: 11px;
        color: #ccc;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ── Bottom sheet — FIXED height so translateY calc works ──────────────── */
    /*
     * KEY FIX: the sheet must have a concrete height so that
     * translateY(calc(100% - 110px)) resolves correctly.
     * We use 70vh. The closed state peeks 110px (handle + download row + tabs).
     */
    .reader-panel {
        position: absolute;
        bottom: 0; left: 0; right: 0;
        width: 100%;
        height: 70vh;              /* concrete height — required for % translateY */
        max-height: 70vh;
        border-left: none;
        border-top: none;
        border-radius: 16px 16px 0 0;
        background: #181818;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.7);
        z-index: 150;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        /* closed: peek 110px — shows handle pill + download row + tab strip */
        transform: translateY(calc(100% - 110px));
        transition: transform 0.38s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        will-change: transform;
    }

    /* Three sheet positions */
    /* collapsed: just the handle arrows (~40px) */
    .reader-panel[data-sheet-state="collapsed"] {
        transform: translateY(calc(100% - 40px));
    }
    /* default: handle + download row + tabs (~110px) */
    .reader-panel[data-sheet-state="default"] {
        transform: translateY(calc(100% - 110px));
    }
    /* open: full height */
    .reader-panel[data-sheet-state="open"] {
        transform: translateY(0);
    }
    /* keep .sheet-open working for any legacy references */
    .reader-panel.sheet-open {
        transform: translateY(0);
    }

    /* Drag handle — three-state chevron indicator */
    .reader-panel-handle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0px;
        padding: 8px 0 6px;
        flex-shrink: 0;
        cursor: pointer;
        min-height: 36px;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
    }

    /* Both chevrons are spans inside the handle div — see HTML */
    .reader-panel-handle .handle-up,
    .reader-panel-handle .handle-down {
        display: block;
        font-family: 'Source Sans 3', sans-serif;
        font-size: 10px;
        line-height: 10px;
        color: #555;
        transition: color 0.25s;
        /* Use SVG-style chevrons via border trick for pixel-perfect symmetry */
    }

    /* SVG chevron approach — perfectly balanced up/down */
    .reader-panel-handle .handle-up::before {
        content: '';
        display: block;
        width: 14px;
        height: 7px;
        border-left: 2px solid currentColor;
        border-top: 2px solid currentColor;
        transform: rotate(45deg) translate(3px, 2px);
        border-radius: 1px;
    }

    .reader-panel-handle .handle-down::before {
        content: '';
        display: block;
        width: 14px;
        height: 7px;
        border-left: 2px solid currentColor;
        border-top: 2px solid currentColor;
        transform: rotate(225deg) translate(3px, 2px);
        border-radius: 1px;
        margin-top: 6px;
    }

    /* State: collapsed — up arrow gold (tap to go to default) */
    .reader-panel[data-sheet-state="collapsed"] .handle-up  { color: #D4AF37; }
    .reader-panel[data-sheet-state="collapsed"] .handle-down { color: #3a3a3a; }

    /* State: default middle — both dimmed (can go either way) */
    .reader-panel[data-sheet-state="default"] .handle-up   { color: #888; }
    .reader-panel[data-sheet-state="default"] .handle-down { color: #888; }

    /* State: open full — down arrow gold (tap to collapse) */
    .reader-panel[data-sheet-state="open"] .handle-up   { color: #3a3a3a; }
    .reader-panel[data-sheet-state="open"] .handle-down { color: #D4AF37; }

    .reader-panel-tabs {
        flex-shrink: 0;
        border-bottom: 1px solid #242424;
        background: #181818;
    }

    .reader-panel-tab {
        font-size: 10px;
        padding: 10px 14px;
        color: #ccc;
        letter-spacing: 1.5px;
    }

    .reader-panel-tab.active {
        color: #D4AF37;
        border-bottom-color: #D4AF37;
    }

    .reader-panel-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px 36px;
        gap: 10px;
    }

    /* Sheet header with download link */
    .reader-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 16px 8px;
        flex-shrink: 0;
    }

    .reader-sheet-title {
        font-family: 'Source Sans 3', sans-serif;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 2px;
        text-transform: uppercase;
        color: #666;
    }

    .reader-sheet-download {
        font-family: 'Source Sans 3', sans-serif;
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 1.5px;
        text-transform: uppercase;
        color: #D4AF37 !important;
        text-decoration: none !important;
        border: 1px solid rgba(212, 175, 55, 0.3);
        padding: 5px 12px;
        border-radius: 2px;
        -webkit-tap-highlight-color: transparent;
        transition: border-color 0.2s, background 0.2s;
    }

    .reader-sheet-download:hover,
    .reader-sheet-download:visited,
    .reader-sheet-download:active,
    .reader-sheet-download:focus {
        color: #D4AF37 !important;
        text-decoration: none !important;
        background: rgba(212, 175, 55, 0.08);
        border-color: rgba(212, 175, 55, 0.6);
        outline: none;
    }

    /* ── Text brightness ────────────────────────────────────────────────────── */
    .reader-passage-text        { color: #f5f1e8; }
    .reader-passage-note        { color: #ccc; }
    .reader-passages-empty      { color: #ccc; }
    .reader-passages-empty p    { color: #ccc; }
    .reader-thread-comment      { color: #c0c0c0; }
    .reader-thread-quote-text   { color: #e0e0e0; }
    .reader-thread-user         { color: #f5f1e8; }
    .reader-thread-handle       { color: #aaa; }
    .reader-thread-date         { color: #aaa; }
    .reader-reply-body          { color: #ccc; }
    .reader-threads-hint        { color: #ccc; border-color: #333; }
    .reader-signin-prompt       { color: #ccc; }
    .reader-no-threads          { color: #ccc; }

    /* ── Selection bar ──────────────────────────────────────────────────────── */
    .reader-selection-bar {
        width: calc(100% - 32px);
        left: 16px;
        transform: none;
        bottom: -140px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 16px;
        border-radius: 4px;
        z-index: 300;
    }

    .reader-selection-bar.visible { bottom: 66px; }

    .reader-selection-bar-text {
        font-size: 0.85rem;
        color: #ddd;
        white-space: normal;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

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

    .reader-selection-bar-save,
    .reader-selection-bar-discuss {
        flex: 1;
        padding: 12px 10px;
        font-size: 10px;
        text-align: center;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .reader-selection-bar-cancel {
        padding: 8px 12px;
        font-size: 18px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* ── Modals → bottom sheet style ───────────────────────────────────────── */
    .reader-passage-modal { align-items: flex-end; padding: 0; }

    .reader-passage-modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 24px 20px 44px;
        gap: 14px;
        animation: mobile-sheet-up 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    @keyframes mobile-sheet-up {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    .reader-passage-modal-quote  { color: #e0e0e0; line-height: 1.7; }
    .reader-passage-modal-note   { font-size: 16px; background: #1a1a1a; border-color: #333; color: #f0ece4; }
    .reader-passage-modal-note::placeholder { color: #888; }
    .reader-passage-modal-public { color: #ccc; font-size: 13px; }

    .reader-passage-modal-actions { flex-direction: row; gap: 10px; }

    .reader-passage-modal-save,
    .reader-passage-modal-cancel {
        flex: 1;
        min-height: 48px;
        font-size: 11px;
        padding: 12px;
    }

    /* ── Jump buttons ───────────────────────────────────────────────────────── */
    .reader-jump-btn { font-size: 10px; padding: 8px 2px 6px; min-height: 40px; }

    /* ── Item actions always visible ────────────────────────────────────────── */
    .reader-item-actions { opacity: 1; }
    .reader-item-edit  { font-size: 10px; padding: 4px 8px; min-height: 36px; color: #bbb; }
    .reader-item-delete { font-size: 10px; padding: 4px 8px; min-height: 36px; color: #e07070; }

    /* 16px prevents iOS auto-zoom on input focus */
    .reader-reply-input { font-size: 16px; color: #f0ece4; }
    .reader-reply-btn   { font-size: 10px; padding: 10px 14px; min-height: 44px; }

    /* Touch selection hover hint */
    .scan-word.touch-hover { background: rgba(212, 175, 55, 0.18) !important; }

    .scan-page-number-label { color: #aaa; }
    .reader-help-btn { width: 32px; height: 32px; }

    /* Help card */
    .reader-help-overlay { padding: 16px; }
    .reader-help-card { width: 100%; max-width: 100%; padding: 28px 22px 24px; }
    .reader-help-title { color: #f5f1e8; font-size: 14px; }
    .reader-help-desc  { color: #ccc; font-size: 13px; }

} /* end @media mobile */

/* ── Mobile onboarding card — hidden on desktop ──────────────────────────────── */
.mobile-onboard-overlay { display: none; }

@media (max-width: 768px) {

    .mobile-onboard-overlay {
        display: flex;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.82);
        z-index: 4000;
        align-items: flex-end;
        transition: opacity 0.3s ease;
    }

    .mobile-onboard-overlay.dismissing {
        opacity: 0;
        pointer-events: none;
    }

    .mobile-onboard-overlay.hidden { display: none; }

    .mobile-onboard-card {
        background: #181818;
        border-top: 2px solid #D4AF37;
        border-radius: 16px 16px 0 0;
        padding: 28px 24px 48px;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 20px;
        animation: mobile-sheet-up 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        box-shadow: 0 -16px 60px rgba(0,0,0,0.8);
    }

    .mobile-onboard-eyebrow {
        font-family: 'Source Sans 3', sans-serif;
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 3px;
        text-transform: uppercase;
        color: #D4AF37;
    }

    .mobile-onboard-headline {
        font-family: 'Cormorant Garamond', serif;
        font-size: 1.6rem;
        font-weight: 600;
        color: #f5f1e8;
        line-height: 1.15;
        margin: -4px 0 0;
    }

    .mobile-onboard-items { display: flex; flex-direction: column; gap: 16px; }

    .mobile-onboard-item { display: flex; align-items: flex-start; gap: 14px; }

    .mobile-onboard-icon {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: rgba(212, 175, 55, 0.1);
        border: 1px solid rgba(212, 175, 55, 0.25);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        flex-shrink: 0;
    }

    .mobile-onboard-text { flex: 1; padding-top: 2px; }

    .mobile-onboard-label {
        font-family: 'Source Sans 3', sans-serif;
        font-size: 13px;
        font-weight: 700;
        color: #f5f1e8;
        margin-bottom: 3px;
    }

    .mobile-onboard-desc {
        font-family: 'Source Sans 3', sans-serif;
        font-size: 12px;
        font-weight: 300;
        color: #ccc;
        line-height: 1.6;
    }

    .mobile-onboard-dismiss {
        font-family: 'Source Sans 3', sans-serif;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 2px;
        text-transform: uppercase;
        padding: 15px;
        background: #D4AF37;
        color: #111;
        border: none;
        cursor: pointer;
        border-radius: 3px;
        width: 100%;
        min-height: 52px;
        transition: background 0.2s;
    }

    .mobile-onboard-dismiss:active { background: #e8c84a; }

}
/* ── Mobile passage button ───────────────────────────────────────────────── */
.reader-mobile-passage-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 2000;
    background: linear-gradient(135deg, #E8C547, #D4AF37, #B8960C);
    color: #111;
    border: none;
    padding: 12px 20px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-radius: 2px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
@media (max-width: 768px) {
    .reader-selection-bar {
        width: calc(100% - 40px);
    }
}

/* ── Download PDF button (desktop) ──────────────────────────────────────── */
.reader-sheet-download {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #D4AF37 !important;
    text-decoration: none !important;
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 5px 12px;
    border-radius: 2px;
    transition: border-color 0.2s, background 0.2s;
}
.reader-sheet-download:hover,
.reader-sheet-download:visited,
.reader-sheet-download:active,
.reader-sheet-download:focus {
    color: #D4AF37 !important;
    text-decoration: none !important;
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.6);
    outline: none;
}
