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

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

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Loading Screen Styles */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease;
    overflow: hidden;
}

.coding-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

.code-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    animation: codeLineMove 8s linear infinite;
}

.code-line:nth-child(1) {
    top: 20%;
    animation-delay: 0s;
}

.code-line:nth-child(2) {
    top: 50%;
    animation-delay: 2s;
}

.code-line:nth-child(3) {
    top: 80%;
    animation-delay: 4s;
}

@keyframes codeLineMove {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

.floating-icon {
    position: absolute;
    font-size: 2rem;
    animation: float 6s ease-in-out infinite;
    opacity: 0.6;
}

.floating-icon:nth-child(4) {
    top: 15%;
    left: 10%;
    animation-delay: 0s;
}

.floating-icon:nth-child(5) {
    top: 30%;
    right: 15%;
    animation-delay: 1.5s;
}

.floating-icon:nth-child(6) {
    bottom: 25%;
    left: 20%;
    animation-delay: 3s;
}

.floating-icon:nth-child(7) {
    bottom: 15%;
    right: 10%;
    animation-delay: 4.5s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-20px) rotate(5deg);
    }
    50% {
        transform: translateY(-10px) rotate(-5deg);
    }
    75% {
        transform: translateY(-15px) rotate(3deg);
    }
}

.loading-content {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.logo-container {
    margin-bottom: 40px;
}

.logo {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 4rem;
    animation: logoPulse 2s ease-in-out infinite;
}

.code-bracket {
    font-size: 5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: bracketGlow 2s ease-in-out infinite;
}

.code-bracket:nth-child(1) {
    animation-delay: 0s;
}

.code-bracket:nth-child(3) {
    animation-delay: 0.5s;
}

.code-symbol {
    font-size: 4.5rem;
    animation: symbolBounce 1.5s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes bracketGlow {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    }
    50% {
        opacity: 0.8;
        text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
}

@keyframes symbolBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.logo-particles {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    pointer-events: none;
}

.logo-particles .particle {
    position: absolute;
    font-size: 1.5rem;
    animation: particleOrbit 3s linear infinite;
    top: 50%;
    left: 50%;
    margin-top: -12px;
    margin-left: -12px;
}

.logo-particles .particle:nth-child(1) {
    animation-delay: 0s;
}

.logo-particles .particle:nth-child(2) {
    animation-delay: 0.75s;
}

.logo-particles .particle:nth-child(3) {
    animation-delay: 1.5s;
}

.logo-particles .particle:nth-child(4) {
    animation-delay: 2.25s;
}

@keyframes particleOrbit {
    0% {
        transform: rotate(0deg) translateX(80px) rotate(0deg);
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: rotate(360deg) translateX(80px) rotate(-360deg);
        opacity: 0.8;
    }
}

.logo-name {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.5),
        0 0 20px rgba(255, 255, 255, 0.3),
        2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
    margin-top: 15px;
    animation: nameGlow 2s ease-in-out infinite;
    text-transform: lowercase;
}

@keyframes nameGlow {
    0%, 100% {
        text-shadow: 
            0 0 10px rgba(255, 255, 255, 0.5),
            0 0 20px rgba(255, 255, 255, 0.3),
            2px 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% {
        text-shadow: 
            0 0 15px rgba(255, 255, 255, 0.7),
            0 0 30px rgba(255, 255, 255, 0.5),
            2px 2px 4px rgba(0, 0, 0, 0.3);
    }
}

.loading-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ff6b6b, #4ecdc4, #45b7d1, #ffd700);
    background-size: 200% 100%;
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progressShine 2s linear infinite;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

@keyframes progressShine {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 200% 0%;
    }
}

/* Responsive Loading Screen */
@media (max-width: 768px) {
    .logo-icon {
        font-size: 3rem;
    }
    
    .code-bracket {
        font-size: 4rem;
    }
    
    .code-symbol {
        font-size: 3.5rem;
    }
    
    .logo-name {
        font-size: 2rem;
        letter-spacing: 2px;
    }
    
    .logo-particles {
        width: 150px;
        height: 150px;
    }
    
    .logo-particles .particle {
        font-size: 1.2rem;
    }
    
    @keyframes particleOrbit {
        0% {
            transform: rotate(0deg) translateX(60px) rotate(0deg);
            opacity: 0.8;
        }
        50% {
            opacity: 1;
        }
        100% {
            transform: rotate(360deg) translateX(60px) rotate(-360deg);
            opacity: 0.8;
        }
    }
    
    .floating-icon {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .logo-icon {
        font-size: 2.5rem;
    }
    
    .code-bracket {
        font-size: 3rem;
    }
    
    .code-symbol {
        font-size: 2.5rem;
    }
    
    .logo-name {
        font-size: 1.75rem;
        letter-spacing: 1px;
    }
    
    .loading-content {
        padding: 15px;
    }
}

@media (min-width: 480px) {
    body {
        padding: 15px;
    }
}

@media (min-width: 768px) {
    body {
        padding: 20px;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeInUp 0.5s ease;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 1.75rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

@media (min-width: 480px) {
    header h1 {
        font-size: 2rem;
        margin-bottom: 10px;
    }
    
    .subtitle {
        font-size: 1rem;
    }
}

@media (min-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    background: var(--surface);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@media (min-width: 768px) {
    .main-content {
        grid-template-columns: 250px 1fr;
        gap: 20px;
        border-radius: 16px;
        padding: 20px;
    }
}

.sidebar {
    background: var(--background);
    border-radius: 12px;
    padding: 15px;
    height: fit-content;
    position: relative;
}

.sidebar h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

@media (min-width: 768px) {
    .sidebar {
        padding: 20px;
        position: sticky;
        top: 20px;
    }
    
    .sidebar h2 {
        font-size: 1.2rem;
        margin-bottom: 15px;
    }
}

.grade-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.grade-btn {
    padding: 10px 12px;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    color: var(--text-primary);
    min-height: 44px; /* Better touch target */
    touch-action: manipulation;
}

.grade-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

@media (min-width: 768px) {
    .grade-btn {
        padding: 12px 16px;
        font-size: 1rem;
    }
    
    .grade-btn:hover {
        transform: translateX(5px);
    }
}

@media (hover: none) {
    .grade-btn:active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }
}

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

.notes-section {
    min-height: 500px;
}

.notes-header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.header-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.notes-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    word-wrap: break-word;
}

@media (min-width: 480px) {
    .header-buttons {
        flex-direction: row;
        width: auto;
    }
    
    .notes-header h2 {
        font-size: 1.4rem;
    }
}

@media (min-width: 768px) {
    .notes-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0;
    }
    
    .header-buttons {
        flex-direction: row;
    }
    
    .notes-header h2 {
        font-size: 1.5rem;
    }
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    min-height: 44px; /* Better touch target */
    width: 100%;
    touch-action: manipulation;
}

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

@media (min-width: 480px) {
    .btn-primary {
        width: auto;
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    .btn-primary:hover {
        transform: translateY(-2px);
    }
}

@media (hover: none) {
    .btn-primary:active {
        background: var(--primary-dark);
        transform: scale(0.98);
    }
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #dc2626;
}

.notes-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 480px) {
    .notes-list {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 15px;
    }
}

@media (min-width: 768px) {
    .notes-list {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 20px;
    }
}

.note-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .note-card {
        padding: 20px;
    }
}

@media (hover: none) {
    .note-card:active {
        transform: scale(0.98);
    }
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.note-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow);
    border-color: var(--primary-color);
}

