:root {
    --bg-color: #050505;
    --accent-primary: #00ff88;
    --accent-secondary: #00ccff;
    --text-main: #ffffff;
    --text-dim: #a0a0a0;
    --card-bg: rgba(255,255,255,0.03);
    --card-border: rgba(255,255,255,0.07);
    --error: #ff4d6d;
}

/* ---- режим (ИИ / OpenCV) ---- */
.mode-switch {
    display: flex; gap: 0.5rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 1.25rem;
    width: fit-content;
}
.mode-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 7px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    cursor: pointer; border: none;
    background: transparent; color: var(--text-dim);
    transition: all 0.2s;
}
.mode-btn.active { background: rgba(255,255,255,0.08); color: var(--text-main); }
.mode-btn.mode-ai.active { color: var(--accent-primary); }
.mode-btn.mode-cv.active { color: var(--accent-secondary); }

/* ---- предупреждение ИИ ---- */
.ai-warning {
    display: flex; align-items: flex-start; gap: 0.75rem;
    background: rgba(245,158,11,0.07);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    font-size: 0.82rem; color: #fcd34d;
    margin-bottom: 1.25rem; line-height: 1.5;
}
.ai-warning svg { flex-shrink: 0; margin-top: 1px; }

/* Вложенные пейны (ИИ / CV) */
.mode-settings-pane { display: none; flex-direction: column; gap: 1.25rem; }
.mode-settings-pane.active { display: flex; }

.hint-text { font-size: 0.72rem; color: rgba(255,255,255,0.2); line-height: 1.4; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-glow {
    position: fixed;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(0,255,136,0.06) 0%, transparent 70%);
    bottom: -100px; right: -100px;
    pointer-events: none; z-index: 0;
}

.page {
    position: relative; z-index: 1;
    max-width: 960px; margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* ---- topbar ---- */
.topbar {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap; gap: 0.75rem;
}
.back-link {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--text-dim); text-decoration: none;
    font-size: 0.85rem; font-weight: 600;
    transition: color 0.2s, transform 0.2s;
}
.back-link:hover { color: var(--accent-primary); transform: translateX(-3px); }
.page-label {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 2.5px;
    color: var(--accent-primary);
}

/* ---- заголовок ---- */
.page-title {
    font-size: clamp(1.8rem, 6vw, 2.8rem);
    font-weight: 800; line-height: 1.1; margin-bottom: 0.5rem;
    animation: fadeInLeft 0.6s forwards;
}
.page-title span {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.page-sub {
    color: var(--text-dim); font-size: 0.95rem;
    margin-bottom: 1.5rem;
    animation: fadeInLeft 0.6s 0.1s both;
}

/* ---- вкладки ---- */
.tabs {
    display: flex; gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0;
}
.tab-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px;
    background: none; border: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem; font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* ---- основная сетка ---- */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.25rem; align-items: start;
}
.left-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0;}

/* ---- вкладка (контент) ---- */
.tab-pane { display: none; }
.tab-pane.active { display: flex; flex-direction: column; gap: 1rem; }

/* ---- рабочая зона ---- */
.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem; align-items: start;
}

/* ---- drop zone ---- */
.drop-zone {
    border: 1.5px dashed var(--card-border);
    border-radius: 14px; background: var(--card-bg);
    min-height: 260px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 0.75rem; cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative; overflow: hidden; padding: 1.5rem;
}
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(0,255,136,0.04);
}
.drop-zone.has-file { cursor: default; padding: 0; align-items: center; justify-content: center; }
.drop-icon { opacity: 0.35; }
.drop-label { font-size: 0.85rem; color: var(--text-dim); text-align: center; line-height: 1.5; }
.drop-label strong { color: var(--accent-primary); }
.drop-hint { font-size: 0.72rem; color: rgba(255,255,255,0.2); }
.drop-zone input[type=file] { display: none; }
.preview-img, .preview-video {
    width: 100%; object-fit: contain;
    border-radius: 14px; display: block; max-height: 360px;
}

/* ---- результат ---- */
.result-panel {
    border: 1.5px solid var(--card-border);
    border-radius: 14px; background: var(--card-bg);
    min-height: 260px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 1rem; padding: 1.5rem;
    position: relative; overflow: hidden;
}
.result-panel.has-result {
    background-image:
    linear-gradient(45deg,#1a1a1a 25%,transparent 25%),
    linear-gradient(-45deg,#1a1a1a 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#1a1a1a 75%),
    linear-gradient(-45deg,transparent 75%,#1a1a1a 75%);
    background-size: 16px 16px;
    background-position: 0 0,0 8px,8px -8px,-8px 0;
    background-color: #111;
    align-items: center; justify-content: center; padding: 0;
}
.result-placeholder { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.result-placeholder .rp-icon { opacity: 0.15; }
.result-placeholder p { font-size: 0.85rem; color: var(--text-dim); text-align: center; }
.result-img, .result-video {
    width: 100%; object-fit: contain;
    border-radius: 14px; display: block; max-height: 360px;
}

/* ---- кнопки ---- */
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 12px 22px; border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    cursor: pointer; border: none;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }
.btn-primary { background: var(--accent-primary); color: #000; }
.btn-primary:hover:not(:disabled) {
    background: #fff; transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,255,136,0.25);
}
.btn-outline {
    background: transparent; color: var(--text-main);
    border: 1px solid var(--card-border);
}
.btn-outline:hover:not(:disabled) {
    border-color: var(--accent-secondary); color: var(--accent-secondary);
    transform: translateY(-2px);
}
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--error); }

/* ---- статус / прогресс ---- */
.file-meta { font-size: 0.75rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;}
.progress-wrap { height: 3px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; display: none; }
.progress-wrap.visible { display: block; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg,var(--accent-primary),var(--accent-secondary)); border-radius: 2px; transition: width 0.3s ease; }
.status-bar { min-height: 1.4em; font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem; }
.status-bar.loading { color: var(--accent-secondary); }
.status-bar.success { color: var(--accent-primary); }
.status-bar.error   { color: var(--error); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(0,204,255,0.3); border-top-color: var(--accent-secondary); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }

/* ---- панель настроек ---- */
.settings-panel {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 14px; padding: 1.25rem;
    display: flex; flex-direction: column; gap: 1.25rem;
    position: sticky; top: 1.5rem;
}
.settings-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 2.5px; color: var(--text-dim); }
.setting-section { display: flex; flex-direction: column; gap: 0.75rem; }
.setting-section-label { font-size: 0.75rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; padding-bottom: 0.5rem; border-bottom: 1px solid var(--card-border); }

