/* ═══════════════════════════════════════════════════════════════
   Telli Scout — Production UI
   Professional · Modern · Fast · Responsive
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #070f1a;
  --bg-elevated: #0d1b2e;
  --bg-card: #12233a;
  --bg-card-hover: #182f4a;
  --bg-input: #0a1628;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f7fb;
  --text-secondary: #a8b8cc;
  --muted: #6b7f96;
  --primary: #00c853;
  --primary-dim: #00a844;
  --primary-soft: rgba(0, 200, 83, 0.14);
  --accent: #1e88e5;
  --accent-soft: rgba(30, 136, 229, 0.15);
  --danger: #ff5252;
  --danger-soft: rgba(255, 82, 82, 0.14);
  --warning: #ffb300;
  --disabled: #3d4f63;
  --disabled-text: #8a9bb0;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --nav-h: 64px;
  --header-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --max-w: 1200px;
  --transition: 0.18s ease;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a { color: var(--primary); text-decoration: none; }

img, video {
  max-width: 100%;
  display: block;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
}

/* ── Boot ─────────────────────────────────────────────────────── */
.boot-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  background: radial-gradient(ellipse at 50% 20%, #123050 0%, var(--bg) 60%);
}

.boot-logo {
  text-align: center;
}

.boot-ball {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
  animation: bounce 1.2s ease infinite;
}

.boot-logo-img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.65rem;
  border-radius: 50%;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.boot-logo h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ── Layout shells ────────────────────────────────────────────── */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.screen-centered {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at 50% 0%, #123050 0%, var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.auth-card .subtitle {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.brand-row .logo,
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: transparent;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo.logo-sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.admin-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.admin-sidebar .brand .brand-logo {
  width: 36px;
  height: 36px;
}

.brand-row strong {
  font-size: 1.1rem;
  font-weight: 800;
}

/* Legal acceptance (signup + re-accept) */
.legal-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0.85rem 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-secondary);
  user-select: text;
}

.legal-check-row input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.legal-check-text {
  flex: 1;
  min-width: 0;
}

.legal-inline-link {
  display: inline;
  padding: 0;
  margin: 0 0.1em;
  font-size: inherit;
  font-weight: 700;
  vertical-align: baseline;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

.legal-inline-link:hover {
  color: var(--primary-dim, var(--primary));
  text-decoration-thickness: 2px;
}

.legal-version-line {
  font-size: 0.78rem;
  margin: 0 0 0.85rem;
}

/* Full-screen legal document modal */
.legal-modal-backdrop {
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.legal-modal {
  width: min(640px, 96vw);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.legal-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.legal-modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.legal-modal-close {
  flex-shrink: 0;
}

.legal-modal-scroll {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.85rem 1.1rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.legal-modal-actions {
  flex-shrink: 0;
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid var(--border);
  margin: 0;
}

.legal-modal .legal-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.legal-screen .legal-card {
  max-width: min(640px, 96vw);
  max-height: min(90vh, 900px);
  overflow: auto;
}

.legal-title {
  font-size: 1.25rem;
  margin: 0.25rem 0 0.35rem;
}

.legal-version,
.legal-updated {
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}

.legal-intro {
  margin: 0.75rem 0 1rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.legal-section {
  margin-bottom: 1rem;
}

.legal-section h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.legal-section p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
}

button.btn-primary:disabled,
button.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Header ───────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(7, 15, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .icon-btn {
  width: 40px;
  height: 40px;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--nav-h) + var(--safe-bottom) + 1.25rem);
}

.main-content.admin {
  padding-bottom: 1.5rem;
}

/* ── Bottom nav (client) ──────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(13, 27, 46, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.bottom-nav.bottom-nav-5 {
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav.bottom-nav-5 button {
  font-size: 0.62rem;
  padding: 0 0.15rem;
}

.bottom-nav button {
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition);
  position: relative;
}

.bottom-nav button .nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav button.active {
  color: var(--primary);
}

.bottom-nav .badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  display: grid;
  place-items: center;
}

/* ── Admin sidebar layout ─────────────────────────────────────── */
.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100dvh;
}

.admin-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.admin-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.admin-sidebar .brand strong {
  font-weight: 800;
}

.admin-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.admin-nav-btn:hover {
  background: var(--bg-card);
  color: var(--text);
}

.admin-nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Red unread badge — same style as client Messages tab */
.nav-badge,
.admin-msg-badge,
#admin-msg-top-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #ff5252 !important;
  color: #fff !important;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  margin-left: 0.35rem;
  box-shadow: 0 0 0 2px rgba(7, 15, 26, 0.55);
  vertical-align: middle;
}

.nav-badge.hidden,
.admin-msg-badge.hidden,
#admin-msg-top-badge.hidden {
  display: none !important;
}

.admin-nav-btn .admin-msg-badge {
  margin-left: auto;
}

