:root {
  --bg: #efe7dc;
  --panel: rgba(255, 252, 246, 0.96);
  --line: #dfd1bc;
  --ink: #1f2937;
  --muted: #667085;
  --brand: #0f6c5b;
  --brand-dark: #0b4f43;
  --accent: #cc8b3d;
  --danger: #b42318;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15,108,91,0.15), transparent 24%),
    linear-gradient(135deg, #f7f1e8 0%, #efe6d9 40%, #f4ede3 100%);
  font-family: "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
code { font-family: Consolas, monospace; background: #f5ecde; padding: 2px 7px; border-radius: 8px; }
textarea, input, select {
  width: 100%;
  border: 1px solid #d4c5af;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fffdfa;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 88px; resize: vertical; }
button { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  padding: 26px 20px;
  border-right: 1px solid rgba(255,255,255,0.3);
  background: linear-gradient(180deg, rgba(11,79,67,0.94) 0%, rgba(8,55,47,0.98) 100%);
  color: #effbf7;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}

.brand-block p { margin: 4px 0 0; color: rgba(239,251,247,0.72); font-size: 0.9rem; }
.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #f0d7b7 0%, #cc8b3d 100%);
  color: #17302b;
  font-weight: 800;
}

.nav-stack {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.nav-stack a {
  padding: 12px 14px;
  border-radius: 14px;
  color: rgba(239,251,247,0.9);
}

.nav-stack a:hover {
  background: rgba(255,255,255,0.08);
}

.main-panel {
  padding: 28px;
}

.hero-panel, .surface-card, .flash-banner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 18px 40px rgba(62,42,21,0.08);
}

.hero-panel {
  padding: 26px 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.hero-panel.slim { align-items: flex-start; }
.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--brand);
}
.hero-panel h1 { margin: 0 0 8px; font-size: clamp(2rem, 4vw, 3rem); font-family: Georgia, serif; }
.lead-copy { margin: 0; max-width: 760px; color: var(--muted); line-height: 1.65; }
.status-chip-group { display: flex; flex-wrap: wrap; gap: 10px; }
.status-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: #f5ecde;
  color: var(--brand-dark);
  font-weight: 600;
}

.flash-banner {
  padding: 16px 18px;
  margin-bottom: 20px;
  color: var(--brand-dark);
}

.card-grid { display: grid; gap: 20px; margin-bottom: 20px; }
.card-grid.two-up { grid-template-columns: repeat(2, minmax(0,1fr)); }
.surface-card { padding: 22px; margin-bottom: 20px; }
.surface-card h2 { margin: 0 0 14px; font-family: Georgia, serif; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-kicker { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.78rem; color: var(--accent); }
.detail-grid { margin: 0; }
.detail-grid div { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-grid div:last-child { border-bottom: 0; }
.detail-grid dt { font-weight: 700; }
.detail-grid dd { margin: 0; color: var(--muted); word-break: break-word; }
.button-stack { display: grid; gap: 12px; }
.primary-btn, .secondary-btn, .ghost-btn, .ghost-link, .row-delete {
  border-radius: 999px;
  padding: 12px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
}
.primary-btn { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); color: #fff; }
.secondary-btn { background: #f0d7b7; color: #3c2d14; }
.ghost-btn, .ghost-link { background: transparent; border: 1px solid #cfbea5; color: var(--brand-dark); }
.row-delete { background: transparent; border: 1px solid #e0b4ae; color: var(--danger); }
.test-form { display: grid; gap: 14px; }
.field-label { font-weight: 700; }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.check-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffdfa;
}
.check-card input { width: auto; }
.check-title { font-weight: 700; }
.check-meta, .muted-inline { color: var(--muted); font-size: 0.88rem; }
.parser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.parser-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: #fffdfa;
  border: 1px solid var(--line);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--brand-dark); white-space: nowrap; }
.workspace-table-wrap { max-height: 68vh; }
.editable-table input, .editable-table select, .editable-table textarea { min-width: 150px; }
.editable-table textarea { min-height: 72px; }
.toolbar-inline { display: flex; gap: 10px; }
.save-bar { margin-top: 16px; display: flex; justify-content: flex-end; }
.compact-card { margin-bottom: 0; }
.mode-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.mode-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: #f8f1e6;
  border: 1px solid var(--line);
  color: var(--brand-dark);
  font-weight: 600;
}
.mode-section {
  overflow: hidden;
}
.mode-section-head {
  align-items: center;
}
.mode-count {
  padding: 10px 14px;
  border-radius: 999px;
  background: #f6efe4;
  color: var(--brand-dark);
  font-weight: 700;
}
.align-center {
  align-items: center;
}
.stack-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.stack-field:last-child {
  margin-bottom: 0;
}
.stack-field label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.sticky-save-bar {
  position: sticky;
  bottom: 14px;
  z-index: 5;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.14); }
}

@media (max-width: 860px) {
  .main-panel { padding: 18px; }
  .hero-panel { flex-direction: column; align-items: flex-start; }
  .card-grid.two-up { grid-template-columns: 1fr; }
  .detail-grid div { grid-template-columns: 1fr; }
  th, td { min-width: 220px; }
}
.inline-grid {
  display: grid;
  gap: 14px;
}
.inline-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.quick-send-form {
  height: 100%;
}

@media (max-width: 860px) {
  .inline-grid.two-col {
    grid-template-columns: 1fr;
  }
}
.template-preview-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: #fffdfa;
  border: 1px solid var(--line);
}
.template-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.template-body-preview {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
}

