:root {
    --primary: #6c4cff;
    --primary-dark: #5233e8;
    --primary-soft: #eeeaff;
    --secondary: #9b6cff;
    --text: #1c1c2e;
    --muted: #858598;
    --border: #ececf3;
    --surface: #ffffff;
    --background: #f4f4fa;
    --danger: #e5484d;
    --success: #1f9d69;
    --shadow:
        0 12px 35px rgba(36, 31, 72, 0.08);
    --bottom-nav-height: 82px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.desktop-background {
    min-height: 100vh;
}

.mobile-app-shell {
    position: relative;
    width: 100%;
    min-height: 100vh;
    margin: 0 auto;
    overflow-x: hidden;
    background:
        linear-gradient(
            180deg,
            #faf9ff 0,
            #f5f4fb 240px,
            #f4f4fa 100%
        );
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 74px;
    padding:
        max(14px, env(safe-area-inset-top))
        20px
        12px;
    background: rgba(250, 249, 255, 0.92);
    border-bottom: 1px solid rgba(236, 236, 243, 0.8);
    backdrop-filter: blur(18px);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-icon {
    display: grid;
    width: 43px;
    height: 43px;
    place-items: center;
    color: #fff;
    font-size: 20px;
    border-radius: 15px;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            #a26dff
        );
    box-shadow:
        0 10px 24px rgba(108, 76, 255, 0.28);
}

.header-brand small {
    display: block;
    margin-bottom: 2px;
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.3px;
}

.header-brand h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.1;
}

