/* chat: uses the tokens in /app.css. Room list (panel and /chat page) and the slide-in chat panel. */

/* ── Room list ─────────────────────────────────────────────────────────── */
.cl { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.cl-search { display: flex; align-items: center; gap: 8px; margin: 0 12px; padding: 0 12px; height: 40px; border-radius: 10px; background: var(--sunken); color: var(--muted); transition: box-shadow var(--dur-1), background-color var(--dur-1); }
.cl-search:focus-within { background: var(--card); box-shadow: var(--focus), var(--shadow-1); }
.cl-search svg { flex: none; }
.cl-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 15px; line-height: 1.4; color: var(--ink); padding: 0; }
.cl-search input::-webkit-search-cancel-button { cursor: pointer; }
.cl-chips { display: flex; gap: 6px; padding: 12px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.cl-chips::-webkit-scrollbar { display: none; }
.cl-chip { flex: none; height: 32px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--card); color: var(--ink-2); font-size: 14px; font-weight: 700; line-height: 1.3; cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1), border-color var(--dur-1); }
.cl-chip:hover { border-color: var(--sky); color: var(--deep); }
.cl-chip[aria-pressed="true"] { background: var(--deep); border-color: var(--deep); color: #fff; }
.cl-list { list-style: none; margin: 0; padding: 4px 6px 12px; overflow-y: auto; flex: 1; min-height: 0; display: grid; align-content: start; gap: 2px; }
.cl .cl-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; color: var(--ink); line-height: 1.4; text-decoration: none; transition: background-color var(--dur-1); font-weight: 400; box-shadow: none; }
.cl .cl-row:hover { background: var(--bg); text-decoration: none; }
.cl .cl-row:focus-visible { box-shadow: var(--focus); }
.cl .cl-row.active { background: var(--tint); box-shadow: none; }
.cl-avatar { width: 44px; height: 44px; font-size: 15px; }
.cl-avatar.space { border-radius: 12px; }
.cl-avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.cl-avatar.sm.space { border-radius: 8px; }
.cl-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.cl-top, .cl-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; line-height: 1.35; font-weight: 700; color: var(--deep); }
.cl-saved { flex: none; display: inline-flex; color: var(--sky); }
.cl-saved svg { width: 14px; height: 14px; fill: currentColor; }
.cl-time { flex: none; font-size: 12.5px; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; }
.cl-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 1.4; color: var(--muted); }
.cl-row.unread .cl-preview { color: var(--ink); font-weight: 700; }
.cl-row.unread .cl-time { color: var(--blue); font-weight: 700; }
.cl-count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--blue); color: #fff; font: 700 11.5px/20px Lato, sans-serif; text-align: center; font-variant-numeric: tabular-nums; }
.cl-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.cl-loading { padding: 8px 12px; display: grid; gap: 14px; }
.cl-sk { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: 14px 12px; gap: 6px 12px; align-items: center; }
.cl-sk span { border-radius: 6px; background: var(--sunken); animation: cl-pulse 1.4s ease-in-out infinite; }
.cl-sk span:first-child { grid-row: span 2; width: 44px; height: 44px; border-radius: 50%; }
@keyframes cl-pulse { 50% { opacity: .55; } }

/* The /chat page's left column hosts the same list. */
.chat-page .room-list { display: flex; flex-direction: column; padding: 16px 0 0; background: var(--card); }
.chat-page .cl-heading { font-size: 24px; line-height: 1.3; margin: 0 22px 12px; }
.room-list-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-page .room-list .cl-list { padding: 4px 8px 12px; }
.chat-title .back-to-list { color: var(--ink-2); place-items: center; width: 34px; height: 34px; margin-left: -8px; border-radius: 10px; }
.chat-title .back-to-list:hover { background: var(--sunken); }
@media (max-width: 800px) { .chat-page.has-room .back-to-list { display: inline-grid; } }

/* ── Slide-in panel ────────────────────────────────────────────────────── */
.cp-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.cp-backdrop { position: absolute; inset: 0; background: rgba(9, 48, 77, .18); opacity: 0; pointer-events: auto; transition: opacity var(--dur-2) var(--ease-out); }
.chat-panel { position: absolute; top: 8px; right: 8px; bottom: 8px; width: min(420px, calc(100vw - 16px)); display: flex; flex-direction: column; background: var(--card); border-radius: 16px; box-shadow: var(--shadow-3); overflow: hidden; pointer-events: auto; transform: translateX(calc(100% + 16px)); transition: transform 280ms var(--ease-out); }
.cp-root.in .cp-backdrop { opacity: 1; }
.cp-root.in .chat-panel { transform: none; }
.cp-root.out .cp-backdrop { opacity: 0; transition-duration: 200ms; }
.cp-root.out .chat-panel { transform: translateX(calc(100% + 16px)); transition: transform 220ms var(--ease-in-out); }
.cp-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cp-head { display: flex; align-items: center; gap: 6px; min-height: 60px; padding: 10px 10px 10px 20px; }
.cp-room .cp-head { padding-left: 8px; border-bottom: 1px solid var(--line); }
.cp-head h2 { margin: 0; font-size: 22px; line-height: 1.3; }
.cp-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1); }
.cp-icon:hover { background: var(--sunken); color: var(--deep); text-decoration: none; }
.cp-bookmark[aria-pressed="true"] { color: var(--blue); }
.cp-bookmark[aria-pressed="true"] svg { fill: currentColor; }
.cp-list-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cp-room-title { flex: 1; min-width: 0; }
.cp-room-title a { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px; border-radius: 10px; color: var(--deep); font-weight: 700; font-size: 15.5px; line-height: 1.35; }
.cp-room-title a:hover { background: var(--bg); text-decoration: none; }
.cp-room-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-room-body { display: flex; flex: 1; min-height: 0; }
.cp-room-body .chat-scroll, .cp-room-body .chat-composer { padding-left: 16px; padding-right: 16px; }
body.chat-panel-open { overflow: hidden; }

@media (max-width: 800px) {
  .chat-panel { inset: 0; width: auto; border-radius: 0; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
  .cp-head { padding-left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel, .cp-root.out .chat-panel, .cp-backdrop { transition: none !important; }
  .cl-sk span { animation: none; }
}
.cl-search input:focus-visible { box-shadow: none; }
@media (min-width: 801px) { .chat-page .cl-chips { flex-wrap: wrap; } }
@media (max-width: 800px) {
  .panel.chat-page { padding: 0; }
  .chat-page .room-list { border-right: 0; }
  .chat-page .cl-heading { margin: 0 16px 10px; }
}
