/* phone console — trace viewer styles (shared by agentd + hub).
   List: instrument-style table. Detail: sticky step rail on the left, the frame
   viewer on the right; below 900px it stacks with the viewer first. */

/* ---------------------------------------------------------------- list */
.tv-tbl .tbl td { padding-top: 10px; padding-bottom: 10px; }
.tv-tbl .tbl tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tv-goal-t { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  vertical-align: bottom; }
.tv-ro { margin-left: 7px; font: 10px var(--mono); letter-spacing: .06em; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 3px;
  padding: 1px 4px; white-space: nowrap; }

/* ---------------------------------------------------------------- detail */
.container.tv-wide { max-width: 1440px; }

.tv-topline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tv-topline .lbl { letter-spacing: .18em; }
.tv-sid { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 46vw; }

.tv-detail { display: grid; grid-template-columns: minmax(310px, 372px) minmax(0, 1fr);
  gap: 16px; align-items: start; }

/* ---- left rail --------------------------------------------------------- */
.tv-side { position: sticky; top: 66px; display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 84px); min-height: 0; }

.tv-sess { padding: 12px 13px; display: grid; gap: 8px; flex: none; }
.tv-sess-hd { display: flex; align-items: center; gap: 8px; }
.tv-sess-hd .chips { font-size: 13px; font-weight: 650; min-width: 0; }
.tv-sess-hd .chips > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-sess-hd > .badge { margin-left: auto; flex: none; }
.tv-goal { font-size: 14px; line-height: 1.35; letter-spacing: -.005em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tv-sess .tv-assist { justify-self: start; }

.tv-meta { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
  border-top: 1px solid var(--line); padding-top: 9px; }
.tv-meta > div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
  min-width: 0; }
.tv-meta dt { font: 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); flex: none; }
.tv-meta dd { margin: 0; font: 11.5px var(--mono); font-variant-numeric: tabular-nums;
  color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-sess-acts { display: flex; gap: 6px; }
.tv-sess-acts .btn { flex: 1; }

/* step rail */
.tv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--panel);
  box-shadow: var(--shadow); scrollbar-width: thin; flex: 1 1 auto; min-height: 90px; }
.tv-item { position: relative; }
.tv-item + .tv-item { border-top: 1px solid var(--line); }
.tv-row { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px 8px 12px; border: 0; background: transparent; color: var(--fg);
  font: inherit; cursor: pointer; position: relative; }
.tv-row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: transparent; }
.tv-row:hover { background: var(--panel-2); }
.tv-row[aria-current="true"] { background: var(--accent-soft); }
.tv-row[aria-current="true"]::before { background: var(--accent); }
.tv-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tv-glyph { flex: none; width: 30px; height: 22px; display: inline-flex; align-items: center;
  justify-content: center; font: 650 9.5px/1 var(--mono); letter-spacing: .08em;
  color: var(--fg-2); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 4px; }
.tv-row[aria-current="true"] .tv-glyph { color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--panel); }
.tv-row.bad .tv-glyph { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

.tv-rowmain { display: grid; gap: 1px; min-width: 0; flex: 1; }
.tv-rowtop { display: flex; align-items: baseline; gap: 8px; }
.tv-act { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.tv-num { margin-left: auto; font: 10.5px var(--mono); color: var(--muted); flex: none; }
.tv-args { font: 11px var(--mono); color: var(--fg-2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.tv-rowbot { display: flex; align-items: center; gap: 6px; font: 10.5px var(--mono);
  color: var(--muted); }
.tv-rowbot .dot { width: 5px; height: 5px; }
.tv-err { color: var(--bad); font: 10px var(--mono); letter-spacing: .04em; }
.tv-assist-tag { color: var(--warn); font: 10px var(--mono); letter-spacing: .04em; }

.tv-thumb { flex: none; width: 26px; height: 46px; border-radius: 3px; overflow: hidden;
  background: var(--stage); border: 1px solid var(--line); }
.tv-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }

.tv-seg { padding: 6px 12px; background: var(--panel-2); border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); }
.tv-item + .tv-seg { border-top: 0; }
.tv-seg-lbl { display: flex; align-items: baseline; gap: 7px; font: 10px var(--mono);
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tv-seg-lbl b { color: var(--accent); font-weight: 650; }
.tv-nosteps { padding: 16px 12px; }

/* ---- right column ------------------------------------------------------ */
.tv-main { min-width: 0; display: grid; gap: 12px; }

.tv-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 8px 10px;
  position: sticky; top: 62px; z-index: 20;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px); }
.tv-transport { display: flex; align-items: center; gap: 8px; flex: none; }
.tv-bar .btn-primary { min-width: 82px; }
.tv-bar .seg button { padding: 6px 9px; }
.tv-progress { display: flex; align-items: center; gap: 9px; flex: 1 1 200px; min-width: 140px; }
.tv-scrub { flex: 1 1 auto; min-width: 90px; max-width: none; margin: 0; }
.tv-pos { font-size: 11.5px; color: var(--fg-2); white-space: nowrap; min-width: 52px;
  text-align: right; }
.tv-nav { display: flex; align-items: center; gap: 4px; flex: none; }
.tv-hint { white-space: nowrap; margin-right: 4px; }
.tv-follow { font-size: 12px; color: var(--fg-2); white-space: nowrap; margin-right: 6px; }
.tv-follow input { accent-color: var(--accent); }

.tv-stepwrap { display: grid; gap: 12px; min-width: 0; }

.tv-viewhd { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tv-title { font-size: 14.5px; font-weight: 650; }
.tv-ms { font-size: 11px; color: var(--muted); }
.tv-viewhd .grow { flex: 1; }

.tv-compare { display: grid; gap: 12px; min-width: 0; }
.tv-compare[data-mode="slide"] .tv-pair,
.tv-compare[data-mode="after"] .tv-slide { display: none; }
.tv-compare[data-mode="side"] .tv-slide { display: none; }
/* after-only: one column, the after frame alone */
.tv-compare[data-mode="after"] .tv-pair { grid-template-columns: minmax(0, 1fr); }
.tv-compare[data-mode="after"] .tv-frame.before { display: none; }
.tv-compare[data-mode="after"] .tv-screen { width: fit-content; max-width: 100%; margin: 0 auto; }
.tv-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px;
  align-items: stretch; min-width: 0; }
.tv-frame { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.tv-frame figcaption { margin-bottom: 6px; }

/* One screen slot: a bench stage the size of the column, with the phone frame
   scaled to fit and centered. Both frames of a pair are identical boxes, so the
   two halves line up. */
.tv-screen { position: relative; flex: 1 1 auto; display: flex; align-items: center;
  justify-content: center; width: 100%; min-width: 0;
  height: 78vh; max-height: 760px; min-height: 260px;
  background: var(--stage); border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; }
.tv-shot { position: relative; display: block; height: 100%; width: auto;
  aspect-ratio: var(--ar, 9 / 19.5); max-width: 100%; line-height: 0; }
.tv-shot img { display: block; width: 100%; height: 100%; object-fit: contain;
  user-select: none; filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .42)); }
