/* ============ CHAT PAGE — Sneat App Chat Style ============ */

/* Full-height chat container */
.chat-app {
  display: flex;
  height: calc(100vh - 32px); /* viewport minus padding */
  height: calc(100dvh - 32px); /* dynamic viewport for modern browsers */
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* ── LEFT SIDEBAR — Contacts ── */
.chat-sidebar {
  width: 320px;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.chat-sidebar-header {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.chat-sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-sidebar-avatar-status {
  position: relative;
}

.chat-sidebar-avatar-status::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-success);
  border: 2px solid var(--color-card);
}

.chat-search {
  flex: 1;
  position: relative;
}

.chat-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-secondary, #646e78);
  pointer-events: none;
}

.chat-search input {
  width: 100%;
  height: 32px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
}

.chat-search input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.16);
}

.chat-search input::placeholder {
  color: var(--color-text-secondary, #646e78);
}

/* Contact list */
.chat-contacts {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  padding: 8px 0;
  min-height: 0;
}

.chat-contacts-label {
  padding: 12px 20px 8px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #646e78);
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
}

.chat-contact:hover {
  background: var(--color-bg);
}

.chat-contact.active {
  background: rgba(var(--color-primary-rgb), 0.06);
  border-radius: 8px;
  border-left: 3px solid var(--color-primary);
  padding-left: 17px;
}

.chat-contact.active .chat-contact-name {
  color: var(--color-primary);
  font-weight: 600;
}

.chat-contact.active .chat-contact-preview,
.chat-contact.active .chat-contact-time {
  color: var(--color-text-secondary);
}

.chat-contact.active .chat-contact-status::after {
  border-color: var(--color-primary);
}

/* Contact avatar */
.chat-contact-avatar {
  position: relative;
  flex-shrink: 0;
}

.chat-contact-avatar img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.chat-contact-avatar .initials {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: #fff;
}

.chat-contact-status {
  position: relative;
}

.chat-contact-status::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-card);
}

.chat-contact-status.online::after { background: var(--color-success); }
.chat-contact-status.away::after { background: var(--color-warning); }
.chat-contact-status.busy::after { background: var(--color-error); }
.chat-contact-status.offline::after { background: var(--color-text-secondary); }


/* Contact info */
.chat-contact-info {
  flex: 1;
  min-width: 0;
}

.chat-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-contact-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-contact-time {
  font-size: 12px;
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-contact-preview {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Subject badge under name */
.tutor-emoji {  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;  font-style: normal;  font-weight: normal;}
.chat-contact-subject {
  font-size: 12px;
  color: var(--color-text-secondary, #646e78);
  margin-top: 1px;
}

.chat-contact.active .chat-contact-subject {
  color: var(--color-primary);
  opacity: 0.8;
}

/* Unread badge */
.chat-contact-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-contact.active .chat-contact-badge {
  background: var(--color-primary);
  color: #fff;
}

/* ── RIGHT SIDE — Conversation ── */
.chat-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-bg);
}

/* Empty state (no contact selected) */
.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 */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  min-height: 64px;
  background: var(--color-card);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  position: relative;
  z-index: 2;
}

.chat-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.chat-header-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 2px;
}

.chat-header-role {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
}

.chat-header-profile-link {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.chat-header-profile-link:hover {
  background: var(--color-bg);
}

.chat-header-chevron {
  color: var(--color-text-secondary, #646e78);
  opacity: 0.5;
  transition: opacity var(--transition);
  vertical-align: middle;
  margin-left: 2px;
}

.chat-header-profile-link:hover .chat-header-chevron {
  opacity: 1;
}

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

.chat-header-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.chat-header-action:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

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

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--color-bg);
}

/* Single message */
.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 75%;
}

.chat-message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.received {
  align-self: flex-start;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.chat-message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

/* Markdown formatting inside AI bubbles */
.chat-bubble p {
  margin: 0 0 6px;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}
.chat-bubble h4, .chat-bubble h5, .chat-bubble h6 {
  margin: 10px 0 4px;
  font-size: inherit;
  font-weight: 600;
  line-height: 1.3;
}
.chat-bubble h4 { font-size: 1.05em; }
.chat-bubble ul, .chat-bubble ol {
  
  margin: 4px 0 8px;
  padding-left: 20px;
}
.chat-bubble li {
  margin-bottom: 3px;
}
.chat-bubble ul { list-style: disc; }.chat-bubble ol { list-style: decimal; }
.chat-bubble li:last-child {
  margin-bottom: 0;
}
.chat-bubble code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}
.chat-bubble strong {
  font-weight: 700;
}
.chat-bubble .katex-display {
  margin: 8px 0;
  overflow-x: auto;
}
.chat-bubble .katex {
  font-size: 1em;
}
.chat-bubble br {
  display: block;
  content: '';
  margin: 4px 0;
}

.chat-message.received .chat-bubble {
  background: var(--color-card);
  color: var(--color-text-primary);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-bubble);
}

