:root {
    color-scheme: dark;
    --bg: #05080f;
    --panel: rgba(8, 15, 25, 0.96);
    --panel-soft: rgba(13, 22, 34, 0.9);
    --text: #eef7f8;
    --muted: #95aab4;
    --coral: #d96f57;
    --violet: #7861d8;
    --danger: #e96578;
    --shadow: rgba(0, 0, 0, 0.5);
    --radius: 8px;
    font-family: Inter, Roboto, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    min-height: 100vh;
    margin: 0;
    padding-bottom: 78px;
    color: var(--text);
    background:
        linear-gradient(rgba(217, 111, 87, 0.016) 1px, transparent 1px),
        linear-gradient(90deg, rgba(120, 97, 216, 0.014) 1px, transparent 1px),
        linear-gradient(135deg, rgba(217, 111, 87, 0.035), transparent 34%),
        linear-gradient(315deg, rgba(120, 97, 216, 0.03), transparent 38%),
        var(--bg);
    background-size: 34px 34px, 34px 34px, auto, auto, auto;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

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

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

a:hover {
    text-decoration: none;
}

.app-header {
    border-bottom: 1px solid rgba(217, 111, 87, 0.18);
    background: linear-gradient(90deg, rgba(217, 111, 87, 0.052), rgba(120, 97, 216, 0.032)), rgba(5, 8, 15, 0.94);
    box-shadow: 0 12px 30px var(--shadow);
}

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(217, 111, 87, 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;
}

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

.limit-strip,
.notice,
.cutter-panel,
.info-panel {
    border: 1px solid rgba(217, 111, 87, 0.18);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 0 14px rgba(217, 111, 87, 0.035), 0 14px 34px var(--shadow);
}

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

.notice {
    margin-top: 16px;
    padding: 14px 16px;
    display: grid;
    gap: 8px;
    max-width: 100%;
    min-width: 0;
}

.notice--result {
    position: relative;
    margin-top: 20px;
    padding: 18px;
    overflow: hidden;
    border-color: rgba(120, 97, 216, 0.34);
    background:
        linear-gradient(135deg, rgba(217, 111, 87, 0.1), rgba(120, 97, 216, 0.065)),
        rgba(8, 16, 26, 0.98);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.035),
        0 0 0 1px rgba(120, 97, 216, 0.08),
        0 14px 34px var(--shadow),
        0 0 18px rgba(217, 111, 87, 0.08);
}

.notice--result::before {
    content: "Result";
    width: max-content;
    padding: 4px 8px;
    color: #071018;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--coral), var(--violet));
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.notice--error {
    border-color: rgba(233, 101, 120, 0.34);
    color: #ffd5dc;
}

.notice--alert {
    animation: alert-border-pulse 1150ms ease-in-out 3;
}

.notice--success {
    border-color: rgba(217, 111, 87, 0.28);
    color: #dffcff;
}

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

.cutter-form,
.interval-panel {
    display: grid;
    gap: 18px;
}

.cutter-form > *,
.file-row > *,
.interval-row > *,
.time-group > *,
.download-item > * {
    min-width: 0;
}

.file-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 240px) auto;
    align-items: end;
    gap: 12px;
}

.file-row__input {
    min-width: 0;
}

.file-actions {
    display: flex;
    justify-content: flex-end;
}

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

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

input,
select {
    max-width: 100%;
    min-width: 0;
    width: 100%;
    min-height: 48px;
    color: var(--text);
    border: 1px solid rgba(217, 111, 87, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.28);
    outline: none;
}

select {
    padding: 10px 12px;
    color-scheme: dark;
}

select option {
    color: var(--text);
    background: #0b1421;
}

input[type="file"] {
    padding: 12px;
}

input[type="number"],
.download-name-field input {
    padding: 10px 12px;
}

input:focus,
select:focus {
    border-color: var(--coral);
    box-shadow: 0 0 0 3px rgba(217, 111, 87, 0.09);
}

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

.preview-panel {
    display: grid;
    gap: 10px;
}

.preview-panel video,
.preview-panel audio {
    width: 100%;
    border: 1px solid rgba(217, 111, 87, 0.18);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.34);
}

.preview-panel video {
    max-height: 420px;
}

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

.preview-panel p,
.hint {
    margin: 0;
    color: var(--muted);
}

.interval-panel {
    padding-top: 16px;
    border-top: 1px solid rgba(217, 111, 87, 0.13);
}

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

.interval-panel h2 {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    text-transform: uppercase;
}

.interval-list {
    display: grid;
    gap: 12px;
}

.interval-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.interval-row__title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: center;
    color: var(--violet);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.interval-number {
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #041316;
    border: 1px solid rgba(207, 169, 94, 0.52);
    border-radius: 50%;
    background: rgba(207, 169, 94, 0.82);
    box-shadow: 0 0 8px rgba(207, 169, 94, 0.12);
    font-size: 0.75rem;
    line-height: 1;
}

