/* team-chat.css — the Team chat component (js/team-chat.js), mounted inside
   a side panel view. Phone first (375x812); desk (host >= 640px) shows the
   room list and the open room side by side. Every colour is the host app's
   own token (--bg, --bg-elevated, --text, --text-muted, --accent, --accent-2,
   --border, --radius-*, --font-mono); nothing here names a colour directly. */

.team-chat-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* the unread dot on the right panel's own edge tab (hidden state) —
   panel-hidden refreshes update it every 20s via team-chat.js's onUnread.
   .side-panel-tab-face is the positioned box (the tab itself is fixed). */
.side-panel-tab-face { position: relative; }
.side-panel-tab-unread {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 0 2px var(--bg-elevated, var(--bg));
}

.atc { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.atc-root { display: flex; flex-direction: row; height: 100%; min-height: 0; overflow: hidden; }

/* ---------- the room list ---------- */
.atc-list-pane { display: flex; flex-direction: column; min-height: 0; width: 100%; flex: none; }
.atc-root[data-screen="room"] .atc-list-pane { display: none; }

.atc-list-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; flex: none; }
.atc-title { margin: 0; font: 700 13px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.atc-list-actions { display: flex; gap: 4px; }

.atc-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--text);
  border-radius: var(--radius-pill); cursor: pointer;
}
.atc-icon-btn:hover { background: var(--accent-soft, rgba(0,0,0,.06)); }

.atc-rooms { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 6px 10px; }
.atc-empty { padding: 20px 14px; color: var(--text-muted); font-size: 13px; text-align: center; }
.atc-error { color: var(--accent-2); }

.atc-room-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 60px; padding: 8px 10px; margin: 2px 0;
  border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text);
  text-align: left; cursor: pointer;
}
.atc-room-row:hover { background: var(--accent-soft, rgba(0,0,0,.05)); }
.atc-room-row.is-active { background: var(--accent-soft, rgba(0,0,0,.08)); box-shadow: inset 2px 0 0 var(--accent); }
.atc-room-row-main { flex: 1; min-width: 0; }
.atc-room-row-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.atc-room-row-name-text { font: 600 14px/1.3 inherit; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atc-kind-tag {
  flex: none; font: 700 9px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-sm); color: var(--text-muted); border: 1px solid var(--border);
}
.atc-kind-support { color: var(--accent); border-color: var(--accent); }
.atc-room-row-preview {
  margin-top: 2px; font-size: 12.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.atc-room-row-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.atc-room-row-time { font-size: 11px; color: var(--text-muted); }
.atc-unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--accent-contrast, var(--bg)); font: 700 10px/18px var(--font-mono);
  text-align: center;
}

/* ---------- the room view ---------- */
.atc-room-pane { display: flex; flex-direction: column; min-height: 0; width: 100%; flex: none; }
.atc-root[data-screen="list"] .atc-room-pane { display: none; }

.atc-room-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-bottom: 1px solid var(--border); flex: none;
}
.atc-back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border: 0; background: transparent; color: var(--text); border-radius: var(--radius-pill); cursor: pointer; }
.atc-back:hover { background: var(--accent-soft, rgba(0,0,0,.06)); }
.atc-room-meta { flex: 1; min-width: 0; }
.atc-room-name { font: 700 14px/1.3 inherit; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atc-room-topic { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.atc-messages {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 10px;
}
.atc-msg { max-width: 88%; }
.atc-msg-user, .atc-msg-staff { align-self: flex-start; }
.atc-msg-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; flex-wrap: wrap; }
.atc-msg-author { font: 700 12.5px/1.3 inherit; color: var(--text); }
.atc-msg-time { font-size: 11px; color: var(--text-muted); }
.atc-msg-status { font-size: 11px; color: var(--text-muted); }
.atc-staff-badge, .atc-owner-badge {
  font: 700 9px/1 var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-sm); border: 1px solid var(--accent-2); color: var(--accent-2);
}
.atc-owner-badge { border-color: var(--accent); color: var(--accent); }
.atc-msg-body {
  font-size: 14px; line-height: 1.45; color: var(--text); white-space: pre-wrap; word-break: break-word;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 8px 12px;
}
.atc-msg-body a { color: var(--accent); text-decoration: underline; word-break: break-all; }

