* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html {
    overscroll-behavior: none;
}

img {
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

a {
    -webkit-touch-callout: none;
}

button {
    -webkit-touch-callout: none;
}

:root {
    --bg: #0f0f0f;
    --bg-elevated: #161616;
    --surface: #1a1a1a;
    --card: #1e1e1e;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --text: #f5f5f5;
    --text-secondary: #a0a0a0;
    --text-tertiary: #6b6b6b;
    --accent: #ff4757;
    --accent-hover: #ff6b7a;
    --physics: #3b82f6;
    --physics-bg: rgba(59, 130, 246, 0.1);
    --chem: #8b5cf6;
    --chem-bg: rgba(139, 92, 246, 0.1);
    --math: #ec4899;
    --math-bg: rgba(236, 72, 153, 0.1);
    --resources: #10b981;
    --resources-bg: rgba(16, 185, 129, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overscroll-behavior-y: contain;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--surface);
    border-radius: 6px;
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--card);
}

::-webkit-scrollbar-thumb:active {
    background: var(--border-hover);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--surface) var(--bg);
}

/* Performance optimizations - removed will-change to reduce memory consumption */
/* will-change should only be used temporarily on specific interactions */

/* Hardware acceleration for animations */
@media (prefers-reduced-motion: no-preference) {
    .subject,
    .item,
    .icon,
    .pdf-badge,
    .tab,
    .modal-content,
    .modal-overlay {
        transform: translateZ(0);
        backface-visibility: hidden;
        perspective: 1000px;
    }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

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

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

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

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes generateIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
        filter: blur(8px);
    }
    50% {
        opacity: 0.5;
        filter: blur(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes typewriter {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 100%;
        opacity: 1;
    }
}

@keyframes glowPulse {
    0% {
        box-shadow: 0 0 5px rgba(255, 71, 87, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 71, 87, 0.6), 0 0 40px rgba(255, 71, 87, 0.3);
    }
    100% {
        box-shadow: 0 0 5px rgba(255, 71, 87, 0.2);
    }
}

@keyframes scanline {
    0% {
        transform: translateY(-100%);
    }
    100% {
        transform: translateY(100%);
    }
}

@keyframes pixelate {
    0% {
        opacity: 0;
        filter: blur(10px) brightness(1.5);
        transform: scale(0.9);
    }
    50% {
        filter: blur(5px) brightness(1.2);
    }
    100% {
        opacity: 1;
        filter: blur(0) brightness(1);
        transform: scale(1);
    }
}

@keyframes buildUp {
    0% {
        clip-path: inset(0 100% 0 0);
        opacity: 0;
    }
    100% {
        clip-path: inset(0 0 0 0);
        opacity: 1;
    }
}

.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
    opacity: 0;
    animation: pixelate 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.nav-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    user-select: none;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: contain;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    -webkit-touch-callout: none;
    pointer-events: none;
}

