:root {
    --bg: #21150f;
    --panel: rgba(54, 33, 23, .92);
    --panel-light: #fff7e7;
    --gold: #f2ad35;
    --gold-dark: #9d5b17;
    --purple: #742fc7;
    --green: #61d358;
    --ink: #2a190f;
    --muted: #8b735e;
    --danger: #b93625;
    --shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 20% 10%, #5b3219 0, transparent 32%),
                linear-gradient(135deg, #180f0b, #312017 55%, #160e0b);
    color: var(--panel-light);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .16em; font-size: 12px; margin: 0 0 6px; }
h1 { margin: 0; font-size: clamp(34px, 5vw, 60px); line-height: .95; text-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.balance-card { background: rgba(255, 247, 231, .9); color: var(--ink); padding: 14px 18px; border-radius: 18px; border: 2px solid rgba(242, 173, 53, .75); text-align: right; box-shadow: var(--shadow); min-width: 240px; }


/* Тоггл звука кузницы. По умолчанию выключен (показывает 🔇).
   Включён → класс .on → показывает 🔊 и подсвечивается золотом. */
.sound-toggle {
    align-self: center;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(54, 33, 23, .65);
    border: 2px solid rgba(242, 173, 53, .55);
    color: var(--panel-light);
    font-size: 24px;
    line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .12s;
    box-shadow: var(--shadow);
}
.sound-toggle:hover { transform: scale(1.05); }
.sound-toggle.on {
    background: linear-gradient(180deg, #ffd166, #e08819);
    border-color: var(--gold);
    color: var(--ink);
}
.sound-toggle .sound-icon-on  { display: none; }
.sound-toggle .sound-icon-off { display: inline; }
.sound-toggle.on .sound-icon-on  { display: inline; }
.sound-toggle.on .sound-icon-off { display: none; }
.balance-card a { color: var(--gold-dark); }
.balance-card .small { font-size: 12px; color: var(--muted); }

.login-card { margin-bottom: 22px; padding: 28px 24px; border-radius: 26px; border: 2px solid rgba(242, 173, 53, .55); box-shadow: var(--shadow); background: rgba(255, 247, 231, .94); color: var(--ink); text-align: center; }
.login-card h2 { margin: 0 0 8px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }

.hero-card { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 24px; align-items: stretch; }

.hero-preview, .converter-panel, .settings-card, .result-card, .alert, .advanced-actions, .progress-card { border: 2px solid rgba(242, 173, 53, .55); border-radius: 26px; box-shadow: var(--shadow); }
.hero-preview { position: relative; overflow: hidden; min-height: 480px; background: #120b08; transition: outline-color .15s; outline: 0 solid transparent; }
.hero-preview img { width: 100%; height: 100%; display: block; object-fit: cover; transition: opacity .25s; cursor: zoom-in; }

/* Лайтбокс: фуллскрин-просмотр hero-картинки. */
.lightbox {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0, 0, 0, .94);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    cursor: zoom-out;
    animation: lb-fade .15s ease-out;
}
.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .85);
    border-radius: 6px;
}
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
.hero-preview.drag-over { outline: 4px solid var(--green); outline-offset: -4px; }
.image-tabs { position: absolute; left: 18px; right: 18px; bottom: 18px; display: flex; flex-wrap: nowrap; gap: 6px; padding: 8px; background: rgba(18, 11, 8, .7); border: 1px solid rgba(255, 255, 255, .18); border-radius: 18px; backdrop-filter: blur(10px); }
.image-tab { white-space: nowrap; flex: 0 1 auto; min-width: 0; }

button { font: inherit; cursor: pointer; border: 0; }
button:disabled { opacity: .5; cursor: not-allowed; }

.image-tab, .ghost-btn { color: #fff7e7; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; padding: 9px 14px; font-weight: 700; }
.image-tab.active, .format-btn.active { background: linear-gradient(180deg, #ffd166, #e08819); color: #241307; box-shadow: 0 0 0 3px rgba(242, 173, 53, .18); }

.converter-panel { background: var(--panel); padding: 22px; display: flex; flex-direction: column; gap: 18px; }

.format-picker p, .settings-card label { display: block; margin: 0 0 8px; font-weight: 700; }

input, select { width: 100%; border: 1px solid rgba(42, 25, 15, .2); border-radius: 14px; padding: 12px 13px; color: var(--ink); background: #fff9ee; font: inherit; }

.drop-format-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: stretch; }
.drop-zone { min-width: 0; min-height: 235px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; border: 3px dashed rgba(242, 173, 53, .8); border-radius: 24px; background: linear-gradient(180deg, rgba(255, 209, 102, .18), rgba(255, 255, 255, .05)); padding: 16px; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; overflow: hidden; }
.drop-zone.has-file { border-style: solid; background: linear-gradient(180deg, rgba(97, 211, 88, .18), rgba(255, 255, 255, .05)); }
.drop-zone.drag-over { border-color: var(--green); background: linear-gradient(180deg, rgba(97, 211, 88, .35), rgba(255, 255, 255, .08)); transform: scale(1.01); }
.drop-zone input { display: none; }
.upload-icon { font-size: 52px; line-height: 1; color: var(--gold); }
.drop-zone strong {
    font-size: 18px;
    max-width: 100%;
    line-height: 1.2;
    /* Длинные имена файлов без пробелов (хеши и т.п.) переносим, а не
       растягиваем drop-zone — иначе колонка с кнопкой формата уезжает. */
    overflow-wrap: anywhere;
    word-break: break-word;
    /* Не больше двух строк, иначе появится ellipsis. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.drop-zone small { color: #e9c792; margin-top: 6px; max-width: 100%; word-break: break-word; overflow-wrap: anywhere; }

.format-picker { padding: 16px; border-radius: 22px; background: #fff7e7; color: var(--ink); display: flex; flex-direction: column; gap: 12px; }
.format-buttons { display: grid; gap: 10px; }
.format-btn { padding: 13px; border-radius: 14px; color: var(--ink); background: #eadcc7; font-weight: 900; letter-spacing: .04em; }
.format-btn.disabled { opacity: .35; cursor: not-allowed; }

.primary-btn, .success-btn { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; border-radius: 15px; padding: 0 18px; background: linear-gradient(180deg, #8f49e7, #5720a7); color: #fff; font-weight: 900; text-decoration: none; box-shadow: 0 10px 24px rgba(87, 32, 167, .35); }
.primary-btn:disabled { background: #6b5c52; box-shadow: none; }
.success-btn { background: linear-gradient(180deg, #79e26e, #2e923f); }

/* Двухстрочная кнопка: основная надпись + второстепенная подсказка снизу.
   Используется для кнопки «Скачать» (Скачать + размер файла). */
.success-btn.two-line {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 18px;
    line-height: 1.15;
    gap: 4px;
    min-height: 60px;
}
.success-btn.two-line .btn-line-1,
.success-btn.two-line .btn-line-2 {
    display: block;
    width: 100%;
    text-align: center;
}
.btn-line-1 { font-weight: 900; font-size: 17px; letter-spacing: .01em; }
.btn-line-2 { font-size: 11px; font-weight: 600; letter-spacing: .03em; opacity: .85; }

/* Скачать: широкая на всю ширину панели */
.success-btn.full { display: flex; width: 100%; }

/* Подсказка о цене под кнопкой «Конвертировать» — красным мелким, по центру */
.price-hint {
    text-align: center;
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    margin: -4px 0 0;
}

.mode-switch-row { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: rgba(0, 0, 0, .18); font-weight: 800; }
.mode-switch input, .mini-switch input { display: none; }
.track { position: relative; display: block; width: 76px; height: 38px; border-radius: 999px; background: #7a5134; border: 2px solid rgba(255, 255, 255, .22); transition: .2s; }
.thumb { position: absolute; width: 28px; height: 28px; border-radius: 50%; left: 3px; top: 3px; background: var(--gold); transition: .2s; }
.mode-switch input:checked + .track { background: var(--purple); }
.mode-switch input:checked + .track .thumb { transform: translateX(38px); }

.advanced-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

.settings-card { background: var(--panel-light); color: var(--ink); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.settings-card.disabled { opacity: .55; }
.settings-card-img { aspect-ratio: 4 / 3; overflow: hidden; background: #120b08; }
.settings-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.settings-card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }

.settings-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 6px; }
.settings-head .title strong { display: block; font-size: 20px; line-height: 1.1; }
.settings-head .title span { color: var(--muted); font-size: 13px; }

.mini-switch span { display: block; width: 44px; height: 24px; border-radius: 999px; background: #c7b8a4; position: relative; }
.mini-switch span::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: white; position: absolute; left: 3px; top: 3px; transition: .2s; }
.mini-switch input:checked + span { background: var(--green); }
.mini-switch input:checked + span::after { transform: translateX(20px); }

.check-line { display: flex !important; gap: 8px; align-items: center; font-weight: 500 !important; margin: 0 !important; }
.check-line input { width: auto; }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-cols label { display: block; }

.advanced-actions { margin-top: 18px; background: rgba(255, 247, 231, .93); color: var(--ink); padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.advanced-actions .file-line { font-weight: 800; }
.advanced-actions .file-line input { margin-top: 8px; }

.progress-card { margin-top: 18px; padding: 18px; background: var(--panel-light); color: var(--ink); }
.progress-card h3 { margin: 0 0 10px; }
.progress-bar { height: 14px; border-radius: 999px; background: #e3d6c0; overflow: hidden; margin-bottom: 10px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #f2ad35, #61d358); transition: width .25s ease; width: 0%; }
.progress-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.progress-step { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: #efe2cb; font-size: 13px; }
.progress-step.active { background: linear-gradient(180deg, #ffd166, #e08819); color: #241307; font-weight: 800; }
.progress-step.done { background: #c6e9bb; }
.progress-step .dot { width: 10px; height: 10px; border-radius: 50%; background: #b8a489; flex-shrink: 0; }
.progress-step.active .dot { background: #5720a7; }
.progress-step.done .dot { background: var(--green); }

.result-card, .alert { margin-top: 18px; padding: 18px; background: var(--panel-light); color: var(--ink); }
.alert { color: #fff; background: var(--danger); }
.result-card h2 { margin: 0 0 10px; }
.result-card p { margin: 4px 0; font-size: 14px; }
.result-card a { display: inline-block; margin-top: 10px; }

.hidden { display: none !important; }
.error-text { color: var(--danger); }

@media (max-width: 920px) {
    .hero-card { grid-template-columns: 1fr; }
    .balance-card { text-align: left; }
    .drop-format-grid, .advanced-grid, .advanced-actions { grid-template-columns: 1fr; }
    .hero-preview { min-height: 360px; }
}
