/* The panel beside an answer (js/answer-inspector.js): tabs, timeline, resource sections and the space it reserves.
   Moved out of base.css, shared-components.css and features.css in their
   original cascade order; loaded after features.css and before type.css. */

body.answer-inspector-open .chat-turn-outline {
  opacity: 0;
  pointer-events: none;
  transform: translate(220px, -50%);
}

.answer-inspector {
  position: fixed;
  z-index: 120;
  inset: 0 0 0 auto;
  display: flex;
  flex-direction: column;
  width: min(var(--answer-inspector-width), 100vw);
  overflow: visible;
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgb(var(--muted-rgb) / .10);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(calc(100% + 40px));
  transition:
    transform 220ms cubic-bezier(.22, 1, .36, 1),
    opacity 150ms ease,
    visibility 0s linear 220ms;
}

.answer-inspector.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition-delay: 0s;
}

.answer-inspector-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.answer-inspector-back {
  display: grid;
  place-items: center;
  position: absolute;
  z-index: 2;
  left: -34px;
  top: 50%;
  width: 34px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  background: var(--surface);
  color: var(--muted);
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: -5px 0 14px rgba(15, 23, 42, 0.04);
}

.answer-inspector-back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.answer-inspector-back:hover {
  background: var(--hover-bg);
  color: var(--ink);
}

.answer-inspector-tabs {
  display: flex;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
}

.answer-inspector-time {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.answer-inspector-tab {
  /* Sized to the label, not stretched to half the panel: a rule under a
     stretched tab is a rule across the whole header, which is the heaviness
     the fill had. Left-aligned, like the Databáze tabs. */
  flex: 0 1 auto;
  min-width: 0;
  padding: 8px 10px 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 550;
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur);
}

/* Tabs are marked by a rule under the active label, not a filled shape.
   The pill this replaced was the loudest thing in a quiet UI, and it had to
   carry a tan strong enough to beat the surface, which made it louder still.
   The transparent border on the resting state reserves the 2px so switching
   tabs never shifts the row. */
.answer-inspector-tab:hover {
  background: transparent;
  color: var(--ink);
}

