/* rrweb.com's marketing look, from the backend's dashboard app: the palette in
   components/marketing/tokens.ts, the backdrop in FoldedBackdrop.tsx, and the
   nav, cards and code blocks in MarketingLayout.tsx and marketing-tokens.ts. */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('space-grotesk.woff2') format('woff2');
}

:root {
  color-scheme: dark;

  --bg: #0d2035;
  --ink-top: #142e4a;
  --ink-bottom: #050c16;
  --text: #dbe2fd;
  --text-bright: #f3f5ff;
  --text-muted: rgba(219, 226, 253, 0.64);
  --text-faint: rgba(219, 226, 253, 0.44);
  --accent: #eec202;
  --button: #ffe373;
  --button-text: #0a1325;
  --danger: #ff8f7e;
  --good: #8fe0b5;

  /* Flat card tints for standing content, glass for floating chrome. */
  --card: rgba(219, 226, 253, 0.03);
  --card-inner: rgba(219, 226, 253, 0.02);
  --line: rgba(219, 226, 253, 0.08);
  --line-strong: rgba(219, 226, 253, 0.16);
  --well: rgba(6, 12, 25, 0.82);
  --field: rgba(6, 12, 25, 0.5);

  --display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px 0;
  background: linear-gradient(
    180deg,
    var(--ink-top) 0%,
    var(--bg) 48%,
    var(--ink-bottom) 100%
  );
}

/* The faint, slightly skewed grid behind rrweb.com, strongest at the top. */
body::before {
  content: '';
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cpath d='M32 0V160M64 0V160M96 0V160M128 0V160M0 32H160M0 64H160M0 96H160M0 128H160' fill='none' stroke='%2389A9C2' stroke-opacity='0.075' stroke-width='0.6'/%3E%3Cpath d='M160 0H0V160' fill='none' stroke='%2389A9C2' stroke-opacity='0.18' stroke-width='1.1'/%3E%3C/svg%3E");
  transform: skew(-4deg, -2deg);
  mask-image: radial-gradient(
    85% 90% at 50% 0%,
    #000 0%,
    rgba(0, 0, 0, 0.82) 45%,
    rgba(0, 0, 0, 0.5) 72%,
    rgba(0, 0, 0, 0.22) 100%
  );
}
body > * {
  position: relative;
  z-index: 1;
}

label {
  font-size: 13px;
  color: var(--text-muted);
}
input[type='checkbox'] {
  accent-color: var(--accent);
}

/* Buttons: the site's soft gold call to action, and its dark outlined
   secondary. */
button {
  font:
    700 13px/1 var(--display),
    sans-serif;
  letter-spacing: -0.02em;
  background: var(--button);
  color: var(--button-text);
  border: 1px solid transparent;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition:
    filter 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}
button:hover {
  filter: brightness(1.06);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
  filter: none;
}
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.secondary {
  background: rgba(10, 19, 37, 0.55);
  border-color: var(--line-strong);
  color: var(--text);
  font-weight: 600;
}
.secondary:hover:not(:disabled) {
  filter: none;
  background: rgba(219, 226, 253, 0.07);
  border-color: rgba(219, 226, 253, 0.3);
}

/* Pills, like the site's star count and tag chips. */
.badge {
  font:
    600 11px/1 var(--display),
    sans-serif;
  border: 1px solid var(--line-strong);
  background: rgba(219, 226, 253, 0.04);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
  color: var(--text-muted);
}
.caption {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  margin: 8px 16px 12px;
}

