.preview {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 100%;
  z-index: 100;
  width: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  background: var(--bg);
  border-left: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  box-shadow: -10px 0 26px rgba(0, 0, 0, 0.07);
  pointer-events: auto;
  cursor: default;
  user-select: text;
}

.turn {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  padding: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 68%, transparent);
  background: transparent;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.turn[data-located="true"] {
  background: color-mix(in srgb, var(--text) 4%, var(--bg));
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--text-muted) 70%, transparent);
}

.number {
  position: relative;
  z-index: 1;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  padding: 0;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
}

.turn[data-located="true"] .number {
  color: var(--text-muted);
}

.content {
  grid-column: 2;
  min-width: 0;
}

.user {
  display: block;
  width: calc(100% + 34px);
  min-height: 32px;
  max-height: 86px;
  margin: 0 0 0 -34px;
  padding: 7px 10px 7px 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 18px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: background 100ms ease;
}

.userText {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.user:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

.assistant {
  position: relative;
  display: block;
  padding: 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 52%, transparent);
}

.assistant + .assistant {
  margin-top: 0;
}

.assistantJump {
  position: absolute;
  top: 0;
  left: -29px;
  z-index: 2;
  width: 24px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease;
}

.assistantJump:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.outline {
  display: grid;
  min-width: 0;
  gap: 0;
}

.outline :global(.katex) {
  font-size: 1em;
}

.outline :global(.katex-display) {
  display: inline;
  margin: 0;
}

.heading,
.paragraph {
  display: block;
  width: calc(100% + 34px);
  min-height: 26px;
  min-width: 0;
  margin-left: -34px;
  padding: 4px 10px 4px 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  letter-spacing: 0;
  line-height: 18px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}

.heading:hover,
.paragraph:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}

.heading[data-level="1"] {
  min-height: 32px;
  padding-top: 7px;
  padding-bottom: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.heading[data-level="2"] {
  min-height: 28px;
  padding-top: 5px;
  padding-bottom: 5px;
  padding-left: 50px;
  color: color-mix(in srgb, var(--text) 88%, var(--text-muted));
  font-size: 12px;
  font-weight: 500;
}

.heading[data-level="3"] {
  padding-left: 60px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
}

.paragraph {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
}

.assistant:has(.heading[data-level="1"]:first-child) .assistantJump {
  height: 32px;
  line-height: 32px;
}

.assistant:has(.heading[data-level="2"]:first-child) .assistantJump {
  height: 28px;
  line-height: 28px;
}

.user:focus-visible,
.heading:focus-visible,
.paragraph:focus-visible {
  outline: 0;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  box-shadow: inset 2px 0 0 color-mix(in srgb, var(--text-muted) 65%, transparent);
}

.assistantJump:focus-visible {
  outline: 1px solid color-mix(in srgb, var(--text-muted) 65%, transparent);
  outline-offset: 1px;
}
