:root {
    color-scheme: dark;
    --bg: #070707;
    --bg-soft: #0f1014;
    --panel: rgba(22, 22, 26, 0.84);
    --panel-strong: #17171d;
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.18);
    --text: #f8f8fb;
    --muted: #a7abb8;
    --soft: #d8dae2;
    --red: #ff0033;
    --red-dark: #b90022;
    --red-glow: rgba(255, 0, 51, 0.38);
    --amber: #f7b955;
    --green: #43f0a7;
    --radius: 22px;
    --shadow: 0 28px 100px rgba(0, 0, 0, 0.55);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 18% 12%, rgba(255, 0, 51, 0.2), transparent 28%),
        radial-gradient(circle at 84% 8%, rgba(255, 255, 255, 0.08), transparent 24%),
        linear-gradient(135deg, #050505 0%, #0d0d11 48%, #070707 100%);
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 78%);
}

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

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 0 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    position: relative;
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 15px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.13), transparent),
        linear-gradient(145deg, var(--red), #74000e);
    box-shadow: 0 16px 42px rgba(255, 0, 51, 0.28);
}

.brand-mark::before {
    width: 0;
    height: 0;
    margin-left: 3px;
    content: "";
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 16px solid #fff;
    filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
}

.brand-mark span {
    position: absolute;
    inset: auto 8px 8px auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 18px rgba(67, 240, 167, 0.9);
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-copy strong {
    font-family: "Space Grotesk", Inter, sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0;
}

.brand-copy small {
    color: var(--muted);
    font-size: 0.78rem;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px);
}

.top-nav a {
    padding: 9px 13px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
    transition: background 180ms ease, color 180ms ease;
}

.top-nav a:hover,
.top-nav a:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 500px);
    align-items: center;
    gap: 34px;
    min-height: calc(100vh - 230px);
    padding: 42px 0 30px;
}

.hero-copy {
    display: grid;
    gap: 20px;
}

.eyebrow,
.section-kicker {
    margin: 0;
    color: var(--red);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-copy h1 {
    max-width: 730px;
    margin: 0;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-size: clamp(2.45rem, 4.8vw, 4.55rem);
    line-height: 1;
    letter-spacing: 0;
}

.hero-text {
    max-width: 650px;
    margin: 0;
    color: var(--soft);
    font-size: 1.03rem;
    line-height: 1.75;
}

.hero-stats,
.mini-timeline,
.stage-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-stats span,
.mini-timeline span,
.stage-list span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.055);
    font-size: 0.84rem;
    font-weight: 800;
}

.hero-stats span:first-child,
.mini-timeline .is-active,
.stage-list .is-active {
    color: #fff;
    border-color: rgba(255, 0, 51, 0.42);
    background: rgba(255, 0, 51, 0.16);
}

.stage-list .is-done {
    color: var(--green);
    border-color: rgba(67, 240, 167, 0.32);
    background: rgba(67, 240, 167, 0.1);
}

.control-panel,
.progress-card,
.video-preview,
.quality-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 40%),
        var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.control-panel {
    position: relative;
    overflow: hidden;
    padding: 22px;
}

.control-panel::before {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    content: "";
    background: linear-gradient(90deg, transparent, var(--red), #fff, var(--red), transparent);
}

.panel-top,
.progress-header,
.quality-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-top h2,
.progress-header h2,
.quality-heading h2 {
    margin: 5px 0 0;
    font-size: 1.12rem;
}

.status-pill,
#qualityCount {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 7px 11px;
    border: 1px solid rgba(67, 240, 167, 0.28);
    border-radius: 999px;
    color: var(--green);
    background: rgba(67, 240, 167, 0.09);
    font-size: 0.78rem;
    font-weight: 900;
    white-space: nowrap;
}

.status-pill.is-busy {
    color: var(--amber);
    border-color: rgba(247, 185, 85, 0.32);
    background: rgba(247, 185, 85, 0.1);
}

