/**
 * The Living Chronicle & Voiced Lorekeeper — Window & UI Styles
 * Seamless integration with Angband3D dark fantasy theme and draggable window system.
 */

/* Standalone Client Guard: Strictly hide The Living Chronicle & Tome on Desktop/Android standalones */
body.is-standalone #btn-toggle-chronicle,
body.is-standalone #chronicle-window {
    display: none !important;
}

#chronicle-window {
    position: absolute;
    top: 50px;
    right: 20px;
    z-index: 7;
    width: min(340px, calc(100vw - 32px));
    min-width: 260px;
    max-width: 90vw;
    height: min(340px, 52dvh);
    min-height: 160px;
    max-height: 85vh;
    background: rgba(10, 13, 20, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.9), 0 0 15px rgba(212, 175, 55, 0.1);
    display: none; /* Controlled by chronicle-manager.js based on toggle state */
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#chronicle-window.active {
    display: flex;
}

#chronicle-window.minimized {
    height: 38px !important;
    min-height: 38px !important;
}

#chronicle-window.minimized #chronicle-scroll,
#chronicle-window.minimized #chronicle-interactive-bar,
#chronicle-window.minimized #chronicle-footer,
#chronicle-window.minimized .chronicle-transport-deck {
    display: none !important;
}

@media (max-width: 768px) {
    #chronicle-window {
        top: 45px;
        left: 10px;
        right: 10px;
        width: auto;
        min-width: 0;
        max-width: none;
        height: 380px;
    }
}

/* Header */
/* Header: 2-Tier Modern Layout */
.chronicle-header {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: linear-gradient(180deg, rgba(22, 28, 42, 0.98) 0%, rgba(14, 18, 28, 0.98) 100%);
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding: 6px 10px;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.chronicle-header:active {
    cursor: grabbing;
}

.chronicle-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.chronicle-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chronicle-window-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chronicle-transport-deck {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: rgba(8, 11, 18, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 5px;
    padding: 3px 6px;
    width: 100%;
    box-sizing: border-box;
}

.chronicle-transport-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.chronicle-play-main-btn {
    font-weight: 700;
    min-width: 58px;
    border-color: rgba(212, 175, 55, 0.45);
}

.chronicle-play-main-btn.loading {
    border-color: rgba(255, 215, 0, 0.8) !important;
    background: rgba(255, 215, 0, 0.15) !important;
    color: #ffd700 !important;
    cursor: wait !important;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
}

.voice-loading-spinner {
    display: inline-block;
    width: 9px;
    height: 9px;
    border: 2px solid rgba(255, 215, 0, 0.25);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: voiceSpin 0.75s linear infinite;
    margin-right: 4px;
    vertical-align: middle;
}

@keyframes voiceSpin {
    to { transform: rotate(360deg); }
}

.voice-loading-pulse {
    color: #ffd700 !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    animation: statusGlow 1.2s ease-in-out infinite alternate;
}

.voice-pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ffd700;
    box-shadow: 0 0 6px #ffd700;
    animation: dotPulse 0.9s ease-in-out infinite alternate;
}

@keyframes statusGlow {
    from { opacity: 0.8; }
    to { opacity: 1; text-shadow: 0 0 8px rgba(255, 215, 0, 0.7); }
}

@keyframes dotPulse {
    from { transform: scale(0.8); opacity: 0.6; }
    to { transform: scale(1.35); opacity: 1; }
}

.chronicle-audio-toggles {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chronicle-title {
    font-family: var(--font-fantasy, Georgia, serif);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--gold-bright, #ffd700);
    text-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chronicle-tradition-badge {
    font-size: 9px;
    font-family: var(--font-terminal, monospace);
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 3px;
    padding: 1px 5px;
    letter-spacing: 0.5px;
}

.chronicle-ctrl-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 4px;
    color: #e2e8f0;
    font-family: var(--font-terminal, monospace);
    font-size: 10px;
    padding: 2px 7px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
}

.chronicle-ctrl-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: rgba(212, 175, 55, 0.6);
    color: #ffd700;
}

.chronicle-ctrl-btn.active {
    background: rgba(212, 175, 55, 0.25);
    border-color: #ffd700;
    color: #ffd700;
}

#btn-chronicle-stop.active {
    border-color: rgba(239, 68, 68, 0.6);
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
}

