:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}
h1, h2, h3, h4 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}
.monospace { font-family: 'Inter', monospace; }

/* Header */
.header {
    background: #1e293b;
    color: white;
    padding: 1rem 2rem;
    border-bottom: 3px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-logo h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}
.header-logo p {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: #94a3b8;
}
.auth-badge {
    background: #334155;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.btn-logout {
    background: none;
    border: none;
    color: white;
    font-size: 0.875rem;
    cursor: pointer;
}
.btn-logout:hover { opacity: 0.8; }

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

/* Tabs */
.tabs {
    display: flex;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}
.tab {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent);
    position: relative;
}
.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.card h2 {
    margin-top: 0;
    font-size: 1.25rem;
    font-weight: 600;
}
.card-centered {
    max-width: 32rem;
    margin-left: auto;
    margin-right: auto;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: var(--bg);
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.drop-zone.drag-over {
    border-color: var(--accent);
    background: #eff6ff;
}
.drop-zone svg {
    width: 48px;
    height: 48px;
    color: var(--accent);
    margin-bottom: 1rem;
}
.drop-zone p {
    margin: 0;
    color: var(--text-muted);
}

/* Buttons */
button {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    font-weight: 500;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border: none;
}
.btn-danger:hover { background: #fecaca; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }

/* Inputs */
input, select {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    width: 100%;
}
input:focus, select:focus {
    border-color: var(--accent);
    outline: 2px solid #eff6ff;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }

/* Markdown preview */
.markdown-preview {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}
.markdown-preview pre {
    background: #1e293b;
    color: #f1f5f9;
    padding: 1rem;
    overflow-x: auto;
    border-radius: 6px;
}
.markdown-preview code { font-family: 'Inter', monospace; }

/* Loading overlay */
.loading {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.loading.active { display: flex; }
.loading-card {
    background: var(--card);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}
.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid var(--card);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Grid */
.grid { display: grid; gap: 2rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

/* Utility */
.hidden { display: none !important; }
.flex { display: flex; }
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.p-2 { padding: 0.5rem; }
.bg-gray-100 { background: #f1f5f9; }
.text-xs { font-size: 0.875rem; }
.text-sm { font-size: 0.95rem; }
.block { display: block; }
.error { color: var(--error); }
.success { color: var(--success); }
.gap-half { gap: 0.5rem; }
.border-top { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.separator {
    margin: 1rem 0;
    border: none;
    border-top: 1px solid var(--border);
}

/* Jobs list */
.job-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

/* API Keys */
.key-value {
    font-family: 'Inter', monospace;
    background: #f1f5f9;
    padding: 0.5rem;
    border-radius: 6px;
}

/* Pro Tab */
#tab-pro .card {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    border: 1px solid #bfdbfe;
}
.pro-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Login card */
.login-card { max-width: 32rem; margin: 0 auto; }
.login-divider {
    margin: 1rem 0;
    border: none;
    border-top: 1px solid var(--border);
}
.page-selection {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}
.page-labels label {
    margin-right: 1rem;
}
.jobs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.empty-state {
    text-align: center;
    opacity: 0.5;
    padding: 2rem 0;
}
.pro-contact {
    font-family: monospace;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* TOC Tree */
#toc-tree {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg);
}
.toc-level { margin: 0; padding-left: 0; }
.toc-row:hover { background: #f1f5f9; }
.toc-arrow { user-select: none; }

/* Page Thumbnails */
.page-thumb-wrapper { transition: all 0.15s; }
.page-thumb-wrapper:hover { border-color: var(--accent) !important; }

/* Signup key box */
.signup-key-box {
    background: #f0fdf4;
    border: 1px solid var(--success);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
}

/* Page thumbnails grid */
#page-thumbnails {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
}
#page-thumbnails.visible {
    display: flex;
}
.page-thumb-wrapper {
    width: 80px;
    height: 110px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.page-thumb-wrapper canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
