.mobile-back { display: none; }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chat-tools {
  border-top: 1px solid #eee9e3;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: #fffdfb;
  max-height: 235px;
  overflow: auto;
}
.chat-tool {
  border: 1px solid #f0ebe5;
  border-radius: 12px;
  background: #fff;
  color: #66636a;
  min-height: 67px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}
.chat-tool:hover { background: var(--surface-accent); border-color: var(--line-strong); color: var(--action-primary); }
.chat-tool-icon { font-size: 22px; line-height: 1.2; }
.composer { align-items: center; gap: 5px; }
.composer .compose-icon {
  min-width: 30px;
  width: 30px;
  height: 34px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #8d8a89;
  font-size: 20px;
  line-height: 1;
}
.composer .compose-icon:hover { color: var(--action-primary); }
.composer .compose-icon.recording {
  color: #d8413d;
  animation: recording-pulse 1s infinite alternate;
}
@keyframes recording-pulse { from { opacity: 1; } to { opacity: .4; } }
.composer .send-button { min-width: 42px; padding: 10px; }
.message > div:last-child { min-width: 0; }
.message .rich-bubble, .message.mine .rich-bubble {
  background: #fff;
  color: #34343b;
  border: 1px solid #eee6de;
  border-radius: 14px;
  min-width: min(260px, 50vw);
  max-width: min(380px, 55vw);
  box-shadow: 0 4px 16px #4b38210b;
  white-space: normal;
}
.rich-bubble > strong { display: block; font-size: 13px; line-height: 1.5; }
.rich-caption { color: #d9765e; font-size: 11px; font-weight: 800; margin-bottom: 7px; }
.rich-detail { display: block; color: #8c8990; font-size: 11px; margin-top: 6px; }
.rich-link { display: inline-block; margin-top: 10px; color: #d57459; font-weight: 800; font-size: 11px; text-decoration: none; }
.rich-button { border: 0; padding: 0; background: transparent; }
.chat-image { display: block; border: 0; padding: 0; background: transparent; cursor: zoom-in; }
.chat-image img { max-width: 250px; max-height: 250px; display: block; border-radius: 9px; object-fit: cover; }
.rich-bubble audio { width: min(240px, 48vw); display: block; }
.chat-video { display: block; width: min(var(--chat-photo-preview), 70vw); max-height: 52vh; border-radius: var(--radius-small); background: var(--call-video-surface); object-fit: contain; }
.file-attachment { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.file-icon { font-size: 24px; }
.file-attachment strong, .file-attachment small { display: block; overflow-wrap: anywhere; }
.file-attachment strong { font-size: 12px; }
.file-attachment small { font-size: 10px; color: #9b9695; margin-top: 4px; }
.rich-options { display: grid; gap: 6px; margin-top: 12px; }
.rich-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #eee8e2;
  border-radius: 9px;
  background: #fff;
  color: #5b5656;
  text-align: left;
  font-size: 11px;
}
.rich-option:hover, .rich-option.chosen, .rich-option:has(input:checked) { background: var(--surface-accent); border-color: var(--action-primary); }
.rich-option small { color: #a8a0a0; white-space: nowrap; }
.date-option { cursor: pointer; }
.date-option input { accent-color: var(--action-primary); }
.date-option span { flex: 1; }
.rich-hint { display: block; margin-top: 10px; color: #9e999a; font-size: 10px; }
.rich-action {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 8px 11px;
  margin-top: 11px;
  background: #ef8064;
  color: white;
  font-size: 11px;
  font-weight: 800;
}
.ladder-list { display: grid; gap: 7px; margin-top: 12px; font-size: 11px; }
.ladder-board { max-width: 100%; overflow-x: auto; margin-top: 11px; background: var(--surface-accent); border-radius: 9px; padding: 6px; }
.ladder-list > div { display: flex; align-items: center; gap: 7px; border-bottom: 1px solid #f3eee9; padding-bottom: 6px; }
.ladder-lane { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--action-primary); background: var(--surface-accent); font-weight: 800; }
.ladder-result { margin-left: auto; color: #968e8c; }
.date-entries { display: grid; gap: 8px; }
.camera-preview { width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 12px; background: #28282d; }
.camera-preview video { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 720px) {
  .chats-layout { display: block; height: calc(100dvh - 195px); min-height: 360px; }
  .chat-list { display: none; height: 100%; border-right: 0; }
  .chat-room { height: 100%; }
  .chats-layout.show-list .chat-list { display: block; }
  .chats-layout.show-list .chat-room { display: none; }
  .chat-row { padding: 14px; gap: 11px; }
  .chat-row .avatar { width: 38px; height: 38px; font-size: 14px; }
  .chat-copy strong { font-size: 13px; }
  .chat-copy small, .chat-time, .list-heading span { display: block; }
  .mobile-back { display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--action-primary); font-size: 20px; padding: 3px; }
  .chat-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px; max-height: 180px; }
  .chat-tool { min-height: 55px; font-size: 10px; }
  .chat-tool-icon { font-size: 19px; }
  .composer { gap: 2px; }
  .composer .compose-icon { min-width: 25px; width: 25px; font-size: 18px; }
  .composer .send-button { min-width: 35px; padding: 8px; }
  .message .rich-bubble, .message.mine .rich-bubble { min-width: 0; max-width: min(310px, 80vw); }
  .chat-image img { max-width: min(240px, 65vw); }
}
@media (prefers-reduced-motion: reduce) { .composer .compose-icon.recording { animation: none; } }

.chat-image img { object-fit: contain; }

.link-preview-slot { display: block; height: 1px; overflow: hidden; }
.link-preview-slot.link-preview-ready {
  height: auto;
  width: 100%;
  max-width: 292px;
  margin-top: 9px;
  white-space: normal;
}
.link-preview-card {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  color: #34343b;
  background: var(--surface-accent);
  border: 1px solid #eadfd7;
  border-radius: 13px;
  text-decoration: none;
  box-shadow: 0 5px 16px #4b38210d;
  -webkit-touch-callout: none;
}
.link-preview-card:hover, .link-preview-card:active { background: var(--surface-accent); }
.link-preview-image {
  display: block;
  width: 100%;
  aspect-ratio: 1.91 / 1;
  object-fit: cover;
  background: #eee9e3;
}
.link-preview-copy { display: grid; gap: 3px; padding: 10px 12px 11px; }
.link-preview-site {
  color: var(--action-primary);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-preview-title {
  display: -webkit-box;
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.link-preview-description {
  display: block;
  color: #817b79;
  font-size: 11px;
  line-height: 1.45;
}
@media (max-width: 720px) {
  .link-preview-slot.link-preview-ready { max-width: 278px; }
}
/* Chat videos show their first frame; tapping opens the zoomable black viewer. */
.chat-video-tile { position: relative; cursor: pointer; }
.chat-video-tile .chat-video { pointer-events: none; min-height: 120px; }