.chat-message.sent .chat-bubble {
  background: var(--color-primary);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Image & file attachments inside sent bubbles */
.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: 12px;
}
.chat-bubble-file-icon {
  font-size: 16px;
  line-height: 1;
}

/* REFER link card inside AI bubbles */
.chat-refer-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  margin-top: 8px;
  border-radius: var(--radius-md);
  background: rgba(var(--color-primary-rgb), 0.06);
  color: var(--color-primary);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  transition: background 0.15s;
  cursor: pointer;
}
.chat-refer-link:hover {
  background: rgba(var(--color-primary-rgb), 0.12);
}
.chat-refer-icon {
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1.7;
}
.chat-refer-body {
  flex: 1;
  min-width: 0;
}
.chat-refer-label {
  font-weight: 600;
}
.chat-refer-arrow {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1.5;
}
[data-theme="dark"] .chat-refer-link {
  background: rgba(var(--color-primary-rgb), 0.12);
}
[data-theme="dark"] .chat-refer-link:hover {
  background: rgba(var(--color-primary-rgb), 0.20);
}

/* Message footer: time + action buttons on same row */
.chat-msg-footer {
  display: flex;
  align-items: center;
  margin-top: 4px;
  gap: 0;
}
.chat-message-time {
  font-size: 12px;
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  line-height: 22px;
}

/* Sent: footer right-aligned, time + check together */
.chat-message.sent .chat-message-content {
  align-items: flex-end;
}
.chat-message.sent .chat-msg-footer {
  justify-content: flex-end;
  gap: 6px;
}
.chat-message-status-wrap {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--color-primary);
  line-height: 22px;
}

/* Typing indicator — rendered as a received message bubble */
.chat-bubble-typing {
  display: inline-flex;
  align-items: center;
  padding: 12px 18px;
  min-height: 0;
}

.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; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input area */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  background: var(--color-card);
}

.chat-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.chat-upload-btn:hover {
  background: var(--color-card);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.chat-upload-btn svg {
  width: 20px;
  height: 20px;
}
.chat-file-input {
  display: none;
}

.chat-input-wrap {
  flex: 1;
  flex-wrap: wrap;
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-input-wrap:focus-within {
  border-color: var(--color-primary);
  background: var(--color-card);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

.chat-input-field {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 90px 10px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--color-text-primary);
  font-size: 15px;
  font-family: var(--font-family);
  resize: none;
  line-height: 1.5;
}

.chat-input-field:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.chat-input-field::placeholder {
  color: var(--color-text-secondary, #646e78);
}

.chat-input-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  align-items: center;
}


/* File upload preview */
.chat-file-preview {
  display: flex;
  gap: 8px;
  padding: 10px 12px 4px;
  width: 100%;
  overflow-x: auto;
  flex-shrink: 0;
}
.chat-file-preview:empty {
  display: none;
}
.chat-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--color-text-primary);
  white-space: nowrap;
  max-width: 200px;
  flex-shrink: 0;
}
.chat-file-item-thumb {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-file-item-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light, rgba(99,102,241,0.1));
  border-radius: 6px;
  flex-shrink: 0;
  font-size: 14px;
}
.chat-file-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.chat-file-item-remove {
  width: 28px;
  height: 28px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 14px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.chat-file-item-remove:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.chat-input-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.chat-input-action:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

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

.chat-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.3);
  white-space: nowrap;
}

.chat-send-btn:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
}

/* ── RIGHT SIDEBAR — Tutor Profile ── */
.chat-profile {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 0;
  overflow: hidden;
  border-left: 1px solid var(--color-border);
  transition: width var(--transition-slow);
  background: var(--color-card);
  z-index: 10;
}

.chat-profile.open {
  width: 300px;
}

.chat-profile-inner {
  width: 300px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
}

.chat-profile-close {
  align-self: flex-end;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  flex-shrink: 0;
}
.chat-profile-close svg {
  width: 16px;
  height: 16px;
}

.chat-profile-close:hover {
  background: var(--color-bg);
}

.chat-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.chat-profile-name {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
}

.chat-profile-role {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary, #646e78);
  text-align: center;
  margin-top: -12px;
}

.chat-profile-section {
  width: 100%;
}

.chat-profile-section-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #646e78);
  margin-bottom: 8px;
}

.chat-profile-about {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  line-height: 1.6;
}

.chat-profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-profile-tag {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

/* Mobile back button (hidden on desktop) */
.chat-back-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 4px;
}

.chat-back-btn svg {
  width: 20px;
  height: 20px;
}

/* ── RESPONSIVE ── */

/* Tablet */
@media (max-width: 1279px) {
  .chat-profile.open {
    width: 260px;
  }
  .chat-profile-inner {
    width: 260px;
  }
}

/* Mobile */
@media (max-width: 991px) {
  .chat-app {
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
  }

  .chat-sidebar {
    width: 260px;
  }

  .chat-profile.open {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    background: var(--color-card);
    z-index: 10;
    box-shadow: var(--shadow-panel);
  }
}

