/* =========================================================
   UNIVERSAL MATERIAL DESIGN 3 (M3) STYLESHEET
   ========================================================= */

:root {
    /* M3 Color System - Baseline Tones */
    --md-sys-color-primary: #6750a4;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #eaddff;
    --md-sys-color-on-primary-container: #21005d;

    --md-sys-color-secondary: #625b71;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e8def8;
    --md-sys-color-on-secondary-container: #1d192b;

    --md-sys-color-tertiary: #7d5260;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #ffd8e4;
    --md-sys-color-on-tertiary-container: #31111d;

    --md-sys-color-surface: #fef7ff;
    --md-sys-color-on-surface: #1d1b20;
    --md-sys-color-surface-variant: #e7e0ec;
    --md-sys-color-on-surface-variant: #49454f;

    --md-sys-color-surface-container-lowest: #ffffff;
    --md-sys-color-surface-container-low: #f7f2fa;
    --md-sys-color-surface-container: #f3edf7;
    --md-sys-color-surface-container-high: #ece6f0;
    --md-sys-color-surface-container-highest: #e6e0e9;

    --md-sys-color-outline: #79747e;
    --md-sys-color-outline-variant: #caccd6;

    /* M3 Validation Feedback */
    --md-sys-color-success: #198754;
    --md-sys-color-success-container: #d1e7dd;
    --md-sys-color-on-success-container: #0f5132;
    --md-sys-color-error: #b3261e;
    --md-sys-color-error-container: #f9dedc;
    --md-sys-color-on-error-container: #410e0b;

    /* Legacy Token Aliases for Backward Compatibility */
    --primary-color: var(--md-sys-color-primary);
    --primary-light: var(--md-sys-color-surface-container-low);
    --text-main: var(--md-sys-color-on-surface);
    --text-muted: var(--md-sys-color-on-surface-variant);
    --bg-main: #f4f5fa;
    --bg-card: var(--md-sys-color-surface-container-lowest);
    --border-color: var(--md-sys-color-outline-variant);

    --correct-green: var(--md-sys-color-success);
    --correct-bg: var(--md-sys-color-success-container);
    --incorrect-red: var(--md-sys-color-error);
    --incorrect-bg: var(--md-sys-color-error-container);
    --test-accent: var(--md-sys-color-primary);

    --workbook-orange: #f39c12;
    --workbook-orange-dark: #d35400;

    /* M3 Shape Tokens */
    --md-shape-xs: 4px;
    --md-shape-sm: 8px;
    --md-shape-md: 12px;
    --md-shape-lg: 16px;
    --md-shape-xl: 28px;
    --md-shape-full: 9999px;

    /* M3 Elevation Shadows */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.12);
    --md-sys-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.08), 0px 1px 2px 0px rgba(0, 0, 0, 0.12);
    --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.08), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
}

/* =========================================
   BASE STYLES & ACCESSIBILITY
   ========================================= */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    min-height: 100vh;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Roboto', 'Segoe UI', sans-serif;
    background-color: var(--bg-main);
    color: var(--md-sys-color-on-surface);
    font-size: 16px;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
    border-radius: var(--md-shape-md);
}

.clickable-image {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clickable-image:hover {
    transform: scale(1.01);
    box-shadow: var(--md-sys-elevation-2);
}

/* =========================================
   PREVIEW FRAME TOGGLE BAR
   ========================================= */
.preview-toggle-bar {
    background: #1e1b2e;
    color: #ffffff;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
}

.preview-toggle-bar button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    padding: 4px 12px;
    border-radius: var(--md-shape-full);
    cursor: pointer;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mobile-preview-active .book-container,
.mobile-preview-active .course-map-container,
.mobile-preview-active .portal-card-container {
    max-width: 375px !important;
    margin: 20px auto;
    border: 8px solid #333;
    border-radius: 36px;
    box-shadow: var(--md-sys-elevation-3);
    overflow: hidden;
}

/* =========================================
   UNIFIED CONTAINER & PAGE CARDS
   ========================================= */
.book-container,
.course-map-container,
.portal-card-container {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 120px;
    box-sizing: border-box;
}

.book-page,
.card-frame {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-shape-xl);
    padding: 20px;
    box-shadow: var(--md-sys-elevation-1);
    margin-bottom: 24px;
    border: 1px solid var(--md-sys-color-surface-container-high);
}

