/* ═══════════════════════════════════════════════════════════════════════════════
   MYOPL Messenger — Theme System (Dark/Light Mode)
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─── Brand Colors (matched to pickleball.myopl.net) ── */
  --brand-orange: #ff8c31;
  --brand-orange-hover: #ffb338;
  --brand-orange-dim: rgba(255,140,49,0.15);
  --brand-navy: #120f54;
  --brand-navy-light: #1a1040;
  --brand-purple: #2d0572;
  --brand-purple-light: #571ce0;

  /* ─── Shared ──────────────────────────────────── */
  --radius: 8px;
  --radius-lg: 15px;
  --transition: 0.2s ease;
  --font: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --online: #4caf50;
  --danger: #ea4335;
}

/* ─── DARK MODE (Default) — matched to MYOPL ────── */
[data-theme="dark"] {
  --bg-primary: #120f54;
  --bg-secondary: #1a1040;
  --bg-tertiary: #2d0572;
  --bg-hover: #432f9f;
  --bg-active: #571ce0;
  --bg-input: #2b1c6a;
  --bg-input-border: #818CFF;
  --bg-bubble-out: #571ce0;
  --bg-bubble-in: #1a1040;
  --bg-card: #1a1040;
  --text-primary: #ffffff;
  --text-secondary: #9b92c1;
  --text-light: #e2e1ff;
  --accent: var(--brand-orange);
  --accent-hover: var(--brand-orange-hover);
  --accent-dim: var(--brand-orange-dim);
  --border: #8790ae;
  --border-color: var(--border);
  --divider: #8790ae;
  --shadow: 0 10px 30px rgba(0,0,0,0.5);
  --login-bg: #120f54;
  --bubble-out-text: #ffffff;
  --bubble-in-text: #ffffff;
}

/* ─── LIGHT MODE ─────────────────────────────────── */
[data-theme="light"] {
  --bg-primary: #f5f3f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0eef5;
  --bg-hover: #ece9f2;
  --bg-active: #e4e0f0;
  --bg-input: #ffffff;
  --bg-input-border: #d0c9e0;
  --bg-bubble-out: #571ce0;
  --bg-bubble-in: #ffffff;
  --bg-card: #ffffff;
  --text-primary: var(--brand-purple);
  --text-secondary: #6b6190;
  --text-light: #4a4070;
  --accent: var(--brand-orange);
  --accent-hover: var(--brand-orange-hover);
  --accent-dim: var(--brand-orange-dim);
  --border: #e0dced;
  --border-color: var(--border);
  --divider: #c5bdd8;
  --shadow: 0 2px 12px rgba(18,15,84,0.08);
  --login-bg: linear-gradient(135deg, #f5f3f8 0%, #ece9f2 50%, #e4e0f0 100%);
  --bubble-out-text: #ffffff;
  --bubble-in-text: var(--brand-purple);
}

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

/* ─── Material Symbols ──────────────────────────── */
.material-symbols-outlined {
  font-size: inherit;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ─── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4c4c4; border-radius: 3px; }



/* ─── Login Page ─────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--login-bg);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 440px;
  max-width: 95vw;
  box-shadow: var(--shadow);
  animation: slideUp 0.4s ease;
  border: 1px solid var(--border);
}

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

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo img {
  height: 50px;
  margin-bottom: 8px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.login-logo h1 .brand-my {
  color: var(--text-primary);
}

.login-logo h1 .brand-o {
  color: var(--brand-orange);
}

.login-logo h1 .brand-pl {
  color: var(--text-primary);
}

.login-logo .subtitle {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ─── Tabs ───────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

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

.tab:hover:not(.active) {
  color: var(--text-light);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Form ───────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 8px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--bg-input-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder {
  color: var(--text-secondary);
}

[data-theme="dark"] .form-group input:-webkit-autofill,
[data-theme="dark"] .form-group input:-webkit-autofill:hover,
[data-theme="dark"] .form-group input:-webkit-autofill:focus,
[data-theme="dark"] .form-group input:autofill {
  -webkit-text-fill-color: var(--text-primary);
  caret-color: var(--text-primary);
  box-shadow: 0 0 0 1000px var(--bg-input) inset;
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(90deg, var(--brand-orange) 0%, var(--brand-orange-hover) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255,140,49,0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,140,49,0.4);
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1.5px solid var(--bg-input-border);
  margin-top: 8px;
}

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

/* ─── Phone verification modal: 6-digit OTP boxes ────── */
.otp-digit {
  width: 44px;
  height: 54px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font);
  transition: var(--transition);
}

.otp-digit:focus {
  outline: none;
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.error-msg {
  background: rgba(234,67,53,0.12);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  border: 1px solid rgba(234,67,53,0.25);
}

.sms-row {
  display: flex;
  gap: 8px;
}

.sms-row input { flex: 1; }
.sms-row .btn { width: auto; padding: 12px 20px; }

/* ─── Chat Layout ────────────────────────────── */
.chat-app {
  display: flex;
  height: 100vh;
  height: var(--app-height, 100dvh);
  padding-top: env(safe-area-inset-top);
  position: relative;
}

/* ─── Sidebar ────────────────────────────────── */
.sidebar {
  position: relative;
  overflow: hidden;
  width: 380px;
  min-width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  height: 64px;
  min-height: 64px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.sidebar-header .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-name {
  font-weight: 600;
  font-size: 18px;
}

.sidebar-header .user-info .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

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

.search-bar {
  padding: 8px 12px;
}

.search-bar input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
}

.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text-secondary); }

.search-wrapper {
  position: relative;
}

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: fine) {
  .conversation-item {
    transition: var(--transition);
  }
}

@media (hover: hover) and (pointer: fine) {
  .conversation-item:hover {
    background: var(--bg-hover);
  }
}

.conversation-item.active {
  background: var(--bg-active);
}

.conversation-item::after,
.contact-item::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background-color: rgba(135, 144, 174, 0.25);
}

.conversation-item:last-child::after,
.contact-item:last-child::after {
  display: none;
}

.conversation-item .conv-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  margin-right: 14px;
  flex-shrink: 0;
  position: relative;
}

.conv-avatar.direct { background: var(--brand-purple); color: #fff; }
.conv-avatar.group { background: #5b3a8c; color: #fff; }
.conv-avatar.court { background: var(--brand-orange); color: #fff; }
.conv-avatar.club { background: #2d6da4; color: #fff; }
.conv-avatar.league { background: #a43333; color: #fff; }

/* Prevent background bleed on image avatars */
.conv-avatar.has-img {
  background: transparent !important;
}

.conv-avatar .entity-type-svg,
.conv-avatar.court .entity-type-svg,
.conv-avatar.club .entity-type-svg,
.conv-avatar.league .entity-type-svg {
  width: 60%;
  height: 60%;
}

/* Fix visibility of OPL AI SVG on Dark Mode - Removed old filter hack as it overwrote backgrounds */

.conv-avatar, .avatar {
  position: relative;
}

.conv-avatar .online-dot, .avatar .online-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: var(--brand-orange);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  z-index: 2;
}

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

.conv-info .conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conv-info .conv-name,
.contact-item .contact-name,
.settings-cat-title,
.mp-link-title,
.settings-profile-name {
  font-size: 15px;
  font-weight: 500;
  color: #29086D;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.conv-info .conv-time {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-left: 8px;
}

.conv-info .conv-time.unread {
  color: var(--accent);
}

.conv-top-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.conv-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-secondary);
  opacity: 1;
  transition: background 0.2s;
  border-radius: 4px;
  z-index: 10;
  margin-left: -4px;
}

.conv-actions .material-symbols-outlined {
  font-size: 20px;
}

@media (hover: hover) and (pointer: fine) {
  .conv-actions:hover {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Sidebar Dropdown Menu (WhatsApp Style) */
.sidebar-context-menu {
  position: fixed;
  z-index: 10000;
  display: none;
  flex-direction: column;
  background: var(--brand-navy);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 8px 0;
  min-width: 220px;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.sidebar-context-menu.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.sidebar-context-menu .ctx-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease;
  gap: 12px;
}

/* The games menu (New Game / Scoreboard / Seeded Leaderboard) has much
   shorter items than this shared class's other menus (chat-header-context-menu
   etc., which genuinely need the 220px min-width for longer labels) --
   scoped to just this menu's id rather than the shared class so those
   other menus keep their own width. width: max-content instead of a
   second hardcoded min-width so it stays correctly sized if the item
   labels ever change. */
#chat-header-sports-menu {
  min-width: 0;
  width: max-content;
}

.sidebar-context-menu .ctx-item:hover {
  background: rgba(255, 255, 255, 0.08); /* WhatsApp subtle hover highlight */
}

/* Light Mode Overrides for Context Menu */
[data-theme="light"] .sidebar-context-menu {
  background: var(--bg-secondary);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

[data-theme="light"] .sidebar-context-menu .ctx-item {
  color: var(--text-primary);
}

[data-theme="light"] .sidebar-context-menu .ctx-item .material-symbols-outlined {
  color: var(--text-secondary);
}

[data-theme="light"] .sidebar-context-menu .ctx-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-context-menu .ctx-item .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-secondary); /* Icon color matches the mockup */
}

.conv-info .conv-preview {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.conv-info .conv-preview > span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 40px;
  text-align: center;
  height: 100%;
  min-height: 100%;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 1;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 300px;
  line-height: 1.5;
}

/* ─── Main Chat Area ─────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  min-width: 0;
  min-height: 100%;
  height: 100%;
}

.chat-main::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  overflow: hidden;
  box-sizing: border-box;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}

.chat-header .conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

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

.chat-header-info h3 {
  font-size: 18px;
  font-weight: 600;
  color: #29086D;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-info .typing-indicator,
.chat-header-info .member-count {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-info .member-count {
  color: var(--text-secondary);
}

/* ─── Messages ───────────────────────────────── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 0;
  z-index: 1;
  min-height: 0;
}

.message {
  max-width: 85%;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.45;
  position: relative;
  margin-bottom: 2px;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease;
}

.msg-hover-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-bubble {
  padding: 8px 12px;
  padding-bottom: 10px;
  border-radius: var(--radius);
  position: relative;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  margin-bottom: 14px; /* extra space for reactions below */
  overflow: visible;
}

.msg-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.message.outgoing .msg-bubble-row {
  justify-content: flex-end;
}

.msg-forwarded-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 2px;
  opacity: 0.9;
}

.msg-forwarded-label .material-symbols-outlined {
  font-size: 13px;
}

/* Dropdown chevron — appears on hover, top-right of bubble */
.msg-dropdown {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 24px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  border-radius: 6px;
  z-index: 3;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .message:hover .msg-dropdown { opacity: 1; }
}
.msg-dropdown:hover { opacity: 1 !important; }

/* Theme-aware chevron colors — solid backgrounds */
/* Dark mode: white bg, dark navy arrow */
[data-theme="dark"] .msg-dropdown {
  color: #1a1a40;
  background: #fff;
}
[data-theme="dark"] .msg-dropdown:hover {
  background: #e0e0e0;
}

/* Light mode: dark navy bg, white arrow */
[data-theme="light"] .msg-dropdown {
  color: #fff;
  background: #1a1a40;
}
[data-theme="light"] .msg-dropdown:hover {
  background: #2d2d5e;
}

/* Meta (time + ticks) clickable */
.msg-meta {
  cursor: pointer;
}
.msg-meta:hover {
  text-decoration: underline;
  text-decoration-style: dotted;
}

.msg-hover-icon {
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
  transition: opacity 0.15s;
  user-select: none;
  flex-shrink: 0;
  margin-bottom: 16px; /* Offset to align with the visual bubble ignoring the 14px reaction margin */
}

.message:hover .msg-hover-icon {
  opacity: 0.7;
}

.msg-hover-icon:hover {
  opacity: 1 !important;
}

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

.bouncing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
}
.bouncing-dots .dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.bouncing-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.bouncing-dots .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.message.outgoing {
  align-self: flex-end;
}

.message.outgoing .msg-bubble {
  background: var(--bg-bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 2px;
}

.message.incoming {
  align-self: flex-start;
}

.message.incoming .msg-bubble {
  background: var(--bg-bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border);
}

.message .sender-name {
  font-size: 12px;
  font-weight: 600;
  color: #29086D;
  margin-bottom: 2px;
}

.message .msg-text {
  display: inline;
}

.message .msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  opacity: 0.6;
  float: right;
  margin-top: 4px;
  margin-left: 12px;
}

.msg-meta .read-check {
  color: var(--accent);
}

.system-msg {
  text-align: center;
  padding: 4px;
  margin: 8px 0;
}

