/* ================================================================ */
/*  READER PREMIUM — Estilos externalizados                         */
/*  Diseño: premium, mobile-first, modo claro/oscuro                */
/* ================================================================ */

/* CONTENEDOR PRINCIPAL */
.psn-reader { max-width: 800px; margin: 0 auto; padding: 0; min-height: 100vh; display: flex; flex-direction: column; }
.psn-reader body { margin: 0; }

/* BARRA SUPERIOR */
.psn-reader-topbar {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; background: white;
    border-bottom: 1px solid #e5e5ea;
    position: sticky; top: 0; z-index: 100;
}
.psn-reader-topbar-back {
    font-size: 20px; text-decoration: none; color: #0a84ff;
    padding: 4px 8px; border-radius: 8px;
}
.psn-reader-topbar-back:hover { background: #f0f7ff; text-decoration: none; }
.psn-reader-topbar-title {
    font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: #1c1c1e; margin: 0;
}
.psn-reader-topbar-meta { display: flex; gap: 6px; font-size: 11px; color: #8e8e93; margin-top: 2px; }
.psn-reader-topbar-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.psn-topbar-action-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 7px 10px; border: 0.5px solid #e0e0e0; border-radius: 8px;
    background: #f8f9fa; cursor: pointer; font-size: 12px; color: #1c1c1e;
    transition: all 0.2s; white-space: nowrap;
}
.psn-topbar-action-btn:hover { background: #eef2ff; border-color: #1a56db; color: #1a56db; }
.psn-action-icon { font-size: 15px; line-height: 1; }
/* En mobile: label visible pero más corto */
.psn-action-label { font-weight: 600; font-size: 11px; }
/* Topbar: título comprimido para que quepan los botones */
.psn-reader-topbar-info { flex: 1; min-width: 0; overflow: hidden; }
@media (max-width: 480px) {
    /* En mobile mostramos label pero reducimos padding */
    .psn-topbar-action-btn { padding: 6px 7px; font-size: 11px; gap: 3px; }
    .psn-action-icon { font-size: 14px; }
    .psn-action-label { font-size: 10px; }
    .psn-reader-topbar-actions { gap: 3px; }
}
.psn-reader-topbar-btn {
    background: none; border: 1px solid #e5e5ea; border-radius: 8px;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px; transition: all 0.2s;
}
.psn-reader-topbar-btn:hover { background: #f0f7ff; border-color: #0a84ff; }

/* BARRA DE PROGRESO */
.psn-reader-progress { height: 3px; background: #f0f0f0; position: sticky; top: 61px; z-index: 99; }
.psn-reader-progress-fill { height: 100%; background: linear-gradient(90deg, #0a84ff, #34c759); transition: width 0.3s; border-radius: 0 2px 2px 0; }

/* CONTENIDO DEL TEXTO */
.psn-reader-content {
    flex: 1; padding: 24px 20px 120px;
    background: var(--psn-reader-bg, #ffffff);
    color: var(--psn-reader-text, #1c1c1e);
    line-height: var(--psn-reader-line-height, 1.8);
    font-size: var(--psn-reader-font-size, 17px);
    transition: background 0.3s, color 0.3s;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}
.psn-reader-content p {
    margin-bottom: 16px;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.psn-reader-content h1 {
    font-size: 24px; font-weight: 700; margin: 0 0 20px;
    color: var(--psn-reader-text, #1c1c1e);
}
.psn-reader-content p { margin-bottom: 16px; }

/* PALABRAS CLICKEABLES - visualmente invisibles */
.psn-word {
    display: inline;
    background: transparent !important;
    border: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    line-height: inherit;
    text-decoration: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation;
    cursor: pointer;
}
.psn-word.selected {
    background: rgba(255, 213, 79, 0.35) !important;
    border-radius: 4px;
}
.psn-word.saved {
    border-bottom: 2px solid #34c759 !important;
}

/* MODO OSCURO */
.psn-reader.dark .psn-reader-topbar { background: #1c1c1e; border-color: #2c2c2e; }
.psn-reader.dark .psn-reader-topbar-title { color: #f5f5f7; }
.psn-reader.dark .psn-reader-topbar-btn { border-color: #2c2c2e; color: #f5f5f7; }
.psn-reader.dark .psn-reader-topbar-btn:hover { background: #2c2c2e; }
.psn-reader.dark .psn-reader-content { background: #1c1c1e; color: #f5f5f7; }

/* TOOLTIP (DESKTOP) */
.psn-word-tooltip {
    position: fixed; background: white; border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 16px 18px; max-width: 340px; width: 340px;
    z-index: 10000; border: 1px solid #e5e5ea;
    display: none; animation: psnTooltipIn 0.2s ease;
}
@keyframes psnTooltipIn { from { opacity: 0; transform: scale(0.95) translateY(4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.psn-tooltip-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.psn-tooltip-headword { font-size: 20px; font-weight: 700; color: #1c1c1e; }
.psn-tooltip-phonetic { font-size: 13px; color: #8e8e93; font-weight: 400; margin-left: 6px; }
.psn-tooltip-pos { font-size: 11px; color: #8e8e93; background: #f0f0f0; padding: 2px 8px; border-radius: 4px; margin-left: 6px; }
.psn-tooltip-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; padding: 0 4px; line-height: 1; }
.psn-tooltip-body { margin-bottom: 10px; }
.psn-tooltip-def { font-size: 14px; color: #1c1c1e; margin: 0 0 4px; }
.psn-tooltip-trans { font-size: 14px; color: #0a84ff; font-weight: 500; margin: 0 0 4px; }
.psn-tooltip-example { font-size: 13px; color: #666; font-style: italic; margin: 0 0 6px; padding-left: 8px; border-left: 2px solid #e5e5ea; }
.psn-tooltip-freq { font-size: 11px; color: #8e8e93; }
.psn-tooltip-freq .high { color: #34c759; } .psn-tooltip-freq .medium { color: #ff9500; } .psn-tooltip-freq .low { color: #ff3b30; }
.psn-tooltip-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid #f0f0f0; }
.psn-tooltip-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.2s; border: 1px solid #e5e5ea; background: white; color: #1c1c1e;
}
.psn-tooltip-btn:hover { border-color: #0a84ff; background: #f0f7ff; }
.psn-tooltip-btn.primary { background: #0a84ff; color: white; border-color: #0a84ff; }
.psn-tooltip-btn.primary:hover { background: #0066cc; }
.psn-tooltip-btn.saved { background: #e8f5e9; border-color: #34c759; color: #2e7d32; }
.psn-tooltip-btn.ia { background: linear-gradient(135deg, #667eea, #764ba2); color: white; border: none; }
.psn-tooltip-btn.ia:hover { opacity: 0.9; }

/* BOTTOM SHEET (MOBILE) */
.psn-bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    z-index: 10000; max-height: 60vh; overflow-y: auto;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 16px 20px 24px;
}
.psn-bottom-sheet.open { transform: translateY(0); }
.psn-bottom-sheet-handle {
    width: 36px; height: 4px; background: #ddd; border-radius: 2px;
    margin: 0 auto 12px; cursor: pointer;
}
.psn-bottom-sheet .psn-tooltip-actions { border-top: 1px solid #f0f0f0; padding-top: 12px; }

/* FOOTER ACCIONES */
.psn-reader-footer {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; border-top: 1px solid #e5e5ea;
    padding: 10px 16px; display: flex; gap: 8px;
    justify-content: center; z-index: 99;
}
.psn-reader-footer-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
    cursor: pointer; border: 1px solid #e5e5ea; background: white; color: #1c1c1e;
    transition: all 0.2s; text-decoration: none;
}
.psn-reader-footer-btn:hover { border-color: #0a84ff; text-decoration: none; }
.psn-reader-footer-btn.primary { background: #0a84ff; color: white; border-color: #0a84ff; }

/* MODAL AJUSTES */
.psn-settings-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    animation: psnFadeIn 0.2s;
}
@keyframes psnFadeIn { from { opacity: 0; } to { opacity: 1; } }
.psn-settings-modal-content {
    background: white; border-radius: 16px; padding: 24px;
    max-width: 340px; width: 90%; box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    animation: psnScaleIn 0.3s;
}
@keyframes psnScaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.psn-settings-modal h3 { margin: 0 0 16px; font-size: 18px; }
.psn-settings-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.psn-settings-row label { font-size: 14px; color: #1c1c1e; }
.psn-settings-row select, .psn-settings-row button {
    padding: 6px 12px; border: 1px solid #e5e5ea; border-radius: 8px; font-size: 14px; background: white;
}

/* VOCABULARIO INLINE */
.psn-inline-vocab {
    margin: 20px 0; padding: 16px; background: #f0f7ff; border-radius: 12px;
    border-left: 3px solid #0a84ff;
}
.psn-inline-vocab-title { font-size: 13px; font-weight: 600; color: #0a84ff; margin: 0 0 8px; }
.psn-inline-vocab-word {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; margin: 2px; border-radius: 6px; background: white;
    font-size: 13px; font-weight: 500; border: 1px solid #e5e5ea;
}
.psn-inline-vocab-word.saved { background: #e8f5e9; border-color: #34c759; }

/* PREGUNTAS */
.psn-comprehension { margin-top: 32px; padding: 24px; background: #f8f9fa; border-radius: 14px; }
.psn-comprehension h3 { margin: 0 0 16px; font-size: 16px; }
.psn-question { margin-bottom: 16px; }
.psn-question p { font-weight: 500; margin: 0 0 8px; font-size: 14px; }
.psn-question-options { display: flex; flex-direction: column; gap: 6px; }
.psn-question-option {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; background: white; border: 1px solid #e5e5ea;
    border-radius: 8px; cursor: pointer; transition: all 0.2s;
}
.psn-question-option:hover { border-color: #0a84ff; }
.psn-question-option input[type="radio"] { accent-color: #0a84ff; }
.psn-question-option.selected { border-color: #0a84ff; background: #f0f7ff; font-weight: 600; }
.psn-question-option.correct { border-color: #34c759; background: #e8f5e9; }
.psn-question-option.wrong { border-color: #ff3b30; background: #ffebee; }

/* MODAL IA */
.psn-ia-modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 99999; display: flex; align-items: center; justify-content: center; }
.psn-ia-modal-content { background: white; border-radius: 16px; padding: 24px; max-width: 400px; width: 90%; max-height: 70vh; overflow-y: auto; box-shadow: 0 16px 48px rgba(0,0,0,0.2); }
.psn-ia-modal h3 { margin: 0 0 8px; font-size: 18px; }
.psn-ia-word { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.psn-ia-def { font-size: 15px; color: #1c1c1e; margin: 0 0 8px; line-height: 1.5; }
.psn-ia-trans { font-size: 14px; color: #0a84ff; font-weight: 500; margin: 0 0 8px; }
.psn-ia-examples { margin: 8px 0; }
.psn-ia-example { font-size: 13px; color: #666; font-style: italic; margin: 4px 0; padding: 6px 10px; background: #f8f9fa; border-radius: 6px; }
.psn-ia-synonyms { font-size: 13px; color: #666; margin: 8px 0; }
.psn-ia-close { margin-top: 12px; width: 100%; padding: 10px; border: 1px solid #e5e5ea; border-radius: 8px; background: white; cursor: pointer; font-size: 14px; }

/* REPRODUCTOR DE AUDIO */
.psn-audio-player {
    display: none; align-items: center; gap: 12px;
    padding: 12px 16px; background: #f0f7ff; border-radius: 12px;
    margin-bottom: 16px; border: 1px solid #dde8f5;
}
.psn-audio-player.visible { display: flex; }
.psn-audio-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: #0a84ff; cursor: pointer; display: flex; align-items: center; justify-content: center; 
    font-size: 20px; color: white; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(10,132,255,0.3);
    transition: all 0.2s;
}
.psn-audio-btn:hover { background: #0066cc; transform: scale(1.05); }
.psn-audio-btn.paused { background: #34c759; }
.psn-audio-info { flex: 1; }
.psn-audio-title { font-size: 14px; font-weight: 600; color: #1c1c1e; }
.psn-audio-status { font-size: 12px; color: #8e8e93; }
.psn-audio-timer { font-size: 12px; color: #8e8e93; min-width: 36px; text-align: right; }

/* ESTADOS VACÍOS */
.psn-reader-empty { text-align: center; padding: 80px 20px; }
.psn-reader-empty-icon { font-size: 64px; margin-bottom: 16px; }
.psn-reader-empty h2 { font-size: 20px; margin: 0 0 8px; }
.psn-reader-empty p { color: #8e8e93; margin: 0 0 20px; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .psn-word-tooltip { display: none !important; }
    .psn-reader-content { padding: 16px 14px 120px; font-size: var(--psn-reader-font-size, 16px); }
    .psn-reader-content h1 { font-size: 20px; }
}
@media (min-width: 769px) {
    .psn-bottom-sheet { display: none !important; }
    .psn-reader-content { padding: 32px 40px 120px; }
}

/* SIDEBAR VOCABULARIO */
.psn-reader-sidebar {
    position: fixed; right: 0; top: 0; height: 100%; width: 340px;
    background: white; box-shadow: -4px 0 24px rgba(0,0,0,0.1);
    z-index: 9999; transform: translateX(100%); transition: transform 0.3s;
    overflow-y: auto; display: flex; flex-direction: column;
}
.psn-reader-sidebar.open { transform: translateX(0); }
@media (max-width: 768px) {
    .psn-reader-sidebar { width: 100%; }
}

/* ================================================================ */
/*  READER V2 — Sistema limpio de tokens interactivos               */
/* ================================================================ */

.psn-reader-text-v2 {
    width: 100%; max-width: 100%; overflow-x: hidden;
    white-space: normal; word-break: normal; overflow-wrap: break-word;
    -webkit-user-select: none !important; user-select: none !important;
    -webkit-touch-callout: none !important;
}
.psn-reader-text-v2 p {
    margin: 0 0 1.2em; white-space: normal;
    max-width: 100%; overflow-wrap: break-word;
}

.psn-token {
    appearance: none; -webkit-appearance: none;
    display: inline; border: 0 !important; outline: 0 !important;
    box-shadow: none !important; background: transparent !important;
    padding: 0 !important; margin: 0 !important;
    font: inherit !important; color: inherit !important;
    line-height: inherit !important; text-decoration: none !important;
    cursor: pointer;
    -webkit-user-select: none !important; user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation;
}
.psn-token:focus, .psn-token:active, .psn-token:hover {
    outline: 0 !important; background: transparent !important;
    text-decoration: none !important;
}
.psn-token-active {
    background: rgba(255, 213, 79, 0.35) !important;
    border-radius: 4px;
}

/* BOTTOM SHEET V2 */
.psn-word-sheet-v2 {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    z-index: 10000; max-height: 60vh; overflow-y: auto;
    transform: translateY(100%); transition: transform 0.3s;
    padding: 16px 20px 24px;
}
.psn-word-sheet-v2.open { transform: translateY(0); }
.psn-sheet-v2-handle {
    width: 36px; height: 4px; background: #ddd; border-radius: 2px;
    margin: 0 auto 12px; cursor: pointer;
}
.psn-sheet-v2-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0;
}
.psn-sheet-v2-word { font-size: 22px; font-weight: 700; color: #1c1c1e; }
.psn-sheet-v2-phonetic { font-size: 14px; color: #8e8e93; margin-left: 8px; }
.psn-sheet-v2-label { font-size: 13px; color: #8e8e93; min-width: 70px; }
.psn-sheet-v2-value { font-size: 15px; color: #1c1c1e; font-weight: 500; text-align: right; }
.psn-sheet-v2-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid #f0f0f0; margin-top: 8px; }
.psn-sheet-v2-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    cursor: pointer; border: 1px solid #e5e5ea; background: white; color: #1c1c1e;
    transition: all 0.2s;
}
.psn-sheet-v2-btn:hover { border-color: #0a84ff; background: #f0f7ff; }
.psn-sheet-v2-btn.primary { background: #0a84ff; color: white; border-color: #0a84ff; }
.psn-sheet-v2-btn.ia { background: linear-gradient(135deg, #667eea, #764ba2); color: white; border: none; }
.psn-sheet-v2-btn.saved { background: #e8f5e9; border-color: #34c759; color: #2e7d32; }
.psn-sheet-v2-close {
    background: none; border: none; font-size: 22px; cursor: pointer; color: #999; padding: 0 4px;
}