/* Fields: dark wells with a hairline edge and a gold focus ring. */
input[type='url'],
input[type='text'],
input[type='number'],
select {
  font: inherit;
  font-size: 13px;
  color: var(--text-bright);
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 12px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
input::placeholder {
  color: var(--text-faint);
}
input:focus,
select:focus {
  outline: none;
  border-color: rgba(238, 194, 2, 0.6);
  box-shadow: 0 0 0 3px rgba(238, 194, 2, 0.14);
}
input:disabled {
  opacity: 0.55;
}

/* Top bar: rrweb.com's floating glass nav, with its logo well. */
.controls {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 8px 14px 8px 10px;
  border-radius: 16px;
  flex: 0 0 auto;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.09) 0%,
      rgba(255, 255, 255, 0.02) 45%,
      rgba(238, 194, 2, 0.05) 100%
    ),
    radial-gradient(
      120% 180% at 0% 0%,
      rgba(99, 140, 255, 0.12) 0%,
      transparent 60%
    ),
    rgba(10, 19, 37, 0.38);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  text-decoration: none;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.15);
}
.brand-mark img {
  height: 20px;
  width: auto;
  display: block;
}
.brand-wordmark {
  height: 28px;
  width: auto;
}
.brand-product {
  font:
    600 14px var(--display),
    sans-serif;
  letter-spacing: -0.02em;
  color: var(--text-muted);
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
}
.controls form {
  flex: 1;
  margin: 0;
}
.address {
  display: flex;
  gap: 8px;
}
input[type='url'] {
  flex: 1;
  min-width: 180px;
}
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.corpus-save {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  flex: 0 0 auto;
  align-self: flex-end;
}
.corpus-save[hidden] {
  display: none;
}
.corpus-save input {
  width: 160px;
}
#connection {
  border-color: rgba(255, 143, 126, 0.35);
  background: rgba(255, 143, 126, 0.08);
  color: var(--danger);
}
#error {
  flex: 0 0 auto;
  padding: 11px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: #ffc4b9;
  background: rgba(255, 110, 90, 0.1);
  border: 1px solid rgba(255, 110, 90, 0.3);
  border-radius: 12px;
}

/* Three cards: the chat on the left, the replay and evidence on the right. */
main.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.chat-panel,
.replay-panel,
.evidence-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 0 1px 2px rgba(219, 226, 253, 0.04);
}
.right-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
}
/* Clipped for the dark well's corners; the chat card is not, so the cost
   comparison can pop up past its top edge. */
.replay-panel {
  flex: 0 0 56%;
  overflow: hidden;
}
.evidence-panel {
  flex: 1;
}

/* Replay: rrweb-player in a dark well, its controller restyled to match. */
.replay-bar,
.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  flex: 0 0 auto;
}
.replay-bar .mode,
.tabs button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
}
.replay-bar .mode:hover:not(:disabled),
.tabs button:hover {
  filter: none;
  color: var(--text-bright);
}
.replay-bar .mode.selected,
.tabs .selected {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.15);
}
.replay-bar .badge,
.tabs .badge {
  margin-left: auto;
}
#replay-wrap {
  position: relative;
  flex: 1;
  min-height: 180px;
  overflow: hidden;
  background: var(--well);
  border-top: 1px solid var(--line);
}
#player-mount {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#replay-empty {
  padding: 75px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
  line-height: 1.8;
}
#player-mount .rr-player {
  background: transparent;
  box-shadow: none;
  float: none;
}
#player-mount .rr-controller {
  background: rgba(10, 19, 37, 0.92);
  border-top: 1px solid var(--line);
  border-radius: 0;
}
#player-mount .rr-timeline__time,
#player-mount .rr-controller__btns,
#player-mount .switch label {
  color: var(--text);
}
#player-mount .rr-controller__btns button {
  color: var(--text);
  fill: currentColor;
}
#player-mount .rr-controller__btns button:active {
  background: rgba(219, 226, 253, 0.1);
}
#player-mount .rr-controller__btns button.active {
  background: var(--button);
  color: var(--button-text);
}
#player-mount .rr-progress {
  background: rgba(219, 226, 253, 0.14);
  background-clip: padding-box;
  border-color: transparent;
}
#player-mount .rr-progress__step {
  background: rgba(238, 194, 2, 0.4);
}
/* Custom event markers: the player writes its blue inline unless given a
   colour per event tag. */
#player-mount .rr-progress div:not([class]) {
  background: rgba(219, 226, 253, 0.7) !important;
}
#player-mount .rr-progress__handler {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(238, 194, 2, 0.18);
}
#player-mount .switch label:before {
  background: rgba(219, 226, 253, 0.2);
}
#player-mount .switch input[type='checkbox']:checked + label:before {
  background: var(--accent);
}

/* Story markers: a tick for every click and input change, lit once the
   playhead has passed it. The knob stays on top so it can always be seen. */