.system-msg span {
  background: var(--bg-tertiary);
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.date-divider {
  text-align: center;
  padding: 8px;
  margin: 12px 0;
}

.date-divider span {
  background: var(--bg-tertiary);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Message Input ──────────────────────────── */
.message-input-area {
  display: flex;
  flex-direction: column;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg-tertiary);
  gap: 8px;
  z-index: 10;
  border-top: 1px solid var(--border);
  position: relative;
  min-height: 73px;
  box-sizing: border-box;
}

.message-input-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

/* ─── Attachment Popup ────────────────────────── */
.attach-popup {
  position: absolute;
  bottom: 100%;
  left: 12px;
  margin-bottom: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 8px 0;
  min-width: 220px;
  z-index: 100;
  animation: fadeInUp 0.15s ease-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.attach-popup-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s;
}
.attach-popup-option:hover {
  background: var(--bg-hover);
}
.attach-popup-option .material-symbols-outlined {
  font-size: 22px;
}
.attach-popup-hint {
  padding: 6px 16px 4px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ─── Emoji Picker ─────────────────────────────── */
.emoji-picker-wrapper {
  position: relative;
  flex-shrink: 0;
}

.emoji-picker {
  display: none;
  position: absolute;
  bottom: 52px;
  left: 0;
  width: 340px;
  height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 50;
  flex-direction: column;
  overflow: hidden;
  animation: emojiSlideUp 0.2s ease;
}

.emoji-picker.open {
  display: flex;
}

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

.emoji-picker-header {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.emoji-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
  overflow-x: auto;
}

.emoji-tabs::-webkit-scrollbar { display: none; }

.emoji-tab {
  background: none;
  border: none;
  font-size: 20px;
  padding: 5px 7px;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.6;
}

.emoji-tab:hover {
  background: var(--bg-hover);
  opacity: 1;
}

.emoji-tab.active {
  background: var(--accent-dim);
  opacity: 1;
}

.emoji-search {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  padding: 0 8px;
}

.emoji-search::placeholder {
  color: rgba(255,255,255,0.65);
}

.emoji-search:focus {
  outline: none;
}

/* Bottom search bar — blue strip matching the screenshot */
.emoji-search-bar {
  display: flex;
  align-items: center;
  background: #1a9fe0;
  padding: 8px 12px;
  flex-shrink: 0;
  gap: 4px;
}

.emoji-search-icon {
  font-size: 20px !important;
  color: #fff;
  flex-shrink: 0;
}

.emoji-search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 2px;
  opacity: 0.8;
  flex-shrink: 0;
}

.emoji-search-clear:hover {
  opacity: 1;
}

.emoji-search-clear .material-symbols-outlined {
  font-size: 18px !important;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1; /* Take up all remaining vertical space */
}

.emoji-grid::-webkit-scrollbar { width: 6px; height: 0; }
.emoji-grid::-webkit-scrollbar-track { background: transparent; }
.emoji-grid::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

.emoji-grid .emoji-category-label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 2px 2px;
  margin-top: 4px;
}

.emoji-grid .emoji-category-label:first-child {
  margin-top: 0;
}

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  padding: 0;
  line-height: 1;
}

.emoji-item:hover {
  background: var(--bg-hover);
  transform: scale(1.15);
}

.message-input-area .icon-btn {
  flex-shrink: 0;
  margin-bottom: 6px;
}

.message-input-wrapper {
  flex: 1;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 4px 12px;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--border);
  gap: 6px;
  position: relative;
}

.message-input-wrapper .media-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  opacity: 0.7;
  padding: 0 4px;
  cursor: pointer;
  transition: opacity 0.2s, color 0.2s;
}

.message-input-wrapper .media-btn .material-symbols-outlined {
  font-size: 24px;
}

.message-input-wrapper .media-btn:hover {
  opacity: 1;
  color: #fff;
  background: transparent;
}

/* In light mode, keep the icon visible on hover instead of going white */
[data-theme='light'] .message-input-wrapper .media-btn:hover {
  color: var(--brand-purple);
}

.message-input-wrapper .icon-btn {
  margin-bottom: 6px;
  flex-shrink: 0;
}

.message-input-wrapper .icon-btn:hover {
  background: transparent;
  color: #fff;
}

[data-theme='light'] .message-input-wrapper .icon-btn:hover {
  color: var(--brand-purple);
}

.upload-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}

/* Media messages in chat */
.message .msg-media {
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
  position: relative;
}

.message .msg-media img {
  max-width: 260px;
  max-height: 300px;
  display: block;
  border-radius: 8px;
}

.message .msg-media video {
  max-width: 260px;
  max-height: 300px;
  display: block;
  border-radius: 8px;
}

/* Document card in chat bubble */
.msg-doc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  min-width: 220px;
  max-width: 320px;
  transition: background 0.15s;
}
.msg-doc-card:hover {
  background: rgba(255,255,255,0.25);
}
.msg-doc-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-doc-info {
  flex: 1;
  min-width: 0;
}
.msg-doc-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-doc-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}
.msg-doc-download {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.msg-doc-download .material-symbols-outlined {
  font-size: 20px;
}

/* Custom video player */
.video-player-wrapper {
  position: relative;
  cursor: pointer;
  min-width: 200px;
  min-height: 140px;
  max-width: 260px;
  background-size: cover;
  background-position: center;
  background-color: rgba(0,0,0,0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  pointer-events: none;
  transition: background 0.2s;
}

.video-play-overlay .material-symbols-outlined {
  font-size: 36px;
}

.video-player-wrapper:hover .video-play-overlay {
  background: rgba(0,0,0,0.7);
}

.video-duration-badge {
  position: absolute;
  bottom: 6px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.message-input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  font-family: var(--font);
  resize: none;
  max-height: 120px;
  min-height: 40px;
  padding: 8px 0;
  line-height: 1.4;
  -webkit-appearance: none; /* Remove iOS default styling */
  appearance: none;
  touch-action: manipulation;
}

.message-input-wrapper textarea:focus { outline: none; }
.message-input-wrapper textarea::placeholder { color: var(--text-secondary); }

.send-btn {
  width: 48px;
  height: 48px;
  border: none;
  background: linear-gradient(90deg, var(--brand-orange) 0%, var(--brand-orange-hover) 100%);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: var(--transition);
  margin-bottom: 2px;
  box-shadow: 0 2px 8px rgba(255,140,49,0.3);
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(255,140,49,0.4);
}

/* ─── New Chat Modal ─────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,10,46,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: modalIn 0.25s ease;
  border: 1px solid var(--border);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-footer .btn {
  width: auto;
  padding: 10px 24px;
}

.type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.type-option {
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.type-option:hover {
  border-color: var(--text-secondary);
}

.type-option.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.type-option .type-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.user-result {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.user-result:hover {
  background: var(--bg-hover);
}

.user-result .user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-right: 12px;
}

.user-result .user-name {
  font-size: 14px;
  font-weight: 500;
}

.user-result .user-email {
  font-size: 12px;
  color: var(--text-secondary);
}

.selected-users {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.selected-user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 13px;
}

.selected-user-chip .remove-chip {
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

/* ─── Mentions ─────────────────────────────── */
.mention-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.mention-dropdown-item:hover, .mention-dropdown-item.active {
  background: var(--bg-hover);
}
.mention-dropdown-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border-color);
}
.mention-dropdown-desc {
  display: flex;
  flex-direction: column;
}
.mention-dropdown-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.mention-dropdown-user {
  font-size: 12px;
  color: var(--brand-primary);
  opacity: 0.8;
}

.chat-mention {
  position: relative;
  border-radius: 4px;
  background: rgba(22, 115, 255, 0.1);
  padding: 0 4px;
  transition: background 0.15s;
  display: inline;
}
[data-theme="dark"] .chat-mention {
  background: rgba(43, 107, 243, 0.2);
}
.chat-mention:hover {
  text-decoration: underline;
  background: rgba(22, 115, 255, 0.2);
}

.mention-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s;
}
.mention-menu-item:hover {
  background: var(--bg-hover);
}

/* ─── Toast (Ambient System Feedback Banners) ─── */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 10px 22px;
  border-radius: 30px;
  margin-top: 8px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDownFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

[data-theme="light"] .toast {
  background: var(--bg-secondary);
  border-color: var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.toast.error {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--text-primary);
  font-weight: 600;
}

[data-theme="light"] .toast.error {
  background: var(--danger);
  color: var(--bg-secondary);
}

/* ─── Offline Banner (persistent, not a toast — stays until reconnected) ───
   Lives inside .sidebar, below .sidebar-header and above .search-bar --
   flows in the sidebar's own layout rather than overlaying the page, so it
   never covers the nav rail or the open chat and never blocks clicks. */
#offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: #c0392b;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

@keyframes slideDownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── Loading ────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
  .chat-app { flex-direction: column; }
  .sidebar { width: 100%; flex: 1; min-width: 0; }
  .chat-main { display: none; }
  .chat-app.chat-open .sidebar { display: none; }
  .chat-app.chat-open .chat-main { display: flex; }
  .messages-container { padding: 12px 16px; }
  .message { max-width: 90%; }
  .back-btn { display: flex !important; }
}

.back-btn { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════════
   Sidebar Tabs & Contacts
   ═══════════════════════════════════════════════════════════════════════════════ */

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  gap: 4px;
}

.sidebar-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.sidebar-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-radius: var(--radius) var(--radius) 0 0;
}

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

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0px 5px;
  border-radius: 9px;
  background: var(--brand-orange-hover);
  color: rgb(255, 255, 255);
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
}

.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

.section-label {
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* ─── Friend Request Conversation Tiles (sidebar) ─── */

.conversation-item.friend-request-conv {
  border-left: 3px solid var(--brand-orange);
  cursor: default;
}

.conversation-item.friend-request-conv .fr-avatar {
  background: var(--brand-orange) !important;
}

.fr-conv-subtitle {
  color: var(--brand-orange);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
}

.fr-conv-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 6px;
}

.fr-btn-accept {
  padding: 5px 14px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand-purple);
  color: #fff;
  transition: var(--transition);
}

.fr-btn-accept:hover {
  background: var(--brand-orange-hover);
}

.fr-btn-ignore {
  padding: 5px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: var(--transition);
}

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

/* ─── Friend Requests ──────────────────────────── */

.friend-requests {
  border-bottom: 1px solid var(--border);
}

.friend-request-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 10px;
  transition: var(--transition);
}

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

.friend-request-item .avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}

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

.friend-request-item .request-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.friend-request-item .request-email {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.request-actions {
  display: flex;
  gap: 6px;
}

.request-actions button {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-accept {
  background: var(--brand-purple);
  color: #fff;
}

.btn-accept:hover {
  background: var(--brand-orange-hover);
}

.btn-decline {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.btn-decline:hover {
  background: var(--danger);
  color: #fff;
}

.request-actions button.btn-decline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.request-actions button.btn-decline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ─── Contacts List ────────────────────────────── */

.contacts-list {
  flex: 1;
  overflow-y: auto;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: fine) {
  .contact-item {
    transition: var(--transition);
  }
}

@media (hover: hover) and (pointer: fine) {
  .contact-item:hover {
    background: var(--bg-hover);
  }
}

.contact-item .avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-light);
  font-size: 16px;
}

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



.contact-item .contact-email {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-item .contact-action {
  opacity: 0;
  transition: var(--transition);
}

@media (hover: hover) and (pointer: fine) {
  .contact-item:hover .contact-action {
    opacity: 1;
  }
}

.contact-action .icon-btn {
  font-size: 14px;
  width: 32px;
  height: 32px;
}

.empty-contacts {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-contacts .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sent-requests {
  border-bottom: 1px solid var(--border);
}

.sent-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sent-item {
  opacity: 0.75;
}

/* ─── Avatar Images ────────────────────────────── */

.avatar,
.conv-avatar,
.user-info .avatar {
  position: relative;
}

.avatar img,
.conv-avatar img,
img.conv-avatar,
img.avatar,
.user-info .avatar img,
.friend-request-item .avatar img,
.contact-item .avatar img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  border-radius: 50%;
  object-fit: cover;
  z-index: 1;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  background-clip: padding-box;
  transform: scale(1.04);
}

/* ── Message Interactions ──────────────────────────────────────────── */

.msg-reply-ref {
  padding: 6px 10px;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  border-left: 3px solid #f19b38;
  cursor: pointer;
}

.reply-ref-name {
  font-size: 11px;
  font-weight: 700;
  color: #f19b38;
}

.reply-ref-text {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.msg-reactions {
  position: absolute;
  bottom: -12px;
  right: 4px;
  display: flex;
  gap: 2px;
  z-index: 2;
}

/* Incoming messages: reactions on the left */
.message.incoming .msg-reactions {
  right: auto;
  left: 4px;
}

.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  font-size: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: default;
}

.reaction-count {
  font-size: 11px;
  color: var(--text-secondary);
}

.message.highlight {
  animation: highlightPulse 1.5s ease;
}

@keyframes highlightPulse {
  0%, 100% { background: transparent; }
  30% { background: rgba(241, 155, 56, 0.2); }
}

/* Context Menu */
.msg-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  min-width: 160px;
  padding: 4px 0;
  animation: fadeIn 0.1s ease;
}

.ctx-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  transition: background 0.15s;
}

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

.ctx-icon {
  width: 20px;
  text-align: center;
}

/* Reaction Picker */
.reaction-picker {
  position: fixed;
  z-index: 1001;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 10px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: fadeIn 0.1s ease;
  max-width: calc(100vw - 16px);
}

.reaction-emoji {
  font-size: 26px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
  transition: transform 0.15s, background 0.15s;
}

.reaction-emoji:hover {
  transform: scale(1.25);
  background: var(--bg-tertiary);
}

.reaction-plus {
  font-size: 22px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

/* Reply Bar */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}

.reply-bar-accent {
  width: 4px;
  height: 36px;
  background: #f19b38;
  border-radius: 2px;
  flex-shrink: 0;
}

.reply-bar-content {
  flex: 1;
  min-width: 0;
}

.reply-bar .reply-name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #f19b38;
}

.reply-bar .reply-text {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-close {
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
  padding: 4px;
}

.reply-close:hover {
  color: var(--text-primary);
}

/* Dialog Overlay */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.dialog-box {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 400px;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.dialog-header {
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}

.dialog-close {
  cursor: pointer;
  font-size: 24px;
  color: var(--text-secondary);
}

.dialog-close:hover {
  color: var(--text-primary);
}

.dialog-search input {
  width: 100%;
  padding: 8px 16px 8px 36px;
  border-radius: 24px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.dialog-search input:focus {
  border-color: var(--accent);
  box-shadow: none;
}

.dialog-search {
  padding: 12px;
  position: relative;
}

.dialog-search .search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 18px;
  pointer-events: none;
}

.dialog-section-label {
  padding: 4px 20px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.dialog-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  color: var(--text-primary);
}

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

.dialog-item input[type="checkbox"] {
  accent-color: #f19b38;
  width: 18px;
  height: 18px;
}

.dialog-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
}

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

.dialog-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  color: var(--text-primary);
}

.dialog-list-item:hover {
  background: var(--bg-tertiary);
}

.dialog-list-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
}

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


.dialog-send {
  margin: 12px 16px 16px;
  padding: 12px;
  background: #f19b38;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.dialog-send:hover {
  opacity: 0.9;
}

