/* ═══════════════════════════════════════════
   Trajectory viewer (/trace/) — loaded by trace_view.html only
   ═══════════════════════════════════════════ */

.container-full {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px 56px;
}

.tv-crumb-sep { opacity: 0.45; margin: 0 2px; }

/* ── viewer layout ── */

.tv-top { padding-top: 40px; padding-bottom: 0; }

.tv-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 292px;
  gap: 24px;
  align-items: start;
}

.tv-hidden { display: none !important; }

.tv-side, .tv-rail { position: sticky; top: 76px; }

.tv-side-inner {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-s);
  padding: 18px;
}

.tv-side-model { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tv-logo { height: 18px; width: auto; filter: var(--logo-invert); }

.tv-side-model h1 {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-b);
  line-height: 1.3;
}

.tv-side-task {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 16px;
}
.tv-side-task a { color: var(--accent); }

.tv-chip {
  font-family: var(--sans);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-m);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 7px;
}

.tv-score { margin-bottom: 18px; }

.tv-score-num {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 700;
  color: var(--text-b);
  line-height: 1;
}
.tv-score-num span { font-size: 17px; color: var(--text-m); }

.tv-score-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--bg-r);
  overflow: hidden;
  margin: 9px 0 5px;
}
.tv-score-bar > span { display: block; height: 100%; background: var(--accent); }
.tv-score-bar-wide { width: 100%; max-width: 260px; margin: 0; }

.tv-score-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-m); }

.tv-stats { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }

.tv-stats-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-m);
  margin-bottom: 6px;
}

.tv-stat { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 2.5px 0; }
.tv-stat-label { color: var(--text-m); white-space: nowrap; }
.tv-stat-label.is-indented { padding-left: 12px; opacity: 0.85; }
.tv-stat-value { font-family: var(--mono); font-size: 11.5px; color: var(--text-b); text-align: right; word-break: break-all; }
.tv-stat-sub { color: var(--text-m); font-weight: 400; }

.tv-side-links { display: flex; flex-direction: column; gap: 7px; border-top: 1px solid var(--border); margin-top: 14px; padding-top: 13px; }
.tv-side-links a { font-size: 12px; color: var(--accent); }
.tv-side-links a:hover { text-decoration: underline; }

.tv-side-id {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-m);
  margin-top: 12px;
  word-break: break-all;
  opacity: 0.75;
}

/* ── viewer tabs + toolbar ── */

.tv-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

.tv-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-m);
  padding: 8px 12px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tv-tab:hover { color: var(--text-b); }
.tv-tab.is-active { color: var(--text-b); border-bottom-color: var(--accent); font-weight: 600; }

.tv-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-s);
  padding: 9px 14px;
  margin-bottom: 16px;
}

.tv-toolbar-meta { font-size: 12px; color: var(--text-m); }
.tv-toolbar-meta strong { font-family: var(--mono); color: var(--text-b); font-weight: 700; }
.tv-toolbar-meta .sep { opacity: 0.5; }
.tv-toolbar-right { display: flex; align-items: center; gap: 10px; }
.tv-dim { color: var(--text-m); opacity: 0.8; }

.tv-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }

.tv-seg-btn {
  background: var(--bg-r);
  border: none;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--text-m);
  padding: 4px 11px;
  cursor: pointer;
}
.tv-seg-btn.is-active { background: var(--accent); color: #fff; font-weight: 600; }

.tv-jump { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }
.tv-jump span { color: var(--text-m); font-size: 12px; }

.tv-jump input {
  width: 62px;
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-b);
}
.tv-jump input:focus { outline: none; }

/* ── viewer timeline ── */

.tv-turn { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 14px; padding-bottom: 18px; }

.tv-gutter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding-top: 3px;
  border-right: 1px solid var(--border);
  padding-right: 12px;
}

.tv-turn-n { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text-b); }
.tv-turn-time, .tv-turn-cost { font-family: var(--mono); font-size: 10px; color: var(--text-m); }
.tv-turn-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tv-turn.is-flash .tv-turn-body { animation: tvFlash 1.2s ease-out; }

@keyframes tvFlash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

.tv-say {
  background: var(--bg-s);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tv-say-empty { color: var(--text-m); font-style: italic; }

.tv-think {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-r);
  font-size: 12.5px;
}