@media (max-width: 767px) {
  .chat-app {
    flex-direction: column;
    height: calc(100vh - 60px); /* viewport minus mobile bottom nav */
    height: calc(100dvh - 60px); /* dynamic viewport for modern phones with notch */
    border-radius: 0;
    box-shadow: none;
  }

  .chat-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    max-height: 100%;
  }

  .chat-sidebar.hidden {
    display: none;
  }

  .chat-main {
    display: none;
  }

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

  .chat-profile {
    display: none;
  }

  .chat-back-btn {
    display: flex;
  }

  .chat-message {
    max-width: 88%;
  }

  .chat-bubble {
    font-size: 15px;
    line-height: 1.5;
  }

  .chat-greeting-text {
    font-size: 20px;
  }

  .chat-greeting-sub {
    font-size: 14px;
  }

  .chat-input {
    gap: 6px;
    padding: 10px 12px;
  }

  .chat-input-field {
    padding-right: 80px;
  }

  .chat-upload-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .chat-send-btn {
    padding: 0 16px;
    min-height: 44px;
  }

  .chat-input-actions button {
    min-width: 44px;
    min-height: 44px;
  }

  .chat-profile.open {
    display: block;
    position: fixed;
    inset: 0;
    width: 100%;
    border-radius: 0;
    background: var(--color-card);
    z-index: 20;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chat-contact {
    padding: 14px 16px;
    min-height: 64px;
  }

  .chat-contact-avatar {
    width: 44px;
    height: 44px;
  }

  .chat-emoji-picker-wrap {
    display: none;
  }

  .chat-upload-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
  }

  .chat-upload-btn svg {
    width: 18px;
    height: 18px;
  }

  .chat-send-btn {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: 10px;
    min-width: auto;
  }

  .chat-send-btn svg {
    width: 14px;
    height: 14px;
  }

  .chat-input {
    gap: 8px;
    padding: 8px 10px;
  }

  .chat-input-field {
    min-height: 38px;
    padding: 8px 44px 8px 12px;
    font-size: 14px;
  }

  .chat-input-wrap {
    border-radius: 10px;
  }

  #chat-mic-btn {
    width: 32px;
    height: 32px;
  }
}


/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 767px) {
    .chat-input {
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
  }
}
/* Date divider */
.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-text-secondary, #646e78);
  font-size: var(--font-size-xs);
  margin: 8px 0;
}

.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

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


/* Grouped consecutive messages from same sender */
.chat-message.grouped {
  margin-top: -12px; /* counteract the 16px gap to get ~4px */
}

.chat-message.grouped .chat-message-avatar {
  visibility: hidden;
}

/* Emoji picker button & popup */
.chat-emoji-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  
  
}

.chat-emoji-btn:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

.chat-emoji-picker-wrap {
  position: relative;
}

.chat-emoji-picker {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popup);
  padding: 12px;
  z-index: 20;
  width: 240px;
}

.chat-emoji-picker.open {
  display: block;
  animation: emojiFadeIn 0.15s ease;
}

@keyframes emojiFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.chat-emoji-grid button {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md, 8px);
  font-size: 22px;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-emoji-grid button:hover {
  background: var(--color-primary-light);
}

/* Character count (near limit only) */
.chat-char-count {
  position: absolute;
  right: 12px;
  bottom: -18px;
  font-size: 12px;
  color: var(--color-text-secondary, #646e78);
  font-family: var(--font-family);
}

.chat-char-count.over-limit {
  color: var(--color-error);
  font-weight: 600;
}

/* Input wrap needs relative positioning for char count */
.chat-input {
  position: relative;
}

/* Message action buttons (Copy + TTS) — always visible next to time */
.chat-msg-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--color-border, rgba(255,255,255,0.1));
}

.chat-msg-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--color-text-secondary, #6b7280);
  cursor: pointer;
  transition: all 0.15s ease;
  opacity: 0.6;
}

.chat-msg-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary, #e2e8f0);
  opacity: 1;
}

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

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

/* Mic recording state */
#chat-mic-btn.recording {
  color: #ef4444;
  animation: pulse-mic 1.5s ease-in-out infinite;
}

@keyframes pulse-mic {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* TTS spin animation */
.spin-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Light mode override */
[data-theme="light"] .chat-msg-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-primary, #111827);
}

/* Custom confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.confirm-overlay.visible {
  opacity: 1;
}

.confirm-dialog {
  background: var(--color-card, #fff);
  border-radius: 16px;
  padding: 28px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.confirm-overlay.visible .confirm-dialog {
  transform: scale(1);
}

.confirm-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary, #111827);
  margin: 0 0 8px 0;
}

.confirm-message {
  font-size: 14px;
  color: var(--color-text-secondary, #6b7280);
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.confirm-btn {
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.confirm-cancel {
  background: var(--color-bg, #f3f4f6);
  color: var(--color-text-primary, #374151);
}

.confirm-cancel:hover {
  background: #e5e7eb;
}

.confirm-ok {
  background: #ef4444;
  color: #fff;
}

.confirm-ok:hover {
  background: #dc2626;
}

/* Connecting state for mic */
#chat-mic-btn.connecting {
  opacity: 0.5;
  pointer-events: none;
}