#btn-chronicle-stop.active:hover {
    border-color: #ef4444;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.25);
}

/* Scroll Area & Body */
.chronicle-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 14px;
    font-family: var(--font-fantasy, "IM Fell English", Georgia, serif);
    color: #e2e8f0;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chronicle-scroll::-webkit-scrollbar {
    width: 6px;
}

.chronicle-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.chronicle-scroll::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.chronicle-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.6);
}

/* Chapter Card */
.chapter-card {
    background: rgba(18, 22, 34, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 6px;
    padding: 10px 12px;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    animation: fadeInChapter 0.3s ease-out;
}

/* Mythic Crossroads & Interactive Vow Cards (WS28) */
.chronicle-crossroads-box {
    margin-top: 8px;
    padding: 8px 10px;
    background: linear-gradient(135deg, rgba(34, 25, 14, 0.88) 0%, rgba(18, 13, 8, 0.92) 100%);
    border: 1px solid rgba(212, 175, 55, 0.42);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chronicle-crossroads-header {
    font-family: var(--font-fantasy, 'Cinzel', serif);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #ffd700;
}

.chronicle-crossroads-prompt {
    font-size: 11.5px;
    color: #e8dec8;
    font-style: italic;
}

.chronicle-vow-choices {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chronicle-vow-choice-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(212, 175, 55, 0.10);
    border: 1px solid rgba(212, 175, 55, 0.32);
    border-radius: 5px;
    padding: 5px 8px;
    color: #f5ebd6;
    cursor: pointer;
    text-align: left;
    transition: all 0.14s ease;
}

.chronicle-vow-choice-btn:hover,
.chronicle-vow-choice-btn.is-sworn {
    background: rgba(212, 175, 55, 0.24);
    border-color: #ffd700;
    color: #ffffff;
}

.vow-choice-label {
    font-family: var(--font-ui, sans-serif);
    font-size: 11px;
    font-weight: 600;
}

.vow-choice-epithet {
    font-family: var(--font-terminal, monospace);
    font-size: 9.5px;
    color: #ffd166;
    opacity: 0.9;
}

/* Chapter Card: Solemn Hero Death Requiem & Epitaph */
.chapter-card.chapter-death {
    background: linear-gradient(135deg, rgba(68, 14, 18, 0.85) 0%, rgba(24, 7, 10, 0.95) 100%);
    border: 1.5px solid rgba(239, 68, 68, 0.65);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 14px rgba(220, 38, 38, 0.35), inset 0 0 12px rgba(185, 28, 28, 0.2);
    animation: fadeInDeathChapter 0.6s ease-out;
}

@keyframes fadeInDeathChapter {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chapter-card.chapter-death .death-header {
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    padding-bottom: 4px;
    margin-bottom: 6px;
}

.chapter-card.chapter-death .death-badge {
    color: #fca5a5;
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(220, 38, 38, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.chapter-card.chapter-death .death-prose {
    color: #fecaca;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.6;
    letter-spacing: 0.2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.chapter-card.chapter-death .death-insight {
    background: rgba(45, 10, 15, 0.55);
    border-left: 3px solid #ef4444;
    color: #fca5a5;
}

@keyframes fadeInChapter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Story Entry Meta & Depth Tag */
.entry-meta-depth {
    font-size: 10px;
    font-family: var(--font-terminal, monospace);
    color: #ffd700;
    opacity: 0.75;
    letter-spacing: 0.5px;
}

/* Prose & Quotes */
.chapter-prose {
    font-size: 12.5px;
    line-height: 1.55;
    color: #e2e8f0;
    margin: 0;
}

.chapter-dialogue {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(212, 175, 55, 0.08);
    border-left: 3px solid #ffd700;
    border-radius: 0 4px 4px 0;
    font-style: italic;
    font-size: 12px;
    line-height: 1.45;
    color: #fef08a;
}

.chapter-dialogue.creature-sound-box {
    background: rgba(148, 163, 184, 0.08);
    border-left: 3px solid #94a3b8;
    color: #cbd5e1;
}

.creature-sound-box .dialogue-speaker {
    color: #94a3b8;
}

.dialogue-sound-noise {
    font-style: italic;
    letter-spacing: 0.2px;
}

.chapter-lead-block {
    position: relative;
    border-radius: 4px;
    padding: 5px 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.chapter-lead-block:hover {
    background: rgba(212, 175, 55, 0.05);
    border-color: rgba(212, 175, 55, 0.25);
}

.flowing-paragraph-block {
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 8px;
    border-radius: 4px;
    padding: 6px;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
}

.flowing-paragraph-block:hover {
    background: rgba(212, 175, 55, 0.05);
    border-color: rgba(212, 175, 55, 0.25);
}

.flowing-paragraph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.flow-play-btn {
    background: rgba(18, 22, 34, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 5px;
    color: #94a3b8;
    font-size: 11px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    user-select: none;
}

.flowing-paragraph-block:hover .flow-play-btn,
.flow-play-btn:hover {
    opacity: 1;
    color: #ffd700;
    border-color: #ffd700;
    background: rgba(212, 175, 55, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.flow-play-btn.active.playing {
    opacity: 1;
    color: #ffd700;
    background: rgba(212, 175, 55, 0.3);
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    animation: playPulse 2s infinite ease-in-out;
}

.flow-play-btn.active.paused {
    opacity: 1;
    color: #fef08a;
    background: rgba(212, 175, 55, 0.15);
    border: 1.5px dashed #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

@keyframes playPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
        border-color: rgba(255, 215, 0, 0.8);
    }
    50% {
        box-shadow: 0 0 16px rgba(255, 215, 0, 0.8);
        border-color: #ffd700;
    }
}

/* Selected Beat Highlight (Cursor Position when Paused / Stopped) */
.chapter-lead-block.narrating-selected,
.flowing-paragraph-block.narrating-selected,
.chapter-card.narrating-selected {
    border: 1px dashed rgba(212, 175, 55, 0.65) !important;
    background: rgba(212, 175, 55, 0.07) !important;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2) !important;
}

/* Paused State on Card */
.chapter-card.is-paused,
.flowing-paragraph-block.is-paused {
    border: 1.5px dashed rgba(255, 215, 0, 0.75) !important;
    background: rgba(212, 175, 55, 0.08) !important;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.25) !important;
}

/* Playing State on Card */
.chapter-card.is-playing,
.flowing-paragraph-block.is-playing {
    border: 1.5px solid rgba(255, 215, 0, 0.9) !important;
    background: rgba(212, 175, 55, 0.12) !important;
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.4), inset 0 0 12px rgba(212, 175, 55, 0.15) !important;
}

/* Active Reading Guide Highlight */
.chapter-lead-block.narrating-active,
.flowing-paragraph-block.narrating-active,
.chapter-card.narrating-active {
    border: 1px solid rgba(212, 175, 55, 0.8) !important;
    background: rgba(212, 175, 55, 0.1) !important;
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.35), inset 0 0 10px rgba(212, 175, 55, 0.12) !important;
    animation: narratingPulse 2.4s infinite ease-in-out;
}

@keyframes narratingPulse {
    0%, 100% {
        box-shadow: 0 0 14px rgba(212, 175, 55, 0.3), inset 0 0 8px rgba(212, 175, 55, 0.1);
        border-color: rgba(212, 175, 55, 0.7);
    }
    50% {
        box-shadow: 0 0 22px rgba(212, 175, 55, 0.55), inset 0 0 14px rgba(212, 175, 55, 0.2);
        border-color: rgba(255, 215, 0, 0.95);
    }
}

.dialogue-speaker {
    font-weight: 700;
    font-style: normal;
    font-size: 10.5px;
    color: #ffd700;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

/* Tactical Lore Box */
.lorekeeper-insight {
    background: rgba(14, 42, 71, 0.4);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 4px;
    padding: 6px 10px;
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.4;
    color: #bae6fd;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.lorekeeper-insight-icon {
    color: #38bdf8;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Consultation & Q&A Bar */
.chronicle-interactive-bar {
    padding: 8px 12px;
    background: rgba(12, 16, 24, 0.95);
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.chronicle-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chronicle-query-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 4px;
    padding: 5px 8px;
    color: #f8fafc;
    font-family: inherit;
    font-size: 11px;
    outline: none;
    transition: border-color 0.15s ease;
}

.chronicle-query-input:focus {
    border-color: #ffd700;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.2);
}

.chronicle-query-input::placeholder {
    color: #64748b;
    font-style: italic;
}

.chronicle-mic-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 13px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chronicle-mic-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #ffd700;
    color: #ffd700;
}

.chronicle-mic-btn.listening {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #f87171;
    animation: micPulse 1.2s infinite ease-in-out;
}

@keyframes micPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.chronicle-send-btn {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 4px;
    color: #ffd700;
    font-family: var(--font-terminal, monospace);
    font-size: 10px;
    font-weight: 700;
    padding: 0 8px;
    height: 28px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chronicle-send-btn:hover {
    background: rgba(212, 175, 55, 0.35);
    border-color: #ffd700;
}

/* Quick Topic Pills */
.chronicle-quick-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.quick-topic-chip {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 3px;
    color: #94a3b8;
    font-size: 9.5px;
    font-family: var(--font-terminal, monospace);
    padding: 1px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-topic-chip:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.5);
    color: #f8fafc;
}

/* Footer / Action Bar */
.chronicle-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 14, 22, 0.98);
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    padding: 5px 10px;
    font-size: 10px;
    font-family: var(--font-terminal, monospace);
    color: #94a3b8;
    flex-shrink: 0;
}

.chronicle-footer-actions {
    display: flex;
    gap: 6px;
}

.chronicle-footer-btn {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 3px;
    color: #cbd5e1;
    font-size: 9.5px;
    font-family: inherit;
    padding: 2px 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chronicle-footer-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.4);
    color: #ffd700;
}

/* Settings Modal */
#chronicle-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#chronicle-settings-modal.hidden {
    display: none !important;
}

.chronicle-settings-card {
    background: #0d111a;
    border: 1px solid rgba(212, 175, 55, 0.5);
    border-radius: 8px;
    width: min(480px, 94vw);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.95);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chronicle-settings-header {
    background: rgba(20, 26, 39, 0.95);
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chronicle-settings-title {
    font-family: var(--font-fantasy, Georgia, serif);
    font-size: 13px;
    font-weight: 700;
    color: #ffd700;
    letter-spacing: 1px;
}

/* Settings Navigation Tabs */
.chronicle-settings-tabs {
    display: flex;
    background: rgba(14, 18, 28, 0.95);
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    padding: 0 8px;
    gap: 4px;
}

.settings-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #94a3b8;
    font-family: var(--font-terminal, monospace);
    font-size: 11px;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.settings-tab-btn:hover {
    color: #ffd700;
    background: rgba(212, 175, 55, 0.08);
}

.settings-tab-btn.active {
    color: #ffd700;
    border-bottom-color: #ffd700;
    background: rgba(212, 175, 55, 0.12);
}

.settings-tab-pane {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.settings-tab-pane.active {
    display: flex;
}

/* Free Tier Guard Banner */
.free-tier-banner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.35);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 4px;
}

.free-tier-badge {
    color: #4ade80;
    font-weight: 700;
    font-size: 11px;
}

.free-tier-desc {
    color: #94a3b8;
    font-size: 9.5px;
    line-height: 1.35;
}

/* Literary Tradition Preview */
.tradition-preview-box {
    background: rgba(212, 175, 55, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.tradition-preview-title {
    color: #ffd700;
    font-family: var(--font-fantasy, Georgia, serif);
    font-size: 12px;
    font-weight: 700;
}

.tradition-preview-style {
    color: #cbd5e1;
    font-size: 10px;
    font-style: italic;
}

.tradition-preview-quote {
    color: #94a3b8;
    font-size: 9.5px;
    line-height: 1.4;
    border-left: 2px solid rgba(212, 175, 55, 0.4);
    padding-left: 8px;
}

.chronicle-settings-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 75vh;
    overflow-y: auto;
    font-family: var(--font-terminal, monospace);
    font-size: 11px;
    color: #cbd5e1;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-label {
    font-weight: 700;
    color: #e2e8f0;
    font-size: 11px;
}

.settings-desc {
    color: #64748b;
    font-size: 10px;
    line-height: 1.35;
}

.settings-select,
.settings-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 4px;
    padding: 6px 8px;
    color: #f8fafc;
    font-family: inherit;
    font-size: 11px;
    outline: none;
}

.settings-select:focus,
.settings-input:focus {
    border-color: #ffd700;
}

.chronicle-settings-footer {
    padding: 10px 14px;
    background: rgba(14, 18, 28, 0.95);
    border-top: 1px solid rgba(212, 175, 55, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Interactive Creature Target Pill */
.chronicle-target-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(234, 88, 12, 0.15);
    border: 1px solid rgba(249, 115, 22, 0.4);
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 6px;
    font-size: 11px;
    color: #fdba74;
}

.chronicle-target-pill.hidden {
    display: none !important;
}

.btn-clear-target {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: #ffedd5;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-clear-target:hover {
    background: rgba(249, 115, 22, 0.4);
}

.creature-chat-card {
    border-left: 3px solid #f97316 !important;
    background: rgba(24, 18, 14, 0.6) !important;
}

.creature-chat-speaker {
    color: #fb923c !important;
    font-weight: 700;
}

.player-chat-card {
    border-left: 3px solid #38bdf8 !important;
    background: rgba(14, 24, 38, 0.6) !important;
}

/* Quick Voice Dropdown in Chronicle Header */
.chronicle-voice-quick-select {
    background: rgba(14, 18, 28, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 4px;
    color: #ffd700;
    font-family: var(--font-terminal, monospace);
    font-size: 10px;
    height: 22px;
    padding: 0 4px;
    cursor: pointer;
    outline: none;
    max-width: 140px;
    transition: all 0.15s ease;
}

.chronicle-voice-quick-select:hover,
.chronicle-voice-quick-select:focus {
    border-color: #ffd700;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
}

.chronicle-voice-quick-select optgroup {
    background: #0d111a;
    color: #94a3b8;
    font-weight: 700;
}

.chronicle-voice-quick-select option {
    background: #0d111a;
    color: #f8fafc;
}

/* Settings Modal Section Headers & Badges */
.settings-section-header {
    font-family: var(--font-fantasy, Georgia, serif);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ffd700;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    padding-bottom: 4px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-autosave-badge {
    font-size: 10px;
    font-family: var(--font-terminal, monospace);
    color: #4ade80;
    transition: opacity 0.3s ease;
}

/* Universal Narrating Active Guide */
.narrating-active {
    border-left: 3px solid #ffd700 !important;
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.18) 0%, rgba(212, 175, 55, 0.05) 100%) !important;
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.35), inset 0 0 10px rgba(212, 175, 55, 0.12) !important;
    border-radius: 4px;
    animation: narratingPulse 2.4s infinite ease-in-out;
}

/* Quick Model Preset Chips */
.model-preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.btn-model-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.25);
    color: #cbd5e1;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-model-chip:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: #ffd700;
    color: #ffd700;
}

