/* Praktiko additions: Bewerbungschat */

.chat-body {
  overflow: hidden;
}

.chat-body .page-wrapper {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-body main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-page {
  background: var(--color-bg);
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
  overflow: hidden;
  position: relative;
}

.chat-shell {
  --chat-sidebar-width: clamp(340px, 200px + 15vw, 440px);
  --chat-context-width: clamp(340px, 24vw, 420px);
  display: grid;
  grid-template-columns: var(--chat-sidebar-width) minmax(0, 1fr);
  grid-template-rows: 1fr;
  flex: 1;
  height: 100%;
  min-height: 0;
  width: 100%;
  border-radius: 0;
  border: none;
  background: var(--color-bg);
  box-shadow: none;
  overflow: hidden;
}

.chat-list-panel {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  box-shadow: none;
}

/* Sidebar Header */
.chat-sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.chat-sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-sidebar-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-sidebar-title {
  font-family: var(--font-display, inherit);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-ink);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.chat-header-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary-border);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.16s ease;
}

.chat-header-link-btn:hover {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.chat-stats-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 5px 8px;
}

.chat-stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--color-muted);
  padding: 2px 4px;
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-dot.total {
  background: var(--color-muted);
}

.stat-dot.open {
  background: var(--color-primary);
}

.stat-dot.hired {
  background: var(--color-success);
}

.stat-dot.rejected {
  background: var(--color-danger);
}

.stat-label {
  font-size: 11px;
  color: var(--color-muted);
}

.stat-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-ink);
}

/* Sidebar Toolbar (Search & Filters) */
.chat-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.chat-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  color: var(--color-muted);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chat-search:focus-within {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 13px;
}

.chat-select {
  min-height: 38px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  padding: 0 var(--space-3);
  font-weight: var(--weight-semi);
  font-size: 12px;
  color: var(--color-ink);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: border-color 0.15s ease;
  cursor: pointer;
}

.chat-select:focus {
  border-color: var(--color-primary);
  outline: none;
}

.chat-select.compact {
  width: auto;
  min-width: 120px;
}

.chat-sort-select {
  width: auto;
  min-width: 100px;
  height: 38px;
}

.chat-job-filters {
  display: flex;
  flex-shrink: 0;
  min-height: fit-content;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  scrollbar-width: thin;
}

.chat-job-filters::-webkit-scrollbar {
  height: 6px;
}

.chat-job-filters::-webkit-scrollbar-track {
  background: transparent;
}

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

.chat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink-2);
  border-radius: 999px;
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  cursor: pointer;
  line-height: 1;
  box-sizing: border-box;
}

.chat-chip.active {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
}

.chat-list {
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.chat-thread-wrap {
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.chat-thread-wrap:hover,
.chat-thread-wrap.active {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.chat-thread-wrap.active {
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.chat-thread-wrap.has-unread {
  background: linear-gradient(90deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.82));
  border-color: var(--color-primary-border);
}

.chat-thread-wrap.is-hired {
  border-color: var(--color-success-border);
}

.chat-thread-wrap.is-inactive {
  opacity: 0.55;
  pointer-events: none;
}

.chat-thread-wrap.is-inactive .chat-thread {
  cursor: default;
}

.chat-thread-wrap.is-deleted {
  opacity: 0.55;
  position: relative;
}

.chat-thread-wrap.is-deleted::after {
  content: 'Stelle entfernt';
  position: absolute;
  top: var(--space-2);
  right: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-muted);
  background: var(--color-surface-3);
  padding: 1px 8px;
  border-radius: var(--radius-full);
}

.chat-thread {
  display: flex;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
  border: none;
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-thread-avatar,
.chat-person-avatar,
.chat-message-avatar {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  font-weight: var(--weight-black);
}

.chat-thread-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xl);
}

.chat-thread-avatar img,
.chat-person-avatar img,
.chat-message-avatar img,
.chat-thread-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-thread-logo {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 21px;
  height: 21px;
  border: 2px solid white;
  border-radius: 999px;
  background: white;
  overflow: hidden;
}

.chat-thread-body {
  flex: 1;
  min-width: 0;
}

.chat-thread-head,
.chat-thread-meta,
.chat-message-meta,
.chat-detail-header,
.chat-person,
.chat-detail-actions {
  display: flex;
  align-items: center;
}

.chat-thread-head {
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 2px;
}

.chat-thread-head strong,
.chat-thread-job,
.chat-thread-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-thread-head strong {
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: var(--weight-xbold);
}

.chat-thread-head strong a {
  color: inherit;
  text-decoration: none;
}

.chat-thread-head strong a:hover {
  text-decoration: underline;
}

.chat-profile-link {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  color: var(--color-muted);
  text-decoration: none;
  flex-shrink: 0;
}

.chat-profile-link:hover {
  color: var(--color-primary);
}

.chat-thread-head time,
.chat-thread-preview,
.chat-thread-job {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.chat-thread-job {
  display: block;
  color: var(--color-ink-2);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-1);
}

.chat-thread-preview {
  display: block;
}

.chat-thread-meta {
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chat-unread-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 var(--space-2);
  border-radius: 999px;
  background: var(--color-primary);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.application-status.delivered,
.application-status.open {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
}

.application-status.hired {
  background: var(--color-success-bg);
  color: var(--color-success-dark);
}

.application-status.rejected {
  background: var(--color-danger-bg);
  color: var(--color-danger-dark);
}

.application-status.withdrawn {
  background: var(--color-surface-3);
  color: var(--color-muted);
}

.chat-detail-panel {
  display: flex;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg);
  position: relative;
}

.chat-detail-empty,
.chat-empty-state,
.chat-filter-empty,
.chat-no-messages {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-muted);
  text-align: center;
  padding: var(--space-8);
}

