/* блок исходного изображения */
.source-box { display: flex; align-items: center; gap: 12px; margin: 10px 0 14px; }
.source-box.hidden { display: none; }
.source-box img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }

/* attention animation for dropzone */
@keyframes dz-shake { 0%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} 100%{transform:translateX(0)} }
.dropzone.attn { border-color: #ff6b81; background:#1a1416; animation: dz-shake .4s ease; }

/* макет рабочей области: слева управление, справа превью */
.workspace { display: grid !important; grid-template-columns: 360px 1fr !important; gap: 18px; align-items: start; }
.panel-left { position: sticky; top: 90px; height: fit-content; }
.panel-right { min-height: 520px; position: relative; }

/* дропзона */
.dropzone { border: 2px dashed #4a4a58; background: #0f0f14; border-radius: 14px; height: 460px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: .2s ease; }
.dropzone:hover { background: #14141c; border-color: #6b6b86; }
.dropzone.dragover { background: #181826; border-color: #8b6ee8; }
.dropzone-inner { text-align: center; }
.drop-title { color: var(--brand-dark); font-weight: 700; margin-bottom: 6px; }
.drop-sub { color: var(--muted); }

@media (max-width: 992px) {
  .workspace { grid-template-columns: 1fr; }
  .panel-left { position: static; }
}

/* iframe прелоудера в блоке результата */
.result-images iframe { width: 100%; height: 420px; border: 0; background: transparent; border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,0.55); }

/* Корневой контейнер приложения на странице Bitrix */
#mm-ai-app {
    margin: 120px auto 40px;
    max-width: 1200px;
    padding: 0 16px;
    position: relative;
    z-index: 1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --brand-primary: #8b6ee8;
    --brand-primary-2: #a48ef0;
    --brand-dark: #e7e7ea;
    --muted: #a3a3ad;
    --bg: #0e0e11;
    --card: #15151a;
    --border: #272734;
    --btn-black: #8c8283;
    --btn-black-hover: #7d7475;
}

/* --- Новые элементы --- */
.ratio-row { display: flex; align-items: center; gap: 16px; margin: 14px 0 6px; flex-wrap: wrap; }
.ratio-label { color: var(--muted); font-size: 0.95rem; }
.ratio-select { background: #1b1b23; color: var(--brand-dark); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.aspect-preview-wrap { display: flex; align-items: center; gap: 10px; }
.aspect-preview { width: 220px; height: 124px; border: 2px dashed #4a4a58; border-radius: 10px; background: #0f0f14; position: relative; }
.aspect-hint { color: var(--muted); font-size: 0.9rem; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; background: var(--bg) !important; min-height: 100vh; color: var(--brand-dark) !important; }

.container { max-width: 1100px; margin: 0 auto; }

.custom-header {
    width: 100%;
    background: rgba(14, 14, 17, 0.95);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    padding: 12px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65);
}

.header-inner {
    margin: 0 auto;
    max-width: 1200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.btn-site {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: capitalize;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-site-icon {
    display: none;
    font-size: 1.2rem;
}

.btn-site-label {
    display: inline;
}

.hero-intro {
    margin: 0 auto 28px;
    padding: 20px 24px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    max-width: 720px;
    background: rgba(255,255,255,0.02);
    color: var(--brand-dark);
    text-align: center;
}

.hero-intro h1 {
    margin: 10px 0 4px;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-description {
    margin: 0;
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.4;
}

.eyebrow {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 3, 10, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 10001;
}

.onboarding-card {
    background: #14141b;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6);
    color: var(--brand-dark);
}

.onboarding-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.onboarding-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.onboarding-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.onboarding-lede {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--muted);
    margin-bottom: 14px;
}

.onboarding-steps {
    margin: 0 0 20px;
    padding-left: 18px;
    color: var(--brand-dark);
    line-height: 1.5;
}

.onboarding-steps li {
    margin-bottom: 8px;
}

.onboarding-btn {
    width: 100%;
}

.header-logo img {
    height: 42px;
    width: auto;
    display: block;
}

.btn-site {
    background: var(--brand-primary);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 10px;
    text-transform: capitalize;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-site:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(139, 110, 232, 0.55);
}

body.guide-open {
    overflow: hidden;
}

main { padding: 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: 0 14px 36px rgba(0,0,0,0.45); }

.upload-section { margin-bottom: 20px; }

.upload-area { border-radius: 12px; }

.upload-buttons { display: flex; gap: 12px; flex-wrap: wrap; }

.btn { padding: 12px 22px; border: 1px solid #2b2b39; border-radius: 10px; font-size: 0.98rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 8px; background: var(--btn-black); color: #0e0e11; }
.btn:hover { background: var(--btn-black-hover); }
.btn-primary { background: var(--btn-black); color: #0e0e11; }
.btn-secondary { background: var(--btn-black); color: #0e0e11; }
.btn-accent { background: var(--btn-black); color: #0e0e11; }
.btn-success { background: var(--btn-black); color: #0e0e11; }

.btn-ghost { background: transparent; color: var(--muted); border: 1px solid #2b2b39; }
.btn-ghost:hover { background: #1a1a22; color: var(--brand-dark); }

.btn-large { padding: 14px 28px; font-size: 1.06rem; }

.preview-container { margin-top: 0; }
.preview-container img { width: 100%; max-height: 520px; object-fit: contain; border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,0.6); }

.inline-actions { display: flex; gap: 10px; }
.inline-actions[hidden] { display: none !important; }
.camera-controls { margin-top: 12px; }
.camera-controls .btn { flex: 1; }

.action-section { margin: 16px 0 0; display: block !important; }
.action-section.hidden { display: none !important; }

.loading-section { text-align: center; padding: 28px; }
.spinner { border: 4px solid #23232f; border-top: 4px solid var(--brand-primary); border-radius: 50%; width: 44px; height: 44px; animation: spin 1s linear infinite; margin: 0 auto 14px; }
@keyframes spin { 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} }

.result-section { margin-top: 18px; }
.result-section h2 { margin-bottom: 14px; color: var(--brand-primary-2); font-size: 1.1rem; }
.result-actions {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.result-images { display: grid; grid-template-columns: 1fr; gap: 16px; }
.result-images img { width: 100%; border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,0.55); }

.result-description { padding: 12px; background: #121219; border: 1px solid #2b2b39; border-radius: 10px; margin-bottom: 8px; line-height: 1.55; color: var(--muted); }

.error-section { background: #2a1820; border: 1px solid #4d2a36; border-radius: 12px; padding: 18px; margin-top: 18px; text-align: center; }
.error-message { color: #ff6b81; margin-bottom: 10px; font-weight: 600; }

.hidden { display: none; }

#cameraVideo { width: 100%; border-radius: 10px; margin-bottom: 12px; box-shadow: 0 8px 22px rgba(0,0,0,0.55); }

/* Секция кредитов */
.credits-section { margin-bottom: 20px; padding: 16px; background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.credits-display { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.credits-label { color: var(--muted); font-size: 0.9rem; }
.credits-value { color: var(--brand-primary); font-weight: 700; font-size: 1.2rem; }
.credits-info { color: var(--brand-dark); font-size: 0.9rem; text-align: center; padding: 8px; background: rgba(139, 110, 232, 0.1); border-radius: 6px; }

.vote-card { margin-bottom: 20px; padding: 16px; background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.vote-card h3 { margin-bottom: 10px; color: var(--brand-dark); font-size: 1rem; }
.vote-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.vote-btn { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.vote-up { background: rgba(46, 204, 113, 0.15); border-color: rgba(46, 204, 113, 0.35); color: #7ff0a3; }
.vote-up:hover { background: rgba(46, 204, 113, 0.25); }
.vote-down { background: rgba(231, 76, 60, 0.12); border-color: rgba(231, 76, 60, 0.35); color: #ff9b9b; }
.vote-down:hover { background: rgba(231, 76, 60, 0.2); }
.vote-hint { margin-top: 8px; color: var(--muted); font-size: 0.9rem; }

/* Модальное окно для комментария */
.vote-comment-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.vote-comment-modal.hidden { 
    display: none !important; 
}
.vote-comment-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}
.vote-comment-content {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.vote-comment-content h3 {
    margin: 0 0 8px;
    color: var(--brand-dark);
    font-size: 1.3rem;
}
.vote-comment-hint {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 0.95rem;
}
.vote-comment-textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #1a1a22;
    color: var(--brand-dark);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 8px;
}
.vote-comment-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
}
.vote-comment-counter {
    text-align: right;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}
.vote-comment-counter span {
    color: var(--brand-primary);
    font-weight: 600;
}
.vote-comment-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
.vote-comment-actions .btn {
    min-width: 120px;
}

/* Секция переключения кодов */
.code-toggle-section { margin-bottom: 20px; }
.code-toggle-section .btn {
    width: 100%;
    transition: all 0.2s ease;
    background: var(--brand-primary);
    color: white;
    border: 1px solid var(--brand-primary);
}
.code-toggle-section .btn:hover {
    background: var(--brand-primary-2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 110, 232, 0.3);
}

/* Секция кодов */
.code-section { margin-bottom: 20px; padding: 16px; background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.code-section h3 { margin-bottom: 12px; color: var(--brand-dark); font-size: 1rem; }
.code-input-group { display: flex; gap: 8px; margin-bottom: 12px; }
.code-input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--brand-dark); }
.code-input:focus { outline: none; border-color: var(--brand-primary); }

@media (max-width: 768px) {
    #mm-ai-app { margin-top: 160px; padding: 0 12px; }
    .custom-header { position: fixed; padding: 12px 16px; }
    .header-inner { flex-direction: row; align-items: center; justify-content: space-between; }
    .btn-site { display: none !important; }
    .upload-buttons { flex-direction: column; }
    .btn { width: 100%; justify-content: center; }
    .workspace { display: block !important; }
    .panel-left, .panel-right { width: 100%; margin: 0 0 16px 0; }
    .preview-container { margin-top: 14px; }
    .camera-controls { flex-direction: column; }
    #cameraVideo { margin-top: 10px; }
    .vote-actions { grid-template-columns: 1fr; }

    /* Мобильные стили для кредитов */
    .credits-section { margin-bottom: 15px; padding: 12px; }
    .code-toggle-section { margin-bottom: 15px; }
    .code-section { margin-bottom: 15px; padding: 12px; }
    .code-input-group { flex-direction: column; }
    .code-input { margin-bottom: 8px; }
}