.btn-model-chip.active {
    background: rgba(212, 175, 55, 0.25);
    border-color: #ffd700;
    color: #ffd700;
    font-weight: 600;
}

/* Security & Protection: Masked API Key Input (Blocks browser password manager popups) */
.masked-key-input {
    -webkit-text-security: disc !important;
    text-security: disc !important;
    font-family: monospace !important;
    letter-spacing: 2px;
}

/* Vocal State Indicators */
.chronicle-vocal-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-family: var(--font-terminal, monospace);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.25s ease-in-out;
}

.chronicle-vocal-pill.loading {
    background: rgba(212, 175, 55, 0.18);
    border: 1px solid rgba(255, 215, 0, 0.4);
    color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
}

.chronicle-vocal-pill.speaking {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: #6ee7b7;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.chronicle-vocal-pill.interrupted {
    background: rgba(245, 158, 11, 0.22);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fef3c7;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.35);
}

.voice-loading-spinner-micro {
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 1.5px solid rgba(255, 215, 0, 0.3);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: chronicleSpin 0.8s linear infinite;
}

/* 3-bar animated soundwave equalizer */
.voice-wave-anim {
    display: inline-flex;
    align-items: flex-end;
    gap: 2px;
    height: 10px;
}

.voice-wave-anim span {
    display: inline-block;
    width: 2px;
    background-color: #34d399;
    border-radius: 1px;
    animation: voiceWaveBar 1s infinite ease-in-out;
}

