@font-face {
    font-family: "SVN Avo";
    src: local("SVN Avo"), local("SVN-Avo");
    font-display: swap;
}

:root {
    --font-main: "SVN Avo", "Avo", "Segoe UI", sans-serif;
    --bg: #fff8f4;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #ffffff;
    --ink: #201715;
    --muted: #7d6d68;
    --line: rgba(161, 77, 63, 0.15);
    --brand: #e11d36;
    --brand-dark: #b80f26;
    --brand-soft: #fff0ef;
    --gold: #f7b267;
    --green: #1f8a4c;
    --shadow: 0 24px 80px rgba(88, 32, 25, 0.12);
    --shadow-sm: 0 12px 34px rgba(88, 32, 25, 0.1);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    font-family: var(--font-main);
    color: var(--ink);
    background:
        radial-gradient(circle at 18% 8%, rgba(247, 178, 103, 0.32), transparent 28rem),
        radial-gradient(circle at 84% 20%, rgba(225, 29, 54, 0.18), transparent 26rem),
        linear-gradient(135deg, #fffaf2 0%, #fff2f1 48%, #fff 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    opacity: 0.42;
    background-image:
        linear-gradient(rgba(184, 15, 38, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(184, 15, 38, 0.055) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, #000, transparent 78%);
}

button,
input {
    font: inherit;
}

.page-shell {
    position: relative;
    min-height: 100vh;
    isolation: isolate;
}

.ambient {
    position: fixed;
    z-index: -2;
    border-radius: 999px;
    filter: blur(8px);
    opacity: 0.55;
    pointer-events: none;
    animation: floaty 12s ease-in-out infinite;
}

.ambient-one {
    width: 320px;
    height: 320px;
    top: 8vh;
    left: -120px;
    background: rgba(247, 178, 103, 0.28);
}

.ambient-two {
    width: 420px;
    height: 420px;
    right: -160px;
    bottom: 10vh;
    background: rgba(225, 29, 54, 0.16);
    animation-delay: -4s;
}

.container {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 56px 0 60px;
}

.hero {
    max-width: 820px;
    margin: 0 auto 30px;
    text-align: center;
    animation: rise-in 0.7s ease both;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 14px;
    border: 1px solid rgba(225, 29, 54, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    backdrop-filter: blur(14px);
}

.eyebrow::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--brand);
    box-shadow: 0 0 0 6px rgba(225, 29, 54, 0.11);
}

.hero h1 {
    margin: 0;
    font-size: clamp(42px, 7vw, 82px);
    line-height: 0.95;
    letter-spacing: -0.06em;
    background: linear-gradient(110deg, #2b1714 0%, #b80f26 48%, #f06f46 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero p {
    max-width: 670px;
    margin: 18px auto 0;
    color: var(--muted);
    font-size: clamp(16px, 2vw, 19px);
    line-height: 1.7;
}

.input-card {
    position: sticky;
    top: 16px;
    z-index: 5;
    margin: 0 auto;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    animation: rise-in 0.7s 0.08s ease both;
}

.input-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    padding: 0 4px;
}

.input-heading span {
    font-size: 18px;
    font-weight: 800;
}

.input-heading small {
    color: var(--muted);
    font-size: 13px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.input-row input {
    width: 100%;
    min-height: 56px;
    padding: 0 18px;
    border: 1px solid rgba(184, 15, 38, 0.18);
    border-radius: 18px;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font-size: 15px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.input-row input::placeholder {
    color: rgba(125, 109, 104, 0.7);
}

.input-row input:focus {
    border-color: rgba(225, 29, 54, 0.55);
    box-shadow: 0 0 0 5px rgba(225, 29, 54, 0.09);
    transform: translateY(-1px);
}

button {
    min-height: 46px;
    padding: 0 22px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand), #f05a45);
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 14px 28px rgba(225, 29, 54, 0.24);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

button:hover {
    transform: translateY(-2px);
    filter: saturate(1.05);
    box-shadow: 0 18px 36px rgba(225, 29, 54, 0.28);
}

button:active {
    transform: translateY(0) scale(0.98);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.62;
    transform: none;
}

button.ghost {
    border: 1px solid rgba(225, 29, 54, 0.2);
    background: rgba(255, 255, 255, 0.76);
    color: var(--brand-dark);
    box-shadow: none;
}

button.ghost:hover {
    background: var(--brand-soft);
    box-shadow: 0 12px 28px rgba(88, 32, 25, 0.08);
}

.hint {
    margin-top: 14px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

.hint code {
    display: inline-block;
    margin: 2px 0;
    padding: 4px 8px;
    border: 1px solid rgba(225, 29, 54, 0.12);
    border-radius: 999px;
    background: rgba(255, 240, 239, 0.75);
    color: var(--brand-dark);
    font-size: 12px;
}

#status {
    min-height: 30px;
    margin: 22px 0;
    color: var(--muted);
    text-align: center;
}

#status.error,
#status.success {
    display: flex;
    width: fit-content;
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 24px rgba(88, 32, 25, 0.07);
    font-weight: 800;
}

#status.error {
    color: var(--brand-dark);
}

#status.success {
    color: var(--green);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 22px 0 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
    animation: rise-in 0.45s ease both;
}

.toolbar .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.ratio-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 14px;
    border: 1px solid rgba(225, 29, 54, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--brand-dark);
    font-size: 13px;
    font-weight: 700;
}

