:root {
    color-scheme: dark;
    --bg: #06050d;
    --panel: rgba(14, 11, 24, 0.96);
    --panel-soft: rgba(21, 16, 33, 0.9);
    --text: #f8eef5;
    --muted: #ad9faa;
    --pink: #b852a8;
    --orange: #c47742;
    --cyan: #4fbeca;
    --danger: #e74f67;
    --shadow: rgba(0, 0, 0, 0.5);
    --radius: 8px;
    font-family: Inter, Roboto, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    padding-bottom: 78px;
    color: var(--text);
    background:
        linear-gradient(rgba(184, 82, 168, 0.016) 1px, transparent 1px),
        linear-gradient(90deg, rgba(196, 119, 66, 0.014) 1px, transparent 1px),
        linear-gradient(135deg, rgba(184, 82, 168, 0.036), transparent 34%),
        linear-gradient(315deg, rgba(79, 190, 202, 0.032), transparent 38%),
        var(--bg);
    background-size: 34px 34px, 34px 34px, auto, auto, auto;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: var(--cyan);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-header {
    border-bottom: 1px solid rgba(184, 82, 168, 0.18);
    background: linear-gradient(90deg, rgba(184, 82, 168, 0.052), rgba(196, 119, 66, 0.034)), rgba(6, 5, 13, 0.94);
    box-shadow: 0 12px 30px var(--shadow);
}

.app-header__content {
    width: min(1080px, calc(100% - 32px));
    min-height: 86px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

h1 {
    margin: 0;
    font-family: "Cascadia Mono", "Segoe UI", monospace;
    font-size: clamp(1.55rem, 4vw, 2.65rem);
    line-height: 1.05;
    text-transform: uppercase;
    text-shadow: 0 0 14px rgba(184, 82, 168, 0.12);
}

h1 a,
h1 a:hover {
    color: inherit;
    text-decoration: none;
}

.header-tagline.is-typing {
    min-width: var(--typing-width, auto);
}

.header-tagline.is-typing::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 1em;
    margin-left: 4px;
    vertical-align: -2px;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    animation: cursor-blink 800ms steps(2, start) infinite;
}

.header-tagline {
    max-width: 620px;
    margin: 8px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.hub-link {
    min-height: 42px;
    padding: 9px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #120711;
    border: 1px solid rgba(79, 190, 202, 0.3);
    border-radius: 6px;
    background: linear-gradient(120deg, var(--pink), var(--orange), var(--cyan), var(--pink));
    background-size: 260% 260%;
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 5px 0 rgba(0, 0, 0, 0.34),
        0 0 10px rgba(184, 82, 168, 0.1);
    font-weight: 700;
    text-transform: uppercase;
    animation: hub-link-flow 5s ease-in-out infinite;
}

.hub-link:hover {
    color: #120711;
    text-decoration: none;
    animation-duration: 1.8s;
}

.hub-link:active {
    box-shadow:
        inset 0 5px 12px rgba(0, 0, 0, 0.38),
        0 1px 0 rgba(0, 0, 0, 0.34),
        0 0 8px rgba(79, 190, 202, 0.1);
    transform: scaleY(0.9);
    transform-origin: bottom;
}

.converter-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 30px auto 56px;
}

.limit-strip,
.notice,
.converter-panel,
.info-panel {
    border: 1px solid rgba(184, 82, 168, 0.18);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 0 14px rgba(184, 82, 168, 0.035), 0 14px 34px var(--shadow);
}

.limit-strip {
    padding: 12px 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 18px;
    color: var(--muted);
    text-align: center;
}

.notice {
    margin-top: 16px;
    padding: 14px 16px;
    display: grid;
    gap: 8px;
}

#resultNotice[hidden],
.notice[hidden] {
    display: none !important;
}

.notice--attention {
    animation: notice-pulse 2.4s ease-out 1;
}

.notice--error {
    border-color: rgba(255, 116, 137, 0.36);
    color: #ffd5dc;
}

.notice--success {
    border-color: rgba(79, 190, 202, 0.28);
    color: #dffcff;
}

.info-panel {
    margin-top: 18px;
    padding: clamp(18px, 4vw, 30px);
}

.info-panel h2 {
    margin: 0 0 12px;
    color: var(--pink);
}

.info-panel p {
    margin: 10px 0 0;
    color: var(--muted);
}

.privacy-note {
    padding: 10px 12px;
    border-left: 3px solid var(--cyan);
    background: rgba(79, 190, 202, 0.045);
    border-radius: 6px;
}

.download-link {
    width: fit-content;
    min-height: 42px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #100713;
    border: 1px solid rgba(79, 190, 202, 0.3);
    border-radius: 6px;
    background: linear-gradient(135deg, var(--cyan), var(--pink));
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 5px 0 rgba(0, 0, 0, 0.34),
        0 0 10px rgba(79, 190, 202, 0.08);
    font-weight: 900;
    text-decoration: none;
    text-transform: uppercase;
}

.download-link:hover {
    color: #100713;
    text-decoration: none;
}

.download-link:active {
    box-shadow:
        inset 0 5px 12px rgba(0, 0, 0, 0.38),
        0 1px 0 rgba(0, 0, 0, 0.34),
        0 0 8px rgba(184, 82, 168, 0.14);
    transform: scaleY(0.92);
    transform-origin: bottom;
}

.download-item {
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    align-items: end;
    gap: 10px 14px;
    border: 1px solid rgba(79, 190, 202, 0.18);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.18);
}

