:root {
    --bg: #060913;
    --bg-deep: #02050c;
    --panel: rgba(13, 19, 33, 0.82);
    --panel-soft: rgba(17, 25, 41, 0.68);
    --panel-strong: rgba(11, 16, 29, 0.94);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f5f7ff;
    --text-soft: rgba(245, 247, 255, 0.72);
    --text-dim: rgba(245, 247, 255, 0.48);
    --accent: #7fb3ff;
    --accent-strong: #4a8cff;
    --accent-soft: rgba(127, 179, 255, 0.16);
    --success: #4dd7a7;
    --warning: #f7c45b;
    --danger: #ff7a8f;
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --shadow: 0 28px 70px rgba(0, 0, 0, 0.38);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 18%, rgba(87, 112, 255, 0.18), transparent 28%),
        radial-gradient(circle at 86% 16%, rgba(70, 149, 255, 0.16), transparent 26%),
        radial-gradient(circle at 70% 78%, rgba(125, 79, 255, 0.14), transparent 30%),
        linear-gradient(180deg, #090d17 0%, #050812 54%, #02040a 100%);
    min-height: 100vh;
}

body,
button,
input,
textarea,
select {
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

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

.app-shell {
    position: relative;
    min-height: 100vh;
    padding: 28px clamp(18px, 3.2vw, 34px) 34px;
    overflow: hidden;
}

.ambient {
    position: absolute;
    border-radius: 999px;
    filter: blur(14px);
    pointer-events: none;
    opacity: 0.78;
}

.ambient-a {
    width: 340px;
    height: 340px;
    top: -90px;
    right: -80px;
    background: radial-gradient(circle, rgba(84, 147, 255, 0.24), transparent 70%);
}

.ambient-b {
    width: 260px;
    height: 260px;
    left: -100px;
    bottom: 16%;
    background: radial-gradient(circle, rgba(129, 98, 255, 0.18), transparent 70%);
}

.ambient-c {
    width: 200px;
    height: 200px;
    left: 44%;
    top: 28px;
    background: radial-gradient(circle, rgba(103, 195, 255, 0.12), transparent 72%);
}

.site-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    background:
        linear-gradient(145deg, rgba(116, 160, 255, 0.92), rgba(68, 118, 255, 0.9));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.26),
        0 16px 34px rgba(29, 78, 216, 0.28);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-copy h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 30px);
    letter-spacing: 0.02em;
    font-weight: 700;
}

.brand-copy span {
    color: var(--text-dim);
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: lowercase;
}

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

.header-pill {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(245, 247, 255, 0.82);
    font-size: 13px;
    line-height: 1;
    letter-spacing: 0.03em;
    backdrop-filter: blur(14px);
}

.header-pill.is-muted {
    color: var(--text-dim);
}

.workspace-layout {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.95fr);
    gap: 24px;
    align-items: start;
}

.panel {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
}

.panel-main {
    padding: 24px;
}

.panel-side {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 24px;
}

.tab-nav {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 22px;
}

.tab-btn {
    border: 0;
    color: var(--text-soft);
    background: transparent;
    padding: 12px 18px;
    border-radius: 999px;
    min-width: 118px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tab-btn:hover {
    color: var(--text);
    transform: translateY(-1px);
}

.tab-btn.is-active {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.image-workbench {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.78fr);
    gap: 20px;
}

.editor-main,
.editor-side,
.placeholder-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-full {
    width: 100%;
}

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

.field-title {
    font-size: 13px;
    color: rgba(245, 247, 255, 0.9);
    letter-spacing: 0.08em;
}

.field-meta {
    color: var(--text-dim);
    font-size: 12px;
}

.prompt-textarea {
    width: 100%;
    min-height: 240px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    background: rgba(7, 11, 21, 0.84);
    color: var(--text);
    padding: 20px 20px 22px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.prompt-textarea::placeholder {
    color: rgba(245, 247, 255, 0.32);
}

.prompt-textarea:focus {
    border-color: rgba(127, 179, 255, 0.44);
    box-shadow: 0 0 0 4px rgba(83, 127, 214, 0.14);
}

.upload-dropzone {
    position: relative;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015));
    min-height: 164px;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragover {
    border-color: rgba(127, 179, 255, 0.52);
    background: rgba(127, 179, 255, 0.06);
    transform: translateY(-1px);
}

.dropzone-inner {
    min-height: 164px;
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.dropzone-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 28px;
    line-height: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.86);
    flex-shrink: 0;
}

.dropzone-copy {
    flex: 1;
}

.dropzone-copy h4 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
}

.dropzone-copy p {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}

.dropzone-btn,
.primary-btn,
.ghost-btn,
.preview-remove-btn,
.result-action-btn {
    border: 0;
    border-radius: 16px;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.dropzone-btn,
.result-action-btn.secondary,
.ghost-btn,
.preview-remove-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.dropzone-btn,
.preview-remove-btn,
.result-action-btn {
    padding: 12px 16px;
}

.dropzone-btn:hover,
.primary-btn:hover,
.ghost-btn:hover,
.preview-remove-btn:hover,
.result-action-btn:hover {
    transform: translateY(-1px);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
    gap: 14px;
}

.empty-box,
.placeholder-box {
    width: 100%;
    min-height: 120px;
    border-radius: 22px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.025);
    display: grid;
    place-items: center;
    text-align: center;
    padding: 24px;
    color: var(--text-dim);
}

.preview-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.035);
    overflow: hidden;
    min-width: 0;
}

.preview-thumb-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    background: rgba(255, 255, 255, 0.04);
    overflow: hidden;
}

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