/* Dark mode */
[data-theme="dark"] .confirm-overlay {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .confirm-dialog {
  background: var(--color-card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .confirm-cancel {
  background: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .confirm-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ── Greeting header (replaces avatar + search) ── */
.chat-greeting {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.chat-greeting-text {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
}

.chat-greeting-sub {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
}

/* ── Subject section labels ── */
.chat-contacts-label-subjects {
  margin-top: 8px;
  padding-top: 0;
}

/* ── Subject color border on contacts ── */
.chat-contact {
  border-left: 3px solid transparent;
}

.chat-contact.active {
  border-left-color: rgba(255,255,255,0.3) !important;
}

/* ── Dark mode for new elements ── */
[data-theme="dark"] .chat-greeting-text {
  color: #e8ecf4;
}

[data-theme="dark"] .chat-greeting-sub {
  color: #8a92a6;
}



/* ============================================================
   VOKSEN CHAT — Template Landing, History, Edition Overrides
   ============================================================ */

/* ── 1. TEMPLATE LANDING PAGE ── */

.chat-templates-landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-8) var(--space-6);
  overflow-y: auto;
  background: var(--color-bg);
}

/* Header: avatar + heading + subtitle centered */
.chat-templates-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.chat-templates-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.chat-templates-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-1) 0;
  font-family: var(--font-family);
}

.chat-templates-subtitle {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-secondary, #646e78);
  margin: 0;
  font-family: var(--font-family);
}

/* Section spacing */
.chat-templates-section {
  width: 100%;
  max-width: 560px;
  margin-top: var(--space-6);
}

/* Section label — uppercase per STYLEGUIDE */
.chat-templates-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #646e78);
  margin-bottom: var(--space-3);
  font-family: var(--font-family);
}

/* Template grid — 2 columns desktop */
.chat-templates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

/* Individual template card */
.chat-template-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4);
  background: var(--color-card);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  min-height: 44px;
  font-family: var(--font-family);
  text-align: left;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
}

.chat-template-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.chat-template-card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Per-card color tints */
.chat-template-card[data-template="email"] { background: linear-gradient(135deg, rgba(59,130,246,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="application"] { background: linear-gradient(135deg, rgba(34,197,94,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="authority"] { background: linear-gradient(135deg, rgba(139,92,246,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="linkedin"] { background: linear-gradient(135deg, rgba(245,158,11,0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="improve"] { background: linear-gradient(135deg, rgba(var(--color-primary-rgb),0.05) 0%, var(--color-card) 60%); }
.chat-template-card[data-template="summarize"] { background: linear-gradient(135deg, rgba(6,182,212,0.05) 0%, var(--color-card) 60%); }

/* SVG icon circle */
.chat-template-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: var(--space-1);
}

.chat-template-icon svg {
  width: 22px;
  height: 22px;
}

/* Card title */
.chat-template-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.3;
}

/* Card description */
.chat-template-desc {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--color-text-secondary, #646e78);
  margin: 0;
  line-height: 1.4;
}

/* Small inline "add" button inside a card */
.chat-template-add-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition);
  align-self: flex-start;
  margin-top: var(--space-1);
}

.chat-template-add-btn:hover {
  background: rgba(var(--color-primary-rgb), 0.2);
}

.chat-template-add-btn svg {
  width: 14px;
  height: 14px;
}

/* Empty state for templates */
.chat-templates-empty {
  /* Ensure gray, not inherited from parent */
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: #646e78; /* hardcoded gray to prevent edition color bleed */
  font-style: italic;
  padding: var(--space-4) 0;
  font-family: var(--font-family);
}


/* ── 2. EDITION VISIBILITY OVERRIDES ── */

.chat-empty.v-skole-only {
  display: none;
}

.chat-empty.v-voksen-only {
  display: none;
}

.v-skole .chat-empty.v-skole-only {
  display: flex;
}

.v-voksen .chat-empty.v-voksen-only {
  display: flex;
  flex-direction: column;
}

/* Bulletproof: when conversation is active, ALWAYS hide empty states */
#chat-main.chat-has-conversation .chat-empty { display: none !important; }


/* Templates landing also respects edition */
.chat-templates-landing.v-skole-only {
  display: none;
}

.chat-templates-landing.v-voksen-only {
  display: none;
}

.v-skole .chat-templates-landing.v-skole-only {
  display: flex;
}

.v-voksen .chat-templates-landing.v-voksen-only {
  display: flex;
}


/* ── 3. CONVERSATION HISTORY IN SIDEBAR (VOKSEN) ── */

.chat-history-section {
  padding: var(--space-2) 0;
}

/* Time bucket label: "I dag", "I går", "Denne uge" */
.chat-history-label {
  padding: var(--space-3) var(--space-5) var(--space-2);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary, #646e78);
  font-family: var(--font-family);
}

/* Individual conversation history item */
.chat-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
  min-height: 44px;
  border-left: 3px solid transparent;
}

.chat-history-item:hover {
  background: var(--color-bg);
}

.chat-history-item.active {
  background: var(--color-primary);
  border-left-color: rgba(255, 255, 255, 0.3);
}

.chat-history-item.active .chat-history-title,
.chat-history-item.active .chat-history-time {
  color: #fff;
}

.chat-history-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-history-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-history-preview {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Actions on history item (delete, etc.) */
.chat-history-actions {
  display: flex;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}

.chat-history-item:hover .chat-history-actions {
  opacity: 1;
}

.chat-history-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.chat-history-action-btn:hover {
  background: var(--color-error-light);
  color: var(--color-error);
}

.chat-history-action-btn svg {
  width: 16px;
  height: 16px;
}

/* New conversation button */
.chat-history-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: calc(100% - var(--space-5) * 2);
  margin: var(--space-3) var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  min-height: 44px;
}

.chat-history-new-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

.chat-history-new-btn svg {
  width: 18px;
  height: 18px;
}


/* ── 4. CUSTOM TEMPLATE CREATION FORM ── */

.chat-template-form {
  width: 100%;
  max-width: 560px;
  padding: var(--space-5);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
}

.chat-template-form-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-4) 0;
  font-family: var(--font-family);
}

.chat-template-form-group {
  margin-bottom: var(--space-4);
}

.chat-template-form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
  font-family: var(--font-family);
}