.atc-msg-assistant .atc-msg-body {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-elevated));
  border-color: var(--accent);
}
.atc-msg-assistant .atc-msg-author { color: var(--accent); }

.atc-msg-muted { align-self: center; max-width: 100%; }
.atc-msg-muted .atc-msg-body {
  background: transparent; border: 0; color: var(--text-muted); font-size: 12px; text-align: center; padding: 2px 8px;
}
.atc-system-line { align-self: center; color: var(--text-muted); font-size: 12px; padding: 6px; }

.atc-msg-pending .atc-msg-body { opacity: 0.65; }
.atc-msg-failed .atc-msg-body { border-color: var(--accent-2); }
.atc-msg-failed .atc-msg-status { color: var(--accent-2); }
.atc-retry-btn {
  margin-top: 4px; min-height: 32px; padding: 0 10px; border: 1px solid var(--accent-2); color: var(--accent-2);
  background: transparent; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
}

/* ---------- composer ---------- */
.atc-composer {
  flex: none; border-top: 1px solid var(--border); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.atc-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.atc-input {
  flex: 1; min-height: 44px; max-height: 140px; resize: none; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-elevated);
  color: var(--text); font: 14px/1.4 inherit; outline: none;
}
.atc-input:focus { border-color: var(--accent); }
.atc-send {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: var(--radius-pill);
  background: var(--accent); color: var(--accent-contrast, var(--bg)); display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer;
}
.atc-send:disabled { opacity: 0.4; cursor: default; }
.atc-composer-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; min-height: 44px; }
.atc-chip {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: transparent; color: var(--text-muted); font: 600 12px/1 var(--font-mono); cursor: pointer;
  display: inline-flex; align-items: center;
}
.atc-chip:hover { color: var(--text); border-color: var(--accent); }
.atc-counter { font-size: 11px; color: var(--text-muted); }
.atc-counter.is-over { color: var(--accent-2); }
.atc-slow { font-size: 11px; color: var(--accent-2); }

