:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

.hero {
    text-align: center;
    padding: 2rem 0;
}

.hero h1 {
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--muted-color);
    margin-bottom: 0;
}

.bilibili-link {
    display: inline-block;
    background: linear-gradient(135deg, #00a1d6, #fb7299);
    color: white !important;
    text-decoration: none;
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 161, 214, 0.3);
}

.bilibili-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 161, 214, 0.4);
    background: linear-gradient(135deg, #0095c8, #f06292);
}

.upload-zone {
    border: 2px dashed var(--muted-border-color);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--card-background-color);
    margin-bottom: 1rem;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.upload-zone svg {
    width: 64px;
    height: 64px;
    color: var(--muted-color);
    margin-bottom: 1rem;
}

.upload-zone.dragover svg {
    color: var(--primary);
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--muted-color);
}

#fileInput {
    display: none;
}

.notice {
    background: color-mix(in srgb, #f59e0b 15%, transparent);
    border: 1px solid #f59e0b;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.notice svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #f59e0b;
}

.notice-content {
    font-size: 0.875rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h2 {
    margin: 0;
}

.download-buttons {
    display: flex;
    gap: 0.5rem;
}

.download-buttons button {
    white-space: nowrap;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.image-card {
    background: var(--card-background-color);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
}

.image-preview {
    width: 162px;
    height: 162px;
    margin: 0 auto 0.75rem;
    background: repeating-conic-gradient(#e5e5e5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px !important;
    height: 24px;
    min-width: 24px;
    padding: 0 !important;
    margin: 0;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    z-index: 10;
    flex-shrink: 0;
}

.image-preview:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    transform: scale(1.15);
    background: rgba(220, 38, 38, 1);
}

.delete-btn svg {
    width: 14px;
    height: 14px;
    color: white;
    stroke-width: 2.5;
    flex-shrink: 0;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-info {
    font-size: 0.75rem;
    color: var(--muted-color);
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.filename-input {
    width: 100%;
    font-size: 0.75rem;
    color: var(--color);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    text-align: center;
    margin: 0;
    transition: all 0.2s ease;
}

.filename-input:hover {
    border-color: var(--muted-border-color);
    background: var(--card-background-color);
}

.filename-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card-background-color);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}

.image-size {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.image-size.success {
    color: #10b981;
}

.image-size.warning {
    color: #f59e0b;
}

.image-card > button,
.image-card .image-info + .image-size + button {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.875rem;
}

.processing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    color: var(--muted-color);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--muted-border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.results-section {
    margin-top: 2rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--muted-border-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #ec4899);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--muted-color);
}

footer {
    text-align: center;
    padding: 2rem 0 1.5rem;
    color: var(--muted-color);
    font-size: 0.875rem;
    border-top: 1px solid var(--muted-border-color);
    margin-top: 3rem;
}

.footer-description {
    margin-bottom: 0.5rem;
    color: var(--muted-color);
}

.footer-links {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-copyright {
    color: var(--muted-color);
}

.footer-separator {
    color: var(--muted-color);
    opacity: 0.5;
}

.footer-link {
    color: var(--muted-color) !important;
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--primary) !important;
}

.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--card-background-color);
    border: 1px solid var(--muted-border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* GIF帧选择弹窗样式 */
.gif-frame-dialog {
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    border: none;
    border-radius: 1rem;
    padding: 0;
    background: var(--card-background-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.gif-frame-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.gif-frame-dialog article {
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.gif-frame-dialog header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--muted-border-color);
    margin: 0;
    background: transparent;
}

.gif-frame-dialog header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.gif-frame-dialog .close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted-color);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.gif-frame-dialog .close-btn:hover {
    background: var(--muted-border-color);
    color: var(--color);
}

.gif-frames-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.gif-frame-item {
    position: relative;
    aspect-ratio: 1;
    border: 2px solid var(--muted-border-color);
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    background: repeating-conic-gradient(#e5e5e5 0% 25%, #fff 0% 50%) 50% / 10px 10px;
}

.gif-frame-item:hover {
    border-color: var(--primary);
    transform: scale(1.02);
}

.gif-frame-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);
}

.gif-frame-item.selected::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gif-frame-item.selected::before {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gif-frame-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gif-frame-item .frame-number {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
}

.gif-frame-dialog footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--muted-border-color);
    margin: 0;
    background: transparent;
}

.gif-dialog-hint {
    font-size: 0.875rem;
    color: var(--muted-color);
    margin: 0 0 1rem 0;
    text-align: center;
}

.gif-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.gif-dialog-actions button {
    margin: 0;
}