#player-mount .rr-progress__handler {
  z-index: 2;
}
#player-mount .story-markers {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
#player-mount .story-marker {
  --marker: var(--accent);
  position: absolute;
  top: 50%;
  width: 9px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}
#player-mount .story-marker.input {
  --marker: #9db8ff;
}

/* The visible tick; the marker itself is a wider target for the pointer. */
#player-mount .story-marker::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--marker);
  opacity: 0.4;
  transform: translate(-50%, -50%);
  transition:
    opacity 0.2s ease,
    height 0.2s ease,
    box-shadow 0.2s ease;
}
/* Actions close together share a marker, drawn a little wider. */
#player-mount .story-marker.many::before {
  width: 5px;
}
#player-mount .story-marker.past::before,
#player-mount .story-marker:hover::before {
  opacity: 1;
}
#player-mount .story-marker:hover::before {
  height: 16px;
}
#player-mount .story-marker.playing::before {
  opacity: 1;
  height: 18px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--marker) 28%, transparent);
}

/* The action, or each action it groups, above the tick on hover. */
#player-mount .story-marker::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  width: max-content;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre;
  padding: 6px 9px;
  font:
    600 11px/1.5 var(--display),
    sans-serif;
  letter-spacing: -0.01em;
  color: var(--text-bright);
  background: #0a1325;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}
#player-mount .story-marker:hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}
#player-mount .story-marker.start::after {
  left: 0;
  transform: translateY(4px);
}
#player-mount .story-marker.end::after {
  left: auto;
  right: 0;
  transform: translateY(4px);
}
#player-mount .story-marker.start:hover::after,
#player-mount .story-marker.end:hover::after {
  transform: none;
}

/* Evidence inspector: the site's code block. */
.evidence-panel pre {
  font:
    12px/1.7 var(--mono),
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0 12px 12px;
  padding: 14px 16px;
  flex: 1;
  min-height: 120px;
  overflow: auto;
  color: #e8ecff;
  background: var(--well);
  border: 1px solid rgba(219, 226, 253, 0.1);
  border-radius: 10px;
}
.evidence-panel .caption {
  margin: 0 16px 10px;
}
mark.evidence-hit {
  color: var(--button-text);
  background: var(--button);
  border-radius: 3px;
  padding: 1px 2px;
}
.evidence-panel.flash {
  animation: evidence-flash 1.2s ease-out;
}
@keyframes evidence-flash {
  from {
    border-color: rgba(238, 194, 2, 0.45);
    background: rgba(238, 194, 2, 0.06);
  }
  to {
    border-color: var(--line);
    background: var(--card);
  }
}

/* Chat: messages, then session info, then the ask bar. */
/* Full-width scroll surface; the message column is centered inside it. */
#chat {
  flex: 1;
  min-height: 200px;
  width: 100%;
  display: block;
  overflow: hidden;
  padding: 0 4px;
}
/* The session stats, spend and cost comparison are for debugging, so they stay
   folded behind a quiet toggle above the ask bar. */
.session-info {
  flex: 0 0 auto;
  margin: 2px 14px 8px;
}
.debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-left: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}
.debug-toggle::-webkit-details-marker {
  display: none;
}

/* A drawn chevron: pointing right when folded, down when open. */
.debug-toggle::before {
  content: '';
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateX(-1px) rotate(-45deg);
  transition: transform 0.15s ease;
}
.session-info[open] > .debug-toggle::before {
  transform: translateY(-2px) rotate(45deg);
}
.debug-toggle:hover,
.session-info[open] > .debug-toggle {
  color: var(--text-muted);
}
.debug-toggle:hover {
  background: rgba(219, 226, 253, 0.04);
}
.debug-toggle:focus-visible {
  outline: 2px solid rgba(238, 194, 2, 0.5);
  outline-offset: 1px;
}
.session-stats {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
  padding: 11px 16px;
  background: var(--card-inner);
  border: 1px solid rgba(219, 226, 253, 0.06);
  border-radius: 12px;
  box-shadow: 0 0 1px 2px rgba(219, 226, 253, 0.03);
}
.session-info[open] > .session-stats {
  animation: debug-open 0.18s ease-out;
}
@keyframes debug-open {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* Labels as the site's small caps headings ("TRUSTED & SPONSORED BY"). */
.session-stats > div > span,
.vision-toggle #vision-label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.session-stats > div > strong,
.vision-toggle #vision-delta {
  display: block;
  font:
    600 14px var(--display),
    sans-serif;
  letter-spacing: -0.01em;
  color: var(--text-bright);
}
.chat-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  margin: 0;
}
.chat-bar input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
}
.chat-bar button {
  padding: 11px 22px;
}

