/* Floating audio player overlay — shown when the user clicks any play
   button in the Book → Audio Files list. Slides up from the bottom. */

#audioPlayerOverlay {
    position: fixed;
    left: 50%;
    bottom: -180px;
    transform: translateX(-50%);
    width: min(720px, calc(100vw - 48px));
    background: rgba(17, 24, 39, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 14px 18px 16px;
    z-index: 10000;
    color: #e5e7eb;
    font-family: inherit;
    transition: bottom 0.22s ease, opacity 0.22s ease;
    opacity: 0;
    pointer-events: none;
}
#audioPlayerOverlay.apo-open {
    bottom: 24px;
    opacity: 1;
    pointer-events: auto;
}

.apo-top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-bottom: 10px;
}
.apo-title {
    flex: 1 1 auto;
    font-size: 0.9rem;
    font-weight: 600;
    color: #f8fafc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.apo-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
}
.apo-close:hover { background: rgba(255, 255, 255, 0.08); color: #f1f5f9; }

.apo-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 12px;
}
.apo-time { min-width: 44px; text-align: center; }
.apo-time-remaining { color: #64748b; }
.apo-seek {
    flex: 1 1 auto;
    height: 6px;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 3px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}
.apo-seek-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg, #7c3aed, #00d4ff);
    border-radius: 3px;
    transition: width 0.1s linear;
}
.apo-seek-thumb {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f8fafc;
    transform: translate(-50%, -50%);
    left: 0%;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3);
    pointer-events: none;
}

.apo-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}
.apo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #f8fafc;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
    font-family: inherit;
    padding: 0;
}
.apo-btn:hover { background: rgba(124, 58, 237, 0.3); }
.apo-btn:active { transform: scale(0.95); }
.apo-btn-skip { width: 44px; height: 44px; font-size: 0.7rem; font-weight: 600; }
.apo-btn-skip svg { width: 22px; height: 22px; }
.apo-btn-skip span { font-size: 0.65rem; line-height: 1; margin-top: 1px; }
.apo-btn-play {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, #7c3aed, #00d4ff);
    border: none;
    color: #0b1220;
    font-size: 1.4rem;
}
.apo-btn-play:hover { filter: brightness(1.1); background: linear-gradient(135deg, #7c3aed, #00d4ff); }
.apo-btn-play svg { width: 26px; height: 26px; fill: currentColor; }

/* Active-row highlight: the file currently playing shows a pulsing dot */
.fe-play-btn.fe-playing-apo {
    background: rgba(124, 58, 237, 0.25) !important;
    color: #c4b5fd !important;
}

/* ─── Proofread expansion ─────────────────────────────────────── */
.apo-iconbtn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.apo-iconbtn svg { width: 18px; height: 18px; }
.apo-iconbtn:hover { background: rgba(255, 255, 255, 0.08); color: #f1f5f9; }
.apo-iconbtn.apo-flag-flash { color: #fbbf24; background: rgba(251,191,36,0.2); }
.apo-iconbtn.apo-copy-ok { color: #34d399; background: rgba(52, 211, 153, 0.2); }
.apo-iconbtn.apo-copy-fail { color: #f87171; background: rgba(248, 113, 113, 0.2); }

#audioPlayerOverlay:not(.apo-has-proof) #apoToggleProof,
#audioPlayerOverlay:not(.apo-has-proof) #apoFlag { display: none; }

.apo-proof {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 14px;
    max-height: 360px;
}
#audioPlayerOverlay.apo-proof-open.apo-has-proof {
    width: min(960px, calc(100vw - 48px));
}
#audioPlayerOverlay.apo-proof-open.apo-has-proof .apo-proof { display: grid; }

.apo-proof-transcript {
    overflow-y: auto;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    font-family: Georgia, serif;
    line-height: 1.7;
    font-size: 0.98rem;
    color: #e2e8f0;
    max-height: 360px;
    text-align: left;
    hyphens: none;
}
.apo-para {
    margin: 0 0 1em 0;
    text-indent: 1.6em;
}
.apo-para:first-child { text-indent: 0; }
.apo-para:last-child { margin-bottom: 0; }
.apo-proof-status {
    color: #94a3b8;
    font-size: 0.85rem;
    font-style: italic;
    padding: 8px 0;
}
.apo-retry {
    display: inline-block;
    margin-left: 10px;
    padding: 3px 12px;
    background: rgba(124, 58, 237, 0.25);
    color: #e2e8f0;
    border: 1px solid rgba(124, 58, 237, 0.5);
    border-radius: 6px;
    font-size: 0.78rem;
    font-style: normal;
    cursor: pointer;
}
.apo-retry:hover { background: rgba(124, 58, 237, 0.5); }
.apo-word {
    cursor: pointer;
    padding: 1px 2px;
    border-radius: 3px;
    transition: background 0.1s ease;
}
.apo-word:hover { background: rgba(124, 58, 237, 0.18); }
.apo-word-active {
    background: #fde047;
    color: #0b1220;
    font-weight: 700;
}

.apo-proof-flags {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    max-height: 360px;
}
.apo-proof-flags-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}
.apo-proof-flags-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1 1 auto;
}
.apo-proof-empty {
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.4;
    padding: 6px 4px;
}

.apo-flag-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 8px;
}
.apo-flag-jump {
    display: inline-flex;
    align-items: center;
    background: rgba(251, 191, 36, 0.14);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    cursor: pointer;
}
.apo-flag-jump:hover { background: rgba(251, 191, 36, 0.28); }
.apo-flag-body { min-width: 0; }
.apo-flag-word {
    font-size: 0.85rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.apo-flag-word-text { color: #f1f5f9; }
.apo-flag-word-pending {
    color: #94a3b8;
    font-weight: 500;
    font-style: italic;
    font-size: 0.78rem;
}
.apo-flag-context {
    color: #94a3b8;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.apo-flag-del {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.apo-flag-del:hover { color: #f87171; background: rgba(248,113,113,0.12); }

/* Flag markers drawn on the seekbar */
.apo-flag-track {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.apo-flag-tick {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: #fbbf24;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.25);
    transform: translateX(-1px);
}