.chat-detail-empty {
  flex: 1;
}

.chat-detail-empty[hidden],
.chat-detail[hidden],
.chat-filter-empty[hidden],
.chat-doc-menu[hidden],
.chat-thread-wrap[hidden],
.chat-file-preview[hidden],
.chat-composer[hidden],
.chat-composer-blocked[hidden] {
  display: none !important;
}

/* Three-dot menu on chat threads */
.chat-thread-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.chat-thread-wrap .chat-thread {
  flex: 1;
  min-width: 0;
}

.chat-thread-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  opacity: 1;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
  align-self: center;
  margin-left: -8px;
  position: relative;
  z-index: 2;
}

.chat-thread-menu-btn:hover {
  background: #f1f5f9;
  color: #334155;
}

/* Context dropdown menu */
.chat-thread-dropdown {
  position: fixed;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  padding: var(--space-1) 0;
  z-index: 99999;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transition: opacity 0.12s ease, transform 0.12s ease;
  overflow: visible;
}

.chat-thread-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.chat-thread-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: none;
  color: var(--color-ink);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: background 0.1s ease;
  border-radius: 0;
}

.chat-thread-dropdown-item:hover {
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.chat-thread-dropdown-item.danger {
  color: var(--color-danger);
}

.chat-thread-dropdown-item.danger:hover {
  background: var(--color-danger-bg, #fef2f2);
  border-radius: var(--radius-md);
}

.chat-thread-dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-1) 0;
}

/* Report modal textarea */
.chat-report-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 160px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  resize: vertical;
  outline: none;
}

.chat-report-textarea:focus {
  border-color: var(--color-primary);
}

.chat-detail {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.chat-detail-header {
  height: 60px;
  min-height: 60px;
  max-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: none;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
}

.chat-back-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-ink);
  cursor: pointer;
  padding: 0;
  margin-right: 2px;
  transition: all 0.15s ease;
}

.chat-back-button:hover {
  background: var(--color-surface-3, #e2e8f0);
}

.chat-person {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.chat-person-avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 700;
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.chat-person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-person-meta,
.chat-person>div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-person h2 {
  margin: 0;
  color: var(--color-ink);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chat-person p {
  margin: 0;
  color: var(--color-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chat-person .chat-profile-link {
  color: var(--color-muted);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease;
}

.chat-person .chat-profile-link:hover {
  color: var(--color-primary);
}

.chat-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-detail-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink-2);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.chat-detail-menu-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
}

.chat-info-strip-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-ink-2);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.chat-info-strip-toggle-btn:hover,
.chat-info-strip-toggle-btn.active {
  background: var(--color-primary-bg);
  border-color: var(--color-primary-border);
  color: var(--color-primary-dark);
}

.chat-context-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chat-context-toggle-btn:hover,
.chat-context-toggle-btn.active {
  background: var(--color-primary-bg);
  border-color: var(--color-primary-border);
  color: var(--color-primary-dark);
}

/* Info Bar / Chips Collapsible Container */
.chat-info-bar-wrap {
  display: flex;
  align-items: center;
  position: relative;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  max-height: 80px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease, border-color 0.28s ease;
}

.chat-info-bar-wrap::before,
.chat-info-bar-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 2;
}

.chat-info-bar-wrap::before {
  left: 0;
  background: linear-gradient(to right, var(--color-surface), transparent);
}

.chat-info-bar-wrap::after {
  right: 40px;
  background: linear-gradient(to left, var(--color-surface), transparent);
}

.chat-info-bar-wrap.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  border-bottom-color: transparent !important;
  pointer-events: none !important;
}

.chat-info-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 20px;
  background: transparent;
  border-bottom: none;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
}

.chat-info-grid::-webkit-scrollbar {
  height: 4px;
}

.chat-info-grid::-webkit-scrollbar-track {
  background: transparent;
}

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

.chat-info-bar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  transition: all 0.18s ease;
}

.chat-info-bar-toggle:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  color: var(--color-ink);
}

.chat-info-bar-toggle .chevron-icon {
  transition: transform 0.25s ease;
}

.chat-info-bar-wrap.collapsed .chat-info-bar-toggle .chevron-icon {
  transform: rotate(180deg);
}

.chat-info-grid>div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--color-muted);
  white-space: nowrap;
  box-shadow: none;
  min-width: max-content;
  flex-shrink: 0;
}

