:root {
    --bg: #fbf7ef;
    --bg-strong: #f1eadc;
    --surface: rgba(255, 252, 245, 0.84);
    --surface-strong: rgba(255, 248, 235, 0.98);
    --border: rgba(78, 55, 29, 0.14);
    --text: #1b1916;
    --muted: #6f6658;
    --accent: #d55c2f;
    --accent-deep: #9f3c1d;
    --accent-soft: #ffd7b6;
    --success: #14775d;
    --danger: #b2362f;
    --shadow: 0 24px 70px rgba(90, 55, 20, 0.12);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --mono: "IBM Plex Mono", monospace;
    --sans: "Sora", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sans);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 184, 118, 0.3), transparent 30%),
        radial-gradient(circle at top right, rgba(255, 111, 76, 0.22), transparent 26%),
        linear-gradient(180deg, #fffaf0 0%, #f7f1e5 48%, #efe5d0 100%);
}

button,
input,
textarea,
select {
    font: inherit;
}

.page-shell {
    width: min(1440px, calc(100vw - 32px));
    margin: 24px auto 40px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
    gap: 18px;
    margin-bottom: 18px;
}

.hero-copy,
.hero-panel,
.panel {
    backdrop-filter: blur(20px);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.hero-copy {
    border-radius: var(--radius-xl);
    padding: 34px;
    position: relative;
    overflow: hidden;
}

.hero-copy::after {
    content: "";
    position: absolute;
    inset: auto -80px -90px auto;
    width: 280px;
    height: 280px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(213, 92, 47, 0.24), transparent 65%);
}

.eyebrow {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(213, 92, 47, 0.1);
    color: var(--accent-deep);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.hero h1 {
    margin: 0;
    max-width: 760px;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1.02;
}

.hero-text {
    max-width: 760px;
    margin: 16px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.badge,
.mini-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(89, 61, 34, 0.12);
    background: rgba(255, 255, 255, 0.64);
    color: var(--muted);
    font-size: 12px;
}

.badge-primary {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}

.hero-panel {
    border-radius: var(--radius-xl);
    padding: 24px;
    display: grid;
    gap: 14px;
    align-content: start;
}

.hero-stat {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    border: 1px solid rgba(89, 61, 34, 0.1);
}

.stat-label {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-stat code {
    display: block;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    word-break: break-all;
}

.hero-stat p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
    gap: 18px;
    align-items: start;
}

.panel {
    border-radius: var(--radius-xl);
    padding: 24px;
}

.panel-header,
.card-header,
.action-row,
.field-grid {
    display: grid;
    gap: 14px;
}

.panel-header,
.card-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.panel-header h2,
.card-header h3 {
    margin: 0;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.field-grid .field:nth-child(3),
.field-grid .field:nth-child(4) {
    margin-top: 0;
}

.field {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.field-wide {
    grid-column: span 1;
}

.field-label {
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(82, 60, 35, 0.14);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    border-radius: var(--radius-md);
    padding: 14px 15px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.7;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(213, 92, 47, 0.5);
    box-shadow: 0 0 0 4px rgba(213, 92, 47, 0.12);
}

.image-mode-section {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 16px;
    margin-top: 18px;
}

.upload-box {
    border: 1px dashed rgba(82, 60, 35, 0.22);
    border-radius: var(--radius-lg);
    padding: 18px;
    background: rgba(255, 254, 250, 0.76);
}

.upload-help,
.image-meta {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.image-preview-wrap {
    min-height: 180px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(255, 231, 210, 0.84), rgba(248, 240, 228, 0.84));
    border: 1px solid rgba(82, 60, 35, 0.12);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.image-preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.action-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 22px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    border: 0;
    border-radius: 999px;
    padding: 14px 16px;
    cursor: pointer;
    transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
    transform: translateY(-1px);
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent), #f28d48);
    color: #fff;
    box-shadow: 0 14px 28px rgba(213, 92, 47, 0.26);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    border: 1px solid rgba(82, 60, 35, 0.12);
}

.ghost-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid rgba(82, 60, 35, 0.12);
}

.status-bar {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid rgba(82, 60, 35, 0.1);
}

#modelCapabilityHint {
    margin-top: 14px;
    color: var(--muted);
}


.status-bar.success {
    color: var(--success);
    border-color: rgba(20, 119, 93, 0.22);
    background: rgba(227, 249, 239, 0.9);
}

.status-bar.error {
    color: var(--danger);
    border-color: rgba(178, 54, 47, 0.2);
    background: rgba(255, 233, 231, 0.9);
}

.output-stack {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.output-card {
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    border: 1px solid rgba(82, 60, 35, 0.1);
    overflow: hidden;
}

.output-card .card-header {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(82, 60, 35, 0.08);
}

.code-block {
    margin: 0;
    min-height: 148px;
    max-height: 360px;
    overflow: auto;
    padding: 18px;
    background: linear-gradient(180deg, rgba(35, 27, 18, 0.96), rgba(21, 17, 12, 0.98));
    color: #f7efe0;
    font-size: 13px;
    line-height: 1.65;
    font-family: var(--mono);
    white-space: pre-wrap;
    word-break: break-word;
}

.output-image .result-frame {
    min-height: 380px;
    background:
        linear-gradient(135deg, rgba(255, 224, 192, 0.42), rgba(255, 255, 255, 0.9)),
        repeating-linear-gradient(45deg, rgba(209, 176, 136, 0.08), rgba(209, 176, 136, 0.08) 12px, transparent 12px, transparent 24px);
    display: grid;
    place-items: center;
    padding: 18px;
}

.placeholder {
    max-width: 320px;
    text-align: center;
    color: var(--muted);
    line-height: 1.7;
}

#resultImage {
    max-width: 100%;
    max-height: 640px;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(59, 38, 14, 0.22);
}

@media (max-width: 1120px) {
    .hero,
    .workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .page-shell {
        width: min(100vw - 20px, 100%);
        margin: 10px auto 24px;
    }

    .hero-copy,
    .hero-panel,
    .panel {
        padding: 18px;
    }

    .field-grid,
    .image-mode-section,
    .action-row {
        grid-template-columns: 1fr;
    }

    .header-actions {
        justify-content: flex-start;
    }
}