/* Delete Dialog */
.delete-dialog {
  padding: 24px;
  width: 320px;
}

.delete-dialog h3 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--text-primary);
}

.delete-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: #f19b38;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}

.delete-btn:hover {
  background: var(--bg-tertiary);
}

.delete-btn.cancel-btn {
  color: var(--text-secondary);
}

/* ─── Chat Search Bar ──────────────────────────────────────────────────────────── */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.chat-search-bar input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}
.chat-search-bar input::placeholder {
  color: var(--text-secondary);
}
.chat-search-bar .search-icon {
  color: var(--text-secondary);
  font-size: 20px;
}
.chat-search-bar .search-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-search-bar .search-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: 8px;
}
.highlight-match {
  background-color: rgba(255, 213, 0, 0.4);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}
.highlight-active {
  background-color: var(--accent);
  color: #fff;
}

/* ─── Contact Info Panel ─────────────────────────────────────────────────────── */
.contact-info-panel {
  width: 380px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  z-index: 100;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s ease, width 0.3s ease;
}

.ci-header {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.ci-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.ci-profile-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ci-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 0 5%;
}

.ci-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-secondary);
  overflow: hidden;
}

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

.ci-profile h3 {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.ci-location {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.ci-location a {
  color: inherit;
  text-decoration: none;
}

.ci-location a:hover {
  text-decoration: underline;
}

.ci-username {
  font-size: 16px;
  color: #ff9600; /* or var(--brand-orange) */
  line-height: 1.4;
}

/* Stats Cards */
.ci-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Most Played Opponent / Best Court need the full row width to fit an
   avatar + name + subtitle + record without cramming -- stack them instead
   of the shared 2-up grid used elsewhere. */
#stats-head-to-head {
  grid-template-columns: 1fr;
}

.ci-stat-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ci-stat-header {
  padding: 8px 10px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ci-stat-title-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ci-stat-icon {
  font-size: 18px !important;
  color: var(--brand-purple);
}

[data-theme='dark'] .ci-stat-icon {
  color: rgba(255,255,255,0.75);
}

.ci-stat-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.ci-stat-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  padding: 4px 10px 4px;
}

.ci-stat-rate {
  font-size: 22px;
  font-weight: bold;
  color: var(--brand-purple);
  margin-top: 2px;
  margin-bottom: 2px;
  letter-spacing: -0.5px;
  line-height: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme='dark'] .ci-stat-rate {
  color: #fff;
}

/* Wrapping variant of .ci-stat-rate for cards whose value is a name/place
   rather than a short number (Most Played Opponent, Best Court) -- lets long
   values wrap onto a 2nd line instead of truncating with "...". CSS Grid's
   default row-stretch behavior then keeps both cards in the row equal height
   automatically, since height now follows content instead of a fixed
   single-line box. */
.ci-stat-rate-wrap {
  font-size: 16px;
  font-weight: 800;
  color: var(--brand-purple);
  margin-top: 2px;
  margin-bottom: 2px;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

[data-theme='dark'] .ci-stat-rate-wrap {
  color: #fff;
}

/* Rate + ring flex row */
.ci-stat-rate-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}

/* Nudge the ring up so it floats like a superscript */
.ci-stat-rate-row .ci-reliability {
  margin-top: -6px;
}

.ci-stat-games {
  font-size: 12px;
  color: var(--text-secondary);
}

.ci-stat-games span {
  font-weight: 700;
  color: var(--text-primary);
}

.ci-reliability {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-secondary);
}

.opl-rating-card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.opl-rating-stat-card {
  flex: 1 1 150px;
  min-width: 0;
  box-sizing: border-box;
}

.opl-rating-stat-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opl-rating-reliability {
  flex: 0 0 30px;
}

.progress-container-small {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-svg-small {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.progress-bg-small {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18); /* Visible ring track in dark mode */
  stroke-width: 20;
}

[data-theme='light'] .progress-bg-small {
  stroke: #c8d3e0; /* Grey-blue track matching macOS app */
}

.progress-bar-small {
  fill: none;
  stroke-width: 20;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease-out, stroke 0.5s;
}

.progress-text-small {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Color Zones for the SVG */
.zone-0-10 { stroke: #E9967A; } 
.zone-10-20 { stroke: #FFA07A; } 
.zone-20-45 { stroke: #ADFF2F; } 
.zone-45-60 { stroke: #00FA9A; } 
.zone-60-80 { stroke: #32CD32; } 
.zone-80-100 { stroke: #01951d; } 

.ci-stat-footer {
  display: flex;
  flex-direction: column;
  padding: 4px 10px 8px;
}


.ci-points-labels-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
}

.ci-points-label {
  font-size: 11px;
  line-height: 1.1;
  font-weight: 500;
}

.ci-points-label.won {
  color: #7BC5B8;
}

.ci-points-label.lost {
  color: #C0584D;
  text-align: right;
}

.ci-points-value {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

/* Sections */
.ci-section-title {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--brand-orange);
  margin-bottom: 0;
  letter-spacing: 0.5px;
  line-height: 1;
}

.ci-section-header {
  width: 100%;
  box-sizing: border-box;
  padding: 30px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 0;
}

.ci-section-divider {
  width: 100%;
  height: 1px;
  min-height: 1px;
  flex-shrink: 0;
  background: var(--divider);
  margin: 6px 0 12px 0;
}

.ci-media-box {
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  transition: all 0.2s;
}

.ci-media-box:hover {
  border-color: var(--brand-orange);
}

.ci-media-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: font-weight 0.2s;
}

.ci-media-box:hover .ci-media-header > span:not(.material-symbols-outlined) {
  font-weight: 700 !important;
}

.ci-media-count {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
}

.ci-media-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.ci-media-grid:not(:empty) {
  margin-top: 12px;
}

.ci-media-item {
  aspect-ratio: 1;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 1px solid var(--border);
}

.ci-media-item img,
.ci-media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ci-media-item:hover { opacity: 0.85; }

.ci-media-video-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
}

.ci-media-video-badge .material-symbols-outlined { font-size: 12px; }

/* ── Media Gallery Overlay ── */

.media-gallery-overlay {
  position: absolute;
  inset: 0;
  z-index: 2500;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.media-gallery-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.media-gallery-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.media-gallery-close:hover { color: var(--text-primary); }

.media-gallery-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.media-gallery-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.media-gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  align-content: start;
}

.media-gallery-grid .ci-media-item {
  border-radius: 4px;
}

/* ── Gallery Tabs ── */
.mg-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.mg-tab:hover { color: var(--text-primary); }
.mg-tab.active {
  color: var(--accent, #ff8c31);
  border-bottom-color: var(--accent, #ff8c31);
}

.mg-links-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mg-docs-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}


/* ── Light mode: softer lightbox overlay ── */
[data-theme='light'] #lightbox {
  background: rgba(0,0,0,0.75) !important;
}

/* Actions */
.ci-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: 4px;
}

.ci-action-row, .ci-action-btn {
  display: flex;
  align-items: center;
  padding: 14px 4px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  gap: 14px;
}

.ci-action-row {
  justify-content: flex-start;
  gap: 14px;
  border-bottom: none;
}

.ci-action-btn {
  gap: 14px;
  background: none;
  border-radius: 0;
}

.ci-action-row:hover, .ci-action-btn:hover {
  background: var(--bg-hover);
  font-weight: 700;
}
.ci-action-row:hover *:not(.material-symbols-outlined), 
.ci-action-btn:hover *:not(.material-symbols-outlined) {
  font-weight: 700 !important;
}

.ci-action-btn.danger {
  color: #c0392b;
  border-bottom: none;
}

.ci-action-btn.danger:hover {
  background: rgba(192, 57, 43, 0.05);
}

.ci-action-btn.warning {
  color: var(--accent);
}

.ci-action-btn.warning:hover {
  background: rgba(255, 140, 49, 0.1);
}

.ci-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

@media (max-width: 768px) {
  .contact-info-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: 320px;
    transform: translateX(100%);
  }
  .contact-info-panel.show-mobile {
    transform: translateX(0);
    box-shadow: -4px 0 16px rgba(0,0,0,0.2);
  }
}
@media (max-width: 600px) {
  .contact-info-panel {
    width: 100%;
  }
}

/* ─── Archived / Pending Panels ─────────────────────────────────────────────── */
.archived-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  z-index: 10;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.archived-panel.open {
  transform: translateX(0);
}
.archived-header {
  height: 64px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.archived-title {
  font-size: 18px;
  font-weight: 700;
  margin-left: 12px;
}
.archived-description {
  padding: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  background-color: var(--bg-secondary);
}
.archived-chats-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  background-color: var(--bg-secondary);
  margin-bottom: 8px;
}
.archived-chats-row:hover {
  background-color: var(--bg-hover);
}
.archived-icon {
  color: var(--text-secondary);
  margin-right: 16px;
}
.archived-label {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}
.archived-count {
  font-size: 12px;
  color: var(--brand-purple);
  font-weight: 700;
}
.friend-request-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.request-info {
  flex: 1;
  margin-left: 12px;
}
.request-name {
  font-weight: 600;
  color: var(--text-primary);
}
.request-email {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.request-actions {
  display: flex;
  gap: 8px;
}
.btn-accept {
  background-color: var(--brand-purple);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.btn-decline {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}
.sent-status {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Archived row count badge */
.archived-count {
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 13px;
  margin-left: auto;
}

/* Sidebar context menu danger items */
.sidebar-context-menu .ctx-item.danger,
.sidebar-context-menu [style*="var(--danger)"] {
  color: #c0392b !important;
}

/* ─── Image Gallery Bubble ───────────────────────────────────────────────────── */
.msg-gallery {
  display: grid;
  gap: 3px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 280px;
  width: 100%;
}

.msg-gallery-2 { grid-template-columns: repeat(2, 1fr); }

.msg-gallery-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* 5-image: first image spans full width */
.msg-gallery-3 .gallery-thumb:first-child {
  grid-column: 1 / -1;
  height: 140px;
  max-height: 140px;
}

.gallery-thumb {
  width: 100%;
  height: 120px;
  max-height: 120px;
  object-fit: cover;
  cursor: pointer;
  display: block;
  transition: filter 0.15s;
}

.gallery-thumb:hover { filter: brightness(0.88); }

/* ─── Select Messages Mode ────────────────────────────────────────────────── */

/* When select mode is active, messages container gets padding-left for checkbox col */
.messages-container.select-mode .message {
  cursor: pointer;
  /* Stretch to full width so checkbox anchors left, bubbles can float right */
  max-width: 100%;
  align-self: stretch;
}

.msg-select-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
}

/* Checkbox column — hidden by default, shown in select mode */
.msg-checkbox-col {
  display: none;
  flex-shrink: 0;
  align-items: center;
  padding-bottom: 0;
}

.select-mode .msg-checkbox-col {
  display: flex;
}

.msg-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

/* Light mode: grey unchecked circle so it's visible on white */
[data-theme="light"] .msg-checkbox {
  border-color: #aaaaaa;
}

.msg-checkbox:checked {
  background: var(--accent, #7c3aed);
  border-color: var(--accent, #7c3aed);
}

.msg-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 3px; left: 6px;
  width: 5px; height: 9px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

/* Selected message row highlight */
.message.msg-selected .msg-bubble {
  outline: 2px solid var(--accent, #7c3aed);
  outline-offset: 2px;
}

/* Disable hover toolbar in select mode */
.select-mode .msg-actions { display: none !important; }

/* Dark mode: selection bar matches the "Type a message" input background */
[data-theme="dark"] #selection-bar {
  background: #2b1c6a !important;
}

/* Light mode: selection bar icons match dropdown menu text colour */
[data-theme="light"] #sel-download-btn,
[data-theme="light"] #sel-forward-btn {
  color: #1a1040 !important;
}
[data-theme="light"] #sel-delete-btn {
  color: #922b21 !important;
}

/* Selection bar action button hover */
#selection-bar button:hover {
  background: rgba(255,255,255,0.08) !important;
}
#sel-delete-btn:hover {
  background: rgba(192,57,43,0.12) !important;
}

/* ─── Confirm Toast Dialog ──────────────────────────────────────────────────── */
.confirm-toast {
  position: fixed;
  inset: 0;
  z-index: 10002; /* Must be above #ai-disclaimer-overlay (10000) and #ai-mention-disclaimer-modal (10001) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  animation: fadeInOverlay 0.15s ease;
}

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

.confirm-toast-inner {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slideUpCard 0.18s ease;
  font-family: 'Nunito Sans', sans-serif;
}

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

.confirm-toast-inner strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.confirm-toast-inner > span {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-toast-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.confirm-btn {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Nunito Sans', sans-serif;
  cursor: pointer;
  transition: opacity 0.15s;
}

.confirm-btn:hover { opacity: 0.85; }

.confirm-btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.confirm-btn-ok {
  background: #c0392b;
  color: #fff;
}

/* ─── Media Preview Modal ─────────────────────────────────────────────────── */
.media-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.media-preview-top {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.media-preview-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.media-preview-close:hover { opacity: 1; }

.media-preview-title {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  flex: 1;
}

.media-preview-count {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  font-weight: 600;
}

.media-preview-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}

.media-preview-main img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.media-preview-thumbs {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.media-thumb-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.media-thumb-wrapper.active {
  border-color: var(--accent, #f19b38);
}

.media-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.media-thumb-wrapper:hover .media-thumb-remove { opacity: 1; }

.media-thumb-video {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  font-size: 28px;
}

.media-preview-bottom {
  padding: 12px 16px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.media-preview-caption {
  flex: 1;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  outline: none;
  min-height: 20px;
  max-height: 80px;
}

.media-preview-caption::placeholder { color: rgba(255,255,255,0.4); }

.media-preview-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f19b38;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.media-preview-send:hover { opacity: 0.9; }

/* ─── Link Preview Card ────────────────────────────────────────────────────── */

.link-preview-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: opacity 0.15s;
  max-width: 320px;
}

.link-preview-card:hover {
  opacity: 0.9;
}

.link-preview-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.link-preview-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  padding: 10px 12px;
}

.link-preview-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-desc {
  font-size: 12.5px;
  opacity: 0.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.link-preview-site {
  font-size: 11px;
  opacity: 0.5;
}

/* Dark mode overrides */
.msg-bubble.outgoing .link-preview-card {
  background: rgba(255, 255, 255, 0.1);
}

.msg-bubble:not(.outgoing) .link-preview-card {
  background: rgba(0, 0, 0, 0.06);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Navigation Rail (Desktop) + Footer Nav (Mobile)
   ═══════════════════════════════════════════════════════════════════════════════ */

.nav-rail {
  width: 64px;
  min-width: 64px;
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 calc(16px + env(safe-area-inset-bottom));
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 10;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-rail::-webkit-scrollbar { width: 0; }

/* Brand logo at top */
.nav-rail-logo {
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-rail-logo:hover { transform: scale(1.08); }

.nav-rail-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Nav items */
.nav-rail-item {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nav-rail-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  transform: scale(1.05);
}

.nav-rail-item.active {
  background: var(--bg-active);
  color: #fff;
}

.nav-rail-item .material-symbols-outlined {
  font-size: 24px;
}

/* Inline SVG icon items — use fill:currentColor, inherit color from parent */
.nav-rail-item .nav-icon-svg {
  width: 26px;
  height: 26px;
}

/* Badge on nav items */
.nav-rail-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  pointer-events: none;
}

/* Tooltip on hover */
.nav-rail-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10001;
}

.nav-rail-item:hover::after {
  opacity: 1;
}

/* Divider */
.nav-rail-divider {
  width: 32px;
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 0;
  flex-shrink: 0;
}

/* Spacer pushes bottom items down */
.nav-rail-spacer {
  flex: 1;
}

/* Profile avatar at bottom */
.nav-rail-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.15);
  transition: border-color 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
  margin-top: 8px;
}

.nav-rail-avatar:hover {
  border-color: var(--accent);
  transform: scale(1.08);
}

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

.nav-rail-avatar .avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-purple);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* ─── Light Mode Overrides ─────────────────────── */
[data-theme="light"] .nav-rail {
  background: #f0eef5;
  border-right-color: var(--border);
}

[data-theme="light"] .nav-rail-item:hover {
  background: rgba(0,0,0,0.06);
}

[data-theme="light"] .nav-rail-item.active {
  background: var(--bg-active);
  color: var(--brand-purple);
}

/* No light-mode filter overrides needed — inline SVGs inherit color */

[data-theme="light"] .nav-rail-divider {
  background: rgba(0,0,0,0.08);
}

[data-theme="light"] .nav-rail-avatar {
  border-color: rgba(0,0,0,0.12);
}

/* ─── Footer Nav (Mobile) ──────────────────────── */
.footer-nav {
  display: none;
  width: 100%;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: center;
  z-index: 200;
  min-height: 73px;
  box-sizing: border-box;
}

.footer-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  transition: color 0.2s ease;
  position: relative;
}

.footer-nav-item.active {
  color: var(--accent);
}

.footer-nav-item .material-symbols-outlined {
  font-size: 22px;
}

/* Footer inline SVG icons — inherit color from parent */
.footer-nav-item .nav-icon-svg {
  width: 22px;
  height: 22px;
}

.footer-nav-badge {
  position: absolute;
  top: -2px;
  right: 0;
  min-width: 16px;
  height: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

[data-theme="light"] .footer-nav {
  background: #f0eef5;
  border-top-color: var(--border);
}

/* ─── Responsive: show/hide rail vs footer ─────── */
@media (max-width: 768px) {
  .nav-rail { display: none !important; }
  .footer-nav { display: flex !important; }
  .chat-app.chat-open .footer-nav { display: none; }
}

@media (min-width: 768px) {
  .footer-nav { display: none; }
}

/* When footer-nav is inside settings/stats sidebar, hide it on desktop landscape/expanded layout */
.settings-sidebar > .footer-nav {
  display: none !important;
}

/* Show it only when the nav-rail is hidden (mobile and tablet portrait views) */
@media (max-width: 768px),
       (min-width: 768px) and (max-width: 900px),
       (min-width: 768px) and (max-width: 1200px) and (orientation: portrait) {
  .settings-sidebar > .footer-nav {
    display: flex !important;
    margin-top: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MEDIA PANEL OVERLAY — triggered from nav rail "Media" button
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Backdrop ── */
.media-panel-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 64px;   /* skip nav rail */
  right: 0;
  bottom: 0;
  background: rgba(147, 140, 158, 0.6);
  z-index: 999999;
  align-items: center;
  justify-content: center;
}
.media-panel-backdrop.active { display: flex; }

/* ── Panel ── */
.media-panel {
  width: min(90%, 960px);
  height: 85vh;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.media-panel-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-shrink: 0;
}
.media-panel-header .mp-title {
  font-weight: 700;
  font-size: 17px;
}
.media-panel-header .mp-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}
.media-panel-header .mp-title-block { flex: 0 0 auto; }
.media-panel-header .mp-tabs {
  display: flex;
  gap: 0;
  margin-left: auto;
}
.media-panel-header .mp-tab {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.media-panel-header .mp-tab.active {
  color: var(--text-primary);
  border-bottom-color: #ff8c31;
}
.media-panel-header .mp-tab:hover:not(.active) {
  color: var(--text-primary);
}
.media-panel-header .mp-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.media-panel-header .mp-action-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
}
.media-panel-header .mp-action-btn .material-symbols-outlined {
  font-size: 22px;
}
.media-panel-header .mp-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.media-panel-header .mp-action-btn.active {
  color: #ff8c31;
}

/* ── Search bar ── */
.media-panel-search {
  display: none;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
}
.media-panel-search.active { display: block; }
.media-panel-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
}
.media-panel-search input:focus {
  outline: none;
  border-color: #ff8c31;
}

/* ── Grid ── */
.media-panel-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px;
  align-content: start;
}

.media-panel-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
  border: 1px solid var(--border);
}
.media-panel-item:hover { transform: scale(1.02); }

.media-panel-item img,
.media-panel-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sender name label (bottom-left) */
.media-panel-item .mp-sender {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 8px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Video badge (top-left) */
.media-panel-item .mp-video-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 4px;
  font-size: 10px;
}
.media-panel-item .mp-video-badge .material-symbols-outlined { font-size: 13px; }

/* Duration badge */
.media-panel-item .mp-duration {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* Selection checkmark overlay */
.media-panel-item .mp-checkbox {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0,0,0,0.3);
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.media-panel-item .mp-checkbox .material-symbols-outlined {
  font-size: 16px;
  color: #fff;
  display: none;
}
.media-panel.select-mode .mp-checkbox { display: flex; }
.media-panel-item.selected .mp-checkbox {
  background: #ff8c31;
  border-color: #ff8c31;
}
.media-panel-item.selected .mp-checkbox .material-symbols-outlined { display: block; }
.media-panel-item.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 140, 49, 0.15);
  pointer-events: none;
}

