@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0a0;
    --border-color: #333333;
    --accent-color: #ffffff;
    --error-color: #cf6679;
    --font-family: 'Noto Sans SC', sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--primary-text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 650px;
}

.header {
    text-align: center;
    padding: 20px 0 30px;
}

.header h1 {
    margin: 0;
    font-size: 2.2em;
    font-weight: 700;
    color: var(--accent-color);
}

.header p {
    margin: 5px 0 0;
    color: var(--secondary-text-color);
}

.input-section {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: var(--font-family);
    box-sizing: border-box;
    background-color: var(--background-color);
    color: var(--primary-text-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #333;
    border-radius: 3px;
    outline: none;
    transition: background .2s;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid var(--surface-color);
    transition: transform 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: var(--secondary-text-color);
    margin-top: 8px;
}

.generate-btn, .retry-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    font-weight: 500;
    color: var(--background-color);
    background-color: var(--accent-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin-top: 10px;
}

.generate-btn:hover, .retry-btn:hover {
    background-color: #cccccc;
}

.generate-btn:disabled {
    background-color: #555;
    color: #888;
    cursor: not-allowed;
}

.output-container {
    min-height: 200px; /* Reserve space */
    background: var(--surface-color);
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.status-section .loading-container, .error-section .error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.status-text {
    font-size: 1.1em;
    font-weight: 500;
    margin-bottom: 10px;
}

.timer {
    color: var(--secondary-text-color);
}

.result-section h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 500;
}

.result-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    color: var(--secondary-text-color);
}

.image-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

#resultImage {
    width: 100%;
    display: block;
}

.error-message {
    color: var(--error-color);
}

.error-message h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.retry-btn {
    background: var(--error-color);
    color: var(--accent-color);
    width: auto;
    padding: 10px 30px;
    margin-top: 20px;
}

.footer {
    text-align: center;
    padding: 30px 0 10px;
    font-size: 0.9em;
    color: var(--secondary-text-color);
}

@media (max-width: 640px) {
    body {
        padding: 10px;
    }
    .container {
        border-radius: 0;
    }
    .input-section, .output-container {
        padding: 20px;
    }
}