.tv-overlay-l { position: absolute; pointer-events: none; }
.tv-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tv-mark { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none; }
.tv-mark::before { content: ""; position: absolute; inset: 0; border: 2px solid var(--accent);
  border-radius: 50%; background: rgba(232, 161, 60, .18); box-shadow: 0 0 0 3px rgba(0,0,0,.35); }
.tv-mark::after { content: ""; position: absolute; left: 50%; top: 50%; width: 1.5px; height: 26px;
  margin: -13px 0 0 -0.75px; background: var(--accent); transform: rotate(45deg); box-shadow: -25px 0 0 -12px var(--accent); }

/* wipe: before and after share one box and one geometry; the slider clips the after layer */
.tv-slide { position: relative; display: block; width: 100%; max-width: 100%; line-height: 0; }
.tv-slide .tv-screen { width: fit-content; max-width: 100%; margin: 0 auto; }
.tv-slide .tv-shot img { position: absolute; inset: 0; }
.tv-slide input[type="range"] { position: absolute; bottom: 10px; left: 4%; width: 92%; z-index: 3; }

.tv-info { display: grid; gap: 10px; margin-top: 2px; min-width: 0; }
.tv-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 9px; min-width: 0; }
.tv-card-hd { display: flex; align-items: center; gap: 8px; }
.tv-card-hd .grow { flex: 1; }
.tv-card .kv dd { text-align: right; }
.tv-error { font-size: 12.5px; color: var(--bad); background: var(--bad-soft);
  border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); border-radius: var(--r-sm);
  padding: 7px 10px; overflow-wrap: anywhere; }
.tv-json { min-width: 0; }
.tv-json summary { font: 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); cursor: pointer; user-select: none; }
.tv-json summary:hover { color: var(--fg-2); }
.tv-json pre { font: 11.5px/1.5 var(--mono); color: var(--fg-2); white-space: pre-wrap;
  overflow-wrap: anywhere; margin: 7px 0 0; max-height: 240px; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 10px; }
.tv-assist { text-decoration: none; }
a.tv-assist:hover { text-decoration: none; filter: brightness(1.1); }

/* ---- narrow: one column, viewer first ---------------------------------- */
@media (max-width: 900px) {
  .tv-detail { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tv-main { order: 1; }
  .tv-side { order: 2; position: static; max-height: none; }
  .tv-list { max-height: 62vh; }
  .tv-bar { position: static; backdrop-filter: none;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
  .tv-hint { display: none; }
  .tv-progress { order: 3; flex-basis: 100%; }
  .tv-sid { max-width: 52vw; }
  .tv-meta { grid-template-columns: 1fr; }
  .tv-sess .tv-goal { -webkit-line-clamp: 2; }
}

@media (max-width: 760px) {
  .tv-pair { grid-template-columns: minmax(0, 1fr); }
  .tv-screen { height: 58vh; max-height: 560px; }
  .tv-nav { margin-left: auto; }
  .tv-nav .tv-follow { margin-right: 0; }
  .tv-viewhd .seg button { padding: 6px 9px; }
  .tv-tbl .tv-ro { display: none; }
}
