/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0f0f13;
    --bg2:        #1a1a22;
    --bg3:        #242432;
    --border:     #2e2e42;
    --accent:     #7c6af7;
    --accent-h:   #9b8fff;
    --green:      #3ecf8e;
    --red:        #f04;
    --text:       #e8e8f0;
    --text2:      #8888aa;
    --text3:      #555570;
    --radius:     10px;
    --radius-lg:  16px;
    --shadow:     0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

/* ===== LAYOUT ===== */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== HEADER ===== */
.header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 680px;
    margin: 0 auto;
    padding: 12px 16px;
    gap: 8px;
}
.header-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background .15s, opacity .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.input {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    padding: 12px 14px;
    transition: border-color .15s;
    outline: none;
    font-family: inherit;
}
.input:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 100px; }
.hint { font-size: 12px; color: var(--text3); margin-top: 6px; display: block; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: rgba(255,0,68,.12); border: 1px solid rgba(255,0,68,.3); color: #ff6688; }
.hidden { display: none !important; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
}
.badge-pending            { background: rgba(136,136,170,.15); color: var(--text2); }
.badge-generating_prompts { background: rgba(124,106,247,.2); color: var(--accent-h); }
.badge-queued             { background: rgba(255,200,0,.15);   color: #ffc800; }
.badge-processing         { background: rgba(124,106,247,.2); color: var(--accent-h); }
.badge-completed          { background: rgba(62,207,142,.15); color: var(--green); }
.badge-failed             { background: rgba(255,0,68,.15);   color: #ff4466; }

/* ===== LOGIN ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 28px; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-top: 8px;
}
.page-header h2 { font-size: 18px; font-weight: 600; }

/* ===== TASK LIST ===== */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
    display: block;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.task-card:hover { border-color: var(--accent); background: var(--bg3); }
.task-card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.task-title { font-weight: 600; font-size: 15px; flex: 1; }
.task-card-meta { margin-bottom: 10px; }
.meta-prompt { font-size: 13px; color: var(--text2); }
.task-card-stats { display: flex; flex-direction: column; gap: 6px; }
.meta-count { font-size: 12px; color: var(--text3); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .3s;
}

/* ===== TASK INFO ===== */
.task-info-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
}
.task-info-prompt { font-size: 15px; margin-bottom: 8px; }
.task-info-meta { font-size: 12px; color: var(--text3); }

/* ===== SECTION ===== */
.section { margin-bottom: 24px; }
.progress-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 8px;
}
.progress-bar-lg { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress-fill-lg { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s; }
.progress-hint { font-size: 12px; color: var(--text3); margin-bottom: 12px; }

/* ===== SELECTION CTA ===== */
.selection-cta {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.selection-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-item { font-size: 14px; color: var(--text2); }

/* ===== FILTER TABS ===== */
.filter-tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; }
.filter-tab {
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
    background: var(--bg2);
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: .15s;
}
.filter-tab:hover { color: var(--text); border-color: var(--accent); }
.filter-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== TRACK LIST ===== */
.track-list { display: flex; flex-direction: column; gap: 8px; }
.track-item {
    display: flex;
    gap: 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    align-items: flex-start;
}
.track-pending { opacity: .6; }
.track-rate-btns { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.tr-like, .tr-dislike {
    width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: .15s;
}
.tr-like:hover { background: rgba(62,207,142,.15); border-color: var(--green); }
.tr-dislike:hover { background: rgba(255,0,68,.15); border-color: #f04; }
.tr-like.active { background: rgba(62,207,142,.25); border-color: var(--green); }
.tr-dislike.active { background: rgba(255,0,68,.25); border-color: #f04; }
.track-body { flex: 1; min-width: 0; }
.track-title { font-size: 14px; font-weight: 500; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-audio { width: 100%; height: 36px; }
.track-status-err { font-size: 12px; color: #ff4466; }
.track-status-wait { font-size: 12px; color: var(--text3); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text2); }

/* ===== CREATE FORM ===== */
.create-form-wrap { padding-top: 16px; }
.progress-wrap { margin-top: 24px; }
.progress-label { font-size: 14px; color: var(--text2); margin-bottom: 12px; }
.progress-steps { max-height: 200px; overflow-y: auto; margin-top: 12px; }
.prompt-preview {
    font-size: 12px;
    color: var(--text3);
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

/* ===== MINI PLAYER (список треков) ===== */
.mini-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.mp-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}
.mp-play:hover { background: var(--accent-h); }
.mp-play.playing { background: var(--green); }
.mp-bar {
    flex: 1;
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}
.mp-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    pointer-events: none;
}
.mp-time {
    font-size: 12px;
    color: var(--text3);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

/* ===== CRON STATUS ===== */
.cron-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 100;
    background: var(--bg3);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.cron-status-ok  { background: rgba(62,207,142,.15); border-color: var(--green); color: var(--green); }
.cron-status-err { background: rgba(255,0,68,.12); border-color: #f04; color: #ff6688; }

/* ===== UTILS ===== */
.mt-8 { margin-top: 8px; }
.ml-8 { margin-left: 8px; }
.text-small { font-size: 12px; color: var(--text3); }

/* ======================================================
   PLAYER OVERLAY (режим отбора)
   ====================================================== */
.player-overlay {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
    padding-bottom: env(safe-area-inset-bottom);
}

.player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}
.player-task-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-counter { font-size: 13px; color: var(--text3); flex-shrink: 0; }

.player-track-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    gap: 12px;
}
.player-track-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
}
.player-track-prompt {
    font-size: 13px;
    color: var(--text3);
    max-width: 400px;
    line-height: 1.5;
}

.player-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 8px 16px;
    font-size: 14px;
}
.stat-liked { color: var(--green); }
.stat-disliked { color: #ff4466; }
.stat-remaining { color: var(--text2); }

.player-controls {
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Progress bar */
.player-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}
.player-time { font-size: 12px; color: var(--text3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.player-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}
.player-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    width: 0%;
    transition: width .25s linear;
    pointer-events: none;
}

/* Transport buttons */
.player-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.btn-player {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    transition: background .15s, transform .1s;
    background: var(--bg3);
    color: var(--text);
}
.btn-player:active { transform: scale(.95); }
.btn-seek {
    padding: 12px 20px;
    font-size: 14px;
}
.btn-play {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 20px;
    background: var(--accent);
    color: #fff;
}
.btn-play:hover { background: var(--accent-h); }

/* Like / Dislike */
.player-rate-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.btn-rate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px;
    border-radius: var(--radius-lg);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid;
    transition: .15s;
}
.btn-rate:active { transform: scale(.96); }
.btn-dislike {
    background: rgba(255,0,68,.08);
    border-color: rgba(255,0,68,.3);
    color: #ff4466;
}
.btn-dislike:hover { background: rgba(255,0,68,.18); }
.btn-like {
    background: rgba(62,207,142,.08);
    border-color: rgba(62,207,142,.3);
    color: var(--green);
}
.btn-like:hover { background: rgba(62,207,142,.18); }

/* Done screen */
.player-done {
    position: absolute;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 20;
}
.done-icon { font-size: 64px; color: var(--green); }
.done-text { font-size: 20px; font-weight: 600; }

/* При режиме отбора убираем скролл */
.selection-mode { overflow: hidden; position: relative; }
.selection-mode .player-overlay { height: 100vh; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .player-track-title { font-size: 17px; }
    .btn-rate { padding: 16px; font-size: 16px; }
    .btn-play { width: 54px; height: 54px; font-size: 18px; }
    .selection-stats { gap: 10px; }
}

@media (min-width: 600px) {
    .player-controls { max-width: 480px; margin: 0 auto; width: 100%; }
    .player-track-info { padding: 48px 32px; }
}
