/* ============================================================
   Hackley Clubz — Application Stylesheet
   
   Font stack:
     BD Megalona Extra Light  → titles, prompts, bold/italic emphasis
     BB Noname Pro Regular    → body, UI text
   
   Color palette (change these variables to retheme):
     --coral       vibrant coral/orange for primary CTAs
     --purple-dark dark blue/purple gradient partner
     --accent-blue #038BFF  "next" / primary action buttons
   ============================================================ */

/* ============================================================
   0. Custom Fonts
   ============================================================ */
/* BD Megalona Extra Light — place font files in public/fonts/ to enable */
@font-face {
  font-family: 'BD Megalona';
  /* Uncomment when font files are placed in public/fonts/:
  src: url('/public/fonts/BDMegalona-ExtraLight.woff2') format('woff2'),
       url('/public/fonts/BDMegalona-ExtraLight.woff')  format('woff');
  */
  src: local('');   /* no-op until files are present; falls back to Georgia */
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}

/* BB Noname Pro Regular — place font files in public/fonts/ to enable */
@font-face {
  font-family: 'BB Noname Pro';
  /* Uncomment when font files are placed in public/fonts/:
  src: url('/public/fonts/BBNonamePro-Regular.woff2') format('woff2'),
       url('/public/fonts/BBNonamePro-Regular.woff')  format('woff');
  */
  src: local('');   /* no-op until files are present; falls back to system-ui */
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   1. CSS Custom Properties (Design Tokens)
   ============================================================ */
:root {
  /* Brand palette */
  --coral:          #FF6B47;
  --coral-light:    #FF8E72;
  --purple-dark:    #2D1B69;
  --purple-mid:     #4A2FA0;
  --accent-blue:    #038BFF;
  --accent-blue-hover: #0275d8;

  /* Gradient (used for hero areas, splash) */
  --gradient-brand: linear-gradient(135deg, var(--coral) 0%, var(--purple-dark) 100%);

  /* UI neutrals */
  --white:          #FFFFFF;
  --bg:             #F8F8FA;
  --surface:        #FFFFFF;
  --border:         #E2E2E8;
  --border-light:   #F0F0F5;

  /* Text */
  --text-primary:   #1A1A2E;
  --text-secondary: #6B6B80;
  --text-muted:     #9999AA;

  /* Feedback */
  --success:        #2ECC71;
  --success-bg:     #EAFAF1;
  --error:          #E74C3C;
  --error-bg:       #FDEDEC;
  --info:           #3498DB;
  --info-bg:        #EBF5FB;

  /* Pinned messages (matches iOS clubzPinGreen) */
  --pin-green:      #22C55E;

  /* Pastel chat-bubble accents */
  --bubble-sent:    #E8F4FD;
  --bubble-recv:    #F5F0FF;

  /* Typography */
  --font-title:     'BD Megalona', Georgia, serif;
  --font-body:      'BB Noname Pro', system-ui, -apple-system, sans-serif;

  /* Spacing */
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      20px;
  --shadow:         0 2px 12px rgba(0,0,0,.08);
  --shadow-md:      0 4px 24px rgba(0,0,0,.12);
  --shadow-lg:      0 8px 40px rgba(0,0,0,.16);

  /* Layout */
  --sidebar-width:  68px;
  --panel-width:    280px;
}

/* ============================================================
   2. Reset / Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

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

ul, ol { list-style: none; }

/* ============================================================
   3. Typography
   ============================================================ */

/* All headings use BD Megalona */
h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-weight: 200;
  line-height: 1.25;
  color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

/* Wizard prompts / page-question style */
.prompt {
  font-family: var(--font-title);
  font-weight: 200;
  font-size: 1.75rem;
  color: var(--text-primary);
  line-height: 1.3;
}

/* The "bold and italic" emphasis pattern: BD Megalona Extra Light, bold+italic */
.prompt strong, .prompt em {
  font-family: var(--font-title);
  font-weight: bold;
  font-style: italic;
  color: var(--purple-dark);
}

/* ============================================================
   4. Form Elements
   ============================================================ */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(3,139,255,.15);
}

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

/* Password field wrapper (for eye toggle) */
.input-wrapper {
  position: relative;
}
.input-wrapper input {
  padding-right: 44px;
}
.input-eye-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
}
.input-eye-btn:hover { color: var(--text-secondary); }

/* ============================================================
   5. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  cursor: pointer;
  border: none;
  transition: background .2s, transform .1s, box-shadow .2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.98); }

/* Primary "Next" / action button — always #038BFF */
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-blue-hover);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(3,139,255,.35);
}