/* ── Selection bar (bottom) — matches chat select-messages bar ── */
.media-panel-selection-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  gap: 12px;
  z-index: 10;
}
.media-panel-selection-bar.active { display: flex; }
.mp-sel-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.media-panel-selection-bar .mp-sel-close {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
}
.media-panel-selection-bar .mp-sel-close .material-symbols-outlined {
  font-size: 22px;
}
.media-panel-selection-bar .mp-sel-count {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.mp-sel-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.media-panel-selection-bar .mp-sel-action {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.media-panel-selection-bar .mp-sel-action .material-symbols-outlined {
  font-size: 22px;
}
.media-panel-selection-bar .mp-sel-action:hover {
  background: var(--bg-hover);
}
.media-panel-selection-bar .mp-sel-action.danger {
  color: #a93226;
}
.media-panel-selection-bar .mp-sel-action.danger:hover {
  color: #a93226;
}

/* ── Empty state ── */
.media-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-secondary);
}
.media-panel-empty .material-symbols-outlined { font-size: 48px; opacity: 0.5; }

/* Links tab */
.media-panel-links {
  display: none;
  flex: 1;
  overflow-y: auto;
}
.media-panel-links.active { display: flex; flex-direction: column; }

/* Links column headers */
.mp-links-header {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}
.mp-links-header .mp-lh-link   { flex: 2; }
.mp-links-header .mp-lh-msg    { flex: 1; }
.mp-links-header .mp-lh-sender { flex: 1; }
.mp-links-header .mp-lh-actions { width: 80px; }

/* Links date group */
.mp-links-group-heading {
  padding: 14px 20px 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.mp-links-group-date {
  padding: 0 20px 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Links list */
.mp-links-list {
  flex: 1;
  overflow-y: auto;
}

/* Link row */
.mp-link-row {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  transition: background 0.15s;
  position: relative;
}
.mp-link-row:hover { background: var(--bg-hover); }

/* Select checkbox circle */
.mp-link-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-secondary);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  cursor: pointer;
}
.mp-link-check .material-symbols-outlined {
  font-size: 16px;
  display: none;
}
.select-mode .mp-link-check {
  display: flex;
}
.mp-link-row.selected .mp-link-check {
  border-color: #ff8c31;
  background: #ff8c31;
}
.mp-link-row.selected .mp-link-check .material-symbols-outlined {
  display: block;
  color: #fff;
}
.mp-link-row.selected {
  border: 2px solid #ff8c31;
  border-radius: 8px;
  background: rgba(255, 140, 49, 0.06);
  margin: 4px 8px;
  padding: 10px 12px;
}

/* Link info column */
.mp-link-info {
  flex: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.mp-link-thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-tertiary);
}
.mp-link-thumb-placeholder {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.mp-link-thumb-placeholder .material-symbols-outlined { font-size: 22px; }
.mp-link-text {
  min-width: 0;
}
.mp-link-title {
  max-width: 320px;
}
.mp-link-domain {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Message caption column */
.mp-link-caption {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sender column */
.mp-link-sender {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mp-link-sender-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.mp-link-sender-info {
  min-width: 0;
}
.mp-link-sender-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.mp-link-sender-time {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Actions column */
.mp-link-actions {
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.mp-link-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.mp-link-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.mp-link-action-btn .material-symbols-outlined { font-size: 20px; }

/* Link row context menu — reuses .msg-context-menu from message dropdowns */
.mp-link-row .msg-context-menu {
  position: absolute;
  right: 8px;
  top: 100%;
  z-index: 950;
}
.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Responsive ── */
@media (max-width: 768px), (max-width: 1200px) and (orientation: portrait) {
  .media-panel-backdrop { left: 0; }
  .media-panel { width: 95%; max-height: 90vh; }
  .media-panel-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  .mp-links-header .mp-lh-msg,
  .mp-link-caption { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Settings Panel — Master-Detail Layout
   ═══════════════════════════════════════════════════════════════════════════════ */

.settings-panel {
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ── */
.settings-sidebar {
  width: 380px;
  min-width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-self: stretch;
  flex-shrink: 0;
}

.settings-sidebar-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.settings-sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.settings-sidebar-scroll::-webkit-scrollbar { width: 6px; }
.settings-sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.settings-sidebar-scroll::-webkit-scrollbar-thumb { background: #c4c4c4; border-radius: 3px; }

.settings-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 16px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
}
.settings-search .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-secondary);
}
.settings-search input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  font-family: 'Nunito Sans', sans-serif;
}
.settings-search input::placeholder {
  color: var(--text-secondary);
}

/* ── Profile Card ── */
.settings-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: none;
}
.settings-profile-card:hover {
  background: var(--bg-hover);
}

.settings-profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.settings-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-profile-location {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 2px;
}
.settings-profile-username {
  font-size: 12px;
  color: var(--brand-orange);
  font-weight: 700;
}

/* ── Category Items ── */
.settings-categories {
  flex: 1;
  padding: 8px 0;
}

.settings-category-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.settings-category-item:hover {
  background: var(--bg-hover);
}
.settings-category-item.active {
  background: var(--bg-active);
}

.settings-cat-icon {
  font-size: 22px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.settings-category-item.active .settings-cat-icon {
  color: var(--brand-orange);
}

.settings-cat-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-cat-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Log Out ── */
.settings-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
}
.settings-logout:hover {
  background: rgba(234, 67, 53, 0.08);
}

/* ── Content Panel ── */
.settings-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-primary);
}

.settings-content-default {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0.7;
}

.settings-mobile-header {
  display: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
}
.settings-mobile-header .icon-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.15s;
}
.settings-mobile-header .icon-btn:hover {
  background: var(--bg-hover);
}
.settings-mobile-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

/* ── Sub Panels ── */
.settings-sub-panel {
  padding: 32px 40px;
  animation: settingsFadeIn 0.2s ease;
}
@keyframes settingsFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-sub-panel h3 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
}
.settings-sub-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 24px;
}

.settings-sub-section {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 8px 0;
  border: 1px solid var(--border);
}

.settings-sub-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  transition: background 0.15s;
}
.settings-sub-item.clickable {
  cursor: pointer;
}
.settings-sub-item.clickable:hover {
  background: var(--bg-hover);
}
.settings-sub-item .material-symbols-outlined {
  font-size: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-sub-label {
  font-size: 14px;
  font-weight: 600;
}
.settings-sub-value {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Theme Segmented Control */
.theme-segmented-control {
  display: flex;
  width: 100%;
  border-radius: 20px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-top: 5px;
}
.theme-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  background: transparent;
}
.theme-segment:not(:last-child) {
  border-right: 1px solid var(--border);
}
.theme-segment.active {
  color: var(--brand-orange);
  background-color: rgba(255, 114, 0, 0.12); /* Match light orange tint */
}
.theme-segment .segment-icon {
  font-size: 18px !important;
}
.theme-segment.active .segment-icon {
  color: var(--brand-orange);
}

/* ── Account Edit Fields ── */
.settings-edit-field {
  padding: 10px 20px;
}
.settings-edit-field-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-edit-field-header .material-symbols-outlined {
  color: var(--text-secondary);
}
.settings-edit-field-header .settings-edit-icon {
  opacity: 0;
  transition: opacity 0.15s;
}
.settings-edit-field:hover .settings-edit-icon {
  opacity: 1;
}
.settings-edit-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-left: 28px;
}
.settings-edit-inline input {
  flex: 1;
  border: 1px solid var(--brand-orange);
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
}
.settings-edit-inline input:focus {
  box-shadow: 0 0 0 2px rgba(255, 140, 49, 0.2);
}
.settings-edit-inline-actions {
  display: flex;
  gap: 2px;
}
.settings-edit-inline-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}
.settings-edit-inline-actions button:hover {
  background: var(--bg-hover);
}