/* ---------- sheets (new room / members) ---------- */
.atc-sheet-overlay {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.atc-sheet {
  width: 100%; max-width: 420px; max-height: 82%; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.2);
}
.atc-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.atc-sheet-head h4 { margin: 0; font: 700 14px/1 inherit; color: var(--text); }
.atc-sheet-body { display: flex; flex-direction: column; gap: 10px; }
.atc-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.atc-field input {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
.atc-field input:focus { border-color: var(--accent); }
.atc-kind-toggle { display: flex; gap: 6px; }
.atc-kind-opt {
  flex: 1; min-height: 40px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: transparent; color: var(--text-muted); font: 600 12px/1 var(--font-mono); cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.atc-kind-opt.is-active { color: var(--text); border-color: var(--accent); background: var(--accent-soft, rgba(0,0,0,.06)); }
.atc-btn-primary {
  min-height: 44px; border: 0; border-radius: var(--radius-pill); background: var(--accent);
  color: var(--accent-contrast, var(--bg)); font: 600 14px/1 inherit; cursor: pointer;
}
.atc-btn-danger {
  min-height: 44px; border: 1px solid var(--accent-2); border-radius: var(--radius-pill); background: transparent;
  color: var(--accent-2); font: 600 14px/1 inherit; cursor: pointer;
}
.atc-sheet-error { margin: 0; color: var(--accent-2); font-size: 12px; }
.atc-add-note { margin: 0; color: var(--text-muted); font-size: 12px; }
.atc-members-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.atc-member-row {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
.atc-member-name { flex: 1; min-width: 0; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- desk: list and room side by side ----------
   The host is a side panel, whose width does not track the viewport, so
   the split is measured in JS (el.getBoundingClientRect().width >= 640)
   and applied via [data-desk="1"] rather than a media query. */
.atc[data-desk="1"] .atc-root { flex-direction: row; }
.atc[data-desk="1"] .atc-list-pane { width: 280px; flex: none; border-right: 1px solid var(--border); display: flex !important; }
.atc[data-desk="1"] .atc-room-pane { flex: 1; display: flex !important; }
.atc[data-desk="1"] .atc-back { display: none; }
.atc:not([data-desk="1"]) .atc-back { display: inline-flex; }

/* ================= v2 (docs/TEAMS_APP.md) ================= */

/* ---------- the orb mark — room list rows and the open room's head ---------- */
.atc-row-orb, .atc-room-orb {
  flex: none; width: 29px; height: 29px; border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px var(--border);
}
.atc-room-orb { width: 35px; height: 35px; }
.atc-row-orb img, .atc-room-orb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.atc-row-orb.is-glowing, .atc-room-orb.is-glowing {
  box-shadow: 0 0 0 2px var(--accent), 0 0 10px 2px var(--accent);
  animation: atc-orb-pulse 1.1s ease-in-out infinite;
}
@keyframes atc-orb-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- room list: bulletin row + visibility tag ---------- */
.atc-room-row-bulletin { box-shadow: inset 2px 0 0 var(--accent-2); }
.atc-vis-tag {
  flex: none; font: 700 9px/1 var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text-muted);
}
.atc-vis-tag.atc-vis-public { color: var(--accent); border-color: var(--accent); }
.atc-kind-bulletin { color: var(--accent-2); border-color: var(--accent-2); }
.atc-kind-meeting_room { color: var(--accent); border-color: var(--accent); }

/* ---------- staff section at the foot of the room list ---------- */
.atc-staff-section { flex: none; border-top: 1px solid var(--border); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px; }
.atc-staff-toggle {
  min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: transparent; color: var(--text-muted); font: 600 12px/1 var(--font-mono); text-align: left; cursor: pointer;
}
.atc-staff-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ---------- room head: name row + visibility badge + join ---------- */
.atc-room-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.atc-room-vis-badge {
  flex: none; font: 700 9px/1 var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 6px; border-radius: var(--radius-sm); border: 1px solid var(--accent); color: var(--accent);
}
.atc-join-btn {
  flex: none; min-height: 44px; padding: 0 12px; width: auto; border: 1px solid var(--accent); border-radius: var(--radius-pill);
  background: transparent; color: var(--accent); font: 600 12px/1 var(--font-mono);
}

/* ---------- the "Next meeting" strip ---------- */
.atc-meeting-strip {
  flex: none; border-bottom: 1px solid var(--border); padding: 8px 12px;
  display: flex; flex-direction: column; gap: 4px; background: var(--accent-soft, rgba(0,0,0,.04));
}
.atc-meeting-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.atc-meeting-label { font: 700 10px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.atc-meeting-title { font: 700 13px/1.3 inherit; color: var(--text); }
.atc-meeting-when { font-size: 12px; color: var(--text-muted); }
.atc-meeting-link { font-size: 12px; }
.atc-meeting-link a { color: var(--accent); word-break: break-all; }
.atc-meeting-empty { font-size: 12px; color: var(--text-muted); }
.atc-meeting-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.atc-rsvp-group { display: flex; gap: 6px; }
.atc-rsvp-btn { min-height: 44px; padding: 0 10px; font-size: 11px; }
.atc-rsvp-btn.is-active { color: var(--text); border-color: var(--accent); background: var(--accent-soft, rgba(0,0,0,.06)); }
.atc-rsvp-tally { font-size: 11px; color: var(--text-muted); }
.atc-ics-link { min-height: 44px; padding: 0 10px; font-size: 11px; text-decoration: none; display: inline-flex; align-items: center; }
.atc-schedule-btn { align-self: flex-start; min-height: 44px; margin-top: 2px; }

/* ---------- bulletin composer states ---------- */
.atc-bulletin-note { padding: 6px 4px; color: var(--text-muted); font-size: 12px; text-align: center; }
.atc-bulletin-post { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 0; }
.atc-pin-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); min-height: 44px; }
.atc-pin-toggle input { width: 18px; height: 18px; }
.atc-bulletin-send { padding: 0 16px; }

/* ---------- pinned posts ---------- */
.atc-msg-pinned .atc-msg-body { border-color: var(--accent-2); }
.atc-pinned-tag { font: 700 9px/1 var(--font-mono); letter-spacing: 0.06em; color: var(--accent-2); margin-bottom: 2px; }
.atc-pin-toggle-btn {
  margin-left: auto; min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); font: 600 10px/1 var(--font-mono); cursor: pointer;
}
.atc-pin-toggle-btn:hover { color: var(--text); border-color: var(--accent-2); }

/* ---------- reactions ---------- */
.atc-reactions { display: flex; gap: 6px; margin-top: 4px; }
.atc-reaction-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 2px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: transparent; cursor: pointer;
}
.atc-reaction-btn.is-mine { border-color: var(--accent); background: var(--accent-soft, rgba(0,0,0,.06)); }
.atc-reaction-emoji { font-size: 13px; line-height: 1; }
.atc-reaction-count { font-size: 11px; color: var(--text-muted); }

