:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.lang-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.lang-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    border-color: var(--primary-color);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.input-wrapper {
    display: flex;
    gap: 12px;
}

.input-wrapper input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.primary-btn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.token-section {
    margin-top: 16px;
}

.token-section details {
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.token-section summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
}

.token-input-wrapper {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.token-input-wrapper input {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.token-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.control-item input[type="number"] {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.control-item input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.color-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 50px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: monospace;
}

.preview-container {
    background: var(--background);
    border-radius: var(--radius-md);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
    padding: 20px;
}

.placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

#mosaic-canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.stats {
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    background: var(--background);
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.stats span {
    color: var(--primary-color);
    font-weight: 700;
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    border-color: var(--primary-color);
    background: white;
}

.export-btn .btn-icon {
    font-size: 1.2rem;
}

.contributors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    margin-bottom: 0;
}

.copy-list-btn {
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-list-btn:hover {
    background: var(--primary-hover);
}

.contributor-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--background);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: transform 0.2s;
}

.contributor-item:hover {
    transform: translateY(-2px);
}

.contributor-item img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.contributor-item a {
    color: var(--text-primary);
    text-decoration: none;
}

.contributor-item a:hover {
    color: var(--primary-color);
}

footer {
    margin-top: 40px;
    padding: 30px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

.support-section {
    padding: 20px;
    background: var(--background);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 400px;
}

.support-section p {
    margin-bottom: 12px;
    font-weight: 500;
}

.support-buttons {
    display: flex;
    justify-content: center;
}

.support-details {
    text-align: center;
}

.support-details summary {
    cursor: pointer;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: inline-block;
}

.support-qr {
    margin-top: 16px;
    padding: 16px;
    background: white;
    border-radius: var(--radius-sm);
}

.qr-placeholder {
    width: 150px;
    height: 150px;
    background: var(--background);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px auto;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 10px;
}

.privacy-notice {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--text-primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: opacity 0.2s;
}

.github-link:hover {
    opacity: 0.9;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-md);
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    header {
        padding: 30px 16px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .primary-btn {
        width: 100%;
    }

    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .export-buttons {
        flex-direction: column;
    }

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

@media (max-width: 480px) {
    .controls-grid {
        grid-template-columns: 1fr;
    }
}
