/* ============================================================
   room.css — subject bar & live study-room roster
   ============================================================ */

/* ---------- "What are you working on?" ---------- */
.subject-bar { display: grid; gap: 10px; }

.subject-input-wrap {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 4px 14px 4px 16px; box-shadow: var(--ring-inset);
  transition: border-color var(--dur-2), background var(--dur-2);
}
.subject-input-wrap:focus-within { border-color: var(--brand-500); background: var(--surface-2); }
.subject-ico { color: var(--brand-300); display: grid; place-items: center; flex: none; }
.subject-ico svg { width: 19px; height: 19px; }

.subject-input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  padding: 13px 0; font-size: var(--fs-sm); font-weight: 500; color: var(--text);
}
.subject-input::placeholder { color: var(--text-3); font-weight: 400; }

.subject-saved {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: var(--fs-xs); font-weight: 600; color: var(--accent-green);
  animation: fade var(--dur-2);
}
.subject-saved svg { width: 14px; height: 14px; }

.subject-recents { display: flex; gap: 7px; flex-wrap: wrap; }
.subject-chip {
  padding: 6px 12px; border-radius: var(--r-full); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-3); font-size: var(--fs-xs); font-weight: 500;
  transition: color var(--dur-1), border-color var(--dur-1), background var(--dur-1);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.subject-chip:hover { color: var(--text); border-color: var(--brand-500); background: var(--surface-3); }

/* ---------- Live roster ---------- */
.participant.is-you { background: rgba(109,92,255,0.09); box-shadow: inset 0 0 0 1px rgba(109,92,255,0.22); }

/* ---------- Subject breakdown (summary) ---------- */
.subj-list { display: grid; gap: 12px; }
.subj-row { display: grid; gap: 7px; }
.subj-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.subj-head b { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subj-head span { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2); flex: none; font-variant-numeric: tabular-nums; }
.subj-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.subj-fill { height: 100%; border-radius: 999px; background: var(--grad-brand); width: 0; transition: width var(--dur-4) var(--ease-out); }
.subj-row:nth-child(2) .subj-fill { background: linear-gradient(90deg, #34e0c4, #29b8a0); }
.subj-row:nth-child(3) .subj-fill { background: linear-gradient(90deg, #ffb547, #f09030); }
.subj-row:nth-child(4) .subj-fill { background: linear-gradient(90deg, #ff6b8b, #e0506f); }
.subj-empty { color: var(--text-3); font-size: var(--fs-sm); text-align: center; padding: 20px 12px; }

/* ---------- Backend mode indicator ---------- */
.backend-pill { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); color: var(--text-3); }
.backend-pill .dot { width: 7px; height: 7px; background: var(--accent-green); }
.backend-pill.local .dot { background: var(--text-3); }

@media (max-width: 640px) {
  .subject-input { padding: 11px 0; font-size: var(--fs-xs); }
  .subject-recents { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .subject-chip { flex: none; }
}

/* ============================================================
   ROOM CHAT — the per-exam community
   ============================================================ */
.chat { display: flex; flex-direction: column; height: 460px; min-height: 0; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.chat-head b { font-size: var(--fs-sm); display: block; }
.chat-head small { font-size: 11px; display: block; margin-top: 1px; }

.chat-thread {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.chat-empty {
  margin: auto; text-align: center; color: var(--text-3);
  font-size: var(--fs-sm); line-height: 1.7;
}

.chat-msg { display: flex; gap: 9px; max-width: 100%; }
.chat-msg .avatar { width: 28px; height: 28px; font-size: 10px; flex: none; }
.chat-msg.mine { flex-direction: row-reverse; }

.cm-body { min-width: 0; max-width: 82%; }
.cm-meta {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px;
  font-size: 11px; color: var(--text-3);
}
.cm-meta.mine { justify-content: flex-end; margin: 4px 0 0; }
.cm-meta b { color: var(--text-2); font-weight: 600; font-size: 11px; }

.cm-text {
  padding: 9px 13px; border-radius: 14px; font-size: var(--fs-sm); line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--line);
  border-top-left-radius: 5px; overflow-wrap: anywhere; white-space: pre-wrap;
}
.chat-msg.mine .cm-text {
  background: var(--grad-brand); color: #fff; border-color: transparent;
  border-top-left-radius: 14px; border-top-right-radius: 5px;
}

.cm-del {
  background: none; border: none; cursor: pointer; color: var(--text-3);
  padding: 0; display: inline-flex; opacity: 0; transition: opacity var(--dur-1), color var(--dur-1);
}
.cm-del svg { width: 13px; height: 13px; }
.chat-msg:hover .cm-del { opacity: 1; }
.cm-del:hover { color: var(--danger); }

.chat-input {
  display: flex; gap: 9px; padding: 12px 14px;
  border-top: 1px solid var(--line); flex: none;
}
.chat-input .input { flex: 1; min-width: 0; }

.chat-note {
  padding: 0 14px 12px; margin: 0;
  font-size: 10px; color: var(--text-3); text-align: center; flex: none;
}

/* The unread badge is the ONLY interruption chat is allowed to make —
   no popups, no sound, nothing that breaks a focus session. */
.rail-tabs #chatUnread { background: var(--accent-rose); color: #fff; }
.rail-tabs button[aria-selected="true"] #chatUnread { background: rgba(109,92,255,0.18); color: var(--brand-300); }

@media (max-width: 640px) {
  .chat { height: 420px; }
}
