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

:root {
    --primary-color: #d5d4d3;
    --secondary-color: #c5c4c3;
    --background: #000000;
    --surface: #1a1a1a;
    --surface-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #999999;
    --border-color: #333333;
    --success-color: #4caf50;
    --error-color: #f44336;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
}

.canvas-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 24 24" fill="none" stroke="%23333333" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"%3E%3Crect width="18" height="18" x="3" y="3" rx="2" ry="2"/%3E%3Ccircle cx="9" cy="9" r="2"/%3E%3Cpath d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 1;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.canvas-container.has-content::before {
    opacity: 0;
}

main {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.generator-section {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 800px;
    width: calc(100% - 4rem);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.input-wrapper {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
    transition: border-color 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.icon-button {
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.icon-button:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.icon-button:active {
    opacity: 0.8;
}

.icon-button.left-icon {
    background: var(--surface);
    border-color: var(--border-color);
}

.icon-button.right-icon {
    background: var(--primary-color);
    color: #000000;
    border-color: var(--primary-color);
}

.icon-button.right-icon:hover {
    border-color: var(--text-primary);
}

.icon-button.right-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

input[type="text"] {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    line-height: 1.5;
    padding: 0;
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    max-width: 600px;
    width: calc(100% - 4rem);
    z-index: 50;
}

#loadingStatus {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.error-container {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--error-color);
    border-radius: 8px;
    padding: 1rem;
    color: var(--error-color);
    position: fixed;
    bottom: 8rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 800px;
    width: calc(100% - 4rem);
    z-index: 100;
}

.result-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90vw;
    max-height: 90vh;
    width: 90vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.result-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.result-icon-button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.result-icon-button:hover {
    background: var(--surface-hover);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.result-content {
    display: flex;
    gap: 2rem;
    width: 100%;
    height: 100%;
    max-height: calc(90vh - 150px);
}

.result-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.image-column {
    display: flex;
    align-items: center;
    justify-content: center;
}

.prompt-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 1rem;
}

.prompt-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prompt-section h3 {
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.prompt-section.error-section {
    order: -1;
}

.prompt-section.error-section h3 {
    color: var(--error-color);
}

.prompt-section.error-section p {
    background: rgba(244, 67, 54, 0.1);
    border-color: var(--error-color);
    color: var(--error-color);
}

.prompt-section p {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.prompt-section pre {
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.generated-image-wrapper {
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: var(--background);
    max-width: 100%;
    max-height: calc(90vh - 150px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.generated-image-wrapper img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(90vh - 150px);
    display: block;
    object-fit: contain;
}

@media (max-width: 768px) {
    .generator-section {
        bottom: 1rem;
        width: calc(100% - 2rem);
    }

    .result-content {
        flex-direction: column;
        gap: 1rem;
        overflow-y: auto;
    }

    .result-column {
        flex: none;
        width: 100%;
    }

    .prompt-column {
        padding-right: 0;
    }
}
