:root {
    --bg: #f4f6fb;
    --text: #1f2937;
    --card: #ffffff;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #2563eb14;
    --danger: #dc2626;
    --danger-light: #dc262614;
    --ok: #16a34a;
    --ok-light: #16a34a14;
    --warning: #f59e0b;
    --warning-light: #f59e0b18;
    --border: #d9e0ea;
    --sidebar: #1e293b;
    --sidebar-text: #f8fafc;
    --sidebar-hover: #334155;
    --shadow-sm: 0 1px 3px rgba(30,41,59,.06);
    --shadow-md: 0 8px 24px rgba(30,41,59,.08);
    --shadow-lg: 0 16px 40px rgba(30,41,59,.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    --focus-ring: 0 0 0 3px rgba(37,99,235,.35);
}

html.dark {
    --bg: #0b1220;
    --text: #e2e8f0;
    --card: #111827;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #3b82f614;
    --danger: #ef4444;
    --danger-light: #ef444414;
    --ok: #22c55e;
    --ok-light: #22c55e14;
    --warning: #fbbf24;
    --warning-light: #fbbf2418;
    --border: #243243;
    --sidebar: #020617;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
    --shadow-md: 0 8px 24px rgba(0,0,0,.25);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.35);
    --focus-ring: 0 0 0 3px rgba(59,130,246,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif; font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* --- Scrollbars --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #8aa0be44; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #8aa0be88; border: 2px solid transparent; background-clip: content-box; }
html.dark ::-webkit-scrollbar-thumb { background: #475569; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; border: 2px solid transparent; background-clip: content-box; }

/* --- App Shell --- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar); color: var(--sidebar-text); padding: 20px 16px; display: flex; flex-direction: column; gap: 8px; transition: width var(--transition-slow), transform var(--transition-slow); overflow-y: auto; overflow-x: hidden; position: relative; z-index: 20; }
.sidebar a { color: var(--sidebar-text); text-decoration: none; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); transition: background var(--transition-fast), color var(--transition-fast); position: relative; }
.sidebar a:hover { background: var(--sidebar-hover); }
.sidebar a.active { background: var(--sidebar-hover); color: #fff; }
.sidebar a.active::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.content-area { flex: 1; padding: 24px 28px; overflow: auto; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-md); animation: slide-up .2s ease-out; transition: box-shadow var(--transition-base), transform var(--transition-base); }
.muted { color: var(--muted); }
.error-msg { color: var(--danger); min-height: 24px; margin-top: 8px; font-size: 14px; }

/* --- Focus & Accessibility --- */
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; box-shadow: none; }

/* --- Form Elements --- */
input, textarea, select, button { font-size: 16px; border-radius: var(--radius-md); border: 1px solid var(--border); padding: 10px 12px; transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast); font-family: inherit; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: var(--focus-ring); outline: none; }
input, textarea { background: var(--card); color: var(--text); }
button { min-height: 44px; background: var(--primary); color: white; cursor: pointer; border: none; font-weight: 500; transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast); }
button:hover:not([disabled]) { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
button:active:not([disabled]) { transform: scale(0.97); }
button[disabled] { opacity: .5; cursor: not-allowed; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { width: min(480px, 92vw); }
.login-card form { display: grid; gap: 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.book-card { cursor: pointer; transition: transform var(--transition-base), box-shadow var(--transition-base); }
.book-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.book-card-title { font-size: 18px; font-weight: 600; line-height: 1.4; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.book-card-info { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 20px; font-size: 13px; font-weight: 500; background: var(--primary-light); color: var(--primary); border: 1px solid #2563eb30; transition: background var(--transition-fast); }
.badge-lang { background: var(--ok-light); color: var(--ok); border-color: #16a34a30; }
.badge-status-running { background: var(--ok-light); color: var(--ok); border-color: #16a34a30; }
.badge-status-done { background: var(--ok-light); color: var(--ok); border-color: #16a34a30; }
.badge-status-draft { background: var(--warning-light); color: var(--warning); border-color: #f59e0b30; }

.header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.header-row h2 { margin: 0; }

.form-grid { display: grid; gap: 16px; margin: 16px 0; }
.form-group { display: grid; gap: 4px; }
.form-group label { font-weight: 500; font-size: 15px; color: var(--text); }
.required { color: var(--danger); }

select { background: var(--card); color: var(--text); appearance: auto; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--ok); }
.btn-success:hover:not([disabled]) { background: #15803d; }
.btn-warning { background: var(--warning); color: #1f2937; }
.btn-warning:hover:not([disabled]) { background: #d97706; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.detail-info { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0; font-size: 15px; }
.detail-info dt { color: var(--muted); }
.file-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.file-row:last-child { border-bottom: none; }
.file-row .filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn-danger { background: var(--danger); }

.upload-zone { border: 2px dashed var(--border); border-radius: 12px; padding: 24px; text-align: center; transition: border-color var(--transition-fast), background var(--transition-fast); cursor: pointer; }
.upload-zone:hover { border-color: var(--muted); }
.upload-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }

.progress-bar { height: 10px; background: #cbd5e1; border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--primary); }

.timeline { border-left: 2px solid var(--border); padding-left: 16px; display: grid; gap: 10px; }
.timeline .step { padding: 8px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }

.chat-wrap { display: grid; gap: 8px; max-height: 70vh; overflow-y: auto; padding: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.msg { border-radius: 12px; padding: 8px 12px; max-width: 80%; }
.msg.system { margin: 0 auto; background: #9ca3af20; text-align: center; }
.msg.progress { background: #3b82f620; }
.msg.log { background: #64748b20; }
.msg.ask_user { background: #f59e0b2a; border: 1px solid #f59e0b; animation: pulse 1.2s infinite; }
.msg.result { background: #22c55e26; border: 1px solid var(--ok); }
.msg.error { background: #ef444433; border: 1px solid var(--danger); }
.msg.user_reply { margin-left: auto; background: #2563eb26; border: 1px solid var(--primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(2,6,23,.45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade-in 0.15s ease-out; }
.modal { width: min(560px, 96vw); background: var(--card); border-radius: var(--radius-lg); padding: 20px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: slide-up-in 0.2s ease-out; }
.ask-user-inline { border: 1px solid #f59e0b; border-radius: 10px; padding: 10px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; }
th { font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: var(--bg); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--primary-light); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.tabs button { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -2px; min-height: 40px; font-weight: 500; transition: color var(--transition-fast), border-color var(--transition-fast); }
.tabs button:hover { color: var(--text); background: transparent; }
.tabs button.active { background: transparent; color: var(--primary); border-bottom-color: var(--primary); }

.wizard-progress { display: flex; gap: 4px; margin-bottom: 16px; }
.wizard-progress .step-dot { width: 100%; height: 4px; border-radius: 2px; background: var(--border); }
.wizard-progress .step-dot.active { background: var(--primary); }
.wizard-progress .step-dot.done { background: var(--ok); }

.wizard-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 12px 0; }
.wizard-choice-card { cursor: pointer; padding: 14px; border: 2px solid var(--border); border-radius: 12px; transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base); }
.wizard-choice-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.wizard-choice-card.selected { border-color: var(--primary); background: var(--primary-light); }
.wizard-choice-card h4 { margin: 0 0 4px; }
.wizard-choice-card p { margin: 0; color: var(--muted); font-size: 14px; }

.wizard-summary { display: grid; gap: 8px; }
.wizard-summary-item { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; gap: 8px; }
.wizard-summary-item .label { color: var(--muted); }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 16px; gap: 8px; }

@keyframes slide-up { from { transform: translateY(6px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,.45); } 50% { box-shadow: 0 0 0 8px rgba(245,158,11,0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up-in { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse-border { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.4); } 50% { box-shadow: 0 0 0 6px rgba(37,99,235,0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ============================================================
   RESPONSIVE — TABLET (≤1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { width: 200px; padding: 16px 12px; }
    .content-area { padding: 20px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .split-view-sidebar { width: 180px; min-width: 180px; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤767px)
   ============================================================ */
@media (max-width: 767px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; overflow-x: auto; gap: 4px; padding: 12px; }
    .sidebar a.active::before { top: auto; bottom: 0; left: 8px; right: 8px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
    .sidebar-footer { margin-top: 0; flex-direction: row; border-top: none; padding-top: 0; }
    .content-area { padding: 16px; }
    .grid { grid-template-columns: 1fr; }
    .split-view { flex-direction: column; }
    .split-view-sidebar { width: 100% !important; min-width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border); max-height: 200px; }
    .split-view-main { min-height: 50vh; }
    .pipeline-stepper { padding: 0 8px; }
    .ask-modal { width: 96vw; padding: 16px; }
    .header-row { flex-direction: column; align-items: stretch; }
    .detail-info { grid-template-columns: 1fr; }
    .book-card-title { white-space: normal; }
}

/* ============================================================
   1. BREADCRUMB NAVIGATION
   ============================================================ */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0 0 16px; padding: 0; font-size: 14px; color: var(--muted); }
.breadcrumb a { color: var(--muted); text-decoration: none; transition: color var(--transition-fast); padding: 2px 4px; border-radius: var(--radius-sm); }
.breadcrumb a:hover { color: var(--primary); background: var(--primary-light); }
.breadcrumb .separator { margin: 0 2px; opacity: .5; user-select: none; }
.breadcrumb .separator::before { content: '›'; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

/* ============================================================
   2. SPLIT VIEW LAYOUT
   ============================================================ */
.split-view { display: flex; min-height: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); overflow: hidden; }
.split-view-sidebar { width: 220px; min-width: 220px; border-right: 1px solid var(--border); overflow-y: auto; padding: 12px 0; background: var(--card); flex-shrink: 0; }
.split-view-sidebar a,
.split-view-sidebar .split-item { display: flex; align-items: center; gap: 8px; padding: 8px 16px; color: var(--text); text-decoration: none; font-size: 14px; transition: background var(--transition-fast); cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.split-view-sidebar a:hover,
.split-view-sidebar .split-item:hover { background: var(--primary-light); }
.split-view-sidebar a.active,
.split-view-sidebar .split-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; border-right: 2px solid var(--primary); }
.split-view-main { flex: 1; padding: 16px 20px; overflow-y: auto; min-width: 0; }

/* ============================================================
   3. ENHANCED BOOK CARDS
   ============================================================ */
.book-card-progress { width: 100%; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.book-card-progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.4s ease; }
.book-card-progress.ok > span { background: var(--ok); }
.book-card-progress.danger > span { background: var(--danger); }
.book-card-stage { font-size: 12px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-card-action { display: inline-flex; align-items: center; justify-content: center; padding: 4px 12px; font-size: 13px; min-height: 30px; border-radius: var(--radius-sm); background: var(--primary); color: #fff; border: none; cursor: pointer; margin-left: auto; transition: background var(--transition-fast); }
.book-card-action:hover { background: var(--primary-hover); }
.book-card-action.action-ok { background: var(--ok); }
.book-card-action.action-ok:hover { background: #15803d; }
.book-card-action.action-gray { background: var(--border); color: var(--text); }
.book-card-action.action-gray:hover { background: var(--muted); color: #fff; }
.book-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.book-card-footer .book-card-info { display: flex; gap: 12px; font-size: 14px; color: var(--muted); }

/* ============================================================
   4. PIPELINE STEPPER — HORIZONTAL
   ============================================================ */
.pipeline-stepper { display: flex; align-items: flex-start; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; padding: 12px 4px; }
.pipeline-step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 80px; position: relative; scroll-snap-align: center; }
.pipeline-step-circle { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: var(--muted); position: relative; z-index: 1; transition: all var(--transition-base); }
.pipeline-step-line { position: absolute; top: 14px; left: calc(50% + 14px); right: calc(-50% + 14px); height: 2px; background: var(--border); z-index: 0; }
.pipeline-step:last-child .pipeline-step-line { display: none; }
.pipeline-step-label { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Done */
.pipeline-step.done .pipeline-step-circle { background: var(--ok); border-color: var(--ok); color: #fff; }
.pipeline-step.done .pipeline-step-circle::after { content: '✓'; }
.pipeline-step.done .pipeline-step-line { background: var(--ok); }
/* Active */
.pipeline-step.active .pipeline-step-circle { background: var(--primary); border-color: var(--primary); color: #fff; animation: pulse-border 1.5s infinite; }
.pipeline-step.active .pipeline-step-label { color: var(--primary); font-weight: 600; }
/* Pending (default — uses base styles) */
.pipeline-step.pending .pipeline-step-circle { border-color: var(--border); background: var(--card); color: var(--muted); }
/* Error */
.pipeline-step.error .pipeline-step-circle { background: var(--danger); border-color: var(--danger); color: #fff; }
.pipeline-step.error .pipeline-step-circle::after { content: '✕'; }
.pipeline-step.error .pipeline-step-label { color: var(--danger); }

/* ============================================================
   5. PIPELINE STEPPER — VERTICAL (sidebar)
   ============================================================ */
.pipeline-vertical { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--border); margin-left: 12px; padding: 4px 0; }
.pipeline-vertical-step { display: flex; align-items: center; gap: 10px; padding: 6px 12px; min-height: 32px; font-size: 14px; color: var(--text); position: relative; cursor: pointer; transition: background var(--transition-fast), color var(--transition-fast); border: none; background: none; text-align: left; width: 100%; }
.pipeline-vertical-step::before { content: ''; position: absolute; left: -7px; top: 50%; transform: translateY(-50%); width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); background: var(--card); transition: all var(--transition-fast); z-index: 1; }
.pipeline-vertical-step:hover { background: var(--primary-light); }
.pipeline-vertical-step.active { background: var(--primary-light); color: var(--primary); font-weight: 500; border-left: none; }
.pipeline-vertical-step.active::before { border-color: var(--primary); background: var(--primary); }
.pipeline-vertical-step.done::before { border-color: var(--ok); background: var(--ok); }
.pipeline-vertical-step.error::before { border-color: var(--danger); background: var(--danger); }
.pipeline-vertical-step .step-icon { width: 18px; text-align: center; flex-shrink: 0; }
.pipeline-vertical-step .step-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   6. ASK-USER SUPPLEMENTAL STYLES
   ============================================================
   Core ask-overlay / ask-modal / ask-choice-card styles are
   defined in the "Ask-User Full-Screen Overlay Modal" section
   below. The following supplement with class aliases used by
   the generic overlay pattern.
   ============================================================ */
.ask-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); padding-left: 16px; border-left: 4px solid var(--warning); }
.ask-header h3 { margin: 0; font-size: 18px; }
.ask-question { font-size: 15px; line-height: 1.7; color: var(--text); margin-bottom: 16px; white-space: pre-wrap; }
.ask-choice-card .choice-number { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }

/* ============================================================
   7. STATUS BADGES
   ============================================================ */
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 13px; font-weight: 500; line-height: 1.4; }
.status-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-badge.running { background: var(--primary-light); color: var(--primary); }
.status-badge.running::before { background: var(--primary); animation: pulse-border 1.5s infinite; }
.status-badge.completed { background: var(--ok-light); color: var(--ok); }
.status-badge.completed::before { background: var(--ok); }
.status-badge.failed { background: var(--danger-light); color: var(--danger); }
.status-badge.failed::before { background: var(--danger); }
.status-badge.queued { background: var(--warning-light); color: var(--warning); }
.status-badge.queued::before { background: var(--warning); }
.status-badge.idle { background: rgba(100,116,139,.1); color: var(--muted); }
.status-badge.idle::before { background: var(--muted); }

/* ============================================================
   8. TOOLTIP (pure CSS)
   ============================================================ */
.tooltip { position: relative; }
.tooltip::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); background: var(--sidebar); color: var(--sidebar-text); padding: 5px 10px; border-radius: var(--radius-sm); font-size: 13px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--transition-fast), transform var(--transition-fast); z-index: 60; box-shadow: var(--shadow-sm); }
.tooltip::before { content: ''; position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--sidebar); pointer-events: none; opacity: 0; transition: opacity var(--transition-fast); z-index: 60; }
.tooltip:hover::after,
.tooltip:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.tooltip:hover::before,
.tooltip:focus-visible::before { opacity: 1; }
/* Tooltip bottom variant */
.tooltip-bottom::after { bottom: auto; top: calc(100% + 8px); }
.tooltip-bottom::before { bottom: auto; top: calc(100% + 3px); border-top-color: transparent; border-bottom-color: var(--sidebar); }

/* ============================================================
   9. GENERAL POLISH
   ============================================================ */

/* --- Heading hierarchy --- */
h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin: 0 0 8px; }
h2 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 0 0 6px; }
h3 { font-size: 18px; font-weight: 600; line-height: 1.4; margin: 0 0 4px; }
h4 { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 0 0 4px; }

/* --- Section divider --- */
.section-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* --- Empty state --- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .6; }
.empty-state h3 { color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 15px; max-width: 360px; margin: 0 auto; }

/* --- Loading spinner --- */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* --- Skeleton loading --- */
.skeleton { background: linear-gradient(90deg, var(--border) 25%, transparent 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: var(--radius-sm); }

/* --- Link base style --- */
.content-area a:not(.btn-secondary):not(.book-card):not(.wizard-choice-card):not(.sidebar a) { color: var(--primary); transition: color var(--transition-fast); }

/* --- Workflow card polish --- */
.wf-card { cursor: pointer; transition: border-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base); }
.wf-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* ============================================================
   10. UTILITY CLASSES
   ============================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.items-center { align-items: center; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 18px; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.mt-xs { margin-top: 4px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.p-sm { padding: 8px; }
.p-md { padding: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.border { border: 1px solid var(--border); }
.shadow { box-shadow: var(--shadow-md); }
.clickable { cursor: pointer; }

/* === Session & Replay Styles === */
.replay-msg {
    opacity: 0.6;
    border-left: 3px solid #94a3b8;
    padding-left: 8px;
}
.replay-banner {
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
    padding: 4px 0;
    border-bottom: 1px dashed #cbd5e1;
    margin: 8px 0;
}
.queue-info {
    text-align: center;
    color: #f59e0b;
    font-weight: 500;
    padding: 8px;
    background: #fefce8;
    border-radius: 6px;
    margin: 4px 0;
}
#session-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(0,0,0,0.05);
    font-size: 0.8rem;
}

/* === xterm.js Terminal === */
.terminal-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
}
#terminal-container {
    flex: 1;
    min-height: 0;
    background: #1e1e1e;
    border-radius: 8px;
    padding: 4px;
    margin: 4px 0;
    overflow: hidden;
    position: relative;
}
#terminal-container .xterm {
    padding: 8px;
    height: 100%;
}
#terminal-container .xterm-viewport {
    overflow-y: auto !important;
}
#system-messages {
    max-height: 60px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
    font-size: 0.85rem;
    color: var(--muted);
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#system-messages:empty {
    display: none;
}
#ask-user-area {
    border-top: 1px solid var(--border);
}
#ask-user-area:empty {
    border-top: none;
}

/* === Pipeline Progress Stepper === */

/* ── Compact (mini bar for book cards) ── */
.pp-compact { margin-top: 8px; }
.pp-compact-bar { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; }
.pp-seg { flex: 1; border-radius: 2px; background: var(--border); transition: background .3s; }
.pp-seg--done   { background: var(--ok); }
.pp-seg--active { background: var(--primary); animation: pp-pulse 1.4s ease-in-out infinite; }
.pp-seg--error  { background: var(--danger); }
.pp-compact-label { font-size: 12px; margin-top: 4px; }

/* ── Full (horizontal stepper) ── */
.pp-full-wrap {
    overflow-x: auto;
    padding: 12px 0 8px;
    -webkit-overflow-scrolling: touch;
}
.pp-full-track {
    display: inline-flex;
    align-items: flex-start;
    gap: 0;
    padding: 0 8px;
    min-width: max-content;
}
.pp-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}
.pp-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 14px;
    border: 2px solid var(--border);
    background: var(--card);
    position: relative;
    cursor: default;
    transition: border-color .2s, box-shadow .2s;
    z-index: 1;
}
.pp-circle--done   { border-color: var(--ok); background: #16a34a18; }
.pp-circle--active { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.2); animation: pp-pulse 1.4s ease-in-out infinite; }
.pp-circle--error  { border-color: var(--danger); background: #dc262618; }
.pp-circle--pending { border-color: var(--border); opacity: .55; }

.pp-step-name {
    font-size: 11px;
    margin-top: 6px;
    white-space: nowrap;
    color: var(--muted);
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.pp-line {
    width: 28px;
    height: 2px;
    background: var(--border);
    align-self: center;
    margin-top: 15px;
    flex-shrink: 0;
    transition: background .3s;
}
.pp-line--done { background: var(--ok); }

/* Tooltip */
.pp-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--sidebar);
    color: var(--sidebar-text);
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    pointer-events: none;
}
.pp-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--sidebar);
}
.pp-circle:hover .pp-tooltip { display: block; }

/* ── Vertical (sidebar list) ── */
.pp-vert { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.pp-vert-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 13px;
    transition: background .15s;
}
.pp-vert-icon {
    width: 18px; height: 18px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    flex-shrink: 0;
}
.pp-vert-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pp-vert-item--done   .pp-vert-icon { color: var(--ok); }
.pp-vert-item--active .pp-vert-icon { color: var(--primary); }
.pp-vert-item--error  .pp-vert-icon { color: var(--danger); }
.pp-vert-item--pending .pp-vert-icon { color: var(--muted); }

.pp-vert-item--active {
    background: #2563eb14;
    border: 1px solid #2563eb30;
    font-weight: 500;
}
.pp-vert-item--done   { opacity: .75; }
.pp-vert-item--pending { opacity: .5; }

/* Pulse animation for active step */
@keyframes pp-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,.35); }
    50%      { box-shadow: 0 0 0 6px rgba(37,99,235,0); }
}

/* === Ask-User Full-Screen Overlay Modal === */
.ask-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(2,6,23,.6);
    display: grid;
    place-items: center;
    padding: 16px;
    opacity: 0;
    transition: opacity .3s ease;
}
.ask-overlay-visible {
    opacity: 1;
}
.ask-overlay-visible .ask-modal {
    transform: translateY(0);
    opacity: 1;
}
.ask-modal {
    width: min(680px, 96vw);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--card);
    border: 2px solid #f59e0b;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35), 0 0 0 1px rgba(245,158,11,.15);
    transform: translateY(24px);
    opacity: 0;
    transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .3s ease;
    animation: ask-border-pulse 2s ease-in-out infinite;
}
@keyframes ask-border-pulse {
    0%,100% { box-shadow: 0 20px 60px rgba(0,0,0,.35), 0 0 0 0 rgba(245,158,11,.35); }
    50%     { box-shadow: 0 20px 60px rgba(0,0,0,.35), 0 0 12px 4px rgba(245,158,11,.18); }
}
.ask-modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 24px;
    font-size: 20px;
    font-weight: 700;
    border-left: 5px solid #f59e0b;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.ask-modal-icon {
    font-size: 26px;
    line-height: 1;
}
.ask-modal-body {
    padding: 20px 24px 24px;
    display: grid;
    gap: 20px;
}
.ask-modal-question {
    font-size: 17px;
    line-height: 1.75;
    margin: 0;
    color: var(--text);
    white-space: pre-wrap;
}
.ask-choices {
    display: grid;
    gap: 10px;
}
.ask-choice-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 60px;
    padding: 14px 18px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-size: 16px;
    color: var(--text);
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.ask-choice-card:hover {
    border-color: #f59e0b;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(245,158,11,.15);
}
.ask-choice-card:active {
    transform: translateY(0);
}
.ask-choice-card.selected {
    border-color: #f59e0b;
    background: #f59e0b18;
    box-shadow: 0 0 0 3px rgba(245,158,11,.25);
}
.ask-choice-num {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #f59e0b20;
    color: #f59e0b;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.ask-choice-text {
    flex: 1;
    line-height: 1.5;
}
.ask-freeform {
    display: grid;
    gap: 10px;
}
.ask-freeform .ask-input {
    width: 100%;
    resize: vertical;
    font-size: 15px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
}
.ask-freeform .ask-input:focus {
    outline: none;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245,158,11,.18);
}
.ask-freeform .ask-submit-btn {
    justify-self: end;
    padding: 10px 28px;
    background: #f59e0b;
    color: #fff;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
}
.ask-freeform .ask-submit-btn:hover {
    background: #d97706;
}
.ask-modal-submitted {
    opacity: .55;
    pointer-events: none;
}
/* Inline variant (backward compat for render()) */
.ask-user-inline-v2 {
    position: relative;
    background: var(--card);
    border: 2px solid #f59e0b;
    border-radius: 14px;
    animation: pulse 1.2s infinite;
}
.ask-user-inline-v2 .ask-modal-header {
    font-size: 17px;
    padding: 12px 16px;
}
.ask-user-inline-v2 .ask-modal-body {
    padding: 12px 16px 16px;
}
.ask-user-inline-v2 .ask-modal-question {
    font-size: 15px;
}

/* ============================================================
   MONITOR TOP BAR & SPLIT VIEW OVERRIDES
   ============================================================ */
.monitor-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.monitor-title { margin: 0; font-size: 1.1rem; white-space: nowrap; }
.monitor-book-name { font-size: 0.9rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.monitor-status { font-size: 0.85rem; white-space: nowrap; }
.monitor-current-step { font-size: 0.85rem; color: var(--primary); white-space: nowrap; display: none; }
.monitor-split-view .split-view { border: none; border-radius: 0; }
.monitor-split-view .split-view-main { padding: 0; }

.btn-back {
    background: none; border: 1px solid var(--border); padding: 4px 10px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem;
    color: var(--text); transition: background var(--transition-fast);
}
.btn-back:hover { background: var(--primary-light); }
.btn-danger-sm {
    background: #dc3545; color: #fff; border: none; padding: 5px 12px;
    border-radius: 6px; cursor: pointer; font-size: 0.85rem;
}
.btn-danger-sm:hover { background: #c82333; }
.btn-sm {
    background: none; border: 1px solid var(--border); padding: 5px 12px;
    border-radius: 6px; cursor: pointer; font-size: 0.85rem; color: var(--text);
}
.btn-sm:hover { background: var(--primary-light); }
.btn-sidebar-toggle { display: none; background: none; border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; color: var(--text); }

/* Desktop: sidebar always visible, toggle hidden */
@media (min-width: 768px) {
    .btn-sidebar-toggle { display: none !important; }
    .monitor-current-step { display: none !important; }
    #pipeline-sidebar.sidebar-collapsed { width: 220px; min-width: 220px; display: block; }
}

/* Mobile: sidebar collapsible */
@media (max-width: 767px) {
    .btn-sidebar-toggle { display: inline-block; }
    .monitor-current-step { display: inline-block; }
    .monitor-title { font-size: 0.95rem; }
    .monitor-book-name { max-width: 120px; font-size: 0.8rem; }
    #pipeline-sidebar {
        width: 100% !important; min-width: 100% !important;
        border-right: none !important; border-bottom: 1px solid var(--border);
        max-height: 240px; overflow-y: auto;
        transition: max-height 0.25s ease;
    }
    #pipeline-sidebar.sidebar-collapsed {
        max-height: 0; overflow: hidden; padding: 0;
        border-bottom: none;
    }
}

/* ── Step Detail Panel ─────────────────────────────────── */
.step-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100%;
    background: var(--card);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 12px rgba(0,0,0,.08);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .25s ease;
    overflow: hidden;
}
.step-detail-panel.visible {
    transform: translateX(0);
}
.step-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.step-detail-header h3 {
    margin: 0;
    font-size: 1rem;
}
.step-detail-icon {
    font-size: 1.5rem;
}
.step-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.step-detail-body h4 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
}
.step-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.btn-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--muted);
    padding: 4px 8px;
    border-radius: 4px;
}
.btn-close:hover {
    background: var(--border);
    color: var(--text);
}