/* Secondary / ghost */
.btn-secondary {
  background: transparent;
  color: var(--accent-blue);
  border: 1.5px solid var(--accent-blue);
}
.btn-secondary:hover {
  background: rgba(3,139,255,.06);
  text-decoration: none;
}

/* Danger */
.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover {
  background: #c0392b;
  color: #fff;
  text-decoration: none;
}

/* Full-width helper */
.btn-block { width: 100%; }

/* ============================================================
   6. Flash / Alert Messages
   ============================================================ */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.flash--success { background: var(--success-bg); color: #1a7a45; border-left: 4px solid var(--success); }
.flash--error   { background: var(--error-bg);   color: #922b21; border-left: 4px solid var(--error); }
.flash--info    { background: var(--info-bg);     color: #1a5276; border-left: 4px solid var(--info); }

/* ── Announcement banner (set via Admin → Settings) ────────────────────── */
.announcement-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fff5f0 0%, #fff0f8 100%);
  border: 1px solid #f4a57a;
  border-left: 4px solid var(--coral, #f4643c);
  border-radius: var(--radius);
  font-size: 0.925rem;
  color: #7a2e10;
  line-height: 1.5;
}
.announcement-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.announcement-text {
  flex: 1;
  white-space: pre-wrap;   /* preserve line breaks from the textarea */
}

/* ============================================================
   7. Splash / Login Screens
   ============================================================ */
.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--gradient-brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
  text-align: center;
}

.splash-quote {
  font-family: var(--font-title);
  font-weight: 200;
  font-style: italic;
  font-size: clamp(1.25rem, 4vw, 2rem);
  color: #fff;
  max-width: 520px;
  opacity: 0;
  transition: opacity .8s ease;
}
.splash-quote.visible { opacity: 1; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.auth-logo img {
  max-height: 56px;
  max-width: 200px;
  object-fit: contain;
}
.auth-logo .app-name {
  font-family: var(--font-title);
  font-weight: 200;
  font-size: 1.75rem;
  color: var(--purple-dark);
  letter-spacing: .02em;
}

.auth-title {
  font-family: var(--font-title);
  font-weight: 200;
  font-size: 1.5rem;
  margin-bottom: 24px;
  text-align: center;
  color: var(--text-primary);
}

.auth-footer-links {
  margin-top: 20px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.auth-footer-links a {
  color: var(--accent-blue);
  margin: 0 8px;
}

/* ============================================================
   8. Wizard / Step Indicator
   ============================================================ */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.wizard-step {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s, transform .2s;
}
.wizard-step.active {
  background: var(--accent-blue);
  transform: scale(1.3);
}
.wizard-step.done {
  background: var(--success);
}

.wizard-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ============================================================
   9. App Shell (main authenticated layout)
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar (Full Width mode header) ────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 60;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  box-shadow: var(--shadow);
}

.topbar-nav-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.topbar-nav-btn:hover {
  box-shadow: var(--shadow-md);
  transform: scale(1.05);
}
.topbar-nav-btn img,
.topbar-nav-btn > div {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ── Left icon rail ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 8px;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  transition: background .15s, color .15s;
  text-decoration: none;
  font-size: 20px;
}
.sidebar-icon-btn:hover,
.sidebar-icon-btn.active {
  background: var(--border-light);
  color: var(--purple-dark);
}

/* Collapse-to-full-width button in the sidebar */
.sidebar-collapse-btn {
  color: var(--text-muted);
  opacity: .7;
}
.sidebar-collapse-btn:hover {
  opacity: 1;
  background: var(--border-light);
  color: var(--purple-dark);
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color .15s;
}
.sidebar-avatar:hover { border-color: var(--accent-blue); }

.sidebar-spacer { flex: 1; }

/* ── Club panel ──────────────────────────────────────────────────────────── */
.club-panel {
  width: var(--panel-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  transition: width .3s ease;
  display: flex;
  flex-direction: column;
}

.club-panel.collapsed { width: 28px; }
.club-panel.collapsed .club-panel-title { display: none; }
.club-panel.collapsed .club-panel-body  { display: none; }

.club-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 10px;
  gap: 8px;
  flex-shrink: 0;
  min-height: 44px;
}

.club-panel-title {
  font-family: var(--font-title);
  font-weight: 200;
  font-size: 0.95rem;
  color: var(--text-secondary);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}

.club-panel-toggle {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s, transform .3s ease;
  padding: 0;
}
.club-panel-toggle:hover {
  background: var(--border-light);
  color: var(--purple-dark);
}
.club-panel.collapsed .club-panel-toggle { transform: rotate(180deg); }
.club-panel.collapsed .club-panel-header {
  padding: 14px 1px 10px;
  justify-content: center;
}

.club-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 20px;
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ── Full Width mode (default; no .nav-menu class on .app-shell) ─────────── */
/* Topbar visible, sidebar hidden, main content offset below topbar          */
.app-shell:not(.nav-menu) .topbar        { display: flex; }
.app-shell:not(.nav-menu) .sidebar       { display: none; }
.app-shell:not(.nav-menu) .main-content  { padding-top: 72px; }

/* ── Menu Layout mode (.nav-menu class on .app-shell) ────────────────────── */
/* Sidebar visible, topbar hidden, content at normal padding                 */
.app-shell.nav-menu .topbar        { display: none; }
.app-shell.nav-menu .sidebar       { display: flex; }
.app-shell.nav-menu .main-content  { padding-top: 32px; }

/* ============================================================
   10. Profile Photo (circle avatar)
   ============================================================ */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
  max-width: none;
}
.avatar-sm  { width: 32px;  height: 32px; }
.avatar-md  { width: 48px;  height: 48px; }
.avatar-lg  { width: 72px;  height: 72px; }
.avatar-xl  { width: 120px; height: 120px; }

/* Placeholder when no photo */
.avatar-placeholder {
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 200;
  flex-shrink: 0;
}
.avatar-placeholder.avatar-sm  { width: 32px;  height: 32px;  font-size: 12px; }
.avatar-placeholder.avatar-md  { width: 48px;  height: 48px;  font-size: 16px; }
.avatar-placeholder.avatar-lg  { width: 72px;  height: 72px;  font-size: 24px; }
.avatar-placeholder.avatar-xl  { width: 120px; height: 120px; font-size: 36px; }

/* ============================================================
   11. Photo Cropper (step 5 of wizard)
   ============================================================ */
.photo-crop-wrapper {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--border);
  border: 2px solid var(--border);
}
.photo-crop-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.photo-upload-area:hover,
.photo-upload-area.drag-over {
  border-color: var(--accent-blue);
  background: rgba(3,139,255,.04);
}

/* ============================================================
   12. Page-level utility classes
   ============================================================ */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); font-size: 0.875rem; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.gap-2 { gap: 8px; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.skip-link {
  display: block;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 12px;
}
.skip-link:hover { color: var(--text-primary); }

/* ============================================================
   13. Admin Panel & Utilities
   ============================================================ */

/* Admin / club panels.
   Desktop (≥ 769px + nav-menu): static flex item — pushes main content right.
   Desktop (≥ 769px, full-width mode): hidden via panel-hidden.
   Mobile (≤ 768px): fixed overlay drawer. */
.admin-panel {
  width: var(--panel-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow-y: auto;
  z-index: 50;
  display: flex;
  flex-direction: column;
  /* Desktop default: in-flow flex item (pushes content) */
  position: static;
  flex-shrink: 0;
}

/* Nav links inside the admin panel */
.admin-panel-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 0;
  display: flex;
  flex-direction: column;
}

.admin-panel-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.admin-panel-link:hover,
.admin-panel-link.active {
  background: var(--border-light);
  color: var(--purple-dark);
  text-decoration: none;
}

.admin-panel-link svg {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color .15s;
}

.admin-panel-link:hover svg,
.admin-panel-link.active svg {
  color: var(--purple-dark);
}

/* Hide a panel without taking up layout space */
.panel-hidden {
  display: none !important;
}

/* ── Join more chats (club panel inline list) ─────────────────────────── */
.joinable-area {
  border-top: 1px solid var(--border);
  padding: 2px 0;
}

.joinable-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-blue);
  padding: 4px 0;
  transition: color .15s;
}

