:root {
    --bg: #26292f;
    --bg-deep: #1d2025;
    --shell: #32363d;
    --shell-2: #3a3f47;
    --panel: #f3f3f5;
    --panel-2: #ffffff;
    --text: #1b1d22;
    --muted: #60656f;
    --accent: #ec5b2a;
    --accent-dark: #c5471e;
    --accent-soft: rgba(236, 91, 42, 0.14);
    --line: #cfd2d8;
    --line-dark: rgba(255,255,255,0.12);
    --header-text: #f7f7f8;
    --success: #0e8f63;
    --danger: #c63b32;
    --shadow: 0 22px 48px rgba(0,0,0,0.28);
    --shadow-soft: 0 12px 28px rgba(0,0,0,0.16);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --control-h: 48px;
    --focus: 0 0 0 4px rgba(236, 91, 42, 0.18);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #2b2f35 0%, #23262c 100%);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { border: 0; }

.page-wrap {
    min-height: 100vh;
    padding: 18px;
}

.app-shell {
    max-width: 1180px;
    margin: 0 auto;
}

.app-header {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    align-items: center;
    gap: 14px;
    background: linear-gradient(180deg, #3b4048, #30343b);
    border: 1px solid var(--line-dark);
    border-radius: var(--radius-xl);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.header-home,
.lang-btn,
.close-btn,
.footer-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.header-home {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(180deg, #4a5059, #3c4149);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.header-home span {
    font-size: 22px;
    line-height: 1;
}

.header-title-wrap { min-width: 0; }
.app-kicker {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #c5c9d1;
    margin-bottom: 4px;
}

.app-header h1 {
    margin: 0;
    color: var(--header-text);
    font-size: clamp(1.45rem, 1.2vw + 1rem, 2rem);
    line-height: 1.05;
    font-weight: 800;
}

.header-actions { display: flex; align-items: center; gap: 10px; }
.lang-switch {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 8px;
    align-items: center;
    min-height: 50px;
    padding: 6px;
    background: rgba(0,0,0,0.18);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.lang-btn {
    min-width: 54px;
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    background: transparent;
    color: #d9dde4;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    opacity: 1;
    transition: background 0.16s ease, color 0.16s ease, transform 0.14s ease, filter 0.14s ease;
}

.lang-btn.is-active {
    background: linear-gradient(180deg, #545b65, #434952);
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.hero-strip {
    margin-bottom: 14px;
    background: linear-gradient(180deg, #3b4048, #343942);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 15px 18px;
    color: #eef1f5;
    box-shadow: var(--shadow-soft);
}
.hero-strip strong { display: block; margin-bottom: 5px; }
.hero-strip p { margin: 0; color: #cfd4dd; }

.tool-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
    width: 100%;
}

.tool-tab {
    width: 100%;
    min-height: 64px;
    padding: 0 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, #464b53, #3a3f47);
    color: #f1f3f6;
    border: 1px solid rgba(255,255,255,0.08);
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease, background 0.16s ease;
}
.tool-tab:hover { filter: brightness(1.06); transform: translateY(-1px); }

.tool-tab.is-active {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
}

.tool-card,
.result-card {
    background: linear-gradient(180deg, #ececef, #e4e6ea);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: var(--shadow);
}

.tool-card { padding: 18px; }
.tool-panel { display: none; }
.tool-panel.is-active { display: block; }

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.panel-head h2 {
    margin: 0 0 4px;
    font-size: 1.25rem;
    color: #1b1e24;
}

.panel-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
    max-width: 68ch;
}

.panel-badge {
    white-space: nowrap;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0 14px;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(0,0,0,0.10);
    color: #343841;
    font-size: 0.8rem;
    font-weight: 800;
}

.tool-form { display: flex; flex-direction: column; gap: 16px; }
.dropzone,
.list-card,
.progress-stack {
    background: rgba(255,255,255,0.72);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 14px;
}

.dropzone { display: grid; gap: 8px; }
.dropzone.is-dragover { box-shadow: var(--focus); border-color: rgba(236, 91, 42, 0.45); }
.dropzone-label,
.list-head strong,
.field > span { font-weight: 800; color: #252932; }
.dropzone small,
.list-head small,
.status-text,
.file-meta,
.range-value { color: var(--muted); }


.file-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--control-h);
    border-radius: 12px;
    border: 1px solid #bcc1ca;
    background: linear-gradient(180deg, #fff, #f4f5f7);
    padding: 8px 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.native-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.file-picker-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid #b8bec8;
    background: linear-gradient(180deg, #fefefe, #e6e9ee);
    color: #1d2128;
    font-weight: 700;
    cursor: pointer;
    flex: 0 0 auto;
}

.file-picker-summary {
    min-width: 0;
    color: #4d5460;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


.field input[type="text"],
.field input[type="number"],
.field select {
    width: 100%;
    min-height: var(--control-h);
    border-radius: 12px;
    border: 1px solid #bcc1ca;
    background: linear-gradient(180deg, #fff, #f4f5f7);
    color: #1d2128;
    padding: 0.7rem 0.9rem;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.field input:focus,
.field select:focus,
button:focus,
.file-picker-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}


.options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.compact-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.images-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field select {
    appearance: none;
    background-image: linear-gradient(180deg, rgba(255,255,255,0), rgba(0,0,0,0.02)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5' fill='none' stroke='%23555b66' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-position: 0 0, right 12px center;
    background-size: auto, 18px 18px;
    padding-right: 42px;
}

.checkbox-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-height: 56px;
    border-radius: 12px;
    border: 1px solid #bcc1ca;
    background: linear-gradient(180deg, #fff, #f3f4f7);
    padding: 0.65rem 0.9rem;
}
.checkbox-field input {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    flex: 0 0 auto;
}
.checkbox-field span {
    line-height: 1.35;
}

.preset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.pill-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid #c0c4cb;
    background: linear-gradient(180deg, #fff, #eceef2);
    color: #2a2e36;
    cursor: pointer;
    font-weight: 700;
}
.pill-option input { accent-color: var(--accent); }
.pill-option:has(input:checked) {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: #fff;
    border-color: transparent;
}

.list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.file-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #c7ccd3;
    background: linear-gradient(180deg, #fff, #f5f6f8);
}
.file-item-image { grid-template-columns: 30px 74px minmax(0, 1fr) auto; }
.file-item.dragging { opacity: 0.5; }
.file-item.drag-over { box-shadow: var(--focus); }
.drag-handle {
    width: 30px; height: 30px; border-radius: 10px;
    background: linear-gradient(180deg, #fefefe, #e5e8ed);
    border: 1px solid #c3c7ce; color: #3c4149; cursor: grab;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
}
.file-preview {
    width: 74px; height: 74px; border-radius: 12px; overflow: hidden;
    background: #e3e6eb; border: 1px solid #c9ced6; display: flex; align-items: center; justify-content: center;
}
.file-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-info { min-width: 0; display: grid; gap: 4px; }
.file-topline { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.file-order {
    min-width: 34px; height: 28px; border-radius: 999px; background: var(--accent-soft);
    color: var(--accent-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem;
}
.file-name { flex: 1 1 auto; min-width: 0; font-weight: 800; word-break: break-word; line-height: 1.35; }
.file-meta { line-height: 1.4; word-break: break-word; }
.remove-btn,
.primary-btn,
.download-btn,
.ghost-btn,
.enter-btn {
    min-height: 46px;
    border-radius: 12px;
    padding: 0 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease;
}

.primary-btn,
.download-btn,
.enter-btn,
.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.remove-btn:hover,
.primary-btn:hover,
.download-btn:hover,
.ghost-btn:hover,
.enter-btn:hover,
.footer-link:hover,
.tool-tab:hover,
.lang-btn:hover,
.header-home:hover { transform: translateY(-1px); filter: brightness(1.03); }
.remove-btn {
    width: 42px; min-width: 42px; padding: 0; background: #eceef1; color: #30343b; border: 1px solid #c0c5cd; align-self: center;
}
.primary-btn,
.download-btn,
.enter-btn {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 10px 20px rgba(197, 71, 30, 0.22), inset 0 1px 0 rgba(255,255,255,0.18);
}

.download-btn {
    min-width: 132px;
    justify-self: end;
    align-self: center;
    padding: 0 22px;
    font-size: 1rem;
}
.ghost-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #ffffff, #eceff3);
    color: #242831; border: 1px solid #c4c9d1;
}
.form-actions {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
}
.status-text { font-weight: 700; }
.status-text.is-working { color: #7c5612; }
.status-text.is-error { color: var(--danger); }

.progress-stack { display: grid; gap: 12px; }
.progress-group { display: grid; gap: 8px; }
.progress-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.progress-bar {
    width: 100%; height: 10px; border-radius: 999px; overflow: hidden;
    background: #daddE3; border: 1px solid #c3c8d0;
}
.progress-bar span {
    display: block; width: 0; height: 100%;
    background: linear-gradient(90deg, var(--accent), #ff8a63);
}

.result-card {
    margin-top: 14px;
    padding: 18px;
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 14px;
    align-items: center;
}
.result-icon {
    width: 56px; height: 56px; border-radius: 16px;
    background: rgba(14, 143, 99, 0.12); color: var(--success);
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 900;
}
.result-copy h3 { margin: 0 0 4px; }
.result-copy { min-width: 0; }
.result-copy p { margin: 0; color: var(--muted); }
.download-btn[aria-disabled="true"] { pointer-events: none; opacity: 0.5; }

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 4px 2px;
    color: #adb3bc;
    font-size: 0.78rem;
}
.footer-right { display: flex; gap: 10px; align-items: center; }
.footer-link {
    background: transparent;
    color: #aeb4bd;
    padding: 0;
    min-height: 0;
    font-size: 0.72rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.modal-backdrop {
    position: fixed;
    visibility: hidden;
    inset: 0;
    background: rgba(15, 17, 21, 0.72);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 50;
}
.modal-backdrop.is-open { display: flex; visibility: visible; }
.modal-card {
    width: min(720px, 100%);
    max-height: min(90vh, 920px);
    overflow: auto;
    background: linear-gradient(180deg, #f4f4f6, #e7e9ed);
    border-radius: 22px;
    border: 1px solid rgba(0,0,0,0.12);
    box-shadow: 0 30px 70px rgba(0,0,0,0.35);
}
.modal-card-large { width: min(860px, 100%); }
.modal-topline {
    height: 6px;
    background: linear-gradient(90deg, var(--accent), #ff8a63, #ffc39f);
    border-radius: 22px 22px 0 0;
}
.modal-header {
    padding: 18px 20px 8px;
}
.modal-header-split {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.modal-kicker {
    color: var(--accent-dark); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px;
}
.modal-header h2 { margin: 0; }
.modal-body { padding: 0 20px 20px; }
.modal-actions {
    padding: 0 20px 20px;
    display: flex;
    justify-content: flex-end;
}
.close-btn {
    width: 40px; height: 40px; border-radius: 12px; background: #eceef2; color: #2c3038; border: 1px solid #c6cad1; font-size: 1.5rem;
}

.intro-body > p { margin-top: 0; color: var(--muted); line-height: 1.65; }
.intro-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.intro-box {
    border-radius: 16px;
    border: 1px solid #cdd2d9;
    background: rgba(255,255,255,0.7);
    padding: 16px;
}
.intro-box p { margin: 10px 0 14px; color: var(--muted); line-height: 1.6; }
.support-links { display: flex; flex-wrap: wrap; gap: 10px; }

.legal-section + .legal-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid #d3d7de; }
.legal-section h3 { margin: 0 0 12px; }
.legal-body p, .legal-body li, .legal-body strong { color: #474d58; line-height: 1.65; }
.legal-body ul { padding-left: 20px; margin: 10px 0; }
.legal-body a { color: var(--accent-dark); text-decoration: underline; }

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

@media (max-width: 820px) {
    .options-grid,
    .compact-grid,
    .images-grid,
    .intro-grid,
    .result-card {
        grid-template-columns: 1fr;
    }

    .result-card { display: grid; }
}

@media (max-width: 820px) {
    .tool-tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .tool-tab {
        width: auto;
        min-height: 44px;
        padding: 0 16px;
        border-radius: 12px;
        font-size: 1rem;
    }
}

@media (max-width: 680px) {
    .page-wrap { padding: 10px; }
    .app-header {
        grid-template-columns: 46px 1fr;
        grid-template-areas:
            "home lang"
            "title title";
        gap: 10px;
        padding: 12px;
    }
    .header-home { grid-area: home; width: 40px; height: 40px; }
    .header-actions { grid-area: lang; justify-content: flex-end; }
    .header-title-wrap { grid-area: title; }
    .hero-strip, .tool-card, .result-card { padding: 14px; }
    .panel-head { flex-direction: column; }
    .file-item { grid-template-columns: 30px 1fr auto; }
    .file-item-image { grid-template-columns: 30px 60px minmax(0, 1fr) auto; }
    .file-preview { width: 60px; height: 60px; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .primary-btn, .download-btn, .enter-btn, .ghost-btn { width: 100%; }
    .support-links { display: grid; grid-template-columns: 1fr; }
    .file-picker-row { flex-wrap: wrap; align-items: flex-start; }
    .file-picker-summary { white-space: normal; }
    .app-footer { flex-direction: column; align-items: flex-start; }
}
