:root {
    color: #17211b;
    background: #f4f6f4;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    line-height: 1.5;
    --ink: #17211b;
    --muted: #66716a;
    --line: #d8ded9;
    --surface: #ffffff;
    --accent: #16794a;
    --accent-dark: #0f5d38;
    --warning: #a9362a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: #f4f6f4;
    color: var(--ink);
}

a {
    color: inherit;
}

.site-header {
    min-height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid rgba(23, 33, 27, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.84);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 750;
    text-decoration: none;
}

.brand-logo {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: block;
    object-fit: contain;
}

.privacy-note,
.eyebrow {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    min-height: calc(100vh - 132px);
    margin: 0 auto;
    padding: 54px 0 48px;
}

.download-panel,
.result-header {
    max-width: 860px;
    margin: 0 auto;
}

.panel-heading {
    max-width: 720px;
}

.eyebrow {
    margin: 0 0 8px;
    letter-spacing: 0;
}

h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1.08;
    letter-spacing: 0;
}

.panel-heading > p:last-child,
.status-block p,
.ready-heading p {
    color: var(--muted);
}

.download-form {
    margin-top: 34px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(29, 49, 37, 0.08);
}

.download-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.url-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

input,
button,
.download-button {
    min-height: 48px;
    border-radius: 6px;
    font: inherit;
}

input {
    width: 100%;
    padding: 0 14px;
    border: 1px solid #aeb8b1;
    color: var(--ink);
    background: white;
}

input:focus {
    outline: 3px solid rgba(22, 121, 74, 0.18);
    border-color: var(--accent);
}

button,
.download-button {
    border: 0;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.download-button:hover {
    background: var(--accent-dark);
}

button:disabled,
button:disabled:hover {
    background: #7a857d;
    cursor: not-allowed;
    opacity: 0.72;
}

.form-error {
    margin: 14px 0 0;
    color: var(--warning);
    font-weight: 650;
}

.form-status {
    margin: 14px 0 0;
    color: var(--muted);
    font-weight: 650;
}

.cf-turnstile {
    margin-top: 16px;
}

.service-strip {
    max-width: 860px;
    margin: 34px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
}

.service-strip div {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.service-strip strong {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--accent-dark);
    background: white;
}

.back-link {
    display: inline-block;
    margin-bottom: 30px;
    color: var(--accent-dark);
    font-weight: 700;
    text-decoration: none;
}

.status-block {
    min-height: 220px;
    display: flex;
    align-items: center;
    gap: 24px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.status-block h1 {
    font-size: 36px;
}

.spinner,
.status-icon {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.spinner {
    border: 4px solid #cfd8d1;
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
}

.status-icon {
    display: grid;
    place-items: center;
    background: #f8dfdc;
    color: var(--warning);
    font-size: 28px;
    font-weight: 800;
}

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

.ready-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}

.ready-heading h1 {
    font-size: 40px;
}

.source-link {
    color: var(--accent-dark);
    font-weight: 700;
    white-space: nowrap;
}

.ready-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.download-all-button {
    min-height: 42px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 750;
    text-decoration: none;
    white-space: nowrap;
}

.download-all-button:hover {
    background: var(--accent-dark);
}

.media-grid {
    margin-top: 34px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 24px;
}

.media-item {
    width: min(100%, 640px, 57.6vh);
    width: min(100%, 640px, 57.6dvh);
    min-width: 0;
    justify-self: center;
}

.media-frame {
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111713;
}

.media-frame img,
.media-frame video,
.media-frame a,
.media-preview-trigger {
    width: 100%;
    height: 100%;
    display: block;
}

.media-frame img,
.media-frame video {
    object-fit: contain;
}

.video-preview {
    position: relative;
}

.media-preview-trigger,
.media-preview-trigger:hover {
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}

.media-preview-trigger.video-preview,
.media-preview-trigger.video-preview:hover {
    cursor: pointer;
}

.play-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    background: rgba(17, 23, 19, 0.78);
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    pointer-events: none;
}

.video-preview-fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    padding: 24px;
    background: #111713;
    color: #ffffff;
    font-size: 15px;
    line-height: 1.4;
    pointer-events: none;
}