.joinable-toggle:hover {
  color: var(--accent-blue-hover);
}

.joinable-toggle svg {
  flex-shrink: 0;
}

.joinable-status {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 8px;
  margin: 0;
}

.joinable-status.error {
  color: #DC2626;
}

.joinable-conv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-light);
}

.joinable-conv-row:last-child {
  border-bottom: none;
}

.joinable-conv-row .joinable-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  color: var(--text-primary);
}

.joinable-conv-row .joinable-name svg {
  flex-shrink: 0;
  color: var(--purple-dark);
}

.joinable-conv-row .joinable-name .joinable-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.joinable-conv-row form {
  margin: 0;
  flex-shrink: 0;
}

.joinable-conv-row .btn {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
}

/* ============================================================
   14. Admin Log Tables
   ============================================================ */

.admin-page {
  max-width: 1200px;
}

.admin-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.admin-subnav a {
  display: inline-block;
  padding: 8px 18px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: none;
}

.admin-subnav a:hover {
  background: var(--border-light);
  color: var(--text-primary);
  text-decoration: none;
}

.admin-subnav a.active {
  background: var(--surface);
  color: var(--purple-dark);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  font-weight: 500;
}

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

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.log-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

.log-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.log-table tr:last-child td { border-bottom: none; }
.log-table tr:hover td      { background: var(--bg); }

