/* Reading mode — mobile only */
@media (min-width: 768px) {
    .reading-mode-btn,
    #interpretationReadingBtn,
    #historyReadingBtn {
        display: none !important;
    }
}

.reading-mode-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 9px 14px;
    border: 1px solid rgba(200, 180, 255, 0.22);
    border-radius: 10px;
    background: rgba(45, 35, 85, 0.55);
    color: #d8c8ff;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.reading-mode-btn:hover:not(:disabled),
.reading-mode-btn:focus-visible {
    background: rgba(65, 50, 110, 0.8);
    border-color: rgba(212, 181, 255, 0.45);
    color: #f3e8ff;
    outline: none;
}

.reading-mode-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.reading-mode-btn.is-active {
    background: rgba(65, 50, 110, 0.8);
    border-color: rgba(212, 181, 255, 0.45);
    color: #f3e8ff;
}

.reading-mode-btn[hidden] {
    display: none !important;
}

.reading-mode-btn--compact {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 8px;
}

[data-theme="light"] .reading-mode-btn {
    border-color: var(--border);
    background: #fff9f2;
    color: var(--text-heading);
}

[data-theme="light"] .reading-mode-btn:hover:not(:disabled),
[data-theme="light"] .reading-mode-btn:focus-visible,
[data-theme="light"] .reading-mode-btn.is-active {
    background: #f5ebe0;
    border-color: rgba(92, 61, 46, 0.34);
    color: var(--text-heading);
}

[data-theme="light"] .reading-mode-btn:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Mobile: wider interpretation text without changing desktop layout */
@media (max-width: 767px) {
    .interpretation-prose {
        padding: 18px 14px;
        border-radius: 12px;
    }

    .interpretation-prose ul,
    .interpretation-prose ol {
        margin-left: 1.1em;
    }

    .history-modal {
        padding: 8px;
    }

    .history-modal__panel {
        padding: 14px 12px 12px;
    }

    .history-modal__body.interpretation-prose {
        padding: 16px 12px;
    }
}

/* Reading mode */
.reading-mode-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2200;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.reading-mode-bar__main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: calc(48px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0 8px;
}

.reading-mode-bar__progress {
    height: 3px;
    flex-shrink: 0;
    background: rgba(200, 180, 255, 0.16);
    overflow: hidden;
}

.reading-mode-bar__progress-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: width 0.1s linear;
}

@media (prefers-reduced-motion: reduce) {
    .reading-mode-bar__progress-fill {
        transition: none;
    }
}

.reading-mode-bar[hidden] {
    display: none !important;
}

.reading-mode-bar__close {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(200, 180, 255, 0.22);
    border-radius: 10px;
    background: rgba(45, 35, 85, 0.55);
    color: #d8c8ff;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.reading-mode-bar__close:hover,
.reading-mode-bar__close:focus-visible {
    background: rgba(65, 50, 110, 0.8);
    border-color: rgba(212, 181, 255, 0.45);
    color: #f3e8ff;
    outline: none;
}

.reading-mode-bar__title {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.reading-mode {
    overflow: hidden;
    padding-bottom: 0 !important;
}

body.reading-mode .bottom-nav {
    opacity: 0;
    pointer-events: none;
}

/* Natal page reading mode */
body.reading-mode[data-reading-scope="natal"] .container.natal-page {
    position: fixed;
    inset: 0;
    z-index: 2100;
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 0;
    border: none;
    padding: calc(55px + env(safe-area-inset-top, 0px)) 0 calc(16px + env(safe-area-inset-bottom, 0px));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    text-align: left;
}

body.reading-mode[data-reading-scope="natal"] .natal-page > *:not(#interpretationSection) {
    display: none !important;
}

body.reading-mode[data-reading-scope="natal"] #interpretationSection {
    margin: 0;
}

body.reading-mode[data-reading-scope="natal"] #interpretationSection > :not(#interpretationResult) {
    display: none !important;
}

body.reading-mode[data-reading-scope="natal"] #interpretationResult {
    margin: 0;
}

body.reading-mode[data-reading-scope="natal"] #interpretationResultHeader,
body.reading-mode[data-reading-scope="natal"] #interpretationResultFooter,
body.reading-mode[data-reading-scope="natal"] #interpretationBackActions {
    display: none !important;
}

body.reading-mode[data-reading-scope="natal"] #interpretationOutput {
    margin: 0 auto;
    max-width: 42rem;
    width: 100%;
    min-height: calc(100dvh - 71px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 20px 16px 28px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    font-size: 1.08rem;
    line-height: 1.75;
    box-shadow: none;
}

/* History modal reading mode */
body.reading-mode[data-reading-scope="history"] .history-modal {
    padding: 0;
}

body.reading-mode[data-reading-scope="history"] .history-modal__panel {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: none;
    padding: calc(55px + env(safe-area-inset-top, 0px)) 0 calc(12px + env(safe-area-inset-bottom, 0px));
}

body.reading-mode[data-reading-scope="history"] .history-modal__header {
    display: none;
}

body.reading-mode[data-reading-scope="history"] #historyReadingStrip {
    display: none !important;
}

body.reading-mode[data-reading-scope="history"] #historyModalBody {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 auto;
    max-width: 42rem;
    width: 100%;
    padding: 20px 16px 28px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    font-size: 1.08rem;
    line-height: 1.75;
    box-shadow: none;
}

[data-theme="light"] .reading-mode-bar__close {
    border-color: var(--border);
    background: var(--bg-elevated);
    color: var(--text-heading);
}

[data-theme="light"] .reading-mode-bar__close:hover,
[data-theme="light"] .reading-mode-bar__close:focus-visible {
    background: rgba(139, 94, 60, 0.12);
    border-color: rgba(139, 94, 60, 0.35);
}

[data-theme="light"] .reading-mode-bar__progress {
    background: rgba(92, 61, 46, 0.12);
}
