/* Stepwise — waterfall debugger on the site's tokens. */

.sw-body { display: flex; flex-direction: column; min-height: 100vh; }

/* top bar */
.sw-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--card);
}
.sw-brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sw-sep { color: var(--line); }
.sw-name { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.sw-name em { font-style: normal; color: #2458b3; }
.sw-tag { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.sw-controls { display: flex; align-items: center; gap: 18px; }
.sw-filter { font-family: var(--mono); font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; cursor: pointer; }
.sw-filter input { accent-color: var(--signal); }
.sw-controls .btn { padding: 7px 14px; font-size: 13px; }

/* layout */
.sw-app { flex: 1; display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 0; }
@media (max-width: 860px) { .sw-app { grid-template-columns: 1fr; } }

/* run list */
.sw-side { border-right: 1px solid var(--line); padding: 14px 12px; overflow-y: auto; }
@media (max-width: 860px) { .sw-side { border-right: none; border-bottom: 1px solid var(--line); } }
.sw-side-head {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); padding: 0 8px 10px;
}
.sw-side-head::before { content: '— '; color: #2458b3; }
.sw-run {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left; cursor: pointer;
  padding: 10px 12px; margin-bottom: 6px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: none; font-family: var(--sans); color: var(--ink);
}
.sw-run:hover { background: var(--card); border-color: var(--line-soft); }
.sw-run.sel { background: var(--card); border-color: var(--ink-3); box-shadow: inset 3px 0 0 #2458b3; }
.sw-run .nm { font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.sw-run .nm i { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; font-style: normal; }
.sw-run .nm i.ok { background: var(--ok); }
.sw-run .nm i.warn { background: #d9a114; }
.sw-run .nm i.error { background: var(--signal); }
.sw-run .mt { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.sw-side-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; padding: 14px 8px 4px; }

/* run header */
.sw-main { display: flex; flex-direction: column; min-width: 0; }
.sw-runhead {
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
  padding: 16px 22px; border-bottom: 1px solid var(--line); background: var(--card);
}
.sw-runhead h1 { font-family: var(--display); font-weight: 650; font-size: 19px; letter-spacing: -0.01em; }
.sw-runhead .kv { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.sw-runhead .kv b { color: var(--ink); font-weight: 500; }
.sw-runhead .verdict { font-family: var(--mono); font-size: 11px; padding: 3px 10px; border-radius: 99px; }
.sw-runhead .verdict.ok { background: var(--ok-soft); color: var(--ok); }
.sw-runhead .verdict.warn { background: var(--warn-soft); color: var(--warn); }
.sw-runhead .verdict.error { background: var(--signal-soft); color: var(--signal); }

/* spans */
.sw-spans { flex: 1; overflow-y: auto; padding: 14px 22px 26px; }
.sw-span { margin-bottom: 4px; border: 1px solid transparent; border-radius: var(--r-sm); }
.sw-span.open { border-color: var(--line); background: var(--card); }
.sw-span.replaying { animation: sw-in 0.3s ease both; }
@keyframes sw-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.sw-span-row {
  display: grid; grid-template-columns: minmax(180px, 34%) minmax(0, 1fr) 74px;
  gap: 12px; align-items: center; width: 100%;
  padding: 7px 10px; cursor: pointer; border: none; background: none; text-align: left;
  font-family: var(--mono); color: var(--ink);
}
.sw-span-row:hover { background: var(--paper); border-radius: var(--r-sm); }
.sw-span-row .nm {
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 7px;
}
.sw-span-row .nm .kind {
  font-size: 9px; letter-spacing: 0.06em; padding: 1px 6px; border-radius: 3px; flex-shrink: 0;
}
.kind.llm { background: #e9e2f9; color: #6636c7; }
.kind.tool { background: #e3ecfb; color: #2458b3; }
.kind.guard { background: var(--warn-soft); color: var(--warn); }
.sw-span-row .lane { position: relative; height: 14px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.sw-span-row .lane i {
  position: absolute; top: 0; bottom: 0; border-radius: 3px; background: #7fa3dd;
}
.sw-span-row .lane i.ok { background: #7fa3dd; }
.sw-span-row .lane i.warn { background: #e2b13c; }
.sw-span-row .lane i.error { background: #d98079; }
.sw-span-row .ms { font-size: 11px; color: var(--ink-3); text-align: right; white-space: nowrap; }
.sw-span-row .ms b { color: var(--ink); font-weight: 500; }
.d1 .sw-span-row .nm { padding-left: 18px; }
.d2 .sw-span-row .nm { padding-left: 36px; }

/* span detail */
.sw-det { padding: 4px 12px 14px; }
.sw-det .kvs { display: flex; gap: 16px; flex-wrap: wrap; margin: 6px 0 10px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }
.sw-det .kvs b { color: var(--ink); font-weight: 500; }
.sw-det .lbl {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); margin: 10px 0 5px;
}
.sw-det pre {
  background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  padding: 10px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: var(--ink-2); overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.sw-det .err { border-color: #ecc7c3; background: var(--signal-soft); color: #7c2f29; }

/* status bar */
.sw-status {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 22px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
}
.sw-back { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.sw-back:hover { color: var(--ink); }