.header-action,
.sheet-close-button {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    color: var(--text);
    font-size: 19px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.page-content {
    padding:
        18px
        16px
        calc(var(--bottom-nav-height) + 45px);
}

.welcome-card {
    position: relative;
    display: flex;
    min-height: 174px;
    padding: 22px;
    overflow: hidden;
    border-radius: 26px;
    background:
        linear-gradient(
            135deg,
            #25165f,
            #7048e8 62%,
            #a679ff
        );
    box-shadow:
        0 18px 40px rgba(77, 52, 176, 0.24);
}

.welcome-card > div:first-child {
    position: relative;
    z-index: 2;
    max-width: 75%;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
}

.welcome-card h2 {
    margin: 15px 0 8px;
    color: #fff;
    font-size: 22px;
    line-height: 1.25;
}

.welcome-card p {
    margin: 0;
    color: rgba(255, 255, 255, 0.74);
    font-size: 13px;
    line-height: 1.6;
}

.welcome-decoration {
    position: absolute;
    right: -22px;
    bottom: -26px;
    display: grid;
    width: 135px;
    height: 135px;
    place-items: center;
    color: rgba(255, 255, 255, 0.16);
    font-size: 80px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 42px;
    transform: rotate(-12deg);
    background: rgba(255, 255, 255, 0.06);
}

.generator-form {
    display: grid;
    gap: 15px;
    margin-top: 17px;
}

.form-card {
    padding: 18px;
    border: 1px solid rgba(232, 231, 241, 0.9);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-heading > div:first-child {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-number {
    display: grid;
    flex: 0 0 auto;
    width: 33px;
    height: 33px;
    place-items: center;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    border-radius: 11px;
    background: var(--primary-soft);
}

.section-heading h3 {
    margin: 0 0 3px;
    font-size: 15px;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
}

.required-label,
.reference-counter {
    padding: 6px 9px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    border-radius: 999px;
    background: var(--primary-soft);
}

.main-upload-box {
    position: relative;
    display: block;
    min-height: 225px;
    overflow: hidden;
    border: 1.5px dashed #cbc4f4;
    border-radius: 20px;
    background: #faf9ff;
    cursor: pointer;
}

.main-upload-placeholder {
    display: flex;
    min-height: 225px;
    padding: 25px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
}

.upload-circle {
    display: grid;
    width: 60px;
    height: 60px;
    margin-bottom: 13px;
    place-items: center;
    color: var(--primary);
    font-size: 27px;
    border-radius: 20px;
    background: var(--primary-soft);
}

.main-upload-placeholder strong {
    margin-bottom: 6px;
    font-size: 15px;
}

.main-upload-placeholder small {
    color: var(--muted);
    font-size: 11px;
}

.choose-file-button {
    margin-top: 15px;
    padding: 9px 16px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 12px;
    background: var(--primary);
}

.main-image-preview {
    position: relative;
    width: 100%;
    height: 260px;
}

.main-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.change-image-badge {
    position: absolute;
    right: 13px;
    bottom: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 11px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    background: rgba(20, 20, 28, 0.72);
    backdrop-filter: blur(10px);
}

.reference-list {
    display: flex;
    gap: 11px;
    padding-bottom: 5px;
    overflow-x: auto;
    scrollbar-width: none;
}

.reference-list::-webkit-scrollbar {
    display: none;
}

.add-reference-card,
.reference-preview-card {
    position: relative;
    flex: 0 0 98px;
    width: 98px;
    height: 118px;
    overflow: hidden;
    border-radius: 17px;
}

.add-reference-card {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 7px;
    color: var(--primary);
    border: 1.5px dashed #cbc4f4;
    background: #faf9ff;
}

.add-reference-card span {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 12px;
    background: var(--primary-soft);
}

.add-reference-card strong {
    font-size: 11px;
}

.reference-preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-reference {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    width: 25px;
    height: 25px;
    padding: 0;
    place-items: center;
    color: #fff;
    font-size: 12px;
    border: 0;
    border-radius: 999px;
    background: rgba(18, 18, 26, 0.72);
}

.reference-type-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.reference-type-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.reference-type-row img {
    width: 43px;
    height: 43px;
    object-fit: cover;
    border-radius: 11px;
}

.reference-type-row label {
    flex: 1;
}

.reference-type-row label span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
}

.reference-type-row select {
    width: 100%;
    padding: 4px 24px 4px 0;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    border: 0;
    outline: none;
    background: transparent;
}

.form-helper {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.prompt-wrapper {
    position: relative;
}

.prompt-wrapper textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px 15px 35px;
    resize: vertical;
    color: var(--text);
    line-height: 1.6;
    border: 1px solid var(--border);
    border-radius: 16px;
    outline: none;
    background: #fafafa;
}

.prompt-wrapper textarea:focus {
    border-color: var(--primary);
    box-shadow:
        0 0 0 4px rgba(108, 76, 255, 0.1);
}

.prompt-wrapper textarea::placeholder {
    color: #aaaabb;
    font-size: 12px;
}

.character-counter {
    position: absolute;
    right: 12px;
    bottom: 10px;
    color: var(--muted);
    font-size: 10px;
}

.prompt-chips {
    display: flex;
    gap: 7px;
    margin-top: 10px;
    overflow-x: auto;
}

.prompt-chip {
    flex: 0 0 auto;
    padding: 8px 11px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    border: 1px solid #ddd7ff;
    border-radius: 999px;
    background: var(--primary-soft);
}

.ratio-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.ratio-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ratio-card {
    display: flex;
    min-height: 104px;
    padding: 11px 5px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: #fff;
    transition: 0.2s ease;
}

.ratio-option input:checked + .ratio-card {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow:
        0 0 0 3px rgba(108, 76, 255, 0.08);
}

.ratio-shape {
    display: block;
    margin-bottom: 4px;
    border: 2px solid currentColor;
    border-radius: 3px;
}

.ratio-shape.square {
    width: 27px;
    height: 27px;
}

.ratio-shape.portrait {
    width: 22px;
    height: 29px;
}

.ratio-shape.story {
    width: 17px;
    height: 31px;
}

.ratio-shape.landscape {
    width: 32px;
    height: 20px;
}

.ratio-card strong {
    font-size: 11px;
}

.ratio-card small {
    color: var(--muted);
    font-size: 8px;
}

.generate-button {
    display: grid;
    grid-template-columns: 45px 1fr auto;
    gap: 12px;
    width: 100%;
    padding: 14px 17px;
    align-items: center;
    color: #fff;
    text-align: left;
    border: 0;
    border-radius: 19px;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            #8c5cff
        );
    box-shadow:
        0 15px 30px rgba(108, 76, 255, 0.3);
}

.generate-button-icon {
    display: grid;
    width: 43px;
    height: 43px;
    place-items: center;
    font-size: 19px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
}

.generate-button strong,
.generate-button small {
    display: block;
}

.generate-button strong {
    font-size: 14px;
}

.generate-button small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
}