.status-pill.is-error {
    color: #ff8ba1;
    border-color: rgba(255, 0, 51, 0.45);
    background: rgba(255, 0, 51, 0.13);
}

.youtube-form {
    display: grid;
    gap: 12px;
    margin-top: 28px;
}

.youtube-form label {
    color: var(--soft);
    font-size: 0.85rem;
    font-weight: 800;
}

.input-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 17px;
    background: rgba(0, 0, 0, 0.32);
}

.input-shell:focus-within {
    border-color: rgba(255, 0, 51, 0.62);
    box-shadow: 0 0 0 4px rgba(255, 0, 51, 0.11);
}

.input-shell input {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    border: 0;
    outline: none;
    color: #fff;
    background: transparent;
    font-size: 0.96rem;
}

.input-shell input::placeholder {
    color: #6f7480;
}

.tool-button,
.primary-button,
.format-button,
.save-button {
    border: 0;
    border-radius: 12px;
    font-weight: 900;
    transition: transform 170ms ease, border-color 170ms ease, background 170ms ease, color 170ms ease;
}

.tool-button {
    min-height: 46px;
    padding: 0 12px;
    border: 1px solid var(--line);
    color: var(--soft);
    background: rgba(255, 255, 255, 0.075);
}

.tool-button:hover,
.tool-button:focus-visible {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
    outline: none;
}

.tool-button.ghost {
    color: var(--muted);
    background: transparent;
}

.field-message {
    min-height: 20px;
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.field-message.is-error {
    color: #ff9aad;
}

.primary-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 55px;
    padding: 0 18px;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    box-shadow: 0 18px 42px var(--red-glow);
}

.primary-button:hover,
.primary-button:focus-visible,
.format-button:hover,
.format-button:focus-visible,
.save-button:hover,
.save-button:focus-visible {
    transform: translateY(-2px);
    outline: none;
}

.primary-button:disabled,
.format-button:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.button-orbit {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 760ms linear infinite;
}

.primary-button.is-loading .button-orbit {
    display: inline-block;
}

.mini-timeline {
    margin-top: 22px;
}

.progress-card {
    display: grid;
    gap: 18px;
    margin: 12px 0 28px;
    padding: 22px;
}

.progress-card[hidden],
.result-layout[hidden] {
    display: none;
}

.pulse-loader {
    position: relative;
    display: grid;
    width: 58px;
    height: 58px;
    flex: 0 0 58px;
    place-items: center;
    border: 1px solid rgba(255, 0, 51, 0.34);
    border-radius: 18px;
    background: rgba(255, 0, 51, 0.12);
}

.pulse-loader::before {
    width: 16px;
    height: 16px;
    content: "";
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 28px var(--red);
}

.pulse-loader span {
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    animation: pulseBox 1.8s ease-in-out infinite;
}

.pulse-loader span:nth-child(2) {
    animation-delay: 0.25s;
}

.pulse-loader span:nth-child(3) {
    animation-delay: 0.5s;
}

.progress-header strong {
    font-size: 1.8rem;
}

.progress-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--red), #ff6a83, #fff);
    box-shadow: 0 0 24px var(--red-glow);
    transition: width 280ms ease;
}

.save-button {
    justify-self: start;
    padding: 13px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--green), #13a86b);
    box-shadow: 0 16px 34px rgba(67, 240, 167, 0.22);
}

.result-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
    gap: 22px;
    padding-bottom: 44px;
}

.video-preview,
.quality-panel {
    overflow: hidden;
}

.thumbnail-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #101014;
}

.thumbnail-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-frame::after {
    position: absolute;
    inset: auto 0 0;
    height: 45%;
    content: "";
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
}

#duration {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 1;
    padding: 6px 9px;
    border-radius: 8px;
    color: #fff;
    background: rgba(0, 0, 0, 0.74);
    font-size: 0.82rem;
    font-weight: 900;
}