.brand-logo:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.brand-name {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.class-tabs {
    display: flex;
    gap: 6px;
    background: var(--surface);
    padding: 5px;
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.class-tabs-mobile {
    display: none;
}

.tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    position: relative;
    user-select: none;
    flex: 1;
    min-width: fit-content;
}

.tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.tab.active {
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.hero {
    padding: 48px 32px 32px;
    max-width: 1280px;
    margin: 0 auto;
    opacity: 0;
    animation: pixelate 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards;
}

.hero-wrap {
    max-width: 640px;
    margin: 0 auto;
}

.search {
    width: 100%;
    padding: 14px 18px 14px 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 16px center;
    background-size: 18px;
}

.search:focus {
    outline: none;
    border-color: var(--border-hover);
    background-color: var(--card);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.03), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.search::placeholder {
    color: var(--text-tertiary);
}

.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px 80px;
}

.footer {
    text-align: center;
    padding: 32px 32px 48px;
    color: var(--text-tertiary);
    font-size: 14px;
    opacity: 0;
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) 1.5s forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer p {
    margin: 0;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.github-link:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    color: var(--text);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.github-link svg {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.github-link:hover svg {
    transform: scale(1.1);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

.subject {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    opacity: 0;
    animation: pixelate 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    position: relative;
    overflow: hidden;
}

.subject::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: scanline 1.5s ease-in-out;
    opacity: 0;
}

.subject:nth-child(1) { animation-delay: 0.6s; }
.subject:nth-child(1)::before { animation-delay: 0.6s; }
.subject:nth-child(2) { animation-delay: 0.75s; }
.subject:nth-child(2)::before { animation-delay: 0.75s; }
.subject:nth-child(3) { animation-delay: 0.9s; }
.subject:nth-child(3)::before { animation-delay: 0.9s; }
.subject:nth-child(4) { animation-delay: 1.05s; }
.subject:nth-child(4)::before { animation-delay: 1.05s; }
.subject:nth-child(5) { animation-delay: 1.2s; }
.subject:nth-child(5)::before { animation-delay: 1.2s; }
.subject:nth-child(6) { animation-delay: 1.35s; }
.subject:nth-child(6)::before { animation-delay: 1.35s; }

.subject:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.subject-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: scaleIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.subject:hover .icon {
    transform: scale(1.08);
}

.icon.physics {
    background: var(--physics-bg);
    color: var(--physics);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.icon.chemistry {
    background: var(--chem-bg);
    color: var(--chem);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.icon.mathematics {
    background: var(--math-bg);
    color: var(--math);
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.icon.resources {
    background: var(--resources-bg);
    color: var(--resources);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.subject-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

.cat {
    margin-bottom: 18px;
}

.cat:last-child {
    margin-bottom: 0;
}

.cat-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    padding-left: 2px;
    opacity: 0;
    animation: typewriter 0.6s steps(20) forwards, fadeIn 0.3s ease-in forwards;
    animation-delay: 0.05s;
    overflow: hidden;
    white-space: nowrap;
}

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

.item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: var(--surface);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: buildUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.item:nth-child(1) { animation-delay: 0.1s; }
.item:nth-child(2) { animation-delay: 0.15s; }
.item:nth-child(3) { animation-delay: 0.2s; }
.item:nth-child(4) { animation-delay: 0.25s; }
.item:nth-child(5) { animation-delay: 0.3s; }
.item:nth-child(6) { animation-delay: 0.35s; }
.item:nth-child(7) { animation-delay: 0.4s; }
.item:nth-child(8) { animation-delay: 0.45s; }
.item:nth-child(9) { animation-delay: 0.5s; }
.item:nth-child(10) { animation-delay: 0.55s; }
.item:nth-child(11) { animation-delay: 0.6s; }
.item:nth-child(12) { animation-delay: 0.65s; }
.item:nth-child(13) { animation-delay: 0.7s; }
.item:nth-child(14) { animation-delay: 0.75s; }
.item:nth-child(15) { animation-delay: 0.8s; }

.item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, transparent, var(--accent), transparent);
    opacity: 0;
    transform: translateX(-3px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255, 71, 87, 0.05), rgba(255, 107, 122, 0.05));
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.item:hover {
    background: var(--bg-elevated);
    border-color: rgba(255, 71, 87, 0.3);
    transform: translateX(6px) scale(1.01);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.15), 
                0 0 0 1px rgba(255, 71, 87, 0.1);
}

.item:hover::before {
    opacity: 1;
    transform: translateX(0);
}

.item:hover::after {
    opacity: 1;
}

.pdf-badge {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(255, 71, 87, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: glowPulse 2s ease-in-out infinite;
}

.item:hover .pdf-badge {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(255, 71, 87, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.item-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.5;
    transition: color 0.2s;
}

.item:hover .item-name {
    color: var(--text);
}

.arrow {
    width: 18px;
    height: 18px;
    opacity: 0.3;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-tertiary);
}

.item:hover .arrow {
    opacity: 1;
    transform: translateX(3px);
    color: var(--accent);
}

.empty {
    text-align: center;
    padding: 80px 32px;
    color: var(--text-tertiary);
    font-size: 15px;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .nav-wrap {
        padding: 14px 24px;
        gap: 20px;
    }
    
    .brand-logo {
        width: 32px;
        height: 32px;
    }
    
    .brand-name {
        font-size: 18px;
    }
    
    .class-tabs {
        display: none;
    }
    
    .class-tabs-mobile {
        display: flex;
        gap: 6px;
        background: var(--surface);
        padding: 5px;
        border-radius: 14px;
        border: 1px solid var(--border);
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
        margin-bottom: 16px;
    }
    
    .tab {
        padding: 7px 12px;
        font-size: 13px;
        flex: 1;
        min-width: fit-content;
    }
    
    .hero {
        padding: 36px 24px 24px;
    }
    
    .search {
        padding: 13px 16px 13px 44px;
        font-size: 14px;
        background-size: 16px;
        background-position: 14px center;
    }
    
    .main {
        padding: 0 24px 60px;
    }
    
    .footer {
        padding: 24px 24px 40px;
        font-size: 13px;
    }
    
    .github-link {
        padding: 9px 16px;
        font-size: 13px;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .subject {
        padding: 20px;
    }
    
    .subject-title {
        font-size: 17px;
    }
    
    .item {
        padding: 10px 12px;
    }
    
    .item-name {
        font-size: 13px;
    }
    
    .icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .pdf-badge {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .brand-logo {
        width: 28px;
        height: 28px;
    }
    
    .brand-name {
        font-size: 16px;
    }
    
    .class-tabs {
        gap: 4px;
        padding: 4px;
    }
    
    .tab {
        padding: 6px 10px;
        font-size: 12px;
        flex: 1;
        min-width: fit-content;
    }
    
    .hero {
        padding: 28px 20px 20px;
    }
    
    .main {
        padding: 0 20px 48px;
    }
    
    .footer {
        padding: 20px 20px 32px;
        font-size: 12px;
    }
    
    .github-link {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    .subject {
        padding: 18px;
    }
    
    .icon {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
}

/* Landscape orientation optimizations */
@media (max-height: 600px) and (orientation: landscape) {
    .nav-wrap {
        padding: 12px 24px;
    }
    
    .hero {
        padding: 24px 32px 20px;
    }
    
    .main {
        padding: 0 32px 40px;
    }
    
    .subject {
        padding: 20px;
    }
    
    .subject-head {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .cat {
        margin-bottom: 14px;
    }
    
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 20px;
    }
}

/* Tablet landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    }
    
    .nav-wrap {
        padding: 14px 32px;
    }
    
    .hero {
        padding: 32px 32px 24px;
    }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    opacity: 0;
}

.modal.active {
    display: block;
    animation: fadeIn 0.2s ease-out forwards;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1001;
    opacity: 0;
}

.modal.active .modal-overlay {
    animation: fadeIn 0.2s ease-out forwards;
}

.modal-content {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1002;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: scale(0.95);
}

.modal.active .modal-content {
    animation: scaleIn 0.3s ease-out 0.1s forwards;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.pdf-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    padding-right: 16px;
    letter-spacing: -0.01em;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.modal-download {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-download:hover {
    background: var(--physics-bg);
    border-color: var(--physics);
    color: var(--physics);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.modal-download svg {
    transition: transform 0.3s ease;
}

.modal-download:hover svg {
    transform: translateY(2px);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(90deg);
}

.modal-close svg {
    transition: transform 0.2s;
}

#pdfViewer {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none;
}

.text-viewer {
    width: 100%;
    height: 100%;
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', monospace;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.modal-copy {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-copy:hover {
    background: var(--resources-bg);
    border-color: var(--resources);
    color: var(--resources);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.modal-copy.copied {
    background: var(--resources-bg);
    border-color: var(--resources);
    color: var(--resources);
}

@media (max-width: 768px) {
    .modal-header {
        padding: 10px 12px;
    }
    
    .pdf-title {
        font-size: 13px;
    }
    
    .modal-actions {
        gap: 6px;
    }
    
    .modal-download,
    .modal-close {
        width: 32px;
        height: 32px;
    }
}

/* Landscape modal optimizations */
@media (max-height: 600px) and (orientation: landscape) {
    .modal-header {
        padding: 10px 16px;
    }
    
    .pdf-title {
        font-size: 13px;
    }
    
    .modal-download,
    .modal-close {
        width: 32px;
        height: 32px;
    }
}


.download-btn {
    margin-top: 16px;
    width: 100%;
    padding: 13px 20px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.download-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 71, 87, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.download-btn:hover::before {
    opacity: 1;
}

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

.download-btn svg {
    flex-shrink: 0;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
}

.download-btn:hover svg {
    animation: downloadBounce 0.6s ease infinite;
}

@keyframes downloadBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(3px);
    }
}

@media (max-width: 768px) {
    .download-btn {
        padding: 12px 18px;
        font-size: 14px;
    }
}


.install-banner {
    position: fixed;
    bottom: -100px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    padding: 18px 24px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    z-index: 999;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.install-banner.show {
    bottom: 0;
    animation: slideUp 0.4s ease-out forwards;
}

.install-content {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text);
}

.install-text strong {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.install-text span {
    font-size: 13px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.85);
}

.install-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-btn {
    padding: 9px 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.install-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.dismiss-btn {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--text);
    font-size: 20px;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
}

.dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    .install-banner {
        padding: 12px 16px;
    }
    
    .install-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .install-text {
        text-align: center;
    }
    
    .install-actions {
        justify-content: center;
    }
    
    .install-btn {
        flex: 1;
    }
}


/* Toast Notifications - Production Grade */
@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateX(400px) scale(0.95);
        opacity: 0;
    }
}

@keyframes toastProgress {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    min-width: 320px;
    max-width: 420px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 10000;
    overflow: hidden;
    backdrop-filter: blur(20px);
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.removing {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    position: relative;
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
}

.toast-icon svg {
    width: 16px;
    height: 16px;
    position: relative;
    z-index: 1;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    line-height: 1.4;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.toast-close {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    padding: 0;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.toast-close svg {
    width: 14px;
    height: 14px;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    animation: toastProgress 3s linear forwards;
    opacity: 0.6;
}

/* Success Toast */
.toast-success .toast-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--resources);
}

.toast-success .toast-progress {
    color: var(--resources);
}

/* Error Toast */
.toast-error .toast-icon {
    background: rgba(255, 71, 87, 0.15);
    color: var(--accent);
}

.toast-error .toast-progress {
    color: var(--accent);
}

/* Warning Toast */
.toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.toast-warning .toast-progress {
    color: #f59e0b;
}

/* Info Toast */
.toast-info .toast-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--physics);
}

.toast-info .toast-progress {
    color: var(--physics);
}

/* Error state */
.empty.error {
    color: var(--accent);
    font-weight: 500;
}

.empty.error::before {
    content: '\26A0';
}

/* Mobile toast adjustments */
@media (max-width: 768px) {
    .toast {
        right: 16px;
        left: 16px;
        min-width: auto;
        max-width: none;
        bottom: 16px;
    }
    
    .toast-content {
        padding: 14px;
    }
    
    .toast-title {
        font-size: 13px;
    }
    
    .toast-message {
        font-size: 12px;
    }
}


/* ================== MUSIC FEATURE STYLES ================== */

/* Music Grid (Custom overrides for music) */
.music-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 120px; /* space for the fixed player */
}

.music-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: pixelate 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    outline: none;
}

.music-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.music-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: scanline 1.5s ease-in-out;
    opacity: 0;
}