.voice-wave-anim span:nth-child(1) {
    height: 40%;
    animation-delay: 0s;
}

.voice-wave-anim span:nth-child(2) {
    height: 100%;
    animation-delay: 0.2s;
}

.voice-wave-anim span:nth-child(3) {
    height: 60%;
    animation-delay: 0.4s;
}

@keyframes voiceWaveBar {
    0%, 100% { height: 30%; }
    50% { height: 100%; }
}

/* Catch-Up Context Banner */
.catchup-context-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0.03) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-left: 3px solid #ffd700;
    border-radius: 4px;
    padding: 4px 8px;
    margin: 4px 0 8px 0;
    font-size: 11px;
    color: #e2e8f0;
}

.catchup-badge {
    background: rgba(212, 175, 55, 0.25);
    color: #ffd700;
    font-family: var(--font-terminal, monospace);
    font-size: 9.5px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.catchup-breakdown {
    font-style: italic;
    opacity: 0.9;
}

/* Interrupted Story Beat Indicators */
.flowing-paragraph-block.is-coalesced-into-epoch {
    display: none !important;
}

.flowing-paragraph-block.is-interrupted {
    border-left: 3px solid rgba(245, 158, 11, 0.7) !important;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.08) 0%, transparent 100%) !important;
}

.badge-interrupted {
    font-family: var(--font-terminal, monospace);
    font-size: 9px;
    font-weight: 700;
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: auto;
    margin-right: 6px;
    letter-spacing: 0.5px;
}