.chat-info-icon {
  color: var(--color-primary);
  opacity: 0.85;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.chat-info-grid span {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}

.chat-info-grid strong {
  color: var(--color-ink);
  font-size: 12px;
  font-weight: 700;
}

.chat-info-grid strong.placeholder-text {
  color: var(--color-muted) !important;
  font-weight: var(--weight-normal) !important;
  font-style: italic !important;
  opacity: 0.75 !important;
}

.chat-info-grid span {
  display: block;
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.chat-info-grid>div>div {
  overflow: hidden;
  min-width: 0;
}

.chat-info-grid strong {
  display: block;
  white-space: nowrap;
  color: var(--color-ink);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-message-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-6);
  background:
    linear-gradient(rgba(248, 250, 252, 0.94), rgba(248, 250, 252, 0.94)),
    radial-gradient(circle at center, rgba(37, 99, 235, 0.08), transparent 30rem);
}

.chat-message {
  display: flex;
  gap: var(--space-3);
  max-width: 76%;
  margin-bottom: var(--space-4);
}

.chat-message.mine {
  flex-direction: row-reverse;
  margin-left: auto;
}

.chat-message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
}

.chat-message-avatar.placeholder::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
}

.chat-message-content {
  min-width: 0;
}

.chat-message-author {
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  margin: 0 0 var(--space-1) var(--space-1);
}

.chat-message.mine .chat-message-author,
.chat-message.mine .chat-message-meta {
  text-align: right;
  justify-content: flex-end;
}

.chat-message-bubble {
  border: 1px solid var(--color-border);
  border-radius: 20px 20px 20px 6px;
  background: white;
  color: var(--color-ink);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.chat-message.mine .chat-message-bubble {
  border-color: transparent;
  border-radius: 20px 20px 6px 20px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
}

.chat-message.deleted .chat-message-bubble {
  background: var(--color-surface-3);
  color: var(--color-muted);
  box-shadow: none;
}

.chat-message-text {
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.chat-message-meta {
  gap: var(--space-2);
  color: var(--color-muted);
  font-size: var(--text-xs);
  margin-top: var(--space-1);
  /* Meta (Uhrzeit + Status) darf die Nachrichtenbreite nie aufblaehen:
     Breite = 100% der Bubble, Ueberstand laeuft weich ins Freie.
     So springt kurze Nachrichten beim Senden->Zugestellt-Wechsel nicht. */
  width: 0;
  min-width: 100%;
  white-space: nowrap;
}

.chat-read-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--color-subtle);
}

.chat-read-icon.read {
  color: var(--color-accent);
}