.chat-template-form-input,
.chat-template-form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-template-form-input:focus,
.chat-template-form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.16);
  background: var(--color-card);
}

.chat-template-form-input::placeholder,
.chat-template-form-textarea::placeholder {
  color: var(--color-text-secondary, #646e78);
}

.chat-template-form-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.chat-template-form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary, #646e78);
  margin-top: var(--space-1);
  font-family: var(--font-family);
}

.chat-template-form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
}

.chat-template-form-cancel {
  padding: var(--space-2) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition);
  min-height: 44px;
}

.chat-template-form-cancel:hover {
  background: var(--color-bg);
}

.chat-template-form-save {
  padding: var(--space-2) var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 6px rgba(var(--color-primary-rgb), 0.3);
  min-height: 44px;
}

.chat-template-form-save:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

.chat-template-form-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* ── 5. RESPONSIVE — Templates & History ── */

@media (max-width: 767px) {
  .chat-templates-landing {
    padding: var(--space-6) var(--space-4);
  }

  .chat-templates-grid {
    grid-template-columns: 1fr;
  }

  .chat-template-card {
    padding: var(--space-4);
  }

  .chat-templates-header {
    margin-bottom: var(--space-6);
  }

  .chat-templates-avatar {
    width: 56px;
    height: 56px;
  }

  .chat-templates-title {
    font-size: var(--font-size-lg);
  }

  .chat-history-item {
    padding: var(--space-3) var(--space-4);
  }

  .chat-history-label {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .chat-history-new-btn {
    margin-left: var(--space-4);
    margin-right: var(--space-4);
    width: calc(100% - var(--space-4) * 2);
  }

  .chat-history-actions {
    opacity: 1;
  }

  .chat-template-form {
    padding: var(--space-4);
  }

  .chat-template-form-actions {
    flex-direction: column;
  }

  .chat-template-form-cancel,
  .chat-template-form-save {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}


/* ── 6. DARK MODE — Templates & History ── */

[data-theme="dark"] .chat-template-card {
  background: var(--color-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .chat-template-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Dark mode per-card tints (slightly brighter for dark bg) */
[data-theme="dark"] .chat-template-card[data-template="email"] { background: linear-gradient(135deg, rgba(59,130,246,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="application"] { background: linear-gradient(135deg, rgba(34,197,94,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="authority"] { background: linear-gradient(135deg, rgba(139,92,246,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="linkedin"] { background: linear-gradient(135deg, rgba(245,158,11,0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="improve"] { background: linear-gradient(135deg, rgba(var(--color-primary-rgb),0.1) 0%, var(--color-card) 60%); }
[data-theme="dark"] .chat-template-card[data-template="summarize"] { background: linear-gradient(135deg, rgba(6,182,212,0.1) 0%, var(--color-card) 60%); }

[data-theme="dark"] .chat-template-form {
  background: var(--color-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .chat-template-form-input,
[data-theme="dark"] .chat-template-form-textarea {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .chat-template-form-cancel {
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .chat-template-form-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .chat-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .chat-history-action-btn:hover {
  background: rgba(255, 62, 29, 0.15);
}

/* ── 7. CUSTOM TEMPLATE MODAL ── */

.chat-template-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
}

.chat-template-modal {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}

.chat-template-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.chat-template-modal-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);  /* 18px per STYLEGUIDE */
  font-weight: 600;                /* 600 per STYLEGUIDE modal headings */
  color: var(--color-text-primary);
  font-family: var(--font-family);
}

.chat-template-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
  /* 44px min touch target per STYLEGUIDE accessibility */
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.chat-template-modal-close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg);
}

.chat-template-modal-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-template-modal-label {
  font-size: var(--font-size-sm);  /* 13px per STYLEGUIDE */
  font-weight: 500;                /* 500 per STYLEGUIDE labels */
  color: var(--color-text-primary);
  margin-bottom: calc(var(--space-1) * -1);
  font-family: var(--font-family);
  display: block;
}

.chat-template-modal-input,
.chat-template-modal-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-card);
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.chat-template-modal-input:focus,
.chat-template-modal-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 105, 108, 255), 0.15);
}

.chat-template-modal-input::placeholder,
.chat-template-modal-textarea::placeholder {
  color: var(--color-text-tertiary);
}

.chat-template-modal-textarea {
  resize: vertical;
  min-height: 80px;
}

.chat-template-icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chat-template-icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-template-icon-option {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-card);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  color: var(--color-text-secondary, #646e78);
}

.chat-template-icon-option svg {
  width: 20px;
  height: 20px;
}

.chat-template-icon-option:hover {
  border-color: var(--color-primary);
  transform: scale(1.1);
}

.chat-template-icon-option.selected {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb, 105, 108, 255), 0.1);
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb, 105, 108, 255), 0.2);
}

.chat-template-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

.chat-template-modal-cancel {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;  /* 44px touch target per STYLEGUIDE */
}

.chat-template-modal-cancel:hover {
  background: var(--color-bg);
}

.chat-template-modal-save {
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 44px;  /* 44px touch target per STYLEGUIDE */
}

.chat-template-modal-save:hover {
  opacity: 0.9;
}

/* Delete button on custom template cards */
.chat-template-delete {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--color-text-secondary, #646e78);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.chat-template-card:hover .chat-template-delete {
  opacity: 1;
}

.chat-template-delete:hover {
  background: var(--color-danger, #e24668);
  color: #fff;
}

/* Custom template cards need position:relative for delete button */
.chat-template-custom {
  position: relative;
}

/* ── 8. DARK MODE — Template Modal ── */

[data-theme="dark"] .chat-template-modal {
  background: var(--color-card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .chat-template-modal-input,
[data-theme="dark"] .chat-template-modal-textarea {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .chat-template-modal-cancel {
  border-color: var(--color-border);
  color: var(--color-text-primary);
  background: transparent;
}

[data-theme="dark"] .chat-template-modal-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .chat-template-icon-option {
  border-color: var(--color-border);
  background: var(--color-bg);
}

[data-theme="dark"] .chat-template-delete {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-secondary, #646e78);
}

[data-theme="dark"] .chat-template-delete:hover {
  background: var(--color-danger, #e24668);
  color: #fff;
}

[data-theme="dark"] .chat-templates-empty {
  color: #8a92a6;
}

/* ── 8b. RESPONSIVE — Template Modal ── */
@media (max-width: 767px) {
  .chat-template-modal-overlay {
    padding: var(--space-3);
    align-items: flex-end;     /* slide up from bottom on mobile */
  }

  .chat-template-modal {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .chat-template-modal-body {
    padding: var(--space-3) var(--space-4);
  }

  .chat-template-modal-header {
    padding: var(--space-3) var(--space-4);
  }

  .chat-template-modal-footer {
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
  }

  .chat-template-modal-cancel,
  .chat-template-modal-save {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}


/* ============================================================
   STYLEGUIDE QA FIXES — 2026-03-20
   ============================================================ */

/* FIX: .chat-templates-header h3 — apply page heading pattern.
   Was inheriting default h3 (500 weight, ~17.55px).
   Per STYLEGUIDE: page heading = 20px, 600 weight. */
.chat-templates-header h3 {
  font-size: var(--font-size-xl);   /* 20px */
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-1) 0;
  font-family: var(--font-family);
}

/* FIX: Touch targets — min 44px per STYLEGUIDE accessibility rules.
   Visual icon stays small, but clickable area meets 44px minimum. */
.chat-header-action {
  min-width: 44px;
  min-height: 44px;
}

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

.chat-emoji-btn {
  min-width: 44px;
  min-height: 44px;
}

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

.chat-profile-close {
  min-width: 28px;
  min-height: 28px;
}

.chat-template-add-btn {
  min-height: 44px;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

/* iOS zoom prevention — inputs must be 16px+ to prevent auto-zoom */
@media (max-width: 767px) {
  .chat-input-field {
    font-size: 16px;
  }
}

/* Hide mobile bottom nav on chat page — chat has its own input bar at bottom */
@media (max-width: 767px) {
  .chat-page .mobile-bottom-nav {
    display: none !important;
  }
  .chat-page .chat-app {
    height: 100vh !important;
    height: 100dvh !important;
  }
}

/* ── 9. DIRECT INPUT ON LANDING PAGE (VOKSEN) ── */

.chat-direct-input {
  margin-top: var(--space-8);
  padding: 0 var(--space-4);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.chat-direct-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  gap: var(--space-2);
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  background: var(--color-card);
  transition: border-color 0.15s ease;
}
.chat-direct-input-wrap:focus-within {
  border-color: var(--color-primary);
}
.chat-direct-input-field {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: 16px; /* prevent iOS zoom */
  color: var(--color-text-primary);
  resize: none;
  min-height: 44px;
  line-height: 1.5;
  padding: var(--space-2) 0;
}
.chat-direct-input-field:focus { outline: none; }
.chat-direct-input-field::placeholder { color: var(--color-text-secondary, #646e78); }
.chat-direct-send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.chat-direct-send-btn:hover { background: var(--color-primary-hover); }
.chat-direct-send-btn:active { transform: scale(0.92); }

/* Focus-visible for keyboard navigation (a11y) */
.chat-direct-send-btn:focus-visible,
.chat-direct-upload-btn:focus-visible,
.chat-direct-mic-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.chat-refer-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-md);
}

/* Upload button (direct input) */
.chat-direct-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  color: var(--color-text-secondary, #646e78);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.chat-direct-upload-btn:hover {
  background: rgba(var(--color-primary-rgb), 0.10);
  color: var(--color-primary);
}
.chat-direct-upload-btn:active {
  background: rgba(var(--color-primary-rgb), 0.12);
  color: var(--color-primary);
}
.chat-direct-upload-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Sidebar template shortcuts (voksen) ── */
.chat-sidebar-templates {
  padding: 0 var(--space-3);
  margin-top: var(--space-2);
  flex-shrink: 0;
}

/* Shared section header (SKABELONER / SAMTALER) */
.chat-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-1);
}

.chat-sidebar-tpl-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 8px var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: var(--font-family);
  text-align: left;
}

.chat-sidebar-tpl-btn:hover {
  background: var(--color-primary-light);
}

.chat-sidebar-tpl-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-sidebar-tpl-icon svg {
  width: 16px;
  height: 16px;
}

.chat-sidebar-tpl-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-sidebar-tpl-add {
  width: 100%;
  border: none;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--font-size-sm);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-family);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-sidebar-tpl-add:hover {
  background: var(--color-primary);
  color: #fff;
}

.chat-sidebar-custom-tpls:empty::after {
  content: '';
}

/* Simple voksen empty state */
.chat-empty-voksen-simple {
  text-align: center;
  padding: var(--space-8) var(--space-8) var(--space-4);
}

.chat-empty-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
  object-fit: cover;
}

.chat-empty-voksen-simple h3 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.chat-empty-voksen-simple p {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

@media (max-width: 767px) {
  .chat-sidebar-templates {
    padding: 0 var(--space-2);
  }
  .chat-sidebar-tpl-btn {
    padding: 6px var(--space-2);
  }
}

/* Position Sofia empty state in upper portion, not dead center */
.chat-empty.v-voksen-only {
  justify-content: flex-start;
  padding-top: 15vh;
}

/* Center Sofia avatar in empty state */
.chat-empty-voksen-simple img.chat-empty-avatar {
  display: block;
  margin-left: auto;
  margin-right: auto;
}


/* ── Voksen sidebar polish ── */

/* Hide message preview on Sofia card in voksen mode — only 1 conversation, preview adds noise */
.v-voksen .chat-contact .chat-contact-preview,
.v-voksen .chat-contact .chat-contact-time {
  display: none;
}

/* Compact Sofia card without preview */
.v-voksen .chat-contact {
  padding: 10px var(--space-3);
}

/* "+ Opret ny skabelon" — full width already set via flex in main rule */

/* Horizontal rule inside AI chat bubbles */
.chat-bubble hr.chat-hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 12px 0;
  opacity: 0.5;
}


/* ── Template edit/delete actions ── */
.chat-sidebar-tpl-actions {
  display: none;
  margin-left: auto;
  gap: 4px;
  flex-shrink: 0;
  pointer-events: none;
}

.chat-sidebar-tpl-btn:hover .chat-sidebar-tpl-actions {
  display: flex;
  pointer-events: auto;
}

.chat-sidebar-tpl-edit,
.chat-sidebar-tpl-del {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-sidebar-tpl-edit:hover {
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--color-primary);
}

.chat-sidebar-tpl-del:hover {
  background: rgba(255, 62, 29, 0.1);
  color: #ff3e1d;
}

/* Restore defaults link */
.chat-sidebar-tpl-restore:hover {
  color: var(--color-primary) !important;
  text-decoration: underline;
}

/* ── Conversation history list (Voksen multi-conversation) ── */
.chat-conv-history {
  padding: 0 12px 12px;
  margin-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-1);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.chat-conv-history::-webkit-scrollbar {
  width: 4px;
}

.chat-conv-history::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.chat-conv-history::-webkit-scrollbar-track {
  background: transparent;
}

/* Show more button */
.chat-conv-show-more {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  text-align: center;
  border-radius: 8px;
  transition: background 0.15s;
  margin-top: 4px;
}

.chat-conv-show-more:hover {
  background: rgba(var(--color-primary-rgb), 0.08);
}

.chat-conv-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  padding: 12px 0 8px;
}

.chat-conv-label .menu-header-line {
  width: 16px;
  height: 1px;
  background: var(--color-text-secondary);
  opacity: 0.4;
  flex-shrink: 0;
}

.chat-conv-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 8px 0 4px;
  opacity: 0.7;
}

.chat-conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--color-text);
  transition: background 0.15s;
  text-align: left;
  margin-bottom: 2px;
}

.chat-conv-item:hover {
  background: var(--color-hover, rgba(0,0,0,0.04));
}

.chat-conv-item.active {
  background: rgba(var(--color-primary-rgb), 0.1);
}

.chat-conv-item-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.chat-conv-item-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.chat-conv-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-conv-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-conv-item-time {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.chat-conv-item-del {
  display: none;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}

.chat-conv-item:hover .chat-conv-item-del {
  display: block;
}

.chat-conv-item-del:hover {
  color: var(--color-danger, #e24668);
  background: rgba(226, 70, 104, 0.1);
}

.chat-conv-empty {
  font-size: 13px;
  color: var(--color-text-secondary);
  padding: 8px 0;
  font-style: italic;
}



/* Voksen: hide greeting header — Sofia's card is the greeting */
.v-voksen .chat-sidebar-header {
  display: none;
}

/* Hide redundant "Din assistent" label */
.chat-contacts-label.v-voksen-only {
  display: none !important;
}

/* New conversation button next to SAMTALER header */
.chat-conv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
}

.chat-conv-new-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.chat-conv-new-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.06);
}

