* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f7f5f3;
  color: #111b21;
}

.hidden {
  display: none !important;
}

.mobile-only-icon,
.mobile-only-inline,
.mobile-only-flex {
  display: none;
}

.wc-shell {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* =========================================
   DESKTOP BEHAVIOR (> 768px)
   ========================================= */
.wc-rail {
  width: 64px;
  background: #f0f2f5;
  border-right: 1px solid #e9edef;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  flex-shrink: 0;
}

.rail-top,
.rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.rail-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #54656f;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
}

.rail-btn:hover {
  background: #e4e7eb;
}

.rail-btn.active {
  background: #e2e5e9;
  color: #111b21;
  font-weight: 700;
}

.rail-btn.has-dot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1fa855;
  position: absolute;
  top: 7px;
  right: 8px;
}

.ai-btn {
  color: #2563eb;
}

.rail-divider {
  width: 28px;
  border: none;
  border-top: 1px solid #d9dee3;
  margin: 4px 0;
}

.rail-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #008069;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.wc-sidebar {
  width: 400px;
  max-width: 100%;
  background: #ffffff;
  border-right: 1px solid #e9edef;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sidebar-top {
  padding: 14px 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1daa61;
  letter-spacing: -0.02em;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #1daa61;
  color: #ffffff;
  font-size: 1.25rem;
  line-height: 1;
  display: grid;
  place-items: center;
  text-decoration: none;
  cursor: pointer;
}

.icon-circle-btn.muted-btn {
  background: transparent;
  color: #54656f;
  font-size: 1.15rem;
}

.icon-circle-btn.muted-btn:hover {
  background: #f0f2f5;
}

.search-box-wrap {
  padding: 6px 16px 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0f2f5;
  border-radius: 20px;
  padding: 8px 14px;
}

.search-icon {
  font-size: 0.85rem;
  color: #667781;
}

.search-box input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  color: #111b21;
}

.search-box input:focus {
  outline: none;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 16px 10px;
  overflow-x: auto;
}

.pill {
  border: 1px solid #e9edef;
  background: #ffffff;
  color: #54656f;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.pill.active {
  background: #d9fdd3;
  border-color: #d9fdd3;
  color: #0b532c;
  font-weight: 600;
}

.pill-add {
  padding: 6px 10px;
}

.chat-scroll-list {
  flex: 1;
  overflow-y: auto;
}

.empty-db-note {
  padding: 16px;
  margin: 12px;
  background: #f8f9fa;
  border: 1px dashed #d1d7db;
  border-radius: 10px;
  font-size: 0.82rem;
  color: #54656f;
  line-height: 1.45;
}

.archived-row {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
  color: #54656f;
  font-size: 0.9rem;
}

.archived-row:hover {
  background: #f5f6f6;
}

.archived-label {
  flex: 1;
  text-align: left;
  color: #111b21;
  font-weight: 500;
}

.archived-count {
  font-size: 0.8rem;
  color: #1daa61;
  font-weight: 600;
}

.chat-row {
  width: 100%;
  border: none;
  background: transparent;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.chat-row:hover,
.chat-row.active {
  background: #f0f2f5;
}

.row-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #008069;
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.row-avatar.sm-avatar {
  width: 38px;
  height: 38px;
  font-size: 0.9rem;
}

.row-avatar.avatar-dark {
  background: #1d3557;
}

.row-avatar.avatar-green {
  background: #1daa61;
}

.row-avatar.avatar-warm {
  background: #b45309;
}

.row-avatar.avatar-teal {
  background: #0f766e;
}

.row-body {
  flex: 1;
  min-width: 0;
  border-bottom: 1px solid #f0f2f5;
  padding-bottom: 11px;
}

.row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.row-name {
  font-size: 0.96rem;
  font-weight: 500;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-time {
  font-size: 0.75rem;
  color: #667781;
  flex-shrink: 0;
}

.row-time.time-unread {
  color: #1daa61;
  font-weight: 600;
}

.row-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.row-preview {
  font-size: 0.84rem;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #1daa61;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.wc-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #f7f5f3;
  display: flex;
  flex-direction: column;
}

.welcome-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 28px;
}

.feature-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(17, 27, 33, 0.04);
}

.feature-illustration {
  width: 160px;
  height: 112px;
  margin: 0 auto 20px;
  border: 2px solid #111b21;
  border-radius: 14px;
  background: #ffffff;
  padding: 8px;
  display: flex;
}

.ill-window {
  flex: 1;
  display: flex;
  gap: 6px;
}

.ill-sidebar {
  width: 34%;
  background: #d9fdd3;
  border-radius: 6px;
}

.ill-content {
  flex: 1;
  background: #f7f5f3;
  border-radius: 6px;
  display: grid;
  place-items: center;
}

.ill-phone-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1daa61;
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}

.feature-card h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #111b21;
  margin-bottom: 10px;
}

