/* Agnes Playground - Minimal product UI
   Aesthetic: Linear-clean monochrome + single restrained accent
   Dial: variance 5 / motion 3 / density 3
*/

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f4f4f5;
    --bg-elevated: #fafafa;
    --bg-strong: #ffffff;
    --bg-soft: #ececee;
    --panel: #ffffff;
    --panel-strong: #ffffff;
    --border: rgba(24, 24, 27, 0.08);
    --border-strong: rgba(24, 24, 27, 0.14);
    --text: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --accent: #3f5cff;
    --accent-soft: rgba(63, 92, 255, 0.08);
    --accent-strong: #2f49e6;
    --success: #16a34a;
    --danger: #dc2626;
    --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 12px 32px rgba(24, 24, 27, 0.06);
    --shadow-soft: 0 1px 2px rgba(24, 24, 27, 0.03), 0 8px 20px rgba(24, 24, 27, 0.04);
    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --shell: 1280px;
    --font-sans: "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
    --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace;
    --header-h: 64px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #09090b;
        --bg-elevated: #0c0c0e;
        --bg-strong: #111113;
        --bg-soft: #0f0f11;
        --panel: #111113;
        --panel-strong: #151518;
        --border: rgba(250, 250, 250, 0.08);
        --border-strong: rgba(250, 250, 250, 0.14);
        --text: #fafafa;
        --text-secondary: #a1a1aa;
        --text-muted: #71717a;
        --accent: #6b84ff;
        --accent-soft: rgba(107, 132, 255, 0.12);
        --accent-strong: #8a9dff;
        --success: #4ade80;
        --danger: #f87171;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px rgba(0, 0, 0, 0.28);
        --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.22), 0 10px 24px rgba(0, 0, 0, 0.18);
    }
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.preview-open {
    overflow: hidden;
}

img,
video {
    display: block;
    max-width: 100%;
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    border: 0;
    background: none;
    color: inherit;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-shell {
    position: relative;
    min-height: 100dvh;
}

.shell {
    position: relative;
    z-index: 1;
    width: min(calc(100% - 48px), var(--shell));
    margin: 0 auto;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-h);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border-bottom: 1px solid var(--border);
}