/* ── Message Sending & Loading Animations ────────────── */
@keyframes chatMsgEnter {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }

  65% {
    opacity: 1;
    transform: translateY(-2px) scale(1.008);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes chatSentSettle {
  0% {
    transform: scale(0.996);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes chatSpin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes chatCheckmarkPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  65% {
    transform: scale(1.25);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.chat-message.is-sending,
.chat-message.is-incoming {
  animation: chatMsgEnter 0.36s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-message.is-sending .chat-message-bubble {
  opacity: 0.94;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
  transition: opacity 0.45s ease, box-shadow 0.45s ease;
}

.chat-message.is-sent .chat-message-bubble {
  animation: chatSentSettle 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 1;
  transition: opacity 0.45s ease, box-shadow 0.45s ease;
}

.chat-sending-badge,
.chat-sent-status {
  transition: opacity 0.16s ease, transform 0.22s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.chat-message-meta time {
  flex-shrink: 0;
}

.chat-message-meta.is-swapping .chat-sending-badge,
.chat-message-meta.is-swapping .chat-sent-status {
  opacity: 0;
  transform: translateY(3px);
}

.chat-sent-status .chat-read-icon {
  animation: chatCheckmarkPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {

  .chat-message.is-sending,
  .chat-message.is-incoming,
  .chat-message.is-sent .chat-message-bubble {
    animation: none;
  }
}

.chat-sending-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--color-subtle);
  transition: all 0.3s ease;
}

.chat-message.mine .chat-sending-badge {
  color: rgba(255, 255, 255, 0.85);
}

.chat-sending-spinner {
  animation: chatSpin 0.75s linear infinite;
  flex-shrink: 0;
}

.chat-sent-status {
  display: inline-flex;
  align-items: center;
}

.chat-sent-status .chat-read-icon {
  animation: chatCheckmarkPop 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-message.is-send-error .chat-message-bubble {
  opacity: 0.95;
  border: 1px solid var(--color-danger, #ef4444) !important;
  background: #fef2f2 !important;
  color: #991b1b !important;
}

.chat-send-error-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--color-danger, #ef4444);
  font-weight: 600;
  font-size: var(--text-xs);
}

.chat-send-button.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

.chat-send-button.is-loading .chat-send-spinner {
  animation: chatSpin 0.75s linear infinite;
}

.chat-file-card.is-pending {
  opacity: 0.85;
}

.chat-thread-preview .chat-read-icon {
  flex-shrink: 0;
  margin-right: 3px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.chat-delete-message {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 999px;
  color: var(--color-muted);
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.chat-delete-message:hover,
.chat-delete-message:focus,
.chat-delete-message:focus-visible,
.chat-delete-message:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.chat-delete-message:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

.chat-delete-message svg {
  display: block;
}

.chat-file-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}

.chat-file-card:hover {
  background: var(--color-surface);
  border-color: var(--color-primary-border);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.10);
  transform: translateY(-1px);
}

.chat-file-card svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

.chat-file-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
}

.chat-file-card small {
  opacity: 0.72;
  font-size: var(--text-xs);
  white-space: nowrap;
}

.chat-message.mine .chat-file-card {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}

.chat-message.mine .chat-file-card:hover {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.chat-message.mine .chat-file-card svg {
  color: white;
}

.chat-message.mine .chat-file-card small {
  opacity: 0.85;
}

.chat-deleted-text {
  font-style: italic;
}

.chat-file-preview {
  flex: 0 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-lg);
}

.chat-file-preview-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-ink-2);
  max-width: 200px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-file-preview-item:hover {
  background: var(--color-surface-2);
  border-color: var(--color-primary-border);
}

.chat-file-preview-item>svg {
  flex-shrink: 0;
  color: var(--color-primary);
}

.chat-file-preview-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-semi);
}

.chat-file-preview-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 999px;
  background: var(--color-danger-bg-light);
  color: var(--color-danger);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
}

.chat-file-preview-remove:hover,
.chat-file-preview-remove:focus,
.chat-file-preview-remove:focus-visible,
.chat-file-preview-remove:active {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.chat-file-preview-remove:hover {
  background: var(--color-danger);
  color: white;
}

.chat-composer {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  border-width: 1px 0 0;
  box-shadow: none;
  padding: var(--space-3) var(--space-6) var(--space-4);
  background: white;
}

/* Toolbar als erste Zeile im Composer (full-width) */
.chat-composer .chat-format-toolbar {
  order: -1;
  width: 100%;
  margin-left: calc(-1 * var(--space-6));
  margin-right: calc(-1 * var(--space-6));
  width: calc(100% + 2 * var(--space-6));
  margin-bottom: var(--space-2);
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding: 5px var(--space-6) 4px;
}

.chat-composer textarea {
  flex: 1;
  min-height: 46px;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: 18px;
  background: var(--color-surface-2);
  padding: var(--space-3) var(--space-4);
  line-height: 1.45;
  min-width: 0;
}

.chat-composer textarea:focus {
  border-color: var(--color-primary-border);
  background: white;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.chat-composer-rich-input {
  flex: 1;
  min-height: 46px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 18px;
  background: var(--color-surface-2);
  padding: var(--space-3) var(--space-4);
  line-height: 1.45;
  min-width: 0;
  outline: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--color-ink);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-composer-rich-input:focus {
  border-color: var(--color-primary-border);
  background: white;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.chat-composer-rich-input:empty::before {
  content: attr(data-placeholder);
  color: var(--color-muted);
  font-style: normal;
  pointer-events: none;
}

.chat-composer-rich-input ul {
  list-style-type: disc !important;
  margin-left: 20px !important;
  padding-left: 10px !important;
  display: block !important;
}

.chat-composer-rich-input ol {
  list-style-type: decimal !important;
  margin-left: 20px !important;
  padding-left: 10px !important;
  display: block !important;
}

.chat-composer-rich-input li {
  display: list-item !important;
  margin: 4px 0 !important;
}



.chat-icon-button,
.chat-send-button {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  line-height: 0;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none;
  appearance: none;
}

.chat-icon-button svg,
.chat-send-button svg,
.chat-file-preview-remove svg {
  display: block;
}

.chat-icon-button {
  border: 1px solid var(--color-border) !important;
  color: var(--color-primary);
  background: var(--color-primary-bg);
}

.chat-send-button {
  color: white;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: none;
  overflow: hidden;
  position: relative;
}

/* Layered soft morph icons */
.chat-send-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.78) translateY(10px);
  pointer-events: none;
  transition: opacity 0.38s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-send-icon.is-active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.chat-send-icon--arrow.is-exiting {
  transform: translateY(-44px) scale(0.72);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.32s ease;
}

.chat-send-icon--arrow.is-entering {
  animation: arrowEnterWings 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes arrowEnterWings {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.55);
  }

  38% {
    opacity: 1;
    transform: translateY(-5px) scale(1.08);
  }

  62% {
    transform: translateY(2px) scale(0.96);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-send-icon--arrow.is-entering polyline {
  transform-origin: 12px 5px;
  animation: wingsOpen 0.62s cubic-bezier(0.34, 1.56, 0.64, 1) 0.18s both;
}

@keyframes wingsOpen {
  0% {
    transform: scaleX(0.45);
    opacity: 0.7;
  }

  52% {
    transform: scaleX(1.32);
    opacity: 1;
  }

  78% {
    transform: scaleX(0.92);
  }

  100% {
    transform: scaleX(1);
    opacity: 1;
  }
}

.chat-send-icon--spinner.is-active .chat-send-spinner {
  animation: chatSpin 0.75s linear infinite;
}

.chat-send-icon--spinner {
  transition: opacity 0.32s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-send-icon--success.is-active {
  animation: chatSendSuccess 0.62s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes chatSendSuccess {
  0% {
    transform: scale(0) rotate(-10deg);
    opacity: 0;
  }

  45% {
    transform: scale(1.18) rotate(2deg);
    opacity: 1;
  }

  70% {
    transform: scale(0.94) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.chat-send-icon--success.is-exiting {
  transform: scale(0.7) translateY(-10px);
  opacity: 0;
  transition: transform 0.32s ease, opacity 0.28s ease;
}

.chat-send-button::before,
.chat-send-button::after,
.chat-icon-button::before,
.chat-icon-button::after,
.chat-file-preview-remove::before,
.chat-file-preview-remove::after {
  display: none !important;
  content: none !important;
}

.chat-file-preview-remove {
  line-height: 0;
  padding: 0;
}

.chat-file-input {
  display: none !important;
}

.chat-doc-menu {
  position: absolute;
  left: var(--space-6);
  bottom: calc(100% - var(--space-2));
  z-index: 10;
  width: min(340px, calc(100vw - 2rem));
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background: white;
  box-shadow: var(--shadow-xl);
  padding: var(--space-2);
}

.chat-doc-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-ink);
  padding: var(--space-3);
  cursor: pointer;
  text-align: left;
}

.chat-doc-option:hover {
  background: var(--color-surface-2);
}

.chat-doc-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-bold);
}

.chat-doc-option small {
  color: var(--color-muted);
}



.chat-composer-blocked {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-top: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-6);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
}

.chat-composer-blocked svg {
  color: var(--color-subtle);
  flex-shrink: 0;
}

.chat-composer-actions-wrap {
  position: relative;
  margin-left: var(--space-3);
}

.chat-composer-actions-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-composer-actions-btn:hover {
  background: var(--color-primary);
  color: white;
}

.chat-composer-actions-btn svg {
  transition: transform 0.15s ease;
}

.chat-composer-actions-wrap.open .chat-composer-actions-btn svg {
  transform: rotate(180deg);
}

.chat-composer-actions-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  padding: var(--space-1) 0;
  z-index: 99999;
  opacity: 0;
  transform: translateY(6px) scale(0.97);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.chat-composer-actions-wrap.open .chat-composer-actions-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Toast z-index fix — Chat-Seite hat backdrop-filter, Toast muss darüber liegen */
.chat-body .toast-container {
  z-index: 99999;
}

/* ===== Image Grid ===== */
.chat-image-grid {
  display: grid;
  gap: 4px;
  margin: calc(var(--space-2) * -1) calc(var(--space-3) * -1);
  padding: var(--space-2) var(--space-3);
}

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

.chat-image-grid.count-2 {
  grid-template-columns: 1fr 1fr;
}

.chat-image-grid.count-3,
.chat-image-grid.count-4,
.chat-image-grid.count-5 {
  grid-template-columns: 1fr 1fr;
}

.chat-image-link {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-md);
  position: relative;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  background: var(--color-surface-2);
}

.chat-image-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.35) 50%, transparent 100%);
  animation: chat-image-shimmer 1.5s ease-in-out infinite;
  z-index: 1;
  pointer-events: none;
}