.feature-card p {
  font-size: 0.9rem;
  color: #667781;
  line-height: 1.45;
  margin-bottom: 20px;
}

.cta-pill-btn {
  border: none;
  background: #d9fdd3;
  color: #0b532c;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
}

.cta-pill-btn:hover {
  background: #c7f7c0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

.quick-action-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #3b4a54;
  font-size: 0.8rem;
}

.quick-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #eceae6;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.quick-icon.ai-ring {
  color: #2563eb;
}

.thread-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #efeae2;
}

.thread-header {
  height: 60px;
  padding: 0 16px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e9edef;
  flex-shrink: 0;
}

.back-btn {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: #54656f;
  padding: 4px 6px;
}

.thread-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.thread-status {
  font-size: 0.78rem;
  color: #667781;
}

.message-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message {
  display: flex;
}

.message.incoming {
  justify-content: flex-start;
}

.message.outgoing {
  justify-content: flex-end;
}

.bubble {
  max-width: min(75%, 520px);
  padding: 8px 12px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  word-wrap: break-word;
}

.message.outgoing .bubble {
  background: #d9fdd3;
}

.bubble-img {
  display: block;
  max-width: 260px;
  max-height: 260px;
  border-radius: 6px;
  margin-bottom: 6px;
  object-fit: cover;
}

.bubble-video {
  display: block;
  max-width: 280px;
  max-height: 220px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.bubble-audio {
  display: block;
  max-width: 260px;
  margin-bottom: 6px;
}

.bubble-doc {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
  color: #111b21;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.msg-time {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: #667781;
  text-align: right;
}

.selected-file-bar {
  padding: 8px 14px;
  background: #e9edef;
  border-top: 1px solid #d1d7db;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.84rem;
  color: #111b21;
  flex-shrink: 0;
}

.clear-file-btn {
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  color: #54656f;
}

.composer {
  padding: 10px 12px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.attach-btn {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  padding: 4px 6px;
  cursor: pointer;
  color: #54656f;
}

.composer-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: none;
  border-radius: 20px;
  background: #ffffff;
  font-size: 0.95rem;
}

.send-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 20px;
  background: #1daa61;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

/* =========================================
   MOBILE BEHAVIOR (<= 768px)
   ========================================= */
@media (max-width: 768px) {
  .wc-rail,
  .desktop-only-icon,
  .desktop-only-row,
  .welcome-view {
    display: none !important;
  }

  .mobile-only-icon {
    display: grid;
  }

  .mobile-only-inline {
    display: inline-block;
  }

  .mobile-only-flex {
    display: flex;
  }

  .wc-sidebar {
    width: 100%;
    max-width: 100%;
    border-right: none;
    background: #ffffff;
  }

  .wc-shell.mobile-thread-open .wc-sidebar {
    display: none;
  }

  .wc-main {
    display: none;
    width: 100%;
  }

  .wc-shell.mobile-thread-open .wc-main {
    display: flex;
  }

  .sidebar-top {
    padding: 14px 16px 6px;
  }

  .brand-title {
    font-size: 1.55rem;
    color: #111b21;
    font-weight: 700;
  }

  .icon-circle-btn.mobile-only-icon,
  .icon-circle-btn.muted-btn {
    background: transparent;
    color: #111b21;
    font-size: 1.2rem;
  }

  .search-box {
    background: #f0f2f5;
    border-radius: 24px;
    padding: 10px 16px;
  }

  .chat-scroll-list {
    padding-bottom: 130px;
  }

  .pin-badge {
    font-size: 0.78rem;
    color: #667781;
  }

  .mobile-fab-stack {
    position: fixed;
    right: 16px;
    bottom: 84px;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 20;
  }

  .wc-shell.mobile-thread-open .mobile-fab-stack,
  .wc-shell.mobile-thread-open .mobile-bottom-nav {
    display: none;
  }

  .fab-ai {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid #eceae6;
    background: #ffffff;
    color: #2563eb;
    font-size: 1.15rem;
    box-shadow: 0 3px 10px rgba(17, 27, 33, 0.12);
    cursor: pointer;
  }

  .fab-compose {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: none;
    background: #1daa61;
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(17, 27, 33, 0.18);
    cursor: pointer;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #e9edef;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
    z-index: 25;
  }

  .m-nav-item {
    flex: 1;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #111b21;
    cursor: pointer;
  }

  .m-nav-icon {
    width: 54px;
    height: 30px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    position: relative;
  }

  .m-nav-item.active .m-nav-icon {
    background: #d9fdd3;
    color: #0b532c;
  }

  .m-nav-badge {
    position: absolute;
    top: -4px;
    right: 4px;
    background: #1daa61;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
  }

  .has-m-dot::after {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #1daa61;
    position: absolute;
    top: 3px;
    right: 12px;
  }

  .m-nav-label {
    font-size: 0.75rem;
    font-weight: 600;
  }

  .composer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}