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

:root {
    /* iOS Glass Theme - White, Orange, Black */
    --primary: #ff9500;
    --primary-dark: #ff8c00;
    --primary-darker: #ff7f00;
    --primary-light: #ffaa33;
    --primary-lighter: #ffb84d;
    
    /* Pure Colors */
    --white: #ffffff;
    --black: #000000;
    --orange: #ff9500;
    
    /* Glass Effect Colors */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-bg-dark: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-shadow: rgba(0, 0, 0, 0.1);
    
    /* Background Colors */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-gradient: linear-gradient(135deg, #ff9500 0%, #ff8c00 50%, #ff7f00 100%);
    --bg-gradient-glass: linear-gradient(135deg, rgba(255, 149, 0, 0.9) 0%, rgba(255, 140, 0, 0.9) 100%);
    
    /* Text Colors */
    --text-primary: #000000;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --text-inverse: #ffffff;
    --text-on-glass: #1d1d1f;
    
    /* Semantic Colors */
    --success: #34c759;
    --warning: #ff9500;
    --danger: #ff3b30;
    --info: #007aff;
    
    /* Border & Shadow */
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, #f5f5f7 0%, #ffffff 50%, #f5f5f7 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 149, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 149, 0, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    position: relative;
    z-index: 1;
}

/* Header Styles - Glass Effect */
header {
    background: var(--bg-gradient-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-2xl) var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
    text-align: center;
    color: var(--text-inverse);
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.1),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    pointer-events: none;
}

header > * {
    position: relative;
    z-index: 1;
}

header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
}

header h1 i {
    font-size: 0.9em;
    opacity: 0.95;
}

.subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    opacity: 0.95;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: var(--spacing-2xl);
}

.btn {
    padding: var(--spacing-md) var(--spacing-xl);
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    letter-spacing: 0.01em;
}

.btn i {
    font-size: 0.9em;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--glass-bg);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: var(--glass-bg-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.3);
    color: var(--primary);
}

.btn-download {
    background: var(--bg-gradient);
    color: var(--text-inverse);
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1rem;
    font-weight: 600;
    margin-top: auto;
    border: none;
    box-shadow: 
        0 4px 16px 0 rgba(255, 149, 0, 0.3),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
    letter-spacing: 0.3px;
    border-radius: var(--border-radius-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    animation: pulse-glow 2s ease-in-out infinite;
}

.btn-download::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-download:hover {
    background: linear-gradient(135deg, #ffaa33 0%, #ff9500 50%, #ff8c00 100%);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 
        0 8px 24px 0 rgba(255, 149, 0, 0.5),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.3);
    animation: none;
}

.btn-download:hover::before {
    width: 300px;
    height: 300px;
}

.btn-download:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 
        0 4px 12px 0 rgba(255, 149, 0, 0.4),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
}

.btn-download.downloading {
    animation: downloading-pulse 1s ease-in-out infinite;
    pointer-events: none;
}

.btn-download:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 
            0 4px 16px 0 rgba(255, 149, 0, 0.3),
            inset 0 1px 0 0 rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow: 
            0 4px 20px 0 rgba(255, 149, 0, 0.5),
            inset 0 1px 0 0 rgba(255, 255, 255, 0.2),
            0 0 20px 0 rgba(255, 149, 0, 0.3);
    }
}

@keyframes downloading-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    color: var(--text-primary);
    font-weight: 500;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.1);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Icon animations */
.btn-primary i.fa-sync-alt {
    transition: transform 0.3s ease;
}

.btn-primary:hover i.fa-sync-alt {
    transform: rotate(90deg);
}

/* Error Message */
.error-message {
    background: #fef2f2;
    color: #991b1b;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-xl);
    border-left: 4px solid var(--danger);
    box-shadow: var(--shadow-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.error-message::before {
    content: '\f06a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 1.2em;
}

/* Ebooks Grid */
.ebooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

@media (min-width: 640px) {
    .ebooks-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

@media (min-width: 1024px) {
    .ebooks-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: var(--spacing-2xl);
    }
}

/* Ebook Card - Glass Effect */
.ebook-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.1),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.ebook-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg-gradient);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.ebook-card:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 12px 40px 0 rgba(0, 0, 0, 0.15),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.6);
    border-color: rgba(255, 149, 0, 0.3);
    background: var(--glass-bg-dark);
}

.ebook-card:hover::before {
    transform: scaleX(1);
}

.ebook-icon {
    font-size: 3.5rem;
    text-align: center;
    margin-bottom: var(--spacing-lg);
    color: var(--orange);
    filter: drop-shadow(0 2px 8px rgba(255, 149, 0, 0.3));
    transition: transform 0.3s ease, color 0.3s ease, filter 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ebook-icon i {
    font-size: 1em;
}

.ebook-card:hover .ebook-icon {
    transform: scale(1.1);
    color: var(--primary-dark);
    filter: drop-shadow(0 4px 12px rgba(255, 149, 0, 0.4));
}

.ebook-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xl);
    word-break: break-word;
    flex-grow: 1;
    line-height: 1.5;
    letter-spacing: -0.01em;
    text-align: center;
}

.ebook-meta {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--glass-border);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.meta-item i {
    color: var(--orange);
    width: 16px;
    text-align: center;
    font-size: 0.875rem;
}

.meta-item span:first-of-type {
    font-weight: 600;
    min-width: 50px;
    color: var(--text-primary);
}

.file-size {
    color: var(--orange);
    font-weight: 600;
    background: rgba(255, 149, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    font-size: 0.8125rem;
    border: 1px solid rgba(255, 149, 0, 0.2);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-xl);
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    border: 1px dashed var(--glass-border);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-lg);
    opacity: 0.5;
    color: var(--orange);
}

.empty-icon i {
    font-size: 1em;
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Responsive Design */
@media (max-width: 640px) {
    .container {
        padding: var(--spacing-md);
    }

    header {
        padding: var(--spacing-xl) var(--spacing-lg);
        margin-bottom: var(--spacing-xl);
    }

    .ebooks-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .ebook-card {
        padding: var(--spacing-lg);
    }

    .controls {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .ebooks-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Focus states for accessibility */
.btn:focus-visible,
.ebook-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--primary-light);
    color: var(--text-inverse);
}