.dialogue-cut-short-note {
    margin-top: 4px;
    font-size: 10.5px;
    color: #fbbf24;
    opacity: 0.85;
    font-style: italic;
}

/* 3D HUD Toast */
.chronicle-hud-toast {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: #ffd700;
    font-family: var(--font-fantasy, Georgia, serif);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 8px rgba(212, 175, 55, 0.2);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chronicle-hud-toast.fade-out {
    opacity: 0;
    transform: translateY(-4px);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Non-Modal 3D Entity Inspection Popover (Zero Focus Stealing, Instant Light-Dismiss) */
.entity-inspect-popover {
    position: fixed;
    top: 80px;
    left: 80px;
    z-index: 48;
    width: min(350px, calc(100vw - 24px));
    max-width: 350px;
    max-height: calc(100vh - 76px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin: 0;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(16, 21, 32, 0.96) 0%, rgba(10, 14, 22, 0.96) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 175, 55, 0.55);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.85), 0 0 14px rgba(212, 175, 55, 0.14);
    color: #e2e8f0;
    pointer-events: auto;
    user-select: none;
    animation: toastSlideIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.entity-inspect-popover.hidden {
    display: none !important;
}

.inspect-popover-header {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 0;
}

.inspect-popover-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(212, 175, 55, 0.45);
    font-family: var(--font-terminal, monospace);
    font-size: 15px;
    font-weight: 700;
    color: #ffd700;
    flex-shrink: 0;
}

.inspect-popover-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.inspect-popover-name {
    font-family: var(--font-fantasy, 'Cinzel', Georgia, serif);
    font-size: 13px;
    font-weight: 700;
    color: #fef08a;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    line-height: 1.25;
}

.inspect-popover-pill {
    display: inline-flex;
    align-self: flex-start;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #7dd3fc;
    letter-spacing: 0.3px;
}

.inspect-popover-pill.hostile {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
}

.inspect-popover-pill.sleeping {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.4);
    color: #cbd5e1;
}

