#messages-view {
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
}

/* Match list */
#match-list-header {
  padding: 1.25rem 1rem 0.5rem;
  border-bottom: 3px solid var(--coral);
}

#match-list-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

#match-list {
  list-style: none;
}

.match-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.match-item:hover {
  background: rgba(208, 0, 0, 0.04);
}

.match-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  overflow: hidden;
}

.match-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.match-info {
  flex: 1;
  min-width: 0;
}

.match-name {
  font-weight: 600;
  font-size: 1rem;
}

.match-preview {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}

.match-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.match-empty h2 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-weight: 700;
}

/* Chat view */
#chat-view {
  display: none;
  flex-direction: column;
  height: calc(100vh - var(--nav-height));
  max-width: 480px;
  margin: 0 auto;
}

#chat-view.visible {
  display: flex;
}

#chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 3px solid var(--coral);
  background: var(--surface);
  flex-shrink: 0;
}

#chat-back-btn {
  background: none;
  border: none;
  color: var(--coral);
  padding: 0.4rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
}

#chat-back-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#chat-other-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  overflow: hidden;
  flex-shrink: 0;
}

#chat-other-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#chat-other-name {
  font-weight: 600;
  font-size: 1rem;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bubble-row {
  display: flex;
}

.bubble-row.mine {
  justify-content: flex-end;
}

.bubble-row.theirs {
  justify-content: flex-start;
}

.bubble {
  max-width: 75%;
  padding: 0.55rem 0.85rem;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.bubble-row.mine .bubble {
  background: var(--coral);
  color: #fefdfa;
  border-bottom-right-radius: 1px;
}

.bubble-row.theirs .bubble {
  background: var(--border);
  color: var(--text);
  border-bottom-left-radius: 1px;
}

#chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  border-radius: 2px;
  padding: 0.55rem 1rem;
  resize: none;
}

#chat-send-btn {
  background: var(--coral);
  color: #fefdfa;
  border: 2px solid var(--coral);
  border-radius: 2px;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#chat-send-btn:hover {
  background: var(--coral-dark);
  border-color: var(--coral-dark);
}

#chat-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: #fefdfa;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#messages-list-panel {
  display: block;
}

#messages-list-panel.hidden {
  display: none;
}

/* Prevent the outer .view from scrolling while chat is open.
   Use height: 100% chain so #chat-view never exceeds the actual visible area. */
.view.chat-active {
  overflow: hidden;
}

.view.chat-active #messages-view {
  height: 100%;
}

.view.chat-active #chat-view {
  height: 100%;
}

/* Attach button */
#chat-attach-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: 2px;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#chat-attach-btn:hover {
  color: var(--coral);
}

#chat-attach-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Image preview strip above input */
#chat-image-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-image-preview-img {
  height: 60px;
  width: 60px;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--border);
}

#chat-image-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-image-clear-btn:hover {
  color: var(--coral);
}

#chat-image-clear-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* Inline image inside chat bubble */
.bubble-img {
  display: block;
  max-width: 100%;
  border-radius: 2px;
  margin-bottom: 0.25rem;
}

.bubble-img:only-child {
  margin-bottom: 0;
}

.bubble span {
  display: block;
}