.navbar {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo,
.footer-logo {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 999px;
    display: block;
}

.brand-logo {
    box-shadow: 0 0 0 1px var(--border);
}

@media (prefers-color-scheme: dark) {
    .brand-logo,
    .footer-logo {
        filter: invert(1);
        box-shadow: none;
    }
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.brand-copy strong {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand-copy span {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-links,
.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a,
.nav-external {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: color 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.nav-links a:hover,
.nav-links a:focus-visible,
.nav-external:hover,
.nav-external:focus-visible {
    color: var(--text);
    background: color-mix(in srgb, var(--text) 4%, transparent);
}

.nav-external {
    border: 1px solid transparent;
}

.nav-actions .nav-external {
    padding: 7px 10px;
}

/* Shared interactive controls */
.nav-cta,
.button,
.btn-api,
.btn-secondary,
.btn-generate,
.toolbar-btn,
.chat-send,
.modal-cancel,
.modal-save,
.preview-download,
.result-action-btn,
.prompt-clear-btn {
    border-radius: var(--radius-sm);
    transition:
        transform 0.18s var(--ease),
        background-color 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        opacity 0.18s ease;
}

.nav-cta,
.button,
.btn-generate,
.modal-save,
.preview-download,
.chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.nav-cta,
.button-primary,
.btn-generate,
.modal-save,
.preview-download,
.chat-send {
    background: var(--text);
    color: var(--bg);
    box-shadow: none;
}

.nav-cta:hover,
.button-primary:hover,
.btn-generate:hover,
.modal-save:hover,
.preview-download:hover,
.chat-send:hover {
    background: color-mix(in srgb, var(--text) 88%, var(--accent));
}

.button-secondary,
.btn-api,
.btn-secondary,
.toolbar-btn,
.modal-cancel,
.result-action-btn,
.prompt-clear-btn {
    background: var(--bg-strong);
    color: var(--text);
    border: 1px solid var(--border);
}

.button-secondary:hover,
.btn-api:hover,
.btn-secondary:hover,
.toolbar-btn:hover,
.modal-cancel:hover,
.result-action-btn:hover,
.prompt-clear-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.nav-cta:active,
.button:active,
.btn-api:active,
.btn-secondary:active,
.btn-generate:active,
.toolbar-btn:active,
.chat-send:active,
.modal-cancel:active,
.modal-save:active,
.preview-download:active,
.result-action-btn:active,
.prompt-clear-btn:active {
    transform: scale(0.98);
}

.btn-api {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.status-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--text-muted);
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent);
}

/* Legacy hero leftovers (safe if unused) */
.hero {
    min-height: calc(100dvh - var(--header-h));
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 48px;
    align-items: center;
    padding: 48px 0 32px;
}

.hero-copy {
    max-width: 620px;
}

.hero-kicker,
.sidebar-label,
.visual-note-label {
    margin: 0 0 12px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero h1,
.section-heading h2 {
    margin: 0;
    font-size: clamp(2rem, 3.6vw, 2.75rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
    font-weight: 600;
}

.hero-body,
.section-heading p,
.site-footer p {
    margin: 12px 0 0;
    max-width: 48ch;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.hero-metrics {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr 0.85fr;
    gap: 12px;
    margin-top: 28px;
}

.hero-metrics article,
.visual-note,
.results,
.faq-item,
.site-footer {
    background: var(--panel);
    border: 1px solid var(--border);
}

.hero-metrics article {
    padding: 16px;
    border-radius: var(--radius-md);
}

.hero-metrics strong {
    display: block;
    font-size: 14px;
    letter-spacing: -0.02em;
}

.hero-metrics span {
    display: block;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

.hero-visual {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 16px;
    align-items: end;
}

.visual-frame {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
}

.visual-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.visual-frame-large {
    min-height: 520px;
}

.visual-stack {
    display: grid;
    gap: 16px;
}

.visual-frame-wide {
    min-height: 220px;
}

.visual-note {
    padding: 20px;
    border-radius: var(--radius-lg);
}

.visual-note p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* Main sections */
.workspace,
.usage,
.faq {
    padding: 28px 0 0;
}

.workspace-hero {
    min-height: calc(100dvh - var(--header-h));
    display: grid;
    align-content: start;
    gap: 18px;
    padding-top: 18px;
    padding-bottom: 24px;
}

.section-heading {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 42rem;
}

.section-heading h2 {
    font-size: clamp(1.5rem, 2.4vw, 1.875rem);
}

.usage-card h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.3;
    letter-spacing: -0.02em;
    font-weight: 600;
}

.usage-card p,
.faq-answer p,
.results-subtitle {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
}

.workspace-intro {
    max-width: 720px;
    padding-top: 8px;
    padding-bottom: 4px;
}

.workspace-kicker {
    margin: 0 0 10px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 550;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.workspace-intro h1 {
    margin: 0;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    line-height: 1.12;
    letter-spacing: -0.04em;
    font-weight: 600;
}

.workspace-intro p {
    margin: 12px 0 0;
    color: var(--text-secondary);
    line-height: 1.65;
    max-width: 52ch;
    font-size: 15px;
}

.models {
    padding-top: 56px;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--panel);
}

.model-card {
    padding: 22px 24px;
    border-right: 1px solid var(--border);
}

.model-card:last-child {
    border-right: 0;
}

.model-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.model-card-top strong {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.model-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 550;
    white-space: nowrap;
}

.model-card p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
}

.glass-card {
    padding: 18px;
    border-radius: var(--radius-xl);
    background: var(--panel-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.glass-card-hero {
    min-height: min(720px, calc(100dvh - 220px));
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.workspace-badge,
.control-card-label {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 6px;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 550;
    letter-spacing: 0;
}

.usage {
    padding-top: 56px;
}

.usage-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--panel);
}

.usage-card {
    padding: 24px;
    border-radius: 0;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border);
    box-shadow: none;
}

.usage-card:last-child {
    border-right: 0;
}

.usage-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-bottom: 14px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Tabs */
.tabs {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 4px;
    margin-bottom: 0;
    padding: 4px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.tab {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0;
    width: 100%;
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 7px;
    border: 1px solid transparent;
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.tab.active {
    background: var(--bg-strong);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.06);
    border-color: var(--border);
}

.tab span:last-child {
    display: none;
}

.tab-icon {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.workspace-mode {
    display: grid;
    gap: 16px;
}

.generate-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: 16px;
    align-items: stretch;
}

.generate-main {
    min-width: 0;
    display: flex;
}

.generate-sidebar {
    display: grid;
    gap: 12px;
    height: 100%;
    align-content: start;
}

.control-card {
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--bg);
    border: 1px solid var(--border);
}

.control-card .bottom-bar {
    margin-top: 12px;
}

.type-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.type-option {
    display: grid;
    gap: 2px;
    min-height: 64px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-strong);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.type-option strong {
    font-size: 13px;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--text);
    font-weight: 600;
}

.type-option span {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
}

.type-option:hover {
    border-color: var(--border-strong);
}

.type-option.active {
    background: var(--bg-strong);
    border-color: var(--text);
    box-shadow: none;
}

.type-option.active strong,
.type-option.active span {
    color: var(--text);
}

.control-card .params-row,
.control-card .action-row {
    flex-direction: column;
    align-items: stretch;
}

.control-card .param-trigger,
.control-card .btn-secondary,
.control-card .btn-generate {
    width: 100%;
}

.control-card-actions .action-row {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.control-note {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
}

.input-main {
    position: relative;
    display: grid;
    gap: 12px;
    margin-bottom: 0;
    flex: 1;
    height: 100%;
}

.upload-area {
    display: none;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-strong);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease;
}

.upload-area.active {
    display: block;
}

.upload-area.has-images {
    border-style: solid;
}

.upload-area:hover {
    border-color: color-mix(in srgb, var(--text) 28%, var(--border));
}

.upload-placeholder,
.upload-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.upload-plus,
.param-prefix {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-strong);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    flex: 0 0 auto;
}

.upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.upload-preview-item,
.chat-preview-item {
    position: relative;
    width: 64px;
    height: 64px;
}

.upload-preview-item img,
.chat-preview-item img,
.chat-msg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.upload-remove,
.chat-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--bg-strong);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 12px;
}

.upload-add {
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
}

.prompt-area {
    position: relative;
    display: flex;
    flex: 1;
    min-height: 0;
}

.prompt-input-wrap {
    position: relative;
    display: flex;
    flex: 1;
}

.prompt-input,
.chat-input,
.modal-input {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.prompt-input::placeholder,
.chat-input::placeholder,
.modal-input::placeholder {
    color: var(--text-muted);
}

.prompt-input:focus,
.chat-input:focus,
.modal-input:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 6%, transparent);
    background: var(--bg-strong);
}