.inspect-popover-pill.item {
    background: rgba(212, 175, 55, 0.18);
    border-color: rgba(212, 175, 55, 0.45);
    color: #fde047;
}

.inspect-popover-close {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #94a3b8;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.inspect-popover-close:hover {
    color: #f8fafc;
    border-color: rgba(212, 175, 55, 0.6);
    background: rgba(255, 255, 255, 0.08);
}

.inspect-popover-hp-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-bottom: 2px;
}

.inspect-popover-hp-track {
    flex: 1 1 100%;
    min-width: 120px;
    height: 6px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.inspect-popover-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width 0.2s ease;
}

.inspect-popover-hp-text {
    flex: 1 1 100%;
    font-size: 11px;
    line-height: 1.35;
    font-family: var(--font-terminal, monospace);
    color: #cbd5e1;
    white-space: normal;
    word-break: break-word;
}

.inspect-popover-prose {
    display: block;
    font-size: 11.5px;
    line-height: 1.42;
    color: #e2e8f0;
    margin: 0 0 4px 0;
    white-space: normal;
    word-break: break-word;
}

.inspect-popover-quote {
    font-size: 11.5px;
    line-height: 1.38;
    font-style: italic;
    color: #fde68a;
    background: rgba(212, 175, 55, 0.09);
    border-left: 2px solid #d4af37;
    padding: 4px 8px;
    border-radius: 0 4px 4px 0;
    margin-bottom: 6px;
}