.mobile-admin-nav button {
  position: relative;
}

.mobile-admin-nav .admin-msg-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  margin: 0;
}

#admin-msg-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 15, 26, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.admin-topbar h1 {
  font-size: 1.15rem;
  font-weight: 750;
}

.admin-body {
  padding: 1.25rem;
  max-width: 1100px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.mobile-admin-nav {
  display: none;
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    display: none;
  }
  .mobile-admin-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }
  .mobile-admin-nav button {
    font-size: 0.72rem;
    padding: 0.55rem 0.35rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
  }
  .mobile-admin-nav button.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
  }
}

/* ── Forms ────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

/* Searchable country combobox */
.country-combo {
  position: relative;
}

.country-combo-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.country-combo-list.hidden {
  display: none !important;
}

.country-combo-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.country-combo-option:hover,
.country-combo-option:focus {
  background: var(--primary-soft);
  color: var(--primary);
}

.country-combo-empty {
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Profile picture field + crop editor */
.profile-pic-field {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.profile-pic-preview {
  flex-shrink: 0;
  background: var(--bg-input);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  overflow: hidden;
}

.profile-pic-actions {
  flex: 1;
  min-width: 0;
}

.pic-editor-modal {
  max-width: 420px;
}

.pic-editor-stage {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.pic-editor-viewport {
  position: relative;
  width: min(280px, 80vw);
  height: min(280px, 80vw);
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  touch-action: none;
  cursor: grab;
  border: 2px solid var(--border-strong);
}

.pic-editor-viewport:active {
  cursor: grabbing;
}

.pic-editor-viewport img {
  position: absolute;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

.pic-editor-mask {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(61, 220, 132, 0.45);
  pointer-events: none;
}

.pic-editor-preview-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.pic-editor-preview-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-input) center/cover no-repeat;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

#pic-zoom {
  width: 100%;
  accent-color: var(--primary);
}

/* Country code + phone number row (WhatsApp) */
.phone-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 0;
}

.phone-row .phone-code-combo {
  flex: 0 1 48%;
  max-width: 14rem;
  min-width: 8.5rem;
}

.phone-row .phone-code-search {
  font-size: 0.85rem;
}

.phone-row .phone-number {
  flex: 1 1 auto;
  min-width: 0;
}

.country-combo-option .phone-dial {
  font-weight: 700;
  color: var(--primary);
  margin-inline-end: 0.35rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 420px) {
  .phone-row {
    flex-direction: column;
  }
  .phone-row .phone-code-combo {
    max-width: none;
    width: 100%;
  }
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-group label .req {
  color: var(--danger);
}

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap .password-input {
  padding-right: 2.75rem;
}

.password-eye {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.75;
  border-radius: 8px;
}

.password-eye:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.06);
}

[dir="rtl"] .password-wrap .password-input {
  padding-right: 0.9rem;
  padding-left: 2.75rem;
}

[dir="rtl"] .password-eye {
  right: auto;
  left: 0.45rem;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input[readonly] {
  cursor: default;
  color: var(--muted, inherit);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-error {
  background: var(--danger-soft);
  color: #ff8a80;
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.form-success {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(0, 200, 83, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background var(--transition), opacity var(--transition);
  text-align: center;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  background: var(--disabled) !important;
  color: var(--disabled-text) !important;
  cursor: not-allowed;
  opacity: 0.85;
}

.btn-primary {
  background: var(--primary);
  color: #04140a;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dim);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
}

.danger-zone {
  border: 1px solid rgba(255, 82, 82, 0.35);
  background: rgba(255, 82, 82, 0.06);
}

.danger-zone h3 {
  color: var(--danger);
}

.btn-danger {
  background: var(--danger-soft);
  color: #ff8a80;
  border: 1px solid rgba(255, 82, 82, 0.35);
}

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

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 1rem 1.25rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
}

/* ── Language picker ──────────────────────────────────────────── */
.lang-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), background var(--transition);
}

.lang-btn:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.lang-btn .flag {
  font-size: 1.5rem;
}

.lang-btn strong {
  display: block;
  font-weight: 700;
}

.lang-picker-backdrop {
  z-index: 120;
}

.lang-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.lang-globe {
  font-size: 1.1em;
  line-height: 1;
}

.modal h2 .lang-globe {
  margin-right: 0.25rem;
}

[dir="rtl"] .modal h2 .lang-globe {
  margin-right: 0;
  margin-left: 0.25rem;
}

.lang-btn span {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Player cards / grid ──────────────────────────────────────── */
.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin: 1.25rem 0 0.65rem;
}

/* Client Browse Players — search + filters */
/* Recently added — single compact horizontal strip (never multi-row) */
.recent-players-section {
  margin-bottom: 1rem;
  padding: 0.85rem 0.9rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(0, 200, 83, 0.08), rgba(30, 136, 229, 0.06));
  /* Cap vertical space so main list stays visible */
  max-height: none;
}
.recent-players-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.recent-players-head .muted {
  display: none; /* keep header one line; hint is long */
}
@media (min-width: 700px) {
  .recent-players-head .muted {
    display: block;
  }
}
.recent-players-count {
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
/* One row only; scroll sideways for many players */
.recent-players-strip {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.65rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0.1rem 0.45rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.recent-players-strip::-webkit-scrollbar {
  height: 6px;
}
.recent-players-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 99px;
}
/* Compact card size inside the strip only */
.recent-players-strip .player-card {
  flex: 0 0 148px;
  width: 148px;
  max-width: 148px;
  scroll-snap-align: start;
  margin: 0;
}
.recent-players-strip .player-card-media {
  aspect-ratio: 1 / 1;
  max-height: 110px;
}
.recent-players-strip .player-card-body {
  padding: 0.45rem 0.55rem 0.55rem;
}
.recent-players-strip .player-card-body h3 {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}
.recent-players-strip .player-meta {
  font-size: 0.72rem;
  gap: 0.2rem 0.4rem;
}
.recent-players-strip .player-stats-row {
  display: none; /* hide goals/assists/value in strip to stay short */
}
.recent-players-strip .rank-badge {
  display: none;
}
.recent-players-strip .selection-badge {
  top: 0.35rem;
  right: 0.35rem;
  font-size: 0.6rem;
  padding: 0.15rem 0.35rem;
}
.player-card.is-new {
  box-shadow: 0 0 0 1px rgba(0, 200, 83, 0.35);
}
.new-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 2;
  background: var(--primary);
  color: #04120a;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.browse-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.browse-filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.browse-filters-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.browse-search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
}