.note-card:hover::before {
    transform: scaleY(1);
}

.note-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.note-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 10px;
    opacity: 0.7;
}

.delete-note-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ef4444;
    border: 2px solid white;
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.5);
    opacity: 1;
}

.delete-note-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.7);
    border-color: #fee2e2;
}

.delete-note-btn:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .delete-note-btn {
        opacity: 1; /* Always visible on mobile for easier access */
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

.powerpoint-card {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .powerpoint-card {
        padding: 25px;
    }
}

@media (hover: none) {
    .powerpoint-card:active {
        transform: scale(0.98);
    }
}

.powerpoint-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: white;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.powerpoint-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.5);
    border-color: #fbbf24;
}

.powerpoint-card:hover::before {
    transform: scaleY(1);
}

.powerpoint-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    text-align: center;
}

.powerpoint-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: white;
    text-align: center;
    word-wrap: break-word;
}

@media (min-width: 768px) {
    .powerpoint-icon {
        font-size: 3rem;
        margin-bottom: 15px;
    }
    
    .powerpoint-card h3 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
}

.powerpoint-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: center;
    margin-bottom: 10px;
}

.file-type {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 10px;
    text-align: center;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.uploaded-file-card {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 2px solid #10b981;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .uploaded-file-card {
        padding: 25px;
    }
}

