:root {
    --bg: #f4f0f5;
    --panel: #fffdfd;
    --panel-soft: #f0e9f1;
    --line: #d9cddd;
    --text: #302a32;
    --muted: #746b77;
    --accent: #806784;
    --accent-dark: #604b64;
    --accent-soft: rgba(128, 103, 132, 0.11);
    --success: #55766b;
    --danger: #a44d58;
    --shadow: 0 22px 62px rgba(83, 63, 87, 0.13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; color-scheme: light; }

body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at 9% 0%, rgba(255, 255, 255, 0.96), transparent 30rem),
        linear-gradient(145deg, #fbf9fb 0%, var(--bg) 58%, #ebe3ed 100%);
    color: var(--text);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button, input, select { font: inherit; }
button, .button { cursor: pointer; }

.shell {
    width: min(900px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 30px;
}

.hero { margin: 8px 0 14px; }
.hero.compact { display: flex; align-items: end; justify-content: space-between; gap: 18px; }

h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(30px, 5vw, 48px);
    font-weight: 500;
    line-height: 1.05;
    letter-spacing: -0.025em;
}

.intro { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.back-link { color: var(--accent-dark); font-size: 13px; white-space: nowrap; }

.panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 253, 253, 0.95);
    box-shadow: var(--shadow);
    padding: clamp(14px, 2.5vw, 21px);
}

.drop-zone {
    display: grid;
    place-items: center;
    min-height: 124px;
    border: 1px dashed #ae9cb2;
    border-radius: 10px;
    background: linear-gradient(145deg, #f2ecf3, #fffdfd);
    padding: 16px;
    text-align: center;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.drop-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone strong { display: block; font-size: 16px; }
.drop-zone span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.file-input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }

.button {
    display: inline-grid;
    place-items: center;
    min-height: 42px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 0 18px;
    font-weight: 800;
    text-decoration: none;
}

.button:hover { background: var(--accent-dark); }
.button.secondary { background: #fffdfd; color: var(--accent-dark); }
.button.secondary:hover { background: var(--accent-soft); }
.button[disabled] { cursor: not-allowed; opacity: 0.48; }

.file-summary {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel-soft);
    padding: 9px;
}

.preview {
    width: 72px;
    height: 58px;
    border-radius: 7px;
    background: #fff;
    object-fit: contain;
}

.file-meta { min-width: 0; }
.file-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { color: var(--muted); font-size: 12px; }
.change-file { border: 0; background: transparent; color: var(--accent-dark); font-size: 13px; }

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
    margin-top: 14px;
}

.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.field input, .field select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdfd;
    color: var(--text);
    padding: 0 11px;
    outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

.dimensions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.dimension-separator { padding-bottom: 12px; color: var(--muted); }
.ratio-note { margin: 6px 0 0; color: var(--muted); font-size: 11px; }

.quality-field { grid-column: 1 / -1; }
.quality-heading { display: flex; justify-content: space-between; gap: 12px; }
.quality-heading output { color: var(--text); font-weight: 800; }
input[type="range"] { width: 100%; min-height: 28px; padding: 0; accent-color: var(--accent); }

.form-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.form-actions .button { min-width: 190px; }
.privacy { margin: 11px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.privacy strong { color: var(--accent-dark); }
.message { min-height: 18px; margin: 9px 0 0; color: var(--danger); font-size: 13px; text-align: center; }

.process-card { text-align: center; }
.status-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 11px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 25px;
}
.status-icon.spinning { animation: pulse 1.1s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.07); background: rgba(128, 103, 132, 0.18); } }
.process-card h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; }
.process-card p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.progress { height: 7px; margin-top: 16px; overflow: hidden; border-radius: 99px; background: #e5dce7; }
.progress span { display: block; width: 5%; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.24s ease; }

.ad-slot {
    width: 100%;
    max-width: 100%;
    min-height: 120px;
    margin-top: 16px;
    overflow: hidden;
}
.adsbygoogle { max-width: 100% !important; }

.format-info {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 253, 253, 0.84);
    padding: 18px;
    color: var(--muted);
    line-height: 1.55;
}
.format-info h2 { margin: 0 0 7px; color: var(--text); font-family: Georgia, "Times New Roman", serif; font-size: 23px; font-weight: 500; }
.format-info p { margin: 7px 0; }

.download-card { margin-top: 22px; text-align: center; }
.download-card h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; }
.result-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px 16px; margin: 10px 0 15px; color: var(--muted); font-size: 13px; }
.result-stats strong { color: var(--text); }
.download-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }

.tool-guide { margin-top: 19px; color: var(--muted); font-size: 14px; line-height: 1.58; }
.tool-guide h2 { margin: 18px 0 6px; color: var(--text); font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 500; }
.tool-guide p { margin: 6px 0; }
.tool-guide a { color: var(--accent-dark); }

@media (max-width: 620px) {
    .shell { width: min(100% - 20px, 900px); padding-top: 12px; }
    .hero.compact { display: block; }
    .back-link { display: inline-block; margin-top: 8px; }
    .settings-grid { grid-template-columns: 1fr; gap: 10px; }
    .quality-field { grid-column: auto; }
    .file-summary { grid-template-columns: 58px minmax(0, 1fr); }
    .preview { width: 58px; height: 52px; }
    .change-file { grid-column: 1 / -1; min-height: 30px; }
    .form-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .status-icon.spinning { animation: none; }
}
