:root {
    color-scheme: dark;
    --bg: #080b12;
    --panel: #10151e;
    --panel-2: #0b1018;
    --line: #26303d;
    --line-soft: #1b2430;
    --text: #f4f7fb;
    --muted: #8b97a8;
    --accent: #b6ff32;
    --accent-ink: #101700;
    --danger: #ff6174;
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 50% -15%, rgba(182, 255, 50, .09), transparent 34rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

button,
input,
textarea {
    font: inherit;
}

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

[hidden] {
    display: none !important;
}

.site-header {
    display: flex;
    width: min(100% - 40px, 1040px);
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin: 0 auto;
    border-bottom: 1px solid var(--line-soft);
}

.site-header > a:last-child,
.site-footer a,
.text-button {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .11em;
}

.site-header > a:last-child:hover,
.site-footer a:hover,
.text-button:hover {
    color: var(--accent);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-size: .94rem;
    font-weight: 900;
    letter-spacing: .03em;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(182, 255, 50, .65);
    border-radius: 10px;
    background: rgba(182, 255, 50, .08);
    color: var(--accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 900;
}

.converter-shell {
    width: min(100% - 40px, 820px);
    margin: 0 auto;
    padding: 72px 0 56px;
}

.converter-intro {
    margin-bottom: 28px;
    text-align: center;
}

.eyebrow {
    display: block;
    margin-bottom: 12px;
    color: var(--accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .16em;
}

.converter-intro h1,
.terms-shell h1,
.admin-shell h1 {
    margin: 0;
    font-size: clamp(2.45rem, 7vw, 4.75rem);
    line-height: .98;
    letter-spacing: -.055em;
}

.converter-intro h1 em {
    color: var(--accent);
    font-style: normal;
}

.converter-intro p {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.converter-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(16, 21, 30, .94);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .34);
    padding: 24px;
}

.yt-url-field > span,
.admin-form strong,
.admin-login label > span {
    display: block;
    margin-bottom: 10px;
    color: #b8c1ce;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .1em;
}

.field-heading {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.field-heading b {
    font: inherit;
}

.field-heading small {
    color: var(--accent);
    font: inherit;
}

.yt-url-field textarea,
.admin-form textarea,
.admin-login input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #090d14;
    color: var(--text);
    outline: none;
}

.yt-url-field textarea {
    min-height: 150px;
    padding: 17px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1rem;
    line-height: 1.65;
}

.yt-url-field textarea:focus,
.admin-form textarea:focus,
.admin-login input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(182, 255, 50, .08);
}

.yt-url-field textarea::placeholder,
.admin-form textarea::placeholder {
    color: #536070;
}

.primary-button {
    width: 100%;
    min-height: 54px;
    margin-top: 15px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85rem;
    font-weight: 900;
    letter-spacing: .11em;
    transition: transform .18s ease, filter .18s ease;
}

.primary-button:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: wait;
    filter: grayscale(.25);
    opacity: .72;
    transform: none;
}

.yt-queue,
.yt-progress-card {
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-2);
}

.yt-queue-head,
.remote-progress-head {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 15px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
}

.yt-queue-head strong,
.remote-progress-head output {
    color: var(--accent);
}

.yt-queue-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--line-soft);
}

.yt-queue-item:last-child {
    border-bottom: 0;
}

.yt-queue-number {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    font-weight: 900;
}

.yt-queue-identity {
    min-width: 0;
}

.yt-queue-identity strong,
.yt-queue-identity small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yt-queue-identity strong {
    font-size: .9rem;
}

.yt-queue-identity small {
    margin-top: 4px;
    color: #657183;
    font-size: .75rem;
}

.yt-queue-state,
.yt-queue-download {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .06em;
    white-space: nowrap;
}

.yt-queue-state {
    color: var(--muted);
}

.yt-queue-download {
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 9px 11px;
    color: var(--accent);
}

.yt-queue-item.is-active .yt-queue-number,
.yt-queue-item.is-ready .yt-queue-number {
    border-color: var(--accent);
    color: var(--accent);
}

.yt-queue-item.is-failed .yt-queue-number,
.yt-queue-item.is-failed .yt-queue-state {
    border-color: var(--danger);
    color: var(--danger);
}

.remote-progress-track {
    height: 6px;
    margin: 16px;
    overflow: hidden;
    border-radius: 999px;
    background: #222b37;
}

.remote-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width .2s linear;
}

.yt-progress-card.is-indeterminate .remote-progress-track span {
    width: 35%;
    animation: progress-pulse 1.2s ease-in-out infinite;
}

@keyframes progress-pulse {
    from { transform: translateX(-115%); }
    to { transform: translateX(390%); }
}

.yt-active-title {
    padding: 0 16px 15px;
}

.yt-active-title span,
.yt-progress-stats b {
    display: block;
    margin-bottom: 5px;
    color: #667285;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .09em;
}

.yt-active-title strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yt-progress-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 15px 16px;
    border-top: 1px solid var(--line-soft);
}

.yt-progress-stats strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
}

.ad-slot {
    width: min(100% - 40px, 1040px);
    margin: 24px auto;
    overflow: hidden;
    text-align: center;
}

.converter-shell > .ad-slot {
    width: 100%;
}

.site-footer {
    display: flex;
    width: min(100% - 40px, 1040px);
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 auto;
    border-top: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: .82rem;
}

.toast,
.notice {
    border: 1px solid rgba(182, 255, 50, .4);
    background: #11180c;
    color: var(--accent);
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 20;
    max-width: min(360px, calc(100vw - 44px));
    border-radius: 12px;
    padding: 13px 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
    font-size: .88rem;
}

.toast.error,
.notice-error {
    border-color: rgba(255, 97, 116, .45);
    background: #1b0d12;
    color: var(--danger);
}

.terms-shell,
.admin-shell {
    width: min(100% - 40px, 820px);
    margin: 0 auto;
    padding: 64px 0 72px;
}

.terms-shell h1,
.admin-shell h1 {
    font-size: clamp(2.25rem, 6vw, 4rem);
}

.terms-date {
    margin: 14px 0 42px;
    color: var(--muted);
}

.terms-shell section {
    padding: 25px 0;
    border-top: 1px solid var(--line-soft);
}

.terms-shell h2 {
    margin: 0 0 10px;
    font-size: 1.15rem;
}

.terms-shell p {
    margin: 0;
    color: #b2bdca;
}

.admin-shell > .brand {
    margin-bottom: 44px;
}

.admin-login {
    max-width: 470px;
    margin: 42px auto 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 28px;
}

.admin-login form {
    margin-top: 28px;
}

.admin-login input {
    min-height: 52px;
    padding: 0 15px;
}

.notice {
    margin-bottom: 22px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: .88rem;
}

.admin-heading,
.admin-slot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.admin-heading {
    margin-bottom: 30px;
}

.admin-heading .eyebrow {
    margin-bottom: 8px;
}

.text-button {
    border: 0;
    background: none;
    cursor: pointer;
}

.admin-slot {
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    padding: 18px;
}

.admin-slot-head {
    margin-bottom: 12px;
}

.admin-slot-head strong {
    margin: 0;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    font-weight: 800;
}

.switch input {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
}

.admin-form textarea {
    min-height: 130px;
    padding: 13px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    line-height: 1.55;
}

.admin-note {
    color: var(--muted);
    font-size: .86rem;
}

@media (max-width: 700px) {
    .site-header,
    .site-footer,
    .converter-shell,
    .terms-shell,
    .admin-shell,
    .ad-slot {
        width: min(100% - 28px, 1040px);
    }

    .converter-shell {
        padding-top: 48px;
    }

    .converter-card,
    .admin-login {
        padding: 17px;
        border-radius: 15px;
    }

    .yt-queue-item {
        grid-template-columns: 36px minmax(0, 1fr) auto;
        gap: 10px;
    }

    .yt-queue-download {
        grid-column: 2 / -1;
        justify-self: start;
    }

    .yt-progress-stats {
        grid-template-columns: 1fr 1fr;
    }

    .site-footer {
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding: 22px 0;
    }
}

@media (max-width: 440px) {
    .site-header {
        min-height: 68px;
    }

    .brand {
        font-size: .84rem;
    }

    .brand-mark {
        width: 31px;
        height: 31px;
    }

    .converter-intro h1 {
        font-size: 2.55rem;
    }

    .yt-url-field textarea {
        min-height: 138px;
    }

    .yt-queue-head,
    .remote-progress-head,
    .admin-heading,
    .admin-slot-head {
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        padding-top: 11px;
        padding-bottom: 11px;
    }

    .yt-queue-item {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .yt-queue-state,
    .yt-queue-download {
        grid-column: 2;
        justify-self: start;
    }

    .yt-progress-stats {
        grid-template-columns: 1fr;
    }

    .toast {
        right: 14px;
        bottom: 14px;
    }
}
