

.chat-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg);
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary, #646e78);
  gap: 12px;
}

.chat-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty-icon svg {
  width: 36px;
  height: 36px;
  color: var(--color-primary);
}

.chat-empty p {
  font-size: var(--font-size-base);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  min-height: 0;
  background: transparent;
  border-bottom: none;
  position: relative;
  z-index: 11;
}
/* When sidebar is collapsed, make room for sidebar-open + new buttons */
.chat-sidebar.collapsed ~ .chat-main .chat-header {
  padding-left: 100px;
}
.chat-header-user {
  display: none;
}
.chat-header-profile-link,
.chat-header-name,
.chat-header-role,
.chat-header-avatar,
.chat-header-chevron {
  display: none;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

.chat-more-menu {
  position: relative;
}
.chat-more-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary, #9ca3af);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.chat-more-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  min-width: 44px;
  min-height: 44px;
}
.chat-more-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary);
}
.chat-more-btn svg {
  width: 18px;
  height: 18px;
}
/* Conversation header dropdown — design system aligned with .s-dropdown */
.chat-more-dropdown {
  display: none;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 180px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(31, 31, 30, 0.2);
  border-radius: 12px;
  box-shadow: rgba(0, 0, 0, 0.08) 0px 2px 8px 0px;
  padding: 6px;
  z-index: 100;
  font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: opacity 120ms cubic-bezier(0.16, 1, 0.3, 1), transform 120ms cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-more-dropdown.open {
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}
.chat-more-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgb(55, 55, 52);
  font-size: 14px;
  font-weight: 430;
  font-family: inherit;
  cursor: pointer;
  transition: background 75ms ease;
  line-height: 19.6px;
  -webkit-font-smoothing: antialiased;
  text-align: left;
}
.chat-more-item:hover {
  background: rgba(0, 0, 0, 0.04);
}
.chat-more-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted, rgb(115, 113, 108));
  flex-shrink: 0;
  stroke-width: 1.8;
}
.chat-more-item--danger {
  color: #c53030;
}
.chat-more-item--danger svg {
  color: #c53030;
}
.chat-more-item--danger:hover {
  background: rgba(197, 48, 48, 0.06);
}