.ratio-select span {
    color: var(--muted);
    font-weight: 600;
}

.ratio-select select {
    padding: 6px 8px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 240, 239, 0.7);
    color: var(--brand-dark);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}

.ratio-select select:focus {
    box-shadow: 0 0 0 3px rgba(225, 29, 54, 0.18);
}

.toolbar #countLabel {
    color: var(--ink);
    font-weight: 800;
}

.gallery {
    column-count: 4;
    column-gap: 18px;
}

.card {
    position: relative;
    display: inline-block;
    width: 100%;
    margin: 0 0 18px;
    overflow: hidden;
    break-inside: avoid;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 24px;
    background: var(--surface-strong);
    box-shadow: 0 16px 36px rgba(49, 27, 24, 0.12);
    cursor: pointer;
    transform: translateZ(0);
    transition: transform 0.26s ease, box-shadow 0.26s ease, border-color 0.26s ease;
    animation: card-in 0.46s ease both;
}

.card:hover {
    border-color: rgba(225, 29, 54, 0.24);
    box-shadow: 0 26px 58px rgba(49, 27, 24, 0.18);
    transform: translateY(-6px);
}

.card img {
    display: block;
    width: 100%;
    background: #f4ece8;
    transition: transform 0.38s ease, filter 0.38s ease;
}

.card:hover img {
    filter: saturate(1.05) contrast(1.02);
    transform: scale(1.035);
}

.card .overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    background: linear-gradient(to bottom, transparent 36%, rgba(27, 14, 12, 0.7));
    opacity: 0;
    transition: opacity 0.22s ease;
}

.card:hover .overlay {
    opacity: 1;
}

.card .dlbtn {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.card .check {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: transparent;
    font-size: 17px;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.card.selected {
    border-color: rgba(225, 29, 54, 0.55);
    box-shadow: 0 0 0 4px rgba(225, 29, 54, 0.1), 0 26px 58px rgba(49, 27, 24, 0.18);
}

.card.selected .check {
    background: var(--brand);
    color: #fff;
    transform: scale(1.05);
}

.card.video::after {
    content: "▶";
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(27, 14, 12, 0.68);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    backdrop-filter: blur(10px);
}

.hidden {
    display: none !important;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    border: 3px solid rgba(225, 29, 54, 0.18);
    border-top-color: var(--brand);
    border-radius: 50%;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

footer {
    margin-top: 54px;
    color: rgba(125, 109, 104, 0.78);
    font-size: 13px;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floaty {
    0%,
    100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
    50% {
        transform: translate3d(20px, -18px, 0) scale(1.04);
    }
}

@media (max-width: 1000px) {
    .gallery {
        column-count: 3;
    }
}

@media (max-width: 760px) {
    .container {
        width: min(100% - 28px, 1180px);
        padding-top: 36px;
    }

    .input-card {
        position: static;
        border-radius: 24px;
    }

    .input-heading,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .input-row button {
        min-height: 54px;
    }

    .toolbar .actions,
    .toolbar .actions button {
        width: 100%;
    }

    .gallery {
        column-count: 2;
        column-gap: 14px;
    }
}

@media (max-width: 460px) {
    .container {
        width: min(100% - 22px, 1180px);
    }

    .hero h1 {
        letter-spacing: -0.045em;
    }

    .hint code {
        max-width: 100%;
        overflow-wrap: anywhere;
        border-radius: 12px;
    }

    .gallery {
        column-count: 1;
    }
}

@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;
    }
}