.whatsapp-hero .status-chip {
  max-width: 100%;
}

.whatsapp-shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.whatsapp-list-panel,
.whatsapp-thread-panel,
.webhook-copy-card {
  background: rgba(255, 252, 246, 0.98);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 18px 40px rgba(62,42,21,0.08);
}

.whatsapp-list-panel {
  overflow: hidden;
}

.whatsapp-list-head,
.thread-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.whatsapp-list-head h2,
.thread-header h2 {
  margin: 0;
}

.whatsapp-chat-list {
  max-height: 72vh;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.chat-list-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
  background: #fffdfa;
  border: 1px solid transparent;
}

.chat-list-item:hover,
.chat-list-item.active {
  border-color: #c9e1d9;
  background: #f4fbf8;
}

.chat-avatar {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #d5f2e6 0%, #9fd5c2 100%);
  color: #11473d;
  font-weight: 800;
  font-size: 1.1rem;
}

.chat-list-copy {
  min-width: 0;
}

.chat-list-copy strong,
.chat-list-copy span,
.chat-list-copy p,
.thread-subtitle {
  display: block;
}

.chat-list-copy span,
.thread-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-list-copy p {
  margin: 6px 0 0;
  color: #344054;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-meta {
  display: grid;
  gap: 10px;
  justify-items: end;
  font-size: 0.8rem;
  color: var(--muted);
}

.chat-unread {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #25d366;
  color: #fff;
  font-weight: 700;
}

.whatsapp-thread-panel {
  overflow: hidden;
}

.thread-body {
  min-height: 58vh;
  max-height: 58vh;
  overflow-y: auto;
  padding: 22px;
  display: grid;
  gap: 14px;
  background:
    radial-gradient(circle at top left, rgba(37,211,102,0.08), transparent 25%),
    linear-gradient(180deg, #efe8dd 0%, #f7f3eb 100%);
}

.chat-bubble {
  max-width: min(72%, 680px);
  padding: 14px 16px;
  border-radius: 20px;
  display: grid;
  gap: 8px;
  box-shadow: 0 10px 20px rgba(30,41,59,0.08);
}

.bubble-in {
  justify-self: start;
  background: #ffffff;
  border-top-left-radius: 8px;
}

.bubble-out {
  justify-self: end;
  background: #dcf8c6;
  border-top-right-radius: 8px;
}

.bubble-system {
  justify-self: center;
  background: #f5ecde;
  border-radius: 999px;
  max-width: 88%;
}

.bubble-meta-row,
.bubble-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.bubble-author {
  font-weight: 700;
  color: #2d3b36;
}

.bubble-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.chat-image {
  max-width: 100%;
  border-radius: 16px;
  display: block;
}

.media-link {
  color: var(--brand-dark);
  font-weight: 700;
}

.type-badge,
.status-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
}