.step-detail-status.badge--pending {
    background: var(--border);
    color: var(--muted);
    border: 1px solid var(--border);
}
.step-detail-status.badge--active {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 32%, transparent);
}
.step-detail-status.badge--done {
    background: color-mix(in srgb, var(--ok) 12%, transparent);
    color: var(--ok);
    border: 1px solid color-mix(in srgb, var(--ok) 32%, transparent);
}
.step-detail-status.badge--error {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
}

/* Sub-agent cards */
.sub-agent-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sub-agent-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}
.sub-agent-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.sub-agent-name {
    font-weight: 600;
    font-size: 0.9rem;
}

/* ── PDF Tools Panel ────────────────────────────── */
.pdf-tools-page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.pdf-tools-header { margin-bottom: 24px; }
.pdf-tools-header h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.pdf-tools-header p { margin: 0; }

.pdf-tools-grid { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .pdf-tools-grid { grid-template-columns: 1fr; } }

.pdf-tools-upload-card, .pdf-tools-files-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; box-shadow: var(--shadow-sm);
}
.pdf-tools-upload-card h3, .pdf-tools-files-card h3 {
    font-size: 16px; font-weight: 600; margin: 0 0 14px; color: var(--text);
}

.pdf-drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 32px 16px;
    text-align: center; transition: border-color var(--transition-base), background var(--transition-base);
    display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
}
.pdf-drop-zone:hover, .pdf-drop-zone.drag-over {
    border-color: var(--primary); background: var(--primary-light);
}
.pdf-drop-zone .drop-icon { font-size: 36px; }
.pdf-drop-zone .drop-text { font-size: 14px; font-weight: 500; color: var(--text); }
.pdf-drop-zone .drop-sub { font-size: 12px; color: var(--muted); }

