:root {
    color-scheme: dark;
    --bg: #07080f;
    --panel: rgba(13, 16, 27, 0.96);
    --panel-soft: rgba(17, 23, 36, 0.9);
    --text: #f5f8fa;
    --muted: #a5b2bb;
    --red: #d95d6f;
    --cyan: #65bed0;
    --amber: #d6aa59;
    --danger: #d9465e;
    --success: #85d7b1;
    --shadow: rgba(0, 0, 0, 0.52);
    --radius: 8px;
    font-family: Inter, Roboto, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    padding-bottom: 78px;
    color: var(--text);
    background:
        linear-gradient(rgba(217, 93, 111, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(101, 190, 208, 0.016) 1px, transparent 1px),
        linear-gradient(135deg, rgba(217, 93, 111, 0.046), transparent 34%),
        linear-gradient(315deg, rgba(214, 170, 89, 0.03), transparent 38%),
        var(--bg);
    background-size: 34px 34px, 34px 34px, auto, auto, auto;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

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

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

a:hover {
    text-decoration: none;
}

.app-header {
    border-bottom: 1px solid rgba(217, 93, 111, 0.18);
    background: linear-gradient(90deg, rgba(217, 93, 111, 0.052), rgba(101, 190, 208, 0.034)), rgba(7, 8, 15, 0.94);
    box-shadow: 0 12px 28px var(--shadow);
}

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

.limit-strip,
.notice,
.pdf-panel,
.info-panel {
    border: 1px solid rgba(217, 93, 111, 0.18);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 0 12px rgba(217, 93, 111, 0.04), 0 12px 30px var(--shadow);
}

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

.limit-strip span {
    flex: 1 1 0;
}

.limit-strip strong {
    color: var(--cyan);
}

.limit-strip strong.is-turbo-limit,
.danger-inline {
    color: #ff8d9c;
    text-shadow: 0 0 8px rgba(217, 70, 94, 0.16);
}

.turbo-toggle {
    min-height: 38px;
    padding: 7px 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--amber);
    border: 1px solid rgba(214, 170, 89, 0.32);
    border-radius: 6px;
    background: rgba(214, 170, 89, 0.07);
    box-shadow:
        inset 0 -2px 0 rgba(0, 0, 0, 0.26),
        0 3px 0 rgba(0, 0, 0, 0.28);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.turbo-toggle[aria-pressed="true"] {
    color: #0d0d10;
    border-color: rgba(214, 170, 89, 0.5);
    background: linear-gradient(135deg, var(--amber), #f0cf7c);
}

.turbo-toggle:active {
    box-shadow:
        inset 0 4px 10px rgba(0, 0, 0, 0.32),
        0 1px 0 rgba(0, 0, 0, 0.28);
    transform: scaleY(0.94);
    transform-origin: bottom;
}

.noscript-alert {
    margin: 14px 0 0;
    padding: 11px 14px;
    color: #ffd8de;
    border: 1px solid rgba(217, 70, 94, 0.36);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    background: rgba(217, 70, 94, 0.11);
    box-shadow: 0 0 14px rgba(217, 70, 94, 0.08);
    font-weight: 800;
    text-align: center;
}

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

.notice[hidden] {
    display: none;
}

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

.notice--error {
    border-color: rgba(217, 93, 111, 0.32);
    color: #ffd5dc;
}

.notice--success {
    border-color: rgba(133, 215, 177, 0.36);
    color: #dffcf0;
}

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

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

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

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

.field-action-row > *,
.field-action-row .field,
.file-item > *,
.download-item > * {
    min-width: 0;
}

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

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

input[type="text"]:focus,
input[type="file"]:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(217, 93, 111, 0.1);
}

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

.file-usage {
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 18px;
    color: var(--muted);
    border: 1px solid rgba(101, 190, 208, 0.14);
    border-radius: 6px;
    background: rgba(101, 190, 208, 0.036);
}

.file-usage[hidden],
.file-list[hidden] {
    display: none;
}

.file-usage__metric {
    flex: 1 1 220px;
}

.file-usage__metric:last-child {
    text-align: right;
}

.file-usage__metric strong {
    color: var(--cyan);
    font-family: var(--font-data), "Cascadia Mono", "Segoe UI", monospace;
}

.file-usage__metric em {
    color: var(--muted);
    font-style: normal;
}

.file-usage__metric.is-near-limit strong {
    color: #b8860b;
}

.file-usage__metric.is-at-limit strong,
.file-usage__metric.is-at-limit em {
    color: var(--danger);
}

.file-list {
    padding: 12px;
    display: grid;
    gap: 10px;
    border: 1px solid rgba(101, 190, 208, 0.18);
    border-radius: var(--radius);
    background: rgba(0, 0, 0, 0.16);
}

.file-list.is-over-limit {
    max-height: 480px;
    overflow: auto;
    padding-right: 8px;
    border-top-color: rgba(214, 170, 89, 0.3);
    border-bottom-color: rgba(214, 170, 89, 0.3);
}

.file-item {
    padding: 10px 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(101, 190, 208, 0.14);
    border-radius: 6px;
    background: rgba(101, 190, 208, 0.036);
    cursor: grab;
    transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.file-item:active {
    cursor: grabbing;
}

.file-item.is-dragged {
    opacity: 0.55;
}

.file-item.is-drop-target {
    border-color: rgba(214, 170, 89, 0.48);
    background: rgba(214, 170, 89, 0.065);
}

.file-item.is-selected {
    border-color: rgba(101, 190, 208, 0.62);
    background:
        linear-gradient(135deg, rgba(101, 190, 208, 0.13), rgba(217, 93, 111, 0.07)),
        rgba(101, 190, 208, 0.08);
    box-shadow: inset 3px 0 0 var(--cyan);
}

.file-item strong {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    color: #080d16;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--red), var(--amber));
}

.file-item a {
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    text-decoration: none;
}

.file-item a:focus-visible {
    outline: 2px solid rgba(101, 190, 208, 0.5);
    outline-offset: 3px;
}

.file-item a:hover {
    text-decoration: underline;
}

.file-item small,
.hint,
.info-panel p {
    color: var(--muted);
}

.file-remove {
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    border: 1px solid rgba(217, 93, 111, 0.48);
    border-radius: 6px;
    background: rgba(217, 70, 94, 0.18);
    font-weight: 900;
    line-height: 1;
}

.file-remove[hidden] {
    display: none;
}

.file-remove:active {
    transform: translateY(1px);
}

.hint {
    margin: 0;
}

.button-primary,
.button-secondary,
.button-danger,
.download-link {
    width: fit-content;
    min-height: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #090e18;
    border: 1px solid rgba(214, 170, 89, 0.32);
    border-radius: 6px;
    background: linear-gradient(135deg, var(--red), var(--amber));
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.28),
        0 5px 0 rgba(0, 0, 0, 0.34),
        0 0 9px rgba(217, 93, 111, 0.08);
    font-weight: 900;
    text-transform: uppercase;
}

.button-secondary {
    color: var(--text);
    border-color: rgba(101, 190, 208, 0.24);
    background: rgba(101, 190, 208, 0.06);
}

.button-secondary:disabled {
    opacity: 0.44;
    cursor: not-allowed;
}

.button-reset {
    color: #fff;
    border-color: rgba(217, 93, 111, 0.62);
    background:
        linear-gradient(135deg, rgba(217, 70, 94, 0.86), rgba(137, 33, 48, 0.84));
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.3),
        0 5px 0 rgba(52, 8, 15, 0.62),
        0 0 9px rgba(217, 70, 94, 0.12);
}

.button-reset:disabled {
    color: rgba(255, 255, 255, 0.62);
    border-color: rgba(217, 93, 111, 0.3);
    background: rgba(95, 22, 34, 0.46);
    box-shadow:
        inset 0 -3px 0 rgba(0, 0, 0, 0.24),
        0 4px 0 rgba(30, 7, 12, 0.44);
}

.button-icon-only {
    width: 44px;
    min-width: 44px;
    padding: 10px;
}

.button-danger {
    color: #fff;
    border-color: rgba(217, 93, 111, 0.48);
    background: rgba(217, 70, 94, 0.3);
}

.button-primary:active,
.button-secondary:active,
.button-danger:active,
.download-link: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;
}

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