.prompt-input {
    min-height: 340px;
    height: 100%;
    padding: 16px 16px 52px;
    resize: vertical;
    line-height: 1.65;
    font-size: 14px;
}

.prompt-clear-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    cursor: pointer;
}

.prompt-clear-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.generation-status {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    display: none;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-strong) 92%, transparent);
    border: 1px solid var(--border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.generation-status.active {
    display: inline-flex;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 650;
}

.status-icon.loading {
    animation: pulse 1.4s ease infinite;
}

.status-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-time {
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
}

.bottom-bar {
    display: grid;
    gap: 12px;
}

.params-row,
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-row {
    justify-content: stretch;
}

.param-dropdown {
    position: relative;
}

.param-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    background: var(--bg-strong);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}

.param-arrow {
    color: var(--text-muted);
    font-size: 10px;
    margin-left: auto;
}

.param-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    padding: 6px;
    display: none;
    background: var(--panel-strong);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    z-index: 5;
}

.param-dropdown.active .param-menu {
    display: block;
}

.param-option {
    padding: 10px 12px;
    border-radius: 7px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
}

.param-option:hover,
.param-option.active {
    background: var(--bg);
    color: var(--text);
}

.btn-secondary {
    min-height: 40px;
    padding: 0 14px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
}

.btn-generate:focus-visible,
.chat-send:focus-visible,
.modal-save:focus-visible,
.nav-links a:focus-visible,
.btn-api:focus-visible,
.tab:focus-visible,
.type-option:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