.log-ts {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.log-meta code {
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.action-badge {
  display: inline-block;
  font-size: 0.72rem;
  background: var(--border-light);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--purple-mid);
  white-space: nowrap;
  font-family: var(--font-body);
}

.status-success { color: #1a7a45; font-size: 0.875rem; }
.status-failed  { color: var(--error); font-size: 0.875rem; }

/* Typeahead dropdown (admin log user-filter) */
.typeahead-dropdown {
  position: absolute;
  z-index: 100;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 2px;
}

.typeahead-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.15s ease;
}

.typeahead-item:last-child {
  border-bottom: none;
}

.typeahead-item:hover,
.typeahead-item.selected {
  background: rgba(3, 139, 255, 0.05);
  text-decoration: none;
}

.typeahead-item:active {
  background: rgba(3, 139, 255, 0.1);
}

.typeahead-item small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Type-ahead search results */
.typeahead-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 4px;
}

/* ============================================================
   15. Club Browse / Discovery Page
   ============================================================ */

/* Vertical list of club cards */
.club-browse-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.club-browse-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}

.club-browse-card:last-child { border-bottom: none; }
.club-browse-card:hover       { background: var(--bg); }

.club-browse-photo-link {
  flex-shrink: 0;
  text-decoration: none;
}

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

.club-browse-action {
  flex-shrink: 0;
}

/* View-toggle buttons (top-right of the browse header) */
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s, color .15s, border-color .15s;
}
.view-toggle-btn:hover  { background: var(--bg); }
.view-toggle-btn.active {
  color: var(--purple-dark);
  border-color: var(--purple-mid);
  background: var(--bg);
}
/* Tile view isn't offered on narrow screens — list is forced there. */
@media (max-width: 599px) {
  #view-toggle { display: none; }
}

/* "See More" load-more button wrapper */
.see-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