.browse-search-wrap .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  pointer-events: none;
}

.browse-search-wrap .input {
  padding-left: 2.4rem;
  width: 100%;
}

[dir="rtl"] .browse-search-wrap .search-icon {
  left: auto;
  right: 0.85rem;
}

[dir="rtl"] .browse-search-wrap .input {
  padding-left: 0.9rem;
  padding-right: 2.4rem;
}

.browse-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.65rem 0.75rem;
}

.browse-filters-grid .form-group {
  margin: 0;
}

.browse-filters-grid label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  display: block;
}

.browse-filters-grid .select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
}

.browse-results-meta {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

#browse-clear:disabled {
  opacity: 0.45;
  cursor: default;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}

.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), background var(--transition);
}

.player-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 200, 83, 0.35);
  background: var(--bg-card-hover);
}

.player-card-media {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #1a3354, #0d1b2e);
  position: relative;
  overflow: hidden;
}

.player-card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.player-card-media .placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  opacity: 0.5;
}

.rank-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: rgba(0, 0, 0, 0.65);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 200, 83, 0.35);
}

.selection-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0.22rem 0.45rem;
  border-radius: 8px;
}

.player-card-body {
  padding: 0.85rem 0.95rem 1rem;
}

.player-card-body h3 {
  font-size: 1.02rem;
  font-weight: 750;
  margin-bottom: 0.2rem;
}

.player-meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
}

.player-meta span::before {
  content: "•";
  margin-right: 0.4rem;
  color: var(--muted);
}

.player-meta span:first-child::before {
  content: none;
  margin: 0;
}

.player-stats-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.mini-stat {
  font-size: 0.78rem;
  color: var(--muted);
}

.mini-stat strong {
  color: var(--text);
  font-weight: 700;
}

/* ── Player profile detail ────────────────────────────────────── */
.profile-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}

/* Facebook-style cover: full photo visible (no crop), blurred fill behind */
.profile-hero-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 420px;
  background: linear-gradient(135deg, #1a3354, #0d1b2e);
  position: relative;
  overflow: hidden;
}

.profile-hero-media .cover-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: blur(28px) brightness(0.55) saturate(1.1);
  transform: scale(1.12);
  z-index: 0;
  pointer-events: none;
}

.profile-hero-media .cover-main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* keep full photo — no cropping */
  object-position: center;
  z-index: 1;
  display: block;
}

.profile-hero-media .placeholder {
  position: relative;
  z-index: 1;
}

.profile-hero-body {
  padding: 1.1rem 1.15rem 1.25rem;
}

.profile-hero-body h2 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.profile-position {
  color: var(--primary);
  font-weight: 700;
  margin-top: 0.15rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

/* Admin-only real name under generated public name */
.admin-real-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  margin: 0.25rem 0 0.15rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 200, 83, 0.1);
  border: 1px solid rgba(0, 200, 83, 0.22);
  max-width: max-content;
}
.admin-real-name-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.admin-real-name-value {
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--text);
}

.field-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
}

.field-item .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.field-item .value {
  font-weight: 650;
  word-break: break-word;
}

