:root {
    color-scheme: dark;
    --bg: #0b0c0e;
    --surface: #111316;
    --surface-raised: #17191d;
    --surface-hover: #1d2024;
    --text: #f0f1f2;
    --text-soft: #c4c7cb;
    --muted: #80858c;
    --muted-strong: #9ca1a8;
    --border: #26292e;
    --border-strong: #34383e;
    --accent: #6f97ff;
    --accent-soft: rgba(111, 151, 255, 0.13);
    --danger: #ff7770;
    --warning-border: #66531f;
    --warning-bg: #17150d;
    --warning-text: #d7c47b;
    --radius: 5px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header {
    height: 58px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 12, 14, 0.96);
}

.header-inner {
    width: min(880px, calc(100% - 48px));
    height: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 670;
    letter-spacing: -0.015em;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.08em;
}

.meta-separator {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #4a4e54;
}

.page-shell {
    width: min(880px, calc(100% - 48px));
    margin: 0 auto;
    padding: 74px 0 48px;
}

.intro {
    max-width: 620px;
    padding-bottom: 42px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.intro h1 {
    margin: 0;
    color: #f6f7f8;
    font-size: clamp(34px, 5vw, 48px);
    line-height: 1.02;
    letter-spacing: -0.045em;
    font-weight: 680;
}

.intro-copy {
    margin: 15px 0 0;
    color: var(--muted-strong);
    font-size: 16px;
}

.setup-warning {
    margin: -12px 0 30px;
    padding: 13px 15px;
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    background: var(--warning-bg);
    color: var(--warning-text);
    font-size: 13px;
}

.setup-warning strong {
    color: #eadb9c;
    margin-right: 5px;
}

.workflow-section {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    column-gap: 28px;
    padding: 30px 0 34px;
    border-top: 1px solid var(--border);
}

.section-heading {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 9px;
    align-content: start;
}

.section-index {
    margin-top: 2px;
    color: #5e636a;
    font-size: 11px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.section-heading h2 {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.section-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.url-form {
    min-width: 0;
}

label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 620;
}

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

input,
.select-trigger {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 110ms ease, background-color 110ms ease, box-shadow 110ms ease;
}

input {
    padding: 0 13px;
}

input::placeholder {
    color: #5f646a;
}

input:hover {
    border-color: #41464d;
}

input:focus,
.select-trigger:focus-visible,
.custom-select.is-open .select-trigger {
    border-color: #66789d;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

button:not(.select-trigger):not(.select-option) {
    height: 44px;
    border: 1px solid #e6e8eb;
    border-radius: var(--radius);
    padding: 0 17px;
    background: #e6e8eb;
    color: #0e0f11;
    font-weight: 680;
    letter-spacing: -0.01em;
    transition: background-color 110ms ease, border-color 110ms ease, opacity 110ms ease, transform 80ms ease;
}

button:not(.select-trigger):not(.select-option):hover:not(:disabled) {
    border-color: #ffffff;
    background: #ffffff;
}

button:not(.select-trigger):not(.select-option):active:not(:disabled) {
    transform: translateY(1px);
}

button:focus-visible {
    outline: none;
}

button:not(.select-trigger):not(.select-option):focus-visible {
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
}

button:disabled {
    cursor: default;
    opacity: 0.48;
}

.message {
    margin: 9px 0 0;
    font-size: 12px;
}

.error-message {
    color: var(--danger);
}

.output-section {
    align-items: start;
}

.video-summary,
.download-controls,
.quality-note {
    grid-column: 2;
}

.video-summary {
    display: grid;
    grid-template-columns: 184px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    min-width: 0;
    margin-bottom: 27px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--border);
}

.thumbnail-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #15171a;
}

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

.video-copy {
    min-width: 0;
}

.video-copy h3 {
    margin: 0;
    max-width: 100%;
    color: #eef0f2;
    font-size: 17px;
    line-height: 1.36;
    letter-spacing: -0.02em;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.video-copy p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.download-controls {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) auto;
    gap: 9px;
    align-items: end;
}

.field {
    min-width: 0;
}

.custom-select {
    position: relative;
    min-width: 0;
}

.select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px 0 13px;
    text-align: left;
    cursor: pointer;
}

.select-trigger:hover {
    border-color: #41464d;
    background: #141619;
}