/* ── Large Profile Avatar ── */
.settings-profile-avatar-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--brand-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 36px;
  color: #fff;
  overflow: hidden;
}
.settings-profile-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Shortcuts List (Mobile/Vertical Style) ── */
.kb-list {
  display: flex;
  flex-direction: column;
}
.kb-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.kb-item:last-child {
  border-bottom: none;
}
.kb-item-label {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px !important;
  background: var(--bg-primary);
  padding: 8px 12px !important;
  border-radius: 8px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.kb-keys {
  display: flex;
  gap: 8px;
}
.kb-key {
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-width: 36px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* Legacy Message Formatting Table */
.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
}
.shortcuts-table td {
  padding: 10px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.shortcuts-table tr:last-child td {
  border-bottom: none;
}
.shortcut-key {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px !important;
  background: var(--bg-primary);
  padding: 4px 10px !important;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-secondary);
  width: 160px;
}

/* ── Settings Responsive ── */

/* Mobile only: stack vertically and hide content until a section is chosen.
   Condition must match isMobileLayout() in chat_v3_v4.js exactly (phones, OR
   tablets up to 1200px in portrait) -- when these two disagreed, a portrait
   iPad (769-1200px) hit the JS mobile branch (hiding the sidebar AND
   chat-main, showing only the settings/stats panel) while this CSS still
   used the old 380px fixed desktop width for .settings-sidebar, leaving the
   rest of the screen a blank grey dead zone with nothing rendered in it. */
@media (max-width: 768px), (max-width: 1200px) and (orientation: portrait) {
  .settings-panel {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex: 1;
    min-height: 0;
  }
  .settings-content {
    display: none;
  }
  
  .settings-panel.mobile-active .settings-sidebar {
    display: none;
  }
  .settings-panel.mobile-active .settings-content {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .settings-mobile-header {
    display: flex !important;
  }
  .settings-sub-panel {
    padding: 32px 16px;
  }
  /* OPL Intelligence panel sets its own inline padding on all four sides; only the
     horizontal component needs to shrink to match the other settings panels on mobile. */
  #settings-sub-opl_intelligence {
    padding: 24px 16px !important;
  }
}



/* ═══ Courts / Locations ═══════════════════════════════════════════════════════ */

.courts-header {
  padding: 0 16px;
}

.courts-tabs {
  display: flex;
  margin: 0;
  border-bottom: 2px solid var(--border);
}

.courts-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.courts-tab.active {
  color: var(--accent, #e87c3e);
  border-bottom-color: var(--accent, #e87c3e);
}

.courts-tab:hover:not(.active) {
  color: var(--text);
}

.courts-browse-count {
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.courts-search {
  position: relative;
  margin: 8px 0 6px;
}

.courts-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text-secondary);
  pointer-events: none;
}

.courts-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--hover);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.courts-search input:focus {
  border-color: var(--accent);
}

/* Location Cards */
.location-card {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}

.location-card:hover {
  background: var(--hover);
}

.location-card .location-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.location-card .location-avatar .location-icon {
  font-size: 22px;
  color: var(--text-secondary);
}

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

.location-card .location-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-card .location-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.location-card .location-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.location-badge.member {
  background: rgba(76, 175, 80, 0.15);
  color: #4CAF50;
}

.location-badge.admin {
  background: rgba(33, 150, 243, 0.15);
  color: #2196F3;
}

/* Court Detail Overlay */
.court-detail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #f5f7fa !important;
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[data-theme="dark"] .court-detail-overlay {
  background-color: #1a1a2e !important;
}

.court-detail-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #f5f7fa;
}

[data-theme="dark"] .court-detail-panel {
  background-color: #1a1a2e;
}

.court-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  height: 64px;
  min-height: 64px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background-color: #f5f7fa;
}

[data-theme="dark"] .court-detail-header {
  background-color: #1a1a2e;
}

.court-detail-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  flex: 1;
  overflow-y: auto;
  background-color: #f5f7fa;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

[data-theme="dark"] .court-detail-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  background-color: #1a1a2e;
}

.court-detail-back {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
}

.court-detail-back:hover {
  background: var(--hover);
}

.court-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.court-detail-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  flex: 1;
  overflow-y: auto;
  padding: 0 0 20px;
}

/* Detail hero */
.court-hero {
  width: 100%;
  height: 180px;
  background: var(--hover);
  overflow: hidden;
  position: relative;
}

.court-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.court-hero .court-hero-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: 48px;
}

/* Detail info */
.court-info-section {
  padding: 20px 5% 16px 5%;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  margin-top: -16px;
  position: relative;
  z-index: 2;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.court-info-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}

.court-info-username {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.court-info-address {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.court-info-address .material-symbols-outlined {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.court-info-stats {
  display: flex;
  gap: 16px;
  padding: 0;
}

.court-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: 10px;
  background: var(--hover);
  border-radius: 8px;
}

.court-stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.court-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Amenities */
.court-amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.court-amenity {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--hover);
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-primary);
}

.court-amenity .material-symbols-outlined {
  font-size: 14px;
}

.court-amenity.available {
  color: #4CAF50;
  background: rgba(76, 175, 80, 0.1);
}

/* Description */
.court-description {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  padding: 0;
}

/* Contact info */
.court-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}

.court-contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.court-contact-item .material-symbols-outlined {
  font-size: 16px;
  color: var(--text-secondary);
}

.court-contact-item a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}

.court-contact-item a:hover {
  text-decoration: underline;
}

/* Join/Leave button */
.court-action-bar {
  padding: 0 5% 16px 5%;
}

.court-join-btn, .court-leave-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.court-join-btn {
  background: var(--accent);
  color: #fff;
}

.court-join-btn:hover {
  filter: brightness(1.1);
  font-weight: 700;
}

.court-leave-btn {
  background: var(--hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.court-leave-btn:hover {
  background: rgba(244, 67, 54, 0.1);
  color: #f44336;
  border-color: #f44336;
  font-weight: 700;
}

/* Loading spinner for courts */
.courts-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  gap: 12px;
}

.courts-loading .spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Pagination */
.courts-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
}

.courts-pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.courts-pagination button:hover:not(:disabled) {
  background: var(--hover);
}

.courts-pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ═══ Club Detail ═════════════════════════════════════════════════════════════ */

.club-organizers-section {
  margin-bottom: 0;
}

.club-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 0;
}

.club-organizer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.club-organizer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.club-organizer-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.club-organizer-avatar-placeholder .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-secondary);
}

.club-organizer-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.club-organizer-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.club-organizer-role {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ─── Add Member Modal ──────────────────────── */
.add-member-modal {
  width: 440px;
  max-height: 72vh;
}

/* Search bar */
.add-member-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  transition: border-color 0.2s;
}
.add-member-search-wrap:focus-within {
  border-color: var(--brand-orange);
}
.add-member-search-wrap .material-symbols-outlined {
  font-size: 20px;
  color: var(--text-secondary);
}
.add-member-search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-family: 'Nunito Sans', sans-serif;
  color: var(--text-primary);
}
.add-member-search-wrap input::placeholder {
  color: var(--text-secondary);
}

/* Selected count badge */
.add-member-count-badge {
  background: var(--brand-orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* Contact list */
.add-member-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 20px;
  max-height: 42vh;
}

.add-member-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

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

/* Custom checkbox — orange brand */
.add-member-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-secondary);
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  background: transparent;
}
.add-member-item input[type="checkbox"]:checked {
  background: var(--brand-orange);
  border-color: var(--brand-orange);
}
.add-member-item input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.add-member-item input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Avatar */
.add-member-item .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 14px;
  flex-shrink: 0;
}

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

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

.add-member-item-status {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.add-member-item.already-member {
  opacity: 0.45;
  cursor: default;
}

/* Footer buttons — pill shape */
.add-member-modal .modal-footer {
  padding: 14px 20px;
  gap: 10px;
}
.add-member-modal .btn-secondary,
.add-member-modal .btn-primary {
  padding: 10px 28px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Nunito Sans', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.add-member-modal .btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.add-member-modal .btn-secondary:hover {
  background: var(--bg-hover);
}
.add-member-modal .btn-primary {
  background: var(--brand-orange);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255,140,49,0.3);
}
.add-member-modal .btn-primary:hover {
  opacity: 0.9;
  box-shadow: 0 4px 14px rgba(255,140,49,0.4);
}

/* Close button — styled × */
.add-member-modal .modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}
.add-member-modal .modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* ─── Invite Link Panel ─────────────────────── */
.ci-invite-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.ci-invite-action:hover {
  background: var(--bg-hover);
}
.ci-invite-action .material-symbols-outlined {
  font-size: 22px;
}

/* ─── Group Info Card (empty chat) ───────────── */
.group-info-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  margin: auto;
  max-width: 380px;
  text-align: center;
}

.group-info-card .conv-avatar {
  width: 80px;
  height: 80px;
  font-size: 28px;
  margin-bottom: 12px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.group-info-card .conv-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.group-info-card-stats {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.group-info-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 16px;
}

.group-info-card-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.group-info-card-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--brand-orange);
  background: transparent;
  color: var(--brand-orange);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.group-info-card-actions button:hover {
  background: var(--brand-orange);
  color: #fff;
}

.group-info-card-actions button .material-symbols-outlined {
  font-size: 18px;
}

/* ─── Members Section (Contact Info Panel) ─────────────────────────────────── */

.ci-members-section {
  padding: 0 0 8px;
}

.ci-members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.ci-member-action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
  color: var(--text-primary);
}

.ci-member-action-row:hover {
  background: var(--bg-hover);
}

.ci-member-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ci-member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  position: relative;
}

.ci-member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-purple-light, #6c5ce7);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

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

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

.ci-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-admin-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--brand-orange);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--brand-orange);
  margin-top: 2px;
  white-space: nowrap;
}

/* Member dropdown */
.ci-member-dropdown-wrap {
  position: relative;
  margin-left: auto;
}

.ci-member-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: background 0.15s;
}

.ci-member-dropdown-btn:hover {
  background: var(--bg-hover);
}

.ci-member-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 180px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  padding: 4px 0;
}

.ci-member-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

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

/* ─── Fly-in Panel (Group Permissions) ─────────────────────────────────────── */

.ci-flyin-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.ci-flyin-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.ci-flyin-back {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: background 0.15s;
}

.ci-flyin-back:hover {
  background: var(--bg-hover);
}

.ci-perm-section {
  padding: 16px 20px 8px;
}

.ci-perm-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 12px;
}

.ci-perm-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
}

.ci-perm-info {
  flex: 1;
}

.ci-perm-title {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.ci-perm-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

/* Toggle Switch */
.ci-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

.ci-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ci-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 22px;
  transition: 0.2s;
}

.ci-toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.ci-toggle input:checked + .ci-toggle-slider {
  background: var(--brand-orange);
}

.ci-toggle input:checked + .ci-toggle-slider::before {
  transform: translateX(18px);
}

/* ─── Court Edit Form ──────────────────────────────────────────────────────── */

.ci-edit-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
  animation: ciSlideIn 0.25s ease-out;
}

.ci-edit-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  height: 64px;
  min-height: 64px;
  box-sizing: border-box;
  background: var(--bg-tertiary);
}

.ci-edit-header .ci-back-btn {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 22px;
  transition: color 0.15s;
}

.ci-edit-header .ci-back-btn:hover {
  color: var(--brand-purple);
}

[data-theme="dark"] .ci-edit-header .ci-back-btn {
  color: #818CFF;
}

.ci-edit-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.ci-edit-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 90px;
}

/* WhatsApp-style avatar upload */
.ci-edit-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.ci-edit-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.ci-edit-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  color: #fff;
}

.ci-edit-avatar:hover .ci-edit-avatar-overlay {
  opacity: 1;
}

.ci-edit-avatar-overlay .material-symbols-outlined {
  font-size: 28px;
  margin-bottom: 2px;
}

.ci-edit-avatar-overlay span:last-child {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Section headers */
.ci-edit-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--brand-orange);
  margin: 20px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .ci-edit-section {
  color: #818CFF;
  border-bottom-color: rgba(129, 140, 255, 0.25);
}

.ci-edit-section:first-of-type {
  margin-top: 0;
}

/* Field groups */
.ci-edit-field {
  margin-bottom: 14px;
}

.ci-edit-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary) !important;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ci-edit-field input,
.ci-edit-field textarea,
.ci-edit-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.ci-edit-field input:focus,
.ci-edit-field textarea:focus,
.ci-edit-field select:focus {
  border-color: var(--brand-purple);
}

.ci-edit-field textarea {
  resize: vertical;
  min-height: 80px;
}

.ci-edit-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Two-column field row */
.ci-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Address sub-fields */
.ci-edit-address-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* Toggle rows for amenities */
.ci-edit-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.ci-edit-toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 0 0 calc(50% - 4px);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  font-size: 13px;
}

.ci-edit-toggle-item:hover {
  border-color: var(--brand-purple);
}

.ci-edit-toggle-item.active {
  border-color: var(--brand-orange);
  background: rgba(244,192,131,0.1);
}

.ci-edit-toggle-item .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-secondary);
}