.music-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 71, 87, 0.1), transparent);
    animation: shimmer 0.8s ease-in-out;
    pointer-events: none;
}

.music-card:nth-child(1) { animation-delay: 0.6s; }
.music-card:nth-child(1)::before { animation-delay: 0.6s; }
.music-card:nth-child(1)::after { animation-delay: 0.6s; }
.music-card:nth-child(2) { animation-delay: 0.75s; }
.music-card:nth-child(2)::before { animation-delay: 0.75s; }
.music-card:nth-child(2)::after { animation-delay: 0.75s; }
.music-card:nth-child(3) { animation-delay: 0.9s; }
.music-card:nth-child(3)::before { animation-delay: 0.9s; }
.music-card:nth-child(3)::after { animation-delay: 0.9s; }
.music-card:nth-child(4) { animation-delay: 1.05s; }
.music-card:nth-child(4)::before { animation-delay: 1.05s; }
.music-card:nth-child(4)::after { animation-delay: 1.05s; }
.music-card:nth-child(5) { animation-delay: 1.2s; }
.music-card:nth-child(5)::before { animation-delay: 1.2s; }
.music-card:nth-child(5)::after { animation-delay: 1.2s; }
.music-card:nth-child(6) { animation-delay: 1.35s; }
.music-card:nth-child(6)::before { animation-delay: 1.35s; }
.music-card:nth-child(6)::after { animation-delay: 1.35s; }
.music-card:nth-child(7) { animation-delay: 1.5s; }
.music-card:nth-child(7)::before { animation-delay: 1.5s; }
.music-card:nth-child(7)::after { animation-delay: 1.5s; }
.music-card:nth-child(8) { animation-delay: 1.65s; }
.music-card:nth-child(8)::before { animation-delay: 1.65s; }
.music-card:nth-child(8)::after { animation-delay: 1.65s; }
.music-card:nth-child(9) { animation-delay: 1.8s; }
.music-card:nth-child(9)::before { animation-delay: 1.8s; }
.music-card:nth-child(9)::after { animation-delay: 1.8s; }
.music-card:nth-child(10) { animation-delay: 1.95s; }
.music-card:nth-child(10)::before { animation-delay: 1.95s; }
.music-card:nth-child(10)::after { animation-delay: 1.95s; }
.music-card:nth-child(11) { animation-delay: 2.1s; }
.music-card:nth-child(11)::before { animation-delay: 2.1s; }
.music-card:nth-child(11)::after { animation-delay: 2.1s; }
.music-card:nth-child(12) { animation-delay: 2.25s; }
.music-card:nth-child(12)::before { animation-delay: 2.25s; }
.music-card:nth-child(12)::after { animation-delay: 2.25s; }
.music-card:nth-child(13) { animation-delay: 2.4s; }
.music-card:nth-child(13)::before { animation-delay: 2.4s; }
.music-card:nth-child(13)::after { animation-delay: 2.4s; }
.music-card:nth-child(14) { animation-delay: 2.55s; }
.music-card:nth-child(14)::before { animation-delay: 2.55s; }
.music-card:nth-child(14)::after { animation-delay: 2.55s; }
.music-card:nth-child(15) { animation-delay: 2.7s; }
.music-card:nth-child(15)::before { animation-delay: 2.7s; }
.music-card:nth-child(15)::after { animation-delay: 2.7s; }