@media (min-width: 768px) {
    .book-container,
    .course-map-container,
    .portal-card-container { 
        padding: 32px 16px 120px 16px; 
    }
    .book-page,
    .card-frame { 
        padding: 32px; 
        margin-bottom: 32px; 
    }
}

/* =========================================
   PORTAL GRID & BANNER STYLES
   ========================================= */
.portal-grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .portal-grid-layout {
        grid-template-columns: 1.4fr 1fr;
    }
}

.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.section-header-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

.live-session-banner {
    background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, #4f378b 100%);
    color: var(--md-sys-color-on-primary);
    border-radius: var(--md-shape-lg);
    padding: 20px;
    box-shadow: var(--md-sys-elevation-2);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.live-session-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.live-session-info {
    font-size: 0.9rem;
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 14px;
    border-radius: var(--md-shape-md);
}

.live-session-info hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 8px 0;
}

.btn-classroom {
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-primary);
    border-radius: var(--md-shape-full);
    font-weight: 700;
    padding: 10px 16px;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-classroom:hover {
    box-shadow: var(--md-sys-elevation-2);
    opacity: 0.95;
}

/* =========================================
   TOP APP BAR & PROFILE DROPDOWN
   ========================================= */
.top-app-bar,
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    margin-bottom: 24px;
}

.badge-chip {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 4px 12px;
    border-radius: var(--md-shape-full);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-chip-error {
    background: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.page-title {
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    font-weight: 800;
    margin: 6px 0 0 0;
    line-height: 1.25;
}

.user-meta {
    position: relative;
    cursor: pointer;
}

.avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--md-sys-color-primary);
}

#userDropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1000;
    min-width: 200px;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: var(--md-shape-lg);
    padding: 8px;
    box-shadow: var(--md-sys-elevation-2);
    border: 1px solid var(--md-sys-color-outline-variant);
    flex-direction: column;
    gap: 4px;
}

#userDropdown.show, #userDropdown[style*="display: flex"] {
    display: flex !important;
}

#userDropdown a, #userDropdown button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--md-shape-md);
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
    font-weight: 600;
    font-size: 0.88rem;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

#userDropdown a:hover, #userDropdown button:hover {
    background: var(--md-sys-color-surface-container-high);
}

.active-dropdown-link {
    background: var(--md-sys-color-primary-container) !important;
    color: var(--md-sys-color-on-primary-container) !important;
}

.logout-action-btn {
    color: var(--md-sys-color-error) !important;
}

/* =========================================
   M3 CALLOUTS & GRAMMAR SECTIONS
   ========================================= */
.m3-callout {
    border-radius: var(--md-shape-lg);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--md-sys-elevation-0);
}

.m3-callout-indigo {
    background: #f0f3ff;
    border-left: 4px solid #4338ca;
    color: #1e1b4b;
}

.m3-callout-teal {
    background: #e6f4f1;
    border-left: 4px solid #0d9488;
    color: #042f2e;
}

.m3-callout-amber {
    background: #fefce8;
    border-left: 4px solid #d97706;
    color: #451a03;
}

.m3-callout-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

/* =========================================
   EXERCISE CARDS & CONTENT BLOCKS
   ========================================= */
.exercise, .content {
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-shape-lg);
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--md-sys-color-surface-container-high);
}

@media (min-width: 768px) {
    .exercise, .content { padding: 24px; }
}