@media (hover: none) {
    .uploaded-file-card:active {
        transform: scale(0.98);
    }
}

.uploaded-file-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: white;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.uploaded-file-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.5);
    border-color: #34d399;
}

.uploaded-file-card:hover::before {
    transform: scaleY(1);
}

.uploaded-file-card .file-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    text-align: center;
}

.uploaded-file-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: white;
    text-align: center;
    word-wrap: break-word;
}

@media (min-width: 768px) {
    .uploaded-file-card .file-icon {
        font-size: 3rem;
        margin-bottom: 15px;
    }
    
    .uploaded-file-card h3 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
}

.uploaded-file-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    line-height: 1.6;
    text-align: center;
    margin-bottom: 10px;
}

.file-info {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
}

.delete-file-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    z-index: 10;
}

.delete-file-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Tab Styles */
.note-type-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--background);
}

.tab-content {
    animation: fadeIn 0.3s ease;
}

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

/* File Upload Styles */
.file-upload-area {
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--background);
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .file-upload-area {
        padding: 40px 20px;
    }
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.file-upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.02);
}

.upload-placeholder {
    pointer-events: none;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

@media (min-width: 768px) {
    .upload-icon {
        font-size: 4rem;
        margin-bottom: 15px;
    }
}

.upload-placeholder p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 5px 0;
}

.upload-hint {
    font-size: 0.85rem !important;
    color: var(--text-secondary) !important;
    opacity: 0.7;
}

.file-preview-item {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-preview-item span {
    color: var(--text-primary);
    font-weight: 500;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 1.1rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 95%;
    max-width: 600px;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    margin: 10px;
}

@media (min-width: 480px) {
    .modal-content {
        width: 90%;
        border-radius: 16px;
        max-height: 90vh;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    word-wrap: break-word;
    flex: 1;
    margin-right: 10px;
}

@media (min-width: 768px) {
    .modal-header {
        padding: 20px 24px;
    }
    
    .modal-header h3 {
        font-size: 1.5rem;
    }
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    flex-shrink: 0;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .modal-body {
        padding: 24px;
    }
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.textarea-field {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    min-height: 200px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

@media (min-width: 768px) {
    .textarea-field {
        min-height: 300px;
    }
}

.textarea-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-footer {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    padding: 15px 20px;
    border-top: 2px solid var(--border);
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary,
.modal-footer .btn-danger {
    width: 100%;
}

@media (min-width: 480px) {
    .modal-footer {
        flex-direction: row;
        justify-content: flex-end;
        padding: 20px 24px;
    }
    
    .modal-footer .btn-primary,
    .modal-footer .btn-secondary,
    .modal-footer .btn-danger {
        width: auto;
    }
}

/* Additional Mobile Optimizations */
@media (max-width: 479px) {
    .grade-selector {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .grade-btn {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    .file-info {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }
    
    .note-type-tabs {
        gap: 5px;
    }
    
    .tab-btn {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* Landscape mobile optimization */
@media (max-width: 767px) and (orientation: landscape) {
    .modal-content {
        max-height: 85vh;
    }
    
    .textarea-field {
        min-height: 150px;
    }
}