/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #6C63FF;
    --primary-dark: #5A52D5;
    --secondary: #FF6584;
    --accent: #43E97B;
    --bg: #F0F4FF;
    --white: #FFFFFF;
    --text: #2D3748;
    --text-muted: #718096;
    --radius: 16px;
    --shadow: 0 8px 32px rgba(108,99,255,0.12);
    --shadow-hover: 0 16px 48px rgba(108,99,255,0.22);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; color: inherit; }

/* ===== NAVBAR ===== */
.navbar {
    background: var(--white);
    box-shadow: 0 2px 20px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--primary);
}

.logo-icon { font-size: 1.8rem; }

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-greeting {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(108,99,255,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(108,99,255,0.5); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-admin {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    box-shadow: 0 4px 15px rgba(245,87,108,0.4);
}
.btn-admin:hover { transform: translateY(-2px); }

.btn-hero {
    background: white;
    color: var(--primary);
    font-size: 1.1rem;
    padding: 14px 32px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.btn-hero:hover { transform: translateY(-3px); box-shadow: 0 12px 40px rgba(0,0,0,0.2); }

.btn-large { padding: 14px 32px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.btn-danger { background: #FC5C7D; color: white; }
.btn-danger:hover { background: #e04060; }

/* ===== ALERTS ===== */
.alert {
    max-width: 1200px;
    margin: 16px auto;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-weight: 600;
}
.alert-success { background: #D4EDDA; color: #155724; border: 1px solid #C3E6CB; }
.alert-error { background: #F8D7DA; color: #721C24; border: 1px solid #F5C6CB; }

/* ===== HERO ===== */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 48px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    min-height: 260px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-content { position: relative; max-width: 560px; }

.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 16px;
}

.highlight {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.15rem;
    opacity: 0.9;
    margin-bottom: 32px;
    line-height: 1.6;
}

.hero-illustration {
    position: relative;
    width: 200px;
    height: 200px;
    display: none;
}

@media (min-width: 768px) {
    .hero-illustration { display: block; }
}

.floating-emoji {
    position: absolute;
    font-size: 2.5rem;
    animation: float 3s ease-in-out infinite;
    animation-delay: var(--delay);
}

.floating-emoji:nth-child(1) { top: 0; left: 50%; }
.floating-emoji:nth-child(2) { top: 20%; right: 0; }
.floating-emoji:nth-child(3) { bottom: 20%; right: 10%; }
.floating-emoji:nth-child(4) { bottom: 0; left: 40%; }
.floating-emoji:nth-child(5) { bottom: 30%; left: 0; }
.floating-emoji:nth-child(6) { top: 30%; left: 10%; }

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

/* ===== SUBJECTS SECTION ===== */
.subjects-section {
    max-width: 1200px;
    margin: 60px auto;
    padding: 0 24px;
}

.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.subject-card {
    border-radius: 24px;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    color: white;
    position: relative;
    overflow: hidden;
}

.subject-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.subject-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.subject-icon { font-size: 3rem; }
.subject-name { font-size: 1.4rem; font-weight: 900; }
.subject-desc { font-size: 0.9rem; opacity: 0.85; line-height: 1.5; flex: 1; }
.subject-cta { font-weight: 700; font-size: 0.95rem; opacity: 0.9; }

/* Subject color themes */
.subject-math    { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.subject-viet    { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.subject-english { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.subject-science { background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%); }
.subject-music   { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); color: #5a3e2b; }
.subject-art     { background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%); color: #5a2a2a; }

/* ===== CTA SECTION ===== */
.cta-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 80px 24px;
    text-align: center;
    color: white;
    margin-top: 40px;
}

.cta-content h2 { font-size: 2rem; font-weight: 900; margin-bottom: 12px; }
.cta-content p { font-size: 1.1rem; opacity: 0.9; margin-bottom: 32px; }

/* ===== LOGIN PAGE ===== */
.login-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: calc(100vh - 70px - 60px);
}

.login-card {
    background: white;
    border-radius: 28px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-header { text-align: center; margin-bottom: 36px; }
.login-logo { font-size: 4rem; margin-bottom: 12px; }
.login-header h1 { font-size: 1.8rem; font-weight: 900; color: var(--text); margin-bottom: 8px; }
.login-header p { color: var(--text-muted); }

.social-login { display: flex; flex-direction: column; gap: 12px; }

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    width: 100%;
}

.btn-google {
    background: white;
    color: #3c4043;
    border: 2px solid #dadce0;
}
.btn-google:hover { background: #f8f9fa; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.btn-facebook {
    background: #1877F2;
    color: white;
}
.btn-facebook:hover { background: #166FE5; box-shadow: 0 4px 12px rgba(24,119,242,0.4); }

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E2E8F0;
}

.login-note {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 20px;
    line-height: 1.5;
}

/* ===== SUBJECT PAGE ===== */
.subject-page { flex: 1; }

.subject-hero {
    padding: 60px 24px;
    text-align: center;
    color: white;
    position: relative;
}

.back-link {
    position: absolute;
    top: 24px;
    left: 24px;
    color: rgba(255,255,255,0.8);
    font-weight: 700;
    font-size: 0.9rem;
    transition: var(--transition);
}
.back-link:hover { color: white; }

.subject-hero-icon { font-size: 5rem; margin-bottom: 16px; }
.subject-hero h1 { font-size: 2.5rem; font-weight: 900; margin-bottom: 12px; }
.subject-hero p { font-size: 1.1rem; opacity: 0.9; max-width: 500px; margin: 0 auto; }

.lessons-container {
    max-width: 900px;
    margin: 48px auto;
    padding: 0 24px;
}

.lessons-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.lessons-header h2 { font-size: 1.5rem; font-weight: 900; }
.lesson-count {
    background: var(--primary);
    color: white;
    padding: 4px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
}

.lessons-grid { display: flex; flex-direction: column; gap: 16px; }

.lesson-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.lesson-card:hover { transform: translateX(4px); box-shadow: var(--shadow-hover); }

.lesson-number {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1rem;
    flex-shrink: 0;
}

.lesson-info { flex: 1; }
.lesson-info h3 { font-weight: 800; margin-bottom: 4px; }
.lesson-info p { color: var(--text-muted); font-size: 0.9rem; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}
.empty-icon { font-size: 5rem; margin-bottom: 20px; }
.empty-state h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: 12px; }
.empty-state p { color: var(--text-muted); margin-bottom: 28px; font-size: 1.05rem; }

/* ===== ADMIN PAGE ===== */
.admin-page {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 24px;
}

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-header h1 { font-size: 1.8rem; font-weight: 900; margin-bottom: 4px; }
.admin-header p { color: var(--text-muted); }

.admin-table-wrapper {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    background: #F7F8FC;
    padding: 14px 16px;
    text-align: left;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td {
    padding: 16px;
    border-top: 1px solid #F0F0F0;
    vertical-align: middle;
}

.admin-table tr:hover td { background: #FAFBFF; }

.text-center { text-align: center; }
.text-2xl { font-size: 1.5rem; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

.action-cell { display: flex; gap: 8px; align-items: center; }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    font-family: 'Nunito', sans-serif;
    transition: var(--transition);
}
.badge-success { background: #D4EDDA; color: #155724; }
.badge-warning { background: #FFF3CD; color: #856404; }
.badge:hover { opacity: 0.8; }

/* ===== FORM ===== */
.form-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
    max-width: 700px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    color: var(--text);
    transition: var(--transition);
    background: white;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.form-check-group {
    display: flex;
    align-items: flex-end;
    padding-bottom: 4px;
}
.form-check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 700;
}
.form-check {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #F0F0F0;
}

code {
    background: #F0F4FF;
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--white);
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
    border-top: 1px solid #E2E8F0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .hero { flex-direction: column; padding: 60px 24px; text-align: center; }
    .subjects-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
    .subject-card { padding: 24px 20px; }
    .subject-icon { font-size: 2.2rem; }
    .subject-name { font-size: 1.1rem; }
    .form-row { grid-template-columns: 1fr; }
    .admin-header { flex-direction: column; }
    .action-cell { flex-direction: column; }
    .login-card { padding: 32px 24px; }
}

@media (max-width: 400px) {
    .subjects-grid { grid-template-columns: 1fr; }
}

/* ===== VALIDATION ===== */
.validation-summary {
    background: #FFF0F0;
    border: 1px solid #FFCDD2;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: #C62828;
    font-size: 0.9rem;
}
.validation-summary ul { margin: 0; padding-left: 18px; }
.field-error { color: #E53E3E; font-size: 0.82rem; margin-top: 4px; display: block; }

/* ===== PASSWORD INPUT ===== */
.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-right: 44px; }
.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
}
.toggle-password:hover { opacity: 1; }

/* ===== LOGIN FOOTER LINKS ===== */
.login-footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    font-size: 0.9rem;
}
.link-muted { color: var(--text-muted); }
.link-primary { color: var(--primary); font-weight: 700; }
.link-primary:hover { text-decoration: underline; }
.link-sep { color: var(--text-muted); }

.form-check-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.form-check-inline .form-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== PROFILE PAGE ===== */
.profile-page {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 24px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 36px;
    background: white;
    border-radius: var(--radius);
    padding: 28px 32px;
    box-shadow: var(--shadow);
}

.profile-avatar { flex-shrink: 0; }

.avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
}

.avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
}

.profile-header h1 { font-size: 1.6rem; font-weight: 900; margin-bottom: 4px; }

.badge-admin {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-block;
    margin-top: 6px;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 640px) {
    .profile-grid { grid-template-columns: 1fr; }
    .profile-header { flex-direction: column; text-align: center; }
}

.card-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #F0F0F0;
}

/* ===== ADMIN USERS ===== */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-initial {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.9rem;
}

.badge-admin-sm {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 1px 8px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 6px;
}

.badge-me {
    background: #E8F4FD;
    color: #2980B9;
    padding: 1px 8px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 4px;
}

.row-locked td { opacity: 0.6; }

.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 24px;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: white;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.page-btn:hover, .page-btn.active {
    background: var(--primary);
    color: white;
}

/* ===== AUTH SETTINGS ===== */
.settings-section {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px solid #F0F0F0;
}
.settings-section:last-of-type { border-bottom: none; }

.settings-section-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid #F7F8FC;
}
.setting-row:last-child { border-bottom: none; }

.setting-info { flex: 1; }
.setting-info strong { display: block; margin-bottom: 2px; }
.setting-info p { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #CBD5E0;
    border-radius: 28px;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(24px); }

/* Info box */
.info-box {
    background: #EBF8FF;
    border: 1px solid #BEE3F8;
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 0.9rem;
    color: #2C5282;
    line-height: 1.6;
}

/* ===== CHILD PROFILE SELECT PAGE ===== */
.child-select-page {
    min-height: calc(100vh - 130px);
    background: linear-gradient(160deg, #a18cd1 0%, #fbc2eb 100%);
    padding: 60px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.child-select-header {
    text-align: center;
    color: white;
    margin-bottom: 48px;
}
.child-select-header h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; margin-bottom: 8px; }
.child-select-header p { font-size: 1.1rem; opacity: 0.9; }

.child-profiles-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
    max-width: 900px;
}

.child-profile-card {
    background: white;
    border-radius: 24px;
    padding: 32px 24px 24px;
    width: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    position: relative;
    text-decoration: none;
    color: var(--text);
}
.child-profile-card:hover { transform: translateY(-8px) scale(1.04); box-shadow: 0 20px 50px rgba(0,0,0,0.18); }

.child-avatar { font-size: 4rem; line-height: 1; }
.child-name { font-size: 1.1rem; font-weight: 800; text-align: center; }
.child-pin-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #F0F4FF;
    padding: 2px 10px;
    border-radius: 50px;
}

.child-add-card {
    border: 3px dashed rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.2);
    color: white;
}
.child-add-card:hover { background: rgba(255,255,255,0.35); }
.child-add-card .child-avatar { opacity: 0.8; }
.child-add-card .child-name { opacity: 0.9; }

