/* ============================================================
   Secure Chat — Powerful Matter skin
   Self-contained: imports tokens.css, mirrors webfonts locally,
   maps SChat's internal CSS variables onto PM tokens, then refines
   shapes/spacing/type to echo the docs/ui workbook.
   Site is dark-only by design.
   ============================================================ */

@import url("/css-v2/tokens.css");

/* ===== Webfonts (mirrored from base.css; kept local so the chat
   doesn't depend on the marketing site's main.css) ===== */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces/Fraunces-Latin-Roman-Full.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/assets/fonts/fraunces/Fraunces-Latin-Italic-Full.woff2") format("woff2");
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
}

/* ===== SChat's internal variables, remapped onto PM tokens ===== */
:root {
  --bg-primary:        var(--pm-black);            /* #0A0A0B */
  --bg-secondary:      #111114;                    /* sidebar, headers */
  --bg-tertiary:       #1A1A1F;                    /* buttons, inputs, member avatars */
  --bg-input:          rgba(255, 255, 255, 0.02);
  --bg-hover:          rgba(196, 0, 173, 0.10);
  --bg-active:         rgba(196, 0, 173, 0.16);
  --bg-msg-incoming:   rgba(255, 255, 255, 0.04);
  --bg-msg-outgoing:   rgba(196, 0, 173, 0.14);
  --bg-modal:          #0F0F12;

  --text-primary:      var(--pm-white);
  --text-secondary:    var(--pm-gray-300);
  --text-muted:        var(--pm-gray-400);

  --accent:            var(--pm-purple-400);       /* #C400AD */
  --accent-hover:      var(--pm-purple-300);
  --accent-deep:       var(--pm-purple-600);
  --accent-dim:        rgba(196, 0, 173, 0.12);
  --focus-ring:        var(--pm-accent);           /* lime, focus only */

  --border:            rgba(255, 255, 255, 0.08);
  --border-strong:     rgba(255, 255, 255, 0.14);

  --error:             #FF7B9C;
  --success:           #6BD16B;
  --warning:           var(--pm-accent);

  --radius-sm:         6px;
  --radius:            10px;
  --radius-md:         14px;
  --radius-lg:         18px;
  --radius-pill:       999px;

  --sidebar-width:     280px;
  --transition:        180ms cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-modal:      0 24px 64px rgba(0, 0, 0, 0.65);

  --font-sans:         "Inter", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display:      "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono:         "SF Mono", "Fira Code", "Consolas", monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(196, 0, 173, 0.18);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 0, 173, 0.32);
}

/* Lime focus rings — workbook convention */
*:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Layout — app shell + sidebar + chat area
   ============================================================ */

#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100vh;
  height: 100dvh;
}

#sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

/* ===== Brand back-link (top of sidebar) ===== */
.brand-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 12px;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: color var(--transition), background var(--transition);
}
.brand-back:hover { color: var(--pm-white); background: var(--bg-hover); }
.brand-back__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-back__mark img { display: block; }
.brand-back__text { flex: 1; }
.brand-back__arrow {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition);
}
.brand-back:hover .brand-back__arrow {
  color: var(--accent);
  transform: translateX(-3px);
}

/* ===== Sidebar header ===== */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.sidebar-search input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  border-left: 2px solid transparent;
}

.room-item:hover {
  background: var(--bg-hover);
}

.room-item.active {
  background: var(--bg-active);
  border-left-color: var(--accent);
}

.room-item-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pm-purple-700) 0%, var(--pm-purple-400) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--pm-white);
  letter-spacing: 0.01em;
}

.room-item-info {
  flex: 1;
  min-width: 0;
}

.room-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.room-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.room-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.room-item-unread {
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--pm-white);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.room-item-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 2px;
}

.room-item:hover .room-item-actions {
  display: flex;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-footer-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ===== Chat area ===== */
#chat-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
}

#chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

#chat-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-badge {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 4px 10px;
  background: var(--pm-purple-900);
  border-radius: var(--radius-pill);
}
.member-badge.visible { display: inline-flex; }

/* ===== Messages container ===== */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

/* ===== Welcome screen (workbook-aligned hero) ===== */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 48px 24px 32px;
  gap: 16px;
  max-width: 640px;
  margin: auto;
}

.welcome-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.welcome-logo {
  width: clamp(140px, 18vw, 200px);
  height: auto;
  filter: drop-shadow(0 0 60px rgba(196, 0, 173, 0.35)) drop-shadow(0 0 120px rgba(196, 0, 173, 0.18));
  animation: welcome-logo-float 8s ease-in-out infinite;
}

@keyframes welcome-logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.welcome-wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 1.4rem + 1.6vw, 2.6rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
  color: var(--pm-white);
}

.welcome-tagline {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  font-style: italic;
}

.welcome .eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: var(--ls-eyebrow);
  color: var(--accent);
  font-weight: 500;
  font-family: var(--font-sans);
  margin-top: 16px;
}

