/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    /* Color Palette */
    --bg-primary: #0b0f19;
    --bg-secondary: #0f172a;
    --bg-card: #182030;
    --bg-card-hover: #222b3d;
    --border-color: #2b3548;
    --border-color-hover: #38bdf8;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-accent: #38bdf8;
    
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    
    --success-color: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --error-color: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning-color: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Box Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
    
    /* Layout */
    --sidebar-width: 280px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
    height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Utility Classes */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.badge-secondary {
    background: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
    border: 1px solid rgba(6, 182, 212, 0.3);
}
.topic-badge-selector {
    position: relative;
    z-index: 1010 !important; /* Forces dropdown above search-box and relative siblings */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    background: var(--primary-gradient);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: white !important;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: var(--shadow-glow);
    transition: all var(--transition-fast) ease;
}
.topic-badge-selector:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.45);
    border-color: rgba(255, 255, 255, 0.35);
}
.topic-badge-selector i.arrow-icon {
    margin-left: 8px;
    font-size: 10px;
    transition: transform var(--transition-fast);
}
.topic-badge-selector:hover i.arrow-icon {
    transform: translateY(2px);
}
/* Solid Dropdown Menu Container (No transparency, High contrast) */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 280px;
    background: #0f172a !important; /* Solid dark slate, completely opaque */
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.2);
    padding: 6px 0;
    z-index: 2000;
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.custom-dropdown-menu.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
/* Individual Dropdown Item Buttons (Brighter, bolder, more legible) */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 18px;
    background: none;
    border: none;
    color: #f1f5f9 !important; /* Bright off-white */
    font-size: 13.5px;
    font-weight: 600; /* Bold text for clarity */
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.dropdown-item:hover {
    background: rgba(99, 102, 241, 0.2) !important;
    color: white !important;
}
.dropdown-item.active {
    background: rgba(99, 102, 241, 0.3) !important;
    color: #a5b4fc !important;
    font-weight: 700;
}
.dropdown-item .item-emoji {
    font-size: 14px;
}
.dropdown-item .check-icon {
    margin-left: auto;
    color: var(--primary-color);
    font-size: 11px;
}
.badge-pos {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.2);
    font-size: 10px;
    padding: 2px 6px;
}

.text-success { color: var(--success-color); }
.text-error { color: var(--error-color); }
.text-warning { color: var(--warning-color); }
.text-primary { color: var(--primary-color); }

.hidden {
    display: none !important;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    background-color: #080c14;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 40px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    box-shadow: var(--shadow-glow);
}

.logo-text h1 {
    font-size: 18px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Topic Selector in Sidebar - Hidden in favor of premium header badge button */
.topic-selector-card {
    display: none !important;
}

.topic-lbl {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.topic-lbl i {
    margin-right: 4px;
    color: var(--primary-color);
}

.select-dropdown-container {
    position: relative;
    width: 100%;
}

.topic-dropdown {
    width: 100%;
    padding: 10px 32px 10px 14px;
    background-color: rgba(15, 23, 42, 0.7);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
}

.topic-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.25);
    background-color: rgba(15, 23, 42, 0.95);
}

.select-dropdown-container::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 10px;
    pointer-events: none;
}

.topic-dropdown option {
    background-color: #1e293b;
    color: white;
    padding: 12px;
}

/* Nav Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: auto;
}

.nav-item {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: white;
    background: var(--primary-gradient);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    font-weight: 600;
}

/* Progress Widget */
.progress-widget {
    margin-top: 30px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.progress-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.progress-percentage {
    font-size: 14px;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-accent);
}

.progress-bar-container {
    height: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 3px;
    transition: width var(--transition-slow);
}

.progress-details {
    font-size: 11px;
    color: var(--text-muted);
}

/* Main Content Styling */
.main-content {
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Utility Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title h2 {
    font-size: 20px;
    font-weight: 700;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    position: relative;
    width: 260px;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.search-box input {
    width: 100%;
    background-color: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 10px 16px 10px 38px;
    color: white;
    font-family: var(--font-body);
    font-size: 13.5px;
    outline: none;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background-color: rgba(30, 41, 59, 0.9);
}

.action-btn {
    background-color: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: var(--transition-fast);
}

.action-btn:hover {
    background-color: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-color);
    color: var(--text-accent);
}

/* ==========================================================================
   DYNAMIC CONTENT PANELS
   ========================================================================== */
.content-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px;
}

.content-panel.active {
    display: flex;
    flex-direction: column;
}

