:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #1a1a1a;
    color: #fff;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    color: #fff;
}

.main-content {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 32px 20px;
}

/* Главная страница */
.hero {
    width: 100%;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
}

.hero h1 {
    margin: 0 0 15px;
    font-size: clamp(32px, 6vw, 56px);
    font-weight: 700;
    letter-spacing: -1px;
    background: linear-gradient(90deg, #fff, #aaa);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.hero p {
    max-width: 500px;
    margin: 0 0 40px;
    color: #aaa;
    font-size: clamp(16px, 2.5vw, 20px);
    line-height: 1.5;
}

.btn-start, .btn-solid {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 0;
    border-radius: 8px;
    background: #0d6efd;
    color: #fff;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.btn-start {
    gap: 8px;
    padding: 14px 32px;
    font-size: 18px;
    box-shadow: 0 4px 15px rgba(13, 110, 253, .2);
}

.btn-solid {
    width: 100%;
    min-height: 48px;
    margin-top: 8px;
    padding: 12px 18px;
    font-size: 16px;
}

.btn-start:hover, .btn-solid:hover {
    background: #0b5ed7;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, .4);
}

.btn-start:focus-visible, .btn-solid:focus-visible, .back-link:focus-visible,
.file-picker:focus-within {
    outline: 3px solid #8bbcff;
    outline-offset: 3px;
}

/* Страница загрузки */
.page-header {
    width: 100%;
    padding: 20px clamp(20px, 5vw, 40px) 0;
}

.back-link {
    color: #aaa;
    font-size: 16px;
    text-decoration: none;
}

.back-link:hover { color: #fff; }

.upload-page {
    width: 100%;
    max-width: 520px;
    text-align: center;
}

.upload-page h1 {
    margin: 0 0 12px;
    font-size: clamp(25px, 4vw, 32px);
}

.page-description {
    margin: 0 0 28px;
    color: #aaa;
    line-height: 1.5;
}

.upload-form {
    padding: clamp(20px, 5vw, 30px);
    border: 1px solid #444;
    border-radius: 12px;
    background: #222;
}

.file-picker-wrap { margin-bottom: 20px; }

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.file-picker {
    min-height: 54px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border: 1px dashed #666;
    border-radius: 8px;
    background: #303030;
    color: #fff;
    cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease;
}

.file-picker:hover { border-color: #0d6efd; background: #353535; }
.file-picker-icon { color: #69a5ff; font-size: 24px; line-height: 1; }
.file-input:focus-visible + .file-picker { outline: 3px solid #8bbcff; outline-offset: 3px; }
.file-help, .selected-file { margin: 10px 0 0; color: #999; font-size: 13px; }
.selected-file { color: #ddd; overflow-wrap: anywhere; }

.image-previews {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

#upload-form.is-dragging {
    outline: 3px dashed #69a5ff;
    outline-offset: 4px;
    box-shadow: 0 0 24px rgba(105, 165, 255, .25);
}
.clear-photos {
    margin: 0 0 16px;
    padding: 10px 16px;
    border: 1px solid #777;
    border-radius: 8px;
    background: #333;
    color: #fff;
    font: inherit;
    cursor: pointer;
}
.clear-photos:hover { background: #494949; }
.clear-photos:focus-visible { outline: 3px solid #8bbcff; outline-offset: 3px; }

.image-previews figure { margin: 0; min-width: 0; }
.preview-media { position: relative; }
.preview-toggle {
    display: block;
    width: 100%;
    min-height: 140px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #181818;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.preview-toggle[aria-expanded="true"] { outline: 2px solid #69a5ff; }
.preview-toggle:focus-visible { outline: 3px solid #8bbcff; outline-offset: 3px; }
.remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #b97474;
    border-radius: 50%;
    background: #402626;
    color: #fff;
    font: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.remove-photo:hover { background: #633434; }
.remove-photo:focus-visible { outline: 3px solid #8bbcff; outline-offset: 3px; }
.image-previews img {
    display: block;
    width: 100%;
    height: 140px;
    object-fit: contain;
    background: #181818;
    border-radius: 8px;
}
.image-previews figcaption {
    margin-top: 6px;
    font-size: 13px;
    overflow-wrap: anywhere;
}
.result-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

.result-message {
    margin-top: 24px;
    padding: 18px 20px;
    border: 1px solid;
    border-radius: 8px;
}

.result-message h2 { margin: 0; color: #fff; font-size: 18px; line-height: 1.45; }
.result-success { border-color: #2e7d4e; background: #1b4d2e; }
.result-error { border-color: #7d2e2e; background: #4d1b1b; }
.result-info { border-color: #41658b; background: #20364d; }

@media (max-width: 600px) {
    .main-content { padding: 24px 16px; }
    .hero { min-height: 60vh; padding-inline: 8px; }
    .btn-start { width: 100%; max-width: 320px; }
    .page-header { padding: 16px 20px 0; }
    .upload-form { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
