/* Part trace: the BOM row hooks, the right-click menu and the player dialog.
   Loaded by index.html (the Review screen) and by trace-player-demo.html.

   Everything is prefixed tp- and nothing here relies on the host page's reset:
   index.html zeroes every margin and sets border-box globally, the demo page
   does neither, and the player has to look the same on both.

   Colours are index.html's own: the grey page ground (#F3F4F6), the slate
   sidebar (#1E293B) for the step list, and the .trace-badge-* palette for the
   rule actions, repeated below as .tp-badge-* because the demo page does not
   carry index.html's stylesheet. */

/* ── Review screen: BOM rows ─────────────────────────────────────────────── */
tr[data-trace-path] { cursor: context-menu; }
tr[data-trace-path]:hover td { background: #F9FAFB; }
tr[data-trace-path]:focus { outline: none; }
tr[data-trace-path]:focus-visible td { background: #EFF6FF; box-shadow: inset 0 2px 0 #2563EB, inset 0 -2px 0 #2563EB; }
tr[data-trace-path].tp-row-open td { background: #EFF6FF; }
.tp-trace-cell { width: 1%; white-space: nowrap; text-align: right; }
.tp-trace-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; border: 1px solid #D1D5DB; background: #fff;
  font: 600 11px system-ui, -apple-system, sans-serif; font-style: normal; color: #4B5563; cursor: pointer;
  opacity: .6; transition: opacity .15s, border-color .15s, color .15s, background .15s;
}
.tp-trace-btn svg { width: 11px; height: 11px; flex: none; }
tr[data-trace-path]:hover .tp-trace-btn, tr[data-trace-path]:focus-within .tp-trace-btn, .tp-trace-btn:focus-visible { opacity: 1; }
.tp-trace-btn:hover, .tp-trace-btn:focus-visible { border-color: #3B82F6; color: #1D4ED8; background: #EFF6FF; outline: none; }
/* No hover on a touch screen, so the affordance cannot depend on one. */
@media (hover: none) { .tp-trace-btn { opacity: 1; } }

/* ── Context menu ────────────────────────────────────────────────────────── */
.tp-menu {
  position: fixed; z-index: 2100; min-width: 250px; max-width: min(360px, calc(100vw - 16px));
  margin: 0; padding: 4px; box-sizing: border-box;
  background: #fff; border: 1px solid #E5E7EB; border-radius: 8px; box-shadow: 0 12px 32px rgba(15, 23, 42, .2);
  font: 13px/1.35 system-ui, -apple-system, sans-serif; color: #111827;
}
.tp-menu-head { padding: 6px 10px 4px; font-size: 11px; color: #6B7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-menu-head b { font-family: 'Courier New', monospace; color: #111827; }
.tp-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; margin: 0;
  padding: 7px 10px; border: 0; border-radius: 5px; background: none;
  font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.tp-menu-item:hover, .tp-menu-item:focus { background: #EFF6FF; color: #1D4ED8; outline: none; }
.tp-menu-item.tp-primary { font-weight: 600; }
.tp-menu-item svg { width: 14px; height: 14px; flex: none; }
.tp-menu-item code { font-family: 'Courier New', monospace; font-weight: 700; }
.tp-menu-sep { height: 1px; margin: 4px 0; background: #F3F4F6; }
.tp-menu-hint { padding: 5px 10px 4px; font-size: 11px; color: #9CA3AF; }

/* ── Player dialog ───────────────────────────────────────────────────────── */
html.tp-lock, html.tp-lock body { overflow: hidden; }

.tp-root {
  --tp-speed: 1;
  position: fixed; inset: 0; z-index: 2000;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  /* One explicit column that may shrink below its content: the implicit
     auto column let a 300-char description push the dialog to 2541px at 1920. */
  grid-template-columns: minmax(0, 1fr);
  background: #F3F4F6; color: #111827;
  font: 14px/1.4 system-ui, -apple-system, sans-serif; text-align: left;
}
.tp-root, .tp-root *, .tp-root *::before, .tp-root *::after { box-sizing: border-box; }
.tp-root h2, .tp-root h3, .tp-root p, .tp-root ol, .tp-root ul, .tp-root table { margin: 0; padding: 0; }
/* A host page's bare h2/h3/p rules (the demo page styles h2 as a small caps
   label) must not reach into the dialog. */
.tp-root h2, .tp-root h3, .tp-root p { text-transform: none; letter-spacing: normal; color: inherit; line-height: inherit; }
/* Rows are placed by name, not by order: the notice is display:none most of
   the time, and auto-placement would then hand the body's 1fr to the footer. */
.tp-root > .tp-head { grid-row: 1; }
.tp-root > .tp-notice { grid-row: 2; }
.tp-root > .tp-body { grid-row: 3; }
.tp-root > .tp-transport { grid-row: 4; }
/* Grid items default to min-width:auto, which is their content's width; the
   rows must be allowed to be narrower than a long title or description so the
   text inside them wraps or clips instead of widening the dialog. */
.tp-root > .tp-head, .tp-root > .tp-body { min-width: 0; }
/* Server strings that have no length limit (descriptions, summaries, option
   labels, the gate text) break anywhere rather than overflow their card. */
.tp-stage-desc, .tp-lk-desc, .tp-gate-text, .tp-result-desc, .tp-result-summary, .tp-emit-meta span, .tp-origin-option { overflow-wrap: anywhere; }
.tp-root button, .tp-root select, .tp-root input { font: inherit; }
.tp-root [hidden] { display: none !important; }
.tp-mono { font-family: 'Courier New', monospace; }
.tp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* "instant" shows every step already built: no transition, no keyframes.
   tp-ff is the same for transitions only, held for the one synchronous pass
   that rebuilds a step up to a given line (pause, seek, previous line). */
.tp-instant *, .tp-instant *::before, .tp-instant *::after { transition: none !important; animation: none !important; }
.tp-ff *, .tp-ff *::before, .tp-ff *::after { transition: none !important; }

.tp-head { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: #fff; border-bottom: 1px solid #E5E7EB; }
.tp-head-main { flex: 1; min-width: 0; }
.tp-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-title .tp-mono { font-size: 17px; }
.tp-sub { font-size: 12px; color: #6B7280; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-crumb-sep { margin: 0 5px; color: #9CA3AF; }
.tp-stats { font-size: 11px; color: #6B7280; text-align: right; white-space: nowrap; }
.tp-close { flex: none; width: 34px; height: 34px; border: 1px solid #E5E7EB; border-radius: 8px; background: #fff; color: #4B5563; cursor: pointer; display: grid; place-items: center; }
.tp-close:hover, .tp-close:focus-visible { background: #F3F4F6; color: #111827; outline: 2px solid #3B82F6; outline-offset: 1px; }
.tp-close svg { width: 14px; height: 14px; }

.tp-notice { padding: 8px 20px; background: #FFFBEB; border-bottom: 1px solid #FDE68A; color: #78350F; font-size: 12.5px; }
.tp-notice b { font-weight: 700; }

/* Side columns follow the viewport so the stage keeps ~680px at 1100 wide
   (fixed 300 + 270 side columns left it 526px, which wrapped every matrix). */
.tp-body { display: grid; grid-template-columns: clamp(220px, 20vw, 300px) minmax(0, 1fr) clamp(200px, 18vw, 270px); min-height: 0; position: relative; }

/* Step list: the app's sidebar colours, so it reads as navigation. */
.tp-timeline { background: #1E293B; color: #CBD5E1; overflow-y: auto; min-height: 0; padding: 10px 0; }
.tp-timeline ol { list-style: none; }
.tp-tl-item {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start; gap: 2px 8px; width: 100%;
  padding: 7px 14px 7px 12px; border: 0; border-left: 3px solid transparent; background: none; color: inherit;
  text-align: left; cursor: pointer; transition: background .15s, opacity .15s;
}
.tp-tl-item:hover { background: #334155; }
.tp-tl-item:focus-visible { outline: 2px solid #93C5FD; outline-offset: -2px; }
.tp-tl-badge { grid-row: span 2; justify-self: start; margin-top: 1px; }
.tp-tl-title { font: 700 12px 'Courier New', monospace; color: #F1F5F9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-tl-gist { font-size: 11.5px; color: #94A3B8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-tl-item.tp-future { opacity: .55; }
.tp-tl-item.tp-cur { background: #1D4ED8; border-left-color: #93C5FD; opacity: 1; }
.tp-tl-item.tp-cur .tp-tl-gist { color: #DBEAFE; }
/* A step the current one consumed: marked, not shouted. */
.tp-tl-item.tp-dep { border-left-color: #F59E0B; opacity: 1; }
.tp-tl-item.tp-dep .tp-tl-title::after { content: ' feeds this'; font: 400 10px system-ui, sans-serif; color: #FCD34D; }
.tp-tl-item.tp-peek { background: #334155; box-shadow: inset 0 0 0 1px #FCD34D; opacity: 1; }

/* Badges: index.html's .trace-badge-* palette, plus three for the non-rule steps. */
.tp-badge { display: inline-block; font: 700 11px 'Courier New', monospace; padding: 2px 6px; border-radius: 4px; background: #F3F4F6; color: #4B5563; white-space: nowrap; }
.tp-badge-MO { background: #DBEAFE; color: #1D4ED8; }
.tp-badge-GV { background: #EDE9FE; color: #6D28D9; }
.tp-badge-CR { background: #DCFCE7; color: #15803D; }
.tp-badge-SV { background: #FEE2E2; color: #B91C1C; }
.tp-badge-CP { background: #F3F4F6; color: #4B5563; }
.tp-badge-MD { background: #FEF3C7; color: #92400E; }
.tp-badge-CN { background: #E0F2FE; color: #0369A1; }
.tp-badge-V2 { background: #FCE7F3; color: #9D174D; }
.tp-badge-origin { background: #E2E8F0; color: #1E293B; }
.tp-badge-explode { background: #CCFBF1; color: #0F766E; }
.tp-badge-result { background: #16A34A; color: #fff; }

/* Stage */
.tp-stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.tp-stage-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 22px 10px; }
.tp-stage-head .tp-badge { font-size: 13px; padding: 3px 8px; }
.tp-stage-id { font: 700 16px 'Courier New', monospace; }
.tp-stage-desc { flex: 1 1 100%; font-size: 13px; color: #374151; white-space: pre-wrap; }
.tp-chip-plain { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #E5E7EB; color: #374151; white-space: nowrap; }
.tp-chip-plain.tp-notheld { background: #F3F4F6; color: #6B7280; border: 1px dashed #9CA3AF; }
.tp-lines { overflow-y: auto; min-height: 0; padding: 4px 22px 18px; display: flex; flex-direction: column; gap: 12px; }

.tp-line { background: #fff; border: 1px solid #E5E7EB; border-radius: 10px; padding: 12px 14px; transition: opacity .2s, border-color .2s; width: 100%; max-width: 1080px; flex: none; }
.tp-line.tp-line-cur { border-color: #93C5FD; box-shadow: 0 0 0 3px rgba(59, 130, 246, .12); }
.tp-line.tp-settled { opacity: .82; }
.tp-line-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #6B7280; margin-bottom: 7px; display: flex; gap: 8px; align-items: baseline; }
.tp-line-label span { font-weight: 400; text-transform: none; letter-spacing: 0; color: #9CA3AF; }

/* Entrances and pulses are keyframes added ONLY on an animated pass, so a
   rebuilt (paused / seeked / instant) step shows the end state with nothing
   left to run. Durations scale with the speed selector. They fill backwards
   only: a forwards fill pinned opacity:1 on a line that had animated in, so it
   ignored .tp-settled while the same line rebuilt by a seek obeyed it. */
@keyframes tp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes tp-pop { 0% { opacity: 0; transform: scale(.6); } 70% { transform: scale(1.12); } 100% { opacity: 1; transform: none; } }
@keyframes tp-flash { 0%, 100% { box-shadow: inset 0 0 0 0 rgba(22, 163, 74, 0); } 40% { box-shadow: inset 0 0 0 2px #16A34A; background: #BBF7D0; } }
@keyframes tp-pulse { 0%, 100% { transform: none; } 50% { transform: scale(1.08); } }
@keyframes tp-glow { 0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .55); } 100% { box-shadow: 0 0 0 9px rgba(37, 99, 235, 0); } }
@keyframes tp-draw { from { stroke-dashoffset: var(--tp-len, 120); } to { stroke-dashoffset: 0; } }
@keyframes tp-drop { 0% { opacity: 0; transform: translateY(-22px); } 70% { opacity: 1; transform: translateY(3px); } 100% { opacity: 1; transform: none; } }
.tp-a-rise { animation: tp-rise calc(320ms / var(--tp-speed)) ease-out backwards; }
.tp-a-pop { animation: tp-pop calc(340ms / var(--tp-speed)) ease-out backwards; }
.tp-a-flash { animation: tp-flash calc(700ms / var(--tp-speed)) ease-in-out 2; }
.tp-a-pulse { animation: tp-pulse calc(520ms / var(--tp-speed)) ease-in-out 2; }
.tp-a-glow { animation: tp-glow calc(800ms / var(--tp-speed)) ease-out 1; }
.tp-a-drop { animation: tp-drop calc(420ms / var(--tp-speed)) ease-out backwards; }

/* Value chips */
.tp-val { display: inline-block; font: 700 12px 'Courier New', monospace; padding: 1px 7px; border-radius: 999px; background: #1E293B; color: #F8FAFC; white-space: pre; vertical-align: baseline; }
.tp-val.tp-blank { background: #F3F4F6; color: #6B7280; font-weight: 400; font-style: italic; border: 1px dashed #9CA3AF; }
.tp-val.tp-green { background: #15803D; }
.tp-val.tp-amber { background: #B45309; }
.tp-val.tp-old { background: #E5E7EB; color: #6B7280; text-decoration: line-through; }
.tp-arrow { color: #6B7280; margin: 0 6px; }

/* condition */
.tp-cond-text { font: 13px/1.9 'Courier New', monospace; color: #374151; white-space: pre-wrap; word-break: break-word; }
.tp-tok { border-radius: 4px; padding: 1px 2px; white-space: nowrap; transition: background .2s, color .2s, box-shadow .2s; }
.tp-tok.tp-on { background: #DBEAFE; color: #1D4ED8; font-weight: 700; box-shadow: 0 0 0 1px #93C5FD; }
.tp-tok-val { margin-left: 4px; font-size: 11px; }
.tp-cond-extra { margin-top: 8px; font-size: 12px; color: #6B7280; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.tp-cond-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; min-height: 30px; }
.tp-verdict { display: inline-block; font: 600 13px system-ui, sans-serif; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; }
.tp-verdict.tp-true { color: #15803D; background: #F0FDF4; }
.tp-verdict.tp-false { color: #6B7280; background: #F9FAFB; }
.tp-verdict-note { font-size: 13px; color: #374151; }

/* lookup */
.tp-lk-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.tp-lk-name { font: 700 15px 'Courier New', monospace; color: #6D28D9; }
.tp-lk-desc { font-size: 12.5px; color: #374151; white-space: pre-wrap; }
.tp-lk-meta { font-size: 11px; color: #9CA3AF; margin-left: auto; white-space: nowrap; }
.tp-matrix-wrap { max-height: min(44vh, 320px); overflow: auto; border: 1px solid #E5E7EB; border-radius: 8px; background: #fff; }
.tp-matrix { border-collapse: collapse; width: 100%; font: 12px 'Courier New', monospace; }
.tp-matrix th { position: sticky; top: 0; z-index: 1; background: #F9FAFB; text-align: left; padding: 6px 10px 5px; border-bottom: 2px solid #E5E7EB; font: 600 11px system-ui, sans-serif; color: #374151; vertical-align: bottom; white-space: nowrap; }
.tp-matrix th .tp-want { display: block; margin-bottom: 4px; font: 400 11px system-ui, sans-serif; color: #1D4ED8; min-height: 18px; }
.tp-matrix th .tp-want.tp-pending { visibility: hidden; }
.tp-want-note { color: #6B7280; font: 400 11.5px system-ui, sans-serif; }
.tp-lk-result .tp-want-note { margin-top: 4px; font-size: 12px; }
.tp-matrix th .tp-th-var { font-family: 'Courier New', monospace; }
.tp-matrix th .tp-th-slot { color: #9CA3AF; font-weight: 400; margin-left: 4px; }
.tp-matrix td { padding: 4px 10px; border-bottom: 1px solid #F3F4F6; white-space: pre; transition: background .16s, opacity .16s, color .16s; }
.tp-matrix td.tp-rownum { color: #9CA3AF; text-align: right; width: 1%; }
.tp-mrow.tp-pending td { opacity: .5; }
.tp-mrow.tp-scan td { background: #FEF9C3; opacity: 1; }
.tp-mrow.tp-dim td { opacity: .34; }
.tp-mrow.tp-hit td { background: #DCFCE7; opacity: 1; font-weight: 700; }
.tp-mrow.tp-hit td.tp-result-cell { color: #15803D; box-shadow: inset 0 0 0 2px #16A34A; }
.tp-mgap td { color: #9CA3AF; font: italic 11.5px system-ui, sans-serif; text-align: center; padding: 3px 10px; background: #FAFAFA; }
.tp-mmiss td { color: #B45309; font: 600 12px system-ui, sans-serif; text-align: center; padding: 6px 10px; background: #FFFBEB; }
/* Once the next line starts, a finished lookup folds down to what mattered. */
.tp-settled .tp-mrow:not(.tp-hit) { display: none; }
.tp-settled .tp-matrix-wrap { max-height: none; }
.tp-lk-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; min-height: 24px; font-size: 13px; }
.tp-lk-result .tp-default-tag { font-size: 11px; font-weight: 700; color: #92400E; background: #FEF3C7; border-radius: 4px; padding: 1px 6px; }

/* assign */
.tp-assign { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 14px 'Courier New', monospace; }
.tp-assign .tp-var { font-weight: 700; color: #1D4ED8; }
.tp-assign .tp-expr { color: #374151; word-break: break-word; white-space: pre-wrap; }
.tp-assign-vals { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: #6B7280; min-height: 22px; }

/* gate */
.tp-gate { display: flex; align-items: center; gap: 16px; }
.tp-gate svg { width: 120px; height: 64px; flex: none; }
.tp-gate path { fill: none; stroke: #CBD5E1; stroke-width: 3; stroke-linecap: round; transition: stroke .25s; }
.tp-gate .tp-gate-on { stroke: #16A34A; stroke-width: 4; }
.tp-gate .tp-gate-off { stroke: #9CA3AF; stroke-width: 4; stroke-dasharray: 5 6; }
.tp-gate-draw { stroke-dasharray: var(--tp-len, 120); animation: tp-draw calc(520ms / var(--tp-speed)) ease-out backwards; }
.tp-gate-verdict { font-weight: 700; font-size: 14px; }
.tp-gate-verdict.tp-true { color: #15803D; }
.tp-gate-verdict.tp-false { color: #6B7280; }
.tp-gate-text { font-size: 12.5px; color: #374151; margin-top: 3px; white-space: pre-wrap; }

/* emit + BOM tray */
.tp-part { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; background: #F0FDF4; border: 1.5px solid #86EFAC; max-width: 100%; }
.tp-part-no { font: 700 15px 'Courier New', monospace; color: #14532D; white-space: pre; }
.tp-part-desc { font-size: 12.5px; color: #374151; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-part-qty { font: 700 13px 'Courier New', monospace; color: #15803D; white-space: nowrap; }
.tp-part.tp-placeholder { background: #FFFBEB; border-color: #FCD34D; border-style: dashed; }
.tp-part.tp-placeholder .tp-part-no { color: #92400E; font-style: italic; }
.tp-oos { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #FEF3C7; color: #92400E; white-space: nowrap; }
.tp-emit-meta { margin-top: 8px; font-size: 12px; color: #6B7280; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.tp-emit-meta code { font-family: 'Courier New', monospace; color: #374151; word-break: break-word; }
.tp-tray { border-top: 1px solid #E5E7EB; background: #fff; padding: 8px 22px 10px; min-height: 58px; max-height: 120px; overflow-y: auto; }
.tp-tray-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #6B7280; margin-bottom: 5px; }
.tp-tray-empty { font-size: 12px; color: #9CA3AF; font-style: italic; }
.tp-tray-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tp-tray-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 6px; background: #F0FDF4; border: 1px solid #86EFAC; font: 700 12px 'Courier New', monospace; color: #14532D; white-space: nowrap; }
.tp-tray-item.tp-placeholder { background: #FFFBEB; border-color: #FCD34D; border-style: dashed; color: #92400E; }
.tp-tray-item.tp-child { background: #F0FDFA; border-color: #5EEAD4; color: #115E59; }
.tp-tray-item.tp-target { box-shadow: 0 0 0 2px #16A34A; }
.tp-tray-item span { font-weight: 400; color: #6B7280; }
.tp-await-fly { visibility: hidden; }

/* detail: a line of the shop paperwork header */
.tp-paper { font: 13px 'Courier New', monospace; background: #FFFDF5; border: 1px solid #FDE68A; border-radius: 6px; padding: 9px 12px; display: flex; align-items: baseline; gap: 8px; }
.tp-paper-label { font-weight: 700; color: #78350F; white-space: pre; }
.tp-paper-dots { flex: 1; border-bottom: 2px dotted #D6D3D1; transform: translateY(-3px); min-width: 24px; }
.tp-paper-value { font-weight: 700; color: #111827; white-space: pre; }
.tp-paper.tp-notprinted { background: #F9FAFB; border-color: #E5E7EB; border-style: dashed; }
.tp-paper.tp-notprinted .tp-paper-label, .tp-paper.tp-notprinted .tp-paper-value { color: #9CA3AF; text-decoration: line-through; }
.tp-paper-meta { margin-top: 7px; font-size: 12px; color: #6B7280; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.tp-notprinted-tag { font-size: 10.5px; font-weight: 700; color: #6B7280; background: #F3F4F6; border: 1px solid #D1D5DB; border-radius: 4px; padding: 1px 6px; }

/* origin */
.tp-origin { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.tp-origin-field { background: #F9FAFB; border: 1px solid #E5E7EB; border-radius: 8px; padding: 9px 12px; min-width: 200px; max-width: 100%; }
.tp-origin-screen { font-size: 10.5px; color: #9CA3AF; text-transform: uppercase; letter-spacing: .05em; }
.tp-origin-label { font-size: 12px; font-weight: 600; color: #374151; text-transform: uppercase; letter-spacing: .04em; margin: 1px 0 6px; }
.tp-origin-option { display: inline-block; padding: 5px 12px; border-radius: 6px; background: #2563EB; color: #fff; font-size: 13px; font-weight: 600; }
.tp-origin-option.tp-muted { background: #E5E7EB; color: #4B5563; }
.tp-origin-arrow { font-size: 20px; color: #6B7280; }
.tp-origin-var { display: inline-flex; align-items: center; gap: 6px; font: 700 14px 'Courier New', monospace; color: #1D4ED8; }
.tp-origin-note { flex: 1 1 100%; font-size: 12px; color: #6B7280; }

/* explode */
.tp-tree { font: 13px 'Courier New', monospace; }
.tp-tree-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; white-space: nowrap; }
.tp-tree-elbow { color: #94A3B8; flex: none; white-space: pre; }
.tp-tree-part { font-weight: 700; padding: 2px 8px; border-radius: 6px; background: #F0FDFA; border: 1px solid #5EEAD4; color: #115E59; }
.tp-tree-row.tp-tree-root .tp-tree-part { background: #F0FDF4; border-color: #86EFAC; color: #14532D; }
.tp-tree-row.tp-tree-new .tp-tree-part { box-shadow: 0 0 0 2px #14B8A6; }
.tp-tree-desc { font: 12.5px system-ui, sans-serif; color: #374151; overflow: hidden; text-overflow: ellipsis; }
.tp-tree-qty { font-weight: 700; color: #0F766E; }
.tp-tree-src { font: 600 10.5px system-ui, sans-serif; color: #0F766E; background: #CCFBF1; border-radius: 4px; padding: 1px 6px; }

/* result */
.tp-result { border: 2px solid #16A34A; border-radius: 12px; background: #F0FDF4; padding: 16px 18px; }
.tp-result-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.tp-result-no { font: 700 22px 'Courier New', monospace; color: #14532D; white-space: pre; }
.tp-result-qty { font: 700 15px 'Courier New', monospace; color: #15803D; }
.tp-result-desc { font-size: 14px; color: #374151; }
.tp-result-path { margin-top: 6px; font: 12.5px 'Courier New', monospace; color: #4B5563; }
.tp-result-summary { margin-top: 10px; font-size: 14px; line-height: 1.5; color: #111827; }
.tp-recap { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #86EFAC; }
.tp-recap-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #15803D; margin-bottom: 6px; }
.tp-recap-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 4px; }
.tp-recap-link { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #BBF7D0; background: #fff; border-radius: 999px; padding: 2px 9px 2px 3px; font: 12px 'Courier New', monospace; color: #111827; cursor: pointer; }
.tp-recap-link:hover, .tp-recap-link:focus-visible { border-color: #16A34A; outline: none; box-shadow: 0 0 0 2px rgba(22, 163, 74, .25); }
.tp-recap-link .tp-badge { font-size: 10px; padding: 1px 5px; border-radius: 999px; }
.tp-recap-sep { color: #86EFAC; font-weight: 700; }
.tp-recap-more { font-size: 12px; color: #6B7280; }

.tp-generic { font: 12px 'Courier New', monospace; color: #374151; white-space: pre-wrap; word-break: break-word; }

/* Variables */
.tp-vars { background: #fff; border-left: 1px solid #E5E7EB; overflow-y: auto; min-height: 0; padding: 12px 14px 16px; }
.tp-vars-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #6B7280; }
.tp-vars-hint { font-size: 11px; color: #9CA3AF; margin: 2px 0 8px; }
.tp-vars-group { margin-top: 10px; }
.tp-vars-group-label { font-size: 11px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.tp-vars-list { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.tp-var-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  border: 1px solid #E5E7EB; background: #F9FAFB; border-radius: 6px; padding: 2px 4px 2px 8px;
  font: 12px 'Courier New', monospace; color: #111827; cursor: pointer; text-align: left;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.tp-var-chip:hover, .tp-var-chip:focus-visible { border-color: #3B82F6; outline: none; }
.tp-var-chip .tp-var-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-var-chip .tp-val { font-size: 11px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.tp-var-chip.tp-read { border-color: #2563EB; background: #EFF6FF; box-shadow: 0 0 0 3px rgba(59, 130, 246, .22); }
.tp-var-chip.tp-new { border-color: #16A34A; background: #F0FDF4; }
.tp-vars-empty { font-size: 12px; color: #9CA3AF; font-style: italic; margin-top: 8px; }

/* Transport */
.tp-transport { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: #fff; border-top: 1px solid #E5E7EB; }
.tp-btn { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 1.5px solid #D1D5DB; border-radius: 8px; background: #fff; color: #374151; cursor: pointer; transition: background .15s, border-color .15s; }
.tp-btn svg { width: 15px; height: 15px; }
.tp-btn:hover:not(:disabled) { background: #EFF6FF; border-color: #3B82F6; color: #1D4ED8; }
.tp-btn:focus-visible, .tp-root select:focus-visible, .tp-root input:focus-visible { outline: 2px solid #3B82F6; outline-offset: 2px; }
.tp-btn:disabled { opacity: .4; cursor: not-allowed; }
.tp-btn.tp-play { width: 44px; background: #2563EB; border-color: #2563EB; color: #fff; }
.tp-btn.tp-play:hover:not(:disabled) { background: #1D4ED8; border-color: #1D4ED8; color: #fff; }
.tp-scrub { flex: 1; min-width: 80px; accent-color: #2563EB; }
.tp-status { font-size: 12px; color: #4B5563; white-space: nowrap; min-width: 190px; text-align: right; font-variant-numeric: tabular-nums; }
.tp-speed { padding: 6px 8px; border: 1.5px solid #D1D5DB; border-radius: 7px; background: #fff; color: #374151; font-size: 13px; }
.tp-instant-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #374151; white-space: nowrap; cursor: pointer; }
.tp-keys { font-size: 11px; color: #9CA3AF; white-space: nowrap; }
@media (max-width: 1320px) { .tp-keys { display: none; } }

/* Loading / error, over the body */
.tp-state { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #F3F4F6; padding: 24px; }
.tp-state-card { max-width: 560px; background: #fff; border: 1px solid #E5E7EB; border-radius: 12px; padding: 24px 28px; text-align: center; }
.tp-state-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.tp-state-card p { font-size: 13.5px; color: #4B5563; white-space: pre-wrap; word-break: break-word; }
.tp-state-card .tp-state-detail { margin-top: 8px; font-size: 12px; color: #9CA3AF; }
.tp-state-card.tp-error { border-color: #FECACA; }
.tp-state-card.tp-error h3 { color: #991B1B; }
.tp-state-actions { margin-top: 16px; display: flex; gap: 10px; justify-content: center; }
.tp-textbtn { padding: 8px 18px; border-radius: 7px; border: 1.5px solid #D1D5DB; background: #F3F4F6; color: #374151; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.tp-textbtn:hover, .tp-textbtn:focus-visible { background: #E5E7EB; outline: none; }
.tp-textbtn.tp-primary { background: #2563EB; border-color: #2563EB; color: #fff; }
.tp-textbtn.tp-primary:hover, .tp-textbtn.tp-primary:focus-visible { background: #1D4ED8; }
.tp-spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid #93C5FD; border-top-color: #2563EB; border-radius: 50%; animation: tp-spin .7s linear infinite; margin-bottom: 10px; }
@keyframes tp-spin { to { transform: rotate(360deg); } }

/* A value chip in flight to the variables strip / the BOM tray. */
.tp-fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 10; overflow: hidden; }
.tp-flyer { position: fixed; margin: 0; transition: transform calc(560ms / var(--tp-speed)) cubic-bezier(.3, .1, .2, 1), opacity calc(560ms / var(--tp-speed)) ease-in; will-change: transform; }

@media (prefers-reduced-motion: reduce) { .tp-spinner { animation-duration: 2.4s; } }