.chat-image-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease, opacity 0.35s ease;
  position: relative;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
}

.chat-image-link img.loaded {
  opacity: 1;
  visibility: visible;
}

@keyframes chat-image-shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.chat-image-link:hover img {
  transform: scale(1.03);
}

.chat-image-grid.count-1 .chat-image-link {
  aspect-ratio: 16 / 9;
  max-height: 360px;
}

.chat-image-grid.count-1 .chat-image-link img {
  object-fit: contain;
}

.chat-image-overflow {
  position: relative;
}

.chat-image-overflow::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.chat-image-overflow:hover::after {
  background: rgba(0, 0, 0, 0.6);
}

.chat-image-overflow-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.6rem;
  font-weight: var(--weight-bold);
  z-index: 1;
  pointer-events: none;
}

.chat-image-hidden {
  display: none !important;
}

/* ===== Document Stack ===== */
.chat-doc-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chat-doc-stack .chat-file-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  min-width: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}

.chat-doc-stack .chat-file-card:hover {
  background: var(--color-surface);
  border-color: var(--color-primary-border);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.10);
  transform: translateY(-1px);
}

.chat-doc-stack .chat-file-card svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

.chat-doc-stack .chat-file-card .chat-file-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  flex: 1;
}

.badge-doc-type {
  display: inline-flex;
  align-items: center;
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  font-size: 11px;
  font-weight: var(--weight-bold);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-primary-border);
  flex-shrink: 0;
  white-space: nowrap;
}

.chat-message.mine .badge-doc-type {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.chat-doc-stack .chat-file-card .chat-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  min-width: 0;
  flex: 1;
}

.chat-doc-stack .chat-file-card small {
  opacity: 0.72;
  font-size: var(--text-xs);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-message.mine .chat-doc-stack .chat-file-card {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}

.chat-message.mine .chat-doc-stack .chat-file-card:hover {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.chat-message.mine .chat-doc-stack .chat-file-card svg {
  color: white;
}

.chat-message.mine .chat-doc-stack .chat-file-card small {
  opacity: 0.85;
}

@media (max-width: 600px) {

  .chat-doc-stack .chat-file-card,
  .chat-file-card {
    grid-template-columns: auto minmax(0, 1fr) auto auto !important;
    gap: 6px !important;
    padding: 8px 10px !important;
    border-radius: var(--radius-md) !important;
  }

  .badge-doc-type {
    font-size: 10px !important;
    padding: 1px 5px !important;
    flex-shrink: 0 !important;
  }

  .chat-doc-stack .chat-file-card .chat-file-name {
    font-size: 12px !important;
  }

  .chat-doc-stack .chat-file-card small {
    font-size: 10px !important;
    opacity: 0.8 !important;
  }

  .chat-file-download {
    padding: 4px !important;
  }
}

.chat-file-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.chat-file-download:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.08);
}