/* Filter Controls */
.filter-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    background: #121926;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    width: 100px;
    flex-shrink: 0;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    flex: 1;
}

.filter-btn {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 9999px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.filter-btn.active {
    background: var(--text-accent);
    color: var(--bg-primary);
    border-color: var(--text-accent);
    font-weight: 600;
}

/* ==========================================================================
   VOCABULARY DECK / GRID
   ========================================================================== */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    padding-bottom: 40px;
}

.vocab-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.vocab-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Star Importance Marker on Top Right */
.card-stars {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 11px;
    color: var(--warning-color);
}

.vocab-card-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.word-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-word {
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.word-pronounce-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
}

.card-ipa {
    color: var(--text-accent);
    font-style: italic;
    font-weight: 500;
}

/* Card image styling */
.card-image-wrapper {
    width: 100%;
    height: auto; /* Dynamic height based on aspect ratio */
    background-color: #ffffff;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-image {
    width: 100%;
    height: auto; /* Scaled height */
    display: block;
    object-fit: contain; /* Fills full horizontal width without cropping */
    transition: transform var(--transition-normal) ease;
}

.vocab-card:hover .card-image {
    transform: scale(1.05);
}

/* Flashcard image styling */
.flashcard-image-wrapper {
    width: calc(100% + 60px) !important; /* Break out of 30px card face padding to match card width */
    margin-left: -30px !important;
    margin-right: -30px !important;
    max-width: none !important;
    height: auto; /* Dynamic height to scale as a perfect square */
    flex-shrink: 0 !important; /* Prevents flexbox layout from squishing image height */
    background-color: #ffffff;
    border-radius: 0; /* Straight edge-to-edge borders */
    overflow: hidden;
    margin-top: 10px !important;
    margin-bottom: 20px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-left: none;
    border-right: none;
}

.flashcard-image {
    width: 100%;
    height: auto; /* Scale height naturally to fill the width */
    display: block;
    object-fit: contain; /* Prevent cropping */
}

.vocab-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-translation {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}

.card-explanation {
    font-size: 13.5px;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.3);
    border-radius: var(--border-radius-sm);
    padding: 8px 12px;
    border-left: 2.5px solid var(--primary-color);
}

.card-examples-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.example-item {
    font-size: 13px;
    line-height: 1.4;
    padding-left: 8px;
    border-left: 1.5px dashed rgba(255, 255, 255, 0.15);
}

.example-eng {
    color: #e2e8f0;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.example-eng:hover {
    color: var(--text-accent);
}

.example-eng i {
    font-size: 10px;
    opacity: 0.6;
}

.example-vie {
    color: var(--text-muted);
    font-style: italic;
}