/* Calendar scope toggle (My Club / All Club) — soft segmented control */
.cal-scope-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
}
.cal-scope-btn {
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.cal-scope-btn:hover { color: var(--text-primary); text-decoration: none; }
/* Active = white pill that lifts off the track (no heavy gradient). */
.cal-scope-btn.active {
  background: var(--surface);
    color: #478fd7;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

/* Calendar page header */
.cal-header { text-align: center; margin-bottom: 32px; }
.cal-header-badge {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bubble-recv);
  color: var(--purple-mid);
}
.cal-header-title {
  font-family: var(--font-title);
  font-weight: 200;
  font-size: 2rem;
  margin: 0 0 6px;
  color: var(--text-primary);
}
.cal-header-sub {
  font-size: 1.05rem;
  font-weight: 600;
  color: #A54D74;
  letter-spacing: .01em;
  line-height: 1.4;
  margin: 0;
}

/* Photo sizing — moved off inline styles so each view can size it. */
.club-browse-photo-link .avatar,
.club-browse-photo-link .avatar-placeholder { width: 60px; height: 60px; }
.club-browse-photo-link .avatar-placeholder { font-size: 24px; }

/* List view (default) — hide the tile-only mission text. */
.club-browse-grid.view-list .club-browse-mission { display: none; }

/* Tile view — cards wrap to fill the viewport width. */
.club-browse-grid.view-tile {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 16px;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.club-browse-grid.view-tile .club-browse-card {
  flex-direction: column;
  align-items: center;
  width: 240px;
  height: 380px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.club-browse-grid.view-tile .club-browse-card:hover { background: var(--surface); }
/* List-only elements hidden in tile view. */
.club-browse-grid.view-tile .club-browse-meeting,
.club-browse-grid.view-tile .club-browse-desc { display: none; }
/* Larger, square image. */
.club-browse-grid.view-tile .club-browse-photo-link .avatar,
.club-browse-grid.view-tile .club-browse-photo-link .avatar-placeholder {
  width: 160px;
  height: 160px;
  border-radius: var(--radius);
}
.club-browse-grid.view-tile .club-browse-photo-link .avatar-placeholder { font-size: 56px; }
.club-browse-grid.view-tile .club-browse-info {
  flex: 0 0 auto;
  width: 100%;
  margin-top: 12px;
}
.club-browse-grid.view-tile .club-browse-action { margin-top: auto; }
.club-browse-mission {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 8px;
  overflow: hidden;
}

/* ============================================================
   16. Club Description (Markdown-rendered)
   ============================================================ */
.club-description {
  color: var(--text-primary);
  line-height: 1.65;
}
.club-description p            { margin: 0 0 12px; }
.club-description p:last-child { margin-bottom: 0; }

.club-description h1,
.club-description h2,
.club-description h3,
.club-description h4 {
  font-family: var(--font-title);
  font-weight: 200;
  color: var(--text-primary);
  margin: 20px 0 8px;
  line-height: 1.25;
}
.club-description h1:first-child,
.club-description h2:first-child,
.club-description h3:first-child { margin-top: 0; }
.club-description h1 { font-size: 1.5rem; }
.club-description h2 { font-size: 1.25rem; }
.club-description h3 { font-size: 1.05rem; }

.club-description strong { font-weight: 700; }
.club-description em     { font-style: italic; }

.club-description a       { color: var(--accent-blue); text-decoration: underline; }
.club-description a:hover { color: var(--accent-blue-hover); }

.club-description ul,
.club-description ol  { margin: 0 0 12px 20px; padding: 0; }
.club-description li  { margin-bottom: 4px; }

.club-description blockquote {
  border-left: 3px solid var(--border);
  margin: 0 0 12px;
  padding: 6px 16px;
  color: var(--text-secondary);
}
.club-description blockquote p { margin: 0; }

.club-description img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  display: block;
  margin: 12px auto;
}

.club-description code {
  background: var(--border-light);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.875em;
  font-family: monospace;
}
.club-description pre {
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.club-description pre code { background: none; padding: 0; }

.club-description table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 0.9rem;
}
.club-description th,
.club-description td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.club-description th { background: var(--border-light); font-weight: 600; }

.club-description hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ============================================================
   17. Responsive
   ============================================================ */
@media (max-width: 768px) {
  /* Base mobile padding — restore topbar gap separately below */
  .main-content { padding: 16px; }
  .auth-card    { padding: 28px 20px; }
  .wizard-page  { padding: 24px 16px; }

  /* Full Width mode on mobile: ensure content clears the fixed topbar */
  .app-shell:not(.nav-menu) .main-content { padding-top: 72px; }

  /* Menu Layout on mobile: no topbar, normal top padding */
  .app-shell.nav-menu .main-content { padding-top: 16px; }

  /* On mobile, admin / club panels overlay as fixed drawers */
  .admin-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    /* Full-width mode: panel slides from left edge */
    left: 0;
    z-index: 50;
    box-shadow: var(--shadow-md);
  }
  /* Menu-layout mode on mobile: panel slides in next to the sidebar rail */
  .app-shell.nav-menu .admin-panel:not(.panel-hidden) {
    left: var(--sidebar-width);
  }
}

/* ============================================================
   18. Profile detail list
   ============================================================ */

/* Mobile-first: label sits above value (natural block flow) */
.profile-dl {
  display: block;
  font-size: 0.9rem;
}
.profile-dl dt {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 14px;
}
.profile-dl dt:first-child { margin-top: 0; }
.profile-dl dd { margin: 0; padding: 0; }

/* Desktop: two-column grid */
@media (min-width: 500px) {
  .profile-dl {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px 16px;
  }
  .profile-dl dt {
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: normal;
    margin-top: 0;
  }
}

/* ============================================================
   19. Conversations / Chat
   ============================================================ */

/* ── Pinned messages banner (outlined card between topbar and thread) ── */
.chat-pinned-banner {
  flex-shrink: 0;
  margin: 8px 12px 0;
  background: var(--surface);
  border: 1.5px solid var(--pin-green);
  border-radius: 12px;
  padding: 3px 0;
  max-height: 118px;            /* ~4 rows; scroll beyond that */
  overflow-y: auto;
}
.chat-pinned-banner--empty { display: none; }
.pinned-banner-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.pinned-banner-pin  { color: var(--pin-green); flex-shrink: 0; display: inline-flex; }
.pinned-banner-text { display: flex; flex-direction: column; min-width: 0; }
.pinned-banner-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--pin-green);
}
.pinned-banner-snippet {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Small "Pinned" marker above a pinned message row */
.msg-pin-marker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--pin-green);
  padding: 0 2px;
}
.msg-row--self .msg-pin-marker { align-self: flex-end; }

/* Scrollable message thread (fills the flex column set up by view.php). */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── Composer footer ── */
.chat-footer {
  flex-shrink: 0;
  display: flex;
  /* Wrap so the reply banner (flex-basis 100%) sits on its own line ABOVE
     the textarea + send button, and the mention dropdown can anchor here. */
  flex-wrap: wrap;
  position: relative;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-footer textarea {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 16px; /* 16px prevents iOS auto-zoom */
  font-family: var(--font-body);
  line-height: 1.4;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.chat-footer textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(3,139,255,.12);
}
.chat-send-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255,107,71,.30);
  transition: opacity .15s, transform .1s, box-shadow .15s;
}
.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(255,107,71,.40);
}
.chat-send-btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

