:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #111827;
    --muted: #667085;
    --line: #d9e0ea;
    --accent: #0f766e;
    --accent-2: #2563eb;
    --accent-soft: #e6f7f4;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% 0%, rgba(15, 118, 110, 0.12), transparent 28rem),
        linear-gradient(145deg, #ffffff 0%, #f5f7fb 58%, #eef3f8 100%);
    color: var(--text);
}

img,
svg,
video {
    max-width: 100%;
}

.page-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.app-header {
    display: flex;
    align-items: center;
    margin-bottom: 46px;
}

.brand {
    display: inline-flex;
    color: inherit;
    text-decoration: none;
}

.brand-logo {
    width: 190px;
    height: 62px;
    object-fit: contain;
    object-position: left center;
    filter: drop-shadow(0 10px 22px rgba(17, 24, 39, 0.08));
}

.upload-layout,
.result-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1fr);
    gap: 42px;
    align-items: start;
}

.intro,
.result-copy {
    padding-top: 34px;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

h1 {
    margin: 0;
    max-width: 620px;
    font-size: clamp(2.5rem, 5vw, 4.7rem);
    line-height: 0.98;
    letter-spacing: 0;
}

p {
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

.upload-panel {
    display: grid;
    gap: 18px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 22px 70px rgba(17, 24, 39, 0.12);
}

.drop-zone {
    display: grid;
    place-items: center;
    gap: 10px;
    min-height: 220px;
    padding: 26px;
    border: 1px dashed #aeb9c8;
    border-radius: 8px;
    background: var(--panel-soft);
    cursor: pointer;
    text-align: center;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.drop-zone input {
    width: 100%;
    max-width: 300px;
    color: var(--muted);
}

.drop-zone input::file-selector-button {
    margin-right: 12px;
    border: 0;
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--text);
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
}

.drop-icon {
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #ffffff;
    font-size: 2rem;
    font-weight: 900;
}

.mode-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0;
    padding: 0;
    border: 0;
}

.mode-group legend {
    grid-column: 1 / -1;
    font-weight: 900;
}

.mode-group label {
    display: flex;
    gap: 11px;
    min-height: 92px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    cursor: pointer;
}

.mode-group label:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.mode-group input {
    margin-top: 3px;
    accent-color: var(--accent);
}

.mode-group strong,
.mode-group small {
    display: block;
}

.mode-group small {
    margin-top: 4px;
    color: var(--muted);
}

.primary-button,
.secondary-button {
    display: inline-flex;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border-radius: 8px;
    font-weight: 900;
    text-decoration: none;
}

.primary-button {
    border: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #ffffff;
    cursor: pointer;
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.75;
}

.secondary-button {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
}

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

.progress-panel[hidden] {
    display: none;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.92rem;
}

.progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7edf5;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 220ms ease;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.preview {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 22px 70px rgba(17, 24, 39, 0.12);
}

.preview img {
    display: block;
    width: 100%;
    height: auto;
}

.flash-list {
    margin: -22px 0 24px;
}

.flash {
    margin: 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #ffd2cc;
}

.site-footer {
    display: flex;
    gap: 18px;
    margin-top: 46px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.site-footer a,
.legal-card a {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.site-footer a:hover,
.legal-card a:hover {
    text-decoration: underline;
}

.legal-page {
    max-width: 820px;
}

.legal-page h1 {
    font-size: clamp(2.2rem, 4vw, 3.6rem);
}

.legal-card {
    margin-top: 28px;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 22px 70px rgba(17, 24, 39, 0.1);
}

.legal-card h2 {
    margin: 26px 0 8px;
    font-size: 1.08rem;
}

.legal-card h2:first-child {
    margin-top: 0;
}

.legal-card p {
    margin: 0 0 12px;
}

@media (max-width: 820px) {
    .page-shell {
        width: min(100% - 24px, 1080px);
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        padding: 24px 0 34px;
    }

    .app-header {
        justify-content: center;
        margin-bottom: 34px;
    }

    .brand-logo {
        width: min(220px, 76vw);
        height: 70px;
        object-position: center;
    }

    .upload-layout,
    .result-layout {
        grid-template-columns: 1fr;
        gap: 28px;
        flex: 1;
        align-content: center;
    }

    .intro,
    .result-copy {
        padding-top: 0;
        text-align: center;
    }

    .eyebrow {
        margin-bottom: 12px;
        font-size: 0.72rem;
    }

    h1 {
        max-width: none;
        font-size: clamp(2.25rem, 11vw, 3.25rem);
        line-height: 1.03;
    }

    p {
        font-size: 1rem;
    }

    .upload-panel {
        gap: 18px;
        padding: 18px;
        box-shadow: 0 18px 44px rgba(17, 24, 39, 0.11);
    }

    .drop-zone {
        min-height: 230px;
        padding: 26px 16px;
    }

    .drop-icon {
        width: 58px;
        height: 58px;
        font-size: 2rem;
    }

    .drop-zone input {
        max-width: 100%;
        font-size: 0.9rem;
    }

    .mode-group {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .mode-group label {
        min-height: 82px;
        padding: 15px;
    }

    .primary-button,
    .secondary-button {
        width: 100%;
        min-height: 52px;
    }

    .actions {
        display: grid;
        gap: 10px;
        margin-top: 20px;
    }

    .preview {
        order: -1;
        box-shadow: 0 14px 36px rgba(17, 24, 39, 0.1);
    }

    .result-layout .preview {
        order: 0;
    }

    .progress-meta {
        font-size: 0.88rem;
    }

    .site-footer {
        justify-content: center;
        margin-top: 38px;
        padding-top: 18px;
    }

    .legal-card {
        margin-top: 18px;
        padding: 18px;
        box-shadow: 0 14px 36px rgba(17, 24, 39, 0.1);
    }

    .legal-card h2 {
        margin-top: 22px;
    }
}

@media (max-width: 420px) {
    .page-shell {
        width: min(100% - 18px, 1080px);
        padding-top: 20px;
    }

    .upload-panel {
        padding: 16px;
    }

    .drop-zone {
        min-height: 210px;
    }

    .drop-zone input::file-selector-button {
        display: block;
        width: 100%;
        margin: 0 0 10px;
    }

    .mode-group label {
        align-items: flex-start;
    }

    .mode-group small {
        font-size: 0.86rem;
    }
}

@media (min-width: 520px) and (max-width: 820px) {
    .mode-group {
        grid-template-columns: 1fr 1fr;
    }
}