/* Card Action Footer */
.card-footer {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.card-btn {
    flex: 1;
    background-color: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.card-btn:hover {
    background-color: rgba(56, 189, 248, 0.1);
    border-color: var(--text-accent);
    color: var(--text-accent);
}

.card-btn-mastered {
    background-color: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

.card-btn-mastered:hover {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: var(--success-color);
    color: white;
}

.card-btn-mastered.active {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: #0b0f19;
}

.speaker-btn {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 4px;
    border-radius: 50%;
}

.speaker-btn:hover {
    color: var(--text-accent);
    background-color: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   FLASHCARDS VIEW
   ========================================================================== */
.flashcard-container {
    max-width: 540px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.flashcard-helper {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.flashcard-wrapper {
    perspective: 1200px;
    width: 100%;
    height: 640px; /* Increased to fit the massive full-width square image without vertical crop */
    cursor: pointer;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg), 0 20px 40px rgba(0, 0, 0, 0.3);
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius-lg);
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.flashcard-front {
    background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
}

.flashcard-front h3 {
    font-size: 36px;
    color: white;
    margin-bottom: 12px;
}

.flashcard-front .card-ipa {
    font-size: 18px;
    margin-bottom: 24px;
}

.card-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: auto;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.flashcard-back {
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
    transform: rotateY(180deg);
}

.flashcard-back h3 {
    font-size: 28px;
    color: white;
    margin-bottom: 4px;
}

.flashcard-back .card-pos {
    margin-bottom: 14px;
}

.flashcard-back .card-definition {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-accent);
    margin-bottom: 16px;
}

.card-back-body {
    text-align: left;
    width: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    border-radius: var(--border-radius-md);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    margin-bottom: 20px;
}

.card-usage-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.card-usage-desc {
    font-size: 13.5px;
    color: #e2e8f0;
}

.card-back-controls {
    display: flex;
    gap: 12px;
    width: 100%;
}

.card-audio-btn, .card-ext-link {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.card-audio-btn {
    background-color: var(--primary-color);
    border: 1px solid var(--primary-color);
    color: white;
}

.card-audio-btn:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.card-ext-link {
    background-color: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
}

.card-ext-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-accent);
    color: var(--text-accent);
}

.flashcard-navigation {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
}

.nav-card-btn {
    background-color: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.nav-card-btn:hover {
    background-color: rgba(56, 189, 248, 0.1);
    border-color: var(--text-accent);
    color: var(--text-accent);
}

.card-counter {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-muted);
}

.flashcard-status-btn-wrapper {
    margin-top: 10px;
}

.mastered-toggle-btn {
    background: none;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mastered-toggle-btn:hover {
    color: var(--success-color);
    border-color: var(--success-color);
    background-color: var(--success-bg);
}

.mastered-toggle-btn.active {
    color: white;
    border-color: var(--success-color);
    background-color: var(--success-color);
    font-weight: 600;
}

/* Card Badging */
.card-badge {
    position: absolute;
    top: 24px;
    left: 24px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 4px 8px;
    border-radius: 4px;
}

/* ==========================================================================
   DIALOGUES SECTION - MANGA COMIC STYLE
   ========================================================================== */
.dialogue-container {
    max-width: 800px;
    margin: 0 auto 40px auto;
}

.manga-hero-banner {
    position: relative;
    width: 100%;
    height: 180px;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    overflow: hidden;
    background-image: linear-gradient(rgba(15, 23, 42, 0.4), rgba(15, 23, 42, 0.85)), url('assets/images/hanoi_background.png');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 24px 30px;
    border-bottom: 2px solid var(--primary-color);
}

.manga-hero-banner h3 {
    font-size: 24px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 4px;
    font-family: var(--font-heading);
    font-weight: 800;
}

.manga-hero-banner p {
    font-size: 13.5px;
    color: #e2e8f0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.manga-storyboard {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    padding: 40px 30px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.manga-panel {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    position: relative;
    width: 100%;
}

.manga-avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.manga-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--bg-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    transition: transform var(--transition-fast);
}

.manga-panel:hover .manga-avatar {
    transform: scale(1.08);
}

.manga-avatar-name {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
}

.manga-bubble {
    background-color: rgba(30, 41, 59, 0.95);
    border-radius: var(--border-radius-md);
    padding: 16px 20px;
    position: relative;
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(5px);
}

/* Left panel layouts (An) */
.manga-left {
    justify-content: flex-start;
}

.manga-left .manga-avatar {
    border: 2px solid var(--primary-color);
}

.manga-left .manga-avatar-name {
    color: #a5b4fc;
}

.manga-left .manga-bubble {
    border: 1.5px solid rgba(99, 102, 241, 0.5);
    border-left: 4px solid var(--primary-color);
}

/* Speech bubble left pointer */
.manga-left .manga-bubble::before {
    content: '';
    position: absolute;
    top: 22px;
    left: -10px;
    border-width: 6px 10px 6px 0;
    border-style: solid;
    border-color: transparent rgba(99, 102, 241, 0.5) transparent transparent;
}

/* Right panel layouts (John) */
.manga-right {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.manga-right .manga-avatar {
    border: 2px solid var(--text-accent);
}

.manga-right .manga-avatar-name {
    color: var(--text-accent);
}

.manga-right .manga-bubble {
    border: 1.5px solid rgba(56, 189, 248, 0.5);
    border-right: 4px solid var(--text-accent);
}

/* Speech bubble right pointer */
.manga-right .manga-bubble::before {
    content: '';
    position: absolute;
    top: 22px;
    right: -10px;
    border-width: 6px 0 6px 10px;
    border-style: solid;
    border-color: transparent transparent transparent rgba(56, 189, 248, 0.5);
}

.manga-bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.manga-eng {
    font-size: 14.5px;
    color: white;
    font-weight: 500;
    line-height: 1.5;
}

.manga-vie {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
}

.manga-bubble-actions {
    display: flex;
    gap: 6px;
    align-self: flex-end;
    margin-top: 4px;
}

.manga-bubble-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 2px 4px;
}

.manga-bubble-actions button:hover {
    color: var(--text-accent);
}

.manga-bubble-actions button.active {
    color: var(--warning-color) !important;
}

.manga-explanation {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    font-size: 12.5px;
    color: #cbd5e1;
    line-height: 1.5;
    animation: slideUp 0.25s ease-out;
    width: 100%;
}

.manga-explanation.hidden {
    display: none;
}

.manga-explanation strong {
    color: var(--text-accent);
}

.manga-sfx {
    position: absolute;
    font-family: var(--font-heading);
    font-weight: 900;
    font-style: italic;
    font-size: 16px;
    color: var(--warning-color);
    background: rgba(15, 23, 42, 0.75);
    border: 1.5px solid var(--warning-color);
    padding: 3px 10px;
    border-radius: 6px;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
    pointer-events: none;
    z-index: 5;
    animation: sfxPulse 1.5s infinite ease-in-out;
}

.manga-left .manga-sfx {
    right: 40px;
    top: -12px;
    transform: rotate(6deg);
}

.manga-right .manga-sfx {
    left: 40px;
    top: -12px;
    transform: rotate(-6deg);
}

@keyframes sfxPulse {
    0%, 100% { transform: scale(1) rotate(-6deg); }
    50% { transform: scale(1.08) rotate(-4deg); }
}

/* Adjust left/right sfx rotations slightly based on position */
.manga-left .manga-sfx {
    animation-name: sfxPulseLeft;
}
@keyframes sfxPulseLeft {
    0%, 100% { transform: scale(1) rotate(6deg); }
    50% { transform: scale(1.08) rotate(4deg); }
}

/* ==========================================================================
   MISTAKES & TIPS SECTION
   ========================================================================== */
.grid-2-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.mistake-card, .tip-card {
    background-color: rgba(15, 23, 42, 0.4);
    border-radius: var(--border-radius-md);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mistake-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wrong-phrase {
    color: var(--error-color);
    font-weight: 600;
    font-size: 14px;
}

.right-phrase {
    color: var(--success-color);
    font-weight: 600;
    font-size: 14px;
}

.mistake-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.tip-title {
    color: var(--warning-color);
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tip-desc {
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.5;
}

/* ==========================================================================
   QUIZ SECTION
   ========================================================================== */
.quiz-container {
    max-width: 680px;
    margin: 0 auto 40px auto;
}

.quiz-screen {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    backdrop-filter: blur(10px);
    transition: opacity var(--transition-normal);
}

.quiz-intro-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.quiz-icon-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    border: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.quiz-features-list {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0 20px 0;
    color: var(--text-muted);
    font-size: 14px;
    padding-left: 20px;
}

.quiz-header-status {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.quiz-progress-text {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}

.quiz-progress-bar {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 4px;
    width: 0;
    transition: width var(--transition-fast);
}

.quiz-timer {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-accent);
    font-size: 13.5px;
}

.quiz-question-card {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    margin-bottom: 30px;
}

.quiz-question-type-badge {
    align-self: flex-start;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--text-accent);
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 14px;
    letter-spacing: 0.05em;
}

.quiz-question-text {
    font-size: 18px;
    font-weight: 600;
    color: white;
    margin-bottom: 24px;
}

/* Fill in the blanks input */
.quiz-answer-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-answer-input-wrapper input {
    background-color: rgba(15, 23, 42, 0.5);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 14px 20px;
    font-family: var(--font-body);
    font-size: 15px;
    color: white;
    outline: none;
    transition: var(--transition-fast);
}

.quiz-answer-input-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.quiz-hint-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* Multiple choice layout */
.quiz-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.quiz-option-btn {
    background-color: rgba(15, 23, 42, 0.4);
    border: 1.5px solid var(--border-color);
    color: #e2e8f0;
    font-family: var(--font-body);
    font-size: 14.5px;
    text-align: left;
    padding: 14px 20px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-option-btn:hover {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.15);
}

.quiz-option-btn.selected {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
    color: white;
}

.quiz-option-btn.correct {
    border-color: var(--success-color);
    background-color: rgba(16, 185, 129, 0.1);
    color: white;
}

.quiz-option-btn.incorrect {
    border-color: var(--error-color);
    background-color: rgba(239, 68, 68, 0.1);
    color: white;
}

.option-letter {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.quiz-option-btn.selected .option-letter {
    background-color: var(--primary-color);
    color: white;
}

/* Quiz Feedback Explanations */
.quiz-feedback-box {
    margin-bottom: 24px;
    border-radius: var(--border-radius-md);
    padding: 20px;
    animation: slideUp 0.3s ease-out;
}

.quiz-feedback-box.correct-bg {
    background-color: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.quiz-feedback-box.incorrect-bg {
    background-color: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.feedback-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.feedback-status h4 {
    font-size: 15px;
    font-weight: 700;
}

.correct-bg h4 { color: var(--success-color); }
.incorrect-bg h4 { color: var(--error-color); }

.feedback-text {
    font-size: 13.5px;
    line-height: 1.5;
    color: #e2e8f0;
}

.quiz-action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

/* Standard Buttons styling */
.primary-btn, .secondary-btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    padding: 10px 24px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

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

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn.btn-large {
    padding: 14px 32px;
    font-size: 15px;
    border-radius: var(--border-radius-md);
}

.secondary-btn {
    background-color: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Results Screen card styling */
.quiz-result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.result-score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.05);
    border: 4px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-glow);
}

.result-score {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    color: white;
    line-height: 1.1;
}

.result-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.quiz-result-card h3 {
    font-size: 24px;
    margin-bottom: 8px;
}

.quiz-result-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.result-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 110px);
    gap: 16px;
    margin-bottom: 36px;
}

.stat-card {
    background-color: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
}

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.result-actions {
    display: flex;
    gap: 16px;
}

/* ==========================================================================
   MODALS STYLING
   ========================================================================== */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.open {
    display: flex;
}

.modal-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition-fast);
}

.close-modal-btn:hover {
    color: white;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    color: white;
    font-family: var(--font-body);
    font-size: 13.5px;
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary-color);
}