.btn-generate:disabled,
.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Chat */
.chat-area {
    display: none;
    gap: 12px;
}

.chat-area.active {
    display: grid;
}

.chat-toolbar,
.chat-input-row,
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-toolbar-left,
.chat-toolbar-right,
.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}


.chat-messages,
.chat-modal-messages {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    min-height: 360px;
    max-height: 540px;
    padding: 16px;
    overflow: auto;
    border-radius: var(--radius-lg);
    background: var(--bg);
    border: 1px solid var(--border);
}

.chat-msg {
    width: fit-content;
    max-width: min(78%, 42rem);
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.65;
    font-size: 14px;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.chat-msg.assistant {
    margin-right: auto;
    background: var(--bg-strong);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

.chat-msg.user {
    margin-left: auto;
    margin-right: 0;
    background: var(--text);
    color: var(--bg);
    border: 0;
    border-bottom-right-radius: 6px;
}

.chat-msg-images {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-msg-image {
    width: 72px;
    height: 72px;
}

.chat-msg code,
.preview-prompt-text code {
    padding: 1px 5px;
    border-radius: 5px;
    background: color-mix(in srgb, var(--text) 6%, transparent);
    font-size: 0.9em;
    font-family: var(--font-mono);
}

.chat-msg pre {
    margin: 10px 0 0;
    padding: 12px;
    overflow-x: auto;
    border-radius: 8px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 12px;
}

.chat-msg a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-input-wrapper {
    width: 100%;
}

.chat-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-strong);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.chat-upload:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.chat-input {
    flex: 1;
    min-height: 40px;
    padding: 0 14px;
    font-size: 14px;
}

.thinking-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.thinking-dots span {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--text-muted);
    animation: bounce 0.9s ease infinite alternate;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.12s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.24s;
}

/* Results */
.results {
    margin-top: 16px;
    padding: 18px;
    border-radius: var(--radius-xl);
    box-shadow: none;
}

.results-header {
    margin-bottom: 14px;
}

.results-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.results-empty {
    display: grid;
    place-items: center;
    min-height: 120px;
    padding: 28px 16px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-strong);
    background: var(--bg);
    color: var(--text-muted);
    text-align: center;
    font-size: 13px;
}

.results-empty p {
    margin: 0;
    max-width: 36ch;
    line-height: 1.6;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.result-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.18s var(--ease);
}

.result-card:hover {
    border-color: var(--border-strong);
}

.result-media,
.result-video {
    width: 100%;
    height: 280px;
    object-fit: cover;
    background: var(--bg-soft);
}

.result-badge,
.result-size-badge {
    position: absolute;
    left: 10px;
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--bg-strong) 88%, transparent);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 550;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.result-badge {
    top: 10px;
}

.result-size-badge {
    top: 40px;
    display: none;
}

.result-size-badge.visible {
    display: inline-flex;
}

.result-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s var(--ease);
}

.result-card:hover .result-actions,
.result-card:focus-within .result-actions {
    opacity: 1;
    transform: translateY(0);
}

.result-action-btn {
    min-height: 32px;
    padding: 0 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    background: color-mix(in srgb, var(--bg-strong) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.result-action-download:hover,
.result-action-download:focus-visible {
    background: var(--bg-strong);
    border-color: var(--border-strong);
    color: var(--text);
}

.result-action-remove:hover,
.result-action-remove:focus-visible {
    background: color-mix(in srgb, var(--danger) 10%, var(--bg-strong));
    border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
    color: var(--danger);
}

/* FAQ */
.faq {
    padding-top: 56px;
    padding-bottom: 48px;
}

.faq-list {
    display: grid;
    gap: 0;
    padding-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--panel);
}

.faq-item {
    border-radius: 0;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}

.faq-item:last-child {
    border-bottom: 0;
}

.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    font-weight: 550;
    letter-spacing: -0.01em;
}