.tv-think > summary {
  cursor: pointer;
  padding: 7px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-m);
  list-style: none;
}
.tv-think > summary::-webkit-details-marker { display: none; }
.tv-think > summary::before { content: '+ '; }
.tv-think[open] > summary::before { content: '– '; }
.tv-think-len { text-transform: none; letter-spacing: 0; opacity: 0.7; margin-left: 6px; }

.tv-think-body {
  padding: 0 12px 11px;
  color: var(--text-m);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 420px;
  overflow-y: auto;
}

.tv-action { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-s); }

.tv-cmd-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 12px;
  background: var(--bg-r);
  border-bottom: 1px solid var(--border);
}

.tv-tool { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-m); }
.tv-rc { font-family: var(--mono); font-size: 10px; color: #ef4444; font-weight: 700; }

.tv-cmd {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-b);
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.tv-prompt-sign { color: var(--accent); font-weight: 700; user-select: none; }

.tv-out { border-top: 1px solid var(--border); }

.tv-out-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-m);
}

.tv-out-toggle {
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.tv-out-body {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text);
  padding: 0 12px 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 620px;
  overflow-y: auto;
}
.tv-out.is-collapsed .tv-out-body {
  max-height: none;
  mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
}
.tv-out-empty, .tv-out-missing { padding: 7px 12px; font-size: 11px; color: var(--text-m); font-style: italic; }

.tv-end { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-m); padding: 6px 0 40px 88px; }
.tv-end-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.tv-skeleton, .tv-note, .tv-error {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-s);
  padding: 16px;
  font-size: 13px;
  color: var(--text-m);
}
.tv-error { display: flex; flex-direction: column; gap: 8px; }
.tv-error strong { color: var(--text-b); }
.tv-error a { color: var(--accent); }
.tv-note { margin-bottom: 14px; }

/* ── viewer right rail ── */

.tv-rail-title, .tv-rail-note {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-m);
  margin-bottom: 8px;
}
.tv-rail-note { margin: 4px 0 0; text-transform: none; letter-spacing: 0; opacity: 0.7; }

.tv-rail-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-s);
  padding: 9px 10px 4px;
  margin-bottom: 10px;
}

.tv-rail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.tv-rail-head > span:first-child { font-size: 11px; color: var(--text-m); }
.tv-rail-val { font-family: var(--mono); font-size: 11px; color: var(--text-b); font-weight: 600; }

.tv-spark { display: block; width: 100%; height: 46px; }
.tv-spark-line { fill: none; stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.tv-spark-area { fill: var(--accent-soft); stroke: none; }
.tv-spark-bar { fill: var(--accent); opacity: 0.75; }

/* ── viewer tests + prompt tabs ── */

.tv-tests-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-s);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text);
}
.tv-tests-head strong { font-family: var(--mono); color: var(--text-b); }

.tv-test-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-s);
  margin-bottom: 8px;
}

.tv-test-group > summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  list-style: none;
}
.tv-test-group > summary::-webkit-details-marker { display: none; }
.tv-test-mod { font-family: var(--mono); font-size: 12.5px; color: var(--text-b); }
.tv-test-count { font-family: var(--mono); font-size: 11px; }
.tv-test-count.is-pass { color: #22c55e; }
.tv-test-count.is-fail { color: #ef4444; }

.tv-test-list { list-style: none; padding: 0 13px 11px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2px 16px; }

.tv-test { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 11.5px; color: var(--text); }
.tv-test-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-m); flex: 0 0 auto; }
.tv-test-passed .tv-test-dot { background: #22c55e; }
.tv-test-failed .tv-test-dot, .tv-test-error .tv-test-dot { background: #ef4444; }
.tv-test-status { font-size: 10px; color: #ef4444; text-transform: uppercase; letter-spacing: 0.5px; }

.tv-prompt-body {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text);
  padding: 0 13px 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 640px;
  overflow-y: auto;
}

@media (max-width: 1280px) {
  .tv-layout { grid-template-columns: 268px minmax(0, 1fr); }
  .tv-rail { grid-column: 1 / -1; position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
  .tv-rail-title, .tv-rail-note { grid-column: 1 / -1; }
}

@media (max-width: 880px) {
  .tv-layout { grid-template-columns: minmax(0, 1fr); }
  .tv-side { position: static; }
  .tv-turn { grid-template-columns: 54px minmax(0, 1fr); gap: 10px; }
  .tv-end { padding-left: 64px; }
}
