/* ============================================================================
   Ask Hitch — the universal right-docked shelf (explorer/platform/ask-shelf.js).
   ONE scope-aware Ask Hitch panel, dropped once onto document.body. Surface-
   agnostic: it holds the panel chrome, the scope ladder, the transcript and the
   composer; grounding comes from a pluggable provider (HitchShelf.configure).

   Ported 1:1 from mockups/ask-hitch-entity-scope.html, scoped under
   `.hitch-shelf` / `body.hitch-shelf-*` so nothing leaks into a host page, and
   every color/type value reads an explorer/hitch-tokens.css token WITH a hard
   fallback so the shelf stays on-brand on a surface that hasn't linked tokens.
   ========================================================================== */

/* self-contained box model — don't depend on a host page's reset (universal) */
.hitch-shelf, .hitch-shelf * { box-sizing: border-box; }

/* ── scrim + panel ──────────────────────────────────────────────────────── */
.hitch-shelf-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 7, 9, .42); opacity: 0; pointer-events: none;
  transition: opacity .28s; backdrop-filter: blur(1px);
}
body.hitch-shelf-open .hitch-shelf-scrim { opacity: 1; pointer-events: auto; }

.hitch-shelf {
  position: fixed; top: 0; right: 0; bottom: 0; width: 456px; max-width: 96vw;
  z-index: 70; display: flex; flex-direction: column;
  /* chain through the host's themed panel token so the shelf follows a light
     surface (cit_app body.light) instead of dead-ending on a dark constant */
  background: var(--bg-panel, var(--panel, #0d0f12));
  border-left: 1px solid var(--line, rgba(244, 241, 234, .1));
  box-shadow: -24px 0 70px rgba(0, 0, 0, .5);
  transform: translateX(100%);
  transition: transform .3s var(--ease, cubic-bezier(.22, 1, .36, 1));
  font-family: var(--sans, "Inter", system-ui, sans-serif);
  color: var(--ink, #f4f1ea);
}
body.hitch-shelf-open .hitch-shelf { transform: none; }

/* ── header ─────────────────────────────────────────────────────────────── */
.hitch-shelf .phead { display: flex; align-items: center; gap: .55rem; padding: 17px 20px 13px; }
.hitch-shelf .pmark {
  font-family: var(--serif, "Instrument Serif", Georgia, serif);
  font-weight: 400; font-size: 1.4rem; line-height: 1; letter-spacing: .01em;
}
.hitch-shelf .pmark .a { color: var(--ink, #f4f1ea); }
.hitch-shelf .pmark .h { color: var(--accent-ink,var(--accent, #e8a13c)); font-style: italic; }
.hitch-shelf .sp { flex: 1; }
.hitch-shelf .status {
  display: inline-flex; align-items: center; gap: .42rem;
  font-family: var(--mono, ui-monospace, Menlo, Consolas, monospace);
  font-size:.6875rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint, #6b675d); white-space: nowrap;
}
.hitch-shelf .status .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.hitch-shelf .status.reading { color: var(--accent-ink,var(--accent, #e8a13c)); }
.hitch-shelf .status.reading .dot {
  background: var(--accent, #e8a13c); box-shadow: 0 0 8px var(--accent, #e8a13c);
  animation: hsh-pulse 1s infinite;
}
.hitch-shelf .picon {
  background: none; border: 1px solid transparent; color: var(--ink-faint, #6b675d);
  font-size: .95rem; line-height: 1; cursor: pointer; border-radius: 8px; padding: .2rem .4rem;
}
.hitch-shelf .picon:hover { color: var(--ink, #f4f1ea); border-color: var(--line, rgba(244, 241, 234, .1)); }

/* ── scope chip + ladder ────────────────────────────────────────────────── */
.hitch-shelf .scopewrap { padding: 0 20px 14px; position: relative; }
.hitch-shelf .scopechip {
  width: 100%; display: flex; align-items: center; gap: .65rem; cursor: pointer;
  background: rgba(232, 161, 60, .07);
  border: 1px solid color-mix(in srgb, var(--accent, #e8a13c) 38%, var(--line, rgba(244, 241, 234, .1)));
  border-radius: 11px; padding: .6rem .75rem; text-align: left; transition: .15s; color: inherit;
}
.hitch-shelf .scopechip:hover { background: rgba(232, 161, 60, .11); }
.hitch-shelf .scopechip .tgt { color: var(--accent-ink,var(--accent, #e8a13c)); font-size: .95rem; line-height: 1; }
.hitch-shelf .scopechip .lbl { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hitch-shelf .scopechip .lbl b { font-size: .9rem; font-weight: 600; color: var(--ink, #f4f1ea); }
.hitch-shelf .scopechip .lbl small { font-size:.6875rem; color: var(--ink-faint, #6b675d); }
.hitch-shelf .scopechip .car {
  font-size: .7rem; color: var(--ink-faint, #6b675d);
  transition: transform .18s var(--ease, cubic-bezier(.22, 1, .36, 1));
}
body.hitch-shelf-scopes .hitch-shelf .scopechip .car { transform: rotate(180deg); }

.hitch-shelf .reach { display: flex; align-items: center; gap: 3px; }
.hitch-shelf .reach i {
  width: 5px; height: 5px; border-radius: 50%; transition: .15s;
  background: color-mix(in srgb, var(--accent, #e8a13c) 22%, transparent);
}
.hitch-shelf .reach i.on { background: var(--accent, #e8a13c); }

.hitch-shelf .ladder {
  position: absolute; left: 20px; right: 20px; top: calc(100% - 6px); z-index: 20;
  background: var(--bg-soft, #101216);
  border: 1px solid var(--line, rgba(244, 241, 234, .1));
  border-radius: 13px; box-shadow: 0 22px 54px rgba(0, 0, 0, .55); padding: 8px;
  opacity: 0; transform: translateY(-8px) scale(.99); transform-origin: top; pointer-events: none;
  transition: .2s var(--ease, cubic-bezier(.22, 1, .36, 1));
}
body.hitch-shelf-scopes .hitch-shelf .ladder { opacity: 1; transform: none; pointer-events: auto; }
.hitch-shelf .lh {
  font-family: var(--mono, ui-monospace, monospace); font-size:.6875rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint, #6b675d); padding: 6px 10px 8px;
}
.hitch-shelf .rung {
  width: 100%; display: flex; align-items: flex-start; gap: .7rem; padding: 10px;
  border-radius: 10px; text-align: left; background: none; border: 0; cursor: pointer;
  transition: background .12s; color: inherit;
}
.hitch-shelf .rung:hover { background: rgba(244, 241, 234, .04); }
.hitch-shelf .rung.on { background: rgba(232, 161, 60, .1); }
.hitch-shelf .rung .radio {
  position: relative; flex: none; width: 15px; height: 15px; margin-top: 2px; border-radius: 50%;
  border: 1.5px solid var(--ink-faint, #6b675d);
}
.hitch-shelf .rung.on .radio { border-color: var(--accent, #e8a13c); }
.hitch-shelf .rung.on .radio::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent, #e8a13c);
}
.hitch-shelf .rung .rl { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hitch-shelf .rung .rl b { font-size: .84rem; font-weight: 600; color: var(--ink, #f4f1ea); display: flex; align-items: center; gap: .4rem; }
.hitch-shelf .rung .rl small { font-size: .72rem; color: var(--ink-faint, #6b675d); line-height: 1.4; }
.hitch-shelf .rung .depth {
  font-family: var(--mono, ui-monospace, monospace); font-size:.6875rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent-ink,var(--accent, #e8a13c));
  border: 1px solid color-mix(in srgb, var(--accent, #e8a13c) 40%, var(--line, rgba(244, 241, 234, .1)));
  border-radius: 100px; padding: .1rem .35rem;
}
.hitch-shelf .rreach { margin-top: 5px; }

/* ── transcript ─────────────────────────────────────────────────────────── */
.hitch-shelf .log { flex: 1; overflow-y: auto; padding: 6px 20px 12px; display: flex; flex-direction: column; gap: 14px; }
/* padding:0 + text-align:left neutralize an unscoped host `.empty` rule (opps.css) */
.hitch-shelf .empty { color: var(--ink-dim, #9a988f); font-size: .84rem; line-height: 1.55; padding: 0; text-align: left; }
.hitch-shelf .empty h4 {
  margin: 0 0 .5rem; font-family: var(--serif, "Instrument Serif", Georgia, serif);
  font-weight: 400; font-size: 1.12rem; color: var(--ink, #f4f1ea);
}
.hitch-shelf .estarts { display: flex; flex-direction: column; gap: .4rem; margin-top: .7rem; }
.hitch-shelf .estart, .hitch-shelf .fubtn {
  text-align: left; background: var(--field, var(--bg, #0c0e11));
  border: 1px solid var(--line, rgba(244, 241, 234, .1)); color: var(--ink-dim, #9a988f);
  border-radius: 10px; padding: .5rem .75rem; font-size: .82rem;
  font-family: var(--sans, "Inter", system-ui, sans-serif); cursor: pointer;
  transition: border-color .12s, color .12s;
}
.hitch-shelf .estart:hover, .hitch-shelf .fubtn:hover {
  color: var(--ink, #f4f1ea);
  border-color: color-mix(in srgb, var(--accent, #e8a13c) 55%, var(--line, rgba(244, 241, 234, .1)));
}

.hitch-shelf .msg { display: flex; flex-direction: column; gap: 6px; }
.hitch-shelf .msg.user { align-items: flex-end; }
.hitch-shelf .msg.user .b {
  background: color-mix(in srgb, var(--accent, #e8a13c) 16%, var(--bg-soft, #101216));
  border: 1px solid color-mix(in srgb, var(--accent, #e8a13c) 30%, var(--line, rgba(244, 241, 234, .1)));
  color: var(--ink, #f4f1ea); border-radius: 12px 12px 4px 12px; padding: .5rem .75rem;
  max-width: 88%; font-size: .86rem; line-height: 1.5;
}
.hitch-shelf .msg.asst .b {
  background: var(--field, var(--bg, #0c0e11)); border: 1px solid var(--line, rgba(244, 241, 234, .1));
  border-radius: 12px 12px 12px 4px; padding: .7rem .85rem; color: var(--ink-dim, #9a988f);
  font-size: .87rem; line-height: 1.62; max-width: 100%;
}
.hitch-shelf .msg.asst .b p { margin: 0 0 .5rem; }
.hitch-shelf .msg.asst .b p:last-child { margin-bottom: 0; }
.hitch-shelf .msg.asst .b ul { margin: .2rem 0 .5rem; padding-left: 1.1rem; }
.hitch-shelf .msg.asst .b li { margin: .15rem 0; }
.hitch-shelf .msg.asst .b b { color: var(--ink, #f4f1ea); font-weight: 600; }
.hitch-shelf .msg.asst .b code {
  font-family: var(--mono, ui-monospace, monospace); font-size: .8rem; background: var(--field, var(--bg, #0c0e11));
  border: 1px solid var(--line, rgba(244, 241, 234, .1)); border-radius: 5px; padding: .05rem .3rem;
  color: var(--ink, #f4f1ea);
}
/* deterministic-skill answer bits (label/value rows, nav buttons, source note) */
.hitch-shelf .msg.asst .b .krow {
  display: flex; justify-content: space-between; gap: 12px; padding: 5px 0;
  border-top: 1px solid var(--line-soft, rgba(244, 241, 234, .06)); font-size: .82rem;
}
.hitch-shelf .msg.asst .b .krow:first-of-type { border-top: 0; }
.hitch-shelf .msg.asst .b .krow small { display: block; color: var(--ink-faint, #6b675d); font-size: .72rem; margin-top: 2px; }
.hitch-shelf .msg.asst .b .kgo {
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
  color: var(--accent-ink,var(--accent, #e8a13c)); font-family: inherit; font-size: .82rem;
}
.hitch-shelf .msg.asst .b .kgo:hover { text-decoration: underline; }
.hitch-shelf .msg.asst .b .knum { color: var(--ink, #f4f1ea); font-weight: 600; font-family: var(--mono, ui-monospace, monospace); }
.hitch-shelf .msg.asst .b .kcite {
  margin-top: .55rem; font-size:.6875rem; color: var(--ink-faint, #6b675d);
  font-family: var(--mono, ui-monospace, monospace); line-height: 1.4;
}
.hitch-shelf .badge {
  font-family: var(--mono, ui-monospace, monospace); font-size:.6875rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-faint, #6b675d); margin-top: .5rem;
}
.hitch-shelf .caveat { margin-top: .4rem; font-size: .72rem; color: var(--ink-faint, #6b675d); line-height: 1.45; }
.hitch-shelf .err { color: #e0655f; }

.hitch-shelf .fu { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.hitch-shelf .fu-l {
  font-family: var(--mono, ui-monospace, monospace); font-size:.6875rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-faint, #6b675d); margin-right: .1rem;
}
.hitch-shelf .fubtn { border-radius: 100px; padding: .34rem .7rem; font-size: .78rem; }

.hitch-shelf .think { display: inline-flex; gap: 4px; padding: .15rem 0; }
.hitch-shelf .think i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint, #6b675d); animation: hsh-blink 1.2s infinite; }
.hitch-shelf .think i:nth-child(2) { animation-delay: .2s; }
.hitch-shelf .think i:nth-child(3) { animation-delay: .4s; }
/* the in-flight clock — a grounded answer is slow on purpose, so say how slow */
.hitch-shelf .elapsed {
  margin-left: .5rem; font-family: var(--mono, ui-monospace, monospace);
  font-size:.6875rem; letter-spacing: .06em; color: var(--ink-faint, #6b675d);
  font-variant-numeric: tabular-nums;
}

/* ── composer + footer ──────────────────────────────────────────────────── */
.hitch-shelf .composer {
  margin: 2px 20px 10px; display: flex; align-items: flex-end; gap: .5rem;
  background: var(--field, var(--bg, #0c0e11)); border: 1px solid var(--line, rgba(244, 241, 234, .1));
  border-radius: 13px; padding: .45rem .45rem .45rem .85rem;
}
.hitch-shelf .composer:focus-within { border-color: color-mix(in srgb, var(--accent, #e8a13c) 55%, var(--line, rgba(244, 241, 234, .1))); }
.hitch-shelf .composer textarea {
  flex: 1; resize: none; background: none; border: none; outline: none;
  color: var(--ink, #f4f1ea); font-family: var(--sans, "Inter", system-ui, sans-serif);
  font-size: .88rem; line-height: 1.5; max-height: 120px; padding: .3rem 0;
}
.hitch-shelf .composer textarea::placeholder { color: var(--ink-faint, #6b675d); }
.hitch-shelf .send {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--accent, #e8a13c); background: var(--accent, #e8a13c);
  color: #1a1206; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.hitch-shelf .send:hover { filter: brightness(1.08); }
/* the same button, as STOP while a turn is in flight — outlined, not filled, so
   it reads as "abandon this" rather than a second way to send. */
.hitch-shelf .send.stop {
  background: none; color: var(--accent-ink,var(--accent, #e8a13c)); font-size:.6875rem;
}
.hitch-shelf .pfoot { display: flex; align-items: center; gap: .5rem; padding: 0 20px 14px; }
/* the account menu's Conversations, moved here (2026-11-02) */
.hitch-shelf .pfoot .pastlink { font-size: 0.75rem; color: var(--ink-dim); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.hitch-shelf .pfoot .pastlink:hover { color: var(--accent-ink,var(--accent)); }
.hitch-shelf .keychip {
  font-family: var(--mono, ui-monospace, monospace); font-size:.6875rem; letter-spacing: .08em;
  color: var(--accent-ink,var(--accent, #e8a13c));
  border: 1px solid color-mix(in srgb, var(--accent, #e8a13c) 45%, var(--line, rgba(244, 241, 234, .1)));
  border-radius: 100px; padding: .16rem .5rem;
}
.hitch-shelf .disc { font-size: .72rem; color: var(--ink-faint, #6b675d); }

@keyframes hsh-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .32 } }
@keyframes hsh-blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

@media (max-width: 520px) { .hitch-shelf { width: 100vw; } }

/* ── topbar trigger — the "Ask Hitch" pill that opens this shelf ───────────
   Injected into the header by each surface's integration (opportunities/
   askhitch.js, explorer/budget-askhitch.js, explorer/intel-askhitch.js). Lives
   here — the one stylesheet all three of those surfaces load — with hard token
   fallbacks so it stays on-brand anywhere the shelf ships. */
.ask-hitch-trigger {
  display: inline-flex; align-items: center; cursor: pointer;
  font-family: var(--serif, "Instrument Serif", Georgia, serif);
  font-size: 1.02rem; line-height: 1; color: var(--ink, #f4f1ea);
  background: rgba(232, 161, 60, .08);
  border: 1px solid color-mix(in srgb, var(--accent, #e8a13c) 40%, var(--line, rgba(244, 241, 234, .1)));
  border-radius: 100px; padding: .34rem .85rem; transition: background .15s, border-color .15s;
}
.ask-hitch-trigger .ah-h { color: var(--accent-ink,var(--accent, #e8a13c)); font-style: italic; }
.ask-hitch-trigger:hover {
  background: rgba(232, 161, 60, .14);
  border-color: color-mix(in srgb, var(--accent, #e8a13c) 60%, var(--line, rgba(244, 241, 234, .1)));
}