.field-item .value.empty {
  color: var(--muted);
}

.media-section {
  margin-top: 1.25rem;
}

.media-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
}

.media-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  user-select: none;
}
.media-tile.is-cover {
  border-color: rgba(0, 200, 83, 0.65);
  box-shadow: 0 0 0 2px rgba(0, 200, 83, 0.35);
}
.media-cover-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 6;
  background: var(--primary);
  color: #04120a;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.media-tile img,
.media-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}

/* Invisible click layer — covers the photo so open always works for admin + client */
.media-open-zone {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.media-play-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  color: white;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 1;
}

.media-tile .media-actions {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.35rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  opacity: 1;
  z-index: 5; /* above open zone so controls stay clickable */
  pointer-events: none; /* bar itself does not block open */
}

.media-tile .media-actions button {
  pointer-events: auto; /* only buttons capture clicks */
}

/* Always-visible delete control (admin) — above open zone */
.media-del-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 6;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 50, 50, 0.92);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, background 0.12s ease;
  pointer-events: auto;
}

.media-del-btn:hover {
  background: #ff1744;
  transform: scale(1.06);
}

.profile-actions {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.5rem;
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 0.75rem);
  z-index: 20;
}

.profile-actions.admin-mode {
  position: static;
}

/* ── Analytics ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 0.25rem;
  color: var(--primary);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

table.data-table th,
table.data-table td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

table.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.2);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Registration codes admin */
.mono-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.status-badge.badge-ok {
  background: var(--primary-soft);
  color: var(--primary);
}
.status-badge.badge-muted {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}
.status-badge.badge-warn {
  background: rgba(255, 179, 0, 0.16);
  color: var(--warning);
}
.status-badge.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.regcodes-table .rc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.regcodes-table th:nth-child(8),
.regcodes-table td.rc-notes-cell {
  min-width: 220px;
  max-width: 340px;
  width: 22%;
}
.rc-notes-btn {
  display: block;
  width: 100%;
  text-align: start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  min-height: 4.5rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.rc-notes-btn:hover {
  border-color: var(--border-strong);
  background: rgba(30, 136, 229, 0.1);
}
.rc-notes-btn.is-empty {
  color: var(--muted);
  font-style: italic;
}
.rc-notes-preview {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.35;
  text-align: start;
}
.rc-notes-textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.45;
}

/* ── Chat ─────────────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 520px;
  background: var(--bg-elevated);
  min-width: 0;
}

@media (max-width: 800px) {
  .chat-layout {
    grid-template-columns: 1fr;
    min-height: 60dvh;
  }
  .chat-layout.thread-open .conv-list {
    display: none;
  }
  .chat-layout:not(.thread-open) .chat-thread {
    display: none;
  }
}

.conv-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conv-search {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.conv-search .input {
  width: 100%;
  font-size: 0.88rem;
  padding: 0.55rem 0.75rem 0.55rem 2.15rem;
}

.conv-search-wrap {
  position: relative;
}

.conv-search-wrap .search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
  pointer-events: none;
  font-size: 0.9rem;
}

.conv-list-items {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.conv-search-empty {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

[dir="rtl"] .conv-search .input {
  padding-left: 0.75rem;
  padding-right: 2.15rem;
}

[dir="rtl"] .conv-search-wrap .search-icon {
  left: auto;
  right: 0.7rem;
}

.conv-item {
  display: flex;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
  border-left: 3px solid transparent;
}

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

/* Clearly show which conversation is open (esp. after search) */
.conv-item.active {
  background: rgba(61, 220, 132, 0.12);
  border-left-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(61, 220, 132, 0.22);
}

.conv-item.active .conv-meta strong {
  color: var(--primary);
}

.conv-item.active .avatar {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 0 0 2px rgba(61, 220, 132, 0.35);
}

.conv-item.is-favorite.active {
  background: rgba(61, 220, 132, 0.14);
}

.conv-item .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.conv-item .conv-meta {
  min-width: 0;
  flex: 1;
}

.conv-item .conv-meta strong {
  display: block;
  font-size: 0.92rem;
}

.conv-item .preview {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-dot {
  min-width: 20px;
  height: 20px;
  border-radius: 99px;
  background: var(--primary);
  color: #04140a;
  font-size: 0.7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  align-self: center;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: 70dvh;
  min-width: 0;
  overflow: hidden;
}

.chat-thread-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 0;
}

.chat-thread-header .header-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-thread-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem;
  opacity: 0.55;
  color: var(--muted);
  transition: opacity var(--transition), transform var(--transition);
}

.fav-btn:hover {
  opacity: 1;
}

.fav-btn.is-fav {
  opacity: 1;
  color: #f5c542;
}

.fav-btn.sm {
  font-size: 0.95rem;
  padding: 0.15rem;
}