.video-details {
    display: grid;
    gap: 10px;
    padding: 20px;
}

.video-details h2 {
    margin: 0;
    font-size: clamp(1.15rem, 2.6vw, 1.72rem);
    line-height: 1.25;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.meta-row span:not(:last-child)::after {
    margin-left: 10px;
    color: rgba(255, 255, 255, 0.22);
    content: "/";
}

.quality-panel {
    padding: 20px;
}

.qualities-grid {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.quality-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.055);
}

.quality-card:hover {
    border-color: rgba(255, 0, 51, 0.42);
    background: rgba(255, 0, 51, 0.08);
}

.quality-main {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.quality-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 9px;
}

.quality-title strong {
    font-size: 1.25rem;
}

.quality-title span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.badges span {
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
}

.badges .is-on {
    color: var(--green);
    border-color: rgba(67, 240, 167, 0.3);
    background: rgba(67, 240, 167, 0.08);
}

.format-button {
    min-height: 42px;
    padding: 0 14px;
    color: #fff;
    background: var(--red);
    box-shadow: 0 14px 26px rgba(255, 0, 51, 0.2);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 20;
    max-width: min(380px, calc(100vw - 36px));
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: #fff;
    background: rgba(17, 18, 22, 0.92);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-error {
    border-color: rgba(255, 0, 51, 0.36);
}

.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 24px 0 34px;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.site-footer p {
    margin: 0;
}

.site-footer strong,
.site-footer a {
    color: #fff;
}

.site-footer a {
    font-weight: 900;
}

/* TEMPORARY MAINTENANCE: Keep this modal styling enabled while the downloader is offline. Remove this block when the original experience returns. */
.maintenance-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(3, 3, 5, 0.8);
    backdrop-filter: blur(14px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.maintenance-modal.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.maintenance-card {
    width: min(560px, 100%);
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 28px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent 45%),
        rgba(17, 18, 22, 0.95);
    box-shadow: 0 38px 120px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.maintenance-icon {
    display: inline-grid;
    place-items: center;
    width: 74px;
    height: 74px;
    margin: 0 auto 16px;
    border: 1px solid rgba(255, 0, 51, 0.3);
    border-radius: 24px;
    background: rgba(255, 0, 51, 0.12);
}

.maintenance-icon span {
    display: block;
    width: 26px;
    height: 26px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.maintenance-card h2 {
    margin: 6px 0 10px;
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    line-height: 1.25;
}

.maintenance-copy {
    margin: 0;
    color: var(--soft);
    font-size: 1rem;
    line-height: 1.75;
}

.maintenance-actions {
    margin-top: 22px;
}

.maintenance-button {
    display: inline-flex;
    justify-content: center;
    min-width: 160px;
}

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

@keyframes pulseBox {
    0% {
        opacity: 0.7;
        transform: scale(0.78);
    }

    70%,
    100% {
        opacity: 0;
        transform: scale(1.35);
    }
}

@media (max-width: 920px) {
    .site-header,
    .site-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .top-nav {
        width: 100%;
        justify-content: space-between;
        border-radius: 18px;
    }

    .top-nav a {
        flex: 1;
        text-align: center;
    }

    .hero-grid,
    .result-layout {
        grid-template-columns: 1fr;
    }

    .hero-grid {
        min-height: auto;
        padding-top: 28px;
    }
}

@media (max-width: 620px) {
    .page-shell {
        width: min(100% - 22px, 1180px);
    }

    .hero-copy h1 {
        font-size: clamp(2.1rem, 10vw, 3.25rem);
    }

    .control-panel,
    .progress-card,
    .quality-panel {
        border-radius: 18px;
        padding: 16px;
    }

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

    .input-shell input {
        grid-column: 1 / -1;
    }

    .tool-button {
        width: 100%;
    }

    .progress-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .quality-card {
        grid-template-columns: 1fr;
    }

    .format-button {
        width: 100%;
    }
}
