:root {
    --canvas: #f3f4ef;
    --panel: #ffffff;
    --subtle: #fafbf8;
    --field: #ffffff;
    --hover: #f8f9f6;
    --ink: #171a19;
    --muted: #69706d;
    --line: #dfe3dd;
    --accent: #f05d3a;
    --accent-dark: #c94528;
    --teal: #176b64;
    --teal-soft: #e7f1ee;
    --warning-soft: #fff4dc;
    --notice-bg: #fff7e8;
    --notice-border: #e6c98e;
    --notice-text: #5f471e;
    --notice-icon: #9a6515;
    --primary-bg: #171a19;
    --primary-fg: #ffffff;
    --shadow-soft: 0 1px 2px rgba(23, 26, 25, 0.06), 0 8px 24px rgba(23, 26, 25, 0.05);
    --shadow-lift: 0 18px 50px rgba(23, 26, 25, 0.14);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    color-scheme: light;
}

html[data-theme="dark"] {
    --canvas: #141716;
    --panel: #1d211f;
    --subtle: #191d1b;
    --field: #202522;
    --hover: #282e2b;
    --ink: #f0f3ef;
    --muted: #a5ada8;
    --line: #353c38;
    --accent: #ff7656;
    --accent-dark: #ff8c71;
    --teal: #67c7bd;
    --teal-soft: #193a36;
    --warning-soft: #3a2d17;
    --notice-bg: #342b1b;
    --notice-border: #665330;
    --notice-text: #f1d9aa;
    --notice-icon: #e1ad51;
    --primary-bg: #f0f3ef;
    --primary-fg: #171a19;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.22), 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-lift: 0 18px 50px rgba(0, 0, 0, 0.34);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-width: 320px;
    background: var(--canvas);
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
}

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

button,
select {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(23, 107, 100, 0.28);
    outline-offset: 2px;
}

::selection {
    color: #ffffff;
    background: var(--teal);
}

.brand-mark {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 0.375rem;
    color: var(--primary-fg);
    background: var(--primary-bg);
}

.field-control {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    color: var(--ink);
    background: var(--field);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field-control:hover {
    border-color: #b8bfba;
}

.field-control:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(23, 107, 100, 0.12);
    outline: none;
}

.prompt-input {
    min-height: 13rem;
    resize: vertical;
    line-height: 1.65;
}

.primary-button {
    display: inline-flex;
    min-height: 3rem;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    border: 1px solid var(--primary-bg);
    border-radius: 0.5rem;
    color: var(--primary-fg);
    background: var(--primary-bg);
    box-shadow: 0 1px 2px rgba(23, 26, 25, 0.12);
    transition: transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.primary-button:hover:not(:disabled) {
    filter: brightness(0.92);
    box-shadow: 0 8px 18px rgba(23, 26, 25, 0.16);
    transform: translateY(-1px);
}

.primary-button:active:not(:disabled) {
    transform: translateY(0);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.icon-button {
    display: inline-grid;
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 2.5rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    color: var(--ink);
    background: var(--panel);
    transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.icon-button:hover:not(:disabled) {
    border-color: #b8bfba;
    background: var(--hover);
    transform: translateY(-1px);
}

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

.result-stage {
    isolation: isolate;
    min-height: 31rem;
    background: #e7e9e3;
}

.result-stage::before {
    position: absolute;
    z-index: -1;
    inset: 0;
    background-image:
        linear-gradient(45deg, rgba(255, 255, 255, 0.34) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.34) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.34) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.34) 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
    content: "";
}

.result-image {
    width: 100%;
    height: 100%;
    min-height: 31rem;
    object-fit: contain;
}

.sample-image {
    object-fit: cover;
}

.loading-sheen {
    position: absolute;
    z-index: 10;
    inset: 0;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: rgba(23, 26, 25, 0.82);
    backdrop-filter: blur(8px);
}

.loading-line {
    overflow: hidden;
    width: min(16rem, 70vw);
    height: 0.25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
}

.loading-line::after {
    display: block;
    width: 40%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    animation: progress-slide 1.4s ease-in-out infinite;
    content: "";
}

.notice-banner {
    border-color: var(--notice-border);
    color: var(--notice-text);
    background: var(--notice-bg);
}

.notice-banner > i {
    color: var(--notice-icon);
}

.swal2-popup {
    border-radius: 0.5rem !important;
    color: var(--ink) !important;
    background: var(--panel) !important;
    font-family: inherit !important;
}

.swal2-confirm {
    border-radius: 0.5rem !important;
    color: var(--primary-fg) !important;
    background: var(--primary-bg) !important;
}

.swal2-cancel {
    border-radius: 0.5rem !important;
}

@keyframes progress-slide {
    from { transform: translateX(-120%); }
    to { transform: translateX(350%); }
}

@media (max-width: 767px) {
    .prompt-input {
        min-height: 10rem;
    }

    .result-stage,
    .result-image {
        min-height: 22rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