.child-select-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 8px 20px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}
.child-select-btn:hover { opacity: 0.9; }

.no-pin-form { width: 100%; }

/* PIN form */
.pin-form {
    display: none;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    align-items: center;
}
.pin-form--visible { display: flex; }

.pin-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 0.3em;
}
.pin-input:focus { outline: none; border-color: var(--primary); }
.pin-input--error { border-color: #e53e3e !important; }
.pin-error-msg { color: #e53e3e; font-size: 0.82rem; font-weight: 700; text-align: center; margin: -4px 0 4px; }

.child-select-footer {
    margin-top: 40px;
    text-align: center;
}
.child-select-footer .link-muted { color: rgba(255,255,255,0.75); font-size: 0.95rem; }
.child-select-footer .link-muted:hover { color: white; }

/* ===== CHILD MANAGE LIST ===== */
.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-header-row h1 { font-size: 1.8rem; font-weight: 900; margin: 4px 0; }

.children-list { display: flex; flex-direction: column; gap: 12px; max-width: 700px; }

.child-list-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.child-list-card:hover { box-shadow: var(--shadow-hover); }

.child-list-avatar { font-size: 2.5rem; flex-shrink: 0; }
.child-list-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.child-list-info strong { font-size: 1.05rem; }
.child-list-actions { display: flex; gap: 8px; }

/* ===== EMOJI PICKER ===== */
.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: #F7F8FC;
    border-radius: 12px;
}
.emoji-option { cursor: pointer; }
.emoji-option input { display: none; }
.emoji-option span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 1.6rem;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: var(--transition);
    background: white;
}
.emoji-option input:checked + span {
    border-color: var(--primary);
    background: #EEF0FF;
    transform: scale(1.15);
}
.emoji-option span:hover { transform: scale(1.1); }

/* ===== NAVBAR CHILD MODE ===== */
.nav-child-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #a18cd1, #fbc2eb);
    color: white;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.9rem;
}
.nav-child-emoji { font-size: 1.2rem; }

.btn-kids {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: #1a5c3a;
    box-shadow: 0 4px 15px rgba(67,233,123,0.4);
}
.btn-kids:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(67,233,123,0.5); }

/* hidden utility */
.hidden { display: none !important; }

/* ===== LEVELS GRID ===== */
.levels-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
}

.level-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 28px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.level-card::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 160px;
    height: 160px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.level-card:hover {
    transform: translateX(8px);
    box-shadow: var(--shadow-hover);
}

.level-icon {
    font-size: 2.8rem;
    flex-shrink: 0;
    line-height: 1;
}

.level-info { flex: 1; }
.level-info h3 { font-size: 1.3rem; font-weight: 900; margin-bottom: 4px; }
.level-info p { font-size: 0.9rem; opacity: 0.85; margin: 0; }

.level-arrow {
    font-size: 1.4rem;
    font-weight: 900;
    opacity: 0.8;
    flex-shrink: 0;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --bg:          #0F1117;
    --white:       #1A1D27;
    --text:        #E2E8F0;
    --text-muted:  #94A3B8;
    --shadow:      0 8px 32px rgba(0,0,0,0.4);
    --shadow-hover:0 16px 48px rgba(0,0,0,0.6);
}

/* Navbar */
[data-theme="dark"] .navbar {
    background: #1A1D27;
    box-shadow: 0 2px 20px rgba(0,0,0,0.4);
    border-bottom: 1px solid #2D3148;
}

/* Cards & surfaces */
[data-theme="dark"] .form-card,
[data-theme="dark"] .lesson-card,
[data-theme="dark"] .child-list-card,
[data-theme="dark"] .profile-header,
[data-theme="dark"] .admin-table-wrapper,
[data-theme="dark"] .login-card,
[data-theme="dark"] .child-profile-card {
    background: #1E2130;
    border: 1px solid #2D3148;
}

/* Form controls */
[data-theme="dark"] .form-control {
    background: #252836;
    border-color: #3D4266;
    color: var(--text);
}
[data-theme="dark"] .form-control:focus {
    border-color: var(--primary);
    background: #2A2D40;
}
[data-theme="dark"] .form-control:disabled {
    background: #1A1D27;
    opacity: 0.6;
}

/* Tables */
[data-theme="dark"] .admin-table th {
    background: #252836;
    color: var(--text-muted);
    border-bottom: 1px solid #2D3148;
}
[data-theme="dark"] .admin-table td {
    border-top-color: #2D3148;
}
[data-theme="dark"] .admin-table tr:hover td {
    background: #252836;
}

