/* X-ray mode — visible only when body.xray-mode is set. */

/* Floating toggle button — always visible so the feature is discoverable. */
#xray-fab {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9000;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #d4d4d8;
  background: #ffffff;
  color: #18181b;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#xray-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
#xray-fab.active {
  background: #ec4899;
  border-color: #db2777;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.25), 0 4px 14px rgba(236, 72, 153, 0.35);
}

/* Highlight every tagged figure when x-ray is on. */
body.xray-mode [data-fig-id] {
  outline: 1px dashed #ec4899;
  outline-offset: 2px;
  cursor: help;
  border-radius: 2px;
  transition: outline-color 0.1s ease, background 0.1s ease;
}
body.xray-mode [data-fig-id]:hover {
  outline: 2px solid #ec4899;
  background: rgba(236, 72, 153, 0.06);
}

/* Suppress link-like hover styles on x-ray-clicked elements. */
body.xray-mode [data-fig-id] {
  position: relative;
}

/* The hover tooltip. Lives at body root, positioned by JS. */
#xray-tooltip {
  position: absolute;
  z-index: 9100;
  width: 320px;
  max-width: calc(100vw - 16px);
  padding: 0;
  border-radius: 8px;
  background: #18181b;
  color: #fafafa;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;  /* tooltip itself never captures hover */
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
#xray-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.xray-tip-header {
  padding: 8px 12px;
  background: #ec4899;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 8px 8px 0 0;
  text-transform: uppercase;
  font-size: 10.5px;
}
.xray-tip-header.xray-tip-warn { background: #f59e0b; }
.xray-tip-body { padding: 10px 12px; }
.xray-tip-formula {
  background: #27272a;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  color: #fde68a;
  white-space: pre-wrap;
  word-break: break-word;
}
.xray-tip-inputs > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dotted #3f3f46;
}
.xray-tip-inputs > div:last-child { border-bottom: 0; }
.xray-tip-inputs span { color: #a1a1aa; }
.xray-tip-inputs code { color: #e4e4e7; }
.xray-tip-more {
  margin-top: 6px;
  font-style: italic;
  color: #a1a1aa;
}
.xray-tip-footer {
  padding: 8px 12px;
  background: #27272a;
  border-radius: 0 0 8px 8px;
  color: #a1a1aa;
  font-size: 10.5px;
}
.xray-tip-footer code { color: #e4e4e7; }

/* The click-to-inspect modal. */
#xray-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
}
#xray-modal.open { display: block; }
.xray-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 20, 0.55);
  backdrop-filter: blur(2px);
}
.xray-modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 92vw);
  max-height: 84vh;
  overflow: auto;
  background: #ffffff;
  color: #18181b;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.xray-modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #18181b;
  color: #fafafa;
  border-radius: 10px 10px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.xray-modal-title {
  flex: 1;
  word-break: break-all;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.xray-modal-close {
  background: transparent;
  border: 0;
  color: #fafafa;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.xray-modal-close:hover { color: #ec4899; }
.xray-modal-body {
  padding: 16px 20px 20px 20px;
  font-size: 13px;
}
.xray-modal-body h4 {
  margin: 0 0 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #71717a;
}
.xray-section { margin-top: 16px; }
.xray-section:first-child { margin-top: 0; }
.xray-section-meta { color: #71717a; font-size: 11.5px; }
.xray-formula {
  background: #f4f4f5;
  padding: 8px 10px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #18181b;
  white-space: pre-wrap;
  word-break: break-word;
}
.xray-notes {
  margin-top: 6px;
  font-size: 12px;
  color: #52525b;
  font-style: italic;
}
.xray-table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.xray-table th, .xray-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #f4f4f5;
  text-align: left;
}
.xray-table th { color: #71717a; font-weight: 500; width: 40%; }
.xray-table td { color: #18181b; word-break: break-word; }
.xray-upstream { margin: 0; padding-left: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.xray-upstream li { margin-bottom: 4px; }
.xray-upstream a {
  color: #ec4899;
  text-decoration: none;
  border-bottom: 1px dashed #ec4899;
}
.xray-upstream a:hover { color: #be185d; }
.xray-tip-source { color: #71717a; font-size: 11px; margin-left: 4px; }
.xray-warn {
  padding: 10px 12px;
  border-left: 3px solid #f59e0b;
  background: #fef3c7;
  border-radius: 0 4px 4px 0;
  color: #78350f;
  font-size: 13px;
}

/* Chat-side x-ray: tagged numbers in agent replies. Always wrapped in
   spans by xray.js' MutationObserver; only visually styled when x-ray
   is on. Tagged spans share the [data-fig-id] selector at the top of
   this file, so they pick up the magenta dashed outline + click target.
   Untagged numbers get a yellow underline so the user can see what's
   not yet covered. */
.xray-chat-figure {
  font-weight: 600;
}
.xray-chat-untagged {
  font-style: italic;
}
body.xray-mode .xray-chat-untagged {
  background: linear-gradient(transparent 60%, rgba(245, 158, 11, 0.4) 60%);
  cursor: help;
}