.welcome h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.25rem, 1.5rem + 2vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--pm-white);
}

.welcome p {
  color: var(--text-secondary);
  max-width: 48ch;
  line-height: 1.65;
  font-size: 16px;
}

.welcome-attrs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  list-style: none;
  padding: 0;
  margin: 8px 0 4px;
  max-width: 560px;
}

.welcome-attrs li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color var(--transition), color var(--transition);
}

.welcome-attrs li:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.welcome-attrs li svg {
  color: var(--accent);
  flex-shrink: 0;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.welcome-foot {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.85;
}

.welcome-foot a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.welcome-foot a:hover {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .welcome-logo { animation: none; }
}

/* ============================================================
   Buttons — workbook .btn echoes (pill, gradient hover)
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--pm-white);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--pm-white);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--pm-white);
}

.btn-danger {
  color: var(--error);
  border-color: var(--error);
  background: transparent;
}

.btn-danger:hover {
  background: rgba(255, 123, 156, 0.10);
  color: var(--error);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* Icon-only button (sidebar, composer, header actions) */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
  font-family: inherit;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-send {
  color: var(--accent);
}

.btn-send:hover {
  background: var(--bg-hover);
  color: var(--accent-hover);
}

.btn-icon.recording {
  color: var(--error);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================================
   Form elements
   ============================================================ */

input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

input::placeholder {
  color: var(--text-muted);
}

label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239D9DA6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select:focus {
  border-color: var(--accent);
}

/* ============================================================
   Modal — workbook-aligned (frosted backdrop, ink panel)
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(10, 10, 11, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 22px;
}

.modal-body .form-group {
  margin-bottom: 18px;
}

.modal-body .form-group:last-child {
  margin-bottom: 0;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.form-row > * { flex: 1; }
.form-row .btn { flex: none; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 400;
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: 0;
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.form-actions .btn { flex: 1; }

/* Passphrase display block */
.passphrase-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  word-break: break-all;
}

.passphrase-display .copy-btn {
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.passphrase-display .copy-btn:hover {
  color: var(--text-primary);
}

/* Modal tabs (Create / Join) */
.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.modal-tab:hover { color: var(--text-primary); }

.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Invite modal rows */
.invite-guest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.invite-guest-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-guest-row input {
  flex: 1;
  min-width: 0;
}

.invite-guest-row .btn-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.invite-link-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.invite-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.invite-link-name {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  white-space: nowrap;
  min-width: 60px;
}

.invite-link-url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.invite-link-item .copy-btn {
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color var(--transition);
  display: flex;
  align-items: center;
}

.invite-link-item .copy-btn:hover { color: var(--text-primary); }
.invite-link-item .copy-btn.copied { color: var(--success); }

.btn-add-guest {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--transition);
}

.btn-add-guest:hover { color: var(--accent-hover); }

/* ============================================================
   Toasts
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--bg-modal);
  color: var(--text-primary);
  box-shadow: var(--shadow-modal);
}

.toast-error {
  background: rgba(255, 123, 156, 0.12);
  border-color: var(--error);
  color: var(--error);
}

.toast-success {
  background: rgba(107, 209, 107, 0.12);
  border-color: var(--success);
  color: var(--success);
}

.toast-info {
  background: rgba(196, 0, 173, 0.14);
  border-color: var(--accent);
  color: var(--pm-white);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ============================================================
   Connection banner
   ============================================================ */

.connection-banner {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.connection-banner.connected {
  background: rgba(107, 209, 107, 0.10);
  color: var(--success);
}

.connection-banner.error {
  background: rgba(255, 123, 156, 0.10);
  color: var(--error);
}

/* ============================================================
   Composer
   ============================================================ */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.composer-input-wrap {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  transition: border-color var(--transition), background var(--transition);
}

.composer-input-wrap:focus-within {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

.composer-input-wrap textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
}

.composer-input-wrap textarea::placeholder { color: var(--text-muted); }

/* Scroll-to-bottom FAB */
.btn-scroll-bottom {
  position: absolute;
  bottom: 88px;
  right: 24px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  box-shadow: var(--shadow-modal);
  transition: opacity var(--transition), transform var(--transition), border-color var(--transition);
}

.btn-scroll-bottom:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Attachments preview chips */
.attachments-preview {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-wrap: wrap;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px;
}

.attachment-chip img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
}

.attachment-chip .remove {
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition);
  display: inline-flex;
}

.attachment-chip .remove:hover {
  color: var(--error);
}

/* ============================================================
   Mobile responsive
   ============================================================ */

.mobile-only { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s var(--transition);
  }

  #sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 11, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-only { display: flex; }

  .composer-input-wrap textarea { font-size: 16px; }

  .welcome-actions { flex-direction: column; width: 100%; max-width: 280px; }
  .welcome h2 { font-size: 36px; }
  .welcome { padding: 24px 20px; }
  .welcome-logo { width: 120px; }
  .welcome-attrs li { font-size: 12px; padding: 6px 12px; }
}