/* Footer */
[data-theme="dark"] .footer {
    background: #1A1D27;
    border-top-color: #2D3148;
}

/* Alerts */
[data-theme="dark"] .alert-success {
    background: #1A3A2A;
    color: #6EE7B7;
    border-color: #2D6A4F;
}
[data-theme="dark"] .alert-error {
    background: #3A1A1A;
    color: #FCA5A5;
    border-color: #7F1D1D;
}

/* Badges */
[data-theme="dark"] .badge-success { background: #1A3A2A; color: #6EE7B7; }
[data-theme="dark"] .badge-warning { background: #3A2E0A; color: #FCD34D; }
[data-theme="dark"] .badge-me      { background: #1A2A3A; color: #93C5FD; }

/* Outline button */
[data-theme="dark"] .btn-outline {
    border-color: #6C63FF;
    color: #A5A0FF;
}
[data-theme="dark"] .btn-outline:hover {
    background: var(--primary);
    color: white;
}

/* btn-hero (white bg on gradient) */
[data-theme="dark"] .btn-hero {
    background: rgba(255,255,255,0.15);
    color: white;
    backdrop-filter: blur(8px);
}

/* Code */
[data-theme="dark"] code {
    background: #252836;
    color: #A5A0FF;
}

/* Info box */
[data-theme="dark"] .info-box {
    background: #1A2A3A;
    border-color: #2D4A6A;
    color: #93C5FD;
}

/* Validation */
[data-theme="dark"] .validation-summary {
    background: #3A1A1A;
    border-color: #7F1D1D;
    color: #FCA5A5;
}

/* Divider */
[data-theme="dark"] .login-divider::before,
[data-theme="dark"] .login-divider::after { background: #2D3148; }

/* Card title border */
[data-theme="dark"] .card-title { border-bottom-color: #2D3148; }

/* Form actions border */
[data-theme="dark"] .form-actions { border-top-color: #2D3148; }

/* Settings section border */
[data-theme="dark"] .settings-section { border-bottom-color: #2D3148; }
[data-theme="dark"] .setting-row { border-bottom-color: #252836; }

/* Emoji picker */
[data-theme="dark"] .emoji-picker { background: #252836; }
[data-theme="dark"] .emoji-option span { background: #1E2130; border-color: transparent; }
[data-theme="dark"] .emoji-option input:checked + span { background: #2D2F50; }

/* Child profile card */
[data-theme="dark"] .child-pin-badge { background: #252836; color: var(--text-muted); }

/* Page btn */
[data-theme="dark"] .page-btn { background: #1E2130; color: var(--text); }

/* Section header */
[data-theme="dark"] .section-header h2 { color: var(--text); }

/* Toggle slider off state */
[data-theme="dark"] .toggle-slider { background: #3D4266; }

/* ===== DARK MODE TOGGLE BUTTON ===== */
.theme-toggle {
    background: none;
    border: 2px solid transparent;
    border-radius: 50px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    flex-shrink: 0;
    color: var(--text-muted);
}
.theme-toggle:hover {
    background: rgba(108,99,255,0.1);
    border-color: rgba(108,99,255,0.3);
    color: var(--primary);
}

/* ===== SUBJECT TYPING ===== */
.subject-typing { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }

/* ===== TYPING PAGE ===== */
.typing-page { flex: 1; display: flex; flex-direction: column; }

.typing-header {
    padding: 48px 24px 40px;
    text-align: center;
    color: white;
    position: relative;
}
.typing-lesson-num {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    padding: 4px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.typing-header h1 { font-size: 2rem; font-weight: 900; margin-bottom: 8px; }
.typing-header p { font-size: 1rem; opacity: 0.9; max-width: 500px; margin: 0 auto; }
.typing-completed-badge {
    display: inline-block;
    margin-top: 16px;
    background: rgba(255,255,255,0.2);
    padding: 6px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 700;
}

.typing-game-area {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 32px auto;
    padding: 0 24px;
}

.typing-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    margin: 0 auto 40px;
    padding: 0 24px;
    gap: 12px;
}

/* ===== LOADING ===== */
.typing-loading {
    text-align: center;
    padding: 80px 24px;
}
.typing-loading-spinner {
    font-size: 4rem;
    animation: float 1.5s ease-in-out infinite;
    margin-bottom: 16px;
}

/* ===== GUIDE ===== */
.guide-container {
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
}
.guide-icon { font-size: 5rem; margin-bottom: 24px; }
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
    text-align: left;
}
.guide-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: #F7F8FC;
    border-radius: 12px;
    padding: 14px 18px;
    animation: slideIn 0.4s ease both;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
.guide-step-num {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.guide-step-text { font-size: 1rem; font-weight: 600; line-height: 1.5; padding-top: 4px; }

/* Keyboard visual */
.guide-keyboard-visual {
    background: #2D3748;
    border-radius: 16px;
    padding: 20px;
    margin: 24px 0;
    display: inline-block;
}
.kb-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 6px;
}
.kb-key {
    width: 40px;
    height: 40px;
    background: #4A5568;
    color: #A0AEC0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    transition: var(--transition);
}
.kb-key--active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(108,99,255,0.5);
}

/* ===== TYPING GAME ===== */
.typing-container {
    background: white;
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.typing-stats-bar {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.typing-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.stat-val { font-size: 1.4rem; font-weight: 900; color: var(--primary); }

.typing-progress-bar {
    height: 8px;
    background: #E2E8F0;
    border-radius: 50px;
    margin-bottom: 28px;
    overflow: hidden;
}
.typing-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50px;
    transition: width 0.3s ease;
}

.typing-word-display {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    letter-spacing: 0.05em;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
    margin-bottom: 24px;
    padding: 20px;
    background: #F7F8FC;
    border-radius: 16px;
}

.tc { transition: color 0.1s; }
.tc-pending { color: #CBD5E0; }
.tc-correct { color: var(--accent); }
.tc-error { color: var(--secondary); text-decoration: underline; }

.typing-text-display {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 2;
    padding: 20px;
    background: #F7F8FC;
    border-radius: 16px;
    margin-bottom: 20px;
    min-height: 100px;
    overflow-y: auto;
    max-height: 200px;
}
.tw { padding: 2px 4px; border-radius: 4px; }
.tw-done { color: #A0AEC0; }
.tw-current { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-radius: 6px; }
.tw-pending { color: var(--text); }

.typing-input-area { display: flex; justify-content: center; margin-bottom: 12px; }
.typing-input {
    width: 100%;
    max-width: 500px;
    padding: 16px 24px;
    font-size: 1.3rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    border: 3px solid #E2E8F0;
    border-radius: 50px;
    text-align: center;
    outline: none;
    transition: var(--transition);
    letter-spacing: 0.05em;
}
.typing-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(108,99,255,0.15); }
.typing-input--error { border-color: var(--secondary) !important; background: #FFF5F5; animation: shake 0.3s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.typing-hint { text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* ===== GAME CONTAINER ===== */
.game-container {
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow);
}
.game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px 20px;
    background: #F7F8FC;
    border-radius: 12px;
}
.game-stat { font-size: 1.1rem; font-weight: 800; }
.game-title { font-size: 1rem; font-weight: 700; color: var(--text-muted); }

.game-canvas {
    position: relative;
    height: 400px;
    background: linear-gradient(180deg, #0F0C29, #302B63, #24243e);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
}
.game-start-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0,0,0,0.7);
    color: white;
    text-align: center;
    padding: 24px;
    z-index: 10;
}
.game-start-icon { font-size: 4rem; }
.game-start-overlay h2 { font-size: 1.8rem; font-weight: 900; }
.game-start-overlay p { opacity: 0.8; }

.falling-ball {
    position: absolute;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    font-weight: 900;
    box-shadow: 0 4px 20px rgba(108,99,255,0.5);
    transition: transform 0.2s;
}
.falling-ball--caught {
    transform: scale(1.5);
    opacity: 0;
    transition: all 0.3s;
}

.game-input {
    width: 100%;
    padding: 14px 24px;
    font-size: 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    border: 3px solid #E2E8F0;
    border-radius: 50px;
    text-align: center;
    outline: none;
    transition: var(--transition);
}
.game-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(108,99,255,0.15); }

/* ===== RESULT SCREEN ===== */
.result-screen {
    background: white;
    border-radius: 24px;
    padding: 48px 32px;
    box-shadow: var(--shadow);
    text-align: center;
}
.result-stars { font-size: 2.5rem; margin-bottom: 16px; letter-spacing: 4px; }
.result-title { font-size: 2rem; font-weight: 900; margin-bottom: 12px; }
.result-pass { color: #38A169; font-weight: 700; font-size: 1.1rem; margin-bottom: 20px; }
.result-fail { color: var(--secondary); font-weight: 700; font-size: 1.1rem; margin-bottom: 20px; }
.result-stats {
    display: flex;
    gap: 32px;
    justify-content: center;
    margin: 28px 0;
    flex-wrap: wrap;
}
.result-stat { text-align: center; }
.result-stat-val { font-size: 2.5rem; font-weight: 900; color: var(--primary); }
.result-stat-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .typing-word-display { font-size: 1.8rem; }
    .typing-input { font-size: 1.1rem; }
    .guide-container { padding: 24px 16px; }
    .kb-key { width: 30px; height: 30px; font-size: 0.7rem; }
    .typing-stats-bar { gap: 12px; }
    .result-stats { gap: 20px; }
}

/* ===== DASHBOARD ===== */
.dashboard-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 60px;
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.dashboard-child-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.dashboard-child-avatar {
    font-size: 4rem;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.dashboard-child-info h1 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 4px;
}

/* Streak badge */
.streak-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #FF6B35, #F7C59F);
    color: white;
    padding: 14px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(255,107,53,0.35);
}
.streak-fire { font-size: 2rem; }
.streak-num { font-size: 1.8rem; font-weight: 900; line-height: 1; }
.streak-label { font-size: 0.75rem; font-weight: 700; opacity: 0.9; }

/* Overview cards */
.dashboard-overview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.overview-card {
    background: white;
    border-radius: 20px;
    padding: 24px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.overview-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

.overview-card::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0.08;
}
.overview-card--primary::before { background: var(--primary); }
.overview-card--gold::before { background: #F6C90E; }
.overview-card--green::before { background: var(--accent); }
.overview-card--purple::before { background: #9B59B6; }

.overview-icon { font-size: 2rem; margin-bottom: 8px; }
.overview-val {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--text);
    line-height: 1;
    margin-bottom: 4px;
}
.overview-total { font-size: 1rem; color: var(--text-muted); font-weight: 600; }
.overview-unit { font-size: 1.2rem; color: var(--text-muted); font-weight: 600; }
.overview-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 700; margin-bottom: 12px; }
.overview-bar {
    height: 6px;
    background: #E2E8F0;
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 4px;
}
.overview-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50px;
    transition: width 1s ease;
}
.overview-pct { font-size: 0.8rem; color: var(--primary); font-weight: 700; }

/* Dashboard body */
.dashboard-body {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.dashboard-section {
    background: white;
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.dashboard-section-title {
    font-size: 1.2rem;
    font-weight: 900;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #F0F0F0;
}

/* Subject progress cards */
.subject-progress-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.subject-progress-card {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #F0F0F0;
    transition: var(--transition);
}
.subject-progress-card:hover { box-shadow: var(--shadow); }

.sp-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: white;
}
.sp-icon { font-size: 2rem; flex-shrink: 0; }
.sp-info { flex: 1; }
.sp-info h3 { font-size: 1.1rem; font-weight: 900; margin-bottom: 2px; }
.sp-info p { font-size: 0.85rem; opacity: 0.9; margin: 0; }
.sp-pct {
    font-size: 1.5rem;
    font-weight: 900;
    background: rgba(255,255,255,0.25);
    padding: 6px 14px;
    border-radius: 50px;
    flex-shrink: 0;
}

.sp-body { padding: 16px 20px; background: #FAFBFF; }

.sp-progress-bar {
    height: 8px;
    background: #E2E8F0;
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 16px;
}
.sp-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50px;
    transition: width 1s ease;
}

.sp-levels { display: flex; flex-direction: column; gap: 8px; }

.sp-level-row {
    display: grid;
    grid-template-columns: 24px 1fr auto auto;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}
.sp-level-icon { font-size: 1rem; text-align: center; }
.sp-level-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-level-bar-wrap { min-width: 80px; }
.sp-level-bar {
    height: 6px;
    background: #E2E8F0;
    border-radius: 50px;
    overflow: hidden;
}
.sp-level-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50px;
    transition: width 1s ease;
}
.sp-level-fill--done { background: linear-gradient(135deg, var(--accent), #38f9d7); }
.sp-level-stat { font-weight: 700; color: var(--text-muted); white-space: nowrap; font-size: 0.8rem; }
.badge-done {
    background: #D4EDDA;
    color: #155724;
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Activity list */
.activity-list { display: flex; flex-direction: column; gap: 0; }

.activity-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #F7F8FC;
    transition: var(--transition);
}
.activity-row:last-child { border-bottom: none; }
.activity-row:hover { background: #FAFBFF; margin: 0 -8px; padding: 14px 8px; border-radius: 10px; }

.activity-subject-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
/* Reuse subject color classes for dot background */
.activity-subject-dot.subject-math { background: #4facfe; }
.activity-subject-dot.subject-viet { background: #f093fb; }
.activity-subject-dot.subject-english { background: #43e97b; }
.activity-subject-dot.subject-science { background: #a18cd1; }
.activity-subject-dot.subject-music { background: #fcb69f; }
.activity-subject-dot.subject-art { background: #ff9a9e; }
.activity-subject-dot.subject-typing { background: #667eea; }

.activity-info { flex: 1; min-width: 0; }
.activity-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.activity-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    flex-shrink: 0;
}
.activity-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 50px;
}
.activity-badge--done { background: #D4EDDA; color: #155724; }
.activity-badge--progress { background: #FFF3CD; color: #856404; }
.activity-score { font-size: 0.85rem; font-weight: 700; color: var(--primary); }
.activity-time { font-size: 0.75rem; color: var(--text-muted); }

/* Dashboard footer */
.dashboard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    gap: 12px;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 640px) {
    .dashboard-overview { grid-template-columns: 1fr 1fr; }
    .dashboard-child-avatar { font-size: 3rem; }
    .dashboard-child-info h1 { font-size: 1.4rem; }
    .sp-level-row { grid-template-columns: 20px 1fr auto; }
    .sp-level-bar-wrap { display: none; }
    .activity-row { flex-wrap: wrap; }
}

/* ===== SUBJECT TABS NAV ===== */
.subject-tabs-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.subject-tabs-nav::-webkit-scrollbar { display: none; }

.subject-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 14px 14px 0 0;
    border: none;
    background: white;
    color: var(--text-muted);
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    position: relative;
    bottom: -2px;
    border-bottom: 3px solid transparent;
}
.subject-tab-btn:hover { color: var(--primary); background: #F0F4FF; }
.subject-tab-btn.active {
    color: var(--primary);
    background: white;
    border-bottom: 3px solid var(--primary);
    box-shadow: 0 -4px 16px rgba(108,99,255,0.12);
    z-index: 1;
}
.subject-tab-btn--inactive { opacity: 0.55; }
.subject-tab-btn--inactive:hover { opacity: 0.8; }

.stb-icon { font-size: 1.2rem; }
.stb-name { font-size: 0.88rem; }
.stb-badge {
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 50px;
}
.stb-badge--done { background: #D4EDDA; color: #155724; }
.stb-badge--pct  { background: #EEF0FF; color: var(--primary); }

/* ===== SUBJECT TABS CONTENT ===== */
.subject-tabs-content {
    background: white;
    border-radius: 0 16px 16px 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.subject-tab-panel { display: none; }
.subject-tab-panel.active { display: block; }

/* Panel header (reuses subject gradient) */
.stp-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px 28px 24px;
    color: white;
    flex-wrap: wrap;
}
.stp-header-icon { font-size: 3.5rem; flex-shrink: 0; }
.stp-header-info { flex: 1; min-width: 160px; }
.stp-header-info h2 { font-size: 1.5rem; font-weight: 900; margin-bottom: 4px; }
.stp-header-info p  { font-size: 0.9rem; opacity: 0.85; margin: 0; }

.stp-header-stats {
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}
.stp-stat { text-align: center; }
.stp-stat-val   { font-size: 1.4rem; font-weight: 900; }
.stp-stat-label { font-size: 0.72rem; opacity: 0.85; font-weight: 700; text-transform: uppercase; }

/* Overall progress bar */
.stp-overall-bar-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 28px 20px;
    background: white;
}
.stp-overall-bar {
    flex: 1;
    height: 10px;
    background: #E2E8F0;
    border-radius: 50px;
    overflow: hidden;
}
.stp-overall-fill {
    height: 100%;
    border-radius: 50px;
    transition: width 1s ease;
    /* Reuse subject gradient via filter trick  fallback to primary */
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
/* Override fill color per subject */
.stp-overall-fill.subject-math    { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.stp-overall-fill.subject-viet    { background: linear-gradient(135deg, #f093fb, #f5576c); }
.stp-overall-fill.subject-english { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.stp-overall-fill.subject-science { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.stp-overall-fill.subject-music   { background: linear-gradient(135deg, #ffecd2, #fcb69f); }
.stp-overall-fill.subject-art     { background: linear-gradient(135deg, #ff9a9e, #fad0c4); }
.stp-overall-fill.subject-typing  { background: linear-gradient(135deg, #667eea, #764ba2); }
.stp-overall-pct { font-size: 0.9rem; font-weight: 800; color: var(--primary); flex-shrink: 0; width: 44px; text-align: right; }

/* Not started state */
.stp-not-started {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.stp-not-started-icon { font-size: 3rem; margin-bottom: 8px; }
.stp-not-started p { margin-bottom: 16px; font-weight: 600; }

/* ===== LEVEL PROGRESS CARDS GRID ===== */
.stp-levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px 28px 24px;
}

.level-progress-card {
    border-radius: 16px;
    padding: 18px 20px;
    border: 2px solid #E2E8F0;
    background: white;
    transition: var(--transition);
}
.level-progress-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.lpc--done     { border-color: #C3E6CB; background: #F8FFF9; }
.lpc--progress { border-color: #BEE3F8; background: #F0F9FF; }
.lpc--locked   { opacity: 0.55; }

.lpc-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.lpc-icon { font-size: 1.8rem; flex-shrink: 0; line-height: 1; }
.lpc-info { flex: 1; min-width: 0; }
.lpc-name    { font-weight: 800; font-size: 0.95rem; margin-bottom: 2px; }
.lpc-lessons { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

.lpc-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 50px;
    white-space: nowrap;
    flex-shrink: 0;
}
.lpc-badge--done     { background: #D4EDDA; color: #155724; }
.lpc-badge--progress { background: #CCE5FF; color: #004085; }
.lpc-badge--locked   { background: #F0F0F0; color: #888; }

.lpc-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.lpc-bar {
    flex: 1;
    height: 8px;
    background: #E2E8F0;
    border-radius: 50px;
    overflow: hidden;
}
.lpc-bar-fill {
    height: 100%;
    border-radius: 50px;
    transition: width 1s ease;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.lpc-bar-fill--done     { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.lpc-bar-fill--progress { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.lpc-bar-fill--locked   { background: #CBD5E0; }
.lpc-pct { font-size: 0.8rem; font-weight: 800; color: var(--text-muted); width: 36px; text-align: right; flex-shrink: 0; }

.lpc-score { font-size: 0.8rem; font-weight: 700; color: #D4A017; margin-bottom: 10px; }

/* Lesson dots */
.lpc-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.lpc-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transition: var(--transition);
    cursor: default;
}
.lpc-dot--done     { background: #43e97b; }
.lpc-dot--accessed { background: #667eea; opacity: 0.6; }
.lpc-dot--empty    { background: #E2E8F0; }

/* Recent activities inside tab */
.stp-recent {
    padding: 0 28px 28px;
    border-top: 1px solid #F0F0F0;
    margin-top: 4px;
}
.stp-recent-title {
    font-size: 1rem;
    font-weight: 800;
    padding: 16px 0 12px;
    color: var(--text);
}

/* db back link */
.db-back-link {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
    transition: var(--transition);
}
.db-back-link:hover { color: var(--primary); }

/* Responsive */
@media (max-width: 640px) {
    .stp-header { padding: 20px 16px; gap: 12px; }
    .stp-header-icon { font-size: 2.5rem; }
    .stp-header-stats { gap: 12px; }
    .stp-stat-val { font-size: 1.1rem; }
    .stp-levels-grid { grid-template-columns: 1fr; padding: 16px; }
    .stp-overall-bar-wrap { padding: 0 16px 16px; }
    .stp-recent { padding: 0 16px 20px; }
    .subject-tab-btn { padding: 8px 12px; }
    .stb-name { display: none; }
    .stb-icon { font-size: 1.4rem; }
}

/* ===== LEVEL UNLOCK SYSTEM ===== */
.locked-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #FFF3CD;
    border: 1px solid #FFEAA7;
    border-radius: var(--radius);
    padding: 14px 20px;
    margin: 16px auto;
    max-width: 900px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #856404;
}
.locked-alert-icon { font-size: 1.4rem; flex-shrink: 0; }

.level-card-wrap { position: relative; }
.level-card--locked {
    opacity: 0.65;
    cursor: not-allowed;
    filter: grayscale(0.3);
}
.level-card--locked:hover { transform: none !important; box-shadow: var(--shadow) !important; }

.level-unlock-req {
    font-size: 0.78rem;
    margin-top: 6px;
    background: rgba(0,0,0,0.15);
    padding: 3px 10px;
    border-radius: 50px;
    display: inline-block;
    font-weight: 700;
}
.level-unlock-req--open {
    background: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.95);
}

/* ===== LEVEL REQUIREMENTS BAR ===== */
.level-requirements-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #EBF8FF;
    border: 1px solid #BEE3F8;
    border-radius: var(--radius);
    padding: 10px 18px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2C5282;
    flex-wrap: wrap;
}
.lrb-icon { font-size: 1.1rem; }
.lrb-tag {
    background: #2B6CB0;
    color: white;
    padding: 3px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
}

/* ===== LEVEL OVERALL PROGRESS BAR ===== */
.level-overall-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.level-overall-bar {
    flex: 1;
    height: 10px;
    background: #E2E8F0;
    border-radius: 50px;
    overflow: hidden;
}
.level-overall-fill {
    height: 100%;
    border-radius: 50px;
    transition: width 0.8s ease;
}
/* Reuse subject color fills */
.level-overall-fill.subject-math    { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.level-overall-fill.subject-viet    { background: linear-gradient(135deg, #f093fb, #f5576c); }
.level-overall-fill.subject-english { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.level-overall-fill.subject-science { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.level-overall-fill.subject-music   { background: linear-gradient(135deg, #ffecd2, #fcb69f); }
.level-overall-fill.subject-art     { background: linear-gradient(135deg, #ff9a9e, #fad0c4); }
.level-overall-fill.subject-typing  { background: linear-gradient(135deg, #667eea, #764ba2); }
.level-overall-pct { font-size: 0.85rem; font-weight: 800; color: var(--primary); width: 44px; text-align: right; flex-shrink: 0; }

.lesson-progress-text { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }

/* ===== LESSON CARD STATES ===== */
.lesson-card--done     { border-left: 4px solid #43e97b; }
.lesson-card--progress { border-left: 4px solid var(--primary); }

.lesson-number--done {
    background: linear-gradient(135deg, #43e97b, #38f9d7) !important;
}

.lesson-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.lesson-score { font-size: 0.8rem; font-weight: 700; }
.lesson-score--done    { color: #38A169; }
.lesson-score--partial { color: var(--primary); }
.lesson-score-req {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #F0F4FF;
    padding: 1px 8px;
    border-radius: 50px;
}

/* ===== ADMIN FORM SECTION TITLE ===== */
.form-section-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 24px 0 12px;
    padding-top: 20px;
    border-top: 2px solid #F0F0F0;
}

/* ===== HOME HERO ACTIONS ===== */
.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.btn-hero-outline {
    background: transparent;
    color: white;
    border: 2px solid rgba(255,255,255,0.7);
    font-size: 1.1rem;
    padding: 14px 32px;
    border-radius: 50px;
    font-family: "Nunito", sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-hero-outline:hover { background: rgba(255,255,255,0.15); border-color: white; }

/* ===== HOME GUEST SECTION ===== */
.home-guest {
    max-width: 1100px;
    margin: 60px auto;
    padding: 0 24px;
}
.home-guest-inner {
    display: flex;
    align-items: center;
    gap: 60px;
    background: white;
    border-radius: 28px;
    padding: 48px;
    box-shadow: var(--shadow);
}
.home-guest-text { flex: 1; }
.home-guest-text h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: 12px; }
.home-guest-text p  { color: var(--text-muted); font-size: 1.05rem; margin-bottom: 20px; line-height: 1.6; }

.home-feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
}
.home-feature-list li { font-weight: 600; font-size: 0.95rem; }

.home-guest-btns { display: flex; gap: 12px; flex-wrap: wrap; }

.home-guest-emojis {
    position: relative;
    width: 220px;
    height: 220px;
    flex-shrink: 0;
}
.hge-bubble {
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 8px 24px rgba(108,99,255,0.25);
    animation: float 3s ease-in-out infinite;
}
.hge-bubble--1 { top: 0;   left: 50%; animation-delay: 0s;    background: linear-gradient(135deg, #667eea, #764ba2); }
.hge-bubble--2 { top: 20%; right: 0;  animation-delay: 0.4s;  background: linear-gradient(135deg, #4facfe, #00f2fe); }
.hge-bubble--3 { top: 55%; right: 10%; animation-delay: 0.8s; background: linear-gradient(135deg, #f093fb, #f5576c); }
.hge-bubble--4 { bottom: 0; left: 40%; animation-delay: 1.2s; background: linear-gradient(135deg, #43e97b, #38f9d7); }
.hge-bubble--5 { bottom: 20%; left: 0; animation-delay: 1.6s; background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.hge-bubble--6 { top: 35%; left: 5%;  animation-delay: 2s;   background: linear-gradient(135deg, #ffecd2, #fcb69f); }

@media (max-width: 768px) {
    .home-guest-inner { flex-direction: column; padding: 32px 24px; gap: 32px; }
    .home-guest-emojis { display: none; }
}

/* ===== HOME CHILDREN SECTION ===== */
.home-children {
    max-width: 1100px;
    margin: 48px auto 60px;
    padding: 0 24px;
}

.home-children-header {
    text-align: center;
    margin-bottom: 32px;
}
.home-children-header h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: 6px; }
.home-children-header p  { color: var(--text-muted); font-size: 1rem; }

.home-children-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 24px;
}

.home-child-form { display: contents; }
.home-child-card-wrap { display: contents; }

.home-pin-form {
    background: white;
    border-radius: 24px;
    padding: 20px 16px;
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    border: 3px solid var(--primary);
}
.home-pin-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #E2E8F0;
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 0.3em;
}
.home-pin-input:focus { outline: none; border-color: var(--primary); }
.home-pin-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

.home-child-card {
    background: white;
    border-radius: 24px;
    padding: 28px 20px 20px;
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    border: 3px solid transparent;
    text-decoration: none;
    color: var(--text);
    font-family: "Nunito", sans-serif;
    font-size: 1rem;
}
.home-child-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: var(--shadow-hover); }

.home-child-card--active {
    border-color: var(--accent);
    box-shadow: 0 8px 32px rgba(67,233,123,0.25);
}
.home-child-card--add {
    border: 3px dashed #CBD5E0;
    background: #F7F8FC;
    color: var(--text-muted);
}
.home-child-card--add:hover { border-color: var(--primary); color: var(--primary); background: #F0F4FF; }

.hcc-avatar { font-size: 3.5rem; line-height: 1; }
.hcc-name   { font-weight: 800; font-size: 1rem; text-align: center; }
.hcc-status {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 50px;
    background: #F0F4FF;
    color: var(--primary);
}
.hcc-status--pin { background: #FFF3CD; color: #856404; }
.hcc-status--go  { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }

.home-children-footer { text-align: center; }

/* ===== HOME NO CHILDREN ===== */
.home-no-children {
    text-align: center;
    background: white;
    border-radius: 24px;
    padding: 60px 32px;
    box-shadow: var(--shadow);
}
.hnc-icon { font-size: 5rem; margin-bottom: 16px; }
.home-no-children h2 { font-size: 1.6rem; font-weight: 900; margin-bottom: 10px; }
.home-no-children p  { color: var(--text-muted); margin-bottom: 28px; font-size: 1rem; }

/* ===== SUBJECT SELECT PAGE ===== */
.subject-select-page { flex: 1; }
.subject-select-header {
    text-align: center;
    padding: 24px 24px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}
.subject-select-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 4px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.subject-select-header h1 { font-size: 2rem; font-weight: 900; margin-bottom: 8px; }
.subject-select-header p  { opacity: 0.9; font-size: 1rem; }

/* ===== HAMBURGER BUTTON ===== */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 10px;
    transition: var(--transition);
    flex-shrink: 0;
}
.nav-hamburger:hover { background: #F0F4FF; }
.nav-hamburger span {
    display: block;
    height: 2.5px;
    background: var(--text);
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}
/* Animate to X */
.nav-hamburger--open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.nav-hamburger--open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger--open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ===== MOBILE DRAWER ===== */
.nav-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.nav-drawer--open {
    opacity: 1;
    pointer-events: all;
}
.nav-drawer-inner {
    position: absolute;
    top: 0;
    right: 0;
    width: min(300px, 85vw);
    height: 100%;
    background: var(--white);
    box-shadow: -8px 0 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 24px 16px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-drawer--open .nav-drawer-inner {
    transform: translateX(0);
}

.nav-drawer-greeting {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 8px 12px 12px;
    border-bottom: 1px solid #F0F0F0;
    margin-bottom: 4px;
}
.nav-drawer-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 14px;
    font-weight: 700;
    border-bottom: 1px solid #F0F0F0;
    margin-bottom: 4px;
    font-size: 1rem;
}

.nav-drawer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-decoration: none;
    transition: var(--transition);
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.nav-drawer-item:hover { background: #F0F4FF; color: var(--primary); }
.nav-drawer-item--highlight {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white !important;
    margin-top: 4px;
}
.nav-drawer-item--highlight:hover { opacity: 0.9; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.nav-drawer-item--btn { color: var(--text); }

/* theme toggle inside drawer */
.nav-drawer-inner .theme-toggle {
    align-self: flex-end;
    margin-bottom: 8px;
}

/* ===== RESPONSIVE: show hamburger, hide desktop nav ===== */
@media (max-width: 768px) {
    .nav-hamburger { display: flex; }
    .nav-actions    { display: none !important; }
    .nav-drawer     { display: block; }
    /* Prevent logo text overflow */
    .nav-logo { font-size: 1.2rem; }
    .logo-icon { font-size: 1.4rem; }
}

/* Dark mode drawer */
[data-theme="dark"] .nav-drawer-inner {
    background: #1A1D27;
    border-left: 1px solid #2D3148;
}
[data-theme="dark"] .nav-drawer-item:hover { background: #252836; }
[data-theme="dark"] .nav-hamburger:hover { background: #252836; }
[data-theme="dark"] .nav-hamburger span { background: var(--text); }

/* ============================================================
   DARK MODE  COMPREHENSIVE OVERRIDES (all new components)
   ============================================================ */

/*  Surfaces chung  */
[data-theme="dark"] .overview-card,
[data-theme="dark"] .dashboard-section,
[data-theme="dark"] .subject-tabs-content,
[data-theme="dark"] .level-progress-card,
[data-theme="dark"] .home-child-card,
[data-theme="dark"] .home-no-children,
[data-theme="dark"] .home-guest-inner,
[data-theme="dark"] .typing-container,
[data-theme="dark"] .game-container,
[data-theme="dark"] .result-screen,
[data-theme="dark"] .guide-container,
[data-theme="dark"] .subject-progress-card,
[data-theme="dark"] .admin-table-wrapper {
    background: #1E2130;
    border-color: #2D3148;
}

/*  Overview cards  */
[data-theme="dark"] .overview-card { box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
[data-theme="dark"] .overview-val  { color: var(--text); }
[data-theme="dark"] .overview-bar  { background: #2D3148; }

/*  Subject tabs nav  */
[data-theme="dark"] .subject-tab-btn {
    background: #252836;
    color: var(--text-muted);
    box-shadow: none;
}
[data-theme="dark"] .subject-tab-btn:hover  { background: #2D3148; color: var(--primary); }
[data-theme="dark"] .subject-tab-btn.active {
    background: #1E2130;
    color: var(--primary);
    border-bottom-color: var(--primary);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
}
[data-theme="dark"] .subject-tabs-content { box-shadow: 0 8px 32px rgba(0,0,0,0.4); }

/*  Subject tab panel body  */
[data-theme="dark"] .stp-overall-bar-wrap { background: #1E2130; }
[data-theme="dark"] .stp-overall-bar      { background: #2D3148; }
[data-theme="dark"] .stp-not-started      { color: var(--text-muted); }
[data-theme="dark"] .stp-recent           { border-top-color: #2D3148; }
[data-theme="dark"] .stp-recent-title     { color: var(--text); }

/*  Level progress cards  */
[data-theme="dark"] .level-progress-card          { border-color: #2D3148; background: #1E2130; }
[data-theme="dark"] .lpc--done                    { border-color: #1A3A2A; background: #141F1A; }
[data-theme="dark"] .lpc--progress                { border-color: #1A2A3A; background: #141820; }
[data-theme="dark"] .lpc-bar                      { background: #2D3148; }
[data-theme="dark"] .lpc-name                     { color: var(--text); }
[data-theme="dark"] .lpc-lessons                  { color: var(--text-muted); }
[data-theme="dark"] .lpc-badge--locked            { background: #252836; color: var(--text-muted); }
[data-theme="dark"] .lpc-dot--empty               { background: #2D3148; }

/*  Activity list  */
[data-theme="dark"] .activity-row                 { border-bottom-color: #2D3148; }
[data-theme="dark"] .activity-row:hover           { background: #252836; }
[data-theme="dark"] .activity-title               { color: var(--text); }
[data-theme="dark"] .activity-badge--done         { background: #1A3A2A; color: #6EE7B7; }
[data-theme="dark"] .activity-badge--progress     { background: #3A2E0A; color: #FCD34D; }

/*  Dashboard header & streak  */
[data-theme="dark"] .dashboard-child-info h1 { color: var(--text); }

/*  Lesson cards  */
[data-theme="dark"] .lesson-card              { background: #1E2130; border-color: #2D3148; }
[data-theme="dark"] .lesson-card:hover        { box-shadow: 0 16px 48px rgba(0,0,0,0.5); }
[data-theme="dark"] .lesson-card--done        { border-left-color: #43e97b; background: #141F1A; }
[data-theme="dark"] .lesson-card--progress    { border-left-color: var(--primary); background: #141820; }
[data-theme="dark"] .lesson-info h3           { color: var(--text); }
[data-theme="dark"] .lesson-info p            { color: var(--text-muted); }
[data-theme="dark"] .lesson-score-req         { background: #252836; color: var(--text-muted); }
[data-theme="dark"] .lesson-count             { background: var(--primary); }
[data-theme="dark"] .lesson-progress-text     { color: var(--text-muted); }

/*  Level overall bar  */
[data-theme="dark"] .level-overall-bar        { background: #2D3148; }
[data-theme="dark"] .level-requirements-bar   { background: #1A2A3A; border-color: #2D4A6A; color: #93C5FD; }
[data-theme="dark"] .lrb-tag                  { background: #2B4A8A; }

/*  Locked alert  */
[data-theme="dark"] .locked-alert             { background: #3A2E0A; border-color: #5A4A1A; color: #FCD34D; }

/*  Level cards (subject index)  */
[data-theme="dark"] .level-card--locked       { opacity: 0.5; }

/*  Typing game  */
[data-theme="dark"] .typing-word-display      { background: #252836; }
[data-theme="dark"] .typing-text-display      { background: #252836; color: var(--text); }
[data-theme="dark"] .typing-input            {
    background: #252836;
    border-color: #3D4266;
    color: var(--text);
}
[data-theme="dark"] .typing-input:focus       { background: #2A2D40; }
[data-theme="dark"] .typing-input--error      { background: #3A1A1A; }
[data-theme="dark"] .typing-hint              { color: var(--text-muted); }
[data-theme="dark"] .typing-stats-bar         { color: var(--text); }
[data-theme="dark"] .typing-progress-bar      { background: #2D3148; }
[data-theme="dark"] .tc-pending               { color: #4A5568; }

/*  Guide  */
[data-theme="dark"] .guide-step               { background: #252836; }
[data-theme="dark"] .guide-step-text          { color: var(--text); }
[data-theme="dark"] .guide-keyboard-visual    { background: #1A1D27; }
[data-theme="dark"] .kb-key                   { background: #2D3148; color: var(--text-muted); }

/*  Game canvas  */
[data-theme="dark"] .game-hud                 { background: #252836; }
[data-theme="dark"] .game-input {
    background: #252836;
    border-color: #3D4266;
    color: var(--text);
}

/*  Result screen  */
[data-theme="dark"] .result-title             { color: var(--text); }
[data-theme="dark"] .result-stat-val          { color: var(--primary); }
[data-theme="dark"] .result-stat-label        { color: var(--text-muted); }

/*  Home children section  */
[data-theme="dark"] .home-child-card          { background: #1E2130; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
[data-theme="dark"] .home-child-card--add     { background: #252836; border-color: #3D4266; }
[data-theme="dark"] .home-child-card--add:hover { background: #2D3148; border-color: var(--primary); }
[data-theme="dark"] .home-pin-form            { background: #1E2130; }
[data-theme="dark"] .home-pin-input           { background: #252836; border-color: #3D4266; color: var(--text); }
[data-theme="dark"] .hcc-name                 { color: var(--text); }
[data-theme="dark"] .hcc-status               { background: #252836; color: var(--primary); }
[data-theme="dark"] .hcc-status--pin          { background: #3A2E0A; color: #FCD34D; }
[data-theme="dark"] .home-children-header h2  { color: var(--text); }
[data-theme="dark"] .home-children-header p   { color: var(--text-muted); }
[data-theme="dark"] .home-no-children h2      { color: var(--text); }
[data-theme="dark"] .home-no-children p       { color: var(--text-muted); }

/*  Guest select page  */
[data-theme="dark"] .subjects-grid .subject-card { box-shadow: 0 8px 32px rgba(0,0,0,0.4); }

/*  Subject progress card (dashboard)  */
[data-theme="dark"] .subject-progress-card    { border-color: #2D3148; }
[data-theme="dark"] .sp-body                  { background: #252836; }
[data-theme="dark"] .sp-progress-bar          { background: #2D3148; }
[data-theme="dark"] .sp-level-bar             { background: #2D3148; }
[data-theme="dark"] .sp-level-name            { color: var(--text); }
[data-theme="dark"] .sp-level-stat            { color: var(--text-muted); }

/*  Admin form section title  */
[data-theme="dark"] .form-section-title       { border-top-color: #2D3148; color: var(--text-muted); }

/*  Levels grid (subject page)  */
[data-theme="dark"] .section-header p         { color: var(--text-muted); }

/*  Child profile select page  */
[data-theme="dark"] .child-profile-card       { background: #1E2130; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
[data-theme="dark"] .child-add-card           { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.2); }
[data-theme="dark"] .pin-input {
    background: #252836;
    border-color: #3D4266;
    color: var(--text);
}

/*  Profile page  */
[data-theme="dark"] .profile-header           { background: #1E2130; border-color: #2D3148; }
[data-theme="dark"] .avatar-placeholder       { box-shadow: none; }

/*  Children list (manage)  */
[data-theme="dark"] .child-list-card          { background: #1E2130; }
[data-theme="dark"] .child-list-info strong   { color: var(--text); }

/*  Pagination  */
[data-theme="dark"] .page-btn                 { background: #1E2130; color: var(--text); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/*  Admin users  */
[data-theme="dark"] .badge-admin-sm           { opacity: 0.9; }
[data-theme="dark"] .row-locked td            { opacity: 0.4; }

/*  Typing page header  */
[data-theme="dark"] .typing-completed-badge   { background: rgba(255,255,255,0.15); }
[data-theme="dark"] .typing-lesson-num        { background: rgba(255,255,255,0.2); }

/*  Subject hero (back link)  */
[data-theme="dark"] .back-link                { color: rgba(255,255,255,0.75); }
[data-theme="dark"] .back-link:hover          { color: white; }

/*  Lessons header  */
[data-theme="dark"] .lessons-header h2        { color: var(--text); }

/*  Empty state  */
[data-theme="dark"] .empty-state h2           { color: var(--text); }
[data-theme="dark"] .empty-state p            { color: var(--text-muted); }

/*  CTA section stays gradient  no override needed  */

/*  Home guest section  */
[data-theme="dark"] .home-guest-inner         { background: #1E2130; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
[data-theme="dark"] .home-guest-text h2       { color: var(--text); }
[data-theme="dark"] .home-guest-text p        { color: var(--text-muted); }
[data-theme="dark"] .home-feature-list li     { color: var(--text); }

/* ===== DARK MODE  GRADIENT SURFACES ===== */

/* Định nghĩa gradient variables cho từng theme */
:root {
    --gradient-hero:    linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-typing:  linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-child-select: linear-gradient(160deg, #a18cd1 0%, #fbc2eb 100%);
}

[data-theme="dark"] {
    --gradient-hero:    linear-gradient(135deg, #2a2d4a 0%, #3a2d52 100%);
    --gradient-typing:  linear-gradient(135deg, #2a2d4a 0%, #3a2d52 100%);
    --gradient-child-select: linear-gradient(160deg, #2d2a40 0%, #3a2d3a 100%);
}

/* Áp dụng variables */
[data-theme="dark"] .hero,
[data-theme="dark"] .cta-section,
[data-theme="dark"] .login-page,
[data-theme="dark"] .subject-select-header {
    background: var(--gradient-hero);
}

[data-theme="dark"] .subject-typing {
    background: var(--gradient-typing);
}

[data-theme="dark"] .child-select-page {
    background: var(--gradient-child-select);
}

/* subject-typing dùng làm header trong typing page  cần text vẫn đọc được */
[data-theme="dark"] .stp-header.subject-typing,
[data-theme="dark"] .subject-hero.subject-typing,
[data-theme="dark"] .typing-header.subject-typing {
    background: var(--gradient-typing);
}

/* Các gradient subject card giữ nguyên (chúng đã đủ tối/sáng tự nhiên)
   chỉ giảm độ bão hòa nhẹ trên dark mode */
[data-theme="dark"] .subject-card {
    filter: brightness(0.85) saturate(0.9);
}
[data-theme="dark"] .subject-card:hover {
    filter: brightness(0.95) saturate(1);
}

/* Level cards (subject index)  giữ gradient nhưng tối hơn */
[data-theme="dark"] .level-card:not(.level-card--locked) {
    filter: brightness(0.8) saturate(0.85);
}
[data-theme="dark"] .level-card:not(.level-card--locked):hover {
    filter: brightness(0.9) saturate(0.95);
}

/* Subject hero banner trên trang môn học */
[data-theme="dark"] .subject-hero {
    filter: brightness(0.8) saturate(0.85);
}

/* stp-header (dashboard tab panel header) */
[data-theme="dark"] .stp-header {
    filter: brightness(0.8) saturate(0.85);
}

/* sp-header (subject progress card header trong dashboard) */
[data-theme="dark"] .sp-header {
    filter: brightness(0.8) saturate(0.85);
}

/* ===== FLUID LAYOUT SYSTEM ===== */

/*
 * Thay thế toàn bộ max-width cứng bằng fluid container.
 * --container-main:   nội dung chính (nav, subjects, dashboard...)
 * --container-narrow: form, lesson list, profile...
 * --container-wide:   admin, typing game...
 *
 * clamp(min, preferred, max):
 *   - min: không bao giờ nhỏ hơn
 *   - preferred: 90vw  co theo viewport
 *   - max: không bao giờ lớn hơn
 */
:root {
    --container-main:   clamp(320px, 92vw, 1400px);
    --container-wide:   clamp(320px, 94vw, 1600px);
    --container-narrow: clamp(320px, 88vw, 860px);
    --container-form:   clamp(320px, 80vw, 720px);
}

/* Nav */
.nav-container {
    max-width: var(--container-main);
    padding-inline: clamp(12px, 3vw, 40px);
}

/* Alerts */
.alert {
    max-width: var(--container-main);
    margin-inline: auto;
}

/* Subjects section */
.subjects-section {
    max-width: var(--container-main);
    padding-inline: clamp(12px, 3vw, 40px);
}

/* Lessons container */
.lessons-container {
    max-width: var(--container-narrow);
    padding-inline: clamp(12px, 3vw, 32px);
}

/* Levels grid  fluid columns */
.levels-grid {
    max-width: var(--container-narrow);
}

/* Admin page */
.admin-page {
    max-width: var(--container-wide);
    padding-inline: clamp(12px, 3vw, 40px);
}

/* Form card */
.form-card {
    max-width: var(--container-form);
}

/* Profile page */
.profile-page {
    max-width: var(--container-main);
    padding-inline: clamp(12px, 3vw, 40px);
}

/* Children profiles grid */
.child-profiles-grid {
    max-width: var(--container-main);
}

/* Children list (manage) */
.children-list { max-width: var(--container-narrow); }

/* Typing game */
.typing-game-area {
    max-width: var(--container-narrow);
    padding-inline: clamp(12px, 3vw, 32px);
}
.typing-nav {
    max-width: var(--container-narrow);
    padding-inline: clamp(12px, 3vw, 32px);
}

/* Dashboard */
.dashboard-page {
    max-width: var(--container-wide);
    padding-inline: clamp(12px, 3vw, 40px);
}

/* Locked alert */
.locked-alert {
    max-width: var(--container-narrow);
    margin-inline: auto;
}

/* Home sections */
.home-guest    { max-width: var(--container-main); padding-inline: clamp(12px, 3vw, 40px); }
.home-children { max-width: var(--container-main); padding-inline: clamp(12px, 3vw, 40px); }

/* Subjects grid  thêm cột trên màn hình rộng */
.subjects-grid {
    grid-template-columns: repeat(auto-fill, minmax(clamp(220px, 22vw, 320px), 1fr));
}

/* Subject progress list trong dashboard  2 cột trên màn hình rộng */
@media (min-width: 1200px) {
    .subject-progress-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

/* Level progress cards  thêm cột trên màn hình rộng */
.stp-levels-grid {
    grid-template-columns: repeat(auto-fill, minmax(clamp(240px, 25vw, 340px), 1fr));
}

/* Dashboard overview  luôn 4 cột trên màn hình đủ rộng */
@media (min-width: 900px) {
    .dashboard-overview {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1200px) {
    .dashboard-overview {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Admin table  full width trên màn hình rộng */
@media (min-width: 1400px) {
    .admin-table th, .admin-table td {
        padding-inline: 20px;
    }
}

/* Hero  padding thoáng hơn trên màn hình rộng */
.hero {
    padding-inline: clamp(24px, 6vw, 120px);
}

/* Subject hero */
.subject-hero {
    padding-inline: clamp(24px, 6vw, 80px);
}

/* ===== CHILD PROFILE EDIT TABS ===== */
.edit-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.edit-tab {
    padding: 10px 24px;
    border-radius: 50px;
    border: 2px solid #E2E8F0;
    background: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
}
.edit-tab--active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
    color: white;
}

/* ===== SUBJECT ACCESS CARDS ===== */
.subject-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.subject-access-card {
    background: white;
    border: 2px solid #E2E8F0;
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: var(--transition);
}
.subject-access-card--on {
    border-color: var(--primary);
    box-shadow: 0 4px 16px rgba(108,99,255,0.12);
}
.sac-header { display: flex; align-items: center; }
.sac-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    width: 100%;
}
.sac-toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.sac-icon { font-size: 1.5rem; }
.sac-name { flex: 1; }
.sac-body { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.sac-label { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); }
.sac-select { font-size: 0.9rem; padding: 8px 12px; }

[data-theme="dark"] .edit-tab { background: #1E2130; border-color: #3D4266; color: var(--text-muted); }
[data-theme="dark"] .subject-access-card { background: #1E2130; border-color: #3D4266; }
[data-theme="dark"] .subject-access-card--on { border-color: var(--primary); }

/* Subject access — non-sequential level checkboxes */
.sac-level-checks { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.sac-level-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.sac-level-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.sac-mode-badge {
    font-size: 0.7rem;
    font-weight: 700;
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: #1a5c3a;
    padding: 2px 8px;
    border-radius: 50px;
    margin-left: 4px;
}
