/* CSS Variables - Warm Yellow/Orange Theme */
:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --primary-light: #fbbf24;
    --secondary: #6b7280;
    --secondary-light: #9ca3af;
    --background: #fffbeb;
    --surface: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --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);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --transition: all 0.2s ease-in-out;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-img {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}

.logo-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Page Title */
.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.page-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.title-icon {
    font-size: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.btn:disabled {
    cursor: not-allowed;
}

.btn-primary:disabled {
    color: rgba(255, 255, 255, 0.5);
    opacity: 1;
    box-shadow: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    text-shadow: none;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-md);
    letter-spacing: 1px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-light);
    border-color: var(--secondary-light);
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
    border-radius: var(--radius-lg);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.btn-text:hover {
    color: var(--primary);
}

.btn-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.btn-primary .btn-icon svg {
    stroke-width: 2.5;
}

/* Upload Section */
.upload-section {
    max-width: 600px;
    margin: 0 auto;
}

.upload-form {
    margin-bottom: 3rem;
}

.upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    padding: 3rem 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background-color: rgba(245, 158, 11, 0.05);
}

.upload-area.drag-over {
    transform: scale(1.02);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.upload-placeholder {
    pointer-events: none;
}

.upload-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    color: var(--primary);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-or {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-preview {
    position: relative;
    display: none;
}

.upload-preview.active {
    display: block;
}

.upload-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.preview-remove {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    width: 2rem;
    height: 2rem;
    background-color: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    z-index: 2;
}

.preview-remove svg {
    width: 1rem;
    height: 1rem;
}

.upload-info {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.info-icon {
    font-size: 1rem;
}

.upload-actions {
    text-align: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(255, 251, 235, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
}

.loading-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Error Message */
.error-message {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 101;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-1rem);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--error);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.error-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
    opacity: 0.8;
}

.error-close:hover {
    opacity: 1;
}

/* Features Section */
.features-section {
    max-width: 800px;
    margin: 0 auto;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.feature-card {
    background-color: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.feature-number {
    position: absolute;
    top: -0.75rem;
    left: 50%;
    transform: translateX(-50%);
    width: 1.5rem;
    height: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.feature-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.feature-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.palette-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.1) 100%);
    border-radius: var(--radius);
    text-align: center;
}

.palette-note {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Result Section */
.result-section {
    max-width: 900px;
    margin: 0 auto;
}

.result-header {
    text-align: center;
    margin-bottom: 2rem;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Preview Section */
.preview-section {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.preview-container {
    text-align: center;
}

.pattern-preview {
    max-width: 100%;
    max-height: 800px;
    width: auto;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    image-rendering: pixelated;
}

.preview-info {
    margin-top: 1rem;
    font-size: 0.875rem;
}

/* 桌面端样式 */
.preview-info-desktop {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.preview-info-mobile {
    display: none;
}

.preview-info .info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.preview-info .info-item.size-item {
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
}

.preview-info .info-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.preview-info .info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.preview-info .info-divider {
    width: 1px;
    height: 2rem;
    background-color: var(--border);
}

.size-info-row {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 0.75rem;
}

.size-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.size-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    white-space: nowrap;
}

.size-dimension {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Bead Size Info */
.bead-size-info {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.bead-size-simple {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.bead-size-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.bead-size-label {
    color: var(--text-secondary);
}

.bead-size-value {
    color: var(--primary-dark);
    font-weight: 600;
}

.bead-size-card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    min-width: 180px;
    text-align: center;
    transition: var(--transition);
}

.bead-size-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.bead-size-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.bead-size-icon {
    font-size: 1.25rem;
}

.bead-size-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.bead-size-detail {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.size-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.size-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.bead-size-tip {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Color Stats Section */
.color-stats-section {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.color-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.color-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--background);
    border-radius: var(--radius);
    transition: var(--transition);
}

.color-stat-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.color-block {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    margin-bottom: 0.5rem;
}

.color-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.color-key {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.color-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 新版颜色统计样式 - 与图纸一致 */
.color-stats-grid-new {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.color-stat-item-new {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
}

.color-block-new {
    width: 52px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.color-key-in-block {
    font-weight: 600;
    font-size: 0.75rem;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

.color-count-new {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.color-stats-total {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    font-weight: 600;
    color: var(--text-primary);
}

/* Color Stats Inline - inside preview section */
.color-stats-inline {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--background);
    border-radius: var(--radius);
}

/* Export Settings Section */
.export-settings-section {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Export Settings Inline - inside preview section */
.export-settings-inline {
    margin-top: 1.5rem;
}

.export-settings-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.settings-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.setting-item {
    display: flex;
    align-items: center;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.setting-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.setting-checkbox:checked {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Custom checkbox styling for better control */
.setting-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.setting-item input[type="checkbox"]:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.setting-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.setting-color {
    width: 2.5rem;
    height: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.setting-actions {
    margin-left: auto;
}

/* Materials Section */
.materials-section {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.materials-table-wrapper {
    overflow-x: auto;
}

.materials-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.materials-table th,
.materials-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.materials-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--background);
}

.materials-table tbody tr:hover {
    background-color: var(--background);
}

.col-color {
    width: 50%;
}

.col-code {
    width: 25%;
}

.col-count {
    width: 25%;
    text-align: right;
}

.color-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.color-name {
    font-weight: 500;
}

.count-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.8125rem;
}

.materials-table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    font-weight: 600;
}

.total-label {
    text-align: right;
    color: var(--text-secondary);
}

.total-value {
    text-align: right;
    color: var(--primary-dark);
    font-size: 1rem;
}

/* Download Section */
.download-section {
    text-align: center;
    padding: 1rem 0;
}

.download-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-download {
    min-width: 160px;
}

.download-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Support Section */
.support-section {
    margin-top: 1rem;
}

.support-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.support-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.support-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.support-text {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.support-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.support-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.support-taobao {
    background-color: #ff5000;
    color: white;
}

.support-taobao:hover {
    background-color: #e64a00;
}

.support-xhs {
    background-color: #fe2c55;
    color: white;
}

.support-xhs:hover {
    background-color: #e6284d;
}

.support-sponsor {
    background-color: var(--primary);
    color: white;
}

.support-sponsor:hover {
    background-color: var(--primary-dark);
}

.link-icon {
    font-size: 1rem;
}

/* Result Actions */
.result-actions {
    text-align: center;
    margin-top: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--border-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    text-align: center;
}

.share-preview {
    margin-bottom: 1rem;
}

.share-preview-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    image-rendering: pixelated;
}

.share-text {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.share-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-light);
}

/* Gallery Section */
.gallery-section {
    max-width: 1200px;
    margin: 0 auto;
}

.gallery-header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.back-link {
    position: absolute;
    left: 0;
    top: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary);
}

.back-icon svg {
    width: 1rem;
    height: 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.artwork-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.artwork-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.artwork-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background-color: var(--background);
}

.artwork-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    transition: var(--transition);
}

.artwork-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.artwork-card:hover .artwork-overlay {
    opacity: 1;
}

.artwork-card:hover .artwork-image img {
    transform: scale(1.05);
}

.view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: white;
    color: var(--text-primary);
    border: none;
    padding: 0.625rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.view-btn:hover {
    background-color: var(--primary);
    color: white;
}

.view-btn svg {
    width: 1rem;
    height: 1rem;
}

.artwork-info {
    padding: 1rem;
}

.artwork-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.artwork-colors {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.mini-color-dot {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 1px solid var(--border);
}

.more-colors {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.page-btn:hover:not(.disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn svg {
    width: 1rem;
    height: 1rem;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

.page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.page-number:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

.page-number.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: white;
}

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Gallery Footer */
.gallery-footer {
    margin-top: 2rem;
    padding: 1rem;
    background-color: var(--surface);
    border-radius: var(--radius);
    text-align: center;
}

.footer-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.footer-note a {
    color: var(--primary);
    text-decoration: none;
}

.footer-note a:hover {
    text-decoration: underline;
}

/* Image Modal */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.image-modal .modal-content {
    max-width: 90vw;
    max-height: 90vh;
    background: transparent;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal .modal-close {
    position: absolute;
    top: -3rem;
    right: 0;
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}

.modal-image {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius);
}

/* Sponsor Modal */
.sponsor-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: rgba(0, 0, 0, 0.5);
}

.sponsor-modal .modal-content {
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.sponsor-section {
    margin-bottom: 1.5rem;
}

.sponsor-section:last-child {
    margin-bottom: 0;
}

.sponsor-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.sponsor-links {
    display: flex;
    gap: 1rem;
}

.sponsor-link-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background-color: var(--surface);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.sponsor-link-item:hover {
    border-color: var(--primary);
    background-color: rgba(245, 158, 11, 0.05);
}

.sponsor-icon {
    font-size: 1.25rem;
}

.sponsor-qr {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.qr-image {
    width: 200px;
    height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    object-fit: contain;
    background-color: white;
    overflow: hidden;
    padding: 8px;
    box-sizing: border-box;
}

.qr-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Mobile Sponsor Modal Adjustments */
@media (max-width: 768px) {
    .sponsor-modal {
        padding: 1rem;
    }

    .sponsor-modal .modal-content {
        max-width: 100%;
        margin: 0;
    }

    .sponsor-links {
        flex-direction: column;
    }

    .sponsor-qr {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .qr-image {
        width: 160px;
        height: 160px;
        padding: 6px;
    }
}

/* Footer */
.footer {
    padding: 2rem 0;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

.footer-content {
    text-align: center;
}

.copyright {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.footer-links,
.beian-links {
    font-size: 0.875rem;
}

.footer-links a,
.beian-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.footer-links a:hover,
.beian-links a:hover {
    color: var(--primary);
}

.divider {
    color: var(--border);
    margin: 0 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }

    .header {
        padding: 0.75rem 0;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .logo-text {
        font-size: 1rem;
    }

    .logo-img {
        width: 1.75rem;
        height: 1.75rem;
    }

    .nav {
        display: flex;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    .nav-link {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
        white-space: nowrap;
    }

    .main-content {
        padding: 1.5rem 0;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        width: 3rem;
        height: 3rem;
    }

    .upload-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .download-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-download {
        width: 100%;
        max-width: 280px;
    }

    .support-links {
        flex-direction: column;
    }

    .support-link {
        width: 100%;
        justify-content: center;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .back-link {
        position: static;
        margin-bottom: 1rem;
    }

    .gallery-header {
        display: flex;
        flex-direction: column;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .page-numbers {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .materials-table {
        font-size: 0.8125rem;
    }

    .materials-table th,
    .materials-table td {
        padding: 0.625rem 0.75rem;
    }

    .color-dot {
        width: 1.25rem;
        height: 1.25rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
    }

    .logo-text {
        font-size: 0.9375rem;
    }

    /* Result page mobile optimization */
    .result-section {
        padding: 0;
    }

    .result-header {
        margin-bottom: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .page-subtitle {
        font-size: 0.875rem;
    }

    .result-content {
        gap: 1rem;
    }

    .preview-section {
        padding: 1rem;
        border-radius: var(--radius);
    }

    .pattern-preview {
        max-height: 60vh;
    }

    .preview-info {
        margin-top: 0.5rem;
        font-size: 0.7rem;
    }

    .preview-info-desktop {
        display: none;
    }

    .preview-info-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .preview-info-row {
        display: flex;
        justify-content: space-around;
        align-items: center;
        gap: 0.25rem;
        width: 100%;
    }

    .preview-info-row.size-row {
        gap: 0.5rem;
        padding-top: 0.35rem;
        border-top: 1px solid var(--border-light);
    }

    .preview-info .info-item {
        flex: 1 1 auto;
        min-width: auto;
        gap: 0.1rem;
    }

    .preview-info .info-item.size-item {
        flex-direction: column;
        gap: 0.1rem;
        align-items: center;
    }

    .preview-info .info-value {
        font-size: 0.8rem;
    }

    .preview-info .info-label {
        font-size: 0.6rem;
    }

    .info-divider {
        display: none;
    }

    .color-stats-inline {
        margin-top: 0.5rem;
        padding: 0.5rem;
    }

    .color-stats-grid-new {
        display: grid;
        grid-template-columns: repeat(8, 1fr);
        gap: 0.25rem;
    }

    .color-stat-item-new {
        width: auto;
        min-width: 0;
    }

    .color-block-new {
        width: 100%;
        height: 22px;
        border-radius: 4px;
        margin-bottom: 1px;
    }

    .color-key-in-block {
        font-size: 0.55rem;
    }

    .color-count-new {
        font-size: 0.55rem;
    }

    .export-settings-inline {
        margin-top: 0.5rem;
        padding: 0.5rem;
    }

    .export-settings-title {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }

    .settings-panel {
        gap: 0.35rem;
        flex-wrap: wrap;
        align-items: center;
    }

    .setting-item {
        flex: 0 0 auto;
        min-width: auto;
    }

    .setting-label {
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    .setting-checkbox {
        width: 0.875rem;
        height: 0.875rem;
    }

    .setting-color {
        width: 24px;
        height: 24px;
        padding: 0;
        border: none;
    }

    .setting-actions {
        width: auto;
        margin-top: 0;
        margin-left: auto;
    }

    .setting-actions .btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .download-buttons {
        flex-direction: column;
    }

    .btn-download {
        width: 100%;
    }

    .support-section {
        margin-top: 0.75rem;
    }

    .support-card {
        padding: 1rem;
        border-radius: var(--radius);
    }

    .support-icon {
        font-size: 2rem;
        margin-bottom: 0.25rem;
    }

    .support-title {
        font-size: 1rem;
        margin-bottom: 0.15rem;
    }

    .support-text {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
    }

    .support-links {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .support-link {
        flex: 1 1 calc(33.333% - 0.35rem);
        min-width: 80px;
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.25rem;
    }

    .link-icon {
        font-size: 0.875rem;
    }

    .artwork-stats {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* Control Panel */
.control-panel {
    background: linear-gradient(135deg, var(--surface) 0%, #fafafa 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.panel-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary);
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

/* Usage Tips */
.usage-tips {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius);
    padding: 1rem;
    grid-column: 1 / -1; /* 占满整行 */
}

.tips-content {
    font-size: 0.875rem;
}

.tips-title {
    font-weight: 600;
    color: var(--primary-dark);
    margin: 0 0 0.5rem 0;
}

.tips-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.tips-list li {
    margin-bottom: 0.25rem;
}

.tips-list li:last-child {
    margin-bottom: 0;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.radio-label:hover {
    border-color: var(--primary-light);
    background-color: rgba(245, 158, 11, 0.05);
}

.radio-label input[type="radio"] {
    margin-top: 0.125rem;
}

.radio-text {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.radio-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Range Control */
.range-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.range-input {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

.range-value {
    min-width: 2rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--primary-dark);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Checkbox */
.checkbox-input {
    margin-right: 0.5rem;
}

.checkbox-text {
    font-weight: 500;
    font-size: 0.875rem;
}

/* Upload Hint */
.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

/* Palette Section */
.palette-section {
    max-width: 800px;
    margin: 3rem auto 0;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.section-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.palette-preview {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.palette-dot {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.palette-dot:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-md);
}

/* Result Page Enhancements */
.result-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 968px) {
    .result-container {
        grid-template-columns: 1fr;
    }
}

.pattern-viewer {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.viewer-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pattern-image-container {
    background: #f8f9fa;
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    overflow: auto;
    max-height: 600px;
}

.pattern-image {
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    box-shadow: var(--shadow);
}

.stats-viewer {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.stat-item-card {
    background: var(--background);
    border-radius: var(--radius);
    padding: 0.75rem;
    text-align: center;
    transition: var(--transition);
}

.stat-item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.stat-color {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
    border: 2px solid var(--border);
}

.stat-key {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-count {
    font-size: 0.875rem;
    color: var(--primary-dark);
    font-weight: 600;
}

/* Download Options */
.download-options {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.options-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-item label {
    font-size: 0.875rem;
    cursor: pointer;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Background Removal Modal */
.bg-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.bg-modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.bg-modal-content {
    position: relative;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    animation: modalIn 0.3s ease-out;
}

.bg-modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.bg-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
}

.bg-modal-body {
    padding: 1.5rem;
    text-align: center;
}

.bg-preview-container {
    max-height: 300px;
    overflow: hidden;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background-color: var(--background);
}

.bg-preview-container img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.bg-modal-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.bg-modal-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-light);
}

/* Background Edit Modal */
.bg-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 210;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}

.bg-edit-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
}

.bg-edit-content {
    position: relative;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    display: flex;
    flex-direction: column;
    margin: auto 0;
}

.bg-edit-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
    flex-shrink: 0;
}

.bg-edit-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.bg-edit-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.bg-edit-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.bg-edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background-color: var(--background);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 0.75rem;
    flex-shrink: 0;
}

.brush-tools {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.brush-mode-toggle {
    display: flex;
    gap: 0.5rem;
}

.brush-mode-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.brush-mode-btn:hover {
    border-color: var(--primary);
}

.brush-mode-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.brush-mode-btn.active.bg-mode {
    background-color: #ef4444;
    border-color: #ef4444;
}

.brush-mode-btn.active.fg-mode {
    background-color: #22c55e;
    border-color: #22c55e;
}

.brush-icon {
    font-size: 1rem;
}

.brush-label {
    font-weight: 500;
}

.brush-size-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brush-size-control label {
    font-size: 0.875rem;
    font-weight: 500;
}

.brush-size-control input[type="range"] {
    width: 100px;
}

.brush-size-value,
#edit-brush-size-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-dark);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    min-width: 2.5rem;
    text-align: center;
}

.bg-edit-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.bg-edit-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.bg-edit-preview-wrapper {
    flex: 1;
    position: relative;
    overflow: auto;
    background-color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

#bg-edit-canvas {
    max-width: 100%;
    max-height: 100%;
}

#bg-edit-overlay-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: crosshair;
}

.bg-edit-toggle {
    padding: 0.75rem 1rem;
    background-color: var(--background);
    border-top: 1px solid var(--border-light);
    text-align: center;
    flex-shrink: 0;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

.toggle-text {
    font-size: 0.875rem;
    font-weight: 500;
}

.bg-edit-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

/* Upload Section Enhancements */
.upload-section {
    max-width: 600px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.page-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}
