/* ==========================================================================
   DESIGN SYSTEM & CONSTANTS
   ========================================================================== */

:root {
    /* Color Palette - Dark Theme Defaults */
    --bg-main: #0b0f19;
    --bg-card: #151c2c;
    --bg-card-hover: #1e293b;
    --bg-input: #0f172a;
    --border-color: #334155;
    --border-highlight: #475569;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #10b981;
    --accent-hover: #059669;
    
    /* Highlight Category Colors */
    --color-sp: #8b5cf6;  /* Simple Present - Purple */
    --color-pc: #3b82f6;  /* Present Continuous - Blue */
    --color-st: #f97316;  /* Simple Past - Orange */
    --color-pt: #10b981;  /* Past Continuous - Emerald */
    --color-mv: #eab308;  /* Modal Verbs - Amber/Gold */
    --color-pv: #ec4899;  /* Phrasal Verbs - Pink */
    --color-dc: #06b6d4;  /* Collocations - Cyan */

    /* Typography & Sizing Defaults ("Not small letters" requirement) */
    --font-base: 'Plus Jakarta Sans', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-size-body: 19px;
    --line-height-body: 1.7;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides */
body.theme-light {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-input: #f8fafc;
    --border-color: #cbd5e1;
    --border-highlight: #94a3b8;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

/* Font Size Scale Classes */
body.font-size-small { --font-size-body: 16px; }
body.font-size-medium { --font-size-body: 19px; }
body.font-size-large { --font-size-body: 22px; }
body.font-size-xlarge { --font-size-body: 25px; }

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-base);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

h1 { font-size: 1.8rem; letter-spacing: 0.5px; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */

.main-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.35rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}

.header-container {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: #ffffff;
}

.brand h1 {
    font-size: 1.05rem;
    margin: 0;
    background: linear-gradient(90deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.brand-badge {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--primary);
    color: #818cf8;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    -webkit-text-fill-color: initial;
}

/* Integrated Header Nav Tabs */
.header-nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-tab {
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 0.35rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.nav-tab.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    font-weight: 700;
}

/* Global Actions: Font Adjuster & Theme Toggle */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.font-adjuster {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    gap: 2px;
}

.adjust-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 4px;
    display: flex;
    align-items: center;
}

.btn-font-size {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-font-size:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-font-size.active {
    background: var(--primary);
    color: #ffffff;
}

.btn-theme {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-theme:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ==========================================================================
   MAIN LAYOUT & STICKY CONTROL PANEL
   ========================================================================== */

.main-content {
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    flex: 1;
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* HIGHLIGHT CONTROL PANEL (Ultra Thin Sticky Top Bar) */
.control-panel-wrapper {
    position: sticky;
    top: 42px;
    z-index: 90;
    margin-bottom: 1rem;
}

.control-panel {
    background: var(--bg-card);
    border: 1.5px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.75rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15), var(--shadow-glow);
    backdrop-filter: blur(10px);
}

.panel-inline-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.toggle-buttons-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    flex: 1;
}

/* Custom Highlight Toggles (Ultra Thin) */
.hl-toggle {
    background: var(--bg-main);
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    padding: 2px 7px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    transition: var(--transition);
    user-select: none;
    line-height: 1.2;
}

.hl-toggle .toggle-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: var(--transition);
}

.hl-toggle .toggle-badge {
    background: var(--border-color);
    color: var(--text-primary);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 800;
}

.hl-toggle:hover {
    border-color: var(--hl-color);
    color: var(--text-primary);
}

.hl-toggle.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--hl-color);
    color: var(--text-primary);
}

.hl-toggle.active .toggle-indicator {
    background: var(--hl-color);
    box-shadow: 0 0 6px var(--hl-color);
}

.hl-toggle.active .toggle-badge {
    background: var(--hl-color);
    color: #ffffff;
}

.panel-quick-actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
}

.btn-action-sm {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action-sm:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ==========================================================================
   CARDS & SECTIONS
   ========================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.section-intro-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
}