.faq-question:hover {
    background: color-mix(in srgb, var(--text) 2%, transparent);
}

.faq-symbol {
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s var(--ease);
}

.faq-answer {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s var(--ease);
}

.faq-answer > p {
    overflow: hidden;
    margin: 0;
    padding: 0 20px 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
}

.faq-item.active .faq-answer {
    grid-template-rows: 1fr;
}

.faq-item.active .faq-answer > p {
    padding-bottom: 18px;
}

.faq-item.active .faq-symbol {
    transform: rotate(45deg);
}

/* Footer */
.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 28px auto 40px;
    padding: 20px 0 8px;
    border-top: 1px solid var(--border);
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.footer-brand {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.footer-brand strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.footer-brand p,
.site-footer p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
    max-width: 42ch;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.footer-links a:hover,
.footer-links a:focus-visible {
    color: var(--text);
    background: color-mix(in srgb, var(--text) 4%, transparent);
}

.usage-card a,
.modal-hint a {
    color: var(--text);
    font-weight: 550;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: color-mix(in srgb, var(--text) 28%, transparent);
}

.usage-card a:hover,
.modal-hint a:hover {
    text-decoration-color: var(--text);
}

/* Modals */
.modal-overlay,
.preview-modal,
.chat-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(9, 9, 11, 0.42);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 40;
}

.preview-modal {
    overflow: hidden;
    align-items: center;
}

.modal-overlay.active,
.preview-modal.active,
.chat-modal.active {
    display: flex;
}

.modal,
.preview-content,
.chat-modal-content {
    width: min(100%, 960px);
    background: var(--panel-strong);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.modal {
    max-width: 440px;
}

.modal-header,
.modal-footer,
.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
}

.modal-header h3,
.chat-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.modal-header,
.chat-modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    gap: 8px;
}

.modal-body {
    padding: 18px 20px;
}

.modal-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.modal-input {
    min-height: 42px;
    padding: 0 12px;
    font-size: 14px;
}

.modal-hint {
    margin-top: 10px;
    font-size: 13px;
}

.modal-hint a {
    color: var(--accent);
    font-weight: 550;
}

.modal-close,
.preview-close,
.chat-modal-close {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 16px;
}

.modal-close:hover,
.preview-close:hover,
.chat-modal-close:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.modal-cancel,
.modal-save,
.preview-download {
    min-height: 38px;
    padding: 0 14px;
    cursor: pointer;
}

.preview-content {
    position: relative;
    width: min(100%, 1180px);
    height: min(820px, calc(100dvh - 48px));
    padding: 20px 56px 20px 20px;
    margin: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--panel-strong);
    box-shadow: var(--shadow-soft);
}

/* Hidden until openPreview mounts it into the prompt header. */
.preview-content > .preview-download {
    display: none;
}

.preview-body {
    display: grid;
    gap: 18px;
    flex: 1;
    min-height: 0;
}

.preview-body-image,
.preview-body-video {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    align-items: stretch;
    height: 100%;
}

.preview-media-wrap img,
.preview-body-video video {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-lg);
    object-fit: contain;
    background: transparent;
}

/* Keep natural aspect ratio; never force-fill the left pane. */
.preview-body-video video {
    aspect-ratio: auto;
    object-fit: contain;
}

.preview-media-wrap {
    position: relative;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg);
    overflow: hidden;
    padding: 12px;
}

.preview-side-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    padding-top: 2px;
}

.preview-prompt-panel {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--bg);
    border: 1px solid var(--border);
}

.preview-prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.preview-prompt-title {
    font-size: 13px;
    font-weight: 600;
}

.preview-prompt-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.preview-download {
    min-height: 32px;
    min-width: 0;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg);
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
}

.preview-download:hover {
    background: color-mix(in srgb, var(--text) 88%, var(--accent));
}

.preview-prompt-copy {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.preview-prompt-copy:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.preview-prompt-text {
    margin-top: 12px;
    color: var(--text-secondary);
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-y: auto;
    min-height: 0;
    font-size: 13px;
}

.chat-modal-content {
    max-width: 840px;
}

.chat-modal-title {
    font-size: 15px;
    font-weight: 600;
}

/* Toasts */
.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: grid;
    gap: 8px;
    z-index: 50;
}

