:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    padding: 20px;
    user-select: none;
}

.container {
    width: 100%;
    max-width: 500px;
}

.converter-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    text-align: center;
    transition: transform 0.3s ease;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 32px;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 40px 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fbfcfe;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: #f5f7ff;
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.upload-area:hover .upload-icon {
    color: var(--primary);
}

.upload-content span {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
}

.upload-content small {
    color: var(--text-muted);
}

/* Progress */
.progress-container {
    margin-top: 24px;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.2s ease;
}

#progressText {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

/* Result Area */
.result-area {
    margin-top: 32px;
    animation: fadeIn 0.5s ease;
}

.preview-box {
    width: 100%;
    max-height: 250px;
    border-radius: 12px;
    overflow: hidden;
    background: #f1f5f9;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-box img {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
}

.stats-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-item {
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-item .value {
    font-weight: 600;
    font-size: 0.9rem;
}

.stat-item.highlight .value {
    color: var(--success);
}

.btn-download {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    transition: background 0.3s ease, transform 0.2s ease;
}

.btn-download:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-reset {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s ease;
}

.btn-reset:hover {
    color: var(--text-main);
}

.error-message {
    margin-top: 20px;
    padding: 12px;
    background: #fef2f2;
    color: var(--error);
    border-radius: 12px;
    font-size: 0.9rem;
    border: 1px solid #fee2e2;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-box.transparent-bg {
    background-image:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Album Styles */
.gallery-title-area {
    display: flex;
    flex-direction: column;
}

.album-item {
    background: white;
    border-radius: 20px;
    height: 200px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    border: 1px solid var(--border);
}

.album-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.album-preview {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-soft);
    transition: transform 0.6s ease;
}

.album-item:hover .album-preview {
    transform: scale(1.1);
}

.album-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent 60%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    color: white;
}

.album-item .name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.album-item .count {
    font-size: 0.85rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.album-item:hover .count {
    opacity: 1;
    transform: translateY(0);
}

.album-icon-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-soft);
    color: var(--primary);
}

@media (max-width: 480px) {
    .converter-card {
        padding: 24px;
    }

    .stats-box {
        grid-template-columns: 1fr;
    }
}

/* Modal and Cropper */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.crop-container {
    width: 100%;
    max-height: 400px;
    background: #000;
    overflow: hidden;
    margin-bottom: 20px;
}

.crop-container img {
    max-width: 100%;
}

.crop-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.edit-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.btn-edit {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-aspect {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-aspect:hover,
.btn-aspect.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.modal-footer {
    display: flex;
    gap: 12px;
}

.btn-secondary {
    flex: 1;
    padding: 12px;
    background: #f1f5f9;
    color: var(--text-main);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    flex: 2;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

/* Gallery Section */
.gallery-section {
    /*margin-top: 60px;*/
    width: 100%;
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.gallery-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.btn-refresh {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-refresh:hover {
    background: #f8fafc;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.gallery-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.gallery-item:hover {
    transform: translateY(-4px);
}

.gallery-thumb {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f1f5f9;
    position: relative;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-info {
    padding: 10px;
}

.gallery-info .name {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.gallery-info .size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.gallery-item .actions {
    display: flex;
    padding: 8px;
    gap: 4px;
}

.gallery-item .btn-action {
    flex: 1;
    text-align: center;
    padding: 4px;
    font-size: 0.7rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    text-decoration: none;
}

.gallery-item .btn-action:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Hamburger Button */
.hamburger {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-main);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Sidebar Open Animation */
body.sidebar-open .hamburger span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

body.sidebar-open .hamburger span:nth-child(2) {
    opacity: 0;
}

body.sidebar-open .hamburger span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: white;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 80px 24px 24px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
}

body.sidebar-open .sidebar {
    transform: translateX(0);
}

.sidebar-header {
    margin-bottom: 40px;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 8px;
}

.sidebar-nav a {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: #f5f7ff;
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

/* Overlay */
.overlay-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

body.sidebar-open .overlay-sidebar {
    opacity: 1;
    pointer-events: auto;
}