.inspect-popover-quote.hidden {
    display: none !important;
}

.inspect-popover-tactics {
    font-size: 11px;
    line-height: 1.35;
    color: #93c5fd;
    background: rgba(30, 58, 138, 0.22);
    border: 1px solid rgba(96, 165, 250, 0.25);
    padding: 4px 7px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.inspect-popover-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inspect-popover-btn {
    font-family: var(--font-ui, system-ui, sans-serif);
    font-size: 11.5px;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.inspect-popover-btn.primary {
    flex: 1;
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.26) 0%, rgba(161, 98, 7, 0.32) 100%);
    border: 1px solid rgba(212, 175, 55, 0.65);
    color: #fef08a;
}

.inspect-popover-btn.primary:hover {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.38) 0%, rgba(161, 98, 7, 0.45) 100%);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.25);
}

.inspect-popover-btn.secondary {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #cbd5e1;
}

.inspect-popover-btn.secondary:hover {
    border-color: rgba(212, 175, 55, 0.5);
    color: #f8fafc;
}

.inspect-popover-quote,
#inspect-popover-parley-btn,
#inspect-popover-vow-btn,
#inspect-popover-voice-btn {
    display: none !important;
}

.inspect-popover-tactics {
    display: none;
    font-size: 10.5px;
    line-height: 1.35;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.32);
    padding: 5px 7px;
    border-radius: 4px;
    margin: 0;
}

.inspect-popover-tactics.is-expanded {
    display: block;
}

.chronicle-context-ribbon {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 4px 0 6px 0;
}

.chronicle-context-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: #fde68a;
}

.chronicle-encounter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(212, 175, 55, 0.22);
}

.chronicle-enc-btn {
    font-family: var(--font-ui, system-ui, sans-serif);
    font-size: 10.5px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(30, 41, 59, 0.88);
    border: 1px solid rgba(212, 175, 55, 0.42);
    color: #fef08a;
    cursor: pointer;
    transition: all 0.14s ease;
}

.chronicle-enc-btn:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: #ffd700;
    color: #ffffff;
    color: #f8fafc;
}