/* ============================================================
   Utilities
   ============================================================ */

.hidden { display: none !important; }

/* ============================================================
   Messages — bubbles, voice, files, images
   ============================================================ */

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.message {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  animation: fadeIn 0.2s ease;
}

.message.outgoing { flex-direction: row-reverse; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pm-purple-700) 0%, var(--pm-purple-400) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--pm-white);
}

.message.outgoing .message-avatar {
  background: var(--accent-dim);
  color: var(--accent);
}

.message-bubble {
  max-width: 75%;
  min-width: 80px;
}

.message-sender {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 3px;
  padding: 0 6px;
}

.message.outgoing .message-sender {
  text-align: right;
  color: var(--text-muted);
}

.message-content {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  border: 1px solid transparent;
}

.message.incoming .message-content {
  background: var(--bg-msg-incoming);
  border-color: var(--border);
  border-top-left-radius: 4px;
}

.message.outgoing .message-content {
  background: var(--bg-msg-outgoing);
  border-color: rgba(196, 0, 173, 0.20);
  border-top-right-radius: 4px;
}

.message-text { white-space: pre-wrap; }

.message-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(196, 0, 173, 0.4);
}

.message-text a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.message.incoming .message-time { text-align: left; }

/* System messages — pill */
.system-message {
  text-align: center;
  padding: 10px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.system-message span {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
}

/* ===== Voice messages ===== */

.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-width: 220px;
}

.voice-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: var(--pm-white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.voice-play-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  height: 32px;
  cursor: pointer;
}

.voice-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--text-muted);
  transition: background 0.1s;
  min-height: 4px;
}

.voice-bar.played { background: var(--accent); }

.voice-duration {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 36px;
}

/* ===== File messages ===== */

.file-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-width: 220px;
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-progress {
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.file-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.file-download {
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  transition: color var(--transition);
}

.file-download:hover { color: var(--accent-hover); }

/* ===== Image messages + lightbox ===== */

.image-message {
  max-width: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}

.image-message img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: var(--radius);
}

/* ===== Recording / typing indicators ===== */

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--error);
  font-size: 13px;
  font-weight: 500;
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  animation: pulse 1.5s ease-in-out infinite;
}

.recording-timer {
  font-variant-numeric: tabular-nums;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ============================================================
   Members panel + DM bar
   ============================================================ */

.members-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 140;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s var(--transition);
  pointer-events: none;
  box-shadow: var(--shadow-modal);
}

.members-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

.members-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.members-panel-header h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.members-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  transition: background var(--transition);
}

.member-item:hover {
  background: var(--bg-hover);
}

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pm-purple-700) 0%, var(--pm-purple-400) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--pm-white);
}

.member-avatar.self {
  background: var(--accent-dim);
  color: var(--accent);
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.member-you {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.member-dm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.member-dm-btn:hover {
  background: var(--bg-active);
  color: var(--accent);
}

.members-backdrop {
  position: fixed;
  inset: 0;
  z-index: 139;
  background: rgba(10, 10, 11, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dm-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.dm-bar strong { font-weight: 600; }

.dm-bar .btn-icon {
  width: 26px;
  height: 26px;
  margin-left: auto;
  color: var(--accent);
}

/* DM message tag */
.dm-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  vertical-align: middle;
}

/* ============================================================
   Call bar (group call active)
   ============================================================ */

.call-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(107, 209, 107, 0.08);
  border-bottom: 1px solid rgba(107, 209, 107, 0.2);
  flex-shrink: 0;
}

.call-bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.call-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 1.5s ease-in-out infinite;
}

.call-bar-text {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.call-bar-timer {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.call-bar-participants {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.call-participant-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pm-purple-700) 0%, var(--pm-purple-400) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--pm-white);
  border: 2px solid var(--bg-secondary);
  margin-left: -4px;
  position: relative;
  flex-shrink: 0;
}

.call-participant-avatar:first-child { margin-left: 0; }

.call-participant-avatar.speaking {
  box-shadow: 0 0 0 2px var(--success);
  animation: speakPulse 0.8s ease-in-out infinite alternate;
}

.call-participant-avatar.muted::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  border: 1.5px solid var(--bg-secondary);
}

.call-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.call-control-btn {
  width: 32px;
  height: 32px;
}

.call-control-btn.muted {
  color: var(--error);
}

.btn-call-join {
  background: var(--success);
  border-color: var(--success);
  color: var(--pm-black);
  font-weight: 600;
}

.btn-call-join:hover {
  background: #8DDC8D;
  border-color: #8DDC8D;
  color: var(--pm-black);
}

.btn-icon.in-call {
  color: var(--success);
}

@keyframes speakPulse {
  from { box-shadow: 0 0 0 2px var(--success); }
  to   { box-shadow: 0 0 0 3px rgba(107, 209, 107, 0.4); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