.bottom-navigation {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.bottom-navigation-inner {
    position: relative;
    display: grid;
    grid-template-columns:
        1fr
        1fr
        76px
        1fr
        1fr;
    width: 100%;
    height: var(--bottom-nav-height);
    margin: 0 auto;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    height: 100%;
    padding: 10px 3px 8px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    color: #9999aa;
    font-size: 9px;
    font-weight: 700;
    border: 0;
    background: transparent;
}

.bottom-nav-item i {
    font-size: 20px;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-center {
    position: relative;
    height: 100%;
}

.all-menu-button {
    position: absolute;
    top: -23px;
    left: 50%;
    display: grid;
    width: 62px;
    height: 62px;
    padding: 0;
    place-items: center;
    color: #fff;
    font-size: 26px;
    border: 6px solid var(--background);
    border-radius: 50%;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            #9d65ff
        );
    box-shadow:
        0 12px 26px rgba(108, 76, 255, 0.38);
    transform: translateX(-50%);
    transition: transform 0.25s ease;
}

.all-menu-button.open {
    transform:
        translateX(-50%)
        rotate(45deg);
}

.menu-overlay {
    position: fixed;
    z-index: 80;
    inset: 0;
    visibility: hidden;
    opacity: 0;
    background: rgba(18, 17, 29, 0.52);
    backdrop-filter: blur(4px);
    transition: 0.25s ease;
}

.menu-overlay.open {
    visibility: visible;
    opacity: 1;
}

.all-menu-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    max-height: 85vh;
    padding:
        10px
        18px
        calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    border-radius: 28px 28px 0 0;
    background: #fff;
    box-shadow:
        0 -20px 50px rgba(25, 22, 45, 0.2);
    transform: translateY(105%);
    transition:
        transform 0.32s
        cubic-bezier(0.25, 0.8, 0.25, 1);
}

.all-menu-sheet.open {
    transform: translateY(0);
}

.sheet-handle {
    width: 43px;
    height: 5px;
    margin: 0 auto 18px;
    border-radius: 999px;
    background: #ddddE7;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sheet-header small {
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.2px;
}

.sheet-header h2 {
    margin: 4px 0 0;
    font-size: 21px;
}

.all-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 11px;
    margin-top: 19px;
}

.all-menu-item {
    display: flex;
    min-width: 0;
    padding: 15px 8px;
    align-items: center;
    flex-direction: column;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
}

button.all-menu-item {
    color: inherit;
}

.all-menu-icon {
    display: grid;
    width: 46px;
    height: 46px;
    margin-bottom: 9px;
    place-items: center;
    color: var(--primary);
    font-size: 20px;
    border-radius: 15px;
    background: var(--primary-soft);
}

.all-menu-item strong {
    font-size: 11px;
}

.all-menu-item small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 8px;
}

.app-toast {
    position: fixed;
    right: 18px;
    bottom: 105px;
    left: 18px;
    z-index: 120;
    display: flex;
    max-width: 440px;
    margin: auto;
    padding: 13px 15px;
    align-items: center;
    gap: 9px;
    color: #fff;
    font-size: 12px;
    border-radius: 14px;
    visibility: hidden;
    opacity: 0;
    background: rgba(27, 26, 38, 0.94);
    transform: translateY(15px);
    transition: 0.25s ease;
}

.app-toast.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.loading-overlay {
    position: fixed;
    z-index: 200;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
    visibility: hidden;
    opacity: 0;
    background: rgba(245, 244, 250, 0.92);
    backdrop-filter: blur(10px);
    transition: 0.25s ease;
}

.loading-overlay.show {
    visibility: visible;
    opacity: 1;
}

.loading-card {
    width: min(100%, 330px);
    padding: 29px 23px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 25px;
    background: #fff;
    box-shadow: var(--shadow);
}

.loading-card h3 {
    margin: 17px 0 7px;
    font-size: 17px;
}

