/* =========================================================
   Duovly — Chat design layer (ChatRoom + ChatList hi-fi)
   Reproduces ui_kits/app/ChatRoom.html & ChatList.html look.
   Tokens only (tokens.css). letter-spacing 0. Card signature §2.
   Loaded at runtime by src/screens/chat.js (index.html not editable).
   Scoped under .chat-room-screen / .chat-inbox-screen to avoid
   bleeding into other screens that reuse .bubble / .msg-row etc.
   ========================================================= */

/* ============ shared chat surface ============ */
.chat-room-screen {
  background:
    linear-gradient(180deg, rgba(255,247,248,.92), rgba(247,251,249,.84) 50%, var(--surface) 100%) !important;
  display: flex;
  flex-direction: column;
}

/* ============ Chat Room — header ============ */
.cr-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(252,250,247,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.cr-back,
.cr-more {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-700);
  padding: 0;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cr-back svg,
.cr-more svg { width: 24px; height: 24px; }
.cr-av {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.cr-av img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-sunken);
}
.cr-av .cr-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.cr-meta {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.cr-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 15.5px;
  font-weight: var(--fw-heavy);
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cr-level {
  font-size: 12px;
  font-weight: var(--fw-heavy);
  background: var(--ink-500);
  color: #fff;
  border-radius: var(--r-pill);
  padding: 2px 8px;
  flex-shrink: 0;
}
.cr-status {
  font-size: 11px;
  font-weight: var(--fw-bold);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cr-status .cr-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* ============ Chat Room — service / action bar ============ */
.cr-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 16px 12px;
}
.cr-action-btn {
  height: 46px;
  border: none;
  border-radius: var(--r-lg);
  font-size: 15px;
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
.cr-action-btn .cr-action-ic {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cr-action-btn--ghost {
  background: var(--surface);
  color: var(--ink-900);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
}
.cr-action-btn--primary {
  background: linear-gradient(135deg, var(--coral-400), var(--rose-500));
  color: #fff;
  box-shadow: var(--sh-cta), inset 0 1px 0 rgba(255,255,255,.4);
}
.cr-action-btn:active { transform: scale(.97); }

/* ============ Chat Room — messages area ============ */
/* Header / actions / input bar stay fixed-height; messages fills the gap.
   Specificity beats base `.screen.active > * { flex-shrink: 0 }`. */
.chat-room-screen .cr-messages {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
}
.chat-room-screen > .cr-header,
.chat-room-screen > .cr-actions,
.chat-room-screen > .cr-inbar { flex: 0 0 auto; }
.cr-messages::-webkit-scrollbar { display: none; }

.cr-day {
  align-self: center;
  font-size: 11px;
  font-weight: var(--fw-bold);
  color: var(--ink-400);
  background: rgba(255,255,255,.7);
  padding: 4px 12px;
  border-radius: var(--r-pill);
  margin: 4px 0;
}

/* coin-safety system message */
.cr-sys {
  align-self: stretch;
  background: var(--mint-50);
  border: 1px solid var(--mint-200);
  border-radius: var(--r-md);
  padding: 11px 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.cr-sys__ic {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  object-fit: contain;
}
.cr-sys__t {
  font-size: 12px;
  font-weight: var(--fw-heavy);
  color: var(--mint-700);
}
.cr-sys__d {
  font-size: 11.5px;
  font-weight: var(--fw-medium);
  color: var(--mint-700);
  line-height: var(--lh-normal);
  margin-top: 2px;
}

/* ============ Chat Room — message bubbles ============ */
.chat-room-screen .msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 80%;
}
.chat-room-screen .msg-row.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-room-screen .msg-row:not(.me) { align-self: flex-start; }
.chat-room-screen .msg-row .avatar-wrap,
.chat-room-screen .msg-row > .avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  align-self: flex-end;
}
.chat-room-screen .bubble {
  padding: 10px 13px;
  font-size: 14px;
  font-weight: var(--fw-medium);
  line-height: var(--lh-normal);
  position: relative;
  max-width: 100%;
  word-break: break-word;
}
.chat-room-screen .bubble.them {
  background: var(--surface);
  color: var(--ink-900);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 6px rgba(16,32,51,.05);
}
.chat-room-screen .bubble.me {
  background: linear-gradient(135deg, var(--coral-400), var(--rose-500));
  color: #fff;
  border-radius: 16px 4px 16px 16px;
  box-shadow: 0 4px 12px rgba(255,111,107,.28);
}
.chat-room-screen .msg-time {
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--ink-400);
  align-self: flex-end;
  margin: 0 2px;
  flex-shrink: 0;
}

/* ============ Chat Room — order / system card ============ */
.cr-order {
  align-self: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-card);
}
.cr-order__h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.cr-order__badge {
  font-size: 11px;
  font-weight: var(--fw-heavy);
  color: #fff;
  background: var(--warning);
  padding: 3px 9px;
  border-radius: var(--r-pill);
}
.cr-order__title {
  font-size: 13.5px;
  font-weight: var(--fw-heavy);
  color: var(--ink-900);
}
.cr-order__b { padding: 13px 14px; }
.cr-order__line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-size: 12.5px;
}
.cr-order__line span { color: var(--ink-400); font-weight: var(--fw-semibold); }
.cr-order__line b { font-weight: var(--fw-heavy); color: var(--ink-900); }
.cr-order__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 11px;
  border-top: 1px dashed var(--border);
}
.cr-order__total .l { font-size: 13px; font-weight: var(--fw-heavy); color: var(--ink-900); }
.cr-order__total .v {
  font-size: 19px;
  font-weight: 900;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cr-order__total .v .cr-coin {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cr-order__body-text {
  font-size: 12.5px;
  font-weight: var(--fw-medium);
  color: var(--ink-700);
  line-height: var(--lh-normal);
}
.cr-order__btns {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
}
.cr-order__btn {
  flex: 1;
  min-height: 44px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: var(--fw-heavy);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cr-order__btn--ghost {
  background: var(--surface);
  border: 1.4px solid var(--border);
  color: var(--ink-700);
}
.cr-order__btn--accept {
  border: none;
  color: #fff;
  background: var(--mint-500);
}
.cr-order__btn--pay {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--coral-400), var(--rose-500));
  box-shadow: var(--sh-cta), inset 0 1px 0 rgba(255,255,255,.4);
}
.cr-order__safe {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: center;
  padding: 0 14px 13px;
  font-size: 10.5px;
  font-weight: var(--fw-bold);
  color: var(--mint-600);
}
.cr-order__safe svg { width: 13px; height: 13px; }

/* ============ Chat Room — input bar ============ */
.cr-inbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0));
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.cr-in-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink-700);
  flex-shrink: 0;
  font-size: 24px;
  line-height: 1;
}
.cr-in-icon svg { width: 22px; height: 22px; }
.cr-in-field {
  flex: 1;
  min-height: 44px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 6px 0 15px;
}
.cr-in-field input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font: var(--fw-medium) 14px var(--font-sans);
  color: var(--ink-900);
}
.cr-in-field input::placeholder { color: var(--ink-400); }
.cr-in-field .my-typing-chip { flex-shrink: 0; margin: 0 4px; }
.cr-in-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--coral-400), var(--rose-500));
  box-shadow: var(--sh-cta);
}
.cr-in-send svg { width: 20px; height: 20px; }
.cr-in-send:active,
.cr-in-icon:active,
.cr-in-gift:active { transform: scale(.95); }
.cr-in-gift {
  position: relative;
  border: none;
  background: transparent;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============ Chat List — empty state (warm) ============ */
.cr-empty {
  margin: 24px 4px;
  padding: 36px 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--coral-50), #FFF6E8 60%, var(--mint-50));
  border: 1px solid var(--coral-100);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-card);
}
.cr-empty__art {
  width: 132px;
  height: 106px;
  margin: 0 auto 14px;
}
.cr-empty__title {
  font-size: 17px;
  font-weight: var(--fw-heavy);
  color: var(--ink-900);
}
.cr-empty__sub {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--ink-500);
  margin-top: 6px;
  line-height: var(--lh-snug);
}
.cr-empty__cta {
  margin-top: 18px;
  min-height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--coral-400), var(--rose-500));
  color: #fff;
  font-size: 14px;
  font-weight: var(--fw-heavy);
  cursor: pointer;
  box-shadow: var(--sh-cta), inset 0 1px 0 rgba(255,255,255,.4);
}
.cr-empty__cta:active { transform: scale(.97); }