.status-read {
  color: #1d70b8;
}

.status-delivered,
.status-sent {
  color: #18794e;
}

.thread-composer {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 14px;
  border-top: 1px solid var(--line);
  background: #fffdfa;
}

.compact-field {
  margin-bottom: 0;
}

.composer-grow textarea {
  min-height: 72px;
}

.empty-chat-note,
.empty-thread-note {
  padding: 24px;
  border: 1px dashed #d6c3ab;
  border-radius: 18px;
  background: rgba(255,255,255,0.7);
  color: var(--muted);
}

@media (max-width: 1100px) {
  .whatsapp-shell {
    grid-template-columns: 1fr;
  }

  .thread-composer {
    grid-template-columns: 1fr;
  }

  .thread-body {
    min-height: 44vh;
    max-height: none;
  }
}

.thread-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.thread-avatar {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #d5f2e6 0%, #8fd0ba 100%);
  color: #11473d;
  font-weight: 800;
}

.thread-header-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.thread-live-indicator {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(37, 211, 102, 0.16);
  color: #117a43;
  font-weight: 700;
}

.chat-image-link {
  display: block;
}

.chat-image {
  background: #f3f3f3;
}

.bubble-foot {
  margin-top: 2px;
}

.bubble-system .bubble-foot {
  justify-content: center;
}

.webhook-copy-card input[readonly] {
  font-weight: 600;
}

@media (max-width: 860px) {
  .thread-title-wrap {
    align-items: flex-start;
  }

  .thread-header-tools {
    width: 100%;
    justify-content: space-between;
  }
}

/* ==============================================
   WhatsApp Inbox – Modern Messaging App UI
   ============================================== */

.wa-app {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 56px);
  border-radius: 6px;
  overflow: hidden;
  background: #efeae2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* --- Sidebar --- */

.wa-sidebar {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #d1d7db;
}

.wa-sidebar-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #f0f2f5;
  min-height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid #d1d7db;
}

.wa-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #00a884 0%, #075e54 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.wa-avatar-brand {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  font-size: 0.75rem;
  font-weight: 800;
}

.wa-hdr-title {
  font-weight: 700;
  font-size: 1rem;
  color: #111b21;
  flex: 1;
}

.wa-chip {
  background: #25d366;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.wa-icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: #54656f;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.wa-icon-btn:hover {
  background: #e9edef;
}

/* New chat panel */

.wa-new-chat {
  padding: 8px 12px;
  background: #f0f2f5;
  border-bottom: 1px solid #d1d7db;
  display: flex;
  gap: 8px;
  align-items: center;
}

.wa-btn-sm {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: #075e54;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.wa-btn-sm:hover {
  background: #064e46;
}

/* Search */

.wa-search-wrap {
  padding: 7px 12px;
  background: #f0f2f5;
  border-bottom: 1px solid #e9edef;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
}

.wa-search-icon {
  position: absolute;
  left: 24px;
  pointer-events: none;
}

.wa-search-field {
  padding-left: 36px !important;
}

.wa-input {
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: #111b21;
  font-size: 0.87rem;
  outline: none;
  font-family: inherit;
}

.wa-input::placeholder {
  color: #8696a0;
}

.wa-input:focus {
  box-shadow: 0 0 0 2px rgba(0, 128, 105, 0.2);
}

/* Contact / conversation list */

.wa-contact-list {
  flex: 1;
  overflow-y: auto;
}

.wa-contact-list::-webkit-scrollbar {
  width: 6px;
}

.wa-contact-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

.wa-contact {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 10px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.12s;
  cursor: pointer;
}

.wa-contact:hover {
  background: #f5f6f6;
}

.wa-contact.active {
  background: #f0f2f5;
}