.loading-card p {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.ai-loader {
    display: flex;
    height: 45px;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-loader span {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: aiBounce 0.8s infinite alternate;
}

.ai-loader span:nth-child(2) {
    animation-delay: 0.18s;
}

.ai-loader span:nth-child(3) {
    animation-delay: 0.36s;
}

.alert-card {
    display: flex;
    margin-bottom: 14px;
    padding: 13px;
    align-items: flex-start;
    gap: 9px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 15px;
}

.alert-card.error {
    color: #b82f35;
    border: 1px solid #ffd7d9;
    background: #fff1f2;
}

.alert-card.success {
    color: #16754f;
    border: 1px solid #ccebdc;
    background: #effaf5;
}

@keyframes aiBounce {
    to {
        transform: translateY(-13px);
        opacity: 0.45;
    }
}

@media (min-width: 580px) {
    .desktop-background {
        padding: 24px 0;
        background:
            radial-gradient(
                circle at top left,
                #e5dfff,
                transparent 35%
            ),
            radial-gradient(
                circle at bottom right,
                #efe7ff,
                transparent 38%
            ),
            #ececf3;
    }

    .mobile-app-shell {
        max-width: 520px;
        min-height: calc(100vh - 48px);
        border-radius: 30px;
        box-shadow:
            0 25px 80px rgba(34, 31, 63, 0.18);
    }

    .app-header {
        border-radius: 30px 30px 0 0;
    }

    .bottom-navigation,
    .all-menu-sheet {
        right: auto;
        left: 50%;
        width: 520px;
        transform-origin: bottom center;
    }

    .bottom-navigation {
        bottom: 24px;
        border-radius: 0 0 30px 30px;
        transform: translateX(-50%);
    }

    .all-menu-sheet {
        bottom: 24px;
        border-radius: 28px 28px 30px 30px;
        transform:
            translate(-50%, 105%);
    }

    .all-menu-sheet.open {
        transform: translate(-50%, 0);
    }
}
.header-back-button {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: var(--text);
    font-size: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}

.result-page-content {
    padding-top: 16px;
}

.latest-result-card {
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: #fff;
    box-shadow: var(--shadow);
}

.latest-result-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.latest-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
    border-radius: 999px;
    background: var(--primary-soft);
}

.latest-result-heading h2 {
    margin: 10px 0 4px;
    font-size: 17px;
}

.latest-result-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
}

.result-ratio-badge {
    display: grid;
    min-width: 43px;
    height: 32px;
    padding: 0 9px;
    place-items: center;
    color: var(--text);
    font-size: 10px;
    font-weight: 800;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafafa;
}

.latest-result-image {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    background: #eeeeF5;
}

.latest-result-image img {
    display: block;
    width: 100%;
    max-height: 540px;
    object-fit: contain;
}

.preview-full-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    color: #fff;
    font-size: 17px;
    border: 0;
    border-radius: 13px;
    background: rgba(20, 19, 29, 0.68);
    backdrop-filter: blur(10px);
}

.result-prompt-box {
    margin-top: 13px;
    padding: 13px;
    border-radius: 15px;
    background: #f8f7fc;
}

.result-prompt-box > span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
}

.result-prompt-box p {
    margin: 7px 0 0;
    color: #5f5f70;
    font-size: 11px;
    line-height: 1.6;
}

.result-actions {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

.primary-result-button,
.secondary-result-button {
    display: flex;
    min-height: 45px;
    padding: 9px 10px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 10px;
    font-weight: 800;
    border-radius: 14px;
}

.primary-result-button {
    color: #fff;
    background:
        linear-gradient(
            135deg,
            var(--primary),
            #9562ff
        );
}

.secondary-result-button {
    color: var(--text);
    border: 1px solid var(--border);
    background: #fff;
}

button.secondary-result-button {
    width: 100%;
}

.gallery-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 2px 13px;
}

.gallery-section-heading h2 {
    margin: 0;
    font-size: 17px;
}