/* ============ Chat List — rows (.citem, ChatList.html) ============ */
.chat-inbox-screen .chat-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.chat-inbox-screen .citem {
  position: relative;
  display: flex;
  gap: 13px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--sh-card);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chat-inbox-screen .citem:active { transform: scale(.99); }
.chat-inbox-screen .citem.has-unread { border-color: var(--coral-200); }
.citem__avwrap { position: relative; flex-shrink: 0; width: 56px; height: 56px; }
.citem__ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  padding: 2.5px;
  background: linear-gradient(135deg, #FF8FB0, #B57BFF);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
}
.citem__av {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 1;
  background: var(--surface-sunken);
}
.citem__dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  z-index: 2;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2.5px solid var(--surface);
}
.citem__main { flex: 1 1 auto; min-width: 0; }
.citem__name { display: flex; align-items: center; gap: 6px; }
.citem__name b {
  font-size: 16px;
  font-weight: var(--fw-heavy);
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.citem .seal {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border-radius: 42% 58% 58% 42% / 42% 42% 58% 58%;
  transform: rotate(8deg);
  flex-shrink: 0;
}
.citem .lbl {
  font-size: 11px;
  font-weight: var(--fw-heavy);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.citem .lbl--mate { background: var(--surface-mute); color: var(--ink-600); }
.citem .lbl--vip  { background: var(--mint-50);     color: var(--mint-700); }
.citem .lbl--bff  { background: var(--coral-50);    color: var(--coral-600); }
.citem .lbl--req  { background: #ECE7FF;            color: var(--lilac-500); }
.citem__msg {
  font-size: 13.5px;
  color: var(--ink-700);
  margin-top: 5px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.citem__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  align-self: stretch;
}
.citem__time { font-size: 12px; color: var(--ink-400); white-space: nowrap; }
.citem .chip {
  font-size: 11.5px;
  font-weight: var(--fw-heavy);
  padding: 5px 10px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.citem .chip--gift   { background: var(--butter-100); color: var(--butter-700); }
.citem .chip--sched  { background: var(--mint-50);    color: var(--mint-700); }
.citem .chip--chat   { background: var(--surface-mute); color: var(--ink-500); }
.citem .chip--review { background: #ECE7FF;           color: var(--lilac-500); }
.citem .chip--sent   { background: transparent; color: var(--butter-700); box-shadow: inset 0 0 0 1px var(--butter-300); }
.citem__unread {
  background: var(--coral-500);
  color: #fff;
  font-size: 11px;
  font-weight: var(--fw-heavy);
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  box-sizing: border-box;
}
