:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-input: #252836;
    --text: #e4e6eb;
    --text-muted: #8b8fa3;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --border: #2d3044;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}
.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 0.9rem;
}
.nav-links a:hover { color: var(--text); }

/* Hero */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}
.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* URL form */
.url-form { max-width: 640px; margin: 0 auto; }
.input-group {
    display: flex;
    gap: 0.5rem;
}
.input-group input {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.input-group input:focus {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s, opacity 0.2s;
    color: var(--text);
    background: var(--bg-input);
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-input); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-download { background: var(--success); color: #fff; }

/* Loading */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Video info */
.video-info {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin: 1.5rem 0;
    text-align: left;
}
.thumbnail {
    width: 200px;
    border-radius: var(--radius);
    flex-shrink: 0;
}
.video-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--bg-input);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 0.5rem;
}
.badge-platform {
    background: var(--primary);
    color: #fff;
}

/* Formats table */
.formats-table {
    margin: 1rem 0;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
}
h3 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.1rem;
}

/* Progress */
.progress-card {
    text-align: center;
    padding: 2rem;
}
.progress-done { color: var(--success); }
.progress-error { color: var(--danger); }
.error-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem 0;
}
.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Bots section */
.bots-section {
    padding: 2.5rem 0 1rem;
    text-align: center;
}
.bots-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}
.bots-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}
.bots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    max-width: 700px;
    margin: 0 auto;
}
.bot-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
    text-align: left;
}
.bot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.bot-card-telegram {
    background: linear-gradient(135deg, rgba(0,136,204,0.1), rgba(0,136,204,0.03));
    border-color: rgba(0,136,204,0.3);
}
.bot-card-telegram:hover { border-color: rgba(0,136,204,0.6); }
.bot-card-telegram .bot-icon { color: #0088cc; }
.bot-card-max {
    background: linear-gradient(135deg, rgba(255,100,50,0.1), rgba(255,100,50,0.03));
    border-color: rgba(255,100,50,0.3);
}
.bot-card-max:hover { border-color: rgba(255,100,50,0.6); }
.bot-card-max .bot-icon { color: #ff6432; }
.bot-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bot-icon img {
    border-radius: 10px;
}
.bot-info { flex: 1; }
.bot-info h3 { margin: 0 0 0.1rem; font-size: 1.05rem; }
.bot-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}
.bot-info p {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.bot-arrow {
    font-size: 1.3rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.bots-note {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 560px;
    margin: 1.25rem auto 0;
    padding: 0.85rem 1.1rem;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius);
    text-align: left;
}
.bots-note-icon {
    font-size: 1.8rem;
    color: var(--primary);
    flex-shrink: 0;
    line-height: 1;
}
.bots-note p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

/* Features */
.features { padding: 3rem 0; }
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.feature-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid var(--border);
}
.feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.feature-card p { color: var(--text-muted); font-size: 0.85rem; }

/* Footer */
.footer {
    margin-top: auto;
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}
.footer a { color: var(--primary); text-decoration: none; }

/* Admin */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0;
}
.admin-nav { display: flex; gap: 0.5rem; }
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.card h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    color: var(--text-muted);
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}
.stat-row span { color: var(--text-muted); }
.worker-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Admin table */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
.admin-table { font-size: 0.85rem; }
.admin-table code { font-size: 0.8rem; color: var(--text-muted); }
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-completed { background: rgba(34,197,94,0.15); color: var(--success); }
.status-failed { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-pending { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-processing { background: rgba(99,102,241,0.15); color: var(--primary); }

.actions { white-space: nowrap; }
.actions .btn { margin-right: 0.25rem; }

/* Admin login */
.admin-login {
    text-align: center;
    padding: 4rem 0;
}
.admin-login h1 { margin-bottom: 0.5rem; }
.telegram-login-wrap { margin: 2rem 0; }

/* Forms */
.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.input-wide {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.form-group input {
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    width: 120px;
}

.alert { padding: 1rem; border-radius: var(--radius); margin: 1rem 0; }
.alert-warning { background: rgba(245,158,11,0.15); color: var(--warning); }

/* Responsive */
@media (max-width: 640px) {
    .hero h1 { font-size: 1.75rem; }
    .input-group { flex-direction: column; }
    .video-info { flex-direction: column; }
    .thumbnail { width: 100%; }
    .admin-header { flex-direction: column; align-items: flex-start; }
}