.music-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.music-cover {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--card), var(--surface));
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--text-tertiary);
    transition: all 0.3s ease;
}

.music-card:hover .music-cover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.3);
}

.music-card.playing .music-cover {
    border-color: var(--accent);
    color: var(--accent);
    animation: spin 6s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.music-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    margin-bottom: 4px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-artist {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
}

.music-download-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.2);
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.music-card:hover .music-download-btn,
.music-download-btn:focus-visible {
    opacity: 1;
    transform: scale(1);
}

.music-download-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.music-download-btn:active {
    transform: scale(0.95);
}

.music-download-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.music-download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.music-download-btn svg {
    flex-shrink: 0;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.music-download-btn:hover svg {
    animation: downloadBounce 0.6s ease infinite;
}

/* Fixed Bottom Player */
.music-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.music-player.hidden {
    transform: translateY(100%);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 30%;
    min-width: 200px;
}

.album-art {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.track-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.track-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    font-size: 12px;
    color: var(--text-tertiary);
}

.player-controls-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 40%;
    gap: 8px;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.control-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    color: var(--text);
    transform: scale(1.1);
}

.control-btn.play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--text);
    color: var(--bg);
}

.control-btn.play-btn:hover {
    transform: scale(1.05);
    background: var(--accent);
    color: white;
}