.story-selector-container {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.custom-select {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    min-width: 300px;
    outline: none;
}

.custom-select:focus {
    box-shadow: var(--shadow-glow);
}

/* Passage Display & Legend Pills */
.passage-card {
    border-left: 6px solid var(--primary);
}

.passage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.legend-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.legend-pill {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    color: #ffffff;
    text-transform: uppercase;
}

.pill-sp { background: var(--color-sp); }
.pill-pc { background: var(--color-pc); }
.pill-st { background: var(--color-st); }
.pill-pt { background: var(--color-pt); }
.pill-mv { background: var(--color-mv); color: #000; }
.pill-pv { background: var(--color-pv); }
.pill-dc { background: var(--color-dc); color: #000; }

.passage-text {
    font-size: 1.15em;
    line-height: 1.9;
    color: var(--text-primary);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.passage-text p {
    margin-bottom: 1rem;
    color: inherit;
}

.passage-text p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   DYNAMIC HIGHLIGHT SPAN & SENTENCE STYLES
   ========================================================================== */

/* Sentence Highlighting Styles for Tenses (Simple Present, Present Continuous, Simple Past, Past Continuous) */
.hl-sentence {
    display: inline;
    padding: 3px 6px;
    border-radius: 6px;
    transition: var(--transition);
    position: relative;
    line-height: 2.1;
}

.hl-sentence.simple-present.active {
    background: rgba(139, 92, 246, 0.16);
    box-shadow: inset 3px 0 0 var(--color-sp);
}

.hl-sentence.present-cont.active {
    background: rgba(59, 130, 246, 0.16);
    box-shadow: inset 3px 0 0 var(--color-pc);
}

.hl-sentence.simple-past.active {
    background: rgba(249, 115, 22, 0.16);
    box-shadow: inset 3px 0 0 var(--color-st);
}

.hl-sentence.past-cont.active {
    background: rgba(16, 185, 129, 0.16);
    box-shadow: inset 3px 0 0 var(--color-pt);
}

/* Light Mode Overrides for Sentence Highlights */
body.theme-light .hl-sentence.simple-present.active { background: rgba(139, 92, 246, 0.12); }
body.theme-light .hl-sentence.present-cont.active { background: rgba(59, 130, 246, 0.12); }
body.theme-light .hl-sentence.simple-past.active { background: rgba(249, 115, 22, 0.12); }
body.theme-light .hl-sentence.past-cont.active { background: rgba(16, 185, 129, 0.12); }


/* Spans inside reading text when toggle is active (Modals, Phrasal Verbs, Collocations) */
.hl-span {
    padding: 2px 7px;
    border-radius: 5px;
    font-weight: 700;
    transition: var(--transition);
    display: inline-block;
    position: relative;
    margin: 0 1px;
    cursor: pointer;
}

.hl-span:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* Tooltip Badge on Highlight */
.hl-span::after {
    content: attr(data-tag);
    position: absolute;
    top: -12px;
    right: -4px;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    color: #fff;
    opacity: 0;
    transform: translateY(4px);
    transition: var(--transition);
    pointer-events: none;
    line-height: 1;
}

.hl-span:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* Active Highlight Styling by Class */
.hl-span.simple-present.active {
    background: rgba(139, 92, 246, 0.25);
    border-bottom: 2px solid var(--color-sp);
    color: #ddd6fe;
}
.hl-span.simple-present.active::after { background: var(--color-sp); }

.hl-span.present-cont.active {
    background: rgba(59, 130, 246, 0.25);
    border-bottom: 2px solid var(--color-pc);
    color: #bfdbfe;
}
.hl-span.present-cont.active::after { background: var(--color-pc); }

.hl-span.simple-past.active {
    background: rgba(249, 115, 22, 0.25);
    border-bottom: 2px solid var(--color-st);
    color: #ffedd5;
}
.hl-span.simple-past.active::after { background: var(--color-st); }

.hl-span.past-cont.active {
    background: rgba(16, 185, 129, 0.25);
    border-bottom: 2px solid var(--color-pt);
    color: #a7f3d0;
}
.hl-span.past-cont.active::after { background: var(--color-pt); }

.hl-span.modal-verb.active {
    background: rgba(234, 179, 8, 0.3);
    border-bottom: 2px solid var(--color-mv);
    color: #fef08a;
}
.hl-span.modal-verb.active::after { background: var(--color-mv); color: #000; }

.hl-span.phrasal-verb.active {
    background: rgba(236, 72, 153, 0.25);
    border-bottom: 2px solid var(--color-pv);
    color: #fbcfe8;
}
.hl-span.phrasal-verb.active::after { background: var(--color-pv); }

.hl-span.collocation.active {
    background: rgba(6, 182, 212, 0.25);
    border-bottom: 2px solid var(--color-dc);
    color: #cffafe;
}
.hl-span.collocation.active::after { background: var(--color-dc); color: #000; }

/* Light mode span contrast overrides */
body.theme-light .hl-span.simple-present.active { background: #ede9fe; color: #5b21b6; }
body.theme-light .hl-span.present-cont.active { background: #dbeafe; color: #1e40af; }
body.theme-light .hl-span.simple-past.active { background: #ffedd5; color: #9a3412; }
body.theme-light .hl-span.past-cont.active { background: #d1fae5; color: #065f46; }
body.theme-light .hl-span.modal-verb.active { background: #fef9c3; color: #854d0e; }
body.theme-light .hl-span.phrasal-verb.active { background: #fce7f3; color: #9d174d; }
body.theme-light .hl-span.collocation.active { background: #cffafe; color: #155e75; }

/* Inline Guide Spans */
.hl-simple-present.active { background: rgba(139, 92, 246, 0.25); border-bottom: 2px solid var(--color-sp); color: #ddd6fe; padding: 2px 6px; border-radius: 4px; }
.hl-present-cont.active { background: rgba(59, 130, 246, 0.25); border-bottom: 2px solid var(--color-pc); color: #bfdbfe; padding: 2px 6px; border-radius: 4px; }
.hl-simple-past.active { background: rgba(249, 115, 22, 0.25); border-bottom: 2px solid var(--color-st); color: #ffedd5; padding: 2px 6px; border-radius: 4px; }
.hl-past-cont.active { background: rgba(16, 185, 129, 0.25); border-bottom: 2px solid var(--color-pt); color: #a7f3d0; padding: 2px 6px; border-radius: 4px; }
.hl-modal.active { background: rgba(234, 179, 8, 0.3); border-bottom: 2px solid var(--color-mv); color: #fef08a; padding: 2px 6px; border-radius: 4px; }
.hl-phrasal.active { background: rgba(236, 72, 153, 0.25); border-bottom: 2px solid var(--color-pv); color: #fbcfe8; padding: 2px 6px; border-radius: 4px; }
.hl-collocation.active { background: rgba(6, 182, 212, 0.25); border-bottom: 2px solid var(--color-dc); color: #cffafe; padding: 2px 6px; border-radius: 4px; }

/* Modal Overlay & Popover Card */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 15, 25, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), var(--shadow-glow);
    position: relative;
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.9) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
}

.modal-close-btn:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.modal-badge-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.modal-tag-badge {
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
}

.modal-category-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-term-title {
    font-size: 1.6rem;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    font-weight: 800;
    text-transform: capitalize;
}

.modal-body-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-info-block {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.info-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-translation {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.info-example {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.6;
}

/* Floating Audio Control Bar */
.floating-audio-bar {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 990;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 0.6rem 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), var(--shadow-glow);
    backdrop-filter: blur(12px);
    transition: var(--transition);
}

.floating-audio-bar:hover {
    border-color: #818cf8;
}

.audio-bar-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.audio-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-icon {
    font-size: 1.2rem;
    color: var(--primary);
    animation: audioPulse 2s infinite ease-in-out;
}

@keyframes audioPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}

.audio-text-group {
    display: flex;
    flex-direction: column;
}

.audio-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.5px;
    line-height: 1;
}

.audio-status-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-audio-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-audio-btn.btn-play {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-audio-btn.btn-play:hover {
    background: var(--primary-hover);
}

.btn-audio-btn.btn-stop {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.btn-audio-btn.btn-stop:hover {
    background: #dc2626;
}

.audio-speed-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.speed-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
}

/* Speaker Icon on Sentences */
.btn-sentence-audio {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary);
    cursor: pointer;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    transition: var(--transition);
    vertical-align: middle;
}

.btn-sentence-audio:hover {
    background: var(--primary);
    color: #ffffff;
    transform: scale(1.1);
}

/* Speaking Active Highlight Animation */
.hl-sentence.speaking-active {
    outline: 2px solid var(--primary);
    background: rgba(99, 102, 241, 0.28) !important;
    animation: glowSpeaking 1.5s infinite alternate;
}

@keyframes glowSpeaking {
    from { box-shadow: 0 0 5px rgba(99, 102, 241, 0.4); }
    to { box-shadow: 0 0 15px rgba(99, 102, 241, 0.8); }
}


/* ==========================================================================
   EXERCISES & QUESTIONS STYLES
   ========================================================================== */

.exercise-card {
    border: 1px solid var(--border-color);
}

.exercise-header {
    margin-bottom: 1.5rem;
    position: relative;
}

.exercise-badge {
    display: inline-block;
    background: var(--primary);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.badge-accent {
    background: var(--accent);
}

.questions-list, .reader-questions-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.q-item {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: var(--transition);
}

.q-item:hover {
    border-color: var(--border-highlight);
}

.q-text {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.85rem;
    font-size: 1.05em;
}

.q-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.option-label {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95em;
}

.option-label:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.option-label input[type="radio"] {
    margin-right: 12px;
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

/* User Text Answer Inputs ("Questions for You") */
.reader-q-item {
    background: var(--bg-main);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.reader-input-group {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.text-input-lg {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 1em;
    outline: none;
    transition: var(--transition);
}

.text-input-lg:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.hint-chip {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

/* Feedback Styling */
.q-feedback {
    margin-top: 0.85rem;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    display: none;
}

.q-feedback.correct {
    display: block;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--accent);
    color: #34d399;
}

.q-feedback.incorrect {
    display: block;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #f87171;
}

body.theme-light .q-feedback.correct { color: #065f46; }
body.theme-light .q-feedback.incorrect { color: #991b1b; }

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-accent {
    background: var(--accent);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-accent:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ==========================================================================
   QUIZ & EVALUATION MODULE STYLES
   ========================================================================== */

.quiz-status-bar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
}

.badge-score-live {
    background: var(--primary);
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.progress-bar-track {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    height: 100%;
    transition: width 0.3s ease;
}

.quiz-part-card {
    position: relative;
    border-top: 4px solid var(--primary);
}

.part-badge {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.85rem;
}

.quiz-questions-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.quiz-submit-container {
    text-align: center;
    margin: 2rem 0;
}

.btn-submit-large {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    border: none;
    padding: 18px 36px;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
    letter-spacing: 0.5px;
}

.btn-submit-large:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.5);
}

/* ==========================================================================
   DIAGNOSTIC RESULT REPORT CARD
   ========================================================================== */

.result-card {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.2);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.result-icon {
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.score-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.score-box {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.score-box.main-score {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(99, 102, 241, 0.1));
}

.score-number {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.score-box.main-score .score-number {
    color: var(--accent);
}

.score-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Category Breakdown Progress Bars */
.category-breakdown {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.75rem;
}

.category-breakdown h3 {
    margin-bottom: 1rem;
}

.cat-bar-group {
    margin-bottom: 1rem;
}

.cat-bar-group:last-child {
    margin-bottom: 0;
}

.cat-info {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.cat-track {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.cat-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.fill-purple { background: var(--color-sp); }
.fill-green { background: var(--color-pt); }
.fill-yellow { background: var(--color-mv); }
.fill-pink { background: var(--color-pv); }

.feedback-details-box {
    margin-bottom: 1.5rem;
}

.explanations-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1rem;
}

.exp-item {
    background: var(--bg-main);
    border-left: 4px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.95em;
}

.exp-item.correct { border-left-color: var(--accent); }
.exp-item.incorrect { border-left-color: #ef4444; }

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ==========================================================================
   STUDY GUIDE & REFERENCE TABLES
   ========================================================================== */

.guide-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.guide-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.sp-header h3 { color: var(--color-sp); }
.st-header h3 { color: var(--color-st); }
.mv-header h3 { color: var(--color-mv); }
.pv-header h3 { color: var(--color-pv); }

.guide-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.guide-table th, .guide-table td {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.guide-table th {
    background: var(--bg-main);
    font-weight: 700;
    color: var(--text-primary);
}

.guide-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.guide-list li {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
}

.vocab-two-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.vocab-two-cols h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* Universal Audio Speaker Button for Questions & Topics */
.btn-item-audio {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary);
    cursor: pointer;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.82rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.btn-item-audio:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    transform: scale(1.1);
}

.guide-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.modal-guide-grid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-guide-item {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border-left: 4px solid var(--color-mv);
}

.modal-guide-item h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-guide-item p {
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.example-line {
    color: var(--text-primary);
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-color);
}

/* ==========================================================================
   FOOTER & UTILITIES
   ========================================================================== */

.main-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 3rem;
}

.hidden {
    display: none !important;
}

/* High Definition Printable PDF Styles */
@media print {
    /* Hide non-printable web UI elements */
    .main-header, 
    .control-panel-wrapper, 
    .floating-audio-bar, 
    .modal-overlay, 
    .header-actions, 
    .header-nav-tabs, 
    .btn-primary, 
    .btn-secondary, 
    .btn-action-sm,
    .btn-item-audio, 
    .btn-sentence-audio,
    .main-footer,
    .story-selector-container,
    .hint-chip {
        display: none !important;
    }

    html, body {
        background: #ffffff !important;
        color: #0f172a !important;
        font-family: 'Plus Jakarta Sans', Arial, sans-serif !important;
        font-size: 11pt !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .main-content {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0.2in !important;
    }

    /* Force Study Guide tab to display in print mode */
    .tab-content#guide-section {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Hide other tabs during Study Guide PDF print */
    .tab-content#reading-section, 
    .tab-content#quiz-section {
        display: none !important;
    }

    .section-intro-card, .card, .guide-card {
        background: #ffffff !important;
        color: #0f172a !important;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 8px !important;
        box-shadow: none !important;
        padding: 1rem 1.25rem !important;
        margin-bottom: 1.25rem !important;
        page-break-inside: avoid;
    }

    .section-intro-card h2, .guide-card-header h3 {
        color: #0f172a !important;
        -webkit-text-fill-color: initial !important;
    }

    .guide-card-header {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        border-bottom: 2px solid #94a3b8 !important;
        padding: 0.5rem 0.75rem !important;
        border-radius: 6px 6px 0 0 !important;
    }

    .guide-table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 0.5rem 0 !important;
    }

    .guide-table th, .guide-table td {
        border: 1px solid #cbd5e1 !important;
        padding: 8px 10px !important;
        color: #0f172a !important;
        background: #ffffff !important;
        text-align: left !important;
    }

    .guide-table th {
        background: #e2e8f0 !important;
        font-weight: 700 !important;
        color: #0f172a !important;
    }

    .guide-list li, .modal-guide-item {
        background: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
        color: #0f172a !important;
        padding: 8px 12px !important;
        margin-bottom: 6px !important;
        page-break-inside: avoid;
    }

    .hl-span, .hl-sentence, .hl-modal, .hl-phrasal, .hl-collocation {
        background: #f1f5f9 !important;
        border-bottom: 2px solid #475569 !important;
        color: #0f172a !important;
        font-weight: 700 !important;
        padding: 1px 4px !important;
        border-radius: 3px !important;
    }

    .example-line {
        background: #ffffff !important;
        border: 1px dashed #94a3b8 !important;
        color: #334155 !important;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header-container { flex-direction: column; align-items: flex-start; }
    .control-panel-wrapper { top: 60px; }
    .nav-tab { padding: 0.75rem 1rem; font-size: 0.9rem; }
    .toggle-buttons-grid { gap: 0.4rem; }
    .hl-toggle { font-size: 0.85rem; padding: 4px 8px; }
    .floating-audio-bar { bottom: 12px; right: 12px; left: 12px; }
}
