:root {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-accent: #007aff;
    --accent: #007aff;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(51, 51, 51, 0.5);
    --shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    --glow: 0 0 40px rgba(0, 122, 255, 0.3);
    --transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* APPLE ID LOGIN STYLES */
.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
    from {
        background: rgba(0, 0, 0, 0);
        backdrop-filter: blur(0px);
    }
    to {
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(4px);
    }
}

.login-modal {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 48px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 120px rgba(0, 0, 0, 0.2);
    animation: slideUpLogin 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(200, 200, 200, 0.2);
}

@keyframes slideUpLogin {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.45s ease-out 0.1s backwards;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    animation: scaleInLogo 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleInLogo {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.login-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.login-form {
    animation: fadeInUp 0.45s ease-out 0.2s backwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-group {
    position: relative;
    margin-bottom: 16px;
    animation: slideInInput 0.45s ease-out backwards;
}

.input-group:nth-child(1) { animation-delay: 0.25s; }
.input-group:nth-child(2) { animation-delay: 0.3s; }

@keyframes slideInInput {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.login-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: all 0.2s ease;
    outline: none;
}

.login-input:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    transform: translateY(-2px);
}

.login-input::placeholder {
    color: transparent;
}

.input-label {
    position: absolute;
    top: 14px;
    left: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.login-input:focus ~ .input-label,
.login-input:not(:placeholder-shown) ~ .input-label {
    top: -8px;
    left: 12px;
    background: var(--bg-secondary);
    padding: 0 4px;
    color: var(--accent);
    font-size: 11px;
}

.show-password-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    padding: 8px;
}

.show-password-btn:hover {
    opacity: 1;
}

.show-password-btn:active {
    transform: translateY(-50%) scale(0.9);
}

.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0 24px 0;
    animation: fadeInUp 0.45s ease-out 0.35s backwards;
}

.remember-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    padding: 8px 12px;
    border-radius: 10px;
    margin-left: -12px;
}

.remember-checkbox:hover {
    background: rgba(0, 122, 255, 0.08);
}

.remember-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.remember-checkbox input[type="checkbox"]:hover {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.remember-checkbox input[type="checkbox"]:checked {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.remember-checkbox span {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.2s ease;
}

.remember-checkbox:hover span {
    color: var(--text-primary);
}

/* Dark mode checkbox styling */
body.dark-mode .remember-checkbox:hover {
    background: rgba(0, 122, 255, 0.12);
}

body.dark-mode .remember-checkbox input[type="checkbox"]:hover {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

body.dark-mode .remember-checkbox input[type="checkbox"]:checked {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25);
}

.forgot-password-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.forgot-password-btn:hover {
    opacity: 0.7;
}

.login-submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: fadeInUp 0.45s ease-out 0.4s backwards;
}

.login-submit-btn:hover {
    background: #0051d5;
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 122, 255, 0.3);
}

.login-submit-btn:active {
    transform: translateY(0);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
    animation: fadeInUp 0.45s ease-out 0.45s backwards;
}

.login-footer p {
    margin: 0;
}

.signup-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    transition: opacity 0.2s ease;
    font-weight: 500;
}

.signup-link:hover {
    opacity: 0.7;
}

/* GUEST MODE BUTTON */
.guest-mode-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 12px;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.guest-mode-btn:hover {
    background: rgba(0, 122, 255, 0.1);
    transform: translateY(-2px);
}

.guest-mode-btn:active {
    transform: translateY(0);
}

body.dark-mode .guest-mode-btn:hover {
    background: rgba(0, 122, 255, 0.15);
}

/* PROFILE SIDEBAR SECTION */
.sidebar-divider {
    display: none;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin-top: auto;
    border-top: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
}

.sidebar-profile:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .sidebar-profile:hover {
    background: rgba(255, 255, 255, 0.05);
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    border: 2px solid var(--accent);
    transition: all 0.2s ease;
}

.sidebar-profile:hover .profile-avatar {
    transform: scale(1.05);
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.profile-edit-btn {
    font-size: 12px;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), pointer-events 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 0;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(1) translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
    display: inline-block;
}