.ci-edit-toggle-item.active .material-symbols-outlined {
  color: var(--brand-orange);
}

.ci-edit-toggle-item .toggle-check {
  margin-left: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.ci-edit-toggle-item.active .toggle-check {
  border-color: var(--brand-orange);
  background: var(--brand-orange);
}

.ci-edit-toggle-item.active .toggle-check::after {
  content: '✓';
  font-size: 11px;
  color: #fff;
  font-weight: bold;
}


/* ── Per-sport accordion (Edit Court) ──────────────────────────────── */
.ci-sport-toggle-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}

.ci-sport-toggle-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  background: var(--bg-secondary);
  user-select: none;
  transition: background 0.15s;
}

.ci-sport-toggle-header:hover {
  background: var(--bg-tertiary);
}

.ci-sport-pill-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.ci-sport-pill-switch::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.ci-sport-pill-switch.on {
  background: var(--brand-orange-hover, #ffb338);
}

.ci-sport-pill-switch.on::after {
  transform: translateX(16px);
}

.ci-sport-toggle-label {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.ci-sport-chevron {
  color: var(--text-secondary);
  font-size: 20px !important;
  transition: transform 0.2s;
}

.ci-sport-section-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ci-sport-courts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ci-sport-features-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.ci-edit-section-sub {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin: 4px 0 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.ci-edit-amenities-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.ci-amenity-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.ci-amenity-item .material-symbols-outlined {
  font-size: 15px;
  flex-shrink: 0;
}

.ci-amenity-item .toggle-check {
  margin-left: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.ci-amenity-item.active {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
  background: rgba(244,192,131,0.1);
}

.ci-amenity-item.active .toggle-check {
  background: var(--brand-orange);
  border-color: var(--brand-orange);
}

.ci-amenity-item.active .toggle-check::after {
  content: '✓';
  font-size: 10px;
  color: #fff;
  font-weight: bold;
}

[data-theme="dark"] .ci-sport-section-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  background: var(--bg-secondary);
}

/* Sticky save/cancel bar */

.ci-edit-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  min-height: 73px;
  box-sizing: border-box;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
}

.ci-edit-actions button {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.ci-edit-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ci-edit-btn-cancel {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border) !important;
}

.ci-edit-btn-save {
  background: var(--brand-purple);
  color: #fff;
}

.ci-edit-btn-save:hover:not(:disabled) {
  opacity: 0.9;
}

/* Claim court/club & Edit trigger buttons */
.ci-claim-btn,
.ci-edit-trigger {
  display: flex;
  align-items: center;
  margin: 0 0 12px 0;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-sizing: border-box;
  width: 100%;
}

.ci-claim-btn:hover,
.ci-edit-trigger:hover {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
}

.ci-claim-btn:hover > span:not(.material-symbols-outlined),
.ci-edit-trigger:hover > span:not(.material-symbols-outlined) {
  font-weight: 700 !important;
}

.ci-claim-btn .material-symbols-outlined,
.ci-edit-trigger .material-symbols-outlined,
.ci-action-row .material-symbols-outlined,
.ci-action-btn .material-symbols-outlined,
.court-leave-btn .material-symbols-outlined {
  font-weight: 400 !important;
  color: var(--text-secondary);
}

.ci-action-btn.danger .material-symbols-outlined,
.ci-edit-trigger.danger .material-symbols-outlined {
  color: #c0392b !important;
}

.ci-edit-trigger.danger {
  color: #c0392b !important;
}

.ci-edit-trigger.danger:hover {
  border-color: #c0392b;
}

.ci-action-btn.warning .material-symbols-outlined {
  color: var(--accent);
}

.ci-claim-btn .material-symbols-outlined:first-child,
.ci-edit-trigger .material-symbols-outlined:first-child {
  font-size: 22px;
  margin-right: 12px;
}

.ci-claim-btn .ci-chevron,
.ci-edit-trigger .ci-chevron {
  font-size: 20px;
  color: var(--text-secondary);
  margin-left: auto;
  margin-right: 0;
}

/* Google autocomplete dropdown override */
.pac-container {
  z-index: 10000 !important;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  font-family: inherit;
  margin-top: 2px;
  background: var(--bg-primary);
}

.pac-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
}

.pac-item:first-child {
  border-top: none;
}

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

.pac-item-query {
  font-weight: 600;
  color: var(--text-primary);
}

.pac-icon {
  display: none;
}

.pac-logo::after {
  /* Hide the "powered by Google" branding — we comply by showing it as text */
  display: none !important;
}

/* Mobile responsive — edit form */
@media (max-width: 768px) {
  .ci-edit-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
  }

  .ci-edit-row {
    grid-template-columns: 1fr;
  }

  .ci-edit-address-grid {
    grid-template-columns: 1fr;
  }

  .ci-edit-toggle-item {
    flex: 0 0 100%;
  }

  .ci-edit-avatar {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 600px) {
  .ci-edit-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

    padding: 12px;
    padding-bottom: 90px;
  }

  .ci-edit-field input,
  .ci-edit-field textarea,
  .ci-edit-field select {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .ci-edit-actions {
    padding: 10px 12px;
  }

  .ci-edit-actions button {
    padding: 12px 16px;
  }


}

/* Claim court confirmation modal */
.ci-claim-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}

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

.ci-claim-modal {
  background: var(--bg-primary);
  border-radius: 16px;
  padding: 28px 24px 20px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  animation: modalSlideUp 0.2s ease-out;
}

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

.ci-claim-modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b3a8c 0%, var(--brand-purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.ci-claim-modal-icon .material-symbols-outlined {
  font-size: 28px;
  color: #fff;
}

.ci-claim-modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.ci-claim-modal p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.5;
}

.ci-claim-modal-actions {
  display: flex;
  gap: 10px;
}

.ci-claim-modal-actions button {
  flex: 1;
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: inherit;
}

.ci-claim-modal-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ci-claim-modal-cancel {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border) !important;
}

.ci-claim-modal-confirm {
  background: linear-gradient(135deg, #5b3a8c 0%, var(--brand-purple) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ci-claim-modal-confirm:hover:not(:disabled) {
  opacity: 0.9;
}

/* ═══════════════════════════════════════════════════════════════════════════
   OPL Badge
   ═══════════════════════════════════════════════════════════════════════════ */

.opl-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-purple) 0%, #7c5ce7 100%);
  border-radius: 4px;
  vertical-align: middle;
  line-height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Results Panel Overlay
   ═══════════════════════════════════════════════════════════════════════════ */

.results-panel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 40;
  display: flex;
  flex-direction: column;
  animation: ciSlideIn 0.25s ease-out;
  overflow: hidden;
}

.results-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.results-panel-header .conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  margin-right: 0;
}

.results-panel-header .conv-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.results-panel-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.results-sub-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.results-sub-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
  font-family: inherit;
}

.results-sub-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.results-sub-tab.active {
  color: var(--brand-purple);
  border-bottom-color: var(--brand-purple);
}

.results-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  overflow-x: auto;
}

.results-game-type-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.results-type-btn {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.results-type-btn.active {
  background: var(--brand-purple);
  color: #fff;
}

.results-counts {
  display: flex;
  gap: 8px;
}

.results-count-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.results-filters {
  display: flex;
  gap: 8px;
  padding: 4px 16px 8px;
  flex-shrink: 0;
}

.results-search-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

.results-search-input:focus {
  border-color: var(--brand-purple);
}

.results-date-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.results-date-input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
  outline: none;
  width: 84px;
  flex-shrink: 0;
  text-align: center;
  cursor: pointer;
}

.results-date-input:focus {
  border-color: var(--brand-purple);
}

.pro-upsell-hero {
  position: relative;
  background-image: url('/MYOPL_Signup.webp');
  background-size: cover;
  background-position: center top;
  padding: 40px 20px 80px 20px;
  text-align: center;
  overflow: visible;
}

.pro-upsell-hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pro-upsell-title {
  color: #ffffff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.pro-pill-container {
  margin-bottom: 8px;
}