.history-toggle {
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.history-toggle.active {
  border-color: var(--primary);
  color: var(--primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.bubble {
  max-width: min(78%, 420px);
  padding: 0.7rem 0.9rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}

.bubble.mine {
  align-self: flex-end;
  background: var(--primary);
  color: #04140a;
  border-bottom-right-radius: 4px;
}

.bubble.theirs {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Message search hit highlight */
mark.msg-search-hit {
  background: #f5c542;
  color: #04140a;
  border-radius: 3px;
  padding: 0 0.15em;
  font-weight: 700;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.bubble.mine mark.msg-search-hit {
  background: #04140a;
  color: #7dffa0;
}

/* Currently selected occurrence while navigating ▲/▼ */
mark.msg-search-hit.msg-search-hit-active {
  background: #ff8c1a;
  color: #0a0a0a;
  box-shadow: 0 0 0 2px rgba(255, 140, 26, 0.85);
}

.bubble.mine mark.msg-search-hit.msg-search-hit-active {
  background: #fff3a0;
  color: #04140a;
  box-shadow: 0 0 0 2px rgba(255, 243, 160, 0.9);
}

.bubble.msg-search-match {
  box-shadow: 0 0 0 2px rgba(245, 197, 66, 0.75);
}

.bubble.msg-search-flash {
  animation: msg-search-flash 1.5s ease;
}

@keyframes msg-search-flash {
  0% {
    box-shadow: 0 0 0 2px rgba(245, 197, 66, 0.9);
    transform: scale(1);
  }
  40% {
    box-shadow: 0 0 0 5px rgba(245, 197, 66, 0.55);
    transform: scale(1.02);
  }
  100% {
    box-shadow: 0 0 0 2px rgba(245, 197, 66, 0.75);
    transform: scale(1);
  }
}

/* Full-width bar under chat header: jump between search hits */
.msg-search-jump {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid rgba(245, 197, 66, 0.35);
  background: linear-gradient(180deg, rgba(245, 197, 66, 0.16), rgba(245, 197, 66, 0.06));
  z-index: 5;
}

.msg-search-jump.hidden {
  display: none !important;
}

.msg-search-jump.no-hits {
  opacity: 0.85;
}

.msg-search-jump-query {
  font-size: 0.82rem;
  font-weight: 650;
  color: #f5c542;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-search-jump-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.msg-search-nav-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(245, 197, 66, 0.45);
  border-radius: 8px;
  background: rgba(10, 22, 40, 0.65);
  color: #f5c542;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.msg-search-nav-btn:hover:not(:disabled) {
  background: rgba(245, 197, 66, 0.22);
  transform: scale(1.05);
}

.msg-search-nav-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.msg-search-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.msg-search-nav-count {
  font-size: 0.85rem;
  font-weight: 800;
  min-width: 2.6rem;
  text-align: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.bubble.deleted-placeholder {
  background: transparent !important;
  border: none !important;
  color: var(--muted);
  font-style: italic;
  opacity: 0.65;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  max-width: min(70%, 360px);
}

.bubble.deleted-placeholder .time {
  display: none;
}

.msg-meta-trace {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-style: italic;
  opacity: 0.55;
  font-weight: 500;
  color: inherit;
}

.bubble.theirs .msg-meta-trace {
  color: var(--muted);
  opacity: 0.85;
}

.bubble.mine .msg-meta-trace {
  color: #04140a;
  opacity: 0.55;
}

.msg-actions {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.35rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.bubble:hover .msg-actions,
.bubble:focus-within .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  background: rgba(0, 0, 0, 0.12);
  border: none;
  border-radius: 6px;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.85;
}

.bubble.theirs .msg-action-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.msg-action-btn:hover {
  opacity: 1;
}

.msg-action-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.msg-translation {
  margin-top: 0.4rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border-left: 3px solid rgba(56, 189, 248, 0.65);
  background: rgba(56, 189, 248, 0.08);
  font-size: 0.86rem;
  line-height: 1.4;
}

.msg-translation.hidden {
  display: none;
}

.bubble.mine .msg-translation {
  border-left-color: rgba(15, 23, 42, 0.35);
  background: rgba(0, 0, 0, 0.1);
}

.bubble.theirs .msg-translation {
  border-left-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.07);
}

.msg-translation-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 0.2rem;
}

.msg-translation-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-original-box {
  margin-top: 0.45rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  font-size: 0.8rem;
  opacity: 0.8;
}

.bubble.mine .msg-original-box {
  border-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.08);
}

.bubble.theirs .msg-original-box {
  background: rgba(255, 255, 255, 0.03);
}

.msg-original-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  margin-bottom: 0.2rem;
}

.msg-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.25rem;
  /* Do not inherit bubble text color (green mine = dark text) */
  color: var(--text);
}

.msg-edit-form .input,
.msg-edit-form .msg-edit-input,
.bubble.mine .msg-edit-form .input,
.bubble.theirs .msg-edit-form .input {
  width: 100%;
  font-size: 0.9rem;
  color: #f4f7fb !important;
  background: #0a1628 !important;
  border: 1px solid var(--border-strong) !important;
  caret-color: #f4f7fb !important;
  -webkit-text-fill-color: #f4f7fb !important;
}

.msg-edit-form .input::placeholder {
  color: var(--muted);
  opacity: 0.85;
  -webkit-text-fill-color: var(--muted);
}

.msg-edit-form .input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px var(--primary-soft);
}