.gallery-section-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.small-filter-button {
    display: grid;
    width: 37px;
    height: 37px;
    padding: 0;
    place-items: center;
    color: var(--text);
    font-size: 17px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.gallery-grid.list-mode {
    grid-template-columns: 1fr;
}

.gallery-item {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    box-shadow:
        0 8px 22px rgba(35, 31, 65, 0.05);
}

.gallery-image-button {
    display: block;
    width: 100%;
    height: 178px;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #eeeeF5;
}

.gallery-image-button img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.gallery-image-button:active img {
    transform: scale(0.98);
}

.gallery-item-info {
    display: flex;
    min-width: 0;
    padding: 10px 8px 7px 11px;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
}

.gallery-item-info > div {
    min-width: 0;
}

.gallery-item-info strong,
.gallery-item-info small {
    display: block;
}

.gallery-item-info strong {
    font-size: 11px;
}

.gallery-item-info small {
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-menu-button {
    display: grid;
    flex: 0 0 auto;
    width: 31px;
    height: 31px;
    padding: 0;
    place-items: center;
    color: var(--muted);
    border: 0;
    border-radius: 10px;
    background: transparent;
}

.gallery-file-size {
    padding: 0 11px 10px;
    color: #aaaabb;
    font-size: 8px;
}

.gallery-grid.list-mode .gallery-item {
    display: grid;
    grid-template-columns: 105px 1fr;
    min-height: 105px;
}

.gallery-grid.list-mode .gallery-image-button {
    width: 105px;
    height: 105px;
}

.gallery-grid.list-mode .gallery-item-info {
    padding: 15px 10px;
}

.gallery-grid.list-mode .gallery-file-size {
    position: absolute;
    left: 116px;
    bottom: 14px;
    padding: 0;
}

.empty-gallery-card {
    padding: 38px 24px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 23px;
    background: #fff;
    box-shadow: var(--shadow);
}

.empty-gallery-icon {
    display: grid;
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    place-items: center;
    color: var(--primary);
    font-size: 29px;
    border-radius: 24px;
    background: var(--primary-soft);
}

.empty-gallery-card h3 {
    margin: 0 0 7px;
    font-size: 16px;
}

.empty-gallery-card p {
    max-width: 260px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.empty-gallery-button {
    display: inline-flex;
    margin-top: 18px;
    padding: 11px 17px;
    align-items: center;
    gap: 7px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 13px;
    background: var(--primary);
}

.image-preview-modal {
    position: fixed;
    z-index: 300;
    inset: 0;
    display: flex;
    visibility: hidden;
    opacity: 0;
    flex-direction: column;
    background: #111119;
    transition: 0.22s ease;
}

.image-preview-modal.open {
    visibility: visible;
    opacity: 1;
}

.image-preview-header {
    display: flex;
    min-height: 68px;
    padding:
        max(13px, env(safe-area-inset-top))
        17px
        10px;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.image-preview-header button {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    color: #fff;
    font-size: 18px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 14px;
    background: rgba(255,255,255,.08);
}

.image-preview-body {
    display: grid;
    flex: 1;
    padding: 15px;
    place-items: center;
    overflow: auto;
}

.image-preview-body img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 115px);
    object-fit: contain;
}

.gallery-action-overlay {
    position: fixed;
    z-index: 140;
    inset: 0;
    visibility: hidden;
    opacity: 0;
    background: rgba(18, 17, 29, 0.52);
    backdrop-filter: blur(4px);
    transition: 0.25s ease;
}

.gallery-action-overlay.open {
    visibility: visible;
    opacity: 1;
}

.gallery-action-sheet {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 150;
    padding:
        10px
        18px
        calc(22px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    background: #fff;
    box-shadow:
        0 -20px 50px rgba(25, 22, 45, 0.2);
    transform: translateY(105%);
    transition:
        transform 0.32s
        cubic-bezier(0.25, 0.8, 0.25, 1);
}

.gallery-action-sheet.open {
    transform: translateY(0);
}

.gallery-action-title {
    display: flex;
    margin-bottom: 17px;
    padding-bottom: 15px;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid var(--border);
}

.gallery-action-title img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 14px;
}

.gallery-action-title strong,
.gallery-action-title small {
    display: block;
}

.gallery-action-title strong {
    font-size: 14px;
}

.gallery-action-title small {
    max-width: 260px;
    margin-top: 4px;
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-action-list {
    display: grid;
    gap: 4px;
}

.gallery-action-list button,
.gallery-action-list a {
    display: flex;
    width: 100%;
    min-height: 58px;
    padding: 9px 8px;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-align: left;
    border: 0;
    border-radius: 14px;
    background: transparent;
}

.gallery-action-list > * > i {
    display: grid;
    flex: 0 0 auto;
    width: 39px;
    height: 39px;
    place-items: center;
    color: var(--primary);
    font-size: 17px;
    border-radius: 12px;
    background: var(--primary-soft);
}

.gallery-action-list strong,
.gallery-action-list small {
    display: block;
}

.gallery-action-list strong {
    font-size: 12px;
}

.gallery-action-list small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
}

.gallery-action-list .danger-action {
    color: var(--danger);
}

.gallery-action-list .danger-action > i {
    color: var(--danger);
    background: #fff0f1;
}

@media (min-width: 580px) {
    .gallery-action-sheet {
        right: auto;
        bottom: 24px;
        left: 50%;
        width: 520px;
        border-radius: 28px 28px 30px 30px;
        transform:
            translate(-50%, 105%);
    }

    .gallery-action-sheet.open {
        transform: translate(-50%, 0);
    }

    .image-preview-modal {
        right: auto;
        left: 50%;
        width: 520px;
        transform: translateX(-50%);
    }
}

@media (max-width: 370px) {
    .result-actions {
        grid-template-columns: 1fr;
    }

    .gallery-image-button {
        height: 155px;
    }
}

.main-source-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 15px;
}

.source-option {
    position: relative;
}

.source-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.source-option > span {
    display: flex;
    min-height: 100px;
    padding: 14px 8px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    transition: 0.2s ease;
}

.source-option i {
    margin-bottom: 3px;
    color: var(--primary);
    font-size: 23px;
}

.source-option strong {
    font-size: 12px;
}

.source-option small {
    color: var(--muted);
    font-size: 9px;
}

.source-option input:checked + span {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow:
        0 0 0 3px rgba(108, 76, 255, 0.08);
}

.main-ai-area {
    padding-top: 2px;
}

.subject-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.subject-field {
    display: block;
}

.subject-field > span {
    display: block;
    margin-bottom: 6px;
    color: #5f5f70;
    font-size: 10px;
    font-weight: 700;
}

.subject-field select,
.subject-field textarea {
    width: 100%;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: none;
    background: #fafafa;
}

.subject-field select {
    height: 44px;
    padding: 0 11px;
    font-size: 11px;
}

.subject-field textarea {
    padding: 12px;
    resize: vertical;
    font-size: 11px;
    line-height: 1.6;
}

.subject-field select:focus,
.subject-field textarea:focus {
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px rgba(108, 76, 255, 0.09);
}

.subject-field-full {
    margin-top: 11px;
}

.generate-subject-button {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    width: 100%;
    margin-top: 13px;
    padding: 12px 14px;
    align-items: center;
    color: #fff;
    text-align: left;
    border: 0;
    border-radius: 16px;
    background:
        linear-gradient(
            135deg,
            #24165c,
            var(--primary)
        );
    box-shadow:
        0 12px 25px rgba(108, 76, 255, 0.22);
}

.generate-subject-button > span {
    display: grid;
    width: 39px;
    height: 39px;
    place-items: center;
    font-size: 17px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
}

.generate-subject-button strong,
.generate-subject-button small {
    display: block;
}

.generate-subject-button strong {
    font-size: 12px;
}

.generate-subject-button small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 9px;
}

