/* EmbodiedSWE Live: dark theme, system fonts, no external assets. */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2d3645;
  --text: #e6edf3;
  --muted: #9aa7b6;
  --accent: #5eb1ff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --run: #58a6ff;
  --skip: #6e7681;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 20px clamp(12px, 3vw, 32px) 32px;
  max-width: 1400px;
  margin: 0 auto;
}
a { color: var(--accent); }
a:hover { text-decoration: none; }
code { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.02rem; margin-bottom: 12px; color: var(--text); letter-spacing: 0.01em; }
h3 { font-size: 1rem; font-family: var(--mono); }
.muted { color: var(--muted); }
.hint { margin: -6px 0 12px; font-size: 0.85rem; }

/* header */
.site-header { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.site-header .title p { margin: 4px 0 0; }
.live {
  color: var(--bad); font-size: 0.8em; border: 1px solid var(--bad); border-radius: 6px;
  padding: 0 8px; vertical-align: middle;
}
.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip, .badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--border); font-size: 0.85rem; white-space: nowrap;
}
.badge { font-weight: 600; }
.stale-ok { border-color: var(--ok); color: #7ee787; }
.stale-warn { border-color: var(--warn); color: #f2cc60; }
.stale-bad { border-color: var(--bad); color: #ff938a; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.metric {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.metric .k { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.metric .v { font-size: 1.3rem; font-weight: 650; }
.metric .s { color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.metric.warn .v { color: #f2cc60; }
.metric.bad { border-color: var(--bad); }
.metric.bad .v { color: #ff938a; }
.alert {
  margin: 10px 0 0; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--warn);
  background: rgba(210, 153, 34, 0.12); overflow-wrap: anywhere;
}
.alert.stop { border-color: var(--bad); background: rgba(248, 81, 73, 0.12); }
.banner, .note {
  margin: 0 0 14px; padding: 8px 12px; border-radius: var(--radius); font-size: 0.9rem;
}
.banner { border: 1px solid var(--bad); background: rgba(248, 81, 73, 0.12); }
.note { border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); }
[hidden] { display: none !important; }

/* bars */
.bar { position: relative; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: visible; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar .marker {
  position: absolute; top: -4px; width: 2px; height: 14px; background: var(--muted); transform: translateX(-1px);
}

/* layout */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.card.wide { grid-column: 1 / -1; }

/* totals */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; display: flex; flex-direction: column;
}
.tile .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.hero .v { font-size: 2.1rem; color: #7ee787; }
.tile .k { font-size: 0.85rem; }
.tile .s { color: var(--muted); font-size: 0.78rem; }

/* tasks */
.tasks { display: flex; flex-direction: column; gap: 12px; }
.task-card {
  border: 1px solid var(--border); border-left: 4px solid var(--c, var(--accent)); border-radius: var(--radius);
  background: var(--panel-2); padding: 12px 14px;
}
.task-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); }
.task-meta { margin: 4px 0 0; font-size: 0.82rem; }
.reason { margin: 6px 0 0; font-size: 0.88rem; color: #f2cc60; overflow-wrap: anywhere; }
.solve { margin-top: 8px; font-size: 0.82rem; max-width: 520px; }
.solve-bar i { background: var(--c, var(--accent)); }
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel);
}
.pill.ok, .pill.state-done { color: #7ee787; border-color: var(--ok); }
.pill.fail, .pill.state-failed { color: #ff938a; border-color: var(--bad); }
.pill.state-running { color: #a5d6ff; border-color: var(--run); }
.pill.state-unsolved { color: #f2cc60; border-color: var(--warn); }
.pill.state-pending, .pill.muted-pill { color: var(--muted); }

.stepper {
  list-style: none; margin: 12px 0 0; padding: 0; display: grid;
  grid-template-columns: 0.7fr 1fr 1fr 2.4fr 1fr 1fr 1.1fr; gap: 6px;
}
.step {
  position: relative; padding: 8px 8px 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.step .dot { position: absolute; top: 11px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--skip); }
.step .name { font-weight: 650; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.step .detail { font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }
.step .detail > span { display: block; }
.step.st-ok { border-color: rgba(63, 185, 80, 0.55); }
.step.st-ok .dot { background: var(--ok); }
.step.st-running { border-color: var(--run); box-shadow: 0 0 0 1px var(--run) inset; }
.step.st-running .dot { background: var(--run); animation: pulse 1.6s ease-in-out infinite; }
.step.st-failed { border-color: var(--bad); }
.step.st-failed .dot { background: var(--bad); }
.step.st-skipped { opacity: 0.55; border-style: dashed; }
.step.st-pending { opacity: 0.75; }
.step.st-pending .dot { background: transparent; border: 1px solid var(--skip); }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .step.st-running .dot { animation: none; } }
.ladder { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0; }
.rung {
  font-family: var(--mono); font-size: 0.74rem; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border); color: var(--muted);
}
.rung.full { border-color: var(--ok); color: #7ee787; }
.rung.part { border-color: var(--run); color: #a5d6ff; }
.flag { color: #ff938a; }

/* chart */
.chart { width: 100%; max-width: 1100px; height: auto; display: block; margin: 0 auto; }
.chart .gridline { stroke: var(--border); stroke-width: 1; }
.chart .tick, .chart .axis { fill: var(--muted); font-size: 12px; }
.chart .axis { font-size: 13px; }
.chart .ref { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 6 5; }
.chart .ref-label { fill: var(--text); font-size: 12px; }
.chart .best { fill: none; stroke-width: 2.2; }
.chart circle { stroke-width: 2; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 0.82rem; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.lg.ref i { border-top: 2px dashed var(--muted); height: 0; }

/* feed */
.feed { max-height: 420px; overflow-y: auto; scroll-behavior: smooth; }
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-item {
  display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 6px 2px;
  border-bottom: 1px solid var(--border); font-size: 0.86rem;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item .icon { text-align: center; font-weight: 700; color: var(--muted); }
.feed-item .meta { display: block; color: var(--muted); font-size: 0.74rem; }
.feed-item .text { display: block; overflow-wrap: anywhere; }
.feed-item code { color: #d2a8ff; }
.kind-message .icon { color: var(--accent); }
.kind-command .icon { color: #d2a8ff; }
.kind-file_change .icon { color: #7ee787; }
.kind-loop .icon { color: #f2cc60; }
.kind-error .icon, .kind-error .text { color: #ff938a; }
.kind-result .icon { color: #7ee787; }

/* clips */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.clip { margin: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.clip video, .clip-missing { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.clip-missing { display: flex; align-items: center; justify-content: center; font-size: 0.85rem; color: var(--muted); }
.clip.missing video { display: none; }
.clip.missing::before {
  content: "clip not available"; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; background: #000; color: var(--muted); font-size: 0.85rem;
}
.clip figcaption { padding: 6px 10px; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.clip figcaption b { color: var(--text); font-family: var(--mono); font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 10px; }
.cheats { margin-top: 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
td { overflow-wrap: anywhere; }

/* links + footer */
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.links a { font-family: var(--mono); }
.site-footer { margin-top: 24px; font-size: 0.85rem; text-align: center; }
.site-footer p { margin: 4px 0; }

@media (max-width: 1000px) {
  .stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .step:nth-child(4) { grid-column: 1 / -1; }
}
@media (max-width: 800px) {
  .grid { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { font-size: 1.4rem; }
}