/* ---------- assistant voices ---------- */
.atc-voice-safety { color: #d0554a; }
.atc-voice-governance { color: #4a7dd0; }
.atc-voice-ethics { color: #6a4ad0; }
.atc-voice-assistant { color: var(--accent); }

/* ---------- mention chips ---------- */
.atc-mention-chips { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex: 1; min-width: 0; }
.atc-mention-chip { flex: none; padding: 0 10px; min-height: 44px; font-size: 11px; }
.atc-composer-foot { flex-wrap: nowrap; }
.atc-composer-foot[hidden] { display: none; }

/* ---------- schedule sheet extras ---------- */
.atc-field textarea {
  min-height: 60px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); color: var(--text); font: 14px/1.4 inherit; resize: vertical; outline: none;
}
.atc-field textarea:focus { border-color: var(--accent); }
.atc-field input[type="datetime-local"], .atc-field input[type="date"], .atc-field input[type="number"], .atc-field input[type="url"] {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
.atc-btn-secondary {
  min-height: 44px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: transparent;
  color: var(--text); font: 600 13px/1 inherit; cursor: pointer; padding: 0 14px;
}

/* ---------- public rooms browse sheet ---------- */
.atc-public-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.atc-public-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--border); }
.atc-public-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.atc-public-row-name { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atc-public-join-btn { flex: none; min-height: 44px; padding: 0 14px; font-size: 12px; }

/* ---------- seat requests (staff) ---------- */
.atc-seat-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.atc-seat-row { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.atc-seat-name { font: 700 13px/1.3 inherit; color: var(--text); }
.atc-seat-org { font-size: 12px; color: var(--text-muted); }
.atc-seat-why { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.atc-seat-actions { display: flex; gap: 8px; margin-top: 4px; }
.atc-seat-actions button { flex: 1; min-height: 44px; font-size: 12px; }
.atc-seat-result { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; word-break: break-all; }

/* ---------- canary board (staff) ---------- */
.atc-canary-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; margin-bottom: 10px; }
.atc-canary-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.atc-canary-badge {
  flex: none; font: 800 10px/1 var(--font-mono); letter-spacing: 0.04em; padding: 3px 8px; border-radius: var(--radius-pill);
  margin-top: 2px;
}
.atc-canary-badge.is-live { background: rgba(60,140,90,0.15); color: #2d7a4f; }
.atc-canary-badge.is-lapsed { background: var(--accent-2-soft, rgba(208,85,74,0.15)); color: var(--accent-2); }
.atc-canary-row-body { flex: 1; min-width: 0; }
.atc-canary-row-statement { font-size: 13px; color: var(--text); margin: 0 0 2px; }
.atc-canary-row-meta { font-size: 11px; color: var(--text-muted); }
.atc-canary-renew-btn { flex: none; align-self: center; }
.atc-canary-publish-title { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: var(--text); }

/* ---------- phone-first hard rules (kept at the end, !important where a
   desktop rule would otherwise win — canon §13) ---------- */
@media (max-width: 480px) {
  .atc-meeting-actions { flex-direction: column; align-items: stretch !important; }
  .atc-rsvp-group { justify-content: stretch; }
  .atc-rsvp-btn { flex: 1; }
  .atc-bulletin-post { flex-direction: column; align-items: stretch !important; }
  .atc-mention-chips { flex-wrap: nowrap; }
}