.chat-message.mine .chat-file-download {
  color: white;
  background: rgba(255, 255, 255, 0.22);
}

.chat-message.mine .chat-file-download:hover {
  background: rgba(255, 255, 255, 0.38);
}

/* ===== Lightbox ===== */
.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.chat-lightbox[hidden] {
  display: none;
}

.chat-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}

.chat-lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 2;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 999px;
  color: white;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chat-lightbox-prev,
.chat-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 999px;
  color: white;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-lightbox-prev {
  left: var(--space-4);
}

.chat-lightbox-next {
  right: var(--space-4);
}

.chat-lightbox-prev:hover,
.chat-lightbox-next:hover {
  background: rgba(255, 255, 255, 0.25);
}

.chat-lightbox-image-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 80vh;
}

.chat-lightbox-image-wrap.skeleton {
  min-width: 320px;
  min-height: 240px;
  border-radius: var(--radius-lg);
}

.chat-lightbox-image {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  user-select: none;
  -webkit-user-drag: none;
}

.chat-lightbox-toolbar {
  position: absolute;
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: var(--space-2) var(--space-4);
}

.chat-lightbox-counter {
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  white-space: nowrap;
}

.chat-lightbox-download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: white;
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.15s ease;
  white-space: nowrap;
}

.chat-lightbox-download:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== Lightbox Mobile ===== */
@media (max-width: 640px) {

  .chat-lightbox-prev,
  .chat-lightbox-next {
    width: 40px;
    height: 40px;
  }

  .chat-lightbox-prev {
    left: var(--space-2);
  }

  .chat-lightbox-next {
    right: var(--space-2);
  }

  .chat-lightbox-close {
    top: var(--space-2);
    right: var(--space-2);
    width: 38px;
    height: 38px;
  }

  .chat-lightbox-toolbar {
    bottom: var(--space-2);
    padding: var(--space-1) var(--space-3);
    gap: var(--space-3);
  }

  .chat-lightbox-download span {
    display: none;
  }

  .chat-image-grid {
    gap: 3px;
  }

  .chat-image-link img {
    max-height: 180px;
  }

  .chat-image-grid.count-1 .chat-image-link img {
    max-height: 280px;
  }
}

/* ===== Responsive Layout: Tablet & Mobile Adaptations ===== */
@media (max-width: 1024px) {

  body.chat-body,
  .chat-body .page-wrapper {
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .chat-body .site-footer {
    display: none !important;
  }

  .chat-body main.chat-page {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    height: calc(100vh - var(--header-height)) !important;
    height: calc(100dvh - var(--header-height)) !important;
    padding: 0 !important;
    background: var(--color-bg) !important;
  }

  .chat-shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
    min-height: 0 !important;
    flex: 1 !important;
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }

  /* List vs Detail View Toggling */
  .chat-shell:not(.show-detail) .chat-detail-panel {
    display: none !important;
  }

  .chat-shell:not(.show-detail) .chat-list-panel {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    border-right: none !important;
  }

  .chat-shell.show-detail .chat-list-panel {
    display: none !important;
  }

  .chat-shell.show-detail .chat-detail-panel {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
  }

  .chat-back-button {
    display: inline-flex !important;
  }

  /* Detail Header on Mobile */
  .chat-detail-header {
    height: 56px !important;
    min-height: 56px !important;
    max-height: 56px !important;
    padding: 0 12px !important;
    gap: 8px !important;
  }

  .chat-desktop-status-select {
    display: none !important;
  }

  .chat-mobile-menu-btn {
    display: inline-flex !important;
  }

  .chat-person {
    gap: 8px !important;
  }

  .chat-person-avatar {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    font-size: 12px !important;
  }

  .chat-person h2 {
    font-size: 14px !important;
  }

  .chat-person p {
    font-size: 11px !important;
  }

  .chat-context-toggle-label {
    display: none !important;
  }

  /* Context Panel: Slide-over Drawer (Overlays Header on Mobile) */
  .chat-context-panel {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 340px !important;
    max-width: 88vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 250 !important;
    background: var(--color-surface) !important;
    border-left: 1px solid var(--color-border) !important;
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.22) !important;
    transform: translateX(0) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow-y: auto !important;
  }

  .chat-body-workspace.context-collapsed .chat-context-panel {
    transform: translateX(100%) !important;
    pointer-events: none !important;
    margin-right: 0 !important;
    opacity: 1 !important;
  }

  /* Mobile Backdrop (Overlays Header on Mobile) */
  .chat-context-backdrop {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.5) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    z-index: 240 !important;
    transition: opacity 0.25s ease !important;
  }

  .chat-context-backdrop[hidden] {
    display: none !important;
  }

  /* Composer on Touch Screens */
  .chat-composer {
    padding: 8px 12px !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 8px !important;
  }

  .chat-composer textarea {
    font-size: 16px !important;
    min-height: 38px !important;
  }

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

  .chat-message-stage {
    padding: 12px 14px !important;
  }
}