.exercise-title, .content-title {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-title > span, .content-title > span {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.exercise-badge {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-radius: var(--md-shape-sm);
    padding: 2px 8px;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* =========================================
   M3 ASSIST CHIPS & BUTTONS
   ========================================= */
.m3-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.m3-assist-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: var(--md-shape-full);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.m3-assist-chip:hover {
    background: var(--md-sys-color-surface-container-high);
    box-shadow: var(--md-sys-elevation-1);
}

.audio-chip {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}

.video-chip {
    background: #ffe4e6;
    color: #e11d48;
    border-color: #fecdd3;
}

.vocab-chip {
    background: #fef9c3;
    color: #a16207;
    border-color: #fef08a;
}

/* Base Buttons */
.btn, .btn-login-submit, .btn-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: var(--md-shape-full);
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-filled, .btn-login-submit {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.btn-filled:hover, .btn-login-submit:hover {
    box-shadow: var(--md-sys-elevation-1);
    opacity: 0.95;
}

.btn-tonal, .btn-social {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-tonal:hover, .btn-social:hover {
    background: var(--md-sys-color-surface-container-highest);
}

.btn-workbook {
    background: var(--workbook-orange);
    color: #ffffff;
}

.btn-workbook:hover {
    background: var(--workbook-orange-dark);
}

.btn-bundle {
    background: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
}

.btn-bundle:hover {
    background: #603a49;
}

.btn-compact {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* Translation Reveal */
.translate-toggle-btn {
    background: transparent;
    border: none;
    color: var(--md-sys-color-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.translation-reveal {
    display: none;
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    padding: 12px 16px;
    border-radius: var(--md-shape-md);
    font-style: italic;
    font-size: 0.9rem;
    margin-top: 8px;
}

.translation-reveal.show {
    display: block;
}

/* =========================================
   FORM INPUTS & SELECTS
   ========================================= */
.question-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}

.question-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-shape-md);
    border: 1px solid var(--md-sys-color-surface-container-high);
}

@media (min-width: 768px) {
    .question-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.answer-select, .answer-input, .answer-textarea {
    width: 100%;
    min-height: 44px;
    padding: 8px 16px;
    border-radius: var(--md-shape-sm);
    border: 1px solid var(--md-sys-color-outline);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    font-size: 0.95rem;
    font-weight: 600;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 768px) {
    .answer-select.inline-auto {
        width: auto;
        min-width: 180px;
    }
}

.answer-select:focus, .answer-input:focus, .answer-textarea:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.answer-select.correct, .answer-input.correct {
    border-color: var(--md-sys-color-success);
    background-color: var(--md-sys-color-success-container);
    color: var(--md-sys-color-on-success-container);
}

.answer-select.incorrect, .answer-input.incorrect {
    border-color: var(--md-sys-color-error);
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.input-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-field-label {
    font-size: 0.8rem;
    font-weight: 700;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.search-input-icon {
    position: absolute;
    left: 12px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1.2rem;
    pointer-events: none;
}

.search-input-field {
    padding-left: 40px !important;
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 8px;
    border-radius: var(--md-shape-sm);
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--md-sys-color-primary);
}

/* Action Buttons Group */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.check-answers-btn {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 10px 20px;
    border-radius: var(--md-shape-full);
    font-weight: 700;
    cursor: pointer;
}

.reset-answers-btn {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    border: none;
    padding: 10px 20px;
    border-radius: var(--md-shape-full);
    font-weight: 700;
    cursor: pointer;
}

/* =========================================
   INTERACTIVE CHIP EXERCISE
   ========================================= */
.chip-pool-container {
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px dashed var(--md-sys-color-outline);
    border-radius: var(--md-shape-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.chip-pool-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
}

.chip-pool, .interactive-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-shape-md);
    margin-bottom: 16px;
}

.activity-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-shape-full);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
}

.activity-chip.assigned {
    opacity: 0.4;
    text-decoration: line-through;
    cursor: not-allowed;
}

.photo-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.photo-card {
    background: var(--md-sys-color-surface-container-lowest);
    border: 2px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-lg);
    padding: 16px;
    cursor: pointer;
}

.photo-card.active-target {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.assigned-chips-area {
    min-height: 48px;
    background: var(--md-sys-color-surface-container-low);
    border: 1px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-md);
    padding: 8px;
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.assigned-chip {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 4px 12px;
    border-radius: var(--md-shape-full);
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.assigned-chip .remove-icon {
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.chip-feedback {
    margin-top: 12px;
    font-weight: 700;
}

.chip-feedback.success { color: var(--md-sys-color-success); }
.chip-feedback.error { color: var(--md-sys-color-error); }

/* =========================================
   COURSE MAP & TAB SWITCHER COMPONENTS
   ========================================= */
.tab-switcher {
    display: flex;
    gap: 8px;
    background: var(--md-sys-color-surface-container-high);
    padding: 6px;
    border-radius: var(--md-shape-full);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--md-shape-full);
    border: none;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.order-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-stack[hidden] {
    display: none !important;
}

.item-card-row, .chapter-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 18px;
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-surface-container-high);
    border-radius: var(--md-shape-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 600px) {
    .item-card-row, .chapter-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.item-card-row:hover, .chapter-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--md-sys-elevation-1);
}

.item-card-content, .chapter-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chapter-num-badge, .chapter-badge {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.chapter-badge.badge-workbook {
    background: #fef3c7;
    color: var(--workbook-orange-dark);
}

.chapter-badge.badge-bundle {
    background: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
}

.item-card-text, .chapter-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chapter-type, .badge-type {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-coursebook, .badge-coursebook { color: var(--md-sys-color-primary); }
.type-workbook, .badge-workbook { color: var(--workbook-orange-dark); }

.chapter-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--md-sys-color-on-surface);
}

.item-card-actions, .chapter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-separator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
    margin: 16px 0 8px 0;
}

/* =========================================
   FLOATING ELEVATED M3 BOTTOM DOCK
   ========================================= */
.sticky-footer-container, .portal-footer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    pointer-events: none;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    box-sizing: border-box;
}

.footer-nav-bar, .portal-footer-nav {
    max-width: 600px;
    margin: 0 auto;
    background: var(--md-sys-color-surface-container-highest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-full);
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    box-shadow: var(--md-sys-elevation-3);
    pointer-events: auto;
}

.footer-nav-bar .btn, .portal-footer-nav .btn-social {
    flex: 1;
    padding: 8px 16px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.footer-dock-single {
    justify-content: center;
}

.dock-btn-full {
    max-width: 280px;
    width: 100%;
}

/* =========================================
   MODALS & DIALOGS
   ========================================= */
.dialog-modal {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-xl);
    padding: 24px;
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-sys-elevation-3);
    max-width: 520px;
    width: 90%;
    margin: auto;
}

.dialog-modal-scrollable {
    max-height: 85vh;
    overflow-y: auto;
}

.dialog-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.dialog-modal-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--md-sys-color-on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dialog-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.video-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.video-modal-backdrop.is-visible {
    display: flex;
}

.video-modal-content {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-shape-xl);
    padding: 24px;
    width: 90%;
    max-width: 650px;
    position: relative;
    box-shadow: var(--md-sys-elevation-3);
}