.download-name-field {
    display: grid;
    gap: 7px;
}

.download-name-field span {
    color: var(--cyan);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.download-name-field input {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    color: var(--text);
    border: 1px solid rgba(79, 190, 202, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    outline: none;
}

.download-name-field input:focus {
    border-color: var(--pink);
    box-shadow: 0 0 0 3px rgba(184, 82, 168, 0.1);
}

.download-name-field input.is-invalid {
    border-color: var(--danger);
}

.download-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px 14px;
    grid-column: 1;
    grid-row: 2;
}

.download-process-time {
    min-height: 1.2em;
    color: var(--orange);
    font-family: "Cascadia Mono", "Segoe UI", monospace;
    font-size: 0.78rem;
    font-weight: 800;
}

.download-size {
    color: var(--muted);
    font-family: "Cascadia Mono", "Segoe UI", monospace;
    font-weight: 800;
}

.download-error {
    min-height: 1.2em;
    grid-column: 1 / -1;
    color: #ffd5dc;
    font-weight: 800;
}

details pre {
    max-height: 260px;
    overflow: auto;
    padding: 12px;
    color: var(--muted);
    background: rgba(0, 0, 0, 0.34);
    border-radius: 6px;
}

.converter-panel {
    margin-top: 16px;
    padding: clamp(18px, 4vw, 30px);
}

.converter-form {
    display: grid;
    gap: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(220px, 0.8fr);
    align-items: end;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    color: var(--pink);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

input[type="file"] {
    width: 100%;
    min-height: 52px;
    padding: 12px;
    color: var(--text);
    border: 1px solid rgba(79, 190, 202, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
}

select {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    color: var(--text);
    border: 1px solid rgba(79, 190, 202, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.34);
    outline: none;
}

select option {
    color: var(--text);
    background-color: #100b1b;
}

input[type="file"],
select {
    cursor: pointer;
}

input:focus,
select:focus {
    border-color: var(--pink);
    box-shadow: 0 0 0 3px rgba(184, 82, 168, 0.1);
}

.hint {
    margin: 0;
    color: var(--muted);
}

.button-primary,
.button-secondary,
.button-danger {
    width: fit-content;
    min-height: 46px;
    padding: 10px 16px;
    border: 1px solid rgba(196, 119, 66, 0.3);
    border-radius: 6px;
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 5px 0 rgba(0, 0, 0, 0.34);
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
}

.button-primary {
    color: #120711;
    background: linear-gradient(135deg, var(--pink), var(--orange));
}

.form-actions {
    display: grid;
    grid-template-columns: minmax(46px, 1fr) auto minmax(46px, 1fr);
    align-items: center;
    gap: 14px;
}

.form-actions .button-primary {
    grid-column: 2;
    justify-self: center;
}

.reset-button {
    grid-column: 3;
    justify-self: end;
    width: 46px;
    min-width: 46px;
    padding: 10px;
    color: #fff;
}

.button-primary:hover {
    color: #120711;
}

.button-secondary {
    color: var(--text);
    border-color: rgba(79, 190, 202, 0.22);
    background: rgba(79, 190, 202, 0.09);
}

.button-danger {
    color: #fff;
    border-color: rgba(255, 79, 109, 0.38);
    background: rgba(192, 39, 61, 0.88);
}

.button-primary:active,
.button-secondary:active,
.button-danger:active {
    box-shadow:
        inset 0 5px 12px rgba(0, 0, 0, 0.38),
        0 1px 0 rgba(0, 0, 0, 0.34);
    transform: scaleY(0.92);
    transform-origin: bottom;
}

.noscript-alert {
    width: min(1080px, calc(100% - 32px));
    margin: 16px auto 0;
    padding: 12px 14px;
    color: #ffe1e8;
    border: 1px solid rgba(255, 116, 137, 0.36);
    border-radius: var(--radius);
    background: rgba(255, 79, 109, 0.12);
}

.loading-dialog,
.confirm-dialog,
.loading-dialog::backdrop,
.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
}

.loading-dialog,
.confirm-dialog {
    width: min(360px, calc(100% - 32px));
    padding: 0;
    color: var(--text);
    border: 1px solid rgba(184, 82, 168, 0.38);
    border-radius: var(--radius);
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.58), 0 0 18px rgba(184, 82, 168, 0.08);
}

.loading-dialog__content,
.confirm-dialog__content {
    padding: 24px;
    display: grid;
    gap: 12px;
    background: var(--panel);
}

.loading-dialog__content {
    justify-items: center;
    text-align: center;
}

.confirm-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.confirm-dialog__header h2,
.confirm-dialog__content p {
    margin: 0;
}

.confirm-dialog__close {
    width: 34px;
    height: 34px;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 6px;
    background: #9f1f32;
    font-weight: 900;
    cursor: pointer;
}

.confirm-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--pink);
    border-radius: 50%;
    animation: spin 850ms linear infinite;
}

