.has-probes { --lab-ink: #514d47; --lab-muted: #817a70; --lab-faint: #a29b91; --lab-border: #ddd8d0; --lab-edge: #bdb5a8; --lab-hover: #f2efea; --lab-selected: #e9e3d9; --lab-accent: #6c6356; }
.lab-badge { display: inline-block; margin-left: 8px; padding: 4px 7px; vertical-align: middle; border: 1px solid var(--lab-border); border-radius: 5px; color: var(--lab-ink); font-size: 10px; font-weight: 500; letter-spacing: .01em; }
.lab-intro { margin: 13px 0 0; color: var(--lab-ink); font-size: 12px; line-height: 1.6; }
.lab-intro a { margin-left: 6px; color: var(--lab-muted); text-decoration-color: var(--lab-border); text-underline-offset: 3px; }
::highlight(lab-selection) { background-color: #ded7cb; color: #423d35; }
::highlight(lab-citation) { background-color: #e5ddcf; color: #4f4638; }
.lab-panel, .lab-history, .lab-shelf { color: var(--lab-ink); font: 13px/1.55 ui-sans-serif, system-ui, sans-serif; overflow-wrap: anywhere; }
.lab-panel { position: relative; flex: none; width: auto; padding: 4px; background: #fffefd; border: 1px solid var(--lab-border); border-radius: 12px; box-shadow: 0 2px 7px #29251f0c; }
.lab-panel[hidden], .lab-history[hidden] { display: none; }
.lab-panel button, .lab-history button, .lab-shelf button, .has-probes .lab-history-toggle { font: inherit; }
.has-probes .lab-panel button, .has-probes .lab-history button, .has-probes .lab-shelf button { color: var(--lab-ink); border: 0; background: transparent; padding: 6px 9px; border-radius: 6px; }
.has-probes .lab-panel button:hover, .has-probes .lab-history button:hover, .has-probes .lab-shelf button:hover { color: var(--lab-ink); background: var(--lab-hover); }
.has-probes .lab-shelf button:focus-visible, .has-probes .lab-history button:focus-visible, .has-probes .lab-panel button:focus-visible, .has-probes .lab-search-pointer:focus-visible { outline: 2px solid var(--lab-accent); outline-offset: 2px; }
.has-probes .lab-panel button:disabled, .has-probes .lab-shelf button:disabled { opacity: .4; cursor: default; }
.lab-actions { display: flex; gap: 3px; }
.lab-actions button { flex: 1; white-space: nowrap; }
.has-probes .lab-panel .lab-actions button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; font-size: 12px; font-weight: 500; }
.lab-panel .lab-icon { margin: 0; }
.lab-icon { width: 15px; height: 15px; vertical-align: -3px; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.has-probes .lab-copy-button { flex: 0 0 28px; display: grid; place-items: center; width: 28px; height: 28px; padding: 0 !important; }
.lab-copy-button .lab-icon { display: block; width: 14px; height: 14px; margin: 0; vertical-align: 0; }
.lab-selection-quote { margin: 0 0 12px; padding-left: 10px; border-left: 2px solid var(--lab-edge); color: var(--lab-muted); font-size: 12px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.lab-conversation { max-height: min(340px, 42dvh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.lab-turn { padding: 10px 0; border-top: 1px solid var(--lab-border); }
.lab-turn:first-child { border-top: 0; padding-top: 0; }
.lab-turn-label { display: block; margin-bottom: 4px; color: var(--lab-faint); font-size: 10px; }
.lab-turn[data-role="user"] .lab-turn-text { color: var(--lab-ink); }
.lab-turn-text { white-space: pre-wrap; }
.lab-citations { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 6px; }
.lab-citations button { padding: 3px 6px !important; font-size: 10px !important; background: var(--lab-hover) !important; }
.lab-composer { display: flex; gap: 7px; align-items: flex-end; margin-top: 6px; border: 1px solid var(--lab-border); border-radius: 8px; padding: 6px; background: #fff; }
.lab-composer:focus-within { border-color: var(--lab-edge); box-shadow: 0 0 0 2px #8c827412; }
.lab-composer textarea { display: block; width: 100%; min-height: 22px; max-height: 110px; padding: 0 3px; resize: none; border: 0; border-radius: 0; background: transparent; color: var(--lab-ink); font: 13px/22px ui-sans-serif, system-ui, sans-serif; }
.has-probes .lab-composer textarea:focus-visible { outline: 0; }
.lab-composer textarea::placeholder { color: var(--lab-faint); }
.has-probes .lab-composer .lab-send { flex: none; padding: 1px 7px; color: #fff; background: var(--lab-accent); font-size: 17px; }
.has-probes .lab-composer .lab-send:hover { background: var(--lab-accent); color: #fff; }
.lab-footnote { color: var(--lab-faint); font-size: 10px; margin: 7px 0 0; }
.lab-error { color: #985841; font-size: 12px; margin: 10px 0; }
.lab-setup-link { display: inline-block; margin-right: 8px; padding: 6px 0; color: var(--lab-ink); font-size: 12px; text-underline-offset: 3px; }
.lab-busy { display: flex; align-items: center; gap: 7px; color: var(--lab-muted); font-size: 12px; padding: 8px 0; }
.lab-busy::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--lab-edge); animation: lab-pulse 1.2s ease-in-out infinite; }
@keyframes lab-pulse { 50% { opacity: .3; } }
.has-probes .lab-shelf .lab-history-toggle { flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 8px; color: var(--lab-muted); background: transparent; }
.has-probes .lab-shelf .lab-history-toggle:hover { color: var(--lab-ink); background: var(--lab-hover); }
.has-probes .lab-shelf .lab-history-toggle[aria-pressed="true"] { color: #fff; background: var(--lab-accent); border-color: var(--lab-accent); }
.lab-history-toggle .lab-icon { width: 18px; height: 18px; margin: 0; }
.lab-history { position: static; display: flex; flex-direction: column; gap: 8px; width: auto; max-width: none; max-height: none; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 3px; margin: -3px; background: transparent; border: 0; box-shadow: none; }
.lab-history-note { flex: none; align-self: flex-end; margin: 0; padding: 4px 7px; border-radius: 7px; background: #fffefdeb; font-size: 10px; color: var(--lab-faint); }
.lab-history-entry { display: flex; align-items: center; padding: 3px; }
.lab-history-entry .lab-history-restore { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; text-align: left; padding: 8px 7px !important; }
.lab-history-entry .lab-history-restore span { display: block; }
.lab-history-label { flex: 1; min-width: 0; }
.lab-history-entry .lab-history-restore .lab-history-kind { color: var(--lab-faint); font-size: 9px; margin-top: 2px; }
.lab-history-entry .lab-history-restore .lab-history-excerpt { color: var(--lab-muted); font-size: 11px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lab-history-empty { flex: none; color: var(--lab-faint); font-size: 12px; margin: 0; padding: 14px; background: #fffefd; border: 1px solid var(--lab-border); border-radius: 12px; }
@media (max-width: 760px) { .lab-badge { margin-left: 3px; } .lab-panel[data-mode] { max-width: calc(100vw - 24px); } .lab-conversation { max-height: 32dvh; } .lab-intro { max-width: 90%; } }
@media (prefers-reduced-motion: reduce) { .lab-panel { transition: none; } .lab-busy::before { animation: none; } }

@media (min-width: 761px) {
  .has-probes main { margin-left: max(192px, calc((100vw - 1280px) / 2)); margin-right: 178px; }
}
@media (min-width: 1100px) {
  .has-probes main { margin-right: 368px; }
}
@media (max-width: 760px) {
  .has-probes main { margin-left: 108px; }
}

/* Cards, navigation, and the composer share the right gutter. */
.lab-shelf { --lab-shelf-max-height: min(660px, calc(100dvh - 100px)); position: fixed; right: 18px; bottom: 18px; z-index: 19; width: 326px; max-width: calc(100vw - 118px); max-height: var(--lab-shelf-max-height); display: flex; flex-direction: column; gap: 10px; overflow: visible; background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.lab-card-list { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 3px; margin: -3px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.lab-card-list[hidden], .lab-card-list:empty { display: none; }
.lab-search-composer { flex: none; display: flex; align-items: center; gap: 3px; padding: 5px; background: #fffefd; border: 1px solid var(--lab-border); border-radius: 12px; box-shadow: 0 2px 7px #29251f0c, 0 7px 22px #29251f10; }
.lab-search-composer:focus-within { border-color: var(--lab-edge); box-shadow: 0 0 0 2px #8c82741a, 0 7px 22px #29251f10; }
.lab-navigation-row { flex: 0 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 32px; min-height: 32px; }
.lab-passage-navigation, .lab-card-navigation { box-sizing: border-box; flex: none; display: flex; align-items: center; gap: 2px; height: 32px; padding: 1px; background: #fffefd; border: 1px solid var(--lab-border); border-radius: 9px; box-shadow: 0 2px 7px #29251f0c; }
.lab-card-navigation { margin-left: auto; }
.lab-navigation-row[hidden], .lab-passage-navigation[hidden], .lab-card-navigation[hidden] { display: none; }
.lab-passage-count, .lab-card-count { flex: 0 0 44px; width: 44px; text-align: center; color: var(--lab-muted); font-size: 10px; line-height: 28px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lab-card-count { flex-basis: 36px; width: 36px; }
.has-probes .lab-passage-navigation button, .has-probes .lab-card-navigation button { box-sizing: border-box; flex: 0 0 28px; display: grid; place-items: center; width: 28px; height: 28px; min-height: 28px; padding: 0; font-size: 15px; line-height: 1; }
.has-probes .lab-card-navigation button { flex-basis: 24px; width: 24px; font-size: 13px; }
.lab-card, .lab-history-entry { flex: none; min-width: 0; background: #fffefd; border: 1px solid var(--lab-border); border-radius: 12px; box-shadow: 0 2px 6px #29251f0e; }
.lab-card { transform-origin: top left; }
.lab-motion-exit { z-index: 24; pointer-events: none; overflow: hidden; }
[data-shelf-moving] { will-change: transform, opacity, clip-path; }
.lab-card[data-active="true"] { border-color: var(--lab-edge); box-shadow: 0 2px 7px #29251f16; }
.lab-card-head { display: flex; align-items: center; min-height: 51px; padding: 3px 6px; gap: 1px; }
.has-probes .lab-card-toggle { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; padding: 5px 6px; text-align: left; }
.lab-card-symbol { color: var(--lab-muted); width: 18px; flex: none; font-size: 23px; line-height: 1; }
.lab-card-symbol .lab-icon { margin: 0; vertical-align: 0; }
.lab-card-label { flex: 1; min-width: 0; }
.lab-card-title { display: block; color: var(--lab-ink); font-size: 11px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-card[data-kind="trajectory"] .lab-card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; font-size: 12px; font-weight: 550; line-height: 1.4; }
.lab-card-meta { display: block; font-size: 9px; color: var(--lab-faint); line-height: 1.5; }
.lab-card-indicator { color: var(--lab-faint); transform: rotate(180deg); font-size: 13px; }
.lab-card[data-active="true"] .lab-card-indicator, .lab-motion-exit[data-active="true"] .lab-card-indicator { transform: none; }
.has-probes .lab-card-close { color: var(--lab-faint); font-size: 17px; padding: 3px 7px; line-height: 1.4; }
.lab-card[data-busy="true"] .lab-card-symbol, .lab-history-entry[data-busy="true"] .lab-card-symbol { animation: lab-pulse 1.2s ease-in-out infinite; }
/* Reserve space for this card's header and the fixed footer, not for other cards. */
.lab-card-body { padding: 0 12px 12px; max-height: min(420px, 46dvh, max(72px, calc(var(--lab-shelf-max-height) - 156px))); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.lab-card-body[hidden] { display: none; }
.lab-card-body .lab-conversation { max-height: min(250px, 30dvh); font-size: 12px; }
.lab-card-body .lab-selection-quote { font-size: 11px; margin-bottom: 8px; }
.lab-card-body .lab-composer textarea { font-size: 12px; }
::highlight(lab-search-current) { background-color: var(--lab-selected); color: var(--lab-ink); }
.lab-timeline-search { min-width: 0; color: var(--lab-ink); font: 12px/1.5 ui-sans-serif, system-ui, sans-serif; }
.lab-search-form { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin: 0; padding: 4px 5px; border: 1px solid var(--lab-border); border-radius: 8px; background: #fff; }
.lab-search-composer .lab-search-form { flex: 1; min-width: 0; border: 0; background: transparent; }
.has-probes .lab-search-input { flex: 1; width: 0; min-width: 80px; margin: 0; border: 0; padding: 5px 3px; border-radius: 4px; background: transparent; font: inherit; font-size: 11px; color: var(--lab-ink); }
.lab-search-input::placeholder { color: var(--lab-faint); }
.has-probes .lab-search-input:focus-visible { outline: none; }
.lab-search-form:focus-within { border-color: var(--lab-edge); box-shadow: 0 0 0 2px #8c82741a; }
.lab-search-composer .lab-search-form:focus-within { box-shadow: none; }
.has-probes .lab-timeline-search button { flex: none; padding: 3px 6px; font-size: 14px; line-height: 1.5; }
.lab-search-details { padding: 4px 1px 0; overflow-wrap: anywhere; }
.lab-search-details[hidden] { display: none; }
.lab-search-details p { margin: 0; }
.lab-search-summary { color: var(--lab-muted); font-size: 11px; }
.has-probes .lab-search-details button { font-size: 11px; margin-top: 5px; }
.lab-search-match-list { display: flex; flex-direction: column; gap: 2px; }
.has-probes .lab-shelf .lab-search-match { display: block; width: 100%; margin: 0; padding: 7px 8px; text-align: left; border-radius: 5px; box-shadow: inset 2px 0 transparent; }
.has-probes .lab-shelf .lab-search-match:hover { background: var(--lab-hover); }
.has-probes .lab-shelf .lab-search-match[data-in-area="true"] { box-shadow: inset 2px 0 var(--lab-edge); }
.has-probes .lab-shelf .lab-search-match[aria-current="step"] { background: var(--lab-selected); box-shadow: inset 2px 0 var(--lab-accent); }
.lab-search-match-label { display: block; font-size: 9px; color: var(--lab-muted); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.lab-search-match-quote { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--lab-ink); font-size: 11px; line-height: 1.5; }
.lab-search-result .lab-busy { color: var(--lab-muted); }
.lab-search-result .lab-busy::before { background: var(--lab-edge); }
.lab-search-result .lab-busy button { margin: 0 0 0 auto; }
.lab-search-pointers { position: absolute; left: calc(100% + 7px); width: 24px; pointer-events: none; }
.lab-search-pointers[hidden] { display: none; }
.has-probes .lab-search-pointer { position: absolute; width: 22px; height: 22px; padding: 0; border: 1px solid var(--lab-edge); border-radius: 50%; color: var(--lab-muted); background: #fcfaf7; pointer-events: auto; transform: translateY(-50%); font: 10px/20px ui-sans-serif, system-ui, sans-serif; text-align: center; box-shadow: 0 1px 3px #29251f10; }
.has-probes .lab-search-pointer:hover, .has-probes .lab-search-pointer:focus-visible { color: var(--lab-ink); background: var(--lab-hover); z-index: 3; }
.has-probes .lab-search-pointer[aria-current="step"] { background: var(--lab-accent); border-color: var(--lab-accent); color: #fff; z-index: 2; }
body.has-probes .trajectory-dock, body.has-probes .trajectory-detail { color: var(--lab-ink); }
body.has-probes .trajectory-dock .trajectory-summary { color: var(--lab-ink); }
body.has-probes .trajectory-dock .trajectory-passage-position, body.has-probes .trajectory-dock .trajectory-passage-reason { color: var(--lab-muted); }
body.has-probes .trajectory-dock .trajectory-status, body.has-probes .trajectory-dock .trajectory-selected-quote,
body.has-probes .trajectory-dock .trajectory-coverage, body.has-probes .trajectory-dock .trajectory-coverage > summary,
body.has-probes .trajectory-detail .trajectory-cluster-note, body.has-probes .trajectory-detail .trajectory-connection-reason,
body.has-probes .trajectory-detail .trajectory-connection-count { color: var(--lab-muted); }
body.has-probes .trajectory-dock .trajectory-selected-quote, body.has-probes .trajectory-detail .trajectory-detail-quote { border-color: var(--lab-edge); }
body.has-probes .trajectory-detail .trajectory-detail-header strong, body.has-probes .trajectory-detail .trajectory-detail-quote { color: var(--lab-ink); }
body.has-probes .trajectory-dock .trajectory-status::before { background: var(--lab-edge); }
body.has-probes .lab-shelf .trajectory-dock button, body.has-probes .trajectory-detail button, body.has-probes .trajectory-dock .trajectory-recovery a { color: var(--lab-muted); }
body.has-probes .lab-shelf .trajectory-dock button:hover, body.has-probes .trajectory-detail button:hover { color: var(--lab-ink); background: var(--lab-hover); }
body.has-probes .lab-shelf .trajectory-dock .trajectory-connections-toggle { color: var(--lab-muted); border-color: var(--lab-border); }
body.has-probes .lab-shelf .trajectory-dock .trajectory-connections-toggle[aria-pressed="true"] { color: var(--lab-ink); border-color: var(--lab-edge); background: var(--lab-selected); }
body.has-probes .trajectory-detail { border-color: var(--lab-border); box-shadow: 0 3px 15px #29251f0e; }
@media (max-width: 760px) {
  .lab-shelf { --lab-shelf-max-height: min(520px, 65dvh); right: 10px; bottom: 10px; width: 310px; max-width: calc(100vw - 114px); }
  .has-trajectory-map .lab-shelf { max-width: calc(100vw - 86px - var(--trajectory-lane-width, 28px)); }
  .lab-card-body { max-height: min(39dvh, max(72px, calc(var(--lab-shelf-max-height) - 156px))); padding: 0 9px 10px; }
  .lab-card-head { padding: 3px; }
  .lab-card-toggle { gap: 6px !important; }
  .lab-search-pointers { left: calc(100% + 5px); }
}
@media (max-width: 360px) { .lab-card-count { display: none; } }
@media (prefers-reduced-motion: reduce) { .lab-card[data-busy="true"] .lab-card-symbol, .lab-history-entry[data-busy="true"] .lab-card-symbol, .lab-busy::before { animation: none; } }