/* Buttons inside green "mine" bubbles must stay readable */
.msg-edit-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

.bubble.mine .msg-edit-form .btn-primary {
  background: #04140a;
  color: var(--primary);
  border: none;
}

.bubble.mine .msg-edit-form .btn-secondary {
  background: rgba(4, 20, 10, 0.2);
  color: #04140a;
  border: 1px solid rgba(4, 20, 10, 0.35);
}

.bubble.theirs .msg-edit-form .btn-primary {
  /* default primary is fine */
}

.bubble.theirs .msg-edit-form .btn-secondary {
  color: var(--text-secondary);
}

.bubble img,
.bubble video {
  border-radius: 8px;
  margin-bottom: 0.35rem;
  max-height: 220px;
  max-width: 100%;
  display: block;
}

.bubble .chat-media-img {
  cursor: pointer;
}

.bubble .chat-link {
  color: inherit;
  text-decoration: underline;
  font-weight: 650;
  word-break: break-all;
}

.bubble.mine .chat-link {
  color: #04140a;
}

.bubble.theirs .chat-link {
  color: var(--primary);
}

.chat-client-name {
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  text-align: left;
}

.chat-client-name:hover {
  text-decoration: underline;
}

.chat-attach-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.chat-attach-preview.hidden {
  display: none !important;
}

.chat-attach-preview-inner {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.chat-preview-media {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  background: #000;
  flex-shrink: 0;
}

video.chat-preview-media {
  object-fit: contain;
}

.chat-preview-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-composer .icon-btn {
  flex-shrink: 0;
}

.chat-call-btn {
  font-size: 1.05rem;
}

/* ── Live audio / video call overlay ─────────────────────────────────────── */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(4, 10, 20, 0.72);
  backdrop-filter: blur(6px);
}

.call-panel {
  width: min(420px, 100%);
  border-radius: 18px;
  background: linear-gradient(160deg, #0f1c2e 0%, #15253a 55%, #0c1624 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  padding: 1.25rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  position: relative;
  overflow: hidden;
}

.call-panel.is-video {
  width: min(720px, 100%);
  max-height: 92vh;
}

.call-remote-stage {
  width: 100%;
  aspect-ratio: 1;
  max-height: 280px;
  border-radius: 16px;
  background: #050b14;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.call-panel.is-video .call-remote-stage {
  aspect-ratio: 16 / 10;
  max-height: min(52vh, 420px);
}

.call-remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.call-remote-video.hidden,
.call-local-video.hidden,
.call-avatar.hidden {
  display: none !important;
}

.call-remote-audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.call-local-video {
  position: absolute;
  right: 1.1rem;
  bottom: 5.5rem;
  width: 110px;
  height: 150px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: #000;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.call-panel.is-video .call-local-video {
  bottom: 6.2rem;
}

.call-avatar {
  font-size: 3.5rem;
  opacity: 0.9;
  animation: call-pulse 1.6s ease-in-out infinite;
}

@keyframes call-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

.call-meta {
  text-align: center;
  width: 100%;
}

.call-peer-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f4f7fb;
}

.call-status {
  margin-top: 0.25rem;
  font-size: 0.92rem;
  color: rgba(244, 247, 251, 0.72);
}

.call-duration {
  margin-top: 0.15rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: rgba(56, 189, 248, 0.95);
  min-height: 1.1em;
}

.call-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  width: 100%;
  margin-top: 0.25rem;
}

.call-actions .btn {
  min-width: 7.5rem;
}

.call-btn-hangup,
.call-btn-decline {
  background: #c0392b !important;
  border-color: #c0392b !important;
  color: #fff !important;
}

.call-btn-accept {
  background: #1e9e5a !important;
  border-color: #1e9e5a !important;
  color: #fff !important;
}

/* Photo / video source menu (device vs camera) */
.chat-media-source-menu {
  position: fixed;
  z-index: 1200;
  min-width: 200px;
  padding: 0.35rem;
  border-radius: 12px;
  background: var(--bg-elevated, #132033);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-media-source-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text, #f4f7fb);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

.chat-media-source-item:hover,
.chat-media-source-item:focus-visible {
  background: rgba(56, 189, 248, 0.12);
  outline: none;
}

.chat-media-source-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* In-app camera capture modal */
.camera-modal-bg {
  z-index: 1300;
}

.camera-modal {
  width: min(520px, 96vw);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem 1rem 1rem;
}

.camera-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.camera-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: min(55vh, 420px);
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.camera-preview,
.camera-photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.camera-preview[controls] {
  object-fit: contain;
}

.camera-snapshot {
  display: none;
}

.camera-rec-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

.camera-rec-badge.hidden {
  display: none !important;
}

.camera-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.6);
  animation: camera-rec-pulse 1.2s ease infinite;
}