.download-file-name {
    min-width: 0;
    overflow-wrap: anywhere;
    color: var(--cyan);
    font-weight: 900;
}

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

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

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

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

.info-panel p {
    margin: 10px 0 0;
}

.privacy-note {
    padding: 10px 12px;
    color: #dff8ff;
    border: 1px solid rgba(101, 190, 208, 0.16);
    border-left: 3px solid var(--cyan);
    border-radius: 6px;
    background: rgba(101, 190, 208, 0.055);
}

.loading-dialog,
.confirm-dialog {
    width: min(420px, calc(100% - 32px));
    padding: 0;
    border: 1px solid rgba(217, 93, 111, 0.24);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--panel);
    box-shadow: 0 16px 46px rgba(0, 0, 0, 0.56);
}

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

.loading-dialog__content,
.confirm-dialog__content {
    padding: 24px;
    display: grid;
    gap: 12px;
}

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

.loading-dialog__content p {
    margin: 0;
    color: var(--muted);
}

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

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

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

.confirm-dialog p {
    color: var(--muted);
}

.confirm-dialog__close {
    width: 34px;
    height: 34px;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 6px;
    background: var(--danger);
    font-weight: 900;
}

.confirm-dialog__actions {
    justify-content: flex-end;
}

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

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

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

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

@keyframes notice-pulse {
    0%,
    100% {
        box-shadow: none;
    }

    18%,
    54% {
        border-color: rgba(214, 170, 89, 0.7);
        box-shadow: 0 0 0 2px rgba(214, 170, 89, 0.12);
    }

    36%,
    72% {
        border-color: rgba(101, 190, 208, 0.56);
        box-shadow: 0 0 0 2px rgba(101, 190, 208, 0.09);
    }
}

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

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

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

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

    .field-action-row--output .button-primary {
        width: min(190px, 34vw);
        min-width: 150px;
    }

    .field-action-row--files .button-secondary {
        width: 44px;
    }

    body {
        padding-bottom: 0;
    }
}

@media (max-width: 425px) {
    .turbo-toggle {
        display: none;
    }

    .file-usage {
        justify-content: flex-start;
        text-align: left;
    }

    .file-usage__metric,
    .file-usage__metric:last-child {
        flex-basis: 100%;
        text-align: left;
    }

    .field-action-row--output {
        grid-template-columns: 1fr;
    }

    .field-action-row--output .button-primary {
        width: min(240px, 100%);
        min-width: 0;
        justify-self: center;
    }

    .file-item {
        grid-template-columns: auto auto;
    }

    .file-item strong {
        grid-column: 1;
        grid-row: 1;
    }

    .file-item a,
    .file-item small {
        grid-column: 1 / -1;
    }

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

@media (min-width: 375px) and (max-width: 425px) {
    .file-usage {
        justify-content: center;
        text-align: center;
    }

    .file-usage__metric,
    .file-usage__metric:last-child {
        text-align: center;
    }
}