.select-value {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #e5e7e9;
    font-size: 13px;
    font-weight: 560;
}

.select-chevron {
    flex: 0 0 auto;
    width: 11px;
    height: 7px;
    color: #777d84;
    transition: transform 130ms ease, color 130ms ease;
}

.custom-select.is-open .select-chevron {
    transform: rotate(180deg);
    color: #aeb3b9;
}

.select-menu {
    position: absolute;
    z-index: 50;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 284px;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #16181c;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
}

.select-menu::-webkit-scrollbar {
    width: 8px;
}

.select-menu::-webkit-scrollbar-track {
    background: transparent;
}

.select-menu::-webkit-scrollbar-thumb {
    border: 2px solid #16181c;
    border-radius: 8px;
    background: #3c4147;
}

.select-option {
    width: 100%;
    min-height: 43px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 9px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-soft);
    text-align: left;
    cursor: pointer;
}

.select-option:hover,
.select-option.is-active {
    background: var(--surface-hover);
}

.select-option:focus-visible {
    background: var(--surface-hover);
    box-shadow: inset 0 0 0 1px #3a4048;
}

.select-option > span {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.select-option strong {
    overflow: hidden;
    color: #e6e8ea;
    font-size: 13px;
    font-weight: 570;
    line-height: 1.35;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.select-option small {
    margin-top: 2px;
    color: #767c83;
    font-size: 11px;
    line-height: 1.3;
}

.option-check {
    width: 13px;
    height: 10px;
    flex: 0 0 auto;
    color: var(--accent);
    opacity: 0;
}

.select-option.is-selected .option-check {
    opacity: 1;
}

.download-button {
    min-width: 116px;
}

.quality-note {
    min-height: 17px;
    margin: 9px 0 0;
    color: #6f747b;
    font-size: 11px;
    line-height: 1.45;
}

.progress-panel {
    align-items: start;
}

.progress-panel .progress-heading {
    grid-column: 1;
}

.progress-heading {
    position: relative;
}

.progress-percent {
    position: absolute;
    right: 0;
    top: 0;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.progress-track,
.progress-details,
.progress-panel .message {
    grid-column: 2;
}

.progress-track {
    width: 100%;
    height: 4px;
    margin-top: 7px;
    overflow: hidden;
    background: #202328;
}

.progress-bar {
    width: 0;
    height: 100%;
    background: #7a9cff;
    transition: width 180ms linear;
}

.progress-details {
    min-height: 19px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: #737980;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.page-footer {
    padding: 24px 0 0 178px;
    border-top: 1px solid var(--border);
}

.page-footer p {
    margin: 0;
    color: #555b61;
    font-size: 11px;
}

[hidden] {
    display: none !important;
}

@media (max-width: 760px) {
    .header-inner,
    .page-shell {
        width: min(100% - 32px, 880px);
    }

    .page-shell {
        padding-top: 52px;
    }

    .workflow-section {
        grid-template-columns: 1fr;
        row-gap: 22px;
    }

    .section-heading,
    .progress-panel .progress-heading,
    .video-summary,
    .download-controls,
    .quality-note,
    .progress-track,
    .progress-details,
    .progress-panel .message {
        grid-column: 1;
    }

    .section-heading {
        grid-template-columns: 26px minmax(0, 1fr);
    }

    .section-heading p {
        max-width: 440px;
    }

    .page-footer {
        padding-left: 0;
    }
}

@media (max-width: 580px) {
    .page-shell {
        padding-top: 42px;
    }

    .intro {
        padding-bottom: 34px;
    }

    .intro h1 {
        font-size: 36px;
    }

    .header-meta {
        display: none;
    }

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

    .url-row > button {
        width: 100%;
    }

    .video-summary {
        grid-template-columns: 140px minmax(0, 1fr);
        gap: 14px;
    }

    .download-controls {
        grid-template-columns: 1fr 1fr;
    }

    .download-button {
        grid-column: 1 / -1;
        width: 100%;
    }
}

@media (max-width: 430px) {
    .header-inner,
    .page-shell {
        width: min(100% - 24px, 880px);
    }

    .video-summary {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .thumbnail-wrap {
        width: 100%;
    }

    .download-controls {
        grid-template-columns: 1fr;
    }

    .download-button {
        grid-column: auto;
    }

    .select-menu {
        max-height: 238px;
    }
}

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