.generate-subject-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.subject-generation-loading {
    display: flex;
    margin-top: 13px;
    padding: 13px;
    align-items: center;
    gap: 12px;
    border: 1px solid #ddd7ff;
    border-radius: 15px;
    background: var(--primary-soft);
}

.subject-generation-loading strong,
.subject-generation-loading small {
    display: block;
}

.subject-generation-loading strong {
    color: var(--primary);
    font-size: 11px;
}

.subject-generation-loading small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
}

.small-ai-loader {
    display: flex;
    width: 48px;
    height: 35px;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.small-ai-loader span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: aiBounce 0.75s infinite alternate;
}

.small-ai-loader span:nth-child(2) {
    animation-delay: 0.15s;
}

.small-ai-loader span:nth-child(3) {
    animation-delay: 0.3s;
}

.generated-subject-result {
    margin-top: 14px;
    overflow: hidden;
    border: 1px solid #ccebdc;
    border-radius: 18px;
    background: #fff;
}

.generated-subject-status {
    display: flex;
    padding: 11px 12px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.generated-subject-status span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
    font-size: 10px;
    font-weight: 800;
}

.generated-subject-status button {
    padding: 6px 9px;
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
    border: 0;
    border-radius: 9px;
    background: var(--primary-soft);
}

.generated-subject-image {
    overflow: hidden;
    background: #eeeeF5;
}

.generated-subject-image img {
    display: block;
    width: 100%;
    max-height: 440px;
    object-fit: contain;
}

@media (max-width: 370px) {
    .subject-form-grid {
        grid-template-columns: 1fr;
    }
}

