* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.text-blue {
    color: #3b82f6;
}

.opacity-30 {
    opacity: 0.3;
}

.icon-sm { width: 1rem; height: 1rem; }
.icon-md { width: 1.25rem; height: 1.25rem; }
.icon-lg { width: 2rem; height: 2rem; }
.icon-xl { width: 4rem; height: 4rem; margin-bottom: 1rem; }

.header {
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .main-wrapper {
        flex-direction: row;
    }
}

.sidebar {
    width: 100%;
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    flex-shrink: 0;
}

@media (min-width: 1024px) {
    .sidebar {
        width: 20rem;
    }
}

.upload-box {
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    background-color: #ffffff;
    position: relative;
    transition: background-color 0.2s;
}

.upload-box:hover {
    background-color: #f9fafb;
}

.upload-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    pointer-events: none;
}

.upload-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.upload-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
}

.controls-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

.control-group {
    background-color: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
}

.control-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: bold;
    color: #374151;
    margin-bottom: 0.75rem;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-input {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    border: none;
    padding: 0;
}

.btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #f3f4f6;
}

.range-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: bold;
    color: #374151;
    margin-bottom: 0.5rem;
}

.range-input {
    width: 100%;
    height: 0.5rem;
    background-color: #e5e7eb;
    border-radius: 0.5rem;
    appearance: none;
    cursor: pointer;
    accent-color: #2563eb;
}

.btn-primary {
    margin-top: auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: #2563eb;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-primary:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.main-area {
    flex: 1;
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    border: 2px dashed #f3f4f6;
    border-radius: 0.5rem;
}

.main-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1rem;
    overflow: hidden;
}

.enlarged-preview {
    width: 100%;
    height: 16rem;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

@media (min-width: 768px) { .enlarged-preview { height: 20rem; } }
@media (min-width: 1024px) { .enlarged-preview { height: 24rem; } }

.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-badge {
    font-size: 0.875rem;
    font-weight: bold;
    color: #4b5563;
    background-color: #ffffff;
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.enlarged-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 20px 13px rgba(0, 0, 0, 0.03)) drop-shadow(0 8px 5px rgba(0, 0, 0, 0.08));
    transition: opacity 0.3s;
}

.placeholder-text {
    color: #9ca3af;
    font-weight: 500;
}

.grid-title {
    font-size: 0.875rem;
    font-weight: bold;
    color: #4b5563;
    flex-shrink: 0;
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    overflow-y: auto;
    padding-bottom: 0.5rem;
    align-content: flex-start;
    flex: 1;
}

.card {
    width: 12rem;
    background-color: #ffffff;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px #bfdbfe;
}

.card-header {
    background-color: #f9fafb;
    padding: 0.375rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f3f4f6;
}

.card-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 0.25rem;
}

.btn-remove {
    color: #9ca3af;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
}

.btn-remove:hover {
    color: #ef4444;
}

.card-preview {
    position: relative;
    width: 100%;
    height: 8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-loading-badge {
    font-size: 0.625rem;
    font-weight: bold;
    color: #4b5563;
    background-color: #ffffff;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.07));
}

.btn-download-small {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    background-color: #f9fafb;
    color: #374151;
    padding: 0.375rem;
    border: none;
    border-top: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

.btn-download-small:hover {
    background-color: #f3f4f6;
}

.checkerboard-bg {
    background-image:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}