:root {
  --bar: calc(3rem + var(--safe-top));
  --bar-icon: 2.5rem;
  --tap: 2.5rem;
  --gutter: 1rem;
  --column: 48rem;
  --side-w: 20rem;
  --side-offset: 0px;
}
.chat-viewport {
  position: relative;
  height: 100vh;
  height: var(--app-height, 100dvh);
  margin-left: var(--side-offset);
  padding: var(--bar) 0 var(--safe-bottom);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.18s ease;
}
.chat-stack {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem max(var(--gutter), calc((100% - var(--column)) / 2)) 2.5rem;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  mask-image:
    linear-gradient(
      to bottom,
      transparent 0,
      #000 1rem,
      #000 calc(100% - 0.75rem),
      transparent 100%);
  -webkit-mask-image:
    linear-gradient(
      to bottom,
      transparent 0,
      #000 1rem,
      #000 calc(100% - 0.75rem),
      transparent 100%);
}
.chat-stack > :first-child {
  margin-top: auto;
}
.chat-stack::-webkit-scrollbar {
  width: 10px;
}
.chat-stack::-webkit-scrollbar-thumb {
  background: rgba(var(--ink-rgb), 0.1);
  border-radius: 8px;
}
.chat-stack::-webkit-scrollbar-track {
  background: transparent;
}
.turn-pair {
  contain: layout style;
}
.turn-pair:has(.streaming) {
  contain: none;
}
.chat-stack:has(.welcome-hero:not([style*="display: none"])) {
  position: relative;
}
.welcome-hero {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  padding: 0 var(--gutter);
  text-align: center;
  pointer-events: none;
  z-index: 1;
}
.welcome-hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: #63778d;
  opacity: 0.5;
}
.welcome-hero .tm {
  font-size: 0.22em;
  font-weight: 400;
  opacity: 0.3;
  vertical-align: super;
  margin-left: 1px;
}
.welcome-hero .tagline {
  margin: 0 0 0.75rem;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 400;
  color: rgba(var(--ink-rgb), 0.55);
}
.welcome-hero .hero-claims {
  margin: 0 0 7rem;
  font-size: 0.75rem;
  color: rgba(var(--ink-rgb), 0.45);
}
.welcome-hero .claim-info {
  pointer-events: auto;
  color: inherit;
  text-decoration: none;
}
.welcome-hero .claim-info:hover {
  color: rgba(var(--ink-rgb), 0.75);
}
.welcome-hero .claim {
  position: relative;
  pointer-events: auto;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: none;
}
.welcome-hero .claim:hover,
.welcome-hero .claim:focus-visible {
  color: rgba(var(--ink-rgb), 0.75);
}
.welcome-hero .claim::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  z-index: 5;
  width: max-content;
  max-width: min(18rem, 80vw);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--card-border);
  background: var(--card);
  box-shadow: var(--shadow);
  color: rgba(var(--ink-rgb), 0.8);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
  pointer-events: none;
}
.welcome-hero .claim:hover::after,
.welcome-hero .claim:focus::after {
  opacity: 1;
  visibility: visible;
}
.welcome-hero .hero-cta {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 400;
  color: rgba(var(--ink-rgb), 0.5);
}
.welcome-hero .hero-signin {
  pointer-events: auto;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.welcome-hero .hero-signin:hover {
  color: rgba(var(--ink-rgb), 0.8);
}
.legal-footer a {
  color: inherit;
  text-decoration: none;
}
.legal-footer a:hover {
  text-decoration: underline;
}
.welcome-hero .hero-link {
  pointer-events: auto;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(var(--ink-rgb), 0.25);
  text-underline-offset: 0.2em;
}
.welcome-hero .inline-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin: 0 3px;
  vertical-align: middle;
}
.welcome-hero .inline-icon.login {
  margin-bottom: 2px;
  color: #4da866;
}
.welcome-hero .inline-icon.literacy {
  margin-bottom: 4px;
  mask: url(/icons/ai-literacy.svg) center/contain no-repeat;
  -webkit-mask: url(/icons/ai-literacy.svg) center/contain no-repeat;
  background:
    linear-gradient(
      135deg,
      #8d7c9f 0%,
      #6f93ab 25%,
      #81a593 50%,
      #a79482 75%,
      #9582aa 100%);
  opacity: 0.8;
}
.turn {
  position: relative;
  display: grid;
  gap: 0.625rem;
  font-size: 1rem;
  overflow-wrap: anywhere;
  contain: layout style;
}
.turn.system.streaming {
  contain: none;
}
.turn.user {
  width: fit-content;
  max-width: 85%;
  margin-left: auto;
  padding: 0.625rem 0.875rem;
  border-radius: 1.125rem;
  background: rgba(var(--ink-rgb), 0.05);
}
.turn.system {
  width: 100%;
  margin-top: 0.5rem;
}
.turn.system.system-notice {
  padding: 0.75rem 0.875rem;
  border: 1px solid rgba(245, 158, 66, 0.25);
  border-radius: 0.875rem;
  background: rgba(245, 158, 66, 0.04);
}
.turn.system.system-notice .outer-voice {
  color: #8b6914;
  font-size: 0.8125rem;
}
.body {
  min-width: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: break-word;
}
.body p {
  margin: 0;
}
.turn.user .body p {
  white-space: pre-wrap;
}
.outer-voice {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}
.outer-voice.streaming-indicator {
  font-style: italic;
  animation: thinkingPulse 1.8s ease-in-out infinite;
}
.outer-voice.streaming-indicator.trailing {
  margin-top: 10px;
  font-size: 0.85em;
  color: var(--faint);
}
@keyframes thinkingPulse {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.7;
  }
}
.outer-voice.error-text {
  color: #d32f2f;
}
.turn.system .body .markdown-content {
  animation: none !important;
  transition: none !important;
}
.markdown-content pre,
.markdown-content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.markdown-content img {
  max-width: 100%;
  height: auto;
}
.turn.user.editing {
  opacity: 0.6;
}
.turn.user.editing .body p {
  color: rgba(var(--ink-rgb), 0.5);
}
.editing-placeholder {
  font-style: italic;
  color: rgba(var(--ink-rgb), 0.4);
  letter-spacing: 0.1em;
}
.had-attachment-indicator {
  position: absolute;
  top: -5px;
  left: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--card);
  border-radius: 4px;
  opacity: 0.4;
  z-index: 1;
}
.had-attachment-indicator .ui-icon {
  width: 14px;
  height: 14px;
  color: #6875a0;
}
.had-attachment-indicator.warning {
  opacity: 0.8;
}
.had-attachment-indicator.warning .ui-icon {
  color: #e07040;
}
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.attachment-pill-readonly {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 140px;
  padding: 3px 8px 3px 5px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  font-size: 0.6875rem;
  color: #444;
}
.attachment-pill-readonly .attachment-preview {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
}
.attachment-pill-readonly .attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-pill-readonly .attachment-icon {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1;
}
.attachment-pill-readonly .attachment-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.25rem;
}
.response-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.25rem;
  margin-right: -0.5rem;
}
.reply-action {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  height: var(--tap);
  min-width: var(--tap);
  justify-content: center;
  padding: 0 0.375rem;
  border: none;
  border-radius: 0.5rem;
  background: transparent;
  font: inherit;
  color: rgba(var(--ink-rgb), 0.5);
  cursor: pointer;
}
.reply-action .ui-icon {
  width: 16px;
  height: 16px;
  opacity: 0.55;
}
.reply-action-tag {
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
}
.reply-action:hover,
.reply-action.copied {
  color: rgba(var(--ink-rgb), 0.85);
  background: rgba(var(--ink-rgb), 0.05);
}
.reply-action:hover .ui-icon,
.reply-action.copied .ui-icon {
  opacity: 0.85;
}
.reply-action-gap {
  width: 0.5rem;
}
@media (hover: hover) {
  .user-actions,
  .response-actions {
    opacity: 0;
    transition: opacity 150ms ease;
  }
  .turn-pair:hover .user-actions,
  .turn-pair:hover .response-actions,
  .user-actions:focus-within,
  .response-actions:focus-within {
    opacity: 1;
  }
}
.scroll-to-bottom {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}
.scroll-to-bottom.visible {
  opacity: 0.5;
  pointer-events: auto;
}
.scroll-to-bottom:hover {
  opacity: 0.8;
}
.scroll-to-bottom .ui-icon {
  width: 1.625rem;
  height: 1.625rem;
  color: var(--ink);
  opacity: 0.6;
}
.fast-scroll {
  position: fixed;
  z-index: 40;
  width: 2.75rem;
  height: 3rem;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  transition: opacity 200ms ease;
}
.fast-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0.25rem;
  bottom: 0;
  width: 0.375rem;
  border-radius: 0.25rem;
  background: rgba(var(--ink-rgb), 0.3);
  transition: width 120ms ease, background-color 120ms ease;
}
.fast-scroll.visible {
  opacity: 1;
  pointer-events: auto;
}
.fast-scroll.dragging::after {
  width: 0.5rem;
  background: rgba(var(--ink-rgb), 0.5);
}
@media (min-width: 769px) {
  body:has(.sidebar.open:not([style*="display: none"])) {
    --side-offset: var(--side-w);
  }
}
.turn-pair.found-turn {
  animation: found-turn 2.4s ease-out;
}
@keyframes found-turn {
  0%, 30% {
    background: rgba(var(--ink-rgb), 0.07);
  }
  100% {
    background: transparent;
  }
}