.answer-inspector-tab.active {
  background: transparent;
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.answer-inspector-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.answer-inspector-content .sources-list,
.answer-inspector-content .skills-list,
.answer-inspector-content .answer-exports,
.answer-inspector-content .analysis-solution,
.answer-inspector-content .agent-trace {
  display: block !important;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.answer-inspector-content .agent-trace.open,
.answer-inspector-content .sources-list.open,
.answer-inspector-content .answer-exports,
.answer-inspector-content .analysis-solution.open {
  padding: 0;
}

.answer-inspector-content .analysis-solution {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.answer-inspector-content .analysis-solution.open {
  padding: 16px 0 0;
}

.answer-inspector-content .analysis-solution-code {
  max-width: 100%;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* No box round the list and no box round each row. The panel is already a
   panel; drawing a card inside it, inside a bordered group, inside the
   inspector, is three frames deep for a list of four things. What is left
   is what the list needed all along: a hairline between rows and enough air
   to read them. */
.answer-inspector-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Names the block without competing with what is in it -- and in the same
   voice the trace view's own labels already speak in, so the two tabs of
   one panel do not each invent their own kind of section heading. Matches
   .agent-trace-summary-label; keep them in step. */
.answer-inspector-section-title {
  flex: 0 0 auto;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Sources use the available space. Only an actual solution reserves room
   for code; short source lists still leave the remaining space to it. */
.answer-inspector-content[data-view="resources"] .answer-inspector-section.is-sources {
  flex: 0 1 auto;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

/* Skills are a short list read at a glance, so they keep their own height
   between the sources and the solution instead of taking a share of it. */
.answer-inspector-content[data-view="resources"] .answer-inspector-section.is-skills {
  flex: 0 0 auto;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.answer-inspector-content[data-view="resources"] .answer-inspector-section + .answer-inspector-section.is-skills {
  margin-top: 18px;
}

/* A rule under the last block closes nothing; it only draws a line. */
.answer-inspector-content[data-view="resources"] .answer-inspector-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.answer-inspector-content[data-view="resources"] .sources-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.answer-inspector-content[data-view="resources"] .data-source-list {
  gap: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.answer-inspector-content[data-view="resources"] .data-source-card {
  padding: 13px 4px;
  box-shadow: none;
}

/* The row does not fill on hover -- there is no card edge for a fill to sit
   inside any more. The name answers instead, the way a link does. */
.answer-inspector-content[data-view="resources"] .data-source-card:hover {
  background: transparent;
}

.answer-inspector-content[data-view="resources"] a.data-source-card:hover .data-source-name,
.answer-inspector-content[data-view="resources"] .data-source-card a.data-source-name:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.answer-inspector-content[data-view="resources"] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.answer-inspector-trace {
  min-width: 0;
  max-width: 100%;
}

/* A thread down the left joins the steps into one run; each step hangs a
   dot on it. The step's own icon stays beside its name. */
.answer-inspector-timeline {
  position: relative;
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.answer-inspector-tl-step {
  position: relative;
  min-width: 0;
}

.answer-inspector-tl-step::before {
  content: "";
  position: absolute;
  top: 13px;
  left: -18px;
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.answer-inspector-tl-step.is-error::before { border-color: var(--red); }

/* The thread runs from each dot to the next, so it ends at the last dot
   however tall the last step grows -- never trailing off below it. */
.answer-inspector-tl-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 17.5px;
  bottom: -17.5px;
  left: -14px;
  width: 1px;
  background: var(--border);
}

.answer-inspector-tl-step::before { z-index: 1; }

.answer-inspector-tl-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

button.answer-inspector-tl-head { cursor: pointer; }

button.answer-inspector-tl-head:hover { background: var(--hover-bg); }

button.answer-inspector-tl-head[aria-expanded="true"] { background: var(--active-bg); }

.answer-inspector-tl-head .step-icon { color: var(--muted); }

.answer-inspector-tl-label {
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-inspector-tl-time {
  color: var(--faint);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.answer-inspector-tl-line {
  grid-column: 2 / -1;
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.answer-inspector-tl-detail {
  margin: 4px 0 8px 8px;
  padding: 10px 12px;
  max-height: 320px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  color: var(--text);
  font-size: var(--text-xs);
}

.answer-inspector-tl-detail[hidden] { display: none; }

/* The detail box is the one scroller; code cloned in from the answer
   panel brings its own height cap, padding and fill, which would nest a
   second scrolling box inside it. */
.answer-inspector-tl-detail pre,
.answer-inspector-tl-detail pre.step-code,
.answer-inspector-tl-detail .analysis-solution-code {
  max-width: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  border-radius: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: var(--font-mono);
  line-height: 1.5;
}

.answer-inspector-tl-fields { display: grid; gap: 8px; }

.answer-inspector-tl-field {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  gap: 10px;
  line-height: 1.45;
}

.answer-inspector-tl-field > span { color: var(--faint); }

.answer-inspector-tl-field p { margin: 0; color: var(--ink); }

.answer-inspector-tl-field p + p { margin-top: 4px; }

.answer-inspector-tl-raw > summary {
  color: var(--muted);
  cursor: pointer;
}

.answer-inspector-tl-raw > summary:hover { color: var(--ink); }

.answer-inspector-tl-raw > pre { margin-top: 8px !important; }

.answer-more {
  position: relative;
  display: inline-flex;
}

.answer-more-trigger {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .14s ease, background .14s ease;
}

.answer-more-trigger:hover,
.answer-more.open .answer-more-trigger {
  color: var(--ink);
  background: var(--hover-bg);
}

/* Opens the side panel with the answer's sources, steps and code, so the
   icon has to say "look at this" without saying "menu". Three earlier
   attempts and why they failed: a filled ellipsis promised a dropdown that
   never appears; an info circle shares its silhouette with a warning at
   this size; a document under a magnifier carried five paths and sat
   noticeably denser than the thumbs beside it. The plus in the lens is
   load-bearing -- without it this is the plain magnifier the Výzkumník nav
   already wears. */
.answer-more-trigger svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.answer-inspector-content .answer-exports {
  display: block !important;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.answer-inspector-content .answer-exports::before {
  content: "Výstupy";
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.answer-inspector-content .data-export-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.answer-inspector-content .data-export-file {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.answer-inspector-content[data-view="resources"] .data-source-card {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.answer-inspector-content[data-view="resources"] .data-source-card + .data-source-card {
  border-top: 1px solid var(--border-soft);
}

body.answer-inspector-open #chat-area {
  padding-right: calc(var(--answer-inspector-width) + var(--main-pad));
}

body.answer-inspector-open #input-area {
  right: var(--answer-inspector-width);
}

.answer-inspector {
  background: var(--surface);
  border-color: var(--border);
}

@media (max-width: 720px) {
  body.answer-inspector-modal-open .rail-backdrop {
      z-index: 119;
      opacity: 1;
      pointer-events: auto;
    }

  body.answer-inspector-modal-open .mobile-rail-toggle {
      visibility: hidden;
      pointer-events: none;
    }

  .answer-inspector {
      width: min(420px, calc(100vw - 64px));
    }

  .answer-inspector .answer-inspector-back {
      display: none;
    }

  body.answer-inspector-open #chat-area {
      padding-right: var(--main-pad);
    }

  body.answer-inspector-open #input-area {
      right: 0;
    }
}
.answer-inspector-content[data-view="resources"] {
  overflow-y: auto;
}