/* Optional cost comparison pops up from the session stats, as the site's nav
   dropdowns do. */
.vision-comparison {
  margin: 0;
}
.vision-toggle {
  cursor: pointer;
  list-style: none;
  min-width: 130px;
}
.vision-toggle::-webkit-details-marker {
  display: none;
}
.vision-toggle #vision-delta::after {
  content: '⌃';
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 8px;
}
.vision-comparison[open] #vision-delta::after {
  content: '⌄';
}
.vision-toggle .vlm-more {
  color: var(--good);
}
.vision-toggle .vlm-less {
  color: var(--danger);
}
.vision-expanded {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 8px;
  right: 8px;
  z-index: 6;
  padding: 16px;
  max-height: min(72vh, 680px);
  overflow: auto;
  background: #0a1325;
  border: 1px solid rgba(219, 226, 253, 0.1);
  border-radius: 12px;
  box-shadow:
    0 0 1px 2px rgba(219, 226, 253, 0.04),
    0 16px 40px rgba(0, 0, 0, 0.5);
}
.cost-heading {
  display: flex;
  justify-content: flex-end;
}
.vision-expanded .caption {
  margin: 10px 0;
}
.vision-settings summary {
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--accent);
}
.vision-settings form {
  display: flex;
  gap: 14px;
  align-items: end;
  margin: 15px 0;
  flex-wrap: wrap;
}
.vision-settings label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}
.vision-settings input,
.vision-settings select {
  max-width: 140px;
  padding: 8px 10px;
}
.vision-settings pre {
  font:
    11px/1.6 var(--mono),
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 14px;
  height: 220px;
  overflow: auto;
  color: #e8ecff;
  background: var(--well);
  border: 1px solid rgba(219, 226, 253, 0.1);
  border-radius: 10px;
}
.scenario-table-wrap {
  overflow-x: auto;
}
.scenario-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}
.scenario-table th,
.scenario-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
.scenario-table thead th {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.scenario-table small {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 400;
  margin-top: 5px;
}
.scenario-table strong {
  font:
    600 14px var(--display),
    sans-serif;
  color: var(--text-bright);
}

/* Hidden summary history retains the pre-redesign markup for tests and debugging. */
#history[hidden] {
  display: none;
}
.entry {
  border-top: 1px solid var(--line);
  padding: 17px 0;
}
.entry:first-child {
  border: 0;
}
.entry .meta {
  font-size: 10px;
  color: var(--text-faint);
  line-height: 1.7;
}
.entry p {
  font-size: 13px;
  line-height: 1.7;
}
.entry.failed {
  color: var(--danger);
}
.friction-callout {
  margin: 12px 0;
  padding: 11px 13px;
  background: rgba(255, 143, 126, 0.08);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  color: #ffc4b9;
}
.friction-callout > strong {
  display: block;
  font-size: 11px;
  font-weight: 650;
  margin-bottom: 5px;
}
.friction-callout p {
  color: #ffc4b9;
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

footer {
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: 11px;
  padding: 0 4px 12px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(219, 226, 253, 0.14);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 1150px) {
  body {
    height: auto;
  }
  main.split {
    grid-template-columns: 1fr;
  }
  .chat-panel {
    height: 80dvh;
  }
  .replay-panel {
    flex: none;
  }
  #replay-wrap {
    min-height: 300px;
  }
  .evidence-panel pre {
    height: 400px;
    flex: none;
  }
}
@media (max-width: 720px) {
  .controls {
    flex-wrap: wrap;
  }
  .brand-product {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .evidence-panel.flash,
  .session-info[open] > .session-stats {
    animation: none;
  }
  .debug-toggle::before,
  #player-mount .story-marker::before,
  #player-mount .story-marker::after {
    transition: none;
  }
}
