/* Light messenger treatment, scoped to Messages so the rest of the app keeps its theme. */
body[data-view="messages"] .phone-shell .views,
body[data-view="messages"] .messages-view {
  background: #f8fafc;
}

.messages-view .messages-head { color: #172033; }
.messages-view .messages-head h2 { color: #172033; }
.messages-view .messages-head .panel-kicker { color: #246bd0; }
.messages-view .new-chat-button {
  border-color: #d9e2ee;
  color: #172033;
  background: #fff;
}
.messages-view .new-chat-button:hover { border-color: #88b9ee; background: #f0f7ff; }

.messages-view .messages-layout {
  border-color: #dce5ef;
  background: #fff;
  box-shadow: 0 18px 48px rgba(39, 75, 117, .08);
}
.messages-view .thread-column {
  border-color: #e3e9f1;
  background: #fff;
}
.messages-view .thread-search {
  border-color: #dbe3ed;
  color: #718095;
  background: #f4f7fb;
}
.messages-view .thread-search input { color: #172033; background: transparent; }
.messages-view .thread-row { border-color: #e9eef4; }
.messages-view .thread-item { color: #172033; background: transparent; }
.messages-view .thread-item:hover { background: #f4f8fd; }
.messages-view .thread-item.is-active {
  background: #eaf3ff;
  box-shadow: inset 3px 0 0 #2477dc;
}
.messages-view .thread-copy > span,
.messages-view .thread-copy small { color: #748198; }
.messages-view .thread-pin-button { color: #748198; }
.messages-view .thread-pin-button:hover,
.messages-view .thread-pin-button[aria-pressed="true"] { color: #246bd0; background: #eaf3ff; }
.messages-view .thread-avatar { border-radius: 50%; }
.messages-view .thread-avatar img { border-radius: inherit; }
.messages-view .thread-list .empty-state { color: #172033; }
.messages-view .thread-list .empty-state span { color: #748198; }

.messages-view .chat-panel.is-conversation {
  position: relative;
  color: #172033;
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.messages-view .chat-panel.is-conversation .chat-head {
  z-index: 3;
  min-height: 76px;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 8px 13px;
  border-bottom: 1px solid #e3e9f1;
  color: #172033;
  background: #fff;
}
.messages-view .chat-panel.is-conversation .chat-head > .icon-button {
  grid-column: 1;
  width: 42px;
  height: 42px;
  border: 1px solid #dce4ee;
  border-radius: 50%;
  color: #34445b;
  background: #f6f9fd;
}
.messages-view .chat-panel.is-conversation .chat-head > .icon-button:hover { background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .chat-person {
  grid-column: 2;
  min-height: 58px;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 11px;
  padding: 5px 14px 5px 6px;
  border: 1px solid #dce4ee;
  border-radius: 32px;
  color: #172033;
  background: #f8fafc;
}
.messages-view .chat-panel.is-conversation .chat-person:hover { background: #edf5ff; }
.messages-view .chat-panel.is-conversation .chat-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
}
.messages-view .chat-panel.is-conversation .chat-avatar img { border-radius: inherit; }
.messages-view .chat-panel.is-conversation .chat-person-copy h3 {
  margin: 0;
  color: #172033;
  font-size: 16px;
  font-weight: 650;
}
.messages-view .chat-panel.is-conversation .chat-person-copy small {
  margin-top: 3px;
  color: #748198;
  font-size: 12px;
}
.messages-view .chat-panel.is-conversation .chat-tools {
  grid-column: 3;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid #dce4ee;
  border-radius: 28px;
  background: #f8fafc;
}
.messages-view .chat-panel.is-conversation .chat-tools > button,
.messages-view .chat-panel.is-conversation .chat-header-actions > summary {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #34445b;
  background: transparent;
  cursor: pointer;
  list-style: none;
}
.messages-view .chat-panel.is-conversation .chat-header-actions > summary::-webkit-details-marker { display: none; }
.messages-view .chat-panel.is-conversation .chat-tools > button:hover,
.messages-view .chat-panel.is-conversation .chat-header-actions > summary:hover { color: #165cbb; background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .chat-tools svg { width: 21px; height: 21px; }
.messages-view .chat-panel.is-conversation .chat-header-actions { position: relative; }
.messages-view .chat-panel.is-conversation .chat-header-menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 11px);
  right: 0;
  width: 196px;
  padding: 5px;
  border: 1px solid #dce4ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(33, 61, 95, .18);
}
.messages-view .chat-panel.is-conversation .chat-header-menu button {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  color: #26364c;
  background: transparent;
  font-size: 12px;
  text-align: left;
}
.messages-view .chat-panel.is-conversation .chat-header-menu button:hover { color: #165cbb; background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .chat-header-menu button svg { width: 17px; height: 17px; }

.messages-view .chat-panel.is-conversation .chat-pinned-messages {
  z-index: 2;
  gap: 8px;
  min-height: 54px;
  padding: 7px 13px 7px 19px;
  border-bottom: 1px solid #e3e9f1;
  color: #172033;
  background: #f7faff;
  font-size: 13px;
}
.messages-view .chat-panel.is-conversation .chat-pinned-messages > svg { display: none; }
.messages-view .chat-panel.is-conversation .chat-pinned-messages > span {
  padding-left: 9px;
  border-left: 3px solid #3580db;
  color: #172033;
}
.messages-view .chat-panel.is-conversation .chat-pinned-messages > button:not(.chat-pinned-dismiss) {
  min-width: 0;
  max-width: 55ch;
  padding: 4px 0;
  border: 0;
  color: #52647c;
  background: transparent;
  font-size: 12px;
}
.messages-view .chat-panel.is-conversation .chat-pinned-messages > .chat-pinned-dismiss {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  color: #52647c;
  background: transparent;
}
.messages-view .chat-panel.is-conversation .chat-pinned-dismiss svg { width: 18px; height: 18px; }
.messages-view .chat-panel.is-conversation .chat-pinned-dismiss:hover { background: #e4edf8; }

.messages-view .chat-panel.is-conversation .chat-search-bar {
  position: absolute;
  z-index: 4;
  top: 82px;
  right: 14px;
  left: 14px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 14px;
  border: 1px solid #d4deeb;
  border-radius: 24px;
  color: #748198;
  background: #fff;
  box-shadow: 0 12px 26px rgba(33, 61, 95, .14);
}
.messages-view .chat-panel.is-conversation .chat-search-bar > svg { width: 18px; height: 18px; flex: none; }
.messages-view .chat-panel.is-conversation .chat-search-bar input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: #172033;
  background: transparent;
  font: inherit;
  font-size: 13px;
}
.messages-view .chat-panel.is-conversation .chat-search-count { flex: none; font-size: 11px; }
.messages-view .chat-panel.is-conversation .chat-search-bar button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 50%;
  color: #52647c;
  background: transparent;
}
.messages-view .chat-panel.is-conversation .chat-search-bar button:hover { background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .chat-search-bar button svg { width: 17px; height: 17px; }

.messages-view .chat-panel.is-conversation .message-stack {
  padding: 18px 20px 24px;
  color: #172033;
  background: #f5f8fc;
}
.messages-view .chat-panel.is-conversation .bubble {
  max-width: min(82%, 650px);
  margin: 6px 0;
  padding: 9px 12px 7px;
  border: 0;
  border-radius: 19px 19px 19px 5px;
  color: #172033;
  background: #fff;
  box-shadow: 0 2px 8px rgba(38, 68, 105, .08);
  font-size: 15px;
  line-height: 1.35;
}
.messages-view .chat-panel.is-conversation .bubble.me {
  margin-left: auto;
  border-radius: 19px 19px 5px 19px;
  color: #fff;
  background: #0968c8;
}
.messages-view .chat-panel.is-conversation .bubble.system {
  max-width: min(100%, 44ch);
  margin: 10px auto 16px;
  padding: 8px 11px;
  border-radius: 14px;
  color: #64748b;
  background: #e9eef5;
  font-size: 12px;
}
.messages-view .chat-panel.is-conversation .bubble.is-important {
  border: 1px solid #ebd176;
  color: #42390f;
  background: #fff3bf;
}
.messages-view .chat-panel.is-conversation .bubble.is-message-pinned { box-shadow: inset 3px 0 0 #9dc4fa; }
.messages-view .chat-panel.is-conversation .bubble.is-search-match { outline: 2px solid #9ec8ff; outline-offset: 2px; }
.messages-view .chat-panel.is-conversation .bubble > small { color: #246bd0; font-size: 11px; }
.messages-view .chat-panel.is-conversation .message-copy { color: inherit; }
.messages-view .chat-panel.is-conversation .message-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-height: 18px;
  margin-top: 2px;
}
.messages-view .chat-panel.is-conversation .message-meta {
  min-height: 0;
  gap: 5px;
  margin: 0;
  color: #718095;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.messages-view .chat-panel.is-conversation .bubble.them .message-meta { color: #718095; }
.messages-view .chat-panel.is-conversation .bubble.me .message-meta { color: #d9eaff; }
.messages-view .chat-panel.is-conversation .bubble.is-important .message-meta,
.messages-view .chat-panel.is-conversation .bubble.is-important .message-actions summary,
.messages-view .chat-panel.is-conversation .bubble.is-important .message-receipt { color: #6e5716; }
.messages-view .chat-panel.is-conversation .message-receipt { color: #c8e0ff; font-size: 13px; }
.messages-view .chat-panel.is-conversation .message-actions { margin: 0; }
.messages-view .chat-panel.is-conversation .message-actions summary { color: #718095; }
.messages-view .chat-panel.is-conversation .bubble.me .message-actions summary { color: #d9eaff; }
.messages-view .chat-panel.is-conversation .message-actions summary:hover { color: #246bd0; background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .message-actions-menu {
  border-color: #dce4ee;
  color: #172033;
  background: #fff;
  box-shadow: 0 18px 34px rgba(33, 61, 95, .18);
}
.messages-view .chat-panel.is-conversation .message-actions .message-actions-menu button {
  color: #26364c;
  background: transparent;
}
.messages-view .chat-panel.is-conversation .message-actions .message-actions-menu button:hover { color: #165cbb; background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .message-actions .message-actions-menu button[aria-pressed="true"] { color: #a36d00; }
.messages-view .chat-panel.is-conversation .bubble.me .message-attachment { border-color: rgba(255, 255, 255, .45); color: #fff; }
.messages-view .chat-panel.is-conversation .bubble.them .message-attachment { border-color: #dce4ee; color: #172033; }

.messages-view .chat-panel.is-conversation .message-form {
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: end;
  padding: 10px 13px;
  border-top: 1px solid #e3e9f1;
  background: #fff;
}
.messages-view .chat-panel.is-conversation .message-form .attach-button,
.messages-view .chat-panel.is-conversation .message-form button[type="submit"] {
  width: 44px;
  height: 44px;
  border: 1px solid #dce4ee;
  border-radius: 50%;
  color: #34445b;
  background: #f6f9fd;
}
.messages-view .chat-panel.is-conversation .message-form .attach-button:hover { background: #eaf3ff; }
.messages-view .chat-panel.is-conversation .message-form button[type="submit"] { border-color: #1675d6; background: #126ed1; }
.messages-view .chat-panel.is-conversation .message-form button[type="submit"]:hover { background: #2382e7; }
.messages-view .chat-panel.is-conversation .message-form button[type="submit"]:disabled { border-color: #dce4ee; color: #9eacbd; background: #f6f9fd; }
.messages-view .chat-panel.is-conversation .message-form textarea[name="message"] {
  min-height: 48px;
  max-height: 180px;
  padding: 12px 17px;
  border: 1px solid #dce4ee;
  border-radius: 25px;
  color: #172033;
  background: #f6f9fd;
  font-size: 14px;
  line-height: 1.45;
}
.messages-view .chat-panel.is-conversation .message-form textarea[name="message"]:focus {
  border-color: #5c9fe8;
  box-shadow: 0 0 0 2px rgba(82, 158, 244, .2);
}
.messages-view .chat-panel.is-conversation .message-form textarea[name="message"]::placeholder { color: #8d9bae; }

@media (max-width: 899px) {
  .messages-view .messages-layout { border: 0; border-radius: 0; box-shadow: none; }
  .messages-view .chat-panel.is-conversation .chat-head {
    min-height: calc(76px + env(safe-area-inset-top));
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 6px;
    padding: calc(6px + env(safe-area-inset-top)) 9px 6px;
  }
  .messages-view .chat-panel.is-conversation .chat-head > .icon-button { width: 40px; height: 40px; }
  .messages-view .chat-panel.is-conversation .chat-person { min-height: 54px; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; padding: 4px 9px 4px 5px; }
  .messages-view .chat-panel.is-conversation .chat-avatar { width: 42px; height: 42px; }
  .messages-view .chat-panel.is-conversation .chat-person-copy h3 { font-size: 15px; }
  .messages-view .chat-panel.is-conversation .chat-person-copy small { font-size: 11px; }
  .messages-view .chat-panel.is-conversation .chat-tools { gap: 0; padding: 2px; }
  .messages-view .chat-panel.is-conversation .chat-tools > button,
  .messages-view .chat-panel.is-conversation .chat-header-actions > summary { width: 35px; height: 35px; }
  .messages-view .chat-panel.is-conversation .chat-tools svg { width: 19px; height: 19px; }
  .messages-view .chat-panel.is-conversation .chat-pinned-messages { min-height: 54px; padding-inline: 11px; }
  .messages-view .chat-panel.is-conversation .chat-pinned-messages > button:not(.chat-pinned-dismiss) { flex: 1; max-width: none; }
  .messages-view .chat-panel.is-conversation .message-stack { padding: 12px 13px 20px; }
  .messages-view .chat-panel.is-conversation .bubble { max-width: 90%; padding: 9px 11px 6px; font-size: 15px; }
  .messages-view .chat-panel.is-conversation .message-form { gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .messages-view .chat-panel.is-conversation .message-form textarea[name="message"] { max-height: min(200px, 30dvh); }
  body[data-view="messages"].is-chat-open #support-launcher { display: none; }
}

@media (max-width: 370px) {
  .messages-view .chat-panel.is-conversation .chat-tools > button,
  .messages-view .chat-panel.is-conversation .chat-header-actions > summary { width: 30px; }
  .messages-view .chat-panel.is-conversation .chat-person-copy small { display: none; }
}