.time-group {
    min-width: 0;
    margin: 0;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    border: 1px solid rgba(217, 111, 87, 0.17);
    border-radius: var(--radius);
    background: rgba(217, 111, 87, 0.035);
}

.time-group legend {
    padding: 0 6px;
    color: var(--coral);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.time-group input[type="hidden"] {
    display: none;
}

.button-primary,
.button-secondary,
.button-danger,
.icon-button,
.download-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 900;
    text-transform: uppercase;
}

.button-primary,
.button-secondary,
.button-danger {
    width: fit-content;
    padding: 10px 16px;
}

.cut-submit {
    min-width: 190px;
}

.form-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.reset-interval {
    width: 48px;
    padding-inline: 0;
}

.button-primary {
    color: #071018;
    border: 1px solid rgba(120, 97, 216, 0.3);
    background: linear-gradient(135deg, var(--coral), var(--violet));
    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(217, 111, 87, 0.08);
}

.button-secondary,
.icon-button {
    color: #06111a;
    border: 1px solid rgba(217, 111, 87, 0.34);
    background: linear-gradient(135deg, rgba(217, 111, 87, 0.84), rgba(217, 111, 87, 0.68));
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.24),
        0 4px 0 rgba(0, 0, 0, 0.34);
}

.button-danger {
    color: #fff7f8;
    border: 1px solid rgba(233, 101, 120, 0.46);
    background: linear-gradient(135deg, rgba(178, 47, 68, 0.92), rgba(116, 31, 51, 0.9));
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 4px 0 rgba(0, 0, 0, 0.36);
}

.button-danger--soft {
    min-width: 128px;
}

.icon-button {
    width: 44px;
    padding: 0;
}

.icon-button--danger {
    color: #fff7f8;
    border-color: rgba(233, 101, 120, 0.46);
    background: linear-gradient(135deg, rgba(178, 47, 68, 0.92), rgba(116, 31, 51, 0.9));
}

.add-interval:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.button-primary:active,
.button-secondary:active,
.button-danger:active,
.icon-button:active,
.download-link:active {
    transform: scaleY(0.92);
    transform-origin: bottom;
}

.download-grid {
    display: grid;
    gap: 12px;
    max-width: 100%;
    min-width: 0;
}

.download-item {
    min-width: 0;
    max-width: 100%;
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    align-items: end;
    gap: 10px 14px;
    border: 1px solid rgba(217, 111, 87, 0.17);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.18);
}

.download-label {
    min-width: 0;
    width: 100%;
    grid-column: 1 / -1;
    justify-self: start;
    padding: 8px 10px;
    color: #071018;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--coral), rgba(120, 97, 216, 0.86));
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

.download-label--selected {
    background: linear-gradient(135deg, #df826b, #8b77de);
}

.download-label--remaining {
    background: linear-gradient(135deg, #7861d8, #df967d);
}

.download-preview {
    width: 100%;
    max-height: 280px;
    grid-column: 1 / -1;
    border: 1px solid rgba(217, 111, 87, 0.17);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.36);
}

@-moz-document url-prefix() {
    .download-item--audio {
        row-gap: 0;
    }

    .download-item--audio .download-name-block,
    .download-item--audio .download-size,
    .download-item--audio .download-link {
        margin-top: 10px;
    }

    .download-item--audio .download-preview {
        display: block;
        height: 42px;
        margin-top: 0;
        max-height: 42px;
    }
}

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

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

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

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

.download-process-time {
    color: var(--violet);
    font-family: "Cascadia Mono", "Segoe UI", monospace;
    font-size: 0.82rem;
    font-weight: 800;
}

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

.download-link {
    max-width: 100%;
    padding: 9px 14px;
    color: #071018;
    border: 1px solid rgba(120, 97, 216, 0.3);
    background: linear-gradient(135deg, var(--coral), var(--violet));
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.3),
        0 5px 0 rgba(0, 0, 0, 0.34),
        0 0 10px rgba(217, 111, 87, 0.09);
    transition: filter 140ms ease, box-shadow 140ms ease, transform 80ms ease;
}

.download-link:hover {
    filter: brightness(1.05);
}

.download-link:active {
    box-shadow:
        inset 0 3px 0 rgba(0, 0, 0, 0.28),
        0 1px 0 rgba(0, 0, 0, 0.34),
        0 0 8px rgba(217, 111, 87, 0.08);
}

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

details {
    max-width: 100%;
    min-width: 0;
}

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

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

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

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

.privacy-note {
    padding: 10px 12px;
    border-left: 3px solid var(--coral);
    background: rgba(120, 97, 216, 0.035);
    border-radius: 6px;
}

.noscript-alert {
    width: min(1080px, calc(100% - 32px));
    margin: 16px auto 0;
    padding: 12px 14px;
    color: #ffe1e8;
    border: 1px solid rgba(233, 101, 120, 0.34);
    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(217, 111, 87, 0.34);
    border-radius: var(--radius);
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.58), 0 0 16px rgba(217, 111, 87, 0.08);
}

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

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

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