.wa-contact-body {
  flex: 1;
  min-width: 0;
}

.wa-contact-row1 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.wa-contact-name {
  font-weight: 600;
  font-size: 0.93rem;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-contact-row1 time {
  font-size: 0.72rem;
  color: #667781;
  flex-shrink: 0;
}

.wa-contact-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.wa-contact-preview {
  flex: 1;
  font-size: 0.83rem;
  color: #667781;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-badge {
  background: #25d366;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-empty-list {
  padding: 48px 24px;
  text-align: center;
  color: #667781;
}

.wa-empty-list .wa-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.wa-empty-list p {
  font-weight: 600;
  margin: 0 0 6px;
  color: #111b21;
  font-size: 0.95rem;
}

.wa-empty-list span {
  font-size: 0.83rem;
  line-height: 1.5;
}

/* --- Chat panel --- */

.wa-chat {
  display: flex;
  flex-direction: column;
  background: #efeae2;
  position: relative;
  min-width: 0;
}

/* Intro / empty state */

.wa-intro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  background: #f0f2f5;
  color: #667781;
}

.wa-intro-graphic {
  margin-bottom: 24px;
  opacity: 0.85;
}

.wa-intro h2 {
  color: #41525d;
  font-weight: 300;
  font-size: 1.8rem;
  margin: 0 0 12px;
  font-family: inherit;
}

.wa-intro p {
  margin: 0 0 6px;
  max-width: 480px;
  line-height: 1.55;
  font-size: 0.9rem;
}

.wa-intro-hint {
  margin-top: 16px;
  font-size: 0.82rem;
  color: #8696a0;
}

.wa-webhook-detail {
  margin-top: 28px;
  background: #fff;
  border: 1px solid #e9edef;
  border-radius: 8px;
  text-align: left;
  max-width: 520px;
  width: 100%;
}

.wa-webhook-detail summary {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #667781;
  cursor: pointer;
}

.wa-webhook-grid {
  padding: 12px 16px;
  display: grid;
  gap: 10px;
  border-top: 1px solid #e9edef;
  font-size: 0.83rem;
}

.wa-webhook-grid code {
  display: block;
  margin-top: 4px;
  padding: 6px 10px;
  background: #f0f2f5;
  border-radius: 6px;
  font-size: 0.82rem;
  word-break: break-all;
}

/* Chat header */

.wa-chat-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid #d1d7db;
  min-height: 56px;
  flex-shrink: 0;
}

.wa-back-link {
  display: none;
  color: #54656f;
  text-decoration: none;
  flex-shrink: 0;
}

.wa-chat-hdr-info {
  flex: 1;
  min-width: 0;
}

.wa-chat-hdr-info strong {
  display: block;
  font-size: 0.97rem;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-chat-hdr-info span {
  display: block;
  font-size: 0.78rem;
  color: #667781;
}

.wa-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #25d366;
  flex-shrink: 0;
  animation: wa-pulse 2s infinite;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.25);
}

@keyframes wa-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Thread / messages area */

.wa-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cg fill='%23cbc1b4' fill-opacity='0.12'%3E%3Ccircle cx='50' cy='50' r='2'/%3E%3Ccircle cx='150' cy='80' r='1.5'/%3E%3Ccircle cx='250' cy='30' r='2'/%3E%3Ccircle cx='80' cy='180' r='1.5'/%3E%3Ccircle cx='200' cy='200' r='2'/%3E%3Ccircle cx='120' cy='260' r='1.5'/%3E%3Ccircle cx='270' cy='150' r='2'/%3E%3Ccircle cx='30' cy='280' r='1.5'/%3E%3C/g%3E%3C/svg%3E"),
    #efeae2;
}

.wa-thread::-webkit-scrollbar {
  width: 6px;
}

.wa-thread::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 3px;
}

.wa-thread-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-thread-empty span {
  background: rgba(255, 255, 214, 0.92);
  color: #54656f;
  font-size: 0.83rem;
  padding: 8px 16px;
  border-radius: 7.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  text-align: center;
  max-width: 400px;
}

