.nav-button[data-view="chat"] {
  position: relative;
}

.chat-nav-badge {
  position: absolute;
  top: 3px;
  right: 5px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

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

#chat-view {
  height: calc(100dvh - 24px);
  min-height: 0;
  overflow: hidden;
}

.chat-shell {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

    .chat-room-panel,
    .chat-conversation-panel {
      min-width: 0;
      min-height: 0;
    }

    .chat-room-panel {
      display: flex;
      flex-direction: column;
      border-right: 1px solid #e4e7ec;
      background: #f8fafc;
    }

    .chat-panel-head,
    .chat-conversation-head {
      flex-shrink: 0;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      padding: 18px;
      border-bottom: 1px solid #e4e7ec;
      background: #ffffff;
    }

    .chat-panel-head h2,
    .chat-conversation-head h2 {
      margin: 0;
      color: #101828;
      font-size: 22px;
      line-height: 1.2;
    }

    .chat-panel-head .result-status {
      margin: 6px 0 0;
      padding: 0;
      background: transparent;
      border: 0;
      font-size: 12px;
    }

    .chat-room-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 12px;
      overflow: auto;
      min-height: 0;
      overscroll-behavior: contain;
    }

    .chat-room-item {
      display: flex;
      flex-direction: column;
      gap: 8px;
      width: 100%;
      padding: 12px;
      border: 1px solid #e4e7ec;
      border-radius: 8px;
      background: #ffffff;
      color: #101828;
      text-align: left;
      cursor: pointer;
    }

    .chat-room-item:hover,
    .chat-room-item.active {
      border-color: #2e90fa;
      box-shadow: 0 8px 24px rgba(46, 144, 250, 0.12);
    }

    .chat-room-item.active {
      background: #eff8ff;
    }

    .chat-room-top,
    .chat-room-bottom {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      min-width: 0;
    }

    .chat-room-top strong,
    .chat-room-bottom span:first-child {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .chat-room-top strong {
      font-size: 14px;
      font-weight: 900;
    }

    .chat-room-top span,
    .chat-room-bottom {
      color: #667085;
      font-size: 12px;
      font-weight: 700;
    }

    .chat-unread-badge {
      min-width: 24px;
      padding: 4px 7px;
      border-radius: 999px;
      background: #f04438;
      color: #ffffff;
      font-size: 11px;
      line-height: 1;
      text-align: center;
    }

    .chat-conversation-panel {
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
      background: #f5f7fa;
    }

    .chat-conversation-head p {
      margin: 6px 0 0;
      color: #667085;
      font-size: 12px;
      font-weight: 800;
    }

    .chat-message-list {
      display: flex;
      flex-direction: column;
      gap: 12px;
      min-height: 0;
      padding: 18px;
      overflow: auto;
      overscroll-behavior: contain;
    }

    .chat-message {
      display: flex;
      flex-shrink: 0;
      justify-content: flex-start;
    }

    .chat-message.own {
      justify-content: flex-end;
    }

    .chat-message.system {
      justify-content: center;
    }

    .chat-bubble {
      width: min(620px, 82%);
      padding: 12px 14px;
      border: 1px solid #e4e7ec;
      border-radius: 8px;
      background: #ffffff;
      box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
    }

    .chat-message.own .chat-bubble {
      border-color: #1570ef;
      background: #175cd3;
      color: #ffffff;
    }

    .chat-message-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 6px;
      font-size: 12px;
      font-weight: 900;
    }

    .chat-message-head span {
      color: #98a2b3;
      font-weight: 800;
      white-space: nowrap;
    }

    .chat-message.own .chat-message-head span {
      color: rgba(255, 255, 255, 0.75);
    }

    .chat-bubble p {
      margin: 0;
      overflow-wrap: anywhere;
      white-space: pre-wrap;
    }

    .chat-photo-frame {
      position: relative;
      overflow: hidden;
      width: min(360px, 100%);
      aspect-ratio: 4 / 3;
      margin-top: 8px;
      border-radius: 8px;
      background: #101828;
    }

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

    .chat-photo-stamp {
      position: absolute;
      left: 8px;
      right: 8px;
      bottom: 8px;
      padding: 6px 8px;
      border-radius: 999px;
      background: rgba(16, 24, 40, 0.74);
      color: #ffffff;
      font-size: 11px;
      font-weight: 900;
      text-align: center;
    }

    .chat-photo-frame + p {
      margin-top: 8px;
    }

    .chat-system-pill {
      max-width: min(680px, 92%);
      padding: 8px 12px;
      border-radius: 999px;
      background: #ecfdf3;
      color: #027a48;
      font-size: 12px;
      font-weight: 900;
      text-align: center;
    }

    .chat-call-card {
      width: min(680px, 92vw);
      padding: 14px;
      border: 1px solid #fdb022;
      border-radius: 8px;
      background: #fffcf5;
      box-shadow: 0 12px 28px rgba(181, 71, 8, 0.12);
    }

    .chat-call-card-top,
    .chat-call-card-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .chat-call-card-top strong {
      min-width: 0;
      overflow-wrap: anywhere;
      color: #101828;
      font-size: 16px;
      font-weight: 900;
    }

    .chat-call-card-meta {
      margin-top: 8px;
      color: #b54708;
      font-size: 12px;
      font-weight: 900;
    }

    .chat-call-card-address {
      margin: 10px 0 0;
      color: #344054;
      font-weight: 900;
      overflow-wrap: anywhere;
    }

    .chat-call-card-description {
      margin: 8px 0 0;
      color: #475467;
      line-height: 1.45;
      overflow-wrap: anywhere;
    }

    .chat-call-card-footer {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid #fedf89;
      color: #667085;
      font-size: 12px;
      font-weight: 800;
    }

    .chat-call-open {
      min-height: 34px;
      padding: 0 12px;
      border: 1px solid #d0d5dd;
      border-radius: 8px;
      background: #ffffff;
      color: #175cd3;
      font-size: 12px;
      font-weight: 900;
      cursor: pointer;
    }

    .chat-composer {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      padding: 14px;
      border-top: 1px solid #e4e7ec;
      background: #ffffff;
    }

    .chat-composer input {
      min-width: 0;
      min-height: 44px;
      border: 1px solid #d0d5dd;
      border-radius: 8px;
      padding: 0 14px;
      font-size: 14px;
      font-weight: 700;
    }

    .chat-empty {
      margin: 0;
      padding: 18px;
      border: 1px dashed #d0d5dd;
      border-radius: 8px;
      color: #667085;
      background: #ffffff;
      text-align: center;
      font-weight: 800;
    }

    .chat-empty-messages {
      margin: auto;
      width: min(360px, 100%);
    }

    .chat-filter-controls {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px;
      border-bottom: 1px solid #e4e7ec;
      background: #ffffff;
    }

    .chat-filter-label {
      font-size: 12px;
      font-weight: 600;
      color: #667085;
      white-space: nowrap;
    }

    .chat-filter-select {
      flex: 1;
      padding: 6px 8px;
      border: 1px solid #d0d5dd;
      border-radius: 4px;
      font-size: 12px;
      background: #ffffff;
      color: #101828;
      cursor: pointer;
    }

    .chat-filter-select:hover,
    .chat-filter-select:focus {
      border-color: #2e90fa;
      outline: none;
      box-shadow: 0 0 0 3px rgba(46, 144, 250, 0.12);
    }

    @media (max-width: 1024px) {
      #chat-view {
        height: calc(100dvh - 150px);
      }
    }

    @media (max-width: 900px) {
      .chat-shell {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 30%) minmax(0, 1fr);
      }

      .chat-room-panel {
        max-height: 280px;
        border-right: 0;
        border-bottom: 1px solid #e4e7ec;
      }

      .chat-call-card-footer,
      .chat-call-card-top {
        align-items: flex-start;
        flex-direction: column;
      }

      .chat-bubble,
      .chat-call-card {
        width: 100%;
      }
    }