/* ── Feature toggle chips (voksen direct input) ── */
.chat-feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 0 8px;
  justify-content: center;
}

.chat-feature-chip {
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-family: 'Nunito Sans', sans-serif;
  color: #a8abbe;
  cursor: default;
  line-height: 1;
  white-space: nowrap;
  transition: color 0.15s;
}

.chat-chip-toggle {
  position: relative;
  width: 28px;
  height: 16px;
  background: #d5d7e2;
  border-radius: 999px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.chat-chip-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: left 0.15s;
}

/* ON state */
.chat-feature-chip.on {
  color: var(--color-text-primary, #2b333b);
}
.chat-feature-chip.on .chat-chip-toggle {
  background: var(--color-primary, #696cff);
}
.chat-feature-chip.on .chat-chip-knob {
  left: 14px;
}

/* Hover */
.chat-feature-chip:hover {
  color: var(--color-text-primary, #2b333b);
}
.chat-feature-chip:not(.on):hover .chat-chip-toggle {
  background: #c5c8d6;
}
.chat-feature-chip.on:hover .chat-chip-toggle {
  filter: brightness(0.9);
}

/* ── Direct input mic button ── */
.chat-direct-mic-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #697a8d);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.chat-direct-mic-btn:hover {
  background: rgba(var(--color-primary-rgb), 0.10);
  color: var(--color-primary);
}
.chat-direct-mic-btn:active {
  background: rgba(var(--color-primary-rgb), 0.12);
  color: var(--color-primary);
}
.chat-direct-mic-btn svg {
  width: 20px;
  height: 20px;
}
.chat-direct-mic-btn.connecting {
  opacity: 0.5;
  pointer-events: none;
}
.chat-direct-mic-btn.recording {
  color: var(--color-danger, #ea5455);
  animation: chat-mic-pulse 1.2s ease infinite;
}

@keyframes chat-mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Dark mode for chips ── */
[data-theme="dark"] .chat-feature-chip {
  pointer-events: none;
  color: #8b8fa3;
}
[data-theme="dark"] .chat-feature-chip.on {
  color: var(--color-text-primary);
}
[data-theme="dark"] .chat-chip-toggle {
  background: #4a4b5e;
}
[data-theme="dark"] .chat-feature-chip.on .chat-chip-toggle {
  background: var(--color-primary, #696cff);
}
[data-theme="dark"] .chat-chip-knob {
  background: #9b9eb0;
}
[data-theme="dark"] .chat-feature-chip.on .chat-chip-knob {
  background: #fff;
}

/* ── Dark mode for direct input ── */
[data-theme="dark"] .chat-direct-input-wrap {
  background: var(--color-card, #2b2c40);
  border-color: var(--color-border, #434968);
}
[data-theme="dark"] .chat-direct-upload-btn:hover,
[data-theme="dark"] .chat-direct-mic-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .chat-feature-chips {
    gap: 10px;
    padding: 0 0 6px;
  }
  .chat-feature-chip {
    pointer-events: none;
    font-size: 12px;
  }
  .chat-direct-input {
    margin-top: var(--space-6);
    padding: 0 var(--space-3);
  }
}
