:root {
    --line: rgba(80, 150, 255, 0.16);
    --panel: rgba(10, 20, 46, 0.92);
    --soft-border: rgba(122, 165, 245, 0.24);
    --text: #f5f7ff;
    --muted: #b5c4e8;
    --accent: #ff8b2c;
}

body {
    color: var(--text);
    min-height: 100vh;
    background: radial-gradient(circle at center, #0a1a35 0%, #071022 52%, #020617 100%);
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    z-index: -2;
    background:
        linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 64px,
        linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 64px 100%;
    opacity: 0.2;
}

body::after {
    z-index: -1;
    background:
        radial-gradient(circle at 16% 18%, rgba(65, 118, 255, 0.22), transparent 34%),
        radial-gradient(circle at 86% 14%, rgba(255, 139, 44, 0.16), transparent 34%),
        radial-gradient(circle at 50% 84%, rgba(40, 155, 255, 0.14), transparent 42%);
}

.page {
    max-width: 1120px;
    margin: 26px auto 36px;
    padding: 0 16px;
}

.image-chat-page {
    max-width: 1060px;
    margin: 20px auto 36px;
    padding: 0 14px;
}

.hero-block {
    text-align: center;
    margin-bottom: 16px;
}

.title {
    text-align: center;
    font-size: clamp(2rem, 3.5vw, 2.9rem);
    font-weight: 800;
    margin-bottom: 10px;
    color: #edf3ff;
    letter-spacing: 0.01em;
}

.subtitle {
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.55;
}

.chat-workspace {
    max-width: 860px;
    margin: 0 auto;
    background: var(--panel);
    border: 1px solid var(--soft-border);
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 18px 36px rgba(5, 12, 32, 0.36);
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 520px;
    min-height: 250px;
    overflow-y: auto;
    padding: 6px 2px 12px;
    margin-bottom: 12px;
}

.assistant-intro {
    color: #d4e3ff;
    border: 1px solid rgba(140, 170, 240, 0.26);
    background: rgba(17, 30, 66, 0.82);
    border-radius: 14px;
    padding: 10px 12px;
}

.assistant-intro p {
    margin: 0;
}

.chat-message {
    display: flex;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.assistant {
    justify-content: flex-start;
}

.chat-bubble {
    width: min(100%, 720px);
    border-radius: 16px;
    padding: 12px;
    border: 1px solid rgba(122, 165, 245, 0.28);
    background: rgba(8, 16, 38, 0.82);
}

.chat-message.user .chat-bubble {
    background: rgba(255, 138, 61, 0.12);
    border-color: rgba(255, 138, 61, 0.34);
}

.prompt-bubble {
    max-width: 88%;
}

.image-bubble {
    background: rgba(16, 35, 74, 0.95);
}

.status-bubble {
    background: rgba(14, 27, 58, 0.9);
}

.assistant-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.chat-label {
    margin: 0 0 6px;
    font-size: 0.86rem;
    font-weight: 700;
    color: #9ec2ff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.chat-text {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.5;
    color: #edf3ff;
    word-break: break-word;
}

.composer {
    display: grid;
    gap: 10px;
    border-top: 1px solid rgba(140, 170, 240, 0.24);
    padding-top: 12px;
}

.composer-actions {
    display: flex;
    justify-content: flex-start;
}

.settings-btn {
    border-radius: 999px;
    border: 1px solid rgba(122, 165, 245, 0.42);
    color: #d8e6ff;
    background: rgba(10, 24, 55, 0.84);
    padding: 7px 12px;
    font-weight: 700;
    cursor: pointer;
}

.advanced-settings {
    border: 1px solid rgba(122, 165, 245, 0.24);
    background: rgba(8, 16, 40, 0.8);
    border-radius: 14px;
    padding: 10px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field {
    display: grid;
    gap: 6px;
}

.field span {
    font-weight: 600;
    font-size: 0.96rem;
    color: #dce7ff;
}

textarea,
input,
select {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid rgba(122, 165, 245, 0.42);
    border-radius: 12px;
    font-size: 1rem;
    background: rgba(6, 13, 30, 0.84);
    color: #f4f8ff;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: rgba(255, 138, 61, 0.72);
    box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.12);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

.prompt-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    border-radius: 999px;
    border: 1px solid var(--accent);
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(100deg, #ff9f41, #ff6f55);
    color: #ffffff;
    border-color: transparent;
}

.btn-primary:hover,
.btn-secondary:hover {
    background: rgba(255, 138, 61, 0.2);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 138, 61, 0.12);
    color: #ffe4cf;
    white-space: nowrap;
}

.loading {
    color: #dfe9ff;
    font-weight: 600;
    font-size: 0.98rem;
}

.error {
    padding: 10px 12px;
    border: 1px solid rgba(255, 123, 123, 0.45);
    background: rgba(95, 22, 22, 0.3);
    color: #ffb4b4;
    border-radius: 10px;
    font-size: 0.95rem;
}

#generated-image {
    width: 100%;
    max-width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(122, 165, 245, 0.34);
    display: block;
    background: rgba(8, 13, 28, 0.9);
}

.hidden {
    display: none;
}

@media (max-width: 860px) {
    .image-chat-page {
        margin-top: 18px;
        padding: 0 12px;
    }

    .title {
        font-size: clamp(1.65rem, 8vw, 2.15rem);
    }

    .subtitle,
    .chat-text,
    textarea,
    input,
    select,
    .btn-primary,
    .btn-secondary,
    .loading,
    .error {
        font-size: 0.95rem;
    }

    .row {
        grid-template-columns: 1fr;
    }

    .prompt-row {
        grid-template-columns: 1fr;
    }

    .assistant-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .chat-bubble {
        width: 100%;
    }
}