/* настройки — скрываемые панели по вкладке */
.settings-pane { display: none; flex-direction: column; gap: 1.25rem; }
.settings-pane.active { display: flex; }

.setting-select {
    width: 100%; background: rgba(255,255,255,0.05);
    border: 1px solid var(--card-border); border-radius: 8px;
    color: var(--text-main); font-family: 'Inter', sans-serif;
    font-size: 0.82rem; padding: 9px 12px; outline: none; cursor: pointer;
    transition: border-color 0.2s; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0a0a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.setting-select:focus { border-color: var(--accent-primary); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.toggle-label { font-size: 0.82rem; color: var(--text-main); display: flex; flex-direction: column; gap: 2px; }
.toggle-label .hint { font-size: 0.68rem; color: rgba(255,255,255,0.25); font-weight: 400; line-height: 1.3; }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track { position: absolute; inset: 0; background: rgba(255,255,255,0.1); border-radius: 20px; cursor: pointer; transition: background 0.2s; }
.toggle-track::after { content:''; position: absolute; width: 14px; height: 14px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform 0.2s; }
.toggle input:checked + .toggle-track { background: var(--accent-primary); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

.slider-row { display: flex; flex-direction: column; gap: 0.35rem; }
.slider-row-head { display: flex; justify-content: space-between; align-items: center; }
.slider-name { font-size: 0.78rem; color: var(--text-dim); }
.slider-val { font-size: 0.78rem; font-weight: 700; color: var(--accent-primary); min-width: 2.5ch; text-align: right; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; outline: none; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-primary); cursor: pointer; transition: box-shadow 0.2s; }
input[type=range]::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px rgba(0,255,136,0.2); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--accent-primary); cursor: pointer; }

.bgcolor-picker-row { display: flex; align-items: center; gap: 0.75rem; }
input[type=color] { -webkit-appearance: none; appearance: none; width: 36px; height: 36px; border: none; border-radius: 8px; cursor: pointer; background: none; padding: 0; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 8px; }

.collapsible { display: none; flex-direction: column; gap: 0.75rem; }
.collapsible.open { display: flex; }

/* ---- подсказки (details/summary) ---- */
.param-tip {
    margin-top: 0.4rem;
}
.param-tip summary {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
    transition: color 0.2s;
}
.param-tip summary::-webkit-details-marker { display: none; }
.param-tip summary::before {
    content: '';
    display: inline-block;
    width: 10px; height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Ccircle cx='5' cy='5' r='4.2' stroke='%23606060' stroke-width='1.2'/%3E%3Cpath d='M5 4.2v3M5 3h.01' stroke='%23606060' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
    flex-shrink: 0;
}
.param-tip[open] summary { color: rgba(255,255,255,0.45); }
.param-tip[open] summary::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Ccircle cx='5' cy='5' r='4.2' stroke='%2300ff88' stroke-width='1.2'/%3E%3Cpath d='M5 4.2v3M5 3h.01' stroke='%2300ff88' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.param-tip-body {
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.03);
    border-left: 2px solid rgba(0,255,136,0.2);
    border-radius: 0 6px 6px 0;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.param-tip-body b {
    color: rgba(255,255,255,0.55);
    font-weight: 600;
}
.param-tip-body .tip-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.5rem;
    align-items: baseline;
}
.param-tip-body .tip-key {
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 0.68rem;
    white-space: nowrap;
}

/* ---- анимации ---- */
@keyframes fadeInLeft { from{opacity:0;transform:translateX(-20px)} to{opacity:1;transform:translateX(0)} }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* ---- адаптив ---- */
@media (max-width: 768px) {
    .main-grid { grid-template-columns: 1fr; }
    .settings-panel { position: static; order: -1; }
    .mode-switch { width: 100%; }
    .mode-btn { flex: 1; justify-content: center; }
}
@media (max-width: 560px) {
    .workspace { grid-template-columns: 1fr; }
    .drop-zone, .result-panel { min-height: 200px; }
    .actions { flex-direction: column; }
    .btn { justify-content: center; }
}