@keyframes camera-rec-pulse {
  0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.camera-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.camera-shutter {
  min-width: 9rem;
}

.camera-shutter.is-recording {
  background: #c0392b;
  border-color: #c0392b;
}

.camera-hint {
  margin: 0;
  font-size: 0.78rem;
  text-align: center;
}

.bubble .time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
  font-size: 0.7rem;
  opacity: 0.85;
}

.bubble.theirs .time {
  justify-content: flex-start;
}

.msg-time-text {
  opacity: 0.85;
}

/* Read receipts — only on your own messages */
.msg-receipt {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}

.msg-receipt-ticks {
  font-size: 0.72rem;
  letter-spacing: -0.08em;
}

.msg-receipt.is-sent {
  opacity: 0.65;
}

.msg-receipt.is-seen {
  opacity: 1;
}

.bubble.mine .msg-receipt.is-sent {
  color: rgba(4, 20, 10, 0.65);
}

.bubble.mine .msg-receipt.is-seen {
  color: #0b3d1f;
}

.bubble.mine .msg-receipt.is-seen .msg-receipt-ticks {
  color: #064e22;
}

.msg-receipt-label {
  font-weight: 650;
  text-transform: none;
}

.chat-voice-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--border);
  background: rgba(220, 60, 60, 0.08);
  flex-shrink: 0;
}

.chat-voice-bar.hidden {
  display: none !important;
}

.chat-voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  flex-shrink: 0;
  animation: voice-pulse 1s ease infinite;
}

@keyframes voice-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.85);
  }
}

.chat-voice-label {
  font-size: 0.85rem;
  font-weight: 650;
  color: #e74c3c;
}

.chat-voice-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 2.5rem;
}

.chat-composer .icon-btn.is-recording {
  background: rgba(231, 76, 60, 0.25);
  color: #e74c3c;
  box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.45);
}

.chat-preview-voice {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1;
}

.chat-preview-voice-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.chat-preview-voice-player {
  flex: 1;
  min-width: 0;
}

.chat-voice-msg {
  margin-bottom: 0.35rem;
  min-width: 0;
  width: 100%;
}

/* Custom voice player — seek + speed */
.voice-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: min(240px, 100%);
  max-width: 320px;
  user-select: none;
}

.voice-player-audio {
  display: none;
}

.voice-player-play {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
}

.bubble.theirs .voice-player-play {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.bubble.mine .voice-player-play {
  background: rgba(4, 20, 10, 0.2);
  color: #04140a;
}

.voice-player-play:hover {
  filter: brightness(1.1);
}

.voice-player-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.voice-player-seek {
  position: relative;
  height: 22px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.voice-player-seek-track {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.18);
  overflow: visible;
}

.bubble.theirs .voice-player-seek-track {
  background: rgba(255, 255, 255, 0.14);
}

.voice-player-seek-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 99px;
  background: var(--primary);
  pointer-events: none;
}

.bubble.mine .voice-player-seek-fill {
  background: #04140a;
}

.voice-player-seek-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.08s ease;
}

.bubble.mine .voice-player-seek-thumb {
  background: #04140a;
}

.voice-player-seek:hover .voice-player-seek-thumb,
.voice-player-seek:active .voice-player-seek-thumb {
  transform: scale(1.15);
}

.voice-player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}

.voice-player-time {
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
  white-space: nowrap;
}

.voice-player-speeds {
  display: inline-flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.voice-speed-btn {
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.12rem 0.4rem;
  cursor: pointer;
  line-height: 1.2;
  opacity: 0.75;
}

.bubble.theirs .voice-speed-btn {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.voice-speed-btn:hover {
  opacity: 1;
}

.voice-speed-btn.active {
  opacity: 1;
  background: var(--primary);
  border-color: var(--primary);
  color: #04140a;
}

.bubble.mine .voice-speed-btn.active {
  background: #04140a;
  border-color: #04140a;
  color: var(--primary);
}

.chat-preview-voice .voice-player {
  max-width: none;
}

.chat-preview-voice .voice-player-play {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.chat-preview-voice .voice-player-seek-track {
  background: rgba(255, 255, 255, 0.14);
}

.chat-preview-voice .voice-player-seek-fill,
.chat-preview-voice .voice-player-seek-thumb {
  background: var(--primary);
}

.chat-preview-voice .voice-speed-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #04140a;
}

/* Reply / emoji / reactions / forward */
.chat-reply-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: rgba(61, 220, 132, 0.08);
  flex-shrink: 0;
}

.chat-reply-bar.hidden {
  display: none !important;
}

.chat-reply-bar-body {
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--primary);
  padding-left: 0.55rem;
}