.video-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
}

.modal-content-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 380px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.page-tag {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 16px;
    font-weight: 600;
}

/* =========================================================
   WORKBOOK SPECIFIC COLOR SCHEME (THEME OVERRIDES)
   ========================================================= */
:root {
    --md-sys-color-workbook-primary: #855300;
    --md-sys-color-workbook-on-primary: #ffffff;
    --md-sys-color-workbook-primary-container: #ffddb8;
    --md-sys-color-workbook-on-primary-container: #2a1700;
    
    --md-sys-color-workbook-secondary: #705b41;
    --md-sys-color-workbook-secondary-container: #fce7cf;
    --md-sys-color-workbook-on-secondary-container: #281805;
}

body.workbook-theme {
    --md-sys-color-primary: var(--md-sys-color-workbook-primary);
    --md-sys-color-on-primary: var(--md-sys-color-workbook-on-primary);
    --md-sys-color-primary-container: var(--md-sys-color-workbook-primary-container);
    --md-sys-color-on-primary-container: var(--md-sys-color-workbook-on-primary-container);

    --md-sys-color-secondary-container: var(--md-sys-color-workbook-secondary-container);
    --md-sys-color-on-secondary-container: var(--md-sys-color-workbook-on-secondary-container);
}

body.workbook-theme .badge-chip {
    background: var(--md-sys-color-workbook-primary-container);
    color: var(--md-sys-color-workbook-on-primary-container);
    border: 1px solid var(--md-sys-color-workbook-primary);
}

body.workbook-theme .exercise-badge {
    background: var(--md-sys-color-workbook-primary);
    color: var(--md-sys-color-workbook-on-primary);
}