/* ── Day dividers ── */
.chat-day {
  text-align: center;
  font-size: 11px;
  margin: 16px 0 10px;
  position: relative;
}
.chat-day::before {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: var(--border);
}
.chat-day span {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ── Message rows ── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
  /* Shifts left to reveal the timestamp rail on horizontal swipe. */
  transform: translateX(calc(-1 * var(--reveal-x, 0px)));
  transition: transform .14s ease;
}
.msg-row--self  { flex-direction: row-reverse; }
.msg-row--other { flex-direction: row; }

/* Grouped continuation: tighten spacing, hide repeated avatar/name. */
.msg-row--grouped { margin-bottom: 2px; }
.msg-row--grouped .msg-avatar,
.msg-row--grouped .msg-author-line { display: none; }
/* Keep bubbles aligned when the avatar is hidden on a grouped "other" row. */
.msg-row--grouped.msg-row--other .msg-content--other { margin-left: 40px; }

/* ── Content wrappers ── */
.msg-content--self {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 72%;
}
.msg-content--other {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 72%;
}

/* ── Bubbles ── */
.msg-bubble--self {
  background: var(--accent-blue);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.msg-bubble--other {
  background: var(--bubble-recv);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
  padding: 9px 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
/* Tighter outer corner within a continuing run. */
.msg-row--grouped .msg-bubble--self  { border-radius: 18px 6px 6px 18px; }
.msg-row--grouped .msg-bubble--other { border-radius: 6px 18px 18px 6px; }

.msg-row--deleted .msg-bubble--self,
.msg-row--deleted .msg-bubble--other {
  background: transparent;
  padding: 2px 0;
  box-shadow: none;
}
.msg-deleted-text { color: var(--text-muted); font-style: italic; font-size: 13px; }
.msg-edited-label { font-size: 10px; opacity: .7; }
.msg-body-text    { display: inline; }
/* @mention names inside a message body (ConversationUI::renderBodyHtml). */
.msg-body-text .mention { font-weight: 700; }

/* ── Author name (others) ── */
.msg-author-line { margin-bottom: 3px; padding-left: 2px; }
.msg-author      { font-weight: 600; font-size: 12px; color: var(--purple-dark); }

/* ── Per-message timestamp rail ── */
/* Sits just off the right edge of each row; the whole thread shifts left on a
   horizontal swipe (--reveal-x) to slide these into view, vertically aligned
   with their message. Never shown in normal vertical scrolling. */
.msg-rail-time {
  position: absolute;
  top: 0;
  bottom: 0;
  right: calc(-1 * var(--reveal-x, 0px) + 4px);
  width: 52px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .14s ease;
}
.chat-thread.revealing .msg-rail-time { opacity: 1; }

/* ── Replies ── quoted parent preview above a reply bubble, a green connector,
   and a slight indent so the reply reads as answering the quoted message. ── */
.msg-reply-quote {
  display: block;
  text-align: left;
  margin: 0 0 3px;
  padding: 4px 10px;
  max-width: 300px;
  background: var(--bubble-recv);
  border: none;
  border-left: 3px solid var(--pin-green);
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.25;
  position: relative;
  font-family: var(--font-body);
}
.msg-reply-quote::after {   /* green connector into the bubble below */
  content: '';
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 3px;
  height: 4px;
  background: var(--pin-green);
}
.msg-reply-quote-author {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--coral);
}
.msg-reply-quote-snippet {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-reply-quote:hover { filter: brightness(0.97); }
.msg-row--reply.msg-row--other .msg-content--other { margin-left: 12px; }
.msg-row--reply.msg-row--self  .msg-content--self  { margin-right: 12px; }

/* Composer "Replying to …" banner */
.reply-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Full first line of the wrapping .chat-footer → renders ABOVE the input. */
  flex-basis: 100%;
  padding: 8px 12px;
  margin-bottom: 2px;
  background: var(--bubble-recv);
  border-left: 3px solid var(--pin-green);   /* matches the reply connector */
  border-radius: 8px;
}
.reply-banner-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.reply-banner-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.reply-banner-title #reply-banner-name { color: var(--coral); font-weight: 700; }
.reply-banner-snippet {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reply-banner-close {
  border: none; background: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--text-muted); padding: 0 4px;
}
.reply-banner-close:hover { color: var(--text-primary); }

/* Brief highlight when jumping to a replied-to message */
@keyframes msg-flash {
  0%, 100% { background: transparent; }
  30%      { background: rgba(34, 197, 94, 0.16); }   /* --pin-green */
}
.msg-row--flash { animation: msg-flash 1.4s ease; border-radius: 10px; }

/* ── @mention typeahead dropdown (anchored above the composer) ── */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 60px;
  margin-bottom: 4px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 500;
}
.mention-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
}
.mention-item:hover,
.mention-item.active {
  background: var(--border-light);
  color: var(--purple-dark);
}