.video-preview-fallback-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    font-size: 20px;
}

.video-preview.has-preview-error .play-badge {
    display: none;
}

.video-preview.has-preview-error .video-preview-fallback {
    display: flex;
}

.media-duration {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 3px 7px;
    border-radius: 4px;
    background: rgba(17, 23, 19, 0.82);
    color: #ffffff;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.3;
    pointer-events: none;
}

.download-button {
    width: 100%;
    margin-top: 10px;
}

.media-dialog {
    width: min(960px, calc(100% - 32px));
    height: min(92vh, 920px);
    height: min(92dvh, 920px);
    max-width: none;
    max-height: none;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
}

.media-dialog[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.media-dialog:fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
}

.media-dialog-body img:fullscreen,
.media-dialog-body video:fullscreen,
.media-dialog-stage:fullscreen {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #111713;
}

.media-dialog:-webkit-full-screen,
.media-dialog-stage:-webkit-full-screen,
.media-dialog-body img:-webkit-full-screen,
.media-dialog-body video:-webkit-full-screen {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    background: #111713;
}

.media-dialog::backdrop {
    background: rgba(17, 23, 19, 0.76);
}

.media-dialog-header,
.media-dialog-actions {
    min-height: 60px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.media-dialog-header {
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.media-dialog-counter {
    margin-left: auto;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.media-dialog-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #111713;
}

.media-dialog-body {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #111713;
}

.media-dialog-body img,
.media-dialog-body video {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
}

.gallery-navigation {
    position: absolute;
    z-index: 2;
    top: 50%;
    width: 48px;
    min-height: 64px;
    padding: 0;
    transform: translateY(-50%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    background: rgba(17, 23, 19, 0.72);
    color: #ffffff;
    font-size: 26px;
}

.gallery-navigation:hover {
    background: rgba(17, 23, 19, 0.94);
}

.gallery-navigation:disabled {
    opacity: 0;
    pointer-events: none;
}

.gallery-navigation-previous {
    left: 12px;
}

.gallery-navigation-next {
    right: 12px;
}

.media-dialog-actions {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
}

button.icon-button {
    width: 42px;
    min-height: 42px;
    padding: 0;
    justify-content: center;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 24px;
}

button.icon-button:hover {
    background: #edf1ed;
}

.media-dialog-download {
    width: auto;
    margin: 0;
}

.caption-block {
    margin-top: 40px;
    padding-top: 26px;
    border-top: 1px solid var(--line);
}

.caption-block h2 {
    margin: 0 0 10px;
    font-size: 20px;
}

.caption-block p {
    max-width: 760px;
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ad-slot {
    width: 100%;
    min-height: 90px;
    margin: 0 auto 32px;
    display: grid;
    place-items: center;
    border: 1px dashed #bbc4bd;
    color: #7a857d;
    background: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    text-transform: uppercase;
}

.ad-slot-bottom {
    margin: 48px auto 0;
}

.site-footer {
    min-height: 68px;
    padding: 20px 24px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

@media (max-width: 640px) {
    .site-header {
        min-height: 58px;
        padding: 0 16px;
    }

    .privacy-note {
        display: none;
    }

    .brand-logo {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .page-shell {
        width: min(100% - 24px, 1120px);
        padding-top: 34px;
    }

    .download-form {
        padding: 16px;
    }

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

    .service-strip {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .ready-heading {
        align-items: start;
        flex-direction: column;
    }

    .ready-actions {
        width: 100%;
        justify-content: space-between;
    }

    .status-block {
        align-items: flex-start;
        padding: 34px 0;
    }

    .media-dialog {
        width: calc(100% - 16px);
        height: calc(100vh - 16px);
        height: calc(100dvh - 16px);
    }

    .gallery-navigation {
        width: 42px;
        min-height: 56px;
    }
}