.chat-reply-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
}

.chat-reply-bar-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emoji-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.55rem 0.65rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  max-height: 260px;
  overflow-y: auto;
  flex-shrink: 0;
}

.emoji-picker.hidden {
  display: none !important;
}

.emoji-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.15rem 0.1rem;
}

.emoji-section-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.2rem;
}

.emoji-pick-btn {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.25rem;
  line-height: 1.2;
}

.emoji-pick-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.msg-forwarded-label {
  font-size: 0.72rem;
  font-weight: 650;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

.msg-reply-quote {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.bubble.theirs .msg-reply-quote {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--primary);
}

.msg-reply-quote strong {
  display: block;
  font-size: 0.72rem;
  margin-bottom: 0.1rem;
  opacity: 0.85;
}

.msg-reply-quote span {
  font-size: 0.8rem;
  opacity: 0.85;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.35rem;
  min-height: 0;
}

.msg-reaction-chip {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: inherit;
  line-height: 1.3;
}

.bubble.theirs .msg-reaction-chip {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.msg-reaction-chip.mine-react {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(61, 220, 132, 0.35);
}

.msg-react-picker {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.35rem;
  padding: 0.4rem;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  max-width: 280px;
  max-height: 220px;
  overflow-y: auto;
}

.msg-react-picker.hidden {
  display: none !important;
}

.msg-react-picker .emoji-section-grid {
  grid-template-columns: repeat(8, 1fr);
}

.forward-list {
  max-height: 50dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
}

.forward-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--bg-card);
}

.forward-row:hover {
  border-color: var(--primary);
}

.forward-row input {
  width: 16px;
  height: 16px;
}

.chat-composer {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

.chat-composer .input {
  flex: 1 1 auto;
  min-width: 0;
  width: 0; /* force flex shrink so Send stays visible in narrow admin pane */
}

.chat-composer .btn {
  flex: 0 0 auto;
  white-space: nowrap;
  padding-left: 0.9rem;
  padding-right: 0.9rem;
}

.chat-composer .icon-btn {
  flex: 0 0 auto;
}

.conv-item .conv-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  align-self: center;
}

.conv-item.is-favorite {
  background: rgba(245, 197, 66, 0.06);
}

.client-fav-cell {
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* ── Search ───────────────────────────────────────────────────── */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}

.search-bar .input {
  padding-left: 2.5rem;
}

.search-bar .search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.55;
}

/* ── Profile settings ─────────────────────────────────────────── */
.avatar-lg {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  object-fit: cover;
  display: grid;
  place-items: center;
  font-size: 2rem;
  overflow: hidden;
}

.avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* Contact Us (client profile) */
.contact-us-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: none;
  border: none;
  padding: 0.15rem 0;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}

.contact-us-title {
  font-size: 1.05rem;
  font-weight: 750;
}

.contact-us-chevron {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.contact-us-toggle.is-open .contact-us-chevron {
  color: var(--primary);
}

.contact-us-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.contact-us-hint {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
}

.contact-us-email {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  word-break: break-all;
  user-select: text;
  cursor: default;
  pointer-events: none;
}

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}

.modal h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

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

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

/* ── Utilities ────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.text-secondary { color: var(--text-secondary); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 650;
  cursor: pointer;
  padding: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.75rem 1.1rem;
  border-radius: 99px;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 0.9rem;
  animation: slideUp 0.2s ease;
  max-width: 90vw;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 4rem;
}

.lightbox-stage {
  max-width: min(96vw, 1100px);
  max-height: 88dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img,
.lightbox video {
  max-width: 100%;
  max-height: 88dvh;
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 5;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.2rem;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.lightbox-nav:hover {
  background: rgba(0, 200, 83, 0.35);
  transform: translateY(-50%) scale(1.05);
}

.lightbox-prev {
  left: 0.75rem;
}

.lightbox-next {
  right: 0.75rem;
}

.lightbox-counter {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 650;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.35rem 0.75rem;
  border-radius: 99px;
}

@media (max-width: 640px) {
  .lightbox {
    padding: 1rem 3rem;
  }
  .lightbox-nav {
    width: 42px;
    height: 42px;
    font-size: 1.6rem;
  }
}

/* RTL */
[dir="rtl"] .bottom-nav .badge {
  right: auto;
  left: calc(50% - 22px);
}

[dir="rtl"] .search-bar .input {
  padding-left: 0.9rem;
  padding-right: 2.5rem;
}

[dir="rtl"] .search-bar .search-icon {
  left: auto;
  right: 0.9rem;
}