/* Date separator */

.wa-date-sep {
  display: flex;
  justify-content: center;
  padding: 12px 0 8px;
}

.wa-date-sep span {
  background: rgba(255, 255, 255, 0.92);
  color: #54656f;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

/* Message bubbles */

.wa-msg {
  max-width: 65%;
  padding: 6px 7px 8px 9px;
  border-radius: 7.5px;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  word-wrap: break-word;
  margin-bottom: 2px;
  line-height: 1.35;
}

.wa-msg-in {
  align-self: flex-start;
  background: #fff;
  border-top-left-radius: 0;
}

.wa-msg-out {
  align-self: flex-end;
  background: #d9fdd3;
  border-top-right-radius: 0;
}

.wa-msg::before {
  content: '';
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
}

.wa-msg-in::before {
  left: -8px;
  background:
    linear-gradient(225deg, #fff 0%, #fff 50%, transparent 50%);
}

.wa-msg-out::before {
  right: -8px;
  background:
    linear-gradient(135deg, #d9fdd3 0%, #d9fdd3 50%, transparent 50%);
}

.wa-msg-author {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #075e54;
  margin-bottom: 1px;
}

.wa-msg-text {
  display: inline;
  font-size: 0.9rem;
  color: #111b21;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-msg-footer {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 4px 0 -4px 12px;
  position: relative;
  top: 4px;
}

.wa-msg-footer time {
  font-size: 0.68rem;
  color: #667781;
}

.wa-tick {
  font-size: 0.78rem;
  color: #8696a0;
  margin-left: 1px;
}

.wa-tick-read {
  color: #53bdeb;
}

/* System message */

.wa-sys {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.wa-sys span {
  background: rgba(255, 255, 214, 0.92);
  color: #54656f;
  font-size: 0.76rem;
  padding: 5px 12px;
  border-radius: 7.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  max-width: 80%;
  text-align: center;
}

/* Media in messages */

.wa-msg-img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 6px;
  display: block;
  margin-bottom: 4px;
  background: #f0f2f5;
}

.wa-msg-img-link {
  display: block;
}

.wa-msg-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  margin-bottom: 4px;
}

.wa-doc-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.wa-msg-doc a {
  color: #027eb5;
  font-size: 0.83rem;
  text-decoration: underline;
  word-break: break-all;
}

/* Scroll-to-bottom FAB */

.wa-scroll-fab {
  position: absolute;
  bottom: 72px;
  right: 20px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #54656f;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.wa-scroll-fab:hover {
  background: #f0f2f5;
}

/* Composer */

.wa-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 10px;
  background: #f0f2f5;
  flex-shrink: 0;
  border-top: 1px solid #d1d7db;
}

.wa-composer-wrap {
  flex: 1;
  background: #fff;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  min-height: 42px;
}

.wa-composer-wrap textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: #111b21;
  resize: none;
  outline: none;
  max-height: 150px;
  min-height: 20px;
  font-family: inherit;
  width: 100%;
}

.wa-composer-wrap textarea::placeholder {
  color: #8696a0;
}

.wa-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: #00a884;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.wa-send-btn:hover {
  background: #008f72;
}

.wa-send-btn svg {
  pointer-events: none;
}

/* Toast */

.wa-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #323739;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.88rem;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  animation: wa-toast-in 0.3s ease;
}

@keyframes wa-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */

@media (max-width: 900px) {
  .wa-app {
    grid-template-columns: 1fr;
  }

  .wa-app:not(.wa-show-list) .wa-sidebar {
    display: none;
  }

  .wa-app.wa-show-list .wa-chat {
    display: none;
  }

  .wa-back-link {
    display: flex !important;
  }

  .wa-thread {
    padding: 12px 16px;
  }

  .wa-msg {
    max-width: 85%;
  }
}

@media (max-width: 1100px) {
  .wa-app {
    grid-template-columns: 300px 1fr;
  }

  .wa-thread {
    padding: 16px 24px;
  }
}
