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

* { 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(251,191,36,0.05) 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;
}

/* ---- основная сетка ---- */
.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;}

/* ---- рабочая зона ---- */
.workspace { display: flex; flex-direction: column; gap: 1rem; }

/* ---- drop zone ---- */
.drop-zone {
    border: 1.5px dashed var(--card-border);
    border-radius: 14px; background: var(--card-bg);
    min-height: 160px;
    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: 2rem;
}
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(251,191,36,0.04);
}
.drop-zone.has-file { cursor: default; }
.drop-icon { opacity: 0.3; color: var(--accent-primary); }
.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; }

/* ---- аудио-плеер ---- */
.audio-player-wrap {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex; flex-direction: column; gap: 0.6rem;
}
.player-label {
    font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 2px;
    color: var(--text-dim);
}
.player-label.result { color: var(--accent-primary); }
audio {
    width: 100%; height: 36px;
    border-radius: 8px;
    accent-color: var(--accent-primary);
}
audio::-webkit-media-controls-panel { background: rgba(255,255,255,0.04); }

/* ---- участок шума ---- */
.noise-segment-wrap {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: none;
    flex-direction: column;
    gap: 0.6rem;
}
.noise-segment-wrap.visible { display: flex; }
.noise-segment-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 2px; color: var(--text-dim);
}
.noise-segment-time {
    color: var(--accent-primary); font-weight: 700;
    letter-spacing: 0; text-transform: none; font-size: 0.78rem;
}
.noise-segment-track {
    position: relative;
    height: 44px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    touch-action: none;
    user-select: none;
    cursor: pointer;
}
.noise-segment-fill {
    position: absolute; top: 0; bottom: 0;
    background: rgba(251,191,36,0.22);
    border-top: 1px solid var(--accent-primary);
    border-bottom: 1px solid var(--accent-primary);
    pointer-events: auto;
    cursor: grab;
}
.noise-segment-fill.dragging {
    cursor: grabbing;
}
.noise-segment-handle {
    position: absolute; top: -3px; bottom: -3px;
    width: 20px; margin-left: -10px;
    display: flex; align-items: center; justify-content: center;
    cursor: ew-resize; touch-action: none;
}
.noise-segment-handle::before {
    content: ''; width: 4px; height: calc(100% - 6px);
    background: var(--accent-primary); border-radius: 3px;
    box-shadow: 0 0 0 3px rgba(251,191,36,0.15);
    transition: background 0.15s;
}
.noise-segment-handle:active::before,
.noise-segment-handle.dragging::before { background: #fff; }
.noise-segment-hint { font-size: 0.72rem; color: rgba(255,255,255,0.2); line-height: 1.4; }
.btn-play-segment {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(251,191,36,0.12); border: 1px solid rgba(251,191,36,0.3);
    color: var(--accent-primary); cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0; padding: 0;
}
.btn-play-segment:hover { background: rgba(251,191,36,0.25); transform: scale(1.1); }
.btn-play-segment:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
/* ---- waveform внутри noise-segment-track ---- */
.noise-waveform {
    position: absolute; inset: 0;
    display: flex; align-items: center;
    gap: 1px; padding: 4px 0;
    pointer-events: none; overflow: hidden;
}
.noise-waveform .wv-bar {
    flex: 1; border-radius: 1px;
    background: rgba(255,255,255,0.12);
    min-height: 2px;
    transition: background 0.15s;
}
/* бары внутри выделения подсвечиваются желтым */
.noise-waveform .wv-bar.in-selection {
    background: rgba(251,191,36,0.55);
}

/* ---- кнопки ---- */
.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(251,191,36,0.3);
}
.btn-outline {
    background: transparent; color: var(--text-main);
    border: 1px solid var(--card-border);
}
.btn-outline:hover:not(:disabled) {
    border-color: var(--accent-primary); color: var(--accent-primary);
    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-primary); }
.status-bar.success { color: #4ade80; }
.status-bar.error   { color: var(--error); }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(251,191,36,0.3); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }

/* ---- визуализация волны (декоративная) ---- */
.waveform-placeholder {
    width: 100%; height: 48px;
    display: flex; align-items: center; justify-content: center; gap: 3px;
    opacity: 0.15;
}
.waveform-placeholder .bar {
    width: 3px; border-radius: 2px;
    background: var(--accent-primary);
    animation: wave 1.2s ease-in-out infinite;
}

/* ---- панель настроек ---- */
.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); }

.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); }
.setting-select option { background: #111; }

.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: 3ch; 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(251,191,36,0.2); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--accent-primary); cursor: pointer; }

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

/* ---- анимации ---- */
@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} }
@keyframes wave {
    0%, 100% { height: 8px; }
    50%       { height: 32px; }
}

/* ---- адаптив ---- */
@media (max-width: 768px) {
    .main-grid { grid-template-columns: 1fr; }
    .settings-panel { position: static; order: -1; }
}
@media (max-width: 560px) {
    .actions { flex-direction: column; }
    .btn { justify-content: center; }
    .noise-segment-handle { width: 28px; margin-left: -14px; }
}
