/* Capynova Support – Posteingang. Ruhiges, Notion-ähnliches Erscheinungsbild wie das Capynova CRM. Keine externen Schriften. */

:root {
  --accent: #2383e2;
  --accent-hover: #0077d4;
  --accent-soft: rgba(35, 131, 226, 0.12);
  --focus-ring: rgba(35, 131, 226, 0.28);
  --text: #37352f;
  --text-2: rgba(55, 53, 47, 0.65);
  --text-3: rgba(55, 53, 47, 0.45);
  --border: #e9e9e7;
  --border-strong: #dfdfdd;
  --bg: #ffffff;
  --bg-soft: #fbfbfa;
  --bg-side: #f7f7f5;
  --hover: rgba(55, 53, 47, 0.06);
  --selected: rgba(55, 53, 47, 0.08);
  --note: #cb912f;
  --note-hover: #b07c22;
  --note-bg: #fbf3db;
  --note-border: #f0e0b0;
  --note-text: #5c4b1c;
  --green: #0f7b6c;
  --green-soft: rgb(219, 237, 219);
  --red: #e03e3e;
  --red-soft: rgba(224, 62, 62, 0.08);
  --orange: rgb(73, 41, 14);
  --orange-soft: rgb(251, 236, 221);
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.06);
  --shadow: rgba(15, 15, 15, 0.06) 0 0 0 1px, rgba(15, 15, 15, 0.06) 0 2px 4px;
  --shadow-lg: rgba(15, 15, 15, 0.05) 0 0 0 1px, rgba(15, 15, 15, 0.1) 0 3px 6px, rgba(15, 15, 15, 0.2) 0 9px 24px;
  --radius: 6px;
  --radius-sm: 6px;
  --side-w: 236px;
  --list-w: 320px;
  --ctx-w: 296px;

  --tag-gray-bg: rgb(227, 226, 224);
  --tag-gray-fg: rgb(50, 48, 44);
  --tag-yellow-bg: rgb(253, 236, 200);
  --tag-yellow-fg: rgb(64, 44, 27);
  --tag-green-bg: rgb(219, 237, 219);
  --tag-green-fg: rgb(28, 56, 41);
  --tag-blue-bg: rgb(211, 229, 239);
  --tag-blue-fg: rgb(24, 51, 71);
  --tag-brown-bg: rgb(238, 224, 218);
  --tag-brown-fg: rgb(68, 42, 30);
  --tag-orange-bg: rgb(250, 222, 201);
  --tag-orange-fg: rgb(73, 41, 14);
  --tag-purple-bg: rgb(232, 222, 238);
  --tag-purple-fg: rgb(65, 36, 84);
  --tag-pink-bg: rgb(245, 224, 233);
  --tag-pink-fg: rgb(76, 35, 55);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: rgba(255, 255, 255, 0.86);
    --text-2: rgba(255, 255, 255, 0.55);
    --text-3: rgba(255, 255, 255, 0.36);
    --border: #2f2f2f;
    --border-strong: #3a3a3a;
    --bg: #191919;
    --bg-soft: #1f1f1f;
    --bg-side: #202020;
    --hover: rgba(255, 255, 255, 0.055);
    --selected: rgba(255, 255, 255, 0.09);
    --accent-soft: rgba(35, 131, 226, 0.25);
    --note-bg: #3a3014;
    --note-border: #5c4b1c;
    --note-text: #f3d77d;
    --green: #4dab9a;
    --green-soft: rgb(36, 73, 61);
    --red: #ff7369;
    --red-soft: rgba(255, 115, 105, 0.12);
    --orange: rgba(255, 255, 255, 0.88);
    --orange-soft: rgb(56, 40, 30);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: rgba(255, 255, 255, 0.07) 0 0 0 1px, rgba(0, 0, 0, 0.25) 0 2px 4px;
    --shadow-lg: rgba(0, 0, 0, 0.3) 0 0 0 1px, rgba(0, 0, 0, 0.4) 0 3px 6px, rgba(0, 0, 0, 0.5) 0 9px 24px;
    --tag-gray-bg: rgb(71, 71, 71);
    --tag-gray-fg: rgba(255, 255, 255, 0.88);
    --tag-yellow-bg: rgb(146, 118, 63);
    --tag-yellow-fg: rgba(255, 255, 255, 0.88);
    --tag-green-bg: rgb(36, 73, 61);
    --tag-green-fg: rgba(255, 255, 255, 0.88);
    --tag-blue-bg: rgb(40, 69, 108);
    --tag-blue-fg: rgba(255, 255, 255, 0.88);
    --tag-brown-bg: rgb(92, 59, 35);
    --tag-brown-fg: rgba(255, 255, 255, 0.88);
    --tag-orange-bg: rgb(136, 72, 15);
    --tag-orange-fg: rgba(255, 255, 255, 0.88);
    --tag-purple-bg: rgb(73, 47, 100);
    --tag-purple-fg: rgba(255, 255, 255, 0.88);
    --tag-pink-bg: rgb(105, 49, 76);
    --tag-pink-fg: rgba(255, 255, 255, 0.88);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  color: var(--text-2);
  background: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

/* ------------------------------------------------------------------ Grundbausteine */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-small {
  height: 30px;
  padding: 0 11px;
  font-size: 13px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn-danger:hover {
  background: #a92a23;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

.btn-block {
  width: 100%;
  height: 40px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  flex: none;
}

.icon-btn:hover,
.icon-btn.active {
  background: var(--hover);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.link-btn.danger {
  color: var(--red);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  flex: none;
}

.tag-guest {
  background: var(--tag-yellow-bg);
  color: var(--tag-yellow-fg);
}

.tag-verified {
  background: var(--tag-green-bg);
  color: var(--tag-green-fg);
}

.tag-muted {
  background: var(--tag-gray-bg);
  color: var(--tag-gray-fg);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  flex: none;
}

.pill-open {
  background: var(--tag-blue-bg);
  color: var(--tag-blue-fg);
}

.pill-closed {
  background: var(--tag-green-bg);
  color: var(--tag-green-fg);
}

.pill-muted {
  background: var(--tag-gray-bg);
  color: var(--tag-gray-fg);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  flex: none;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: none;
  user-select: none;
}

.av-blue { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.av-green { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.av-orange { background: var(--tag-orange-bg); color: var(--tag-orange-fg); }
.av-purple { background: var(--tag-purple-bg); color: var(--tag-purple-fg); }
.av-pink { background: var(--tag-pink-bg); color: var(--tag-pink-fg); }
.av-yellow { background: var(--tag-yellow-bg); color: var(--tag-yellow-fg); }
.av-brown { background: var(--tag-brown-bg); color: var(--tag-brown-fg); }
.av-gray { background: var(--tag-gray-bg); color: var(--tag-gray-fg); }

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar-xs {
  width: 20px;
  height: 20px;
  font-size: 8.5px;
  letter-spacing: 0;
}

/* Profilbild über den Initialen: erst sichtbar, wenn es geladen ist. */
.avatar {
  position: relative;
  overflow: hidden;
}

/* Solange das Bild lädt, ist das <img> leer und die Initialen scheinen durch; aus dem Cache
   steht es sofort da. Erst nach dem Laden die Initialen ausblenden (wegen transparenter PNGs). */
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar.img-loaded {
  color: transparent !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

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

.boot {
  display: grid;
  place-items: center;
  height: 100dvh;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.empty-text {
  margin: 0;
  max-width: 300px;
}

.mobile-only {
  display: none;
}

/* ------------------------------------------------------------------ Anmeldung */

.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
  background: var(--bg-side);
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 26px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 24px;
  font-weight: 700;
}

.login-card h1 {
  margin: 4px 0 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.login-sub,
.login-note {
  margin: -8px 0 4px;
  color: var(--text-2);
}

.login-note {
  margin: 2px 0 0;
  font-size: 12px;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 500;
  font-size: 13px;
}

.field input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 400;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
}

/* ------------------------------------------------------------------ Grundlayout */

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

.nav-scrim,
.ctx-scrim {
  display: none;
}

/* ------------------------------------------------------------------ Seitenleiste */

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 8px 8px 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-side);
  overflow-y: auto;
}

.sb-head {
  padding: 4px 4px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.brand:hover {
  background: var(--hover);
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 700;
}

.sb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  margin: 0 0 6px;
  padding: 0 6px 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
}

.sb-search:hover {
  background: var(--hover);
}

.sb-search:focus-within,
.sb-search.active {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.sb-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
}

.sb-search input::-webkit-search-cancel-button {
  display: none;
}

.sb-search-clear {
  width: 22px;
  height: 22px;
}

.sb-nav,
.sb-bottom {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--selected);
  color: var(--text);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  justify-content: center;
  width: 20px;
  flex: none;
  color: var(--text-3);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  color: var(--text);
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}

.nav-count.strong {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-align: center;
}

.menu-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
}

.list-head .icon-btn {
  position: relative;
}

.nav-kbd {
  font-size: 10px;
}

.sb-spacer {
  flex: 1;
  min-height: 16px;
}

.sb-offline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 12px;
  font-weight: 500;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  padding: 10px 6px 2px 8px;
  border-top: 1px solid var(--border);
}

.sb-user-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.sb-user-name,
.sb-user-mail {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sb-user-name {
  font-weight: 600;
  font-size: 13px;
}

.sb-user-mail {
  font-size: 11.5px;
  color: var(--text-3);
}

/* ------------------------------------------------------------------ Posteingang (3 Spalten) */

.inbox {
  display: grid;
  grid-template-columns: var(--list-w) minmax(0, 1fr) var(--ctx-w);
  min-width: 0;
  min-height: 0;
  height: 100dvh;
}

.inbox.ctx-toggled,
.inbox:not(.has-selection) {
  grid-template-columns: var(--list-w) minmax(0, 1fr) 0;
}

.inbox:not(.has-selection) .ctx-col {
  display: none;
}

.inbox.ctx-toggled .ctx-col {
  display: none;
}

/* ------------------------------------------------------------------ Liste */

.list-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 60px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.list-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conv-list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.conv-row {
  display: flex;
  gap: 11px;
  padding: 10px 10px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  transition: background 0.08s;
}

.conv-row:hover {
  background: var(--hover);
}

.conv-row.selected {
  background: var(--selected);
}

.conv-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.conv-top,
.conv-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conv-name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 500;
}

.conv-row.unread .conv-name {
  font-weight: 600;
}

.conv-time {
  margin-left: auto;
  padding-left: 6px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  flex: none;
}

.conv-row.unread .conv-time {
  color: var(--accent);
  font-weight: 600;
}

.conv-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--text-2);
}

.conv-row.unread .conv-preview {
  color: var(--text);
}

.conv-prefix {
  color: var(--text-3);
}

.conv-alert {
  color: var(--red);
  display: inline-flex;
}

.conv-assignee {
  display: inline-flex;
  flex: none;
}

.list-more {
  display: flex;
  justify-content: center;
  padding: 6px 0 16px;
}

.list-skeleton {
  padding: 8px 6px;
}

.skeleton-row {
  display: flex;
  gap: 11px;
  padding: 11px 10px;
}

.sk-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hover);
  flex: none;
}

.sk-lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
  padding-top: 3px;
}

.sk-lines span {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--hover) 0%, var(--bg-soft) 50%, var(--hover) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

.sk-lines span:first-child {
  width: 55%;
}

.sk-lines span:last-child {
  width: 85%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ------------------------------------------------------------------ Chat */

.conv-col {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-soft);
  container-type: inline-size;
}

/* Schmale Chatspalte: Aktionen kompakter, damit der Name sichtbar bleibt. */
@container (max-width: 580px) {
  .conv-actions .btn-label {
    display: none;
  }

  .conv-actions .btn {
    padding: 0 9px;
  }

  .assign-btn {
    max-width: 140px;
  }
}

@container (max-width: 700px) {
  .conv-head-sub .since,
  .conv-head-sub .since-dot {
    display: none;
  }
}

/* Sehr schmal (Handy): Aktionen in eine eigene Zeile unter dem Namen. */
@container (max-width: 540px) {
  .conv-head {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* Höhere Spezifität: Die Grundregeln stehen weiter unten. */
  .conv-head .conv-actions {
    order: 3;
    flex: 0 0 100%;
    gap: 6px;
  }

  .conv-head .assign {
    flex: 1;
    margin-right: 0;
  }

  .conv-head .assign-btn {
    width: 100%;
    max-width: none;
    height: 34px;
  }

  .conv-head .assign-label {
    flex: 1;
    text-align: left;
  }

  .conv-head .assign-menu {
    right: auto;
    left: 0;
    width: min(280px, calc(100cqw - 12px));
  }

  .conv-actions .btn-label {
    display: inline;
  }
}

.conv-empty {
  justify-content: center;
}

.conv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex: none;
}

.conv-head-main {
  flex: 1;
  min-width: 0;
}

.conv-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conv-head-title h2 {
  flex: 0 1 auto;
  min-width: 4em;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conv-head-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--text-2);
}

.conv-head-sub .dot {
  color: var(--text-3);
}

.conv-head-sub .origin,
.conv-head-sub .warn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.conv-head-sub .warn {
  color: var(--red);
  font-weight: 500;
}

.conv-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.assign {
  position: relative;
  margin-right: 4px;
}

.assign-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  max-width: 190px;
  padding: 0 7px 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.assign-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--hover);
}

.assign-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.assign-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.assign-label {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assign-none,
.assign-none-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--hover);
  color: var(--text-3);
  flex: none;
}

.assign-none-lg {
  width: 28px;
  height: 28px;
}

.assign-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 230px;
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  animation: rise 0.1s ease-out;
}

.assign-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 38px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.assign-option.active {
  background: var(--hover);
  outline: none;
}

.assign-option[aria-selected="true"] {
  font-weight: 600;
}

.assign-option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assign-check {
  display: inline-flex;
  color: var(--accent);
}

.messages {
  flex: 1;
  min-height: 0;
  padding: 8px 22px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.messages-loading {
  display: grid;
  place-items: center;
  height: 100%;
}

.history-top {
  display: flex;
  justify-content: center;
  padding: 10px 0 2px;
  min-height: 36px;
}

.history-start {
  font-size: 12px;
  color: var(--text-3);
}

.day-sep {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}

.day-sep span {
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

.event-line {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.event-line time {
  font-size: 11px;
}

.msg {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  max-width: min(680px, 86%);
}

.msg.compact {
  margin-top: 3px;
}

.msg-in {
  margin-right: auto;
}

.msg-out,
.msg-note {
  margin-left: auto;
  justify-content: flex-end;
}

.msg-avatar {
  width: 28px;
  flex: none;
}

.msg-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.msg-out .msg-body,
.msg-note .msg-body {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 4px 3px;
  font-size: 11.5px;
  color: var(--text-3);
}

.msg-out .msg-meta {
  justify-content: flex-end;
}

.bubble {
  padding: 9px 13px;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.5;
}

.msg-in .bubble {
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.msg-in.compact .bubble {
  border-top-left-radius: 6px;
}

.msg-out .bubble {
  border-bottom-right-radius: 6px;
  background: var(--accent);
  color: #fff;
}

.msg-out.compact .bubble {
  border-top-right-radius: 6px;
}

.msg-out .bubble a {
  color: #fff;
}

.msg-note {
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.msg-note .msg-meta {
  color: var(--note-text);
  font-weight: 600;
}

.msg-note .bubble {
  border: 1px solid var(--note-border);
  border-bottom-right-radius: 6px;
  background: var(--note-bg);
  color: var(--text);
}

.msg.pending .bubble {
  opacity: 0.7;
}

.msg.failed .bubble {
  opacity: 1;
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

.msg-status {
  margin: 3px 4px 0;
  font-size: 11.5px;
  color: var(--text-3);
}

.msg-failed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--red);
}

/* ------------------------------------------------------------------ Antwortfeld */

.composer-wrap {
  padding: 0 18px 16px;
  flex: none;
}

.composer {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 3px var(--focus-ring);
}

.composer.note {
  border-color: var(--note-border);
  background: var(--note-bg);
}

.composer.note:focus-within {
  border-color: var(--note);
  box-shadow: var(--shadow), 0 0 0 3px rgba(203, 145, 47, 0.25);
}

.composer-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 8px 0;
}

.composer-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.composer-tab:hover {
  background: var(--hover);
}

.composer-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.composer-tab.tab-note.active {
  background: rgba(203, 145, 47, 0.18);
  color: var(--note-text);
}

.composer-hint {
  margin-left: auto;
  padding-right: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  max-height: 240px;
  padding: 8px 14px 4px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14.5px;
  line-height: 1.5;
}

.composer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 8px 14px;
}

.composer-help {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-3);
}

.composer-attach {
  margin-left: -8px;
}

.composer.note .composer-attach:hover {
  background: rgba(203, 145, 47, 0.15);
}

/* Dateien im Antwortfeld */

.upload-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 8px 10px 0;
  list-style: none;
}

.upload-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  height: 44px;
  padding: 4px 4px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  animation: rise 0.12s ease-out;
}

.composer.note .upload-chip {
  border-color: var(--note-border);
  background: rgba(255, 255, 255, 0.45);
}

.upload-chip.failed {
  border-color: var(--red);
  background: var(--red-soft);
}

.chip-thumb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: var(--hover);
  flex: none;
  cursor: zoom-in;
}

.chip-thumb:disabled {
  cursor: default;
}

.chip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-chip.busy .chip-thumb img {
  opacity: 0.55;
}

.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Fortschrittsring: konischer Verlauf, innen ausgestanzt */
.chip-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 0.36deg), var(--accent-soft) 0);
  -webkit-mask: radial-gradient(circle, transparent 7px, #000 7.5px);
  mask: radial-gradient(circle, transparent 7px, #000 7.5px);
  transition: background 0.2s;
}

.chip-alert {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 52, 44, 0.75);
  color: #fff;
}

.chip-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.chip-name {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-meta {
  overflow: hidden;
  font-size: 11.5px;
  color: var(--text-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-chip.failed .chip-meta {
  color: var(--red);
}

.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  flex: none;
  cursor: pointer;
}

.chip-remove:hover,
.chip-remove:focus-visible {
  background: var(--hover);
  color: var(--text);
  outline: none;
}

/* Ablegen von Dateien auf den Chat */

.drop-zone {
  position: absolute;
  inset: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  pointer-events: none;
  animation: fade 0.1s ease-out;
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-align: center;
}

.drop-title {
  font-size: 16px;
  font-weight: 600;
}

.drop-text {
  font-size: 12.5px;
  color: var(--text-2);
}

.composer-count {
  font-size: 11.5px;
  color: var(--text-3);
}

.composer-count.over {
  color: var(--red);
  font-weight: 600;
}

.btn-send {
  height: 32px;
}

.btn-send.btn-note {
  background: var(--note);
  border-color: var(--note);
}

.btn-send.btn-note:hover:not(:disabled) {
  background: var(--note-hover);
  border-color: var(--note-hover);
}

.composer-archived {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--text-2);
}

.composer-archived > span:not(.icon) {
  flex: 1;
}

/* ------------------------------------------------------------------ Dateien im Verlauf */

.msg-note .msg-meta .avatar {
  margin-right: 2px;
}

.att-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 4px;
  max-width: 100%;
}

.att-list.att-end {
  align-items: flex-end;
}

.msg-meta + .att-list {
  margin-top: 0;
}

.att-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
}

.att-end .att-images {
  justify-content: flex-end;
}

.att-images.att-grid {
  max-width: 280px;
}

.att-image {
  position: relative;
  display: block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--hover);
  cursor: zoom-in;
  transition: filter 0.12s, box-shadow 0.12s;
}

.att-grid .att-image {
  width: 138px;
  height: 138px;
  border-radius: 6px;
}

.att-image:hover {
  filter: brightness(0.96);
}

.att-image:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.att-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.att-image.broken {
  width: 200px;
  height: 120px;
  cursor: default;
}

.att-broken {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  font-size: 12px;
  color: var(--text-3);
}

.att-file {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 280px;
  max-width: 100%;
  padding: 4px 4px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.msg-note .att-file {
  border-color: var(--note-border);
  background: var(--note-bg);
}

.att-file-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 4px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.att-file-main:hover {
  background: var(--hover);
}

.att-file-main:focus-visible,
.att-file-dl:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.att-file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  flex: none;
}

.att-file-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.att-file-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.att-file-meta {
  font-size: 11.5px;
  color: var(--text-3);
}

/* Farben je Dateiart (hell und dunkel lesbar) */
.k-pdf { background: #fdecea; color: #b42318; }
.k-doc { background: #e6f0ff; color: #1e4f99; }
.k-sheet { background: #e4f5ee; color: #12805c; }
.k-slides { background: #fff1dc; color: #a35b00; }
.k-text, .k-other { background: var(--hover); color: var(--text-2); }
.k-image { background: var(--accent-soft); color: var(--accent); }

@media (prefers-color-scheme: dark) {
  .k-pdf { background: #3f1a18; color: #ff9b8f; }
  .k-doc { background: #172a4a; color: #9cc0ff; }
  .k-sheet { background: #12352a; color: #7fd8b4; }
  .k-slides { background: #3d2a10; color: #f6c27a; }
}

/* Großansicht */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(15, 15, 15, 0.9);
  color: #fff;
  animation: fade 0.12s ease-out;
}

.lb-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 10px 18px;
  flex: none;
}

.lb-title {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.lb-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
}

.lb-btn {
  width: 38px;
  height: 38px;
  color: rgba(255, 255, 255, 0.85);
}

.lb-btn:hover,
.lb-btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  outline: none;
}

.lb-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  padding: 0 64px 24px;
}

.lb-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  object-fit: contain;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}

.lb-img.loaded {
  background-image: none !important;
}

.lb-nav {
  position: absolute;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-top: -34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.lb-nav:hover,
.lb-nav:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  outline: none;
}

.lb-prev {
  left: 12px;
}

.lb-next {
  right: 12px;
}

/* Team in der Seitenleiste */

.sb-team {
  margin-top: 14px;
  padding: 0 8px;
}

.sb-team-title {
  margin: 0 0 4px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sb-team-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sb-team-row {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.sb-team-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-team-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.sb-team-count.zero {
  color: var(--text-3);
  font-weight: 500;
}

/* ------------------------------------------------------------------ Kundeninfos */

.ctx-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--bg);
}

.ctx-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 10px 0 18px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.ctx-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.ctx-body {
  flex: 1;
  min-height: 0;
  padding: 14px 16px 24px;
  overflow-y: auto;
}

.ctx-empty,
.ctx-loading {
  padding: 24px 16px;
  color: var(--text-3);
  text-align: center;
}

.ctx-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.ctx-section:last-child {
  border-bottom: 0;
}

.ctx-section h3 {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.ctx-section h4 {
  margin: 12px 0 6px;
  font-size: 12px;
  color: var(--text-2);
}

.ctx-person {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-top: 2px;
  border-bottom: 0;
}

.ctx-name {
  font-size: 15px;
  font-weight: 600;
}

.ctx-mail {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  word-break: break-all;
}

.ctx-mail:hover {
  color: var(--accent);
  text-decoration: underline;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0;
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.4;
}

.notice .icon {
  margin-top: 1px;
}

.notice-ok {
  background: var(--green-soft);
  color: var(--green);
}

.notice-warn {
  background: var(--orange-soft);
  color: var(--orange);
}

.notice-danger {
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
}

.ctx-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  margin: 0;
  font-size: 13px;
}

.ctx-dl dt {
  color: var(--text-3);
}

.ctx-dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ctx-url a {
  color: var(--text-2);
}

.ctx-person-row {
  display: flex;
  gap: 9px;
  padding: 5px 0;
}

.ctx-person-name {
  font-weight: 600;
  font-size: 13px;
}

.ctx-person-meta {
  font-size: 12px;
  color: var(--text-2);
}

.ctx-crm {
  margin: 12px 0 2px;
  width: 100%;
}

.ctx-history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ctx-history a {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -8px;
  padding: 7px 8px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

.ctx-history a:hover {
  background: var(--hover);
}

.ctx-hist-top {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
}

.ctx-hist-meta {
  font-weight: 400;
  color: var(--text-3);
}

.ctx-hist-preview {
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ctx-mails {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
}

.ctx-mails li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}

.ctx-mail-status {
  color: var(--text-3);
  white-space: nowrap;
}

.ctx-mails li.bad .ctx-mail-status {
  color: var(--red);
  font-weight: 600;
}

.ctx-hint {
  margin: 8px 0 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-3);
}

.ctx-danger {
  padding-top: 16px;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ Einstellungen */

.settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 0 32px 32px;
  overflow-y: auto;
  background: var(--bg-soft);
}

.settings-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 60px;
  margin: 0 -32px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.settings-head h1 {
  margin: 0;
  font-size: 16px;
}

.settings > .btn {
  align-self: flex-start;
}

.card {
  max-width: 640px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.card-text {
  margin: 0 0 12px;
  color: var(--text-2);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.switch-title {
  display: block;
  font-weight: 600;
}

.switch-text {
  display: block;
  font-size: 13px;
  color: var(--text-2);
}

.switch {
  appearance: none;
  position: relative;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(16px);
}

/* ------------------------------------------------------------------ Dialoge und Meldungen */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 15, 15, 0.32);
  animation: fade 0.12s ease-out;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 41;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 20px 22px;
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%);
  animation: pop 0.14s ease-out;
}

.modal-small {
  width: min(420px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal-text {
  margin: 0 0 18px;
  color: var(--text-2);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.shortcut-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 16px;
  margin: 8px 0 0;
}

.shortcut-list dt {
  text-align: right;
}

.shortcut-list dd {
  margin: 0;
  color: var(--text-2);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translate(-50%, -48%) scale(0.98);
  }
}

/* Für Elemente im Fluss (ohne die Zentrierung der Dialoge) */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(3px) scale(0.98);
  }
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 380px;
  padding: 9px 8px 9px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  pointer-events: auto;
  animation: slide 0.16s ease-out;
}

.toast span {
  flex: 1;
}

.toast .icon-btn {
  width: 24px;
  height: 24px;
  color: rgba(255, 255, 255, 0.7);
}

.toast .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.toast-error {
  background: var(--red);
}

@keyframes slide {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ------------------------------------------------------------------ Mittlere Breite: Kundeninfos als Schublade */

@media (max-width: 1279px) {
  .inbox,
  .inbox.ctx-toggled,
  .inbox:not(.has-selection) {
    grid-template-columns: var(--list-w) minmax(0, 1fr);
  }

  .ctx-col,
  .inbox.ctx-toggled .ctx-col {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: min(var(--ctx-w), 92vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.18s ease-out, visibility 0.18s;
  }

  .inbox.ctx-toggled .ctx-col {
    transform: none;
    visibility: visible;
  }

  .inbox.ctx-toggled .ctx-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgba(15, 15, 15, 0.2);
  }
}

@media (max-width: 1079px) {
  :root {
    --list-w: 300px;
  }

  .btn-label {
    display: none;
  }
}

/* ------------------------------------------------------------------ Schmal (Handy): Liste ODER Chat */

@media (max-width: 899px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 35;
    width: min(280px, 86vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.18s ease-out, visibility 0.18s;
  }

  .shell.nav-open .sidebar {
    transform: none;
    visibility: visible;
  }

  .shell.nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 34;
    background: rgba(15, 15, 15, 0.25);
  }

  .mobile-only {
    display: inline-flex;
  }

  .desktop-only {
    display: none;
  }

  .inbox,
  .inbox.ctx-toggled,
  .inbox:not(.has-selection) {
    grid-template-columns: minmax(0, 1fr);
  }

  .inbox .conv-col {
    display: none;
  }

  .inbox.has-selection .conv-col {
    display: flex;
  }

  .inbox.has-selection .list-col {
    display: none;
  }

  .list-col {
    border-right: 0;
  }

  .list-head {
    padding: 0 10px;
  }

  .conv-head {
    gap: 8px;
    padding: 8px 8px 8px 6px;
  }

  .conv-head > .avatar {
    display: none;
  }

  .conv-head-sub {
    font-size: 11.5px;
  }

  .messages {
    padding: 6px 12px 12px;
  }

  .msg {
    max-width: 92%;
  }

  .composer-wrap {
    padding: 0 8px calc(8px + env(safe-area-inset-bottom));
  }

  .composer-help {
    display: none;
  }

  .composer-foot {
    justify-content: flex-end;
  }

  .composer textarea {
    font-size: 16px;
  }

  .settings {
    padding: 0 16px 24px;
  }

  .settings-head {
    margin: 0 -16px;
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 899px) {
  .composer-attach {
    margin-right: auto;
  }

  .lb-stage {
    padding: 0 8px 16px;
  }

  .lb-nav {
    top: auto;
    bottom: 24px;
  }

  .upload-chip {
    max-width: 100%;
  }
}