.upload-bar-wrap {
    height: 6px; background: var(--border); border-radius: 3px; margin: 12px 0 6px; overflow: hidden;
}
.upload-bar {
    height: 100%; background: var(--primary); border-radius: 3px; width: 0%;
    transition: width 0.3s ease;
}

.compress-settings { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.compress-settings h3 { margin: 0 0 12px; }
.setting-row { margin-bottom: 12px; }
.setting-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; cursor: pointer; }
.setting-input-group { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.setting-input-group input[type="range"] { flex: 1; accent-color: var(--primary); }
.setting-number {
    width: 60px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; text-align: center; background: var(--card); color: var(--text);
}
.setting-unit { font-size: 13px; color: var(--muted); }
.setting-hint { display: block; margin-top: 4px; font-size: 12px; }

/* File list table */
.pdf-files-list .empty-state {
    text-align: center; padding: 40px 16px; color: var(--muted);
}
.empty-state .empty-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.empty-state p { margin: 0; font-size: 14px; }

.pdf-files-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.pdf-files-table th {
    text-align: left; padding: 8px 10px; font-size: 12px; font-weight: 600;
    color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}
.pdf-files-table td {
    padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.pdf-files-table tr:last-child td { border-bottom: none; }
.pdf-files-table tr:hover td { background: var(--primary-light); }

.file-name-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name-cell .file-icon { margin-right: 4px; }
.size-cell { white-space: nowrap; color: var(--muted); }
.compressed-cell .compress-done { color: var(--ok); font-weight: 500; }
.compressed-cell .compress-pct { font-size: 11px; color: var(--muted); }
.compressed-cell .compress-pending { color: var(--muted); }

.actions-cell { white-space: nowrap; }
.btn-sm {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); font-size: 13px; cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    margin-right: 4px;
}
.btn-sm:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-sm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm.btn-delete:hover { background: var(--danger-light); border-color: var(--danger); }

.success-msg { color: var(--ok); font-size: 13px; padding: 8px 0; }
.warning-msg { color: var(--warning); font-size: 13px; padding: 8px 0; }
.error-msg { color: var(--danger); font-size: 13px; padding: 8px 0; }
.info-msg { color: var(--primary); font-size: 13px; padding: 8px 0; font-weight: 500; }

.compress-running { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-size: 13px; font-weight: 500; }
.spinner {
    display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.badge--model {
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
}
html.dark .badge--model {
    background: #312e81;
    color: #a5b4fc;
}
.sub-agent-duration {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--muted);
}
.sub-agent-prompt {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sub-agent-actions ul {
    margin: 4px 0 0 0;
    padding-left: 20px;
    font-size: 0.8rem;
}
.sub-agent-actions span {
    font-size: 0.8rem;
    font-weight: 600;
}
.sub-agent-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--muted);
}

/* Pipeline vertical - clickable */
.pp-vert-item.pp-clickable {
    cursor: pointer;
    transition: background .15s ease;
}
.pp-vert-item.pp-clickable:hover {
    background: var(--border);
    border-radius: 4px;
}
.pp-vert-item.pp-selected {
    border-left: 3px solid var(--primary);
    padding-left: 5px;
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

/* No data state */
.step-detail-empty {
    text-align: center;
    color: var(--muted);
    padding: 32px 16px;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .step-detail-panel { width: 100%; }
}
