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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #dc2626;
    --bg: #f8fafc;
    --card-bg: #fff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
}

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

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}

h1 { font-size: 28px; margin-bottom: 24px; }
h2 { font-size: 20px; margin-bottom: 16px; }

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

/* Card */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.card-thumb {
    aspect-ratio: 4/3;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 32px;
    color: var(--text-muted);
}

.card-body { padding: 12px 16px; }
.card-body h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-ready { background: #dcfce7; color: #166534; }
.badge-converting { background: #fef3c7; color: #92400e; animation: pulse 1.5s infinite; }
.badge-pending { background: #f1f5f9; color: #475569; }
.badge-error { background: #fecaca; color: #991b1b; }

@keyframes pulse { 50% { opacity: 0.7; } }

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; width: 100%; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--primary); }

/* Dropzone */
.dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: #eef2ff;
}
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.dropzone-icon { font-size: 48px; margin-bottom: 12px; }
.dropzone-content p { font-size: 14px; color: var(--text); }

.dropzone-file {
    font-size: 14px;
    font-weight: 500;
    display: flex;
    gap: 12px;
    justify-content: center;
}
.dropzone-file span:last-child { color: var(--text-muted); }

/* Progress */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
}

/* Detail page */
.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
}
.back-link:hover { color: var(--text); }

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.detail-header h1 { margin-bottom: 0; }

.status-card {
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.status-card.converting { background: #fef3c7; }
.status-card.pending { background: #f1f5f9; }
.status-card.error { background: #fecaca; }

.action-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.section { margin-bottom: 32px; }

.embed-code {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.embed-code textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'SF Mono', monospace;
    font-size: 12px;
    resize: none;
    background: #f8fafc;
}

.thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}
.thumb-grid img {
    width: 100%;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.danger-zone {
    border-top: 1px solid #fecaca;
    padding-top: 24px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 24px;
}
.empty-state h2 { color: var(--text-muted); font-weight: 500; }
.empty-state p { color: var(--text-muted); margin-bottom: 24px; }

/* Conversion tracker */
.conversion-tracker {
    margin: 32px 0;
}

.tracker-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
    border-left: 3px solid var(--primary);
    margin-left: 13px;
    padding-left: 24px;
    position: relative;
}

.tracker-step:last-child {
    border-left-color: transparent;
}

.tracker-step.pending {
    border-left-color: var(--border);
    opacity: 0.5;
}

.tracker-step.pending .tracker-spinner {
    display: none;
}

.tracker-step.completed {
    border-left-color: #22c55e;
}

.tracker-step.failed {
    border-left-color: var(--danger);
}

.tracker-icon {
    position: absolute;
    left: -15px;
    top: 14px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-radius: 50%;
}

.tracker-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.tracker-step.pending .tracker-icon {
    background: var(--bg);
}

.tracker-step.pending .tracker-icon::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
}

.tracker-info {
    flex: 1;
    min-width: 0;
}

.tracker-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.tracker-step.completed .tracker-label {
    color: #166534;
}

.tracker-step.failed .tracker-label {
    color: var(--danger);
}

.tracker-detail {
    font-size: 13px;
    color: var(--text-muted);
}

.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }
