/* ============ APP STYLES ============ */

/* ---------- Login ---------- */
.login-shell {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg-0);
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(212, 168, 75, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(212, 168, 75, 0.04), transparent 50%),
    var(--bg-0);
  pointer-events: none;
}
.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 48px 44px 40px;
  z-index: 1;
  animation: slideUp 0.5s ease;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}
.login-logo img {
  width: 220px;
  height: auto;
  filter: drop-shadow(0 4px 24px rgba(212, 168, 75, 0.25));
}
.login-eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--gold);
  text-transform: uppercase;
  margin-top: 8px;
}
.login-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
  text-align: center;
  letter-spacing: 0.04em;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-mid);
  text-align: center;
  margin: 0 0 32px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}
.field-input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field-input:focus {
  border-color: var(--gold);
  background: var(--bg-3);
}
.field-input::placeholder { color: var(--text-dim); }

.login-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-top: 4px;
}
.login-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-mid);
  cursor: pointer;
}
.login-row a {
  color: var(--gold);
  text-decoration: none;
}
.login-row a:hover { color: var(--gold-bright); }

.checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  appearance: none;
  cursor: pointer;
  position: relative;
}
.checkbox:checked {
  background: var(--gold);
  border-color: var(--gold);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--bg-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1a1a;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  letter-spacing: 0.02em;
  transition: filter 0.15s, transform 0.05s;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 8px rgba(212, 168, 75, 0.2);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}
.login-footer .sep { margin: 0 8px; opacity: 0.4; }

.login-error {
  background: rgba(217, 100, 89, 0.08);
  border: 1px solid rgba(217, 100, 89, 0.3);
  color: #e89690;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- App Shell ---------- */
.app {
  display: grid;
  grid-template-columns: 64px 360px 1fr;
  height: 100vh;
  height: 100dvh; /* iOS Safari dynamic viewport — fixes URL-bar clipping composer */
  background: var(--bg-0);
  color: var(--text);
}

/* ---------- Nav rail ---------- */
.rail {
  background: var(--bg-1);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
}
.rail-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 1px solid var(--gold-soft-2);
  position: relative;
}
.rail-logo svg { width: 22px; height: 22px; }
.rail-logo::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  background: radial-gradient(circle at center, rgba(212, 168, 75, 0.2), transparent 70%);
  z-index: -1;
}
.rail-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s;
}
.rail-btn:hover {
  background: var(--bg-2);
  color: var(--text);
}
.rail-btn.active {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: var(--gold-soft-2);
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-spacer { flex: 1; }

.rail-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #555 0%, #333 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  border: 2px solid var(--bg-3);
  cursor: pointer;
}

/* ---------- Sidebar (chat list) ---------- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  min-height: 0; /* CSS Grid: default min-height:auto traps overflow:auto children */
  overflow: hidden;
  min-width: 0;
}
.sidebar-header {
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0;
}
.sidebar-title .accent { color: var(--gold); }

.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mid);
  padding: 4px 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.platform-pill .ig-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap svg {
  position: absolute;
  left: 11px;
  width: 14px;
  height: 14px;
  color: var(--text-dim);
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px 9px 33px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--gold-soft-2); }
.search-input::placeholder { color: var(--text-dim); }

.filter-row {
  display: flex;
  gap: 6px;
  padding: 0 18px 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-top: -2px;
}
.filter-pill {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-mid);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.filter-pill:hover { color: var(--text); border-color: var(--bg-4); }
.filter-pill.active {
  background: var(--gold-soft);
  border-color: var(--gold-soft-2);
  color: var(--gold);
}
.filter-pill .count {
  background: var(--bg-3);
  color: var(--text-mid);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
}
.filter-pill.active .count {
  background: var(--gold);
  color: var(--bg-0);
}

.chat-list {
  flex: 1;
  min-height: 0; /* Firefox needs this for flex children with overflow:auto */
  overflow-y: auto;
  padding: 4px 0;
}
.chat-item {
  padding: 12px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.15s;
  position: relative;
}
.chat-item:hover { background: var(--bg-2); }
.chat-item.active {
  background: var(--bg-2);
  border-left-color: var(--gold);
}
.chat-item.unread .chat-name { color: var(--text); font-weight: 600; }
.chat-item.unread .chat-snippet { color: var(--text); }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}
.avatar.online::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: var(--success);
  border: 2px solid var(--bg-1);
  border-radius: 50%;
}
.chat-item.active .avatar.online::after { border-color: var(--bg-2); }

.chat-meta { min-width: 0; }
.chat-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.chat-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-left: auto;
}
.chat-snippet {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-snippet .who-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.chat-snippet .who-tag.ai { color: var(--gold); }
.chat-snippet .who-tag.staff { color: var(--success); }
.chat-snippet .who-tag.you { color: var(--text-mid); }

.chat-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.unread-badge {
  background: var(--gold);
  color: var(--bg-0);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}
.ai-indicator-dot.paused { background: var(--text-dim); box-shadow: none; }

/* ---------- Main / Chat View ---------- */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  min-width: 0;
  min-height: 0; /* CSS Grid: enables inner overflow:auto on .messages */
  overflow: hidden;
  position: relative;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  padding: 32px;
  text-align: center;
}
.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  margin-bottom: 8px;
}
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: 0.06em;
}
.empty-state p { margin: 0; font-size: 13px; max-width: 320px; }

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-1);
  min-height: 68px;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.chat-header-name .verified { color: var(--gold); }
.chat-header-handle {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.icon-btn:hover {
  background: var(--bg-3);
  color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; }

/* AI toggle */
.ai-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  transition: all 0.15s;
}
.ai-toggle:hover { border-color: var(--bg-4); }
.ai-toggle.on {
  background: var(--gold-soft);
  border-color: var(--gold-soft-2);
  color: var(--gold);
}
.ai-toggle .switch {
  position: relative;
  width: 28px;
  height: 16px;
  background: var(--bg-4);
  border-radius: 999px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.ai-toggle .switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text);
  border-radius: 50%;
  transition: left 0.2s;
}
.ai-toggle.on .switch { background: var(--gold); }
.ai-toggle.on .switch::after { left: 14px; background: var(--bg-0); }

.ai-toggle .ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}
.ai-toggle.on .ai-dot {
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
  animation: pulse 2s infinite;
}
.ai-toggle .label-text {
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.ai-toggle { white-space: nowrap; flex-shrink: 0; }

/* Notice bar (when AI is paused after staff reply) */
.notice-bar {
  background: linear-gradient(90deg, var(--gold-soft), transparent 70%);
  border-bottom: 1px solid var(--gold-soft-2);
  padding: 10px 24px;
  font-size: 12px;
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease;
}
.notice-bar .icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--gold-soft-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}
.notice-bar .text { flex: 1; color: var(--text); }
.notice-bar .text strong { color: var(--gold-bright); font-weight: 600; }
.notice-bar button {
  background: transparent;
  border: 1px solid var(--gold-soft-2);
  color: var(--gold-bright);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.15s;
}
.notice-bar button:hover {
  background: var(--gold-soft-2);
  color: var(--gold-bright);
}

/* Messages */
.messages {
  flex: 1;
  min-height: 0; /* enables flex child overflow:auto in Firefox + nested CSS Grid */
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.day-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 16px 0 12px;
  position: relative;
}
.day-divider::before, .day-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 70px);
  height: 1px;
  background: var(--line-soft);
}
.day-divider::before { left: 0; }
.day-divider::after { right: 0; }

.msg-row {
  display: flex;
  gap: 10px;
  max-width: 70%;
  animation: slideUp 0.25s ease;
}
.msg-row.from-them { align-self: flex-start; }
.msg-row.from-us { align-self: flex-end; flex-direction: row-reverse; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  position: relative;
  max-width: 100%;
}
.msg-row.from-them .msg-bubble {
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.msg-row.from-us .msg-bubble {
  border-bottom-right-radius: 4px;
}
.msg-row.from-us.staff .msg-bubble {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
}
.msg-row.from-us.ai .msg-bubble {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-2);
  color: var(--text);
}
/* Source-specific styles — distinguish dashboard reply vs. direct Instagram-App reply */
.msg-row.from-us.src-dashboard .msg-bubble {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
}
.msg-row.from-us.src-ig_app .msg-bubble {
  background: var(--bg-2);
  border: 1px dashed var(--line);
  color: var(--text);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.msg-row.from-us .msg-meta { justify-content: flex-end; }
.msg-meta .who {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 9.5px;
}
.msg-meta .who.ai { color: var(--accent); }
.msg-meta .who.staff { color: var(--success); }
.msg-meta .who.staff.dashboard { color: var(--success); }
.msg-meta .who.staff.ig-app { color: var(--text-mid); font-style: italic; }

.msg-image {
  max-width: 280px;
  max-height: 320px;
  border-radius: 12px;
  display: block;
  margin: 0;
  background: var(--bg-2);
}
.msg-row.from-them .msg-image { border-bottom-left-radius: 4px; }
.msg-row.from-us .msg-image { border-bottom-right-radius: 4px; }
.msg-bubble.no-pad { padding: 0; background: transparent; border: none; overflow: hidden; }

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: typing 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

.ai-thinking-row {
  display: flex;
  gap: 10px;
  max-width: 70%;
  align-self: flex-start;
  animation: slideUp 0.25s ease;
}
.ai-thinking-bubble {
  background: linear-gradient(135deg, rgba(212, 168, 75, 0.15), rgba(212, 168, 75, 0.05));
  border: 1px solid var(--gold-soft-2);
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

/* Composer */
.composer {
  border-top: 1px solid var(--line-soft);
  background: var(--bg-1);
  padding: 14px 20px 18px;
}
.composer-attach-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.attach-preview {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.attach-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-preview .remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: var(--text);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.attach-preview .remove:hover { background: var(--danger); }

.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: end;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 12px;
  transition: border-color 0.15s;
}
.composer-row:focus-within { border-color: var(--gold-soft-2); }
.composer-input {
  background: transparent;
  border: none;
  resize: none;
  color: var(--text);
  font-size: 14px;
  outline: none;
  padding: 8px 0;
  max-height: 140px;
  min-height: 24px;
  font-family: inherit;
  line-height: 1.45;
}
.composer-input::placeholder { color: var(--text-dim); }

.composer-actions { display: flex; align-items: center; gap: 4px; }
.composer-actions .icon-btn { width: 36px; height: 36px; }
.composer-actions .icon-btn:hover { color: var(--gold); }

.btn-send {
  background: var(--gold);
  color: var(--bg-0);
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.btn-send:hover { filter: brightness(1.1); }
.btn-send:active { transform: translateY(1px); }
.btn-send:disabled {
  background: var(--bg-4);
  color: var(--text-dim);
  cursor: not-allowed;
  filter: none;
}
.btn-send svg { width: 18px; height: 18px; }

.composer-hint {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
}
.composer-hint kbd {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
  color: var(--text-mid);
}

/* Right Panel — customer details */
.app.has-details {
  grid-template-columns: 64px 320px 1fr 280px;
}
.details {
  background: var(--bg-1);
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.details-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.details-header h4 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin: 0;
}
.details-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}
.details-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 24px;
  color: var(--text);
}
.details-name {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px;
}
.details-handle {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 18px;
}
.details-section {
  border-top: 1px solid var(--line-soft);
  padding: 16px 0;
}
.details-section h5 {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 10px;
}
.details-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 8px;
}
.details-row .lbl { color: var(--text-dim); }
.details-row .val { color: var(--text); }
.tag {
  display: inline-block;
  font-size: 10.5px;
  padding: 3px 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin-right: 4px;
  margin-bottom: 4px;
  color: var(--text-mid);
}
.tag.gold {
  background: var(--gold-soft);
  border-color: var(--gold-soft-2);
  color: var(--gold);
}

/* Anfragen-Filter-Pill — Highlight für Instagram Message Requests */
.filter-pill.requests {
  border-color: var(--accent-soft-2, var(--gold-soft-2));
  color: var(--accent, var(--gold));
}
.filter-pill.requests.active {
  background: var(--accent-soft, var(--gold-soft));
  color: var(--accent, var(--gold));
  border-color: var(--accent, var(--gold));
}
.filter-pill.requests .count {
  background: var(--accent, var(--gold));
  color: #fff;
  font-weight: 700;
}

/* Chat-Item mit pending Anfrage — linker Streifen + leichter Hintergrund */
.chat-item.is-request {
  position: relative;
  background: linear-gradient(90deg, var(--accent-soft, var(--gold-soft)) 0%, transparent 60%);
}
.chat-item.is-request::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent, var(--gold));
  border-radius: 0 2px 2px 0;
}

/* Request-Banner im ChatView Header — instruiert das Studio zu akzeptieren */
.request-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: var(--accent-soft, var(--gold-soft));
  border-bottom: 1px solid var(--accent-soft-2, var(--gold-soft-2));
  font-size: 13px;
}
.request-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
}
.request-banner-text strong {
  font-family: var(--font-display, serif);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
}
.request-banner-text span {
  font-size: 12.5px;
  color: var(--text-mid);
  line-height: 1.5;
}
.request-banner-cta {
  background: var(--accent, var(--gold));
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.request-banner-cta:hover {
  filter: brightness(1.1);
}

/* Mobile-Logout (in sidebar global-header) — visible only on mobile where rail is hidden */
.mobile-logout-btn {
  display: none; /* desktop: hidden, logout via rail-avatar */
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--text-mid);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.mobile-logout-btn:hover {
  border-color: var(--accent, var(--gold));
  color: var(--accent, var(--gold));
}

/* Mobile */
@media (max-width: 900px) {
  .mobile-logout-btn { display: inline-flex; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .app.has-details { grid-template-columns: 1fr; }
  .rail {
    flex-direction: row;
    width: 100%;
    height: 56px;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    display: none;
  }
  .sidebar {
    display: flex;
    border-right: none;
  }
  .main {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg-0);
    animation: slideInRight 0.25s ease;
  }
  .details { display: none; }
  .app.show-chat .sidebar { display: none; }
  .app.show-chat .main { display: flex; }
  .chat-header { padding-left: 12px; }
  .messages { padding: 16px; }
  .composer { padding: 12px 14px; }
  .login-card { padding: 32px 24px; max-width: 100%; }
}

.back-btn {
  display: none;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  color: var(--text);
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  margin-right: 4px;
}
.back-btn:hover { background: var(--bg-3); }
@media (max-width: 900px) {
  .back-btn { display: flex; }
}

/* Header bar (top of sidebar — Studio info + global AI) */
.global-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-1);
  gap: 8px;
}
.studio-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.studio-info img {
  height: 28px;
  width: auto;
}
.studio-info .studio-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.studio-info .studio-name {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1;
}
.studio-info .studio-loc {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Top toolbar */
.toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
}

/* =====================================================================
 * INK & PAPER — Visual Override Layer (P2)
 * Premium Tattoo-Brand Aesthetic — Editorial Operator
 *
 * Idee:
 *   - Workspace (Sidebar, Rail, Composer-Frame) = Ink #0E0E0E
 *   - Messaging-Canvas (.messages, Bubbles) = Bone-Paper #F3EFE6
 *   - Surgical Ink-Red Accent #c6a36a NUR fuer: Unread / Send / AI-Live / Pin
 *   - Hairline-Rules statt Pills, Gradients raus, Drop-Shadows raus
 *
 * Diese Regeln stehen am Ende -> CSS-Cascade ueberschreibt aeltere
 * Gold/Gradient-Definitionen. Alte Klassen + Variablen bleiben aktiv,
 * werden hier visuell ueberholt.
 * ===================================================================== */

/* --- App Shell + Login --- */
body, html { background: #0E0E0E; }
.login-bg {
  background:
    radial-gradient(ellipse at 30% 0%, rgba(200, 48, 42, 0.05), transparent 55%),
    radial-gradient(ellipse at 70% 100%, rgba(200, 48, 42, 0.03), transparent 55%),
    #0E0E0E;
}
.login-bg::before { opacity: 0.4; }
.login-logo img { filter: none; }

/* --- Sidebar + Rail (Ink workspace) --- */
.app { background: #0E0E0E; }
.rail { background: #0A0A0A; border-right-color: #1F1D1B; }
.sidebar { background: #161616; border-right-color: #1F1D1B; }
.global-header {
  background: linear-gradient(180deg, #1C1C1C 0%, #161616 100%);
  border-bottom: 1px solid #1F1D1B;
}
.studio-info img { filter: none; height: 28px; }

/* --- Chat-List Items (Ink panels with hairline) --- */
.chat-item {
  background: transparent;
  border-bottom: 1px solid #1F1D1B;
  transition: background 0.12s ease;
}
.chat-item:hover { background: #1C1C1C; }
.chat-item.active {
  background: #1C1C1C;
  border-left: 2px solid #c6a36a;
}
.chat-item.unread { background: rgba(198, 163, 106, 0.05); }
.chat-name { color: #ECECE6; font-weight: 600; }
.chat-snippet { color: #B5B0A8; }

.unread-badge {
  background: #c6a36a;
  color: #fff;
  box-shadow: none;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
}

.ai-indicator-dot {
  background: #c6a36a;
  box-shadow: 0 0 0 2px rgba(198, 163, 106, 0.18);
}
.ai-indicator-dot.paused { background: #5C5852; box-shadow: none; }

/* --- Filter Pills as Tabs (hairline, not pill) --- */
.filter-row { border-bottom: 1px solid #1F1D1B; padding-bottom: 0; padding-top: 4px; }
.filter-pill {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  border-bottom: 2px solid transparent !important;
  color: #7A7670 !important;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
  padding: 10px 14px !important;
  margin-bottom: -1px;
}
.filter-pill.active {
  color: #ECECE6 !important;
  border-bottom-color: #c6a36a !important;
}
.filter-pill .count {
  background: transparent;
  color: #7A7670;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
}
.filter-pill.active .count { color: #c6a36a; }

/* --- AI Toggle (Ink-Red dot when on) --- */
.ai-toggle .ai-dot { background: #5C5852; }
.ai-toggle.on .ai-dot { background: #c6a36a; box-shadow: 0 0 8px rgba(198, 163, 106, 0.4); }
.ai-toggle.on .switch::after { background: #c6a36a; }

/* --- ChatView (Main) — Bone Paper Canvas --- */
.main { background: #F3EFE6; }
.chat-header {
  background: linear-gradient(180deg, #FFFFFF 0%, #F3EFE6 100%);
  border-bottom: 1px solid #D9D2C2;
  color: #1A1815;
}
.chat-header-name { color: #1A1815; font-weight: 700; }
.chat-header-handle { color: #5C5852; }
.chat-header .icon-btn {
  background: transparent;
  border: 1px solid #D9D2C2;
  color: #5C5852;
}
.chat-header .icon-btn:hover { border-color: #c6a36a; color: #c6a36a; }

/* Day divider on bone */
.messages { background: #F3EFE6; }
.day-divider {
  color: #8B8580;
  font-family: var(--font-display, serif);
  font-weight: 500;
  letter-spacing: 0.18em;
  font-size: 10px;
  text-transform: uppercase;
  margin: 14px 0;
}
.day-divider::before, .day-divider::after {
  border-color: #D9D2C2 !important;
}

/* --- Message Bubbles (Editorial, no gradient, hairline) --- */
.msg-bubble {
  box-shadow: none !important;
  border-radius: 4px !important;
  font-size: 14px;
  line-height: 1.55;
  padding: 10px 14px;
}
.msg-row.from-them .msg-bubble {
  background: #FFFFFF;
  border: 1px solid #D9D2C2;
  color: #1A1815;
}
.msg-row.from-us .msg-bubble {
  background: #1A1815;
  border: 1px solid #1A1815;
  color: #F3EFE6;
}

/* AI-Antwort: Ink-Bubble mit roter Akzent-Linie links */
.msg-row.from-us.ai .msg-bubble {
  background: #1A1815 !important;
  border: 1px solid #1A1815 !important;
  border-left: 3px solid #c6a36a !important;
  color: #F3EFE6 !important;
}

/* Dashboard-Staff: gleicher Ink-Look wie Standard-Out */
.msg-row.from-us.src-dashboard .msg-bubble {
  background: #1A1815 !important;
  border: 1px solid #1A1815 !important;
  color: #F3EFE6 !important;
}

/* IG-App Reply: gleiche Form aber dashed border = "kam von ausserhalb" */
.msg-row.from-us.src-ig_app .msg-bubble {
  background: #2A2724 !important;
  border: 1px dashed #5C5852 !important;
  color: #ECECE6 !important;
}

/* Message-meta + Badges */
.msg-meta {
  color: #8B8580;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.msg-row.from-them .msg-meta { color: #8B8580; }
.msg-row.from-us .msg-meta { color: #8B8580; }
.msg-meta .who.ai { color: #c6a36a; }
.msg-meta .who.staff.dashboard { color: #1A1815; }
.msg-meta .who.staff.ig-app { color: #8B8580; font-style: italic; }

/* --- Composer (Bone Paper toolbar) --- */
.composer {
  background: #FFFFFF;
  border-top: 1px solid #D9D2C2;
}
.composer textarea {
  background: transparent;
  color: #1A1815;
  font-family: var(--font-ui, system-ui);
}
.composer textarea::placeholder { color: #8B8580; }
.composer .icon-btn {
  background: transparent;
  border: 1px solid #D9D2C2;
  color: #5C5852;
  border-radius: 4px;
}
.composer .send-btn, .composer button[type="submit"], .composer .icon-btn:last-child {
  background: #c6a36a !important;
  color: #fff !important;
  border-color: #c6a36a !important;
  box-shadow: none !important;
}
.composer .send-btn:hover { filter: brightness(1.08); }

/* --- Notice Bar (KI pausiert) — Sand on Bone, no shadow --- */
.notice-bar {
  background: #FFF8E8;
  border-bottom: 1px solid #E8DCC0;
  color: #5C5852;
  box-shadow: none !important;
}
.notice-bar strong { color: #1A1815; }
.notice-bar button {
  background: #1A1815;
  color: #F3EFE6;
  border: 1px solid #1A1815;
  box-shadow: none !important;
}

/* --- Avatars — Solid Ink with Bone initials (no gradient) --- */
.avatar {
  background: #1A1815 !important;
  color: #F3EFE6;
  font-family: var(--font-display, serif);
  font-weight: 500;
  border: 1px solid #1A1815;
  box-shadow: none !important;
}
.avatar.online::after {
  background: #6CBA8A;
  border-color: #F3EFE6;
}

/* --- Sidebar Title typography --- */
.sidebar-title {
  font-family: var(--font-display, serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  font-size: 22px;
  color: #ECECE6;
}
.platform-pill {
  background: transparent;
  border: 1px solid #2A2724;
  color: #B5B0A8;
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 2px;
  text-transform: uppercase;
}

/* --- Search input --- */
.search-input {
  background: #1C1C1C;
  border: 1px solid #2A2724;
  color: #ECECE6;
  border-radius: 4px;
}
.search-input:focus { border-color: #c6a36a; outline: none; }
.search-input::placeholder { color: #5C5852; }

/* --- Drop-shadow cleanup --- */
* { -webkit-tap-highlight-color: transparent; }
.rail-logo, .rail-btn, .rail-avatar, .icon-btn, .chat-item, .msg-bubble, .composer, .login-card, .notice-bar { box-shadow: none !important; }

/* --- Login form on Ink --- */
.login-card { background: transparent; border: none; box-shadow: none; }
.login-input {
  background: #1C1C1C;
  border: 1px solid #2A2724;
  color: #ECECE6;
}
.login-input:focus { border-color: #c6a36a; }
.login-submit, .btn-primary {
  background: #c6a36a !important;
  color: #fff !important;
  border: none !important;
  font-family: var(--font-ui, system-ui);
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: none !important;
}
.login-submit:hover, .btn-primary:hover { filter: brightness(1.08); }

/* --- Mobile responsiveness leftover fixes --- */
@media (max-width: 900px) {
  .global-header { padding: 12px 14px; }
  .msg-bubble { max-width: 85%; }
  .msg-row { max-width: 95%; }
  .chat-header { padding: 10px 14px; }
}

/* =====================================================================
 * TF P3 — Bug-Fix Sweep + Cream-Gold Polish
 * Chat-name prominenter, Composer heller, Pin/Archive active-states,
 * EmojiPicker, AIToggle compact, Subtile KI-Indikatoren
 * ===================================================================== */

/* Chat-Names prominenter (was nicht klar genug sichtbar) */
.chat-name {
  font-family: var(--font-display, serif) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #f2e8dc !important;
  letter-spacing: -0.005em;
}
.chat-item.unread .chat-name { color: #f2e8dc !important; font-weight: 700 !important; }
.chat-snippet {
  font-size: 13px;
  color: #d2c7ba !important;
  line-height: 1.45;
}
.chat-time { color: #9d9287 !important; font-family: var(--font-mono, monospace); font-size: 10.5px; }

/* Composer-Bar heller — TF surface statt pure black */
.composer {
  background: #1c1c20 !important;
  border-top: 1px solid rgba(255,255,255,0.08) !important;
}
.composer-row {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 12px;
}
.composer-row:focus-within {
  border-color: #c6a36a !important;
  background: rgba(255,255,255,0.05);
}
.composer-input {
  background: transparent !important;
  color: #f2e8dc !important;
}
.composer-input::placeholder { color: #9d9287 !important; }
.composer-actions .icon-btn {
  background: transparent;
  color: #d2c7ba;
  border: 1px solid transparent;
}
.composer-actions .icon-btn:hover {
  color: #c6a36a !important;
  background: rgba(198, 163, 106, 0.08);
  border-color: rgba(198, 163, 106, 0.20);
}
.btn-send {
  background: #c6a36a !important;
  color: #131313 !important;
  border-radius: 10px;
  border: none !important;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-send:hover { background: #d5b27a !important; }
.btn-send:disabled {
  background: rgba(255,255,255,0.06) !important;
  color: #9d9287 !important;
  cursor: not-allowed;
}

/* Emoji-Picker Popover */
.emoji-wrap { position: relative; }
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: #1c1c20;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(10, 28px);
  gap: 2px;
  z-index: 200;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.emoji-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s;
}
.emoji-btn:hover { background: rgba(255,255,255,0.08); }

/* Pin-mini in der Chat-Liste */
.pin-mini { color: #c6a36a; margin-right: 4px; opacity: 0.85; }
.chat-item.is-pinned {
  background: linear-gradient(90deg, rgba(198,163,106,0.06) 0%, transparent 70%);
}

/* ChatHeader Pin-Button active-state */
.chat-header-actions .icon-btn.active {
  color: #c6a36a;
  background: rgba(198, 163, 106, 0.12);
  border-color: rgba(198, 163, 106, 0.25);
}

/* AIToggle compact (Sidebar global-header)
   Same Pill-Look wie Instagram-DMs-Pill — Cream-Gold wenn aktiv, danger-red wenn aus */
.ai-toggle.compact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid rgba(198, 163, 106, 0.30);
  background: rgba(198, 163, 106, 0.08);
  color: #c6a36a;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-toggle.compact:hover { background: rgba(198, 163, 106, 0.14); }
.ai-toggle.compact .ai-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #c6a36a;
  box-shadow: 0 0 6px rgba(198,163,106,0.5);
}
.ai-toggle.compact .label-text { font-family: var(--font-mono, monospace); }
.ai-toggle.compact .switch { display: none; }

/* Wenn AI aus: warning-red look */
.ai-toggle.compact:not(.on) {
  background: rgba(217, 100, 89, 0.10);
  border-color: rgba(217, 100, 89, 0.35);
  color: #d96459;
}
.ai-toggle.compact:not(.on) .ai-dot {
  background: #d96459;
  box-shadow: 0 0 6px rgba(217,100,89,0.5);
}

/* Platform-Pill ("Instagram DMs") im SELBEN Stil */
.platform-pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 4px 10px !important;
  font-size: 10px !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  border-radius: 999px !important;
  border: 1px solid rgba(198, 163, 106, 0.30) !important;
  background: rgba(198, 163, 106, 0.08) !important;
  color: #c6a36a !important;
  font-weight: 600 !important;
  font-family: var(--font-mono, monospace) !important;
}
.platform-pill .ig-dot {
  width: 6px !important; height: 6px !important; border-radius: 50% !important;
  background: #c6a36a !important;
  box-shadow: 0 0 6px rgba(198,163,106,0.5) !important;
}

/* AIToggle full mode (ChatHeader) — Label klarer mit "aktiv"-Badge */
.ai-toggle .label-text { font-weight: 500; }
.ai-toggle.on .label-text { color: #c6a36a; }
.ai-toggle.on .label-text::after { content: ''; }

/* Sidebar-Title in TF-Cream-Style */
.sidebar-title {
  color: #f2e8dc !important;
  font-family: var(--font-display, serif);
  font-weight: 500;
  letter-spacing: -0.005em;
}

/* Filter-Pills auf TF-Cream-Gold */
.filter-pill .count { color: #9d9287; }
.filter-pill.active { color: #f2e8dc !important; }
.filter-pill.requests {
  border-color: rgba(198, 163, 106, 0.20) !important;
  color: #c6a36a !important;
}

/* Rail TF-Brand */
.rail { background: #0d0d0f; border-right: 1px solid rgba(255,255,255,0.06); }
.rail-btn {
  color: #9d9287;
  background: transparent;
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
}
.rail-btn:hover { color: #c6a36a; background: rgba(198, 163, 106, 0.08); }
.rail-btn.active {
  color: #c6a36a;
  background: rgba(198, 163, 106, 0.12);
  border: 1px solid rgba(198, 163, 106, 0.25);
}
.rail-avatar {
  background: #1c1c20 !important;
  color: #c6a36a !important;
  font-family: var(--font-display, serif);
  font-weight: 600;
}

/* Main + Composer Background harmonisieren */
.main { background: #f2e8dc; } /* TF warm-cream */
.messages { background: #f2e8dc; }

/* Outgoing-Bubbles Ink mit Cream-Text */
.msg-row.from-us .msg-bubble {
  background: #1a1815 !important;
  border: 1px solid #1a1815 !important;
  color: #f2e8dc !important;
}
/* AI-Bubble bekommt Cream-Gold linke Akzent-Linie */
.msg-row.from-us.ai .msg-bubble {
  background: #1a1815 !important;
  border: 1px solid #1a1815 !important;
  border-left: 3px solid #c6a36a !important;
  color: #f2e8dc !important;
}
.msg-meta .who.ai { color: #c6a36a !important; }
.msg-row.from-them .msg-bubble {
  background: #ffffff !important;
  border: 1px solid rgba(26, 24, 21, 0.08) !important;
  color: #1a1815 !important;
}

/* Chat-Header auf TF-Paper */
.chat-header {
  background: linear-gradient(180deg, #ffffff 0%, #f2e8dc 100%) !important;
  border-bottom: 1px solid rgba(26, 24, 21, 0.10) !important;
  color: #1a1815;
}
.chat-header-name { color: #1a1815 !important; font-weight: 700; font-family: var(--font-display, serif); }
.chat-header-handle { color: #5c5852 !important; }
.chat-header .icon-btn {
  background: transparent;
  border: 1px solid rgba(26, 24, 21, 0.12);
  color: #5c5852;
  border-radius: 8px;
}
.chat-header .icon-btn:hover {
  border-color: #c6a36a;
  color: #c6a36a;
  background: rgba(198, 163, 106, 0.08);
}
.chat-header .icon-btn.active {
  color: #c6a36a;
  background: rgba(198, 163, 106, 0.12);
  border-color: rgba(198, 163, 106, 0.30);
}

/* AIToggle im ChatHeader (Paper-Style) */
.chat-header .ai-toggle {
  background: rgba(26, 24, 21, 0.04);
  border: 1px solid rgba(26, 24, 21, 0.10);
  color: #1a1815;
}
.chat-header .ai-toggle.on { color: #c6a36a; border-color: rgba(198, 163, 106, 0.30); background: rgba(198, 163, 106, 0.08); }

/* Day-Divider auf Paper */
.day-divider {
  color: #8b8580 !important;
  font-family: var(--font-display, serif);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 10px;
}

/* Composer auf Paper bei active */
.main .composer {
  background: #ffffff !important;
  border-top: 1px solid rgba(26, 24, 21, 0.08) !important;
}
.main .composer-row {
  background: rgba(26, 24, 21, 0.025);
  border: 1px solid rgba(26, 24, 21, 0.08) !important;
}
.main .composer-row:focus-within {
  border-color: #c6a36a !important;
  background: rgba(198, 163, 106, 0.04);
}
.main .composer-input { color: #1a1815 !important; }
.main .composer-input::placeholder { color: #8b8580 !important; }
.main .composer-actions .icon-btn { color: #5c5852; }
.main .composer-actions .icon-btn:hover {
  color: #c6a36a !important;
  background: rgba(198, 163, 106, 0.08);
}
.main .composer-hint { color: #8b8580; }
.main .composer-hint kbd {
  background: rgba(26, 24, 21, 0.05);
  border: 1px solid rgba(26, 24, 21, 0.10);
  color: #5c5852;
}
.main .emoji-picker {
  background: #ffffff;
  border: 1px solid rgba(26, 24, 21, 0.10);
  box-shadow: 0 12px 32px rgba(26, 24, 21, 0.15);
}
.main .emoji-btn:hover { background: rgba(26, 24, 21, 0.06); }

/* Send-Button auf Paper */
.main .btn-send {
  background: #c6a36a !important;
  color: #131313 !important;
}
.main .btn-send:hover { background: #d5b27a !important; }
.main .btn-send:disabled {
  background: rgba(26, 24, 21, 0.08) !important;
  color: #8b8580 !important;
}

/* Request-Banner Cream-Gold */
.request-banner {
  background: rgba(198, 163, 106, 0.10) !important;
  border-bottom: 1px solid rgba(198, 163, 106, 0.25) !important;
}
.request-banner-text strong { color: #c6a36a !important; }
.request-banner-cta {
  background: #c6a36a !important;
  color: #131313 !important;
}

/* =====================================================================
 * TF P4 — Mode Color-Coding (KI / Mensch / Request) + Delete-Button
 * Filter-Tabs visuell differenziert + linker Streifen pro Mode
 * ===================================================================== */

/* ChatItem position context fuer ::before-Streifen */
.chat-item {
  position: relative;
  padding: 14px 18px !important;
}
.chat-item::before { content: none; }

/* Mode-Streifen links — orthogonal zu unread/pinned */
.chat-item.mode-ki::before,
.chat-item.mode-human::before,
.chat-item.mode-request::before {
  content: '';
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}
.chat-item.mode-ki::before    { background: rgba(198, 163, 106, 0.55); } /* cream-gold */
.chat-item.mode-human::before { background: rgba(108, 186, 138, 0.55); } /* TF success-green */
.chat-item.mode-request::before { background: #c6a36a; }

/* Subtle background-tint pro Mode (nur sichtbar wenn nicht selected) */
.chat-item.mode-ki:not(.active):not(.unread):not(.is-request) {
  background: rgba(198, 163, 106, 0.025);
}
.chat-item.mode-human:not(.active):not(.unread):not(.is-request) {
  background: rgba(108, 186, 138, 0.025);
}

/* Unread bleibt deutlich rot-cream — ueberschreibt mode-tint */
.chat-item.unread {
  background: rgba(198, 163, 106, 0.07) !important;
}
.chat-item.unread::before {
  background: #c6a36a !important;
  width: 4px;
}

/* Active-State ueberschreibt mode-tint */
.chat-item.active {
  background: rgba(255, 255, 255, 0.06) !important;
  border-left: none;
}
.chat-item.active::before {
  background: #c6a36a !important;
  width: 4px;
}

/* AI-Indicator-Dot rechts: KI gold, Mensch gruen, paused dimmed */
.ai-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c6a36a;
  box-shadow: 0 0 0 2px rgba(198, 163, 106, 0.18);
}
.ai-indicator-dot.paused {
  background: #6CBA8A;
  box-shadow: 0 0 0 2px rgba(108, 186, 138, 0.18);
}

/* Filter-Pills KI / Mensch — Mode-spezifische Active-Farbe */
.filter-pill.ki.active {
  color: #c6a36a !important;
  border-bottom: 2px solid #c6a36a !important;
}
.filter-pill.ki .count { color: #c6a36a; }
.filter-pill.ki.active .count {
  background: rgba(198, 163, 106, 0.15);
  border-radius: 999px;
  padding: 1px 6px;
}

.filter-pill.human.active {
  color: #6CBA8A !important;
  border-bottom: 2px solid #6CBA8A !important;
}
.filter-pill.human .count { color: #6CBA8A; }
.filter-pill.human.active .count {
  background: rgba(108, 186, 138, 0.15);
  border-radius: 999px;
  padding: 1px 6px;
}

/* Trash/Danger-Button im ChatHeader */
.icon-btn.danger {
  color: #d96459;
  border-color: rgba(217, 100, 89, 0.20);
  margin-left: 6px;
}
.icon-btn.danger:hover {
  background: rgba(217, 100, 89, 0.10) !important;
  border-color: #d96459 !important;
  color: #d96459 !important;
}

/* Sidebar-Title Polish */
.sidebar-title {
  font-size: 24px !important;
  font-weight: 500 !important;
  letter-spacing: -0.01em;
}

/* Filter-Row Padding fuer mehr Atemraum */
.filter-row {
  padding: 6px 14px 0 !important;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-pill {
  white-space: nowrap;
  padding: 12px 14px !important;
}

/* Sticky Filter-Row beim Scroll */
.sidebar-header { position: sticky; top: 0; z-index: 5; background: inherit; }

/* =====================================================================
 * TF P5 — Clean-Redesign Final
 * Card-Style ChatItems, IG-Profilbilder, Mode-Dot statt Streifen,
 * CustomerProfile-Sidebar, Quick-Reply-Picker, Day-Stats-Banner
 * ===================================================================== */

/* 1) Filter-Pill counts immer als Pill sichtbar */
.filter-pill .count {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--text-mid, #d2c7ba) !important;
  padding: 2px 8px !important;
  border-radius: 999px !important;
  font-family: var(--font-mono, monospace) !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
  margin-left: 4px;
}
.filter-pill.active .count {
  background: rgba(198, 163, 106, 0.18) !important;
  color: #c6a36a !important;
}
.filter-pill.ki.active .count {
  background: rgba(198, 163, 106, 0.18) !important;
  color: #c6a36a !important;
}
.filter-pill.human.active .count {
  background: rgba(108, 186, 138, 0.18) !important;
  color: #6CBA8A !important;
}
.filter-pill.requests .count {
  background: rgba(198, 163, 106, 0.18) !important;
  color: #c6a36a !important;
}

/* 2) Streifen-Style RAUS, weniger Wirrwarr — nur unread + active behalten */
.chat-item.mode-ki::before,
.chat-item.mode-human::before,
.chat-item.mode-request::before { content: none !important; }
.chat-item.mode-ki:not(.active):not(.unread),
.chat-item.mode-human:not(.active):not(.unread) {
  background: transparent !important;
}

/* 3) ChatItem als clean Card */
.chat-list {
  padding: 6px 8px 24px !important;
}
.chat-item {
  margin: 2px 0 !important;
  padding: 11px 12px !important;
  border-radius: 10px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  transition: background 0.12s ease, border-color 0.12s ease;
  border-bottom: 0 !important;
  position: relative;
  display: grid !important;
  grid-template-columns: 36px 1fr auto !important;
  gap: 12px !important;
  align-items: center !important;
}
.chat-item:hover {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
}
.chat-item.unread {
  background: rgba(198, 163, 106, 0.06) !important;
  border-color: rgba(198, 163, 106, 0.18) !important;
}
.chat-item.unread .chat-name { font-weight: 700 !important; }
.chat-item.active {
  background: rgba(198, 163, 106, 0.12) !important;
  border-color: rgba(198, 163, 106, 0.35) !important;
}
.chat-item.is-pinned {
  background: linear-gradient(90deg, rgba(198,163,106,0.05) 0%, transparent 90%) !important;
}

/* Chat-Name / Snippet sauber */
.chat-name {
  font-family: var(--font-ui, system-ui) !important;
  font-size: 14.5px !important;
  font-weight: 600 !important;
  color: #f2e8dc !important;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.chat-snippet {
  font-size: 12.5px !important;
  color: #9d9287 !important;
  display: flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
}
.chat-snippet span:not(.who-tag) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-snippet .who-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.chat-snippet .who-tag.ai { color: #c6a36a; }
.chat-snippet .who-tag.staff { color: #6CBA8A; }
.chat-time {
  font-family: var(--font-mono, monospace) !important;
  font-size: 10.5px !important;
  color: #7a7670 !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Tag-Pills in der Chat-Liste (mini) */
.chat-tag-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.chat-tag-mini {
  font-size: 10px;
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(198, 163, 106, 0.10);
  border: 1px solid rgba(198, 163, 106, 0.22);
  color: #c6a36a;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-transform: lowercase;
}

/* 4) Avatar — IG-Profilbild vs. Initial */
.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: none !important;
}
.avatar-img-wrap {
  background: transparent !important;
  padding: 0;
  border: 1px solid rgba(198, 163, 106, 0.15);
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-initial {
  background: rgba(198, 163, 106, 0.10) !important;
  border: 1px solid rgba(198, 163, 106, 0.30) !important;
  color: #c6a36a !important;
  font-family: var(--font-display, serif) !important;
  font-weight: 500 !important;
}
.avatar.online::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #c6a36a;
  border: 2px solid #161618;
}

/* 5) Status-Bereich rechts: Mode-Dot statt Streifen */
.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mode-dot-ki { background: #c6a36a; box-shadow: 0 0 0 2px rgba(198,163,106,0.20); }
.mode-dot-human { background: #6CBA8A; box-shadow: 0 0 0 2px rgba(108,186,138,0.20); }
.mode-dot-request { background: #c6a36a; box-shadow: 0 0 0 2px rgba(198,163,106,0.35); }
.pin-mini { color: #c6a36a; opacity: 0.85; }
.note-mini { color: #6CBA8A; opacity: 0.8; }
.ai-indicator-dot { display: none !important; }

/* Unread-Badge nur leichten Pop */
.chat-item.unread .unread-badge {
  background: #c6a36a;
  color: #131313;
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* 6) QuickReplyPicker (Composer-Popover) */
.quick-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: #1c1c20;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 200;
  width: 360px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
}
.quick-picker-header {
  font-family: var(--font-display, serif);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9d9287;
  padding: 4px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}
.quick-row {
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 4px;
  align-items: baseline;
  color: #d2c7ba;
}
.quick-row:hover { background: rgba(198,163,106,0.10); color: #f2e8dc; }
.quick-slash {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: #c6a36a;
  font-weight: 700;
}
.quick-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #f2e8dc;
}
.quick-preview {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: #9d9287;
  line-height: 1.4;
  margin-top: 2px;
}
.main .quick-picker {
  background: #ffffff;
  border-color: rgba(26,24,21,0.10);
  box-shadow: 0 16px 40px rgba(26,24,21,0.18);
}
.main .quick-picker-header { color: #8b8580; border-bottom-color: rgba(26,24,21,0.08); }
.main .quick-row { color: #5c5852; }
.main .quick-row:hover { background: rgba(198,163,106,0.10); color: #1a1815; }
.main .quick-label { color: #1a1815; }
.main .quick-preview { color: #8b8580; }

/* 7) CustomerProfile Sidebar (rechts) */
.app.has-details {
  grid-template-columns: 64px 360px 1fr 320px !important;
}
.customer-profile {
  background: #161618;
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 22px 28px;
  overflow-y: auto;
  min-height: 0;
}
.customer-profile-head {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.customer-profile-avatar {
  margin-bottom: 14px;
}
.customer-profile-avatar .avatar {
  box-shadow: 0 8px 24px rgba(198,163,106,0.18);
}
.customer-profile-name {
  font-family: var(--font-display, serif);
  font-size: 18px;
  font-weight: 600;
  color: #f2e8dc;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.2;
}
.customer-profile-handle {
  font-size: 12px;
  color: #9d9287;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 16px;
}
.customer-profile-handle a {
  color: #c6a36a;
  text-decoration: none;
}
.customer-profile-handle a:hover { text-decoration: underline; }
.customer-profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}
.customer-profile-stats .stat {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.customer-profile-stats .stat-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9d9287;
  font-weight: 600;
}
.customer-profile-stats .stat-value {
  font-family: var(--font-mono, monospace);
  font-size: 14px;
  color: #f2e8dc;
  font-weight: 600;
}
.customer-profile-section {
  width: 100%;
  margin-bottom: 20px;
}
.customer-profile-section-title {
  font-family: var(--font-display, serif);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #c6a36a;
  margin-bottom: 10px;
}

/* Tag-Picker (in Profile) */
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-chip {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  color: #d2c7ba;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.12s;
}
.tag-chip:hover { border-color: rgba(198,163,106,0.30); color: #c6a36a; }
.tag-chip.active {
  background: rgba(198,163,106,0.12);
  border-color: rgba(198,163,106,0.40);
  color: #c6a36a;
}

/* Staff-Note Textarea */
.staff-note {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.10);
  color: #f2e8dc;
  font-family: var(--font-ui, system-ui);
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  resize: vertical;
  min-height: 100px;
  outline: none;
}
.staff-note:focus { border-color: #c6a36a; }
.customer-profile-section .btn-primary {
  margin-top: 8px;
  padding: 6px 14px;
  font-size: 12px;
}

/* 8) Day-Stats-Banner */
.day-stats-banner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(198,163,106,0.08), rgba(198,163,106,0.02));
  border-bottom: 1px solid rgba(198,163,106,0.16);
  font-size: 11.5px;
  color: #d2c7ba;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.04em;
  flex-wrap: wrap;
}
.day-stats-banner strong {
  color: #c6a36a;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10.5px;
}
.day-stats-banner .stat-ki { color: #c6a36a; font-weight: 600; }
.day-stats-banner .stat-wait { color: #d96459; font-weight: 600; }

/* 9) Hot-Key hint im Search-Input area */
.search-wrap { position: relative; }
.search-wrap::after {
  content: '⌘K';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: #7a7670;
  padding: 2px 5px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  pointer-events: none;
}

/* Mobile: Profile vollbild */
@media (max-width: 900px) {
  .app.has-details {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr;
  }
  .customer-profile {
    position: fixed;
    inset: 0;
    z-index: 100;
  }
}