/* ── Reply-chain modal (click a chained message; mirrors iOS) ── */
.chain-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 16px 0 8px;
}
.chain-modal-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--border-light);
}
.chain-modal-list {
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px 16px;
}
.chain-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.chain-row:last-child { margin-bottom: 4px; }
.chain-row-bar {
  flex-shrink: 0;
  width: 3px;
  border-radius: 1.5px;
  background: var(--pin-green);
}
.chain-row-author { font-size: 12px; font-weight: 600; color: var(--purple-dark); }
.chain-row-time   { font-size: 10px; color: var(--text-muted); margin-left: 6px; }
.chain-row-body   { font-size: 14px; color: var(--text-primary); overflow-wrap: anywhere; }

/* ── Owner action buttons (appear on hover; always visible on touch) ── */
.msg-actions--self {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 3px;
  opacity: 0;
  transition: opacity .12s;
}
.msg-row--self:hover .msg-actions--self { opacity: 1; }
@media (hover: none) { .msg-actions--self { opacity: 1 !important; } }

.msg-action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background .12s, color .12s, border-color .12s;
}
.msg-action-btn:hover    { background: var(--border-light); color: var(--text-primary); }
.msg-action-delete:hover { background: #FEE2E2; color: #DC2626; border-color: #FECACA; }

/* ── Inline edit form ── */
.msg-edit-form { margin-top: 4px; width: 100%; }
.msg-edit-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 10px;
  border: 1px solid var(--accent-blue);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  color: var(--text-primary);
  background: var(--surface);
}

/* ── Empty-thread state ── */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  margin: 56px auto 0;
  max-width: 280px;
}
.chat-empty svg { color: var(--coral); opacity: .85; margin-bottom: 14px; }
.chat-empty h3 {
  font-family: var(--font-title);
  font-weight: 200;
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.chat-empty p { font-size: 0.85rem; margin: 0; line-height: 1.5; }

/* ── Members dropdown panel ── */
.members-panel {
  position: fixed;
  top: 56px;
  right: 12px;
  width: 244px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  display: none;
}
.members-panel.open { display: block; }
.members-panel-hdr {
  padding: 12px 16px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.members-panel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
}
.members-panel-row:hover { background: var(--border-light); }
.members-panel-row:last-child { border-bottom: none; }

/* ============================================================
   20. Message reactions
   ============================================================ */

/* The message-content column anchors the floating-reaction animation. */
.msg-content--self,
.msg-content--other { position: relative; }

/* Floating-reaction anchor: positioned at the bubble's outer-bottom corner,
   never intercepts clicks, never obscures the text. */
.msg-fx {
  position: absolute;
  bottom: 28px;
  pointer-events: none;
  z-index: 5;
}
.msg-content--self  .msg-fx { right: 8px; }
.msg-content--other .msg-fx { left: 8px; }
.msg-fx-pop {
  position: absolute;
  bottom: 0;
  font-size: 22px;
  line-height: 1;
  will-change: transform, opacity;
}
.msg-content--self  .msg-fx-pop { right: 0; }
.msg-content--other .msg-fx-pop { left: 0; }
.msg-fx-icon { width: 24px; height: 24px; display: block; }

@keyframes float-heart {
  0%   { opacity: 0; transform: translateY(0) scale(.5); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-52px) scale(1.25); }
}
@keyframes haha-bounce {
  0%   { opacity: 0; transform: translateY(0) scale(.6) rotate(0); }
  25%  { opacity: 1; transform: translateY(-14px) scale(1.15) rotate(-10deg); }
  55%  { transform: translateY(-6px) scale(1.05) rotate(10deg); }
  100% { opacity: 0; transform: translateY(-26px) scale(1) rotate(0); }
}
.msg-fx--float { animation: float-heart .9s ease-out forwards; }
.msg-fx--haha  { animation: haha-bounce .8s ease-in-out forwards; }

/* ── Bubble + reactions wrapper ── */
/* Keeps the chip row visually tied to its own bubble (chips tuck onto the
   bubble's bottom edge instead of floating between messages). */
.msg-bubble-wrap {
  display: inline-flex;
  flex-direction: column;
  position: relative;
  max-width: 100%;
}
.msg-content--self  .msg-bubble-wrap { align-items: flex-end; }
.msg-content--other .msg-bubble-wrap { align-items: flex-start; }