.pro-pill {
  background-color: #d4af37;
  color: #111;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}

.pro-upsell-headline {
  color: #ffffff;
  font-size: 34px;
  font-weight: 800;
  margin: 0 0 24px 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  letter-spacing: 0.5px;
}

.pro-upsell-desc {
  max-width: 480px;
  color: #f3f4f6;
  font-size: 15px;
  line-height: 1.6;
  margin: 0 auto;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.pro-badge-savings {
  position: absolute;
  top: 10px;
  right: calc(50% - 220px);
  background-color: #a7f3d0;
  color: #064e3b;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transform: rotate(8deg);
  z-index: 10;
}
@media (max-width: 500px) {
  .pro-badge-savings { right: 10px; top: 0px; }
}

.pro-badge-savings-text {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.pro-badge-savings-amount {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

.pro-pricing-container {
  position: relative;
  z-index: 3;
  margin-top: -30px;
  padding: 0 20px 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pro-pricing-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-orange);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 8px 30px rgba(255, 140, 49, 0.15); /* orange glow */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pro-pricing-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.pro-pricing-price {
  color: var(--text-primary);
  margin-bottom: 2px;
}

.pro-pricing-amount {
  font-size: 44px;
  font-weight: 800;
}

.pro-pricing-period {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 600;
}

.pro-pricing-billed {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}

.pro-pricing-divider {
  width: 100%;
  height: 1px;
  background-color: var(--border-color);
  margin-bottom: 16px;
}

.pro-pricing-footer-text {
  width: 100%;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.pro-save-text {
  color: #10b981;
  font-weight: 700;
  margin-right: 4px;
}

.pro-limited-text {
  font-weight: 600;
}

.pro-upgrade-btn {
  width: 100%;
  max-width: 420px;
  background-color: var(--brand-orange);
  color: #111;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.2s, background-color 0.2s;
  box-shadow: 0 4px 12px rgba(255, 140, 49, 0.3);
}

.pro-upgrade-btn:hover {
  transform: translateY(-2px);
  background-color: var(--brand-orange-hover);
}

.pro-social-proof {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 16px;
}

.results-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.results-loading,
.results-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  gap: 12px;
  font-size: 13px;
}

.results-loading .spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Leaderboard table */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.results-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.results-table thead th:first-child {
  padding-left: 16px;
  width: 40px;
}

.results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.results-table tbody tr:hover {
  background: var(--bg-hover);
}

.results-table tbody td {
  padding: 10px 10px;
  color: var(--text-primary);
}

.results-table tbody td:first-child {
  padding-left: 16px;
  font-weight: 700;
  color: var(--brand-purple);
}

[data-theme="dark"] .results-table tbody td:first-child {
  color: #a78bfa; /* lighter violet — readable on dark backgrounds */
}

.results-player-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

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

.results-player-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.results-rank-score {
  font-weight: 700;
  color: var(--brand-orange);
}

@media (max-width: 768px) {
  .results-table thead th {
    padding: 6px 6px;
    font-size: 10px;
  }
  .results-table thead th:first-child {
    padding-left: 10px;
  }
  .results-table tbody td {
    padding: 8px 6px;
  }
  .results-table tbody td:first-child {
    padding-left: 10px;
  }
  .results-player-name {
    max-width: 90px;
  }
}

/* Match cards */
/* ─── Score Card Matches Tab ── */
.results-match-card-v2 {
  margin: 0 16px 10px;
}

.results-match-card-v2:first-child {
  margin-top: 8px;
}

.results-match-card-v2 .score-card {
  font-size: 13px;
}

.results-match-card-v2 .sc-player-name {
  max-width: 140px;
}

/* Legacy match card (kept for backwards compatibility) */
.results-match-card {
  margin: 0 16px 8px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.results-match-card:first-child {
  margin-top: 8px;
}

.results-match-date {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.results-match-players {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.results-match-player {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.results-match-player-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.results-match-vs {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.results-match-score {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
}

.results-match-score-set {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.results-match-winner {
  color: var(--brand-orange);
}

/* Pagination */
.results-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.results-scroll-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.results-page-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.results-page-btn:hover:not(:disabled) {
  border-color: var(--brand-purple);
  color: var(--brand-purple);
}

.results-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.results-page-info {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   New Match Dialog
   ═══════════════════════════════════════════════════════════════════════════ */

.new-match-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}

.new-match-dialog {
  background: var(--bg-primary);
  border-radius: 16px;
  width: 440px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: modalSlideUp 0.2s ease-out;
  border: 1px solid var(--border);
}

/* New Match, hosted inline in the Info panel instead of the floating
   backdrop modal — same overlay technique as .ci-edit-panel (absolute,
   inset:0, same z-index/animation) so it looks consistent with
   "Suggest an edit". */
.new-match-dialog.in-panel {
  position: absolute;
  inset: 0;
  width: auto;
  max-width: none;
  height: auto;
  max-height: none;
  border-radius: 0;
  border: none;
  box-shadow: none;
  z-index: 30;
  animation: ciSlideIn 0.25s ease-out;
}

.new-match-dialog.in-panel .new-match-header {
  border-radius: 0;
}

.new-match-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 2;
  border-radius: 16px 16px 0 0;
}

.new-match-header h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  color: var(--text-primary);
}

/* Footer: Cancel + Save Match, matching Flutter's fixed action bar exactly
   (AppColors.brandPurple solid Save button, outlined Cancel) instead of a
   single Save button in the header. */
.new-match-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  position: sticky;
  bottom: 0;
}

.new-match-cancel-btn {
  flex: 1;
  height: 48px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.new-match-submit-btn {
  flex: 1;
  height: 48px;
  font-size: 14px !important;
  padding: 0 18px !important;
  border-radius: 8px !important;
  font-weight: 700;
  white-space: nowrap;
  background: var(--brand-purple) !important;
  box-shadow: none !important;
}

.new-match-submit-btn:hover {
  transform: none;
  box-shadow: none;
  opacity: 0.9;
}

.new-match-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* Dark mode: white border around the Save button so it doesn't blend into
   the dark footer background. */
[data-theme="dark"] .new-match-submit-btn {
  border: 1px solid #fff;
}

/* ─── Team Group Visual Containers ── */
.nm-team-group {
  margin: 4px 10px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  padding: 2px 0;
}

.nm-team-group .new-match-section {
  padding: 6px 12px;
}

.nm-team-1 {
  border-left-color: var(--brand-purple, #7c3aed);
  border-right-color: var(--brand-purple, #7c3aed);
  background: rgba(124, 58, 237, 0.22);
}

.nm-team-2 {
  border-left-color: var(--brand-orange, #FF8C31);
  border-right-color: var(--brand-orange, #FF8C31);
  background: rgba(255, 140, 49, 0.22);
  margin-bottom: 16px;
}

[data-theme="dark"] .nm-team-1 {
  border-left-color: #a78bfa;
  border-right-color: #a78bfa;
}

[data-theme="dark"] .nm-team-2 {
  border-left-color: #ffb366;
  border-right-color: #ffb366;
}

.new-match-section {
  padding: 8px 16px;
}

.new-match-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-orange) !important;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* Game Type Toggle */
.new-match-type-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.new-match-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.new-match-type-btn.active {
  background: var(--brand-purple);
  color: #fff;
}

.new-match-type-btn:hover:not(.active) {
  background: var(--bg-hover);
}

/* Player fields */
.new-match-player-field {
  margin-bottom: 8px;
}

.new-match-player-field:last-child {
  margin-bottom: 0;
}

.new-match-player-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

.new-match-search-wrap {
  position: relative;
}

.new-match-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.new-match-input:focus {
  border-color: var(--brand-purple);
}

/* Make the native date/time picker clock/calendar icon visible in dark mode */
[data-theme="dark"] .new-match-input::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: brightness(0) invert(1);
  opacity: 0.9;
  cursor: pointer;
}

.new-match-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* Last player field in Team 2: open dropdown upward */
.nm-team-2 .new-match-player-field:last-child .new-match-search-results {
  top: auto;
  bottom: 100%;
  border-top: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.15);
}

.new-match-search-results.active {
  display: block;
}

.nm-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

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

.nm-search-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
  flex-shrink: 0;
}

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

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

.nm-search-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-search-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.nm-search-empty {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Selected player chip */
.new-match-selected-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--brand-purple);
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 6px;
}

.new-match-selected-player .nm-search-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--brand-purple-light, #e8e0f0);
  color: var(--brand-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.new-match-selected-player .nm-search-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.new-match-selected-player .nm-selected-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.new-match-selected-player .nm-selected-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.new-match-selected-player .nm-selected-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.new-match-selected-player .nm-selected-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 2px;
  display: flex;
  align-items: center;
}

.new-match-selected-player .nm-selected-clear:hover {
  color: #e74c3c;
}

/* Scores */
.new-match-scores {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nm-score-set {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nm-score-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 56px;
}

.nm-score-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.nm-score-dash {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
}

.nm-score-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.nm-score-remove:hover {
  color: #e74c3c;
}

.new-match-add-set-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.new-match-add-set-btn:hover {
  border-color: var(--brand-purple);
  color: var(--brand-purple);
}

/* Status message */
.new-match-status {
  padding: 10px 16px 14px;
  font-size: 13px;
  text-align: center;
}

.new-match-status.error {
  color: #e74c3c;
}

.new-match-status.success {
  color: #2ecc71;
}

/* ─── Entity Info Header (+ inline date) ── */
.nm-entity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px !important;
}

.nm-entity-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.nm-entity-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

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

.nm-entity-details {
  flex: 1;
  min-width: 0;
}

.nm-entity-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-entity-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-datetime-inline {
  width: auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  flex-shrink: 0;
  box-sizing: border-box;
}

.nm-datetime-inline:focus {
  border-color: var(--brand-purple);
}

/* ─── Player 1 (Current User) ── */
.nm-player1-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.nm-player1-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

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

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

.nm-player1-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.nm-player1-username {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ─── Player Rating Badge ── */
.nm-player-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-orange);
  background: var(--brand-orange-dim);
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.nm-player-rating .material-symbols-outlined {
  font-size: 14px;
}

.nm-player-rating.no-rating {
  color: var(--text-secondary);
  background: transparent;
  font-weight: 600;
}

/* ═══ Score Grid (5-column horizontal layout matching design) ═══ */
.nm-score-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.nm-score-grid .nm-score-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nm-score-grid .nm-score-cell input[type="number"] {
  width: 52px;
  height: 44px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.nm-score-grid .nm-score-cell input[type="number"]:focus {
  border-color: var(--brand-purple);
}

.nm-score-grid .nm-score-dash {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 0 4px;
  display: flex;
  align-items: center;
  height: 44px;
}

.nm-score-game-labels {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 2px 0;
  padding: 0 10px;
}

.nm-score-game-labels .nm-game-label {
  width: 52px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-primary);
}

.nm-score-game-labels .nm-game-label-dash {
  padding: 0 4px;
  width: auto;
  display: inline-block;
  font-size: 14px;
  color: transparent;
}

/* ─── Score Hint ── */
.nm-score-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--brand-orange);
  letter-spacing: 0;
  text-transform: none;
}

.new-match-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── Location Dropdown ── */
.nm-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239b92c1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ─── Datetime Input ── */
.nm-datetime {
  cursor: pointer;
}

.nm-datetime::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

/* ─── Responsive ── */
@media (max-width: 480px) {
  .new-match-dialog {
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
  }

  .nm-spinner-value {
    font-size: 18px;
    height: 36px;
    width: 50px;
  }

  .nm-spinner-btn {
    width: 32px;
    height: 24px;
  }

  .nm-spinner {
    width: 50px;
  }
}

/* ─── Score Card Message ──────────────────────────────────────────────────── */

.message.score-message,
.message.event-message {
  justify-content: center !important;
  padding: 4px 0;
  max-width: 100% !important;
}

.message.score-message .msg-select-wrapper,
.message.event-message .msg-select-wrapper {
  max-width: 420px;
  width: 100%;
}

.message.score-message .msg-meta {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 2px 8px 0;
}

.score-card {
  background: var(--bg-primary);
  border: 1px solid var(--brand-orange);
  border-radius: 12px;
  overflow: hidden;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
}

.sc-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
}

/* Date/time now lives in the header (not the body row below), so the body
   can give its full width to game info instead of sharing it with a date
   column. */
.sc-header .sc-date-col {
  padding: 0;
}

.sc-header-main {
  flex: 1;
  min-width: 0;
}

.sc-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--accent);
  font-size: 13px;
}

.sc-header-title-row > .material-symbols-outlined {
  font-size: 18px;
}

/* Row 2: time + confirmation status. Status text ("Awaiting confirmation")
   is longer than the title row has room for next to "Doubles Match
   Recorded", so it lives here instead. */
.sc-header-status-row {
  display: flex;
  align-items: center;
  margin-top: 6px;
}

.sc-header-status-row > .sc-time {
  font-size: 13px;
  color: var(--text-secondary);
}

.sc-header-status-row .sc-confirm-btn,
.sc-header-status-row .sc-confirmed,
.sc-header-status-row .sc-pending {
  margin-left: auto;
}

.sc-confirm-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 20px;
  background: var(--bg-primary);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sc-confirm-btn:hover {
  background: var(--accent);
  color: #fff;
}

.sc-confirm-btn .material-symbols-outlined {
  font-size: 16px;
}

.sc-confirmed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #16a34a;
  font-size: 13px;
  font-weight: 600;
}

.sc-confirmed .material-symbols-outlined {
  font-size: 16px;
}

.sc-pending {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
}

.sc-pending .material-symbols-outlined {
  font-size: 16px;
}

.sc-body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  display: flex;
  padding: 10px 14px 12px;
  gap: 20px;
}

.sc-date-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 52px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}

.sc-date {
  font-weight: 600;
  color: var(--text-primary);
}

.sc-teams-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sc-team-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--divider);
}

.sc-team-row.sc-winner {
  background: rgba(var(--accent-rgb, 234, 88, 12), 0.06);
  border: 1px solid rgba(var(--accent-rgb, 234, 88, 12), 0.3);
}

.sc-players {
  flex: 1;
  min-width: 0;
}

.sc-player {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

.sc-player-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--brand-orange);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

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

.sc-player-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.sc-player-flag {
  font-size: 12px;
  flex-shrink: 0;
}

.sc-player-rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.sc-player-rating .material-symbols-outlined {
  font-size: 13px;
}

.sc-scores {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sc-score-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 700;
  background: var(--bg-tertiary);
  border-radius: 6px;
  border: 1px solid #999;
}

[data-theme="dark"] .sc-score-cell {
  border: 1px solid var(--border);
}

.sc-score-cell.sc-win {
  font-weight: 800;
  color: var(--accent);
  background: rgba(var(--accent-rgb, 234, 88, 12), 0.15);
  border: none;
}

.sc-win-arrow {
  font-size: 14px;
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 500px) {
  .message.score-message .msg-select-wrapper,
  .message.event-message .msg-select-wrapper {
    max-width: 100%;
  }

  .sc-body {
    gap: 12px;
  }

  .sc-player-name {
    max-width: 80px;
  }

  /* On a match with 4-5 games, the score columns eat most of the row's
     width, squeezing player info the hardest -- seeing WHO played matters
     more than their rating number in that tight a space, so drop the
     rating first and give the freed-up width back to the name instead of
     truncating it further. Matches with 1-3 games have enough room as-is. */
  .sc-body-many-games .sc-player-rating {
    display: none;
  }

  .sc-body-many-games .sc-player-name {
    max-width: 140px;
  }

}

@media (max-width: 375px) {
  .sc-body {
    padding: 8px 10px;
    gap: 8px;
  }

  .sc-player-name {
    max-width: 60px;
  }

  .sc-player-rating {
    font-size: 10px;
  }

  .sc-score-cell {
    width: 22px;
    height: 20px;
    font-size: 12px;
  }

  .sc-body-many-games .sc-player-name {
    max-width: 100px;
  }
}