.loading-timer {
    padding: 5px 9px;
    color: var(--cyan);
    border: 1px solid rgba(79, 190, 202, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    font-family: "Cascadia Mono", "Segoe UI", monospace;
    font-weight: 800;
}

.loading-cancel {
    margin-top: 8px;
    justify-self: center;
}

@keyframes cursor-blink {
    50% {
        opacity: 0;
    }
}

@keyframes hub-link-flow {
    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

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

@keyframes notice-pulse {
    0%,
    100% {
        box-shadow: 0 0 14px rgba(184, 82, 168, 0.035), 0 14px 34px var(--shadow);
    }

    18%,
    54% {
        border-color: rgba(255, 122, 24, 0.82);
        box-shadow: 0 0 0 2px rgba(255, 122, 24, 0.16), 0 0 24px rgba(255, 122, 24, 0.16);
    }

    36%,
    72% {
        border-color: rgba(79, 190, 202, 0.58);
        box-shadow: 0 0 0 2px rgba(79, 190, 202, 0.1), 0 0 18px rgba(79, 190, 202, 0.1);
    }
}

@media (max-width: 768px) {
    .app-header__content {
        width: calc(100% - 20px);
        padding: 16px 0;
        align-items: flex-start;
        flex-direction: column;
    }

    .converter-shell {
        width: calc(100% - 20px);
    }

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

    .download-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .download-name-field {
        min-width: 0;
    }

    .download-meta {
        grid-column: 1;
        grid-row: 2;
        justify-content: center;
        text-align: center;
    }

    .download-link {
        grid-column: 2;
        grid-row: 1;
        align-self: end;
    }

    .button-primary {
        min-width: min(240px, 72vw);
        justify-self: center;
    }

    .limit-strip {
        justify-content: center;
        text-align: center;
    }

    body {
        padding-bottom: 0;
    }
}

@media (min-width: 320px) and (max-width: 425px) {
    .limit-strip {
        justify-content: center;
    }

    .limit-strip span {
        width: 100%;
        text-align: center;
    }

    .limit-strip,
    .download-item,
    .download-name-field,
    .download-size,
    .download-process-time,
    .download-error {
        text-align: center;
    }

    .download-meta {
        flex-wrap: nowrap;
        grid-column: 1 / -1;
        grid-row: auto;
        justify-content: center;
        width: 100%;
    }

    .download-link {
        grid-column: 1 / -1;
        grid-row: auto;
        justify-self: center;
    }

    .button-primary {
        justify-self: center;
    }

    .converter-panel {
        padding: 14px 10px;
    }

    .converter-form {
        gap: 14px;
    }

    .field {
        gap: 6px;
    }

    input[type="file"] {
        min-height: 48px;
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    select {
        min-height: 44px;
        padding: 8px;
    }

    .form-actions {
        grid-template-columns: minmax(0, 1fr) 42px;
        gap: 10px;
        width: 100%;
    }

    .form-actions .button-primary {
        grid-column: 1;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding-inline: 10px;
        white-space: normal;
    }

    .reset-button {
        grid-column: 2;
        width: 42px;
        min-width: 42px;
        padding: 8px;
    }

    .confirm-dialog__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
        width: 100%;
    }

    .confirm-dialog__actions .button-secondary,
    .confirm-dialog__actions .button-danger {
        width: 100%;
        min-height: 38px;
        min-width: 0;
        padding: 8px 6px;
        justify-content: center;
        font-size: 0.78rem;
        text-align: center;
        white-space: normal;
    }
}

@-moz-document url-prefix() {
    @media (min-width: 320px) and (max-width: 425px) {
        .converter-panel,
        .converter-form,
        .form-row,
        .field,
        .hint,
        .form-actions {
            min-width: 0;
            max-width: 100%;
        }

        .converter-panel {
            overflow: hidden;
            padding-inline: 12px;
        }

        .form-row {
            grid-template-columns: minmax(0, 1fr);
        }

        input[type="file"],
        select {
            width: 100%;
            max-width: 100%;
            min-width: 0;
        }

        .field--files input[type="file"] {
            font-size: 0.82rem;
        }

        .form-actions {
            grid-template-columns: minmax(0, 1fr) 42px;
            gap: 10px;
        }

        .form-actions .button-primary {
            grid-column: 1;
            width: 100%;
            max-width: 100%;
            min-width: 0;
            padding-inline: 10px;
            white-space: normal;
        }

        .reset-button {
            grid-column: 2;
            width: 42px;
            min-width: 42px;
            padding: 8px;
        }

        .hint {
            overflow-wrap: anywhere;
        }
    }
}

.download-size,
.process-time,
.loading-timer,
.limit-details {
    font-family: var(--font-data), "Cascadia Mono", "Segoe UI", monospace;
}