[data-theme="dark"] .chat-more-dropdown {
  background: rgba(30, 30, 46, 0.95);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .chat-more-item {
  color: #e8ecf4;
}
[data-theme="dark"] .chat-more-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .chat-more-item svg {
  color: var(--text-muted, #8a92a6);
}
[data-theme="dark"] .chat-more-item--danger {
  color: #f87171;
}
[data-theme="dark"] .chat-more-item--danger svg {
  color: #f87171;
}
[data-theme="dark"] .chat-more-item--danger:hover {
  background: rgba(248, 113, 113, 0.1);
}
.chat-more-divider {
  height: 0.5px;
  background: rgba(0, 0, 0, 0.08);
  margin: 4px 6px;
}
[data-theme="dark"] .chat-more-divider {
  background: rgba(255, 255, 255, 0.08);
}

.chat-header-action svg {
  width: 20px;
  height: 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  /* We drive scroll manually (see chat-renderer._scrollToLastSent). Disable
     browser scroll-anchoring to prevent it from fighting our adjustments
     during streaming — otherwise both systems try to correct scroll each
     frame and the viewport visibly judders. */
  overflow-anchor: none;
  padding: 24px max(16px, calc(50% - 384px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  background: var(--color-bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
  transition: opacity 0.15s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.chat-msgs-fade-out {
  opacity: 0;
  transition: none;
}
.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.12);
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.2);
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chat-message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: min(85%, 75ch);
}

.chat-message.received {
  align-self: flex-start;
  max-width: 100%;
}

.chat-message-avatar {
  display: none;
}

.chat-message-content {  max-width: 100%;  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-bubble {
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Paragraphs (Claude: margin 0, grid gap handles spacing) ── */
.chat-bubble p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble p:empty { margin: 0; display: none; }

/* ── Headings (markdown # → h3, ## → h4, ### → h5) ── */
.chat-bubble h3 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  margin: 12px 0 -4px;
  color: inherit;
}
.chat-bubble h4 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.47;
  margin: 12px 0 -4px;
  color: inherit;
}
.chat-bubble h5, .chat-bubble h6 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  margin: 8px 0 -4px;
  color: inherit;
}

/* ── Lists (Claude: flex column, gap 4px, pl 32px) ── */
.chat-bubble ul, .chat-bubble ol {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 32px;
  margin: 0;
}
.chat-bubble ul { list-style: disc; }
.chat-bubble ol { list-style: decimal; }
.chat-bubble li {
  padding-left: 8px;
  margin: 0;
  line-height: 1.65;
  word-break: break-word;
}
/* Nested lists inside <li> — Claude: reduced gap, margin-top 4px */
.chat-bubble li > ul,
.chat-bubble li > ol {
  margin-top: 4px;
  padding-left: 32px;
  gap: 4px;
}

/* ── Inline code (Claude: dark red, subtle border) ── */
.chat-bubble code {
  font-family: ui-monospace, 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
  color: rgb(141, 37, 37);
  background: rgba(55, 55, 52, 0.05);
  border: 1px solid rgba(31, 31, 30, 0.15);
  border-radius: 6.4px;
  padding: 1px 4px;
  white-space: pre-wrap;
}
.chat-message.sent .chat-bubble code {
  color: inherit;
  background: rgba(255, 255, 255, 0.15);
  border-color: transparent;
}
[data-theme="dark"] .chat-message.received .chat-bubble code {
  color: #f0a0a0;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ── Code blocks (Claude: light bg, subtle border) ── */
.chat-code-block {
  position: relative;
  margin: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(31, 31, 30, 0.15);
  overflow: hidden;
}
.chat-code-block pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.08) transparent;
}
.chat-code-block code {
  font-family: ui-monospace, 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.625;
  color: rgb(20, 24, 31);
  background: none;
  padding: 0;
  border: none;
  border-radius: 0;
  white-space: pre;
}
.chat-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.chat-code-header svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.chat-code-lang {
  font-size: 12px;
  font-family: var(--font-family);
  color: rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chat-code-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chat-code-copy svg {
  width: 15px;
  height: 15px;
}
.chat-code-copy:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.6);
}
.chat-code-copy.done {
  color: #22c55e;
}
/* Dark mode code blocks */
[data-theme="dark"] .chat-code-block {
  background: #1e1e2e;
  border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .chat-code-block code {
  color: #e2e8f0;
}
[data-theme="dark"] .chat-code-header {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .chat-code-lang {
  color: rgba(255, 255, 255, 0.4);
}
[data-theme="dark"] .chat-code-copy {
  color: rgba(255, 255, 255, 0.35);
}
[data-theme="dark"] .chat-code-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}
[data-theme="dark"] .chat-code-block pre {
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* ── Bold (700 for Nunito Sans to visually match Anthropic Serif 600) ── */
.chat-bubble strong {
  font-weight: 700;
}

/* ── KaTeX math ── */
.chat-bubble .katex-display {
  margin: 8px 0;
  overflow-x: auto;
}
.chat-bubble .katex {
  font-size: 1em;
}

/* ── BR (grid gap handles spacing for received; keep for sent) ── */
.chat-message.received .chat-bubble > br {
  display: none;
}
.chat-message.sent .chat-bubble br {
  display: block;
  content: '';
  margin: 4px 0;
}

/* ── Links (Claude: underline, same color as text, subtle decoration) ── */
.chat-bubble a:not(.chat-refer-link) {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: rgba(0, 0, 0, 0.4);
}
.chat-bubble a:not(.chat-refer-link):hover {
  text-decoration-color: currentColor;
}
[data-theme="dark"] .chat-bubble a:not(.chat-refer-link) {
  text-decoration-color: rgba(255, 255, 255, 0.4);
}

/* ── Table (Claude: 14px, subtle borders) ── */
.chat-bubble table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.7;
}
.chat-bubble thead { text-align: left; }
.chat-bubble th {
  font-weight: 600;
  border-bottom: 1px solid rgba(31, 31, 30, 0.6);
  padding: 8px 16px 8px 1px;
  vertical-align: top;
  color: rgb(18, 18, 18);
}
.chat-bubble td {
  border-bottom: 1px solid rgba(31, 31, 30, 0.3);
  padding: 8px 16px 8px 1px;
  vertical-align: top;
}
[data-theme="dark"] .chat-bubble th {
  color: #e8e8ed;
  border-bottom-color: rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] .chat-bubble td {
  border-bottom-color: rgba(255, 255, 255, 0.15);
}

/* ── Blockquote (Claude: left border, muted text) ── */
.chat-bubble blockquote {
  border-left: 4px solid rgba(31, 31, 30, 0.1);
  margin-left: 8px;
  padding-left: 8px;
  color: rgb(55, 55, 52);
}
[data-theme="dark"] .chat-bubble blockquote {
  border-left-color: rgba(255, 255, 255, 0.1);
  color: #a0a0a0;
}

.chat-message.received .chat-bubble {
  background: transparent;
  color: rgb(18, 18, 18);
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  max-width: 720px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
[data-theme="dark"] .chat-message.received .chat-bubble {
  background: transparent;
  color: #e8e8ed;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.chat-message.sent .chat-bubble {
  background: var(--color-primary);
  color: #fff;
}

.v-voksen .chat-message.sent .chat-bubble {
  background: rgb(239, 238, 235);
  color: rgb(18, 18, 18);
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 430;
  line-height: 1.4;
  white-space: pre-wrap;
}
.v-voksen .chat-message.sent .chat-bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.4);
}
.v-voksen .chat-message.sent .chat-bubble code {
  background: rgba(0, 0, 0, 0.05);
  color: rgb(141, 37, 37);
}