.toast {
    min-width: 200px;
    max-width: 320px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--panel-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--text-secondary);
}

.toast.success {
    border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}

.toast.error {
    border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

.toast.info {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

/* Motion */
.reveal {
    opacity: 0;
    transform: translateY(12px);
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 0.5s var(--ease),
        transform 0.5s var(--ease);
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.55;
    }
}

@keyframes bounce {
    from {
        transform: translateY(0);
        opacity: 0.4;
    }
    to {
        transform: translateY(-3px);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}

/* Responsive */
@media (max-width: 1180px) {
    .hero,
    .usage-grid,
    .models-grid,
    .preview-body-image,
    .preview-body-video {
        grid-template-columns: 1fr;
    }

    .usage-card,
    .model-card {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .usage-card:last-child,
    .model-card:last-child {
        border-bottom: 0;
    }

    .preview-body-image,
    .preview-body-video {
        height: 100%;
        grid-template-rows: minmax(0, 1.2fr) minmax(180px, 0.5fr);
        gap: 14px;
    }

    .preview-content {
        padding: 20px 52px 18px 18px;
    }

    .generate-layout {
        grid-template-columns: 1fr;
    }

    .workspace-hero {
        min-height: auto;
    }

    .glass-card-hero {
        min-height: auto;
    }
}

@media (max-width: 920px) {
    .navbar,
    .nav-actions,
    .workspace-header,
    .hero-actions,
    .hero-metrics,
    .chat-toolbar,
    .chat-toolbar-left,
    .chat-toolbar-right,
    .chat-input-wrapper,
    .results-header,
    .site-footer {
        flex-wrap: wrap;
    }

    .workspace-header {
        align-items: stretch;
        flex-direction: column;
    }

    .navbar {
        height: auto;
        min-height: var(--header-h);
        padding: 10px 0;
    }

    .site-header {
        height: auto;
    }

    .nav-links {
        display: none;
    }

    .tabs {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-msg {
        max-width: min(92%, 42rem);
    }

    .chat-messages,
    .chat-modal-messages {
        min-height: 280px;
    }

    .result-actions {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 640px) {
    .shell {
        width: min(calc(100% - 24px), var(--shell));
    }

    .site-header {
        position: static;
    }

    .hero h1 {
        font-size: clamp(1.75rem, 8vw, 2.25rem);
    }

    .section-heading h2,
    .workspace-intro h1 {
        font-size: clamp(1.35rem, 6vw, 1.75rem);
    }

    .glass-card,
    .results,
    .usage-card,
    .site-footer,
    .preview-content {
        padding: 14px;
    }

    .type-picker {
        grid-template-columns: 1fr;
    }

    .control-card-actions .action-row {
        grid-template-columns: 1fr;
    }

    .prompt-input {
        min-height: 240px;
    }

    .params-row,
    .action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .param-trigger,
    .btn-secondary,
    .btn-generate,
    .chat-upload,
    .chat-send,
    .chat-input,
    .toolbar-btn,
    .nav-cta,
    .button {
        width: 100%;
    }

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

    .result-media,
    .result-video {
        height: 220px;
    }

    .modal-overlay,
    .preview-modal,
    .chat-modal {
        padding: 12px;
    }

    .preview-content {
        width: 100%;
        height: calc(100dvh - 24px);
        padding: 48px 14px 14px;
    }

    .preview-close {
        top: 10px;
        right: 10px;
    }

    .preview-body-image,
    .preview-body-video {
        grid-template-rows: minmax(0, 1fr) minmax(160px, 0.42fr);
        gap: 12px;
    }

    .preview-prompt-header {
        align-items: flex-start;
    }

    .preview-prompt-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .brand-copy span {
        display: none;
    }

    .nav-actions .nav-external {
        display: none;
    }

    .site-footer,
    .footer-brand {
        flex-direction: column;
        align-items: flex-start;
    }

    .footer-links {
        width: 100%;
    }
}