.msg-avatar-container {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-self: flex-end;
  margin-bottom: 12px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.msg-avatar-placeholder {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

/* Tablet Portrait: Split screen but with bottom nav */
@media (min-width: 768px) and (max-width: 900px),
       (min-width: 768px) and (max-width: 1200px) and (orientation: portrait) {
  .nav-rail { display: none !important; }
  .footer-nav { display: flex !important; }
}

.messages-container::after {
  content: '';
  display: block;
  min-height: 16px;
  flex-shrink: 0;
}

/* ─── Theme Toggle Button ──────────────────── */
/* Must be position:fixed so it doesn't participate in flex layout and cause
   the chat-main content to be pushed down. Visually anchored bottom-left. */
.theme-toggle {
  position: fixed;
  bottom: 16px;
  left: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: var(--transition);
  line-height: 1;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  transform: scale(1.1);
}

/* AI Response Card Styling */
.msg-bubble.ai-response {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

[data-theme="dark"] .msg-bubble.ai-response {
  background: var(--bg-secondary);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* OPL Intelligence Avatar Specifics */
/* Light Mode (Default) - White background, Purple Icon */
img.msg-avatar[src*="MyOPL_AI.svg"],
img.conv-avatar[src*="MyOPL_AI.svg"],
.msg-avatar-container img[src*="MyOPL_AI.svg"],
.conv-avatar img[src*="MyOPL_AI.svg"],
.avatar img[src*="MyOPL_AI.svg"] {
  content: url('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7') !important;
  background-image: url('https://cdn.myopl.net/images/MyOPL_AI_Purple.svg?v=5') !important;
  background-color: #ffffff !important;
  background-size: 70% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border-radius: 50% !important;
  border: none !important;
  box-shadow: inset 0 0 0 2px #ffffff, 0 2px 4px rgba(0,0,0,0.05) !important;
  box-sizing: border-box !important;
}

/* Dark Mode - Deep Purple background, White Icon */
[data-theme="dark"] img.msg-avatar[src*="MyOPL_AI.svg"],
[data-theme="dark"] img.conv-avatar[src*="MyOPL_AI.svg"],
[data-theme="dark"] .msg-avatar-container img[src*="MyOPL_AI.svg"],
[data-theme="dark"] .conv-avatar img[src*="MyOPL_AI.svg"],
[data-theme="dark"] .avatar img[src*="MyOPL_AI.svg"] {
  content: url('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7') !important;
  background-image: url('https://cdn.myopl.net/images/MyOPL_AI_White.svg?v=5') !important;
  background-color: #29086D !important;
  background-size: 70% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  border: none !important;
  box-shadow: inset 0 0 0 2px #29086D !important;
  box-sizing: border-box !important;
}

/* AI Disclaimer Modal Logos */
img.ai-disclaimer-logo {
  content: url('https://cdn.myopl.net/images/MyOPL_AI_Purple.svg?v=5');
}
[data-theme="dark"] img.ai-disclaimer-logo {
  content: url('https://cdn.myopl.net/images/MyOPL_AI_White.svg?v=5');
}

/* Markdown Formatting Resets */
.msg-text h1, .msg-text h2, .msg-text h3, .msg-text h4 {
  margin: 12px 0 8px 0;
  font-weight: 700;
  line-height: 1.3;
}
.msg-text h1 { font-size: 1.4em; }
.msg-text h2 { font-size: 1.25em; }
.msg-text h3 { font-size: 1.1em; }
.msg-text p {
  margin: 0 0 10px 0;
  line-height: 1.5;
}
.msg-text p:last-child {
  margin-bottom: 0;
}
.msg-text ul, .msg-text ol {
  margin: 0 0 10px 0;
  padding-left: 24px;
}
.msg-text li {
  margin-bottom: 6px;
  line-height: 1.5;
}
.msg-text pre {
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.9em;
  margin: 10px 0;
}
.msg-text code {
  background: var(--bg-tertiary);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}
.msg-bubble.ai-response .sender-name {
  color: var(--brand-orange);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  display: block;
}

/* AI Disclaimer bullet icons and headings */
.ai-bullet-svg {
  color: #29086D;
}
.ai-bullet-icon {
  color: #29086D;
}
.ai-brand-text {
  color: #29086D !important;
}
[data-theme="dark"] .ai-bullet-svg {
  color: #ffffff;
}
[data-theme="dark"] .ai-bullet-icon {
  color: #ffffff;
}
[data-theme="dark"] .ai-brand-text {
  color: #ffffff !important;
}

/* Profile Names Dark Mode Overrides */
[data-theme="dark"] .conv-info .conv-name,
[data-theme="dark"] .contact-item .contact-name,
[data-theme="dark"] .settings-cat-title,
[data-theme="dark"] .mp-link-title,
[data-theme="dark"] .settings-profile-name,
[data-theme="dark"] .chat-header-info h3,
[data-theme="dark"] .ci-section-title,
[data-theme="dark"] .message .sender-name {
  color: #ffffff;
}

.ci-location .material-symbols-outlined {
  font-size: 14px !important;
  color: var(--text-secondary) !important;
  font-variation-settings: 'wght' 400 !important;
  margin-right: 4px !important;
}

/* Premium Upgrade Popover */
.premium-popover {
  position: absolute;
  bottom: 80px;
  left: 45px;
  background: #090e35; /* Premium dark blue background */
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  padding: 16px 20px;
  z-index: 1001;
  min-width: 250px;
  max-width: 320px;
  animation: fadeInUp 0.2s ease-out;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.premium-popover-content {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.premium-popover-icon {
  width: 24px;
  height: 24px;
  color: #7f7fd5; /* Dotted ring icon color */
  flex-shrink: 0;
  margin-top: 2px;
}

.premium-popover-text {
  display: flex;
  flex-direction: column;
}

.premium-popover-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff !important;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.premium-popover-desc {
  font-size: 13.5px;
  line-height: 1.45;
  color: #a2a8cc !important;
  font-weight: 500;
}

/* Light Mode Overrides for Premium Popover */
[data-theme="light"] .premium-popover {
  background: #ffffff;
  border: 1px solid rgba(45, 5, 114, 0.15); /* Soft purple border */
  box-shadow: 0 12px 36px rgba(45, 5, 114, 0.12); /* Deep purple shadow */
}

[data-theme="light"] .premium-popover-title {
  color: var(--brand-purple) !important; /* Elegant brand purple */
}

[data-theme="light"] .premium-popover-desc {
  color: #6b6190 !important; /* Matching text-secondary in light mode */
}

[data-theme="light"] .premium-popover-icon {
  color: var(--brand-orange) !important; /* Vibrant orange spinner */
}

/* OPL Intelligence Tiered Settings & FOMO Styles */
.opl-settings-tier-section {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  position: relative;
  transition: all 0.3s ease;
}

.opl-settings-tier-section:hover {
  border-color: rgba(255, 150, 0, 0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.opl-settings-tier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.opl-settings-tier-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.opl-settings-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  position: relative;
}

.opl-settings-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.opl-settings-item-info {
  flex: 1;
  padding-right: 16px;
}

.opl-settings-item-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.opl-settings-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

/* Disabled & Locked States for FOMO */
.opl-settings-item-disabled {
  opacity: 0.5;
}

.opl-settings-item-disabled-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  cursor: pointer;
  z-index: 10;
}

.opl-settings-tier-locked {
  border-color: var(--border) !important;
  background: rgba(255, 255, 255, 0.01) !important;
}

.opl-settings-tier-locked:hover {
  border-color: rgba(255, 150, 0, 0.3) !important;
}

.opl-settings-tier-locked .ci-toggle-slider {
  background: var(--border) !important;
  cursor: not-allowed;
}

.opl-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

/* Premium Badges & Accents */
.premium-badge-gold {
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
  color: var(--brand-purple) !important;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.premium-badge-sapphire {
  background: linear-gradient(135deg, #007fff 0%, #0000ff 100%);
  color: #fff !important;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(0, 127, 255, 0.3);
}

.premium-badge-current {
  background: var(--bg-secondary);
  border: 1.5px solid var(--brand-orange);
  color: var(--brand-orange);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  position: absolute;
  top: -11px;
  right: 20px;
  z-index: 2;
  letter-spacing: 0.5px;
}

.premium-badge-available {
  background: var(--brand-orange);
  border: 1.5px solid var(--brand-orange);
  color: #ffffff !important;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  position: absolute;
  top: -11px;
  right: 20px;
  z-index: 2;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(255, 140, 49, 0.4);
}

.premium-badge-locked {
  background: var(--bg-secondary);
  border: 1.5px solid var(--brand-purple);
  color: var(--brand-purple);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  position: absolute;
  top: -11px;
  right: 20px;
  z-index: 2;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
}

.opl-heading-icon {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  content: url('https://cdn.myopl.net/images/MyOPL_AI_Purple.svg?v=5') !important;
}

.opl-brand-purple-icon {
  color: var(--brand-purple);
}

/* Dark mode overrides for OPL Intelligence settings */
[data-theme="dark"] .opl-heading-icon {
  filter: brightness(0) invert(1) !important;
}

[data-theme="dark"] .opl-brand-purple-icon {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .premium-badge-locked {
  border-color: #ffffff !important;
  color: #ffffff !important;
}

[data-theme="dark"] .premium-badge-locked .material-symbols-outlined {
  color: #ffffff !important;
}

[data-theme="dark"] .ci-edit-trigger .material-symbols-outlined {
  color: #ffffff !important;
}

/* OPL Intelligence Disabled System State */
.opl-settings-tier-disabled-all {
  opacity: 0.6 !important;
}
.opl-settings-tier-disabled-all .opl-settings-tier-list {
  pointer-events: none !important;
  opacity: 0.5 !important;
}

/* Event location link hover style */
.event-location-link:hover {
  text-decoration: underline !important;
  color: #0056b3 !important;
}
.event-location-link:hover span {
  color: #0056b3 !important;
}

/* Dark Mode Friend Request Accept Button overrides */
[data-theme="dark"] .btn-accept {
  background: var(--brand-orange) !important;
}

[data-theme="dark"] .fr-btn-accept:hover,
[data-theme="dark"] .btn-accept:hover {
  background: var(--brand-purple) !important;
}

/* ═══ Player Stats Dashboard Premium Styles ═══ */

/* Segmented Tab Bar */
.stats-tab-btn {
  background: none;
  border: none;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  outline: none;
}

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

.stats-tab-btn.active {
  color: var(--brand-orange);
  font-weight: 800;
  border-bottom-color: var(--brand-orange);
}

/* Premium Strava-style Glow Cards */
.stats-mojo-card {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stats-mojo-card:hover {
  border-color: var(--brand-orange) !important;
  box-shadow: 0 8px 24px rgba(255, 140, 49, 0.12) !important;
  transform: translateY(-3px);
}

[data-theme="dark"] .stats-mojo-card:hover {
  box-shadow: 0 8px 24px rgba(255, 140, 49, 0.18) !important;
}

/* Large Progress Ring widgets */
.progress-container-large {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-container-large circle {
  fill: none;
}

/* Ensure color zones also apply cleanly to larger progress bars */
.progress-container-large circle[id$="-circle"] {
  stroke-width: 20;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-out, stroke 0.5s;
}

/* Point Dominance pointer visual state adjustments */
#stats-pdi-pointer {
  transition: left 0.6s cubic-bezier(0.19, 1, 0.22, 1), transform 0.2s;
}

#stats-pdi-pointer:hover {
  transform: translateX(-50%) scale(1.15);
}

/* premium locked blur overlays */
.opl-stats-premium-overlay {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  background: rgba(10, 10, 10, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  padding: 16px;
}

[data-theme="light"] .opl-stats-premium-overlay {
  background: rgba(255, 255, 255, 0.75);
}

.pro-upgrade-trigger-btn {
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pro-upgrade-trigger-btn:hover {
  transform: scale(1.05);
}

/* SVG Chart interactive tooltips */
.chart-tooltip {
  position: absolute;
  background: var(--bg-secondary);
  border: 1.5px solid var(--brand-orange);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  z-index: 200;
  width: 150px;
  font-size: 11px;
  text-align: left;
  color: var(--text-primary);
  pointer-events: none;
  animation: scaleInTooltip 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  box-sizing: border-box;
}

[data-theme="dark"] .chart-tooltip {
  background: #181818;
  border-color: var(--brand-orange);
}

@keyframes scaleInTooltip {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Sarasota-style Facility rank standing list */
.stats-facility-standing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.stats-facility-standing-row:hover {
  border-color: var(--brand-purple);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.08);
  transform: translateY(-1px);
}

/* Head-to-Head rows share the standing-row card look but aren't clickable --
   cancel the pointer cursor and hover highlight so hovering doesn't imply
   an action that isn't there. */
.stats-facility-standing-row.stats-h2h-row {
  cursor: default;
}

.stats-facility-standing-row.stats-h2h-row:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

.stats-rank-badge {
  font-size: 13px;
  font-weight: 800;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.stats-rank-1 {
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
}

.stats-rank-2 {
  background: rgba(192, 192, 192, 0.15);
  color: #C0C0C0;
}

.stats-rank-3 {
  background: rgba(205, 127, 50, 0.15);
  color: #CD7F32;
}

.stats-rank-other {
  background: var(--divider);
  color: var(--text-secondary);
}

.animate-lock-bounce {
  animation: lockBounce 2s infinite ease-in-out;
}

@keyframes lockBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.stats-facility-standing-icon-wrapper svg {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Premium Empty State Chart Overlay */
.opl-stats-empty-overlay {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(10, 10, 10, 0.55);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 90;
  border-radius: 12px;
  box-sizing: border-box;
  padding: 16px;
  transition: all 0.3s ease;
}

[data-theme="light"] .opl-stats-empty-overlay {
  background: rgba(255, 255, 255, 0.6);
}

/* Custom Tooltip styling to fit neater in active panel */
.custom-tooltip-trigger {
  position: relative;
}

.custom-tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  right: 0;
  width: 250px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.45;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10002;
  white-space: normal;
  text-transform: none;
  font-family: 'Nunito Sans', sans-serif;
  text-align: left;
}

.custom-tooltip-trigger:hover::after {
  opacity: 1;
  transform: translateY(0);
}


/* ═══ Single Column Player Stats Layout overrides ═══ */
#stats-panel {
  width: 380px !important;
  flex: none !important;
  border-right: 1px solid var(--border) !important;
  display: none; /* controlled by JS display: flex */
}

#stats-panel .settings-sidebar {
  width: 100% !important;
  min-width: unset !important;
  border-right: none !important;
}

#stats-panel .stats-sub-panel {
  display: block !important;
  position: relative !important;
  box-sizing: border-box !important;
  height: auto !important;
  overflow-y: visible !important;
  border-bottom: none !important;
  padding: 30px 24px 0 24px !important;
}

#stats-panel .stats-sub-panel:last-child {
  padding-bottom: 24px !important;
}

/* Must match isMobileLayout() in chat_v3_v4.js and the shared .settings-panel
   breakpoint above -- #stats-panel's own width:380px!important (ID selector)
   otherwise beats that shared fix at any specificity, so this panel needs its
   own copy of the same condition or it reintroduces the same blank grey dead
   zone in the 769-1200px portrait gap (a real iPad, or a desktop window
   resized narrower than it is tall -- orientation:portrait is just window
   aspect ratio on desktop, not a real device orientation). */
@media (max-width: 768px), (max-width: 1200px) and (orientation: portrait) {
  #stats-panel {
    width: 100% !important;
    flex: 1 !important;
    border-right: none !important;
  }
}

/* Save Match Button for Entity Leaderboard Empty State */
.save-match-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid #ffffff;
  border-radius: 8px;
  padding: 12px 24px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

[data-theme='light'] .save-match-btn {
  border-color: var(--border);
  color: var(--text-primary);
}

.save-match-btn:hover {
  background: var(--bg-hover);
}

/* Player Stats Consolidated Dashboard Classes */
.stats-empty-state {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  padding: 0;
  gap: 16px;
}

.stats-empty-text {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

.stats-save-match-btn {
  border-radius: 12px;
  align-self: center;
}

.stats-premium-wrapper {
  position: relative;
  margin-bottom: 24px;
}

.stats-quick-lock {
  border-radius: 12px !important;
}

.stats-sub-panel-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}

.stats-pdi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  transition: all 0.2s;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
}

.stats-pdi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stats-pdi-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.stats-pdi-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--brand-orange);
}

.stats-pdi-track {
  position: relative;
  height: 12px;
  background: var(--divider);
  border-radius: 6px;
  overflow: visible;
  margin-bottom: 16px;
}

.stats-pdi-fill {
  position: absolute;
  height: 100%;
  left: 0;
  width: 50%;
  background: linear-gradient(90deg, #C0584D, #ffb03b, #7BC5B8);
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.stats-pdi-pointer {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  border: 4.5px solid var(--brand-orange);
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: left 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

#stats-singles-pdi-pointer:hover,
#stats-doubles-pdi-pointer:hover {
  transform: translateX(-50%) scale(1.15);
}

.stats-pdi-footer {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

.stats-rating-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-sizing: border-box;
  position: relative;
}

.stats-rating-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.stats-rating-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-rating-value {
  font-size: 48px;
  font-weight: 900;
  color: var(--brand-purple);
  margin-top: 8px;
  line-height: 1;
}

[data-theme='dark'] .stats-rating-value {
  color: #fff;
}

.stats-confidence-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stats-confidence-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stats-progress-wrapper {
  position: relative;
  width: 64px;
  height: 64px;
}

.stats-progress-svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.stats-rating-card-footer {
  border-top: 1px solid var(--divider);
  padding-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 8px;
}

.stats-footer-metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

.stats-footer-metric-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 4px;
}

.stats-footer-metric-value.highlight {
  color: var(--brand-purple);
}

[data-theme='dark'] .stats-footer-metric-value.highlight {
  color: #fff;
}