[data-theme="dark"].v-voksen .chat-message.sent .chat-bubble {
  background: rgba(255, 255, 255, 0.08);
  color: #e8e8ed;
  font-weight: 430;
}
[data-theme="dark"].v-voksen .chat-message.sent .chat-bubble a {
  color: inherit;
  text-decoration-color: rgba(255, 255, 255, 0.4);
}
[data-theme="dark"].v-voksen .chat-message.sent .chat-bubble code {
  background: rgba(255, 255, 255, 0.1);
  color: #f0a0a0;
}



.chat-bubble-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.chat-bubble-img {
  max-width: 220px;
  max-height: 200px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.chat-bubble-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 13px;
}
.chat-bubble-file-icon {
  font-size: 16px;
  line-height: 1;
}

.chat-refer-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  margin: 4px 4px 4px 0;
  border-radius: 16px;
  border: 1px solid var(--color-border, #e7e7e8);
  background: transparent;
  color: var(--color-text-primary, #2b333b);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  cursor: pointer;
}
.chat-refer-link:hover {
  background: rgba(var(--color-primary-rgb), 0.06);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.chat-refer-label {
  white-space: nowrap;
}
.chat-refer-arrow {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.chat-refer-link:hover .chat-refer-arrow {
  opacity: 1;
}
[data-theme="dark"] .chat-refer-link {
  border-color: var(--color-border, #434968);
  color: var(--color-text-primary, #cfd3ec);
}
[data-theme="dark"] .chat-refer-link:hover {
  background: rgba(var(--color-primary-rgb), 0.12);
  color: var(--color-primary);
}

.chat-msg-footer {
  display: flex;
  align-items: center;
  margin-top: 4px;
  gap: 0;
}

.chat-message-time {
  display: none;
}
[data-theme="dark"] .chat-message-time {
  display: none;
}

.chat-message.sent .chat-message-content {  max-width: 100%;  overflow: hidden;
  align-items: flex-end;
}
.chat-message.sent .chat-msg-footer {
  justify-content: flex-end;
  gap: 6px;
}
.chat-message-status-wrap {
  display: none;
}

/* ── Long message truncation ──────────────────────── */
.chat-bubble.is-collapsed {
  max-height: 200px;
  overflow: hidden;
  position: relative;
}
.chat-message.sent .chat-bubble.is-collapsed {
  border-radius: var(--radius-lg);
}
.chat-bubble.is-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(transparent, var(--color-bg, #f5f5f9));
  pointer-events: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
/* Sent bubble collapse gradient (skole) */
.chat-message.sent .chat-bubble.is-collapsed::after {
  background: linear-gradient(transparent, var(--color-primary, #696cff));
}
.v-voksen .chat-message.sent .chat-bubble.is-collapsed::after {
  background: linear-gradient(transparent, #f0f0ee);
}
.v-voksen .chat-bubble.is-collapsed::after {
  background: linear-gradient(transparent, var(--color-bg, #FAFAF8));
}
[data-theme="dark"].v-voksen .chat-message.sent .chat-bubble.is-collapsed::after {
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.08));
}
[data-theme="dark"] .chat-bubble.is-collapsed::after {
  background: linear-gradient(transparent, var(--color-card, #2b2c40));
}
[data-theme="dark"] .chat-message.sent .chat-bubble.is-collapsed::after {
  background: linear-gradient(transparent, var(--color-primary, #696cff));
}
.chat-bubble-show-more {
  display: block;
  width: 100%;
  padding: 6px 0 2px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}
.chat-bubble-show-more:hover {
  color: var(--color-text-primary);
}

.chat-bubble-typing {
  display: inline-flex;
  align-items: center;
  /* Match .chat-bubble base padding so there is no height jump when
     the first streamed token arrives and the class is swapped. */
  padding: 10px 16px;
  min-height: 1.4em; /* matches .chat-bubble-streaming so no first-token jump */
  flex-wrap: wrap;
  gap: 6px;
}

/* Fix: prevent overflow:hidden from clipping bouncing dots */
#typing-bubble .chat-message-content {
  overflow: visible;
}

.chat-typing-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  width: 100%;
  line-height: 1;
  margin-bottom: 2px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-secondary);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.chat-date-divider {
  display: none;
}

.chat-read-receipt {
  color: var(--color-primary);
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Direction-change spacing: wider gap when switching sent↔received */
.chat-message.sent + .chat-message.received,
.chat-message.received + .chat-message.sent {
  margin-top: 14px;
}

.chat-msg-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0;
  position: relative;
}
/* Show on message hover (desktop) */
.chat-message:hover .chat-msg-action-btn {
  opacity: 0.5;
}
.chat-msg-action-btn svg {
  width: 16px;
  height: 16px;
}

.chat-msg-action-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  min-width: 44px;
  min-height: 44px;
}

.chat-msg-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary, #2b333b);
  opacity: 1;
}
[data-theme="dark"] .chat-msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e8e8ed;
}

.chat-msg-action-btn.done {
  color: #22c55e;
  opacity: 1;
}

.chat-msg-action-btn.active {
  color: var(--color-primary);
  opacity: 1;
}

/* light mode hover already handled above */

.chat-bubble hr.chat-hr {
  border: none;
  border-top: 0.5px solid rgba(31, 31, 30, 0.3);
  margin: 12px 6px;
}
[data-theme="dark"] .chat-bubble hr.chat-hr {
  border-top-color: rgba(255, 255, 255, 0.15);
}

.chat-empty-voksen-greeting {
  text-align: center;
  padding: 0 var(--space-4);
}

.chat-empty-heading {
  font-size: 28px;
  font-weight: 400;
  color: #131313;
  margin: 0;
  line-height: 34px;
  letter-spacing: -0.01em;
}
[data-theme="dark"] .chat-empty-heading {
  color: var(--color-text-primary, #e0e0e0);
}

.chat-empty-subtitle {
  font-size: 15px;
  font-weight: 400;
  color: #73716c;
  margin: 8px 0 0;
  line-height: 1.5;
}
[data-theme="dark"] .chat-empty-subtitle {
  color: var(--color-text-secondary, #8e8e8e);
}

.chat-empty-input-area {
  width: 100%;
  max-width: 768px;
  padding: 0 var(--space-4);
  margin-top: var(--space-6);
}

.chat-empty.v-voksen-only {
  justify-content: center;
  padding-bottom: 30px;
  gap: 0;
  align-items: center;
}

[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
}
[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}
[data-theme="dark"] .chat-messages {
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.chat-header-action {
  min-width: 44px;
  min-height: 44px;
}

.chat-msg-action-btn {
  min-width: 28px;
  min-height: 28px;
}

@media (max-width: 767px) {
  .chat-main {
    display: none;
  }

  .chat-main.active {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  .chat-header {
    padding: 6px 12px;
    min-height: 44px;
    border-bottom: none;
  }
  
  .chat-header-user {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .chat-messages {
    padding: 16px 12px;
  }

  .chat-message.sent {
    max-width: 80%;
  }

  .chat-message.received {
    max-width: 92%;
  }

  /* Always show action buttons on mobile (no hover) */
  .chat-msg-action-btn {
    opacity: 0.5;
  }

  .chat-bubble {
    font-size: 16px;
    line-height: 1.5;
  }
  .chat-message.received .chat-bubble {
    gap: 10px;
  }

  
  .chat-empty.v-voksen-only {
    justify-content: center;
    padding-bottom: 0;
  }
  .chat-empty-heading {
    font-size: 24px;
    line-height: 30px;
  }
  .chat-empty-input-area {
    padding: 0 var(--space-3);
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .chat-main {
    min-width: 0;
    overflow: hidden;
  }
}

/* Scroll-to-bottom FAB */
.chat-scroll-fab {
  position: absolute;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border, #e7e7e8);
  background: var(--color-card, #fff);
  color: var(--color-text-secondary, #646e78);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 5;
}
.chat-scroll-fab svg {
  width: 18px;
  height: 18px;
}
.chat-scroll-fab.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.chat-scroll-fab:hover {
  background: var(--color-bg, #f5f5f9);
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-scroll-fab {
  background: var(--color-card, #2b2c40);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .chat-scroll-fab:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ── Skeleton loading ── */
@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.chat-skeleton-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  align-items: flex-start;
}
.chat-skeleton-row.sent {
  flex-direction: row-reverse;
}

.chat-skeleton-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.03) 50%, rgba(0,0,0,0.06) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.chat-skeleton-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 65%;
  flex: 1;
}
.chat-skeleton-row.sent .chat-skeleton-content {
  align-items: flex-end;
}

.chat-skeleton-line {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 25%, rgba(0,0,0,0.03) 50%, rgba(0,0,0,0.06) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* Stagger the shimmer for visual variety */
.chat-skeleton-row:nth-child(2) .chat-skeleton-line,
.chat-skeleton-row:nth-child(2) .chat-skeleton-avatar { animation-delay: 0.15s; }
.chat-skeleton-row:nth-child(3) .chat-skeleton-line,
.chat-skeleton-row:nth-child(3) .chat-skeleton-avatar { animation-delay: 0.3s; }
.chat-skeleton-row:nth-child(4) .chat-skeleton-line,
.chat-skeleton-row:nth-child(4) .chat-skeleton-avatar { animation-delay: 0.45s; }
.chat-skeleton-row:nth-child(5) .chat-skeleton-line,
.chat-skeleton-row:nth-child(5) .chat-skeleton-avatar { animation-delay: 0.6s; }
.chat-skeleton-row:nth-child(6) .chat-skeleton-line,
.chat-skeleton-row:nth-child(6) .chat-skeleton-avatar { animation-delay: 0.75s; }

[data-theme="dark"] .chat-skeleton-avatar,
[data-theme="dark"] .chat-skeleton-line {
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 25%, rgba(255,255,255,0.03) 50%, rgba(255,255,255,0.06) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════
   ARTIFACT SYSTEM — ssdoc streaming & versioning
   ═══════════════════════════════════════════════ */

/* Zero-flash fix: hide raw ssdoc code blocks.
   doc-preview.js replaces them with cards after 50ms setTimeout.
   Without this, raw JSON flashes between stream end and card render. */
.chat-code-block[data-lang="ssdoc"] {
  display: none !important;
}

/* ── Document skeleton during ssdoc streaming ── */
.doc-preview-skeleton {
  border: 1px solid var(--color-border, #e7e7e8);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 12px;
  max-width: 500px;
}

.doc-skel-image {
  height: 120px;
  background: var(--color-bg, #f5f5f9);
  position: relative;
  overflow: hidden;
}

.doc-skel-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 25%,
    rgba(255,255,255,0.4) 50%,
    transparent 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.doc-skel-body {
  padding: 16px;
}

.doc-skel-line {
  height: 14px;
  border-radius: 7px;
  background: var(--color-border, #e7e7e8);
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.doc-skel-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.5) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.doc-skel-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.doc-skel-btn {
  flex: 1;
  height: 40px;
  border-radius: 8px;
  background: var(--color-border, #e7e7e8);
  position: relative;
  overflow: hidden;
}
.doc-skel-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.5) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
/* Stagger shimmer on skeleton body elements */
.doc-skel-line:nth-child(2)::after { animation-delay: 0.2s; }
.doc-skel-btn:nth-child(2)::after { animation-delay: 0.3s; }

/* Dark mode: skeleton */
[data-theme="dark"] .doc-preview-skeleton {
  border-color: #3a3a4a;
}

[data-theme="dark"] .doc-skel-image {
  background: #2a2a3a;
}

[data-theme="dark"] .doc-skel-shimmer {
  background: linear-gradient(90deg,
    transparent 25%,
    rgba(255,255,255,0.08) 50%,
    transparent 75%);
  background-size: 200% 100%;
}

[data-theme="dark"] .doc-skel-line,
[data-theme="dark"] .doc-skel-btn {
  background: #3a3a4a;
}

/* ── Version switcher in doc-preview card header ── */
.doc-version-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: 13px;
  white-space: nowrap;
}

.doc-version-prev,
.doc-version-next {
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border, #e7e7e8);
  border-radius: 6px;
  background: var(--color-surface, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text, #333);
  transition: background 0.15s;
}

.doc-version-prev:hover:not(:disabled),
.doc-version-next:hover:not(:disabled) {
  background: var(--color-bg, #f5f5f9);
}

.doc-version-prev:disabled,
.doc-version-next:disabled {
  opacity: 0.35;
  cursor: default;
}

.doc-version-label {
  min-width: 48px;
  text-align: center;
  color: var(--color-text-secondary, #666);
  font-weight: 500;
}

/* Dark mode: version switcher */
[data-theme="dark"] .doc-version-prev,
[data-theme="dark"] .doc-version-next {
  border-color: #3a3a4a;
  background: #2a2a3a;
  color: #ccc;
}

[data-theme="dark"] .doc-version-prev:hover:not(:disabled),
[data-theme="dark"] .doc-version-next:hover:not(:disabled) {
  background: #3a3a4a;
}

[data-theme="dark"] .doc-version-label {
  color: #aaa;
}

/* ── Update card (compact inline notification) ── */
.doc-update-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--color-border, #e7e7e8);
  border-radius: 10px;
  margin-top: 8px;
  max-width: 400px;
  font-size: 14px;
  background: var(--color-surface, #fff);
}

.doc-update-card .doc-update-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-primary, #696cff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-update-card .doc-update-info {
  flex: 1;
  min-width: 0;
}

.doc-update-card .doc-update-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-update-card .doc-update-version {
  font-size: 12px;
  color: var(--color-text-secondary, #666);
}

.doc-update-card .doc-update-link {
  color: var(--color-primary, #696cff);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

/* Dark mode: update card */
[data-theme="dark"] .doc-update-card {
  border-color: #3a3a4a;
  background: #2a2a3a;
}

[data-theme="dark"] .doc-update-card .doc-update-version {
  color: #aaa;
}

/* ── Full update card indicator (Claude.ai style — full card per version) ── */
.doc-preview-card--update {
  border-left: 3px solid var(--color-primary, #696cff);
}
.doc-preview-card--update .doc-type-badge {
  background: var(--color-primary, #696cff);
  color: #fff;
}
[data-theme="dark"] .doc-preview-card--update {
  border-left-color: #8b8eff;
}

/* ── Mobile responsive ── */
@media (max-width: 480px) {
  .doc-preview-header {
    flex-wrap: wrap;
  }

  .doc-version-switcher {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    margin-left: 0;
  }
}
