:root {
  --bg: #f3f4f6; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #111827; --accent-ink: #fff; --blue: #2563eb; --err: #b91c1c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle; }
.by { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 10px; }
.meta { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .by, .meta { display: none; } }
.wrap { max-width: 820px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; margin-bottom: 18px; }
h2 { margin: 0 0 6px; font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--err); font-size: 13px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 8px 0 4px; }
input[type=file] { display: block; width: 100%; font-size: 13px; margin-bottom: 6px; }
input[type=password], textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 9px 11px; font: inherit; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.row.end { justify-content: flex-end; align-items: center; }
button { border: 1px solid #d1d5db; background: #fff; color: var(--ink); border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; counter-reset: s; }
.steps li { flex: 1; text-align: center; padding: 8px; border-radius: 8px; background: #e5e7eb; color: var(--muted); font-size: 13px; font-weight: 600; }
.steps li.active { background: var(--accent); color: #fff; }
.steps li.done { background: #d1fae5; color: #065f46; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); background: #f3f4f6; border-radius: 8px; padding: 8px 12px; margin: 6px 0 4px; min-height: 34px; }
.status.done { background: #d1fae5; color: #065f46; }
.status .spin { width: 12px; height: 12px; border: 2px solid #cbd5e1; border-top-color: var(--blue); border-radius: 50%; animation: spinr .8s linear infinite; flex: none; }
.status .spin[hidden] { display: none; }
@keyframes spinr { to { transform: rotate(360deg); } }
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 6px 2px; margin-top: 10px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.bubble.assistant { background: #f3f4f6; align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.user { background: var(--blue); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.thinking { color: var(--muted); font-style: italic; }
.stages { margin: 10px 0 12px; }
.stage-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.stage { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #e5e7eb; color: var(--muted); }
.stage.active { background: var(--blue); color: #fff; }
.stage.done { background: #d1fae5; color: #065f46; }
.elapsed { margin-left: auto; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.bar > div { height: 100%; width: 2%; background: var(--blue); border-radius: 999px; transition: width .4s ease; }
.bar.done > div { background: #059669; }
/* live stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 8px 10px; text-align: center; border: 1px solid #1e293b; }
.stat-v { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: #67e8f9; transition: transform .15s; }
.stat-v.bump { transform: scale(1.12); }
.stat-l { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #64748b; margin-top: 2px; }

/* terminal */
.term { margin-top: 12px; border-radius: 10px; overflow: hidden; border: 1px solid #1e293b; box-shadow: 0 10px 30px rgba(2, 6, 23, .25); }
.term-bar { display: flex; align-items: center; gap: 6px; background: #1e293b; padding: 7px 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: #94a3b8; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.r { background: #f87171; } .dot.y { background: #fbbf24; } .dot.g { background: #34d399; }
.term-title { margin-left: 8px; letter-spacing: .04em; }
.term-status { margin-left: auto; color: #34d399; }
.term-status.done { color: #a5b4fc; } .term-status.fail { color: #fca5a5; }
.progress { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; background: #0b1220; color: #cbd5e1; padding: 12px 14px; height: 300px; overflow-y: auto; white-space: pre-wrap;
  background-image: radial-gradient(ellipse at top left, rgba(56, 189, 248, .06), transparent 60%); }
.progress > div { animation: lineIn .25s ease-out; }
.progress .ts { color: #475569; margin-right: 8px; }
.progress .l-search { color: #67e8f9; }
.progress .l-search .q { color: #f0f9ff; background: rgba(103, 232, 249, .12); padding: 0 4px; border-radius: 3px; }
.progress .l-edgar { color: #fbbf24; }
.progress .l-ok { color: #86efac; }
.progress .l-fail { color: #fca5a5; }
.progress .l-warn { color: #fdba74; }
.progress .l-stage { color: #f8fafc; font-weight: 700; margin-top: 6px; }
.progress .l-stage::before { content: "══ "; color: #38bdf8; }
.progress .cost { color: #64748b; }
.progress .cursor { display: inline-block; width: 8px; height: 13px; background: #67e8f9; vertical-align: -2px; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@keyframes lineIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* progress bar shimmer + active stage pulse */
.bar.running > div { background-image: linear-gradient(90deg, var(--blue) 0%, #60a5fa 40%, var(--blue) 80%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.stage.active { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .45); } 50% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0); } }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.report { margin-top: 16px; }
details { margin-top: 14px; font-size: 13px; }
pre { background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; }
@media print {
  .top, .steps, .term, .stages, #reportActions, #profileBox, #step1, #step2, h2 { display: none !important; }
  body { background: #fff; } .card { border: 0; padding: 0; }
}
