@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;800;900&display=swap");

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Roboto, Arial, sans-serif;
    color: #172033;
    background:
            radial-gradient(circle at 50% 0%, rgba(52, 211, 153, 0.12), transparent 28%),
            radial-gradient(circle at 86% 10%, rgba(76, 143, 255, 0.22), transparent 34%),
            #f7faff;
}

body.is-editor-open {
    overflow: hidden;
}

button,
select,
input {
    font-family: inherit;
}

.page {
    max-width: 980px;
    margin: 0 auto 0;
    padding: 40px 28px 44px;
}

.hero {
    text-align: center;
    margin-bottom: 30px;
}

.hero h1 {
    margin: 0;
    font-size: 54px;
    line-height: 1;
    letter-spacing: -2px;
    font-weight: 900;
    color: transparent;
    background: linear-gradient(90deg, #172033 0%, #172033 45%, #4d8fff 62%, #31d29c 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.hero p {
    margin: 14px 0 0;
    color: #7a889c;
    font-size: 17px;
    font-weight: 400;
}

.card {
    padding: 30px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(220, 228, 239, 0.95);
    box-shadow: 0 18px 46px rgba(22, 34, 56, 0.06);
}

.top-panel {
    display: grid;
    grid-template-columns: 1.55fr 0.65fr 0.9fr;
    gap: 28px;
    align-items: stretch;
}

.upload-zone {
    min-height: 112px;
    border: 1.5px dashed #d4dfec;
    border-radius: 12px;
    background: rgba(250, 252, 255, 0.78);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    transition: 0.18s;
}

.upload-zone:hover {
    border-color: #9bbcff;
    background: #ffffff;
}

.upload-zone input {
    display: none;
}

.upload-icon {
    color: #4d8fff;
    font-size: 25px;
    line-height: 1;
}

.upload-zone strong {
    color: #172033;
    font-size: 15px;
    font-weight: 800;
}

.upload-zone small {
    color: #7a889c;
    font-size: 14px;
    font-weight: 400;
}

.upload-zone em {
    color: #9aa7b8;
    font-size: 13px;
    font-style: normal;
    font-weight: 400;
}

.stats-card {
    min-height: 112px;
    padding: 18px;
    border: 1px solid #dce5ef;P0+r4B31\P0+r4B33\P0+r4B34\P0+r4B35\P0+r6B42\P0+r5053\P0+r5045\
    border-radius: 12px;
    background: rgba(250, 252, 255, 0.78);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stats-card span {
    color: #7a889c;
    font-size: 13px;
    font-weight: 500;
}

.stats-card strong {
    margin-top: 8px;
    color: #172033;
    font-size: 32px;
    line-height: 1;
    font-weight: 900;
}

.process-box {
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.primary {
    width: 100%;
    height: 56px;
    border: none;
    border-radius: 10px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(90deg, #4b82f5, #2dcc98);
    box-shadow: 0 10px 22px rgba(52, 145, 217, 0.12);
    transition: 0.18s;
}

.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(52, 145, 217, 0.16);
}

.primary:disabled {
    cursor: default;
    opacity: 0.75;
    transform: none;
}

.process-box span {
    color: #8b98aa;
    font-size: 13px;
    font-weight: 400;
    text-align: center;
}

.files-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.files-grid:empty {
    display: none;
}

.file-card {
    position: relative;
    min-height: 156px;
    padding: 10px;
    border: 1px solid #dce5ef;
    border-radius: 12px;
    background: rgba(250, 252, 255, 0.88);
    overflow: hidden;
    cursor: grab;
    transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.file-card:hover {
    transform: translateY(-1px);
    border-color: #b9c9dc;
}

.file-card.sortable-chosen {
    cursor: grabbing;
}

.file-card.sortable-ghost {
    opacity: 0.35;
    border-style: dashed;
    background: #eef6ff;
}

.file-card.sortable-drag {
    box-shadow: 0 18px 42px rgba(22, 34, 56, 0.18);
}

.file-remove {
    position: absolute;
    top: 7px;
    right: 9px;
    border: none;
    background: transparent;
    color: #34445c;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.file-preview {
    width: 78px;
    height: 92px;
    margin: 0 auto 9px;
    border-radius: 6px;
    background: #ffffff;
    box-shadow: 0 8px 15px rgba(22, 34, 56, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-placeholder {
    color: #c8d2df;
    font-size: 20px;
    font-weight: 800;
}

.file-name {
    color: #34445c;
    font-size: 12px;
    line-height: 1.15;
    font-weight: 700;
    word-break: break-word;
}

.file-meta {
    margin-top: 4px;
    color: #8b98aa;
    font-size: 12px;
    font-weight: 400;
}

.result-head {
    margin-top: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.result-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #172033;
    font-size: 16px;
}

.result-title strong {
    font-weight: 850;
}

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.result-actions.is-hidden {
    display: none;
}

.result-actions button {
    height: 38px;
    padding: 0 14px;
    border: 1px solid #dce5ef;
    border-radius: 8px;
    background: #ffffff;
    color: #172033;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(22, 34, 56, 0.035);
}

.result-actions button:hover {
    background: #f8fafc;
}

#reset {
    color: #ef4444;
}

.status-icon {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 2px solid #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-icon.loading {
    border-color: #4d8fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.status-icon.success {
    border-color: #2dcc98;
    background: #2dcc98;
}

.status-icon.success::after {
    content: "✓";
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
}

.status-icon.error {
    border-color: #ef4444;
    background: #ef4444;
}

.status-icon.error::after {
    content: "!";
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
}

.result-output {
    width: 100%;
    height: 360px;
    margin-top: 14px;
    padding: 24px 30px;
    border: 1px solid #dce5ef;
    border-radius: 10px;
    overflow: auto;
    outline: none;
    color: #172033;
    background: rgba(250, 252, 255, 0.9);
    font-size: 16px;
    line-height: 1.7;
    font-family: Roboto, Arial, sans-serif;
}

.result-output .placeholder {
    color: #8b98aa;
}

.result-output h2 {
    margin: 0 0 14px;
    font-size: 22px;
    line-height: 1.35;
    font-weight: 800;
}

.result-output h3 {
    margin: 22px 0 10px;
    font-size: 18px;
    line-height: 1.35;
    font-weight: 800;
}

.result-output p {
    margin: 0 0 14px;
}

.result-output ul {
    margin: 0 0 16px 24px;
    padding: 0;
}

.result-output li {
    margin-bottom: 6px;
}

.result-output .file-separator {
    margin: 26px 0;
    border: none;
    border-top: 1px solid #e1e8f1;
}

.preview-modal {
    position: fixed;
    inset: 0;
    padding: 40px;
    background: rgba(15, 23, 42, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.preview-modal.open {
    display: flex;
}

.preview-modal img {
    max-width: min(100%, 1100px);
    max-height: 88vh;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.preview-close {
    position: fixed;
    top: 22px;
    right: 28px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.editor-modal {
    position: fixed;
    inset: 0;
    padding: 40px;
    background: rgba(15, 23, 42, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 30;
}

.editor-modal.open {
    display: flex;
}

.editor-window {
    width: min(100%, 980px);
    max-height: 90vh;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-head {
    height: 58px;
    padding: 0 20px;
    border-bottom: 1px solid #e1e8f1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-head strong {
    font-size: 18px;
    font-weight: 800;
}

#editor-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #f3f6fb;
    color: #172033;
    font-size: 24px;
    cursor: pointer;
}

.editor-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid #e1e8f1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    background: #f8fbff;
}

.editor-toolbar button,
.editor-toolbar select {
    height: 36px;
    padding: 0 12px;
    border: 1px solid #dce5ef;
    border-radius: 8px;
    background: #ffffff;
    color: #172033;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.editor-toolbar button.active {
    background: #172033;
    color: #ffffff;
    border-color: #172033;
}

.editor-area {
    min-height: 460px;
    padding: 34px 40px;
    overflow: auto;
    outline: none;
    font-family: Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: #172033;
}

.editor-area h2 {
    margin: 0 0 14px;
    font-size: 22px;
    line-height: 1.35;
    font-weight: 800;
}

.editor-area h3 {
    margin: 22px 0 10px;
    font-size: 18px;
    line-height: 1.35;
    font-weight: 800;
}

.editor-area p {
    margin: 0 0 14px;
}

.editor-area ul {
    margin: 0 0 16px 24px;
    padding: 0;
}

.editor-area li {
    margin-bottom: 6px;
}

.editor-actions {
    padding: 14px 20px;
    border-top: 1px solid #e1e8f1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fbff;
}

.editor-actions button {
    height: 40px;
    padding: 0 18px;
    border-radius: 9px;
    border: 1px solid #dce5ef;
    background: #ffffff;
    color: #172033;
    font-weight: 800;
    cursor: pointer;
}

#editor-save {
    color: #ffffff;
    border-color: transparent;
    background: linear-gradient(90deg, #4b82f5, #2dcc98);
}

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

@media (max-width: 900px) {
    .page {
        margin-top: 34px;
        padding: 0 18px 32px;
    }

    .hero h1 {
        font-size: 40px;
        letter-spacing: -1px;
    }

    .hero p {
        font-size: 15px;
    }

    .card {
        padding: 20px;
    }

    .top-panel {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .files-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .result-actions {
        justify-content: flex-start;
    }

    .editor-modal {
        padding: 16px;
    }

    .editor-area {
        padding: 24px;
    }
}