.preview-status {
    position: absolute;
    left: 12px;
    bottom: 12px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.preview-status.uploading {
    background: rgba(95, 131, 255, 0.28);
}

.preview-status.success {
    background: rgba(77, 215, 167, 0.24);
}

.preview-status.error {
    background: rgba(255, 122, 143, 0.24);
}

.preview-card-body {
    padding: 14px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-card-title {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-all;
}

.preview-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-dim);
    font-size: 12px;
}

.preview-remove-btn {
    padding: 7px 10px;
    border-radius: 12px;
    color: rgba(245, 247, 255, 0.9);
}

.preview-progress {
    position: relative;
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.preview-progress span {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(90, 145, 255, 0.65), rgba(112, 188, 255, 1));
}

.ratio-grid,
.resolution-grid {
    display: grid;
    gap: 10px;
}

.ratio-grid {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}

.resolution-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    min-height: 84px;
    padding: 14px 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.option-card:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
}

.option-card input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.option-card:has(input:checked),
.option-card.is-checked {
    border-color: rgba(117, 169, 255, 0.58);
    background: linear-gradient(180deg, rgba(98, 145, 255, 0.16), rgba(98, 145, 255, 0.08));
    box-shadow: inset 0 0 0 1px rgba(104, 158, 255, 0.08);
}

.option-main {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.option-card small {
    color: var(--text-dim);
    line-height: 1.4;
}

.action-bar {
    display: flex;
    gap: 12px;
}

.action-bar.vertical {
    flex-direction: column;
    margin-top: auto;
}

.primary-btn,
.ghost-btn {
    min-height: 54px;
    padding: 0 18px;
    font-weight: 600;
}

.primary-btn {
    color: #ffffff;
    background: linear-gradient(135deg, #6aa4ff 0%, #3f82ff 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        0 18px 30px rgba(45, 100, 232, 0.3);
}

.ghost-btn {
    color: rgba(245, 247, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
}

.primary-btn:disabled,
.ghost-btn:disabled {
    opacity: 0.68;
    cursor: not-allowed;
    transform: none;
}

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

.section-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 650;
    letter-spacing: 0.02em;
}

.status-panel,
.result-panel {
    display: flex;
    flex-direction: column;
}

.result-panel {
    padding-top: 2px;
}

.task-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.task-meta-item {
    padding: 14px 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    min-width: 0;
}

.task-meta-item span {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

.task-meta-item strong {
    display: block;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
    color: #ffffff;
}

.progress-block {
    margin-top: 18px;
    padding: 18px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.progress-track {
    position: relative;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-inner {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #6aa4ff 0%, #79d1ff 100%);
    box-shadow: 0 0 18px rgba(84, 174, 255, 0.22);
}

.progress-block p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
    font-size: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    font-size: 13px;
    white-space: nowrap;
}

.badge.neutral,
.badge.queued {
    color: rgba(245, 247, 255, 0.86);
}

.badge.processing {
    color: var(--warning);
    background: rgba(247, 196, 91, 0.12);
    border-color: rgba(247, 196, 91, 0.2);
}

.badge.success {
    color: var(--success);
    background: rgba(77, 215, 167, 0.12);
    border-color: rgba(77, 215, 167, 0.2);
}

.badge.failed {
    color: var(--danger);
    background: rgba(255, 122, 143, 0.12);
    border-color: rgba(255, 122, 143, 0.2);
}

.result-gallery {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 420px;
}

.result-main {
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
}

.result-main > img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.04);
}

.result-main-body {
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.result-main-meta {
    min-width: 0;
    flex: 1;
}

.result-main-meta h4,
.result-item-body h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.result-main-meta p {
    margin: 6px 0 0;
    color: var(--text-dim);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.result-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 14px;
    color: #ffffff;
    background: linear-gradient(135deg, #639dff 0%, #3f82ff 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.result-action-btn.secondary {
    color: rgba(245, 247, 255, 0.92);
    box-shadow: none;
}

.result-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
    gap: 12px;
}

.result-item-card {
    overflow: hidden;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.result-item-card:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.14);
}

.result-item-card.is-active {
    border-color: rgba(110, 166, 255, 0.46);
    background: rgba(110, 166, 255, 0.08);
}

.result-item-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.04);
}

.result-item-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item-body h5 {
    font-size: 14px;
}

.toast-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 240px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(12, 18, 31, 0.88);
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.34);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.success {
    border-color: rgba(77, 215, 167, 0.18);
}

.toast.error {
    border-color: rgba(255, 122, 143, 0.2);
}

.toast.info {
    border-color: rgba(127, 179, 255, 0.16);
}

@media (max-width: 1220px) {
    .workspace-layout {
        grid-template-columns: 1fr;
    }

    .panel-side {
        position: static;
    }
}

@media (max-width: 960px) {
    .image-workbench {
        grid-template-columns: 1fr;
    }

    .editor-side {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 18px;
    }

    .action-bar.vertical {
        flex-direction: row;
        align-items: stretch;
        margin-top: 0;
        grid-column: 1 / -1;
    }

    .primary-btn,
    .ghost-btn {
        flex: 1;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 20px 14px 28px;
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .panel-main,
    .panel-side {
        padding: 18px;
        border-radius: 24px;
    }

    .tab-nav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .tab-btn {
        min-width: 0;
        padding: 12px 10px;
    }

    .dropzone-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-grid,
    .result-thumb-grid,
    .task-meta-grid,
    .editor-side,
    .resolution-grid {
        grid-template-columns: 1fr;
    }

    .ratio-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-bar,
    .action-bar.vertical,
    .result-main-body,
    .result-actions {
        flex-direction: column;
    }

    .result-action-btn,
    .primary-btn,
    .ghost-btn {
        width: 100%;
    }

    .toast-stack {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }

    .toast {
        min-width: 0;
        width: 100%;
        max-width: none;
    }
}