/* ── Reaction chip row — overlaps the bubble's bottom corner so it clearly
   belongs to that bubble (iMessage-style). ── */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: -8px;
  padding: 0 6px;
  position: relative;
  z-index: 2;
}
.msg-reactions:empty { margin: 0; padding: 0; }
.msg-reactions--self  { justify-content: flex-end; }
.msg-reactions--other { justify-content: flex-start; }

.msg-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 2px;
  line-height: 1;
  /* Ring in the thread colour separates the chip from the bubble it sits on. */
  box-shadow: 0 0 0 2px var(--bg);
  transition: background .12s, border-color .12s;
}
.msg-chip--mine { background: var(--bubble-sent); border-color: var(--accent-blue); }
.msg-chip-emoji,
.msg-chip-count {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 3px 4px;
  border-radius: 10px;
}
.msg-chip-emoji { font-size: 13px; }
/* Branded reaction icon (named reactions); custom emoji still render as text. */
.msg-chip-icon { width: 18px; height: 18px; display: block; }
.msg-chip-count { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.msg-chip--mine .msg-chip-count { color: var(--accent-blue); }
.msg-chip-emoji:hover,
.msg-chip-count:hover { background: var(--border-light); }

/* ── React trigger (grey smiley) — sits beside the bubble on the side closest
   to the screen centre (left of your messages, right of others'). Appears on
   hover; always shown on touch. ── */
.msg-react-btn {
  flex-shrink: 0;
  align-self: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.msg-react-btn:hover { background: var(--border-light); color: var(--text-primary); }
.msg-row:hover .msg-react-btn { opacity: 1; }
@media (hover: none) { .msg-react-btn { opacity: 1 !important; } }

/* ── Reaction picker popover (quick bar + emoji button) ── */
.react-picker {
  position: fixed;
  z-index: 1200;
  display: flex;
  gap: 2px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
}
.react-picker-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, transform .1s;
}
.react-picker-btn:hover { background: var(--border-light); transform: scale(1.15); }
.react-picker-icon { width: 28px; height: 28px; display: block; }
.react-picker-more { color: var(--text-muted); }

/* ── Emoji grid modal ── */
.emoji-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.emoji-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.emoji-search {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
}
.emoji-search:focus { outline: none; border-color: var(--accent-blue); }
.emoji-cat-tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.emoji-cat-tab {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  opacity: .6;
  transition: opacity .12s, background .12s;
}
.emoji-cat-tab:hover { background: var(--border-light); opacity: 1; }
.emoji-cat-tab.active { opacity: 1; background: var(--border-light); }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
}
.emoji-grid button {
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 0;
  line-height: 1;
  transition: background .1s;
}
.emoji-grid button:hover { background: var(--border-light); }

/* ── "Who reacted" popover ── */
.who-popover {
  position: fixed;
  z-index: 1250;
  min-width: 160px;
  max-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 8px 10px;
  font-size: 12px;
}
.who-popover-loading { color: var(--text-muted); }
.who-popover-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 3px 0;
}
.who-popover-glyph { flex-shrink: 0; font-size: 14px; }
.who-popover-names { color: var(--text-primary); line-height: 1.4; }

/* ============================================================
   21. Content reporting
   ============================================================ */

/* ⋯ message menu (next to the react button) */
.msg-context-menu {
  position: fixed;
  z-index: 1250;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px;
  display: none;
}
.msg-context-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}
.msg-context-menu-item:hover { background: var(--border-light); }
.msg-context-menu-item--danger { color: #DC2626; }
.msg-context-menu-item--danger:hover { background: #FEE2E2; }

/* Report reason modal (chat) */
.report-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.report-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 24px;
}
.report-modal-title { margin: 0 0 6px; font-size: 1rem; font-weight: 700; }
.report-modal-sub   { margin: 0 0 14px; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.report-modal-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.report-modal-textarea:focus { outline: none; border-color: var(--accent-blue); }
.report-modal-error { color: var(--error, #ef4444); font-size: 12px; margin: 8px 0 0; }
.report-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Read-only embedded chat history on the report view */
.report-chat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-height: 460px;
  overflow-y: auto;
}
/* Hide all interactive message affordances in the moderation view. */
.report-chat .msg-react-btn,
.report-chat .msg-more-btn,
.report-chat .msg-actions,
.report-chat .msg-reactions,
.report-chat .msg-fx { display: none !important; }

/* The reported message, highlighted and scrolled into view. */
.msg-row--reported {
  background: #FEF3C7;
  border-radius: 12px;
  box-shadow: 0 0 0 2px #F59E0B;
  padding: 4px 6px;
}