.control-btn.active {
    color: var(--accent);
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.time-display {
    font-size: 11px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    min-width: 35px;
}

.progress-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--surface);
    outline: none;
    cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-container:hover .progress-bar::-webkit-slider-thumb {
    opacity: 1;
}

.player-volume {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    width: 30%;
    min-width: 150px;
    color: var(--text-secondary);
}

.volume-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    border-radius: 2px;
    background: var(--surface);
    outline: none;
    cursor: pointer;
}

.volume-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text);
    cursor: pointer;
}

@media (max-width: 768px) {
    .music-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .music-card {
        padding: 16px;
    }
    
    .music-cover {
        width: 80px;
        height: 80px;
        margin-bottom: 12px;
    }
    
    .music-title {
        font-size: 14px;
    }
    
    .music-artist {
        font-size: 12px;
    }
    
    .music-download-btn {
        width: 32px;
        height: 32px;
        top: 8px;
        right: 8px;
        opacity: 1;
        transform: scale(1);
    }
    
    .music-download-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .music-player {
        padding: 12px;
        height: auto;
        flex-direction: column;
        gap: 12px;
    }
    
    .player-info {
        width: 100%;
        max-width: 100%;
        justify-content: center;
    }
    
    .album-art {
        width: 40px;
        height: 40px;
    }
    
    .track-details {
        flex: 1;
        min-width: 0;
    }
    
    .track-title {
        font-size: 13px;
    }
    
    .track-artist {
        font-size: 11px;
    }
    
    .player-controls-container {
        width: 100%;
        max-width: 100%;
        gap: 8px;
    }
    
    .player-controls {
        gap: 12px;
        justify-content: center;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    .control-btn.play-btn {
        width: 44px;
        height: 44px;
    }
    
    .control-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .control-btn.play-btn svg {
        width: 22px;
        height: 22px;
    }
    
    .progress-container {
        width: 100%;
        gap: 6px;
    }
    
    .time-display {
        font-size: 10px;
        min-width: 35px;
    }
    
    .progress-bar {
        height: 4px;
    }
    
    .player-volume {
        width: 100%;
        justify-content: center;
        gap: 8px;
        padding-top: 4px;
        border-top: 1px solid var(--border);
    }
    
    .player-volume svg {
        width: 16px;
        height: 16px;
    }
    
    .volume-bar {
        max-width: 120px;
    }
    
    .control-btn#btnClosePlayer {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        margin: 0;
    }
}