.range-control {
    width: 100%;
    accent-color: var(--primary-color);
    background-color: rgba(15, 23, 42, 0.6);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

.modal-hint-text {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* ==========================================================================
   ANIMATIONS KEYFRAMES
   ========================================================================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   RESPONSIVE LAYOUT MEDIA QUERIES
   ========================================================================== */
@media (max-width: 992px) {
    /* Fixed Top Header Layout */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: rgba(8, 12, 20, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border-color);
        z-index: 1000;
        padding: 10px 24px;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        overflow: visible !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar-header {
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }
    
    .logo-wrapper {
        gap: 10px;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .logo-text h1 {
        font-size: 16px;
    }
    
    .logo-text p {
        display: none; /* Hide subtitle */
    }

    /* Inline Topic Selector Dropdown */
    .sidebar .topic-selector-card {
        margin-bottom: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: none !important;
        box-shadow: none !important;
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }
    
    .sidebar .topic-selector-card .topic-lbl {
        display: none !important; /* Hide "Chủ đề học tập" label */
    }
    
    .sidebar .select-dropdown-container {
        width: 180px;
    }
    
    .sidebar .topic-dropdown {
        padding: 6px 28px 6px 10px;
        font-size: 12px;
        border-radius: var(--border-radius-sm);
        background-color: rgba(15, 23, 42, 0.85);
    }
    
    /* Fixed Bottom Tab Navigation Bar */
    .nav-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(8, 12, 20, 0.96);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        flex-direction: row !important;
        justify-content: space-around;
        align-items: center;
        margin: 0 !important;
        padding: 0 16px !important;
        gap: 0 !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .nav-item {
        flex: 1;
        height: 100%;
        flex-direction: column !important;
        justify-content: center;
        align-items: center;
        gap: 4px !important;
        padding: 6px 0 !important;
        border-radius: 0 !important;
        background: none !important;
        border: none !important;
        color: var(--text-muted);
        font-size: 10px !important;
        text-align: center;
        transition: color 0.2s ease;
    }
    
    .nav-item i {
        font-size: 18px !important;
        margin-right: 0 !important;
    }
    
    .nav-item span {
        display: block !important; /* Force show short tabs labels */
        font-weight: 600;
    }
    
    .nav-item.active {
        color: var(--primary-color) !important;
        background: none !important;
    }
    
    .nav-item.active i {
        color: var(--primary-color) !important;
    }

    /* Recalculate Scrollable Middle Container */
    .app-container {
        grid-template-columns: 1fr;
        height: 100vh;
        overflow: hidden;
    }
    
    .main-content {
        margin-top: 64px; /* Space for fixed header */
        margin-bottom: 60px; /* Space for fixed navigation bar */
        height: calc(100vh - 124px) !important;
        overflow-y: auto;
        display: block;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Layout structure adjustments */
    .grid-2-col {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px 24px 8px 24px !important;
    }
    
    .top-actions {
        justify-content: space-between;
    }
    
    .search-box {
        flex: 1;
    }
    
    .content-panel {
        padding: 20px 24px 40px 24px !important;
    }
}

/* Smartphone Specific Adjustments (< 768px) */
@media (max-width: 768px) {
    .sidebar {
        padding: 10px 16px;
    }
    
    .sidebar .select-dropdown-container {
        width: 155px; /* Slightly smaller to fit logo on very narrow screens */
    }
    
    .nav-menu {
        padding: 0 8px !important;
    }
    
    .top-bar {
        padding: 16px 16px 8px 16px !important;
    }
    
    .content-panel {
        padding: 12px 16px 40px 16px !important;
    }
    
    /* Flashcard responsiveness */
    .flashcard-wrapper {
        height: 460px; /* Taller card container to support square mobile image without vertical crop */
    }
    
    .flashcard-image-wrapper {
        height: auto !important; /* Scale dynamically as a square on mobile */
        width: calc(100% + 40px) !important; /* Break out of 20px mobile padding */
        margin-left: -20px !important;
        margin-right: -20px !important;
        margin-top: 5px !important;
        margin-bottom: 15px !important;
        max-width: none !important;
    }
    
    .flashcard-face {
        padding: 20px;
    }
    
    .flashcard-front h3 {
        font-size: 28px;
    }
    
    .flashcard-back h3 {
        font-size: 22px;
    }
    
    .flashcard-back .card-definition {
        font-size: 16px;
    }
    
    /* Quiz responsiveness */
    .quiz-screen {
        padding: 16px;
    }
    
    .quiz-header-status {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }
    
    .quiz-timer {
        justify-self: center;
    }
    
    .result-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
    }
}

/* Micro Mobile Specific styling (< 576px) */
@media (max-width: 576px) {
    /* Dynamic pill scrolling for categories */
    .filter-wrapper {
        padding: 10px 12px !important;
        margin-bottom: 16px !important;
        border-radius: var(--border-radius-md);
    }
    
    .filter-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .filter-label {
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    
    .filter-buttons {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 4px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    
    .filter-buttons::-webkit-scrollbar {
        display: none; /* Hide ugly scrollbars in category pill rows */
    }
    
    .filter-btn {
        padding: 6px 12px !important;
        font-size: 11.5px !important;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    /* Compact Cards Grid for single column on mobile */
    .vocab-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .vocab-card {
        padding: 16px !important;
    }
    
    .card-word {
        font-size: 20px !important;
    }
    
    .card-image-wrapper {
        height: auto !important;
        border-radius: var(--border-radius-sm);
    }
    
    /* Dialogue Manga panels stacking optimization */
    .manga-hero-banner {
        padding: 16px 20px !important;
    }
    
    .manga-hero-banner h3 {
        font-size: 18px !important;
    }
    
    .manga-hero-banner p {
        font-size: 11.5px !important;
    }
    
    .manga-storyboard {
        padding: 20px 12px !important;
        gap: 24px !important;
    }
    
    .manga-panel {
        gap: 10px !important;
    }
    
    .manga-avatar-wrapper {
        gap: 4px !important;
    }
    
    .manga-avatar {
        width: 44px !important;
        height: 44px !important;
    }
    
    .manga-avatar-name {
        font-size: 10px !important;
    }
    
    .manga-bubble {
        max-width: calc(100% - 56px) !important;
        padding: 12px 14px !important;
        border-radius: 12px !important;
    }
    
    .manga-eng {
        font-size: 13px !important;
        line-height: 1.4;
    }
    
    .manga-vie {
        font-size: 11.5px !important;
        line-height: 1.35;
    }
    
    .manga-bubble-actions button {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    /* Adjust float dialogue sound effects */
    .manga-sfx {
        font-size: 11.5px !important;
        padding: 2px 6px !important;
    }
    
    .manga-left .manga-sfx {
        right: 15px !important;
        top: -12px !important;
    }
    
    .manga-right .manga-sfx {
        left: 15px !important;
        top: -12px !important;
    }
    
    /* Common Mistakes Stacking Header */
    .mistake-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }
    
    /* Quiz Panels adjustments */
    .quiz-question-card {
        padding: 16px !important;
    }
    
    .quiz-question-text {
        font-size: 15px !important;
        line-height: 1.45;
    }
    
    .quiz-option-btn {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
    
    /* Self-grading controls stack vertically on narrow screens */
    .self-grade-container {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    
    .self-grade-container button {
        width: 100% !important;
        justify-content: center;
    }
}