/* Show on desktop hover */
.sidebar-profile:hover .profile-edit-btn {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Show on mobile when sidebar is open */
@media (max-width: 768px) {
    .sidebar.open .sidebar-profile .profile-edit-btn {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* PROFILE EDITOR MODAL */
.profile-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeInOverlay 0.3s ease-out;
}

.profile-editor-overlay.active {
    display: flex;
}

.profile-editor-modal {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 700px;
    box-shadow: 0 25px 120px rgba(0, 0, 0, 0.2);
    animation: slideUpLogin 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(200, 200, 200, 0.2);
    position: relative;
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .profile-editor-modal {
        max-width: 600px;
        padding: 30px;
    }
}

@media (max-width: 600px) {
    .profile-editor-modal {
        max-width: 90vw;
        padding: 25px;
    }
}

.profile-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease, transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 4px;
}

.profile-modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.profile-modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

.profile-modal-close.animate-close {
    animation: closeButtonRotate 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes closeButtonRotate {
    from {
        transform: rotate(0deg) scale(1);
        color: var(--text-secondary);
    }
    to {
        transform: rotate(90deg) scale(0.95);
        color: var(--text-primary);
    }
}

.profile-editor-modal h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 28px 0;
    text-align: center;
}

/* Avatar Section */
.avatar-section {
    text-align: center;
    margin-bottom: 32px;
}

.avatar-display {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 16px;
    border: 3px solid var(--accent);
    transition: all 0.2s ease;
}

.avatar-display:hover {
    transform: scale(1.05);
}

.avatar-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.avatar-btn {
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.avatar-btn:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Emoji Picker */
.emoji-picker {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.emoji-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
}

.emoji-item:hover {
    background: var(--accent);
    transform: scale(1.1);
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.profile-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: all 0.2s ease;
    outline: none;
}

.profile-input:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.char-count {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    text-align: right;
}

.form-divider {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 24px 0 16px 0;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

/* Password Fields Row - Horizontal Layout */
.password-fields-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 750px) {
    .password-fields-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 500px) {
    .password-fields-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.password-fields-row .form-group {
    margin-bottom: 0;
}

.password-fields-row .profile-input {
    font-size: 14px;
    padding: 10px 12px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.btn-cancel, .btn-save {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.btn-cancel {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-cancel:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-save {
    background: var(--accent);
    color: white;
}

.btn-save:hover {
    background: #0051d5;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 122, 255, 0.3);
}

.btn-save:active {
    transform: translateY(0);
}

/* Profile Footer - Logout Button */
.profile-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    text-align: center;
}

.btn-logout {
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.btn-logout:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 122, 255, 0.3);
    opacity: 0.9;
}

.btn-logout:active {
    transform: translateY(0);
}

body.dark-mode .btn-logout:hover {
    box-shadow: 0 6px 12px rgba(0, 122, 255, 0.4);
}

/* Settings Modal Styles */
.settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeInOverlay 0.3s ease-out;
}

.settings-modal-overlay.active {
    display: flex;
}

.settings-modal {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 25px 120px rgba(0, 0, 0, 0.2);
    animation: slideUpLogin 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(200, 200, 200, 0.2);
    position: relative;
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.settings-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease, transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 4px;
}

.settings-modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.settings-modal-close:active {
    transform: rotate(90deg) scale(0.95);
}

.settings-modal-close.animate-close {
    animation: closeButtonRotate 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.settings-modal h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 28px 0;
    text-align: center;
}

/* Dark mode support */
body.dark-mode .profile-editor-modal {
    background: #1d1d1f;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .avatar-display {
    background: #424245;
}

body.dark-mode .profile-input {
    background: #424245;
    border-color: rgba(255, 255, 255, 0.2);
    color: #f5f5f7;
}

body.dark-mode .profile-input:focus {
    background: #505052;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

body.dark-mode .emoji-picker {
    background: #424245;
}

body.dark-mode .emoji-item {
    background: #505052;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .avatar-btn {
    background: #424245;
    border-color: rgba(255, 255, 255, 0.2);
    color: #f5f5f7;
}

body.dark-mode .avatar-btn:hover {
    background: #505052;
}

body.dark-mode .btn-cancel {
    background: #424245;
    color: #f5f5f7;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .btn-cancel:hover {
    background: #505052;
}

body.dark-mode .settings-modal {
    background: #1d1d1f;
    border-color: rgba(255, 255, 255, 0.1);
}



/* Dark mode login styles */
body.dark-mode .login-modal {
    background: #1d1d1f;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .login-input {
    background: #424245;
    border-color: rgba(255, 255, 255, 0.2);
    color: #f5f5f7;
}

body.dark-mode .login-input:focus {
    background: #505052;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

body.dark-mode .input-label {
    color: #a1a1a6;
}

body.dark-mode .login-input:focus ~ .input-label,
body.dark-mode .login-input:not(:placeholder-shown) ~ .input-label {
    background: #1d1d1f;
    color: var(--accent);
}

/* Feature detection for animation support */
@supports not (transform: translateZ(0)) {
    :root {
        --transition: all 0.25s ease;
    }
    .section {
        will-change: auto !important;
    }
    .sidebar-icon, .step-card, .subject-card, .lesson-card {
        will-change: auto !important;
    }
}

/* Disable animations on low-performance devices */
@media (max-width: 480px) and (max-device-pixel-ratio: 1) {
    :root {
        --transition: none;
    }
    .section {
        animation: none !important;
        will-change: auto !important;
    }
    .sidebar-icon, .step-card, .subject-card, .lesson-card {
        animation: none !important;
        will-change: auto !important;
    }
}

/* Simplified fallback animations for older browsers */
@supports not (animation: slideInFromRight 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94)) {
    .section.slide-enter {
        opacity: 0;
        transform: translateX(50px);
        transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    }

    .section.swipe-enter {
        opacity: 0;
        transform: translateY(50px);
        transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    }

    .section.surf-enter {
        opacity: 0;
        transform: translateX(30px);
        transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    }

    .section.wave-enter {
        opacity: 0;
        transform: translateY(-30px);
        transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    }

    .section.slide-enter.active,
    .section.swipe-enter.active,
    .section.surf-enter.active,
    .section.wave-enter.active {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

/* Basic fade-in for elements when advanced animations are disabled */
@supports not (animation: bounceInUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1)) {
    .step-card.visible,
    .subject-card.visible,
    .lesson-card.visible,
    .setting-group.visible {
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    }

    .step-card.visible.active,
    .subject-card.visible.active,
    .lesson-card.visible.active,
    .setting-group.visible.active {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fallback for hero elements */
@supports not (animation: slideUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94)) {
    .hero h1.visible,
    .hero p.visible {
        opacity: 0;
        transform: translateY(30px);
        transition: opacity 0.6s ease-out 0.2s, transform 0.6s ease-out 0.2s;
    }

    .hero h1.visible.active,
    .hero p.visible.active {
        opacity: 1;
        transform: translateY(0);
    }
}

.dark-mode {
    --bg-primary: #1d1d1f;
    --bg-secondary: #2d2d2f;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --glass-bg: rgba(45, 45, 47, 0.8);
    --glass-border: rgba(200, 200, 200, 0.3);
    --shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
    overflow-x: hidden;
}

.dark-mode .floating-chat-toggle {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark-mode .sidebar-toggle {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark-mode .setting-group {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark-mode .chat-container {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.light-mode {
    overflow-x: hidden;
}

.light-mode .setting-group {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.light-mode .chat-container {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: var(--transition);
    width: 100%;
}

body.inter {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body.system {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 80px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 0 16px 16px 0;
    box-shadow: var(--shadow);
    transition: var(--transition);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    gap: 40px;
    animation: scaleIn 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform, width;
    transform: translateZ(0);
}

.sidebar:hover {
    width: 200px;
}

.sidebar-icon {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 12px;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    margin: 0 10px;
    animation: slideInLeft 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.sidebar-icon:nth-child(1) { animation-delay: 0.05s; }
.sidebar-icon:nth-child(2) { animation-delay: 0.1s; }
.sidebar-icon:nth-child(3) { animation-delay: 0.15s; }
.sidebar-icon:nth-child(4) { animation-delay: 0.2s; }
.sidebar-icon:nth-child(5) { animation-delay: 0.25s; }
.sidebar-icon:nth-child(6) { animation-delay: 0.3s; }
.sidebar-icon:nth-child(7) { animation-delay: 0.35s; }

.sidebar-icon:hover {
    background: var(--accent);
    color: white;
    transform: translateX(5px) scale(1.05) translateZ(0);
}

.sidebar-icon .icon {
    font-size: 24px;
    margin-right: 12px;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-icon .label {
    font-size: 14px;
    opacity: 0;
    transition: var(--transition);
    white-space: nowrap;
}

.sidebar:hover .sidebar-icon .label {
    opacity: 1;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px) translateZ(0); }
    to { opacity: 1; transform: translateX(0) translateZ(0); }
}

.main-content {
    margin-left: 80px;
    transition: var(--transition);
}

.sidebar:hover ~ .main-content {
    margin-left: 200px;
}

.section {
    min-height: 100vh;
    padding: 80px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    will-change: transform, opacity;
    backface-visibility: hidden;
    perspective: 1000px;
    width: 100%;
    overflow-x: hidden;
}

.home {
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(0, 122, 255, 0.1) 100%);
    position: relative;
    overflow: hidden;
}

.hero {
    text-align: center;
    z-index: 2;
    position: relative;
}

.hero h1 {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent), #ff9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0;
    transform: translateY(50px) translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.hero h1.visible {
    animation: slideUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.hero p {
    font-size: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(50px) translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.hero p.visible {
    animation: slideUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s both;
}

.blob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: blobAnimation 8s ease-in-out infinite;
    z-index: 1;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px) translateZ(0); }
    to { opacity: 1; transform: translateY(0) translateZ(0); }
}

@keyframes blobAnimation {
    0%, 100% { transform: translate(-50%, -50%) scale(1) translateZ(0); }
    50% { transform: translate(-50%, -50%) scale(1.1) translateZ(0); }
}

.how-to-use {
    background: var(--bg-secondary);
    animation: fadeInUp 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.how-to-use h2 {
    text-align: center;
    margin-bottom: 80px;
    font-size: 2.5rem;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.step-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 32px 16px;
    box-shadow: var(--shadow);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 1;
    transform: translateY(0) translateZ(0);
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    perspective: 1000px;
}

.step-card.visible {
    animation: zoomIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 1;
}

.step-card:hover {
    transform: translateY(-8px) translateZ(0);
    box-shadow: var(--shadow), var(--glow);
}

.step-card .icon {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

.step-card h3 {
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.step-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(50px) translateZ(0); }
    to { opacity: 1; transform: translateY(0) translateZ(0); }
}

@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.85) translateZ(0); }
    60% { opacity: 1; transform: scale(1.03) translateZ(0); }
    100% { opacity: 1; transform: scale(1) translateZ(0); }
}

@keyframes bounceInUp {
    0% { opacity: 0; transform: translateY(40px) scale(0.85) translateZ(0); }
    45% { opacity: 1; }
    60% { transform: translateY(-8px) scale(1.02) translateZ(0); }
    80% { transform: translateY(2px) scale(0.98) translateZ(0); }
    100% { opacity: 1; transform: translateY(0) scale(1) translateZ(0); }
}

@keyframes zoomIn {
    0% { opacity: 0; transform: scale(0.3) translateZ(0); }
    50% { opacity: 1; transform: scale(1.05) translateZ(0); }
    70% { transform: scale(0.9) translateZ(0); }
    100% { opacity: 1; transform: scale(1) translateZ(0); }
}

@keyframes fadeInLeft {
    0% { opacity: 0; transform: translateX(-50px) translateZ(0); }
    100% { opacity: 1; transform: translateX(0) translateZ(0); }
}

@keyframes fadeInRight {
    0% { opacity: 0; transform: translateX(50px) translateZ(0); }
    100% { opacity: 1; transform: translateX(0) translateZ(0); }
}

@keyframes slideInFromBottom {
    0% { opacity: 0; transform: translateY(100px) translateZ(0); }
    100% { opacity: 1; transform: translateY(0) translateZ(0); }
}

@keyframes rotateIn {
    0% { opacity: 0; transform: rotate(-180deg) scale(0.5) translateZ(0); }
    100% { opacity: 1; transform: rotate(0deg) scale(1) translateZ(0); }
}

@keyframes bounceInLeft {
    0% { opacity: 0; transform: translateX(-100px) scale(0.3) translateZ(0); }
    50% { opacity: 1; transform: translateX(-50px) scale(1.05) translateZ(0); }
    70% { transform: translateX(-10px) scale(0.9) translateZ(0); }
    100% { opacity: 1; transform: translateX(0) scale(1) translateZ(0); }
}

@keyframes bounceInRight {
    0% { opacity: 0; transform: translateX(100px) scale(0.3) translateZ(0); }
    50% { opacity: 1; transform: translateX(50px) scale(1.05) translateZ(0); }
    70% { transform: translateX(10px) scale(0.9) translateZ(0); }
    100% { opacity: 1; transform: translateX(0) scale(1) translateZ(0); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: var(--shadow); }
    50% { box-shadow: var(--shadow), 0 0 30px rgba(0, 122, 255, 0.6); }
}

/* Section Transition Animations */

@-webkit-keyframes slideInFromRight {
    from { opacity: 0; -webkit-transform: translateX(100px) translateZ(0); transform: translateX(100px) translateZ(0); }
    to { opacity: 1; -webkit-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
}

@-moz-keyframes slideInFromRight {
    from { opacity: 0; -moz-transform: translateX(100px) translateZ(0); transform: translateX(100px) translateZ(0); }
    to { opacity: 1; -moz-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
}

@-ms-keyframes slideInFromRight {
    from { opacity: 0; -ms-transform: translateX(100px) translateZ(0); transform: translateX(100px) translateZ(0); }
    to { opacity: 1; -ms-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
}

@keyframes slideInFromRight {
    from { opacity: 0; transform: translateX(100px) translateZ(0); }
    to { opacity: 1; transform: translateX(0) translateZ(0); }
}

@-webkit-keyframes slideOutToLeft {
    from { opacity: 1; -webkit-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
    to { opacity: 0; -webkit-transform: translateX(-100px) translateZ(0); transform: translateX(-100px) translateZ(0); }
}

@-moz-keyframes slideOutToLeft {
    from { opacity: 1; -moz-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
    to { opacity: 0; -moz-transform: translateX(-100px) translateZ(0); transform: translateX(-100px) translateZ(0); }
}

@-ms-keyframes slideOutToLeft {
    from { opacity: 1; -ms-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
    to { opacity: 0; -ms-transform: translateX(-100px) translateZ(0); transform: translateX(-100px) translateZ(0); }
}

@keyframes slideOutToLeft {
    from { opacity: 1; transform: translateX(0) translateZ(0); }
    to { opacity: 0; transform: translateX(-100px) translateZ(0); }
}

@-webkit-keyframes swipeInFromBottom {
    from { opacity: 0; -webkit-transform: translateY(80px) scaleY(0.9) translateZ(0); transform: translateY(80px) scaleY(0.9) translateZ(0); }
    to { opacity: 1; -webkit-transform: translateY(0) scaleY(1) translateZ(0); transform: translateY(0) scaleY(1) translateZ(0); }
}

@-moz-keyframes swipeInFromBottom {
    from { opacity: 0; -moz-transform: translateY(80px) scaleY(0.9) translateZ(0); transform: translateY(80px) scaleY(0.9) translateZ(0); }
    to { opacity: 1; -moz-transform: translateY(0) scaleY(1) translateZ(0); transform: translateY(0) scaleY(1) translateZ(0); }
}

@-ms-keyframes swipeInFromBottom {
    from { opacity: 0; -ms-transform: translateY(80px) scaleY(0.9) translateZ(0); transform: translateY(80px) scaleY(0.9) translateZ(0); }
    to { opacity: 1; -ms-transform: translateY(0) scaleY(1) translateZ(0); transform: translateY(0) scaleY(1) translateZ(0); }
}

@keyframes swipeInFromBottom {
    from { opacity: 0; transform: translateY(80px) scaleY(0.9) translateZ(0); }
    to { opacity: 1; transform: translateY(0) scaleY(1) translateZ(0); }
}

@-webkit-keyframes swipeOutToTop {
    from { opacity: 1; -webkit-transform: translateY(0) scaleY(1) translateZ(0); transform: translateY(0) scaleY(1) translateZ(0); }
    to { opacity: 0; -webkit-transform: translateY(-80px) scaleY(0.9) translateZ(0); transform: translateY(-80px) scaleY(0.9) translateZ(0); }
}

@-moz-keyframes swipeOutToTop {
    from { opacity: 1; -moz-transform: translateY(0) scaleY(1) translateZ(0); transform: translateY(0) scaleY(1) translateZ(0); }
    to { opacity: 0; -moz-transform: translateY(-80px) scaleY(0.9) translateZ(0); transform: translateY(-80px) scaleY(0.9) translateZ(0); }
}

@-ms-keyframes swipeOutToTop {
    from { opacity: 1; -ms-transform: translateY(0) scaleY(1) translateZ(0); transform: translateY(0) scaleY(1) translateZ(0); }
    to { opacity: 0; -ms-transform: translateY(-80px) scaleY(0.9) translateZ(0); transform: translateY(-80px) scaleY(0.9) translateZ(0); }
}

@keyframes swipeOutToTop {
    from { opacity: 1; transform: translateY(0) scaleY(1) translateZ(0); }
    to { opacity: 0; transform: translateY(-80px) scaleY(0.9) translateZ(0); }
}

@-webkit-keyframes surfInFromRight {
    0% { opacity: 0; -webkit-transform: translateX(120px) translateZ(0); transform: translateX(120px) translateZ(0); }
    70% { opacity: 1; -webkit-transform: translateX(-15px) translateZ(0); transform: translateX(-15px) translateZ(0); }
    100% { opacity: 1; -webkit-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
}

@-moz-keyframes surfInFromRight {
    0% { opacity: 0; -moz-transform: translateX(120px) translateZ(0); transform: translateX(120px) translateZ(0); }
    70% { opacity: 1; -moz-transform: translateX(-15px) translateZ(0); transform: translateX(-15px) translateZ(0); }
    100% { opacity: 1; -moz-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
}

@-ms-keyframes surfInFromRight {
    0% { opacity: 0; -ms-transform: translateX(120px) translateZ(0); transform: translateX(120px) translateZ(0); }
    70% { opacity: 1; -ms-transform: translateX(-15px) translateZ(0); transform: translateX(-15px) translateZ(0); }
    100% { opacity: 1; -ms-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
}

@keyframes surfInFromRight {
    0% { opacity: 0; transform: translateX(120px) translateZ(0); }
    70% { opacity: 1; transform: translateX(-15px) translateZ(0); }
    100% { opacity: 1; transform: translateX(0) translateZ(0); }
}

@-webkit-keyframes surfOutToLeft {
    0% { opacity: 1; -webkit-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
    70% { opacity: 1; -webkit-transform: translateX(-15px) translateZ(0); transform: translateX(-15px) translateZ(0); }
    100% { opacity: 0; -webkit-transform: translateX(-120px) translateZ(0); transform: translateX(-120px) translateZ(0); }
}

@-moz-keyframes surfOutToLeft {
    0% { opacity: 1; -moz-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
    70% { opacity: 1; -moz-transform: translateX(-15px) translateZ(0); transform: translateX(-15px) translateZ(0); }
    100% { opacity: 0; -moz-transform: translateX(-120px) translateZ(0); transform: translateX(-120px) translateZ(0); }
}

@-ms-keyframes surfOutToLeft {
    0% { opacity: 1; -ms-transform: translateX(0) translateZ(0); transform: translateX(0) translateZ(0); }
    70% { opacity: 1; -ms-transform: translateX(-15px) translateZ(0); transform: translateX(-15px) translateZ(0); }
    100% { opacity: 0; -ms-transform: translateX(-120px) translateZ(0); transform: translateX(-120px) translateZ(0); }
}

@keyframes surfOutToLeft {
    0% { opacity: 1; transform: translateX(0) translateZ(0); }
    70% { opacity: 1; transform: translateX(-15px) translateZ(0); }
    100% { opacity: 0; transform: translateX(-120px) translateZ(0); }
}

@-webkit-keyframes waveInFromTop {
    0% { opacity: 0; -webkit-transform: translateY(-80px) translateZ(0); transform: translateY(-80px) translateZ(0); }
    50% { opacity: 0.7; -webkit-transform: translateY(-30px) translateZ(0); transform: translateY(-30px) translateZ(0); }
    100% { opacity: 1; -webkit-transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0); }
}

@-moz-keyframes waveInFromTop {
    0% { opacity: 0; -moz-transform: translateY(-80px) translateZ(0); transform: translateY(-80px) translateZ(0); }
    50% { opacity: 0.7; -moz-transform: translateY(-30px) translateZ(0); transform: translateY(-30px) translateZ(0); }
    100% { opacity: 1; -moz-transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0); }
}

@-ms-keyframes waveInFromTop {
    0% { opacity: 0; -ms-transform: translateY(-80px) translateZ(0); transform: translateY(-80px) translateZ(0); }
    50% { opacity: 0.7; -ms-transform: translateY(-30px) translateZ(0); transform: translateY(-30px) translateZ(0); }
    100% { opacity: 1; -ms-transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0); }
}

@keyframes waveInFromTop {
    0% { opacity: 0; transform: translateY(-80px) translateZ(0); }
    50% { opacity: 0.7; transform: translateY(-30px) translateZ(0); }
    100% { opacity: 1; transform: translateY(0) translateZ(0); }
}

@-webkit-keyframes waveOutToBottom {
    0% { opacity: 1; -webkit-transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0); }
    50% { opacity: 0.7; -webkit-transform: translateY(30px) translateZ(0); transform: translateY(30px) translateZ(0); }
    100% { opacity: 0; -webkit-transform: translateY(80px) translateZ(0); transform: translateY(80px) translateZ(0); }
}

@-moz-keyframes waveOutToBottom {
    0% { opacity: 1; -moz-transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0); }
    50% { opacity: 0.7; -moz-transform: translateY(30px) translateZ(0); transform: translateY(30px) translateZ(0); }
    100% { opacity: 0; -moz-transform: translateY(80px) translateZ(0); transform: translateY(80px) translateZ(0); }
}

@-ms-keyframes waveOutToBottom {
    0% { opacity: 1; -ms-transform: translateY(0) translateZ(0); transform: translateY(0) translateZ(0); }
    50% { opacity: 0.7; -ms-transform: translateY(30px) translateZ(0); transform: translateY(30px) translateZ(0); }
    100% { opacity: 0; -ms-transform: translateY(80px) translateZ(0); transform: translateY(80px) translateZ(0); }
}

@keyframes waveOutToBottom {
    0% { opacity: 1; transform: translateY(0) translateZ(0); }
    50% { opacity: 0.7; transform: translateY(30px) translateZ(0); }
    100% { opacity: 0; transform: translateY(80px) translateZ(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Section animation classes - GPU accelerated */
.section.slide-enter {
    -webkit-animation: slideInFromRight 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -moz-animation: slideInFromRight 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation: slideInFromRight 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -webkit-will-change: transform, opacity;
    will-change: transform, opacity;
}

.section.swipe-enter {
    -webkit-animation: swipeInFromBottom 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -moz-animation: swipeInFromBottom 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation: swipeInFromBottom 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -webkit-will-change: transform, opacity;
    will-change: transform, opacity;
}

.section.surf-enter {
    -webkit-animation: surfInFromRight 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -moz-animation: surfInFromRight 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation: surfInFromRight 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -webkit-will-change: transform, opacity;
    will-change: transform, opacity;
}

.section.wave-enter {
    -webkit-animation: waveInFromTop 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -moz-animation: waveInFromTop 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation: waveInFromTop 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    -webkit-will-change: transform, opacity;
    will-change: transform, opacity;
}

.lessons {
    background: var(--bg-primary);
    animation: fadeInUp 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.lessons h2 {
    text-align: center;
    margin-bottom: 80px;
    font-size: 2.5rem;
}

.science-book-container {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 35px 18px;
    margin-bottom: 50px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow);
    transition: var(--transition);
    opacity: 0;
    transform: translateY(50px);
}

.science-book-container.visible {
    animation: fadeInScale 0.8s ease-out both;
}

.science-book-container:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow), var(--glow);
}

.science-book-container h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
}

.science-book-iframe {
    width: 100%;
    height: 600px;
    border: none;
    border-radius: 12px;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.subject-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    opacity: 0;
    transform: translateY(50px);
}
.subject-card.visible {
    animation: zoomIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.subject-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow), var(--glow);
}

.subject-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: var(--transition);
    border-radius: 0;
}

.subject-card:hover img {
    transform: scale(1.05);
}

.subject-card .content {
    padding: 30px 16px;
}

.subject-card h3 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.subject-card p {
    color: var(--text-secondary);
    line-height: 1.5;
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.lesson-card {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    opacity: 0;
    transform: translateY(50px);
}
.lesson-card.visible {
    animation: zoomIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.lesson-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow), var(--glow);
}

.lesson-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: var(--transition);
    border-radius: 0;
}

.lesson-card:hover img {
    transform: scale(1.05);
}

.lesson-card .content {
    padding: 30px 16px;
}

.lesson-card h3 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.lesson-card p {
    color: var(--text-secondary);
    line-height: 1.5;
}

.settings {
    background: var(--bg-secondary);
    animation: fadeInUp 1s ease-out;
}

.settings h2 {
    text-align: center;
    margin-bottom: 80px;
    font-size: 2.5rem;
}

.setting-group {
    max-width: 600px;
    margin: 0 auto 40px;
    padding: 35px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(50px);
}

.setting-group.visible {
    animation: slideUp 0.6s ease-out both;
}

.setting-group.logout-group {
    padding: 20px 30px;
    display: flex;
    justify-content: center;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
}

.setting-group h3 {
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.logout-btn {
    width: 100%;
    max-width: 200px;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 122, 255, 0.3);
    opacity: 0.9;
}

.logout-btn:active {
    transform: translateY(0);
}

body.dark-mode .logout-btn:hover {
    box-shadow: 0 8px 16px rgba(0, 122, 255, 0.4);
}

.toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.toggle span {
    font-size: 1.1rem;
}

.toggle input[type="checkbox"] {
    width: 50px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
}

.toggle input[type="checkbox"]:checked {
    background: var(--accent);
}

.toggle input[type="checkbox"]:before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
}

.toggle input[type="checkbox"]:checked:before {
    transform: translateX(24px);
}

.color-picker {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: var(--transition);
}

.color-option.selected {
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.font-selector select {
    padding: 12px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.font-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 95vw;
    height: 90vh;
    max-width: none;
    max-height: 900px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: none;
}

.modal-content.closing {
    animation: windowClose 0.3s ease-in forwards;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--accent);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    z-index: 10;
    transition: var(--transition);
}

.close-btn:hover {
    background: #0056cc;
    transform: scale(1.1);
}

.chat-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--accent);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    z-index: 10;
    transition: var(--transition);
    display: none;
}

.chat-close-btn:hover {
    background: #0056cc;
    transform: scale(1.1);
}

.chat-close-btn:active {
    transform: scale(0.95);
}

#subject-title {
    padding: 20px 30px 0;
    margin: 0;
    font-size: 1.8rem;
}

#lesson-title {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 0;
    margin: 0;
    font-size: 1.8rem;
    z-index: 10;
}

#lesson-iframe {
    position: absolute;
    top: 80px;
    left: 0;
    width: 100%;
    height: calc(100% - 80px);
    border: none;
    border-radius: 0 0 16px 16px;
    display: block;
}

.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 30px;
    margin-top: 20px;
    max-height: 600px;
    overflow-y: auto;
    transition: var(--transition);
}

.lessons-list.closing {
    animation: slideDown 0.3s ease-in forwards;
}

.lesson-item {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px 20px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lesson-item:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.lesson-item::after {
    content: '▶';
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.lesson-item:hover::after {
    color: white;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9) translateZ(0); }
    to { opacity: 1; transform: scale(1) translateZ(0); }
}

@media (max-width: 1024px) {
    .sidebar:hover {
        width: 200px;
    }

    .sidebar:hover ~ .main-content {
        margin-left: 200px;
    }

    .hero h1 {
        font-size: 3rem;
    }

    .hero p {
        font-size: 1.2rem;
    }

    .floating-chat {
        top: 20px;
        right: 20px;
        bottom: auto;
    }

    .floating-chat-container {
        top: 100px;
        right: 20px;
        bottom: auto;
    }
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 2002;
    transition: var(--transition);
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: var(--accent);
    color: white;
}

.sidebar-toggle .icon {
    font-size: 24px;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar.closed {
    transform: translateX(-100%);
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 200px;
        position: fixed;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100%;
        overflow-x: hidden;
    }

    .sidebar.open ~ .main-content {
        margin-left: 0 !important;
        width: 100%;
        overflow-x: hidden;
    }

    .section {
        padding: 60px 30px;
    }

    .how-to-use h2, .lessons h2, .settings h2 {
        margin-bottom: 80px;
        margin-top: 20px;
    }

    .chatbox h2 {
        margin-bottom: 70px;
        margin-top: 20px;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .steps-grid {
        grid-template-columns: 1fr;
    }

    .step-card, .lesson-card {
        max-width: 100%;
        padding: 20px 12px;
    }

    .step-card .icon {
        font-size: 2rem;
        margin-bottom: 12px;
    }

    .step-card h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .lessons-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .lesson-card {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 180px;
    }

    .lesson-card img {
        height: 100px;
        width: 100%;
        object-fit: cover;
    }

    .lesson-card .content {
        padding: 18px 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .lesson-card h3 {
        font-size: 0.95rem;
        margin-bottom: 6px;
        line-height: 1.2;
    }

    .lesson-card p {
        font-size: 12px;
        line-height: 1.2;
    }

    .subjects-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .subject-card {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 180px;
    }

    .subject-card img {
        height: 100px;
        width: 100%;
        object-fit: cover;
    }

    .subject-card .content {
        padding: 18px 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .subject-card h3 {
        font-size: 0.95rem;
        margin-bottom: 6px;
        line-height: 1.2;
    }

    .subject-card p {
        font-size: 12px;
    }

    .sidebar-icon .label {
        opacity: 1 !important;
        font-size: 12px;
    }

    .modal-content {
        width: 95vw;
        height: 80vh;
        max-width: none;
        max-height: none;
        top: 10vh;
        left: 2.5vw;
        transform: none;
    }

    #lesson-iframe {
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100% - 60px);
    }

    .lessons-list {
        padding: 20px;
        margin-top: 10px;
        max-height: 300px;
    }

    .close-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
        top: 10px;
        right: 10px;
        z-index: 2001;
        padding: 10px;
        box-sizing: border-box;
    }

    #subject-title, #lesson-title {
        font-size: 1.2rem;
        top: 15px;
        left: 10px;
    }

    .chatbox {
        padding: 0;
        height: 100%;
        flex-direction: column;
        position: relative;
    }

    .chatbox h2 {
        margin-bottom: 20px;
        margin-top: 20px;
        position: relative;
        z-index: 1;
    }

    .chat-wrapper {
        flex-direction: column;
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
        height: calc(100% - 100px);
        flex: 1;
    }

    .chat-history-panel {
        width: calc(100% - 10px);
        height: 100%;
        position: relative;
        left: 0;
        top: 0;
        flex: none;
        border-right: none;
        border-radius: 12px;
        margin-right: 0;
        margin-left: 5px;
        margin-right: 5px;
        display: flex !important;
        flex-direction: column;
        z-index: 10;
        opacity: 1;
        transform: translateY(0);
        transition: opacity 0.3s ease, visibility 0.3s ease;
        min-height: auto;
        background: var(--bg-secondary);
        border: 1px solid var(--glass-border);
        overflow: hidden;
    }

    .chat-history-panel.hidden {
        display: none !important;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .chat-main {
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        flex: 1;
        display: flex;
    }

    .chat-container {
        width: calc(100% - 10px);
        height: 100%;
        display: none !important;
        flex-direction: column;
        position: absolute;
        left: 0;
        top: 0;
        margin-left: 5px;
        margin-right: 5px;
        opacity: 0;
        transform: translateY(20px);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border: 1px solid #e5e5e5;
        background: #ffffff;
        transition: opacity 0.3s ease, transform 0.3s ease;
        pointer-events: none;
        z-index: 20;
        overflow: hidden;
    }

    .chat-container.visible {
        display: flex !important;
        position: relative;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        animation: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border: 1px solid #e5e5e5;
        z-index: 2000;
    }

    .chat-close-btn {
        display: block;
    }

    .profile-modal-close {
        display: block;
    }

    .profile-modal-close:hover {
        transform: none;
        color: var(--text-secondary);
    }

    .profile-modal-close:active {
        transform: rotate(90deg) scale(0.95);
        color: var(--text-primary);
    }

    .settings-modal-close:hover {
        transform: none;
        color: var(--text-secondary);
    }

    .settings-modal-close:active {
        transform: rotate(90deg) scale(0.95);
        color: var(--text-primary);
    }

    .profile-edit-btn {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: scale(1) translateZ(0);
    }

    .sidebar.open .sidebar-profile .profile-edit-btn {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* Tablet styles for better conversation list width */
@media (min-width: 769px) and (max-width: 1024px) {
    .chat-history-panel {
        width: calc(100% - 20px);
        margin-left: 10px;
        margin-right: 10px;
    }

    .chat-container {
        width: calc(100% - 20px);
        margin-left: 10px;
        margin-right: 10px;
    }
}

@media (max-width: 480px) {
    .section {
        padding: 40px 20px;
    }

    .how-to-use h2, .lessons h2, .settings h2 {
        margin-bottom: 70px;
        margin-top: 15px;
    }

    .chatbox h2 {
        margin-bottom: 60px;
        margin-top: 15px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .step-card, .lesson-card {
        padding: 16px 10px;
    }

    .step-card .icon {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }

    .step-card h3 {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .step-card p {
        font-size: 12px;
    }

    .lessons-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .lesson-card {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 150px;
    }

    .lesson-card img {
        height: 80px;
        width: 100%;
        object-fit: cover;
    }

    .lesson-card .content {
        padding: 16px 10px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .lesson-card h3 {
        font-size: 0.95rem;
        margin-bottom: 4px;
        line-height: 1.2;
        word-wrap: break-word;
    }

    .lesson-card p {
        font-size: 11px;
        line-height: 1.2;
        word-wrap: break-word;
    }

    .subjects-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .subject-card {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 150px;
    }

    .subject-card img {
        height: 80px;
        width: 100%;
        object-fit: cover;
    }

    .subject-card .content {
        padding: 16px 10px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .subject-card h3 {
        font-size: 0.95rem;
        margin-bottom: 4px;
        line-height: 1.2;
        word-wrap: break-word;
    }

    .subject-card p {
        font-size: 11px;
        line-height: 1.2;
        word-wrap: break-word;
    }

    .setting-group {
        padding: 20px 14px;
    }

    .chat-wrapper {
        flex-direction: column;
    }

    .chat-history-panel {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        display: block;
        border-right: none;
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 5;
    }

    .chat-history-panel.hidden {
        opacity: 0;
        visibility: hidden;
        transform: translateX(-100%);
        pointer-events: none;
    }

    .chat-main {
        position: relative;
        width: 100%;
        flex: 1;
    }

    .chat-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        transform: translateX(100%);
        transition: opacity 0.3s ease, transform 0.3s ease;
        pointer-events: none;
    }

    .chat-container.visible {
        opacity: 1;
        transform: translateX(0);
        pointer-events: auto;
        animation: none;
    }

    .chat-close-btn {
        display: block;
    }

    .profile-modal-close {
        display: block;
    }
}

/* Floating Chat Box Styles */
.floating-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    font-size: 14px;
    user-select: none;
    -webkit-user-select: none;
}

.floating-chat-toggle {
    position: fixed;
    z-index: 2001;
    width: 60px;
    height: 60px;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    animation: bounceIn 0.3s ease-out;
    will-change: transform;
    transform: translateZ(0);
    -webkit-tap-highlight-color: transparent;
}

.floating-chat-toggle:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

.floating-chat-toggle:active {
    transform: scale(0.95);
}

.floating-chat-toggle .icon {
    font-size: 24px;
    line-height: 1;
}

.floating-chat-container {
    position: fixed;
    width: 360px;
    height: 520px;
    max-height: 80vh;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 2000;
}

.floating-chat-container.active {
    display: flex;
    z-index: 2000;
}

.floating-chat-container.closing {
    animation: closeAnimation 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes closeAnimation {
    0% { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.9) translateY(20px); }
}

@media (max-width: 768px) {
    .floating-chat {
        user-select: none;
        -webkit-user-select: none;
    }

    .floating-chat-toggle {
        width: 56px;
        height: 56px;
    }

    .floating-chat-toggle .icon {
        font-size: 20px;
    }

    .floating-chat-container {
        width: calc(100vw - 24px);
        height: 60vh;
        max-height: 70vh;
        border-radius: 16px;
    }
}

@media (max-width: 480px) {
    .floating-chat-toggle {
        width: 52px;
        height: 52px;
    }

    .floating-chat-toggle .icon {
        font-size: 20px;
    }

    .floating-chat-container {
        width: calc(100vw - 16px);
        height: 50vh;
        border-radius: 12px;
    }

    .floating-chat-header {
        padding: 12px 16px;
        font-size: 14px;
    }

    .floating-chat .chat-messages {
        padding: 8px;
    }

    .floating-chat .message {
        font-size: 13px;
        padding: 6px 10px;
    }

    .floating-chat .chat-input {
        padding: 8px 10px;
        font-size: 13px;
    }
}

.floating-chat-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
    border-radius: 20px 20px 0 0;
    letter-spacing: 0.2px;
}

.floating-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.floating-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.floating-chat-close:active {
    background: rgba(255, 255, 255, 0.4);
}

.floating-chat .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    border-radius: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    margin: 0;
}

.floating-chat .chat-input-container {
    padding: 10px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--glass-border);
}

.floating-chat .chat-input {
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
    transition: var(--transition);
    flex: 1;
}

.floating-chat .chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.floating-chat .send-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    margin-left: 8px;
}

.floating-chat .send-btn:hover {
    background: #0056cc;
    transform: scale(1.05);
}

.floating-chat .message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 80%;
    animation: slideUp 0.3s ease-out;
    font-size: 12px;
}

.floating-chat .message.user {
    background: #007aff;
    color: white;
    margin-left: auto;
    text-align: left;
    border-radius: 18px 18px 4px 18px;
    box-shadow: none;
}

.message.bot {
    background: #f7f7f8;
    color: #1e1e1e;
    border: 1px solid #d0d0d0;
    border-radius: 18px 18px 18px 4px;
    margin-right: auto;
}

.dark-mode .message.bot {
    background: rgba(45, 45, 47, 0.9) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.dark-mode .floating-chat .message.bot {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.floating-chat .message .username {
    font-weight: bold;
    font-size: 10px;
    margin-bottom: 3px;
    opacity: 0.8;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

@keyframes windowOpen {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes windowClose {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.8); }
}

@media (max-width: 1024px) {
    .chat-container {
        height: calc(100vh - 320px);
        min-height: 400px;
        padding: 15px;
    }

    .floating-chat-container {
        width: 300px;
        height: 450px;
    }

    .section {
        padding: 60px 30px;
    }

    .hero h1 {
        font-size: 3.5rem;
    }

    .hero p {
        font-size: 1.3rem;
    }
}

@media (min-width: 769px) {
    .floating-chat {
        bottom: 20px;
        right: 20px;
    }

    .floating-chat-container {
        bottom: 100px;
        right: 20px;
    }

    .floating-chat-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .floating-chat {
        top: 20px;
        right: 20px;
        bottom: auto;
    }

    .floating-chat-container {
        display: none;
        width: calc(100vw - 30px);
        height: 400px;
        max-width: 350px;
        top: 100px;
        right: 20px;
        bottom: auto;
    }

    .floating-chat-toggle {
        display: flex;
        z-index: 2001;
    }

    .chat-container {
        height: calc(100vh - 350px);
        min-height: 350px;
        padding: 10px;
    }

    .section {
        padding: 50px 20px;
    }

    .hero h1 {
        font-size: 2.8rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .subjects-grid, .lessons-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .floating-chat {
        bottom: 20px;
        right: 20px;
    }

    .floating-chat-toggle {
        display: none;
    }

    .floating-chat-toggle .icon {
        font-size: 24px;
    }

    .floating-chat-container {
        width: calc(100% - 20px);
        height: 300px;
        max-width: none;
        bottom: 90px;
    }

    .chat-container {
        height: calc(100vh - 400px);
        min-height: 300px;
        padding: 8px;
    }

    .section {
        padding: 40px 15px;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .step-card, .subject-card, .lesson-card {
        padding: 20px;
    }

    .setting-group {
        padding: 20px;
        margin: 0 auto 30px;
    }
}

.chatbox {
    background: var(--bg-primary);
    animation: fadeInUp 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.chatbox h2 {
    margin-bottom: 60px;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* Chat History Panel Styles */
.chat-history-panel {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-right: 20px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    min-height: 550px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) translateZ(0);
    transition: box-shadow 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: box-shadow;
    backface-visibility: hidden;
}

.chat-history-panel.visible {
    animation: slideUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.chat-history-header {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-primary);
}

.chat-search-bar {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-search-input {
    width: 100%;
    padding: 6px 12px 6px 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    transition: var(--transition);
}

.chat-search-input::placeholder {
    color: var(--text-secondary);
}

.chat-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.search-icon {
    position: absolute;
    left: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
}

.chat-header-buttons {
    display: flex;
    gap: 8px;
}

.new-chat-btn, .clear-history-btn {
    flex: 1;
    padding: 6px 8px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: var(--transition);
}

.new-chat-btn:hover, .clear-history-btn:hover {
    background: #0056cc;
}

.new-chat-btn:active, .clear-history-btn:active {
    transform: translateY(0);
}

.new-chat-btn .icon, .clear-history-btn .icon {
    font-size: 16px;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history-item {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    position: relative;
}

.chat-history-item:hover {
    background: rgba(0, 122, 255, 0.1);
    border-color: var(--accent);
}

.chat-history-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.chat-history-timestamp {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-history-edit {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.chat-history-item:hover .chat-history-edit {
    opacity: 1;
    background: #007aff;
    color: white;
}

.chat-history-edit:hover {
    background: #0056cc;
    color: white;
}

.chat-history-delete {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: var(--transition);
}

.chat-history-item:hover .chat-history-delete {
    background: #ff3b30;
    color: white;
}

.chat-history-delete:hover {
    background: #ff3b30;
    color: white;
}

.chat-history-panel.expanded {
    width: 350px;
}

.chat-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 20px;
    flex: 1;
    position: relative;
    z-index: 1;
}

.chat-main {
    flex: 1;
    display: flex;
    min-width: 0;
}

/* Desktop adjustments for chat layout */
@media (min-width: 1025px) {
    .chat-history-panel {
        flex: 0.6;
    }

    .chat-main {
        flex: 1.4;
    }
}

/* Desktop optimization for 1600x900 and larger screens */
@media (min-width: 1600px) {
    #lesson-modal .modal-content {
        width: 99vw;
        height: 90vh;
        max-width: none !important;
        max-height: 900px;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .lessons-list {
        max-height: 700px;
        padding: 40px;
    }

    .lesson-item {
        padding: 18px 24px;
        font-size: 1.05rem;
    }
}

.chat-container {
    flex: 1;
    min-width: 0;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    min-height: 550px;
    opacity: 0;
    transform: translateY(20px) translateZ(0);
    transition: box-shadow 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: box-shadow;
    backface-visibility: hidden;
    overflow: hidden;
    margin: 0;
}

.chat-container.visible {
    animation: slideUp 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.dark-mode .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.dark-mode .chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-placeholder {
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    padding: 60px 30px;
    opacity: 0.7;
    animation: fadeIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.message {
    margin-bottom: 0;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    line-height: 1.4;
    font-size: 15px;
}

.message.user {
    background: #007aff;
    color: white;
    margin-left: auto;
    text-align: left;
    border-radius: 18px 18px 4px 18px;
    box-shadow: none;
}

.message.bot {
    background: #f7f7f8;
    color: #1e1e1e;
    border: 1px solid #d0d0d0;
    border-radius: 18px 18px 18px 4px;
    margin-right: auto;
}

.message .username {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    opacity: 0.9;
    letter-spacing: 0.2px;
}

.message-image-container {
    margin-top: 8px;
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    display: block;
    animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-image {
    box-shadow: 0 2px 4px rgba(0, 122, 255, 0.15), 0 4px 8px rgba(0, 122, 255, 0.15);
}

.message-file {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 14px;
    margin-top: 8px;
}

.message.user .message-file {
    background: rgba(255, 255, 255, 0.2);
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px 20px;
    background: transparent;
    border-top: 1px solid var(--glass-border);
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backface-visibility: hidden;
    font-weight: 500;
}

.chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.chat-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
    background: var(--bg-secondary);
}

.send-btn {
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.send-btn:hover {
    background: #0056cc;
    transform: scale(1.05);
}

.send-btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), background 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    flex-shrink: 0;
    backface-visibility: hidden;
}

.send-btn-icon:hover {
    transform: scale(1.08) translateZ(0);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
}

.send-btn-icon:active {
    transform: scale(0.95) translateZ(0);
}

.attach-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
    backface-visibility: hidden;
    position: relative;
    margin: 0;
    min-width: 40px;
    min-height: 40px;
}

.attach-btn:hover {
    background: rgba(0, 122, 255, 0.1);
    border-color: var(--accent);
    transform: scale(1.05) rotate(5deg) translateZ(0);
}

.attach-btn:active {
    transform: scale(0.95) rotate(-5deg) translateZ(0);
}

.attach-btn.has-file {
    background: rgba(0, 122, 255, 0.2);
    border-color: var(--accent);
    animation: pulse-attachment 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes pulse-attachment {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
        transform: scale(1.05);
    }
}

.file-input {
    display: none;
}

.file-preview {
    padding: 12px 16px 8px;
    background: transparent;
    border-top: 1px solid var(--glass-border);
}

.preview-item {
    position: relative;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.preview-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bg-primary);
}

.preview-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 60px;
    line-height: 1.4;
}

.preview-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
    border: 1px solid #ff3b30;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-weight: 600;
}

.preview-remove:hover {
    background: #ff3b30;
    color: white;
    transform: scale(1.08);
}

.preview-remove:active {
    transform: scale(0.95);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.send-btn-icon-old:hover {
    background: #0056cc;
    transform: scale(1.1);
}
    
.send-btn-icon .icon {
    font-size: 16px;
    line-height: 1;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 12px;
    background: var(--glass-bg);
   border: 1px solid var(--glass-border);
    max-width: 70%;
    animation: fadeIn 0.3s ease-out;
}

.typing-indicator .username {
    font-weight: bold;
    font-size: 12px;
    opacity: 0.8;
    color: var(--text-primary);
}

.typing-dots {
    display: flex;
    gap: 4px;
    margin-top: 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

.floating-chat .typing-indicator {
    padding: 8px 12px;
    margin-bottom: 10px;
    max-width: 80%;
}

.floating-chat .typing-indicator .username {
    font-size: 10px;
    margin-bottom: 3px;
}

.floating-chat .typing-dots span {
    width: 5px;
    height: 5px;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Skeleton Loading Styles */
.skeleton {
    background: linear-gradient(90deg, rgba(200, 200, 200, 0.4) 25%, rgba(255, 255, 255, 0.6) 50%, rgba(200, 200, 200, 0.4) 75%);
    background-size: 200% 100%;
    animation: shimmer 1s infinite;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease-out;
}

.light-mode .skeleton {
    background: linear-gradient(90deg, rgba(150, 150, 150, 0.6) 25%, rgba(200, 200, 200, 0.8) 50%, rgba(150, 150, 150, 0.6) 75%) !important;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.light-mode .lesson-item.skeleton {
    background: linear-gradient(90deg, rgba(0, 122, 255, 0.3) 25%, rgba(0, 122, 255, 0.6) 50%, rgba(0, 122, 255, 0.3) 75%) !important;
    border: 1px solid rgba(0, 122, 255, 0.5);
    color: rgba(0, 122, 255, 0.8);
}

.dark-mode .lesson-item.skeleton {
    background: linear-gradient(90deg, rgba(0, 122, 255, 0.4) 25%, rgba(0, 122, 255, 0.7) 50%, rgba(0, 122, 255, 0.4) 75%) !important;
    border: 1px solid rgba(0, 122, 255, 0.6);
    color: rgba(0, 122, 255, 0.9);
}

.skeleton-image {
    width: 100%;
    height: 200px;
    position: absolute;
    top: 0;
    left: 0;
}

.subject-card {
    position: relative;
}

.subject-card img {
    position: relative;
    z-index: 1;
}

.skeleton-iframe {
    width: 100%;
    height: calc(100% - 80px);
    position: absolute;
    top: 80px;
    left: 0;
    border-radius: 0 0 16px 16px;
}

/* MESSENGER/INBOX SECTION */
.community {
    padding: 0;
    height: 100%;
    flex-direction: column;
    position: relative;
}

.community h2 {
    padding: 20px 30px;
    margin: 0;
    font-size: 28px;
    color: var(--text-primary);
}

.messenger-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 0;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Conversations Panel */
.conversations-panel {
    flex: 0 0 340px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conversations-header {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
    transition: var(--transition);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.search-icon {
    position: absolute;
    left: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    pointer-events: none;
}

.header-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-btn:hover {
    background: #0056cc;
    transform: scale(1.02);
}

.action-btn:active {
    transform: scale(0.95);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.conversation-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-secondary);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.conversation-item:hover {
    background: rgba(0, 122, 255, 0.05);
}

.conversation-item.active {
    background: rgba(0, 122, 255, 0.1);
    border-left: 3px solid var(--accent);
}

.conversation-avatar {
    width: 50px;
    height: 50px;
    min-flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conversation-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.conversation-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 14px;
}

/* Messages Panel */
.messages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.messages-panel.active {
    opacity: 1;
    pointer-events: auto;
    animation: slideInPanel 0.3s ease-in-out;
}

.dark-mode .messages-panel {
    background: var(--bg-secondary);
}

/* Animation for messages container fade-in */
@keyframes fadeInMessages {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animation for messages panel slide-in */
@keyframes slideInPanel {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}

.header-info {
    flex: 1;
}

.header-info h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-info p {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-actions .action-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.messages-container.animate-messages {
    animation: fadeInMessages 0.3s ease-in-out;
}

.message-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    max-width: 70%;
    font-size: 14px;
    line-height: 1.4;
}

.message-bubble.own {
    background: var(--accent);
    color: white;
    align-self: flex-end;
    border-radius: 18px 4px 18px 18px;
}

.message-bubble.other {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    align-self: flex-start;
    border-radius: 4px 18px 18px 18px;
}

.dark-mode .message-bubble.other {
    background: rgba(255, 255, 255, 0.1);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    padding: 0 4px;
}

.message-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-primary);
    background: white;
    transition: var(--transition);
    resize: none;
    max-height: 100px;
}

.dark-mode .message-input {
    background: rgba(255, 255, 255, 0.05);
}

.message-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    background: #0056cc;
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Info Panel */
.info-panel {
    flex: 0 0 300px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.info-panel.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.info-header {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.info-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.info-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.members-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.member-item {
    padding: 10px 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-primary);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.member-name {
    flex: 1;
}

.remove-member-btn {
    background: none;
    border: none;
    color: #ff3b30;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
}

.danger-btn {
    width: 100%;
    padding: 10px;
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.danger-btn:hover {
    background: #e63027;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Lesson modal - override to be full width */
#lesson-modal .modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 95vw;
    height: 90vh;
    max-width: none !important;
    max-height: 900px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: none;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-input {
    padding: 12px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.user-select,
.members-select {
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--bg-primary);
    max-height: 300px;
    overflow-y: auto;
}

.users-list {
    display: flex;
    flex-direction: column;
}

.user-option,
.member-checkbox {
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-primary);
}

.user-option:hover,
.member-checkbox:hover {
    background: rgba(0, 122, 255, 0.05);
}

.user-option.selected,
.member-checkbox.checked {
    background: rgba(0, 122, 255, 0.1);
}

.checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--glass-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: white;
}

.member-checkbox.checked .checkbox {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-primary {
    padding: 12px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
}

.btn-primary:hover {
    background: #0056cc;
    transform: scale(1.02);
}

.btn-primary:active {
    transform: scale(0.95);
}

/* Mobile Styles */
@media (max-width: 768px) {
    .messenger-wrapper {
        flex-direction: column;
    }

    .conversations-panel {
        flex: 0 0 auto;
        max-height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .conversations-panel.hidden {
        display: none;
    }

    .messages-panel {
        flex: 1;
    }

    .messages-panel:not(.active) {
        display: none;
    }

    .info-panel {
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-left: none;
        z-index: 1000;
    }

    .message-bubble {
        max-width: 85%;
    }

    .message-input {
        font-size: 16px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .community h2 {
        padding: 16px 16px;
        font-size: 24px;
    }

    .conversations-panel {
        max-height: 45%;
    }

    .message-header {
        padding: 12px 16px;
    }

    .messages-container {
        padding: 12px 16px;
    }

    .message-input-area {
        padding: 12px 16px;
    }

    .message-bubble {
        max-width: 90%;
    }
}
#lesson-iframe {
    position: relative;
    z-index: 1;
}

.skeleton-list-item {
    height: 50px;
    margin-bottom: 10px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}



@media (max-width: 480px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .step-card, .lesson-card {
        padding: 20px;
    }

    .setting-group {
        padding: 20px;
    }
}