@media (max-width: 640px) {
  .chat-sidebar-header {
    padding: 12px 14px 10px !important;
  }

  .chat-toolbar {
    padding: 10px 14px !important;
  }

  .chat-stats-strip {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .chat-stats-strip::-webkit-scrollbar {
    display: none;
  }

  .chat-info-grid {
    padding: 6px 12px !important;
    gap: 6px !important;
  }

  .chat-info-grid>div {
    padding: 3px 8px !important;
    font-size: 11px !important;
  }

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

/* ─── Chat Format Toolbar ──────────────────────────────────────────────────── */

.chat-format-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px var(--space-4) 2px;
  background: white;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  flex-wrap: wrap;
  min-height: 36px;
}

.chat-fmt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--color-ink-3);
  cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.chat-fmt-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-ink);
  border-color: var(--color-border);
}

.chat-fmt-btn:active,
.chat-fmt-btn.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-color: var(--color-primary-border);
}


.chat-fmt-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 4px;
  flex-shrink: 0;
}

.chat-fmt-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-muted);
  font-style: italic;
  white-space: nowrap;
  padding-right: 4px;
}

/* Dropdown Wrapper */
.chat-fmt-dropdown-wrap {
  position: relative;
}

.chat-fmt-dropdown-trigger {
  gap: 4px;
}

.chat-fmt-caret {
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.chat-fmt-dropdown-wrap.open .chat-fmt-caret {
  transform: rotate(180deg);
}

.chat-fmt-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  top: auto;
  left: 0;
  z-index: 100;
  min-width: 180px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12);
  padding: 4px;
  display: none;
  flex-direction: column;
}


.chat-fmt-dropdown-wrap.open .chat-fmt-dropdown {
  display: flex;
}

.chat-fmt-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-ink);
  text-align: left;
  transition: background 0.1s ease;
}

.chat-fmt-dropdown-item:hover {
  background: var(--color-surface-2);
}

/* ─── Markdown Rendering im Chat-Bubble ─────────────────────────────────────*/

.chat-message-text .chat-md-h1 {
  font-size: 1.15em;
  font-weight: 700;
  line-height: 1.3;
  margin: 4px 0 2px;
  color: inherit;
}

.chat-message-text .chat-md-h2 {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.3;
  margin: 3px 0 2px;
  color: inherit;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}

.chat-message-text .chat-md-small {
  font-size: 0.8em;
  opacity: 0.75;
}

/* EXPLIZITE LISTEN-STYLES HINZUGEFÜGT */
.chat-message-text .chat-md-ul {
  margin: 4px 0 4px 24px;
  padding: 0;
  list-style-type: disc;
}

.chat-message-text .chat-md-ol {
  margin: 4px 0 4px 24px;
  padding: 0;
  list-style-type: decimal;
}

.chat-message-text .chat-md-ul li,
.chat-message-text .chat-md-ol li {
  margin: 2px 0;
  line-height: 1.4;
  display: list-item;
}

/* ─── Drawer-spezifische Isolierung gegen Dashboard-Globalstyles ─── */

.drawer-chat-wrapper .chat-message-bubble {
  padding: var(--space-3) var(--space-4);
}

.drawer-chat-wrapper .chat-message-text .chat-md-h1 {
  font-size: 1.2em;
  font-weight: 700;
  line-height: 1.4;
  margin: 10px 0 4px 0;
  color: inherit;
}

.drawer-chat-wrapper .chat-message-text .chat-md-h2 {
  font-size: 1.05em;
  font-weight: 700;
  line-height: 1.4;
  margin: 10px 0 4px 0;
  color: inherit;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}

/* Kompakte, aber sichtbare Abstände für Listen im Drawer */
.drawer-chat-wrapper .chat-message-text .chat-md-ul,
.drawer-chat-wrapper .chat-message-text .chat-md-ol {
  margin: 6px 0 6px 22px !important;
  padding: 0 !important;
}

.drawer-chat-wrapper .chat-message-text .chat-md-ul {
  list-style-type: disc !important;
}

.drawer-chat-wrapper .chat-message-text .chat-md-ol {
  list-style-type: decimal !important;
}

.drawer-chat-wrapper .chat-message-text .chat-md-ul li,
.drawer-chat-wrapper .chat-message-text .chat-md-ol li {
  margin: 3px 0 !important;
  padding: 0 !important;
  line-height: 1.45 !important;
  display: list-item !important;
}

/* FIX: Schaltet die fehlerhafte Block-Sperre ab, damit echte Absätze normal umbrechen */
.drawer-chat-wrapper .chat-message-text br {
  display: inline !important;
  content: normal !important;
}

/* Archived section styling */
.chat-archived-section {
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}

.chat-archived-toggle {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 0;
  border-radius: var(--radius-lg);
  color: var(--color-ink-2);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.chat-archived-toggle:hover {
  background: var(--color-border);
  color: var(--color-ink);
}

.chat-archived-toggle svg.chevron-icon {
  margin-left: var(--space-2);
}

.chat-archived-toggle.open svg.chevron-icon {
  transform: rotate(180deg);
}

.chat-archived-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: var(--space-1);
}