.confirm-dialog h2 {
    color: var(--danger);
    font-size: 1rem;
    text-transform: uppercase;
}

.confirm-dialog__close {
    width: 32px;
    height: 32px;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.88);
    border-radius: 6px;
    background: #9f1831;
    cursor: pointer;
}

.confirm-dialog__actions {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.confirm-dialog__actions .button-secondary,
.confirm-dialog__actions .button-danger {
    min-width: 104px;
    padding: 8px 12px;
}

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

.loading-timer {
    padding: 5px 9px;
    color: var(--coral);
    border: 1px solid rgba(217, 111, 87, 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: 4px;
}

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

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

@keyframes alert-border-pulse {
    0%,
    100% {
        border-color: rgba(233, 101, 120, 0.34);
        box-shadow:
            inset 0 0 0 1px rgba(255, 255, 255, 0.035),
            0 0 0 1px rgba(120, 97, 216, 0.08),
            0 14px 34px var(--shadow),
            0 0 18px rgba(217, 111, 87, 0.08);
    }

    45% {
        border-color: rgba(233, 101, 120, 0.78);
        box-shadow:
            inset 0 0 0 1px rgba(233, 101, 120, 0.22),
            0 0 0 1px rgba(233, 101, 120, 0.18),
            0 14px 34px var(--shadow),
            0 0 20px rgba(233, 101, 120, 0.18);
    }
}

@media (max-width: 760px) {
    .cutter-shell {
        width: calc(100% - 20px);
    }

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

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

    .interval-row__title {
        grid-column: 1 / -1;
    }

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

    .download-error {
        grid-column: 1 / -1;
    }

    .button-primary,
    .button-secondary,
    .button-danger {
        width: 100%;
    }

    .cut-submit {
        width: min(100%, 240px);
    }

    body {
        padding-bottom: 0;
    }
}

@media (min-width: 426px) and (max-width: 768px) {
    .file-row {
        grid-template-columns: minmax(0, 1fr) minmax(180px, 220px) auto;
    }

    .limit-strip {
        justify-content: center;
        flex-wrap: nowrap;
        gap: 10px 14px;
        text-align: center;
        font-size: 0.82rem;
    }

    .limit-strip span {
        flex: 0 0 auto;
        white-space: nowrap;
    }

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

    .download-label,
    .download-name-block,
    .download-error {
        grid-column: 1 / -1;
    }

    .download-size {
        grid-column: 1;
        justify-self: start;
        align-self: end;
    }

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

@media (max-width: 425px) {
    .support-note,
    .support-note p,
    .support-note__link {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .support-note,
    .support-note p,
    .support-note__link {
        overflow-wrap: anywhere;
    }

        .header-tagline.is-typing {
        min-width: 0 !important;
    }

    .cutter-shell {
        width: calc(100% - 16px);
    }

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

    .limit-strip span {
        flex: 1 1 100%;
    }

    .cutter-panel,
    .info-panel,
    .notice--result {
        padding: 14px;
    }

    .interval-panel {
        gap: 14px;
    }

    .interval-panel__header {
        justify-content: space-between;
        text-align: center;
    }

    .interval-row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .interval-row__title {
        grid-column: 1;
        text-align: left;
    }

    .interval-row .time-group {
        grid-column: 1 / -1;
    }

    .remove-interval {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .hint {
        text-align: center;
    }

    .form-actions {
        justify-content: center;
        gap: 10px;
    }

    .reset-interval {
        flex: 0 0 46px;
        width: 46px;
    }

    .cut-submit {
        flex: 0 1 190px;
        min-width: 0;
        width: 190px;
    }

    .confirm-dialog__content {
        padding: 18px;
    }

    .confirm-dialog__actions {
        gap: 8px;
    }

    .confirm-dialog__actions .button-secondary,
    .confirm-dialog__actions .button-danger {
        width: auto;
        min-width: 82px;
        min-height: 38px;
        padding: 7px 9px;
        font-size: 0.78rem;
    }

    .download-item:nth-of-type(1) {
        background: rgba(217, 111, 87, 0.055);
    }

    .download-item:nth-of-type(2) {
        background: rgba(217, 111, 87, 0.055);
    }

    .download-item,
    .download-name-block,
    .download-name-field,
    .download-name-field input,
    .time-group,
    .time-group .field,
    input[type="file"],
    input[type="number"],
    .download-link {
        min-width: 0;
    }
}

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