/* ── 3-Column Workspace & Collapsible Application Context Panel ── */

/* Filter Pills */
.chat-filter-pills {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chat-filter-pills::-webkit-scrollbar {
  display: none;
}

.chat-filter-pill {
  padding: 6px 13px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-filter-pill:hover {
  background: var(--color-surface-2);
  border-color: #cbd5e1;
  color: var(--color-ink);
}

.chat-filter-pill.active {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

/* Body Workspace (Flex container for Conversation + Context Panel) */
.chat-body-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.chat-conversation-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* Context Toggle Button in Header */
.chat-context-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.chat-context-toggle-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-context-toggle-btn.active {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chat-context-toggle-btn svg {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

/* Collapsible Context Panel */
.chat-context-panel {
  width: var(--chat-context-width, 340px);
  min-width: var(--chat-context-width, 340px);
  max-width: var(--chat-context-width, 340px);
  border-left: 1px solid var(--color-border);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    min-width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    max-width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.22s ease,
    border-color 0.2s ease;
}

.chat-body-workspace.context-collapsed .chat-context-panel {
  width: 0;
  min-width: 0;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  border-left-color: transparent;
}

.chat-context-inner {
  width: var(--chat-context-width, 340px);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: #ffffff;
  flex-shrink: 0;
}

.chat-context-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-ink);
}

.chat-context-title-wrap svg {
  color: var(--color-primary);
  flex-shrink: 0;
}

.chat-context-title-wrap h3 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
}

.chat-context-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chat-context-close-btn:hover {
  background: var(--color-surface);
  color: var(--color-ink);
}

/* Context Body Scroll */
.chat-context-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  scrollbar-width: thin;
}

/* Bento Card Style */
.chat-context-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.chat-context-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.chat-context-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-muted);
  font-size: 11px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

.chat-context-card-head svg {
  color: var(--color-subtle);
  flex-shrink: 0;
  margin-right: 4px;
}

.chat-context-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--color-border);
  color: var(--color-ink-2);
  font-size: 10px;
  font-weight: var(--weight-bold);
}

/* Job & Company Card */
.chat-context-job-title {
  margin: 0 0 3px;
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
  line-height: 1.35;
}

.chat-context-company-name {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.chat-context-meta-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}

.chat-context-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--color-ink-2);
}

.chat-context-meta-item svg {
  color: var(--color-subtle);
  flex-shrink: 0;
}

.chat-context-view-job-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-border);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.chat-context-view-job-link:hover {
  text-decoration: underline;
  color: var(--color-primary-dark);
}

/* Status & Deadline Card */
.chat-context-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.chat-context-label {
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-weight: 500;
}

.chat-context-deadline-box {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}

.chat-context-deadline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-context-deadline-head strong {
  font-size: var(--text-xs);
  color: var(--color-ink);
}

.chat-context-deadline-countdown {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.chat-countdown-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.chat-context-applied-date {
  font-size: 11px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

/* Documents List in Context Panel */
.chat-context-docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-context-no-docs {
  font-size: var(--text-xs);
  color: var(--color-muted);
  padding: var(--space-2) 0;
  text-align: center;
  font-style: italic;
}

.chat-context-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all 0.15s ease;
  cursor: pointer;
}

.chat-context-doc-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  background: var(--color-surface-2);
}

.chat-context-doc-item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.chat-context-doc-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.chat-context-doc-icon {
  color: var(--color-primary);
  flex-shrink: 0;
}

.chat-context-doc-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-context-doc-name {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-context-doc-sub {
  font-size: 10px;
  color: var(--color-muted);
}

.chat-context-doc-dl {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chat-context-doc-dl:hover {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

/* ── Chat-Detail-Header: Status-Icon + Overflow-Menü (nur mobil) ── */
.chat-status-icon {
  display: none;
}

.chat-status-icon-only {
  display: none;
}

.chat-header-overflow-btn {
  display: none;
}

@media (max-width: 1024px) {
  .chat-detail-actions .chat-context-toggle-btn#exportChatPdfBtn,
  .chat-detail-actions .chat-context-toggle-btn#toggleContextBtn,
  .chat-detail-actions .chat-info-strip-toggle-btn#toggleInfoStripBtn {
    display: none !important;
  }

  .chat-header-overflow-btn {
    display: inline-flex !important;
  }

  .chat-detail-actions #detailStatus {
    min-width: 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .chat-detail-actions #detailStatus .chat-status-text {
    display: none !important;
  }

  .chat-detail-actions #detailStatus .chat-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
  }

  .chat-detail-actions #detailStatusCompanyIcon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    flex-shrink: 0;
    line-height: 0;
  }

  .chat-detail-actions {
    gap: 6px !important;
  }

  .chat-person {
    min-width: 0;
    flex: 1;
  }

  .chat-person h2,
  .chat-person p {
    max-width: 100%;
  }
}

@media (min-width: 1025px) {
  .chat-detail-actions #detailStatus .chat-status-icon {
    display: none !important;
  }

  .chat-detail-actions #detailStatus .chat-status-text {
    display: inline !important;
  }

  .chat-detail-actions #detailStatusCompanyIcon,
  .chat-detail-actions #chatHeaderOverflowBtn {
    display: none !important;
  }
}