/* Minimal external styles to enable tabs and memory UI */

/* CSS variables for enhancement theming and font sizes */
:root {
  /* Card and section backgrounds */
  --enh-card-bg-rgb: 15, 23, 42;      /* #0f172a */
  --enh-card-bg-alpha: 0.92;
  --enh-card-border: rgba(148, 163, 184, 0.38);
  /* Section background as RGB + alpha so we can control transparency without bleed-through on the card */
  --enh-section-bg-rgb: 30, 41, 59;   /* #1e293b */
  --enh-section-bg-alpha: 0.9;

  /* Posts appearance (defaults match current look) */
  --posts-bg-rgb: 0, 0, 0;  /* #000000 */
  --posts-bg-alpha: 0.3;     /* 30% */
  --posts-font-scale: 1;     /* 100% */
  --posts-en-scale: 1;
  --posts-ja-scale: 1;
  --posts-zh-scale: 1;
  --posts-yue-scale: 1;
  --posts-ja-ruby-scale: 1;
  --posts-zh-ruby-scale: 1;
  --posts-yue-ruby-scale: 1;
  /* Post card background (even darker light gray for stronger contrast) */
  --post-card-bg-rgb: 209, 213, 219; /* #d1d5db */
  --post-card-bg-alpha: 0.92;

  /* Font scales (relative multipliers) */
  --en-main-size: 1.25;   /* English main text larger by default */
  --ja-main-size: 1.10;   /* Japanese main (kanji text) */
  --ja-ruby-size: 0.70;   /* Furigana ruby text */
  --zh-main-size: 1.10;   /* Chinese main (hanzi text) */
  --zh-ruby-size: 0.90;   /* Pinyin ruby text (slightly smaller by default) */
  --yue-main-size: 1.10;  /* Cantonese main (hanzi text) */
  --yue-ruby-size: 0.90;  /* Jyutping ruby text */
  /* Desktop header spacing scale (0=tight .. 1=roomy) */
  --desktop-header-space-scale: .5;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Unified enhancement section card styling */
.language-section {
  background: rgba(var(--enh-section-bg-rgb), var(--enh-section-bg-alpha));
  border: 1px solid var(--enh-card-border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  color: #f8fafc;
}
.language-header {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; margin-bottom: 6px;
  color: #dbeafe;
}
.language-codes { opacity: 0.85; font-size: 12px; }
.english-content, .japanese-content, .cantonese-content, .chinese-content { padding: 4px 0; }
.original-text { opacity: 0.9; margin-bottom: 4px; }
.processing-time { opacity: 0.85; font-size: 12px; margin-top: 6px; }

/* Mobile topbar */
.mobile-topbar { display: none; position: relative; padding: 6px 10px; }
.mobile-topbar .hamburger { background: rgba(255,255,255,0.15); border:1px solid rgba(255,255,255,0.3); color:#fff; border-radius:8px; padding:6px 10px; font-size:18px; cursor:pointer; }
.mobile-topbar .mobile-actions { display:flex; align-items:center; gap:8px; }
.mobile-topbar .mobile-lang-wrap { position: relative; overflow: hidden; flex: 0 0 auto; }
.mobile-topbar .mobile-lang {
  background: rgba(255,255,255,0.15);
  border:1px solid rgba(255,255,255,0.3);
  color:#fff;
  border-radius:8px;
  padding:6px;
  padding-right: 22px; /* room for custom arrow */
  box-sizing: border-box;
  width: 100% !important;
  max-width: 100% !important;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
/* Custom dropdown arrow */
.mobile-topbar .mobile-lang-wrap::after {
  content: '▾';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: rgba(255,255,255,0.85);
}
.mobile-topbar .mobile-brand { display:flex; align-items:center; gap:8px; flex:1; min-width: 0; }
.mobile-topbar .mobile-logo { height: 22px; width: 22px; border-radius: 4px; }
.mobile-topbar .mobile-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.95; }
.mobile-topbar .mobile-lang-wrap { border-radius: 8px; overflow: hidden; }
/* Mobile avatar + dropdown near hamburger */
.mobile-topbar .mobile-user-menu { position: relative; display:flex; align-items:center; }
.mobile-topbar .mobile-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.85); cursor: pointer; }
.mobile-topbar .mobile-user-dropdown { position: absolute; right: 0; top: 120%; background: rgba(0,0,0,0.85); border:1px solid rgba(255,255,255,0.3); border-radius:8px; min-width: 140px; box-shadow: 0 6px 18px rgba(0,0,0,0.2); z-index: 1000; }
.mobile-topbar .mobile-user-dropdown a { display:block; color:#fff; text-decoration:none; padding:8px 10px; font-size:14px; }
.mobile-topbar .mobile-user-dropdown a:hover { background: rgba(255,255,255,0.08); }
@media (max-width: 700px) {
  .mobile-topbar { display: flex; justify-content: space-between; align-items: center; }
  /* Hide header elements by default on small screens */
  .header-bar, .features-badge { display: none !important; }
  /* Show header when toggled */
  body.show-header .header-bar { display: flex !important; }
  body.show-header .features-badge { display: block !important; }
  /* Keep hamburger visible even when header is shown */
  body.show-header .mobile-topbar { display: flex !important; }
  /* Smaller avatars on mobile */
  .header-avatar { width:24px; height:24px; border-width:1px; }
  .letter-avatar { width:24px; height:24px; border-width:1px; font-size:12px; }
  .mobile-topbar .mobile-avatar { width:24px; height:24px; border-width:1px; }
  /* Disable hamburger on mobile */
  .mobile-topbar .hamburger { display: none !important; }
  /* Enforce exact sizes on Safari with IDs */
  #mobileHeaderAvatar, #headerAvatar { width:22px !important; height:22px !important; border-width:1px !important; display:block; }
  #mobileHeaderAvatarFallback, #headerAvatarFallback { width:22px !important; height:22px !important; border-width:1px !important; font-size:12px !important; }
}

/* Login buttons styling */
.header-right .login-btn { margin-left: 8px; padding: 6px 10px; }
.mobile-topbar .login-btn { margin-left: 6px; padding: 6px 10px; background: rgba(255,255,255,0.15); border:1px solid rgba(255,255,255,0.3); color:#fff; border-radius:8px; }

/* Busy button + dots animation */
.btn-busy, .control-button.busy, .btn.busy, button.busy {
  position: relative;
  opacity: 0.8;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(66,165,245,0.35), rgba(33,150,243,0.55), rgba(66,165,245,0.35));
  background-size: 200% 100%;
  animation: glow-slide 1.6s linear infinite;
}
/* Password visibility toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 36px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: none; cursor: pointer; font-size: 16px; opacity: 0.85; }
.pw-toggle:hover { opacity: 1; }
/* Mobile auth modal labels */
.auth-form label { position: relative; }
.auth-form input[type="password"] { padding-right: 36px; }
.auth-form .pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: none; cursor: pointer; font-size: 16px; opacity: 0.85; }
@keyframes glow-slide {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
.dots::after {
  content: '';
  display: inline-block;
  width: 1em;
  text-align: left;
  animation: ellipses 1.2s steps(4, end) infinite;
}
@keyframes ellipses {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

/* Compact mobile margins */
@media (max-width: 700px) {
  .container { padding: 16px; border-radius: 14px; }
  .conversation-list { padding: 16px; }
.user-message, .ai-message { padding: 10px 12px; margin: 6px 0; position: relative; }
  .conversations-list { padding: 8px; }
  .control-button { padding: 8px 12px; }
}

/* Extra-compact chat layout for small phones */
@media (max-width: 600px) {
  .container { padding: 12px; border-radius: 12px; }
  .conversation-list { padding: 12px; border-radius: 12px; }
  /* AI chat list sizing */
  #conversationList { min-height: 300px; max-height: 70vh; }
  /* DM list sizing (override inline height) */
  #dmMessages { height: 55vh !important; }
  /* Bring bubbles closer to edges */
.user-message, .ai-message { padding: 8px 10px; margin: 4px 0; max-width: 95%; position: relative; }
  .user-message { margin-right: 4px; }
  .ai-message { margin-left: 4px; }
  /* Reduce column gaps in friends */
  .friends-columns { gap: 12px !important; }
}

@media (max-width: 480px) {
  .container { padding: 10px; border-radius: 10px; }
  .conversation-list { padding: 10px; border-radius: 10px; }
  #conversationList { min-height: 240px; max-height: 68vh; }
  #dmMessages { height: 58vh !important; }
.user-message, .ai-message { padding: 7px 9px; margin: 3px 0; max-width: 96%; position: relative; }
  .user-message { margin-right: 3px; }
  .ai-message { margin-left: 3px; }
}

/* Final mobile overrides (high specificity + !important) */
@media (max-width: 700px) {
  /* Remove body side padding/margins and width constraints on mobile */
  body { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  /* When virtual keyboard is open, add bottom padding so layout isn't obscured */
  body.kb-open { padding-bottom: var(--kb-offset, 0px) !important; }
  .container { padding: 8px !important; border-radius: 10px !important; }
  .conversation-area { margin-top: 10px !important; }
  .conversation-list { padding: 8px !important; border-radius: 10px !important; }
  .conversations-list { padding: 6px !important; }
.user-message, .ai-message { padding: 6px 8px !important; margin: 3px 0 !important; max-width: 96% !important; position: relative; }
  .user-message { margin-right: 2px !important; }
  .ai-message { margin-left: 2px !important; }
  .friends-columns { gap: 10px !important; }
  .dm-input-row { gap: 6px !important; }
  .dm-fonts { margin-top: 8px !important; padding: 6px !important; }
  .chat-palette-panel {
    display: none;
    margin-top: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(148,163,184,0.25);
    border-radius: 12px;
  }
  .chat-palette-panel.is-open {
    display: block;
  }
  .chat-palette-panel > .setting-group {
    margin-top: 0;
  }
  .settings { margin: 8px 0 !important; }
  .setting-group { padding: 8px !important; }
}

@media (max-width: 480px) {
  .container { padding: 6px !important; }
  .conversation-list { padding: 6px !important; }
.user-message, .ai-message { padding: 5px 7px !important; margin: 2px 0 !important; max-width: 97% !important; position: relative; }
}

/* Desktop: keep language dropdown + brand/login + tabs visible while scrolling */
@media (min-width: 701px) {
  #desktopStickyHeader {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Default theme (no data-theme): vivid blue gradient for desktop header */
    background: linear-gradient(135deg, #0ea5e9 0%, #4f46e5 100%);
    border-bottom: 1px solid rgba(255,255,255,0.18);
  }
}

.tabs {
  display: flex;
  gap: 10px;
  margin: calc(var(--desktop-header-space-scale, .5) * 8px) 0 calc(var(--desktop-header-space-scale, .5) * 12px);
  flex-wrap: wrap; /* allow tabs to flow on small screens */
}

.conversation-item.system-item {
  display: flex;
  justify-content: center;
}

.group-system-message {
  max-width: 70%;
  margin: 10px auto;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.35;
  color: inherit;
}

.group-system-message .system-actor,
.group-system-message .system-target {
  font-weight: 600;
}

.group-system-message .system-alias {
  font-style: italic;
}

.group-system-message .system-group-name {
  font-weight: 600;
}

.group-system-message .system-group-name.previous {
  opacity: 0.7;
}

.group-system-time {
  margin-top: 6px;
  font-size: 0.75rem;
  opacity: 0.72;
}

/* High-contrast action buttons inside system bubbles (e.g., game invites/results) */
.group-system-message .control-button,
.group-system-message .control-button.tiny {
  background: linear-gradient(135deg, #22d3ee, #a78bfa);
  border: none;
  color: #0b1220;
  font-weight: 700;
}
[data-theme="light"] .group-system-message .control-button,
[data-theme="light"] .group-system-message .control-button.tiny,
[data-theme="bright"] .group-system-message .control-button,
[data-theme="bright"] .group-system-message .control-button.tiny,
[data-theme="vivid"] .group-system-message .control-button,
[data-theme="vivid"] .group-system-message .control-button.tiny {
  background: linear-gradient(135deg, #22d3ee, #a78bfa);
  color: #0b1220;
  border: none;
}

.tab-button {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap; /* keep each button on a single line */
  position: relative;
}

.tab-button.active {
  background: linear-gradient(45deg, #42a5f5, #2196f3);
}

.tab-button.hidden { display: none !important; }

.tab-content.hidden {
  display: none;
}

.memory-management {
  background: rgba(255, 255, 255, 0.08);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin: 10px 0 20px;
}

.memory-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.memory-panel {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 10px;
}

.memory-panel h5 { margin: 0 0 8px 0; color: #ffa726; }

.memory-list { display: flex; flex-direction: column; gap: 8px; }

.memory-item {
  background: linear-gradient(135deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.memory-item:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,0.25); }

.memory-item .content { flex: 1; white-space: pre-wrap; }
.memory-item .actions { display: flex; gap: 8px; align-items: center; }
.memory-item button { 
  font-size: 12px; 
  padding: 6px 10px; 
  background: linear-gradient(45deg, #e74c3c, #c0392b);
  border: none;
  color: white;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.memory-item button:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(231,76,60,0.35); }

.memory-panel .add-row { display: flex; gap: 6px; margin-top: 8px; }
.memory-panel textarea { width: 100%; min-height: 80px; }

/* Header user info */
.header-bar { display:flex; justify-content: space-between; align-items:center; margin-bottom: calc(var(--desktop-header-space-scale, .5) * 8px); padding-block: calc(var(--desktop-header-space-scale, .5) * 2px); }
.site-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0; /* remove default h1 margins to control spacing via slider */
}
.site-title-text {
  font-weight: 700;
  font-size: 1.6rem;
}
.site-description {
  font-size: 0.95rem;
  opacity: 0.8;
  display: inline-block;
}

/* Mascot overlay (desktop only) */
#mascotBuddyWrap {
  position: fixed;
  right: 18px;
  bottom: 28px;
  width: 160px;
  max-width: 26vw;
  z-index: 30; /* above content, below modals */
  pointer-events: auto;
  cursor: pointer;
}
#mascotBuddy {
  display: block;
  width: 100%;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.35));
  transform-origin: 80% 100%;
}
.mascot-enter {
  animation: mascotEnter .9s ease-out both;
}
@keyframes mascotEnter {
  0% { opacity: 0; transform: translateX(90px) translateY(20px) scale(.85) rotate(4deg); }
  60% { opacity: 1; transform: translateX(-6px) translateY(-8px) scale(1.03) rotate(-2deg); }
  100% { opacity: 1; transform: translateX(0) translateY(0) scale(1) rotate(0deg); }
}

/* Energy bar */
#mascotEnergy {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -10px;
  width: 120px;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.25);
  pointer-events: auto;
}
#mascotEnergy .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f97316, #ef4444);
  transition: width .35s ease, background .3s ease;
}

/* Floating +N bubbles */
.mascot-bubble {
  position: absolute;
  right: 8px;
  bottom: 100px;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(.9);
  animation: mascotBubble 1.2s ease-out forwards;
}
@keyframes mascotBubble {
  0% { opacity: 0; transform: translateY(8px) scale(.9); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(-24px) scale(1.02); }
  100% { opacity: 0; transform: translateY(-36px) scale(1.02); }
}

/* Subtle starve wobble when energy low */
#mascotBuddyWrap.mascot-low #mascotBuddy {
  animation: mascotStarve 2.6s ease-in-out infinite;
}
@keyframes mascotStarve {
  0% { transform: translateY(0) scale(1); filter: drop-shadow(0 8px 18px rgba(0,0,0,.35)); }
  50% { transform: translateY(2px) scale(.995); filter: drop-shadow(0 6px 14px rgba(0,0,0,.3)); }
  100% { transform: translateY(0) scale(1); filter: drop-shadow(0 8px 18px rgba(0,0,0,.35)); }
}

#mascotCoinTooltip {
  position: absolute;
  bottom: 128px;
  left: 50%;
  transform: translate(-50%, 10px);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(99, 102, 241, 0.45);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f8fafc;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(15,23,42,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#mascotCoinTooltip .coin-icon { font-size: 18px; }
#mascotCoinTooltip .coin-label { font-size: 12px; letter-spacing: 0.5px; opacity: 0.85; }
#mascotCoinTooltip.show {
  opacity: 1;
  transform: translate(-50%, -2px);
}

/* Blink + wave animations for inline SVG */
#mascotBuddyWrap svg #face > g > g {
  transform-origin: center;
  transform-box: fill-box;
  animation: buddyBlink 6s ease-in-out infinite;
}
@keyframes buddyBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  94% { transform: scaleY(0.12); }
  96% { transform: scaleY(1); }
}

#mascotBuddyWrap svg #arm-right {
  transform-box: fill-box;
  transform-origin: 232px 238px;
  animation: buddyWave 7.2s ease-in-out infinite;
}
@keyframes buddyWave {
  0%, 80%, 100% { transform: rotate(0deg); }
  84% { transform: rotate(-7deg); }
  88% { transform: rotate(12deg); }
  92% { transform: rotate(-6deg); }
  96% { transform: rotate(9deg); }
}
.mobile-title-group {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.mobile-title-group .site-description {
  font-size: 0.85rem;
}
.container-top-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: calc(var(--desktop-header-space-scale, .5) * 8px);
}
.container-top-controls .header-lang {
  min-width: 160px;
}

.site-desc-toggles {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.site-desc-toggles .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.user-info { font-size: 14px; opacity: 0.9; }

/* Generic profile @username link pill */
.profile-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  color: #0b1220;
  background: rgba(209, 213, 219, 0.9);
  border: 1px solid rgba(148,163,184,0.45);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.1px;
  transition: background .2s ease, box-shadow .2s ease, transform .05s ease-in-out;
}
.profile-link:hover { background: rgba(229, 231, 235, 0.95); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.profile-link:active { transform: translateY(1px); }
.profile-link:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,0.45); }

/* Vivid username link (pill style, modern, no underline) */
#headerUsernameLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  transition: background .2s ease, box-shadow .2s ease, transform .05s ease-in-out;
}
#headerUsernameLink:hover { background: rgba(255,255,255,0.2); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
#headerUsernameLink:active { transform: translateY(1px); }
#headerUsernameLink:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(66,165,245,0.5); }
#headerUsernameLink strong { font-weight: 700; letter-spacing: .2px; }
.logout-btn { background: linear-gradient(45deg, #ff6b6b, #ee5a24); border:none; color:white; padding:6px 10px; border-radius: 8px; cursor:pointer; }
.logout-btn:hover { opacity: 0.9; }
.app-logo { height: calc(44px + var(--desktop-header-space-scale, .5) * 40px); vertical-align: middle; margin-right: 10px; border-radius: 10px; }
.header-right { display:flex; align-items:center; gap:10px; flex-wrap: wrap; }
.user-account-shell {
  position: relative;
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:6px;
}
.user-account-shell .user-menu { order:0; }
.user-account-shell .lac-balance { order:1; }
.lac-balance {
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  background: rgba(32, 41, 88, 0.65);
  border: 1px solid rgba(99,102,241,0.45);
  color:#f8fafc;
  font-size:13px;
  font-weight:600;
  box-shadow: 0 6px 16px rgba(15,23,42,0.22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.lac-balance.hidden { display:none !important; }
.lac-balance .lac-icon { font-size:16px; }
.lac-balance .lac-label { font-size:12px; letter-spacing:0.6px; opacity:0.85; }
.lac-balance:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15,23,42,0.28);
}
#headerLacBalance {
  position:absolute;
  top:calc(100% + 6px);
  right:0;
  pointer-events:auto;
  z-index:15;
}
.notify-bell { position: relative; font-size: 18px; cursor: pointer; }
.notify-bell.has-unread::after {
  content: attr(data-count);
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: #e53935;
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.85);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* Notifications dropdown */
.notify-dropdown {
  position: absolute;
  z-index: 2000;
  min-width: 280px;
  max-width: 360px;
  max-height: 320px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.35);
  background: rgba(25, 25, 25, 0.96);
  backdrop-filter: blur(6px);
  color: #fff;
}
.notify-dropdown.hidden { display: none; }
.notify-dropdown .notify-header { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.12); font-size: 14px; opacity: .9; }
.notify-dropdown .notify-list { max-height: 240px; overflow-y: auto; }
.pending-empty {
  padding:12px;
  text-align:center;
  opacity:0.75;
  font-size:0.9rem;
}

.notify-dropdown .notify-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  line-height: 1.35;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.15s ease;
}
.notify-dropdown .notify-item:last-child { border-bottom: none; }
.notify-dropdown .notify-empty { padding: 14px; text-align: center; opacity: .85; }
.notify-dropdown .notify-footer { padding: 8px; display: flex; justify-content: center; }
.notify-dropdown .notify-footer .control-button[disabled] { opacity: .6; pointer-events: none; }

.notify-dropdown .notify-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.notify-dropdown .notify-item.unread {
  background: rgba(66, 165, 245, 0.12);
}

.notify-dropdown .notify-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
}
.notify-dropdown .notify-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.notify-dropdown .notify-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.notify-dropdown .notify-actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
}
.notify-dropdown .notify-action {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 12px;
}
.notify-dropdown .notify-action.approve { background:#22c55e; color:#0b1b0f; }
.notify-dropdown .notify-action.reject { background:#ef4444; color:#290808; }

.notify-dropdown .notify-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.notify-dropdown .notify-actor {
  background: none;
  border: none;
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.notify-dropdown .notify-actor:hover {
  text-decoration: underline;
}

.notify-dropdown .notify-context {
  opacity: 0.85;
  font-size: 13px;
}

.notify-dropdown .notify-preview {
  font-size: 12.5px;
  opacity: 0.9;
}

.notify-dropdown .notify-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.7;
}

.notify-dropdown .notify-icon {
  font-size: 12px;
}

.tab-button.has-badge[data-count]:not([data-count=""])::after,
.tab-button[data-count]:not([data-count=""])::after {
  content: attr(data-count);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: #e53935;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(17,24,39,0.7);
}

/* Header language dropdown styling (desktop) */
.container-top-controls .header-lang {
  background: rgba(255,255,255,0.15);
  border:1px solid rgba(255,255,255,0.3);
  color:#fff;
  border-radius:8px;
  padding:4px 6px;
  font-size: 12px;
  min-width: 90px;
  max-width: 120px;
}
/* Mobile language dropdown near hamburger */
.mobile-topbar .mobile-lang { margin-right: 8px; background: rgba(255,255,255,0.15); border:1px solid rgba(255,255,255,0.3); color:#fff; border-radius:8px; padding:6px; }

@media (max-width: 700px) {
  /* Hide header language on small screens and show mobile one */
  .container-top-controls { display: none; }
  .mobile-topbar .mobile-lang { display: inline-block; }
}

@media (min-width: 701px) {
  .mobile-topbar .mobile-lang { display: none; }
}

@media (max-width: 700px) {
  .header-bar { flex-wrap: wrap; gap: 6px; }
  .user-info { max-width: 45vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

.memory-section {
  margin-bottom: 12px;
}

.memory-section textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 10px;
}

.memory-buttons {
  display: flex;
  gap: 10px;
}

/* Enhancement original text toggle */
body.enhancement-hide-original .original-text { display: none !important; }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            color: white;
        }
        
        .container {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .conversation-item-list {
            padding: 8px 12px;
            margin: 5px 0;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.2);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

/* Remove aggressive hover reset that caused darkening by inheriting dark parent bg */
/* Keep default hover behavior defined later for .post-card; no override needed here. */
/* Keep reply indentation to one level */
.comments .comment-children .comment-children { margin-left: 0 !important; }

        .conversation-item-list.active {
            background: linear-gradient(45deg, #42a5f5, #2196f3);
            border-color: #42a5f5;
        }

        .conversation-info {
            flex: 1;
            pointer-events: none;
        }

        .conversation-title {
            font-weight: bold;
            margin-bottom: 3px;
        }

        .conversation-meta {
            font-size: 0.8em;
            opacity: 0.7;
        }
        
        /* Delete button styles */
        .delete-conversation-btn {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            border: none;
            border-radius: 15px;
            padding: 5px 10px;
            color: white;
            cursor: pointer;
            font-size: 0.7em;
            transition: all 0.3s ease;
            pointer-events: auto;
            min-width: 60px;
            opacity: 0.8;
        }

        .delete-conversation-btn:hover {
            opacity: 1;
            transform: scale(1.05);
            box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
        }

        .delete-confirmation {
            background: rgba(231, 76, 60, 0.9);
            color: white;
            padding: 15px;
            border-radius: 10px;
            margin: 10px 0;
            text-align: center;
            border: 2px solid #e74c3c;
        }

        .confirm-buttons {
            margin-top: 10px;
            display: flex;
            gap: 10px;
            justify-content: center;
        }

        .confirm-btn, .cancel-btn {
            padding: 8px 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s ease;
        }

        .confirm-btn {
            background: #e74c3c;
            color: white;
        }

        .cancel-btn {
            background: #95a5a6;
            color: white;
        }

        .confirm-btn:hover, .cancel-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
        }

        /* ADDED: Auto-conversation toggle styles */
        .auto-conversation-control {
            background: rgba(255, 152, 0, 0.1);
            border: 1px solid rgba(255, 152, 0, 0.3);
            border-radius: 10px;
            padding: 15px;
            margin: 15px 0;
            text-align: center;
        }

        .auto-conversation-control h4 {
            margin: 0 0 10px 0;
            color: #ff9800;
        }

        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 60px;
            height: 34px;
            margin: 0 10px;
        }

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

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 34px;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 26px;
            width: 26px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        input:checked + .toggle-slider {
            background-color: #ff9800;
        }

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

        .toggle-description {
            font-size: 0.9em;
            opacity: 0.9;
            margin-top: 10px;
            line-height: 1.4;
        }

        /* All other existing styles remain the same */
        h1 {
            text-align: center;
            margin-bottom: 40px;
            font-size: 2.5em;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        }
        
        .features-badge {
            text-align: center;
            margin-bottom: 10px;
            font-size: 14px;
            opacity: 0.9;
            background: rgba(255, 255, 255, 0.1);
            padding: 10px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .vad-status {
            text-align: center;
            margin: 20px 0;
            padding: 20px;
            border-radius: 15px;
            font-size: 1.8em;
            font-weight: bold;
            transition: all 0.3s ease;
        }

        .recorder-core .vad-status {
            margin: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .vad-status.speaking {
            background: rgba(255, 107, 107, 0.2);
            border: 2px solid #ff6b6b;
            color: #ff6b6b;
            animation: pulse 1s infinite;
        }
        
        .vad-status.silence {
            background: rgba(78, 205, 196, 0.2);
            border: 2px solid #4ecdc4;
            color: #4ecdc4;
        }
        
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.7; }
        }
        
        .device-selector {
            margin: 20px 0;
            text-align: center;
        }
        
        select {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.3);
            border-radius: 5px;
            padding: 10px;
            color: white;
            font-size: 16px;
            min-width: 200px;
        }
        
        select option {
            background: #333;
            color: white;
        }
        
        .settings {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        
        .setting-group {
            background: rgba(255, 255, 255, 0.05);
            padding: 15px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .setting-group h4 {
            margin: 0 0 10px 0;
            color: #ffa726;
        }
        
        label {
            display: block;
            margin: 10px 0;
            font-size: 14px;
        }
        
        input[type="range"] {
            width: 100%;
            margin: 5px 0;
            -webkit-appearance: none;
            height: 6px;
            border-radius: 3px;
            background: rgba(255, 255, 255, 0.3);
            outline: none;
        }
        
        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #42a5f5;
            cursor: pointer;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        input[type="range"]::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: #42a5f5;
            cursor: pointer;
            border: none;
        }
        
        input[type="checkbox"] {
            margin-right: 8px;
            transform: scale(1.2);
        }
        
        .value-display {
            font-weight: bold;
            color: #42a5f5;
        }
        
        .voice-selector {
            background: rgba(255, 255, 255, 0.08);
            padding: 16px;
            border-radius: 12px;
            margin: 20px 0;
        }

        .voice-selector h4 {
            margin: 0 0 16px 0;
            color: #ffa726;
        }

        .voice-row {
            background: rgba(15, 23, 42, 0.25);
            border: 1px solid rgba(99, 102, 241, 0.18);
            border-radius: 12px;
            padding: 12px 14px;
            margin-bottom: 14px;
        }

        .voice-row:last-of-type {
            margin-bottom: 0;
        }

        .voice-row-head {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .voice-row-title {
            font-weight: 600;
            color: rgba(248, 250, 252, 0.92);
        }

        .current-voice-tag {
            font-size: 12px;
            padding: 4px 10px;
            border-radius: 999px;
            background: rgba(99, 102, 241, 0.25);
            color: #a5b4fc;
        }

        .voice-row-body {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: center;
        }

        .voice-button-group {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }

        .voice-custom-control {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }

        .voice-custom-hint {
            font-size: 12px;
            color: rgba(148, 163, 184, 0.75);
        }

        .voice-button {
            background: linear-gradient(45deg, #3742fa, #2f3542);
            border: none;
            border-radius: 999px;
            padding: 8px 18px;
            color: #f8fafc;
            cursor: pointer;
            transition: all 0.2s ease;
            font-size: 13px;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .voice-button.custom {
            border: 1px solid rgba(168, 85, 247, 0.5);
        }

        .voice-button:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
        }

        .voice-button.active {
            background: linear-gradient(45deg, #ff6b6b, #ee5a24);
            box-shadow: 0 4px 14px rgba(255, 107, 107, 0.35);
        }

        .voice-select-wrapper {
            position: relative;
            display: inline-flex;
            align-items: center;
            border-radius: 999px;
            background: rgba(15, 23, 42, 0.6);
            border: 1px solid rgba(148, 163, 184, 0.45);
            padding-right: 34px;
            transition: all 0.2s ease;
        }

        .voice-select-wrapper:hover {
            border-color: rgba(148, 163, 184, 0.7);
        }

        .voice-select-wrapper.active {
            border-color: rgba(248, 113, 113, 0.9);
            box-shadow: 0 4px 14px rgba(248, 113, 113, 0.25);
        }

        .voice-select {
            appearance: none;
            border: none;
            background: transparent;
            color: #f1f5f9;
            border-radius: 999px;
            padding: 8px 0 8px 16px;
            font-size: 13px;
            cursor: pointer;
        }

        .voice-select:focus {
            outline: none;
        }

        .voice-select option {
            color: #0f172a;
        }

        .voice-select-arrow {
            position: absolute;
            right: 14px;
            font-size: 11px;
            pointer-events: none;
            color: rgba(148, 163, 184, 0.85);
            transition: transform 0.2s ease, color 0.2s ease;
        }

        .voice-select-wrapper .voice-select:focus + .voice-select-arrow {
            transform: rotate(180deg);
            color: rgba(248, 113, 113, 0.95);
        }

        .voice-select-wrapper.active .voice-select-arrow {
            color: rgba(248, 113, 113, 0.95);
        }

        .voice-custom-panel {
            margin-top: 18px;
            background: rgba(15, 23, 42, 0.18);
            border-radius: 12px;
            padding: 12px;
        }

        .voice-custom-toolbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }

        .voice-quota {
            font-size: 12px;
            color: rgba(226, 232, 240, 0.8);
        }

        .voice-profiles-toggle {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 10px 12px;
            margin: 4px 0 10px;
            background: rgba(30, 41, 59, 0.35);
            border: 1px solid rgba(99, 102, 241, 0.25);
            border-radius: 10px;
            color: rgba(226, 232, 240, 0.9);
            font-weight: 600;
            cursor: pointer;
            transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
        }

        .voice-profiles-toggle:hover,
        .voice-profiles-toggle:focus,
        .voice-profiles-toggle.expanded {
            border-color: rgba(248, 113, 113, 0.6);
            background: rgba(30, 41, 59, 0.5);
            color: rgba(248, 250, 252, 0.95);
            outline: none;
        }

        .voice-profiles-toggle:focus-visible {
            outline: 2px solid rgba(248, 113, 113, 0.8);
            outline-offset: 2px;
        }

        .voice-toggle-count {
            min-width: 26px;
            padding: 2px 8px;
            border-radius: 999px;
            background: rgba(99, 102, 241, 0.35);
            color: rgba(226, 232, 240, 0.9);
            font-size: 12px;
            text-align: center;
        }

        .voice-toggle-icon {
            font-size: 16px;
            line-height: 1;
        }

        .voice-profiles {
            display: grid;
            gap: 10px;
        }

        .voice-profiles.collapsed {
            display: none;
        }

        .voice-profiles-empty {
            padding: 12px;
            border-radius: 10px;
            background: rgba(30, 41, 59, 0.35);
            color: rgba(226, 232, 240, 0.85);
            font-size: 13px;
        }

        .voice-profile-card {
            display: flex;
            flex-direction: column;
            gap: 6px;
            background: rgba(30, 41, 59, 0.4);
            border-radius: 10px;
            padding: 10px 12px;
            border: 1px solid rgba(99, 102, 241, 0.2);
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }

        .voice-profile-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 8px;
            font-weight: 600;
            color: rgba(226, 232, 240, 0.9);
            flex-wrap: wrap;
        }

        .voice-profile-title {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .voice-profile-info {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .voice-profile-badges {
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .voice-profile-badges.hidden {
            display: none;
        }

        .voice-profile-meta {
            font-size: 11px;
            color: rgba(148, 163, 184, 0.85);
        }

        .voice-profile-badge {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.04em;
            padding: 2px 6px;
            border-radius: 999px;
            background: rgba(148, 163, 184, 0.25);
            color: #f8fafc;
        }

        .voice-profile-badge.ai {
            background: rgba(96, 165, 250, 0.35);
        }

        .voice-profile-badge.user {
            background: rgba(248, 113, 113, 0.35);
        }

        .voice-profile-badge.hidden {
            display: none;
        }

        .voice-profile-text {
            font-size: 12px;
            color: rgba(226, 232, 240, 0.92);
            line-height: 1.4;
        }

        .voice-profile-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .voice-profile-actions .control-button {
            padding: 6px 12px;
            font-size: 12px;
        }

        .voice-profile-actions .control-button.active {
            background: linear-gradient(45deg, #ff6b6b, #ee5a24);
            color: #fff;
            border-color: transparent;
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.25);
        }

        .voice-profile-card.voice-profile-active-ai {
            border-color: rgba(96, 165, 250, 0.85);
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
        }

        .voice-profile-card.voice-profile-active-user {
            border-color: rgba(248, 113, 113, 0.85);
            box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25);
        }

        .voice-profile-card.voice-profile-active-ai.voice-profile-active-user {
            border-color: rgba(249, 168, 212, 0.95);
            box-shadow: 0 0 0 2px rgba(249, 168, 212, 0.35);
        }

        .voice-editor {
            margin-top: 12px;
            background: rgba(15, 23, 42, 0.35);
            border-radius: 12px;
            padding: 12px;
            border: 1px solid rgba(99, 102, 241, 0.2);
        }

        .voice-editor-record {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: center;
            margin-bottom: 12px;
        }

        .voice-editor-visual {
            flex: 1 1 200px;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .voice-progress-track {
            width: 100%;
            height: 6px;
            background: rgba(148, 163, 184, 0.3);
            border-radius: 999px;
            overflow: hidden;
        }

        .voice-progress-bar {
            display: block;
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, #38bdf8, #6366f1);
            border-radius: 999px;
            transition: width 0.1s linear;
        }

        .voice-wave {
            display: flex;
            align-items: flex-end;
            gap: 2px;
            height: 42px;
        }

        .voice-wave .waveform-bar {
            width: 3px;
            background: rgba(94, 234, 212, 0.6);
            border-radius: 2px;
        }

        .voice-editor-field {
            display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 10px;
            font-size: 13px;
            color: rgba(226, 232, 240, 0.92);
        }

        .voice-editor-field input,
        .voice-editor-field textarea {
            width: 100%;
            border-radius: 8px;
            border: 1px solid rgba(148, 163, 184, 0.3);
            padding: 8px 10px;
            background: rgba(15, 23, 42, 0.4);
            color: #e2e8f0;
            font-size: 13px;
        }

        .voice-editor-actions {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            margin-top: 8px;
        }

        .voice-editor-status {
            margin-top: 8px;
            font-size: 12px;
            color: rgba(248, 250, 252, 0.85);
        }
        .voice-editor-status.error {
            color: #ef4444; /* red for errors/too-short */
        }


        .conversation-management {
            background: rgba(255, 255, 255, 0.1);
            padding: 15px;
            border-radius: 10px;
            margin: 20px 0;
        }

        .conversation-management h4 {
            margin: 0 0 15px 0;
            color: #ffa726;
        }

        .conversation-controls {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
            margin-bottom: 15px;
        }

        .conversations-list {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 8px;
            padding: 10px;
            overflow-y: auto;
        }
/* Presence dot next to friend names */
        .presence-dot { display:inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: #9e9e9e; box-shadow: 0 0 0 2px rgba(255,255,255,0.2); vertical-align: middle; }
        .presence-dot.online { background: #4caf50; }
        .presence-dot.offline { background: #9e9e9e; }
        #friendsList .conversation-item { display: flex; align-items: center; gap: 8px; }
        #friendsList .conversation-item .friend-name { flex: 1; }
        /* Ensure Chat tab conversations list stays scrollable */
        #conversationsList { max-height: 200px; overflow-y: auto; }

        /* Keep friends/requests panels a steady height even with few items */
        /* Make all three social lists same fixed height with scroll */
        #friendRequestsIncoming, #friendRequestsOutgoing, #friendsList {
            height: 260px;
            min-height: 260px;
            max-height: 260px;
            overflow-y: auto;
        }

/* Friend list + requests items: clickable rows with selection + unread badge */
#friendsList .conversation-item,
#friendRequestsIncoming .conversation-item,
#friendRequestsOutgoing .conversation-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 8px 12px;
            margin: 6px 0;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 10px;
            transition: background 0.2s ease, transform 0.1s ease, border-color 0.2s ease;
        }
        #friendsList .conversation-item:hover,
        #friendRequestsIncoming .conversation-item:hover,
        #friendRequestsOutgoing .conversation-item:hover { background: rgba(255,255,255,0.16); transform: translateY(-1px); }
        #friendsList .conversation-item.selected { background: linear-gradient(45deg, #42a5f5, #2196f3); border-color: #42a5f5; }

        /* Unread red bubble */
        #friendsList .conversation-item .badge {
            background: #e53935;
            color: #fff;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: 700;
            box-shadow: 0 2px 6px rgba(229,57,53,0.4);
        }

        /* Older messages button inside DM list */
        #dmLoadOlderBtn.control-button.tiny { font-size: 12px; padding: 4px 8px; }

        /* Toast bubble for new DM notifications */
        #toast-container {
            position: fixed;
            right: 20px;
            bottom: 20px;
            z-index: 9999;
            display: flex;
            flex-direction: column-reverse;
            gap: 8px;
            pointer-events: none;
        }
        .toast {
            background: linear-gradient(45deg, #ef5350, #e53935);
            color: #fff;
            border-radius: 16px;
            padding: 10px 14px;
            font-size: 14px;
            box-shadow: 0 8px 20px rgba(0,0,0,0.25);
            animation: floatUp 2.4s ease forwards;
            pointer-events: auto;
        }

/* Admin management styles */
.admin-tabs { display:flex; gap:10px; margin:8px 0 10px; }
.admin-tab-btn { background: rgba(255,255,255,0.12); border:1px solid rgba(255,255,255,0.22); color:#fff; border-radius:8px; padding:6px 10px; cursor:pointer; font-size:12px; }
.admin-tab-btn.active { background: linear-gradient(45deg,#42a5f5,#2196f3); }
.admin-tab-content.hidden { display:none; }

.admin-row { display:grid; grid-template-columns: 24px 180px 120px 110px 1fr; column-gap: 6px; row-gap: 2px; align-items:center; padding:6px 8px; margin:4px 0; background: rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.18); border-radius:10px; }
.admin-row .cell { min-width: 0; }
.admin-row .cell.user { min-width: 120px; display:flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.admin-row.compact .cell { display:flex; align-items:center; gap:6px; }
.admin-row .avatar-24 { width:20px; height:20px; border-radius:50%; object-fit:cover; }
.admin-row .u-name { font-weight:700; line-height: 1.08; }
.admin-row .u-name, .admin-row .u-email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.admin-row .u-email { font-size:12px; opacity:.8; }
.admin-row .cell.role, .admin-row .cell.tier { align-items: flex-start; flex-direction: column; gap: 1px; }
.admin-row .cell.role > span, .admin-row .cell.tier > span { display:inline-block; max-width:100%; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.field-title { font-size: 12px; opacity: .95; line-height: 1.15; margin: 0; }
.admin-select { background: rgba(255,255,255,0.1); color:#fff; border:1px solid rgba(255,255,255,0.25); border-radius:6px; padding:2px 6px; min-width: 90px; width: 100%; font-size: 13px; height: 26px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-row label.tiny { font-size:12px; opacity:.95; margin-right:6px; white-space:nowrap; }
.admin-row .quotas { display:flex; flex-wrap:wrap; gap:4px; }
.admin-row .quotas .q { font-size:12px; background: rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.18); border-radius:6px; padding:4px 6px; display:flex; gap:4px; align-items:stretch; flex-direction: column; }
.admin-row .quotas .q .q-title { font-size: 12px; opacity: .95; line-height: 1.1; white-space: nowrap; }
.admin-row .quotas .q input { width:72px; padding:3px 6px; border-radius:6px; border:1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.2); color:#fff; font-size: 12px; }

@media (max-width: 980px) {
  .admin-row { grid-template-columns: 24px 160px 110px 100px 1fr; }
}

/* Posts composer: larger text + inline counter */
.post-input-wrap { position: relative; }
#postComposer { font-size: 16px; line-height: 1.4; text-align: left; padding-bottom: 28px; }
.post-word-counter { position: absolute; right: 12px; bottom: 10px; font-size: 12px; opacity: .8; color: #fff; pointer-events: none; }
@media (max-width: 820px) {
  .admin-row { grid-template-columns: 24px 1fr; }
  .admin-row .cell.role, .admin-row .cell.tier, .admin-row .cell.quotas { margin-top: 4px; }
}

.admin-tier-table { display:flex; flex-direction:column; gap:8px; }
.admin-tier-table .tier-row { display:grid; grid-template-columns: 100px 1fr auto; gap:10px; align-items:center; background: rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.18); border-radius:10px; padding:10px; }
.admin-tier-table .t-quotas { display:flex; flex-wrap:wrap; gap:6px; }
.admin-tier-table .q { font-size:12px; background: rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.18); border-radius:6px; padding:4px 6px; display:flex; gap:4px; align-items:stretch; flex-direction: column; }
.admin-tier-table .q .q-title { font-size: 12px; opacity: .95; line-height: 1.1; white-space: nowrap; }
.admin-tier-table .q input { width:72px; padding:3px 6px; border-radius:6px; border:1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.2); color:#fff; font-size: 12px; }
.admin-tier-table .cell.actions { display:flex; flex-direction: column; gap:6px; align-items: center; }

/* Admin pager */
.admin-pager { display:flex; align-items:center; gap:8px; justify-content:flex-end; margin: 4px 0 8px; }
.admin-pager #adminUsersPageInfo { font-size: 12px; opacity: .9; }
.admin-pager span { font-size: 12px; opacity: .9; }

/* Tier badge near username */
.tier-badge { margin-left: 6px; font-size: 14px; vertical-align: middle; }
.tier-free { color: #66bb6a; }
.tier-plus { color: #42a5f5; }
.tier-pro { color: #ffb300; }
.tier-premium { color: #00e5ff; }

/* Header avatar + dropdown */
.header-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.85); margin-right: 8px; cursor: pointer; }
.user-menu { position: relative; display: inline-flex; align-items: center; }
.user-dropdown { position: absolute; top: 36px; right: 0; background: rgba(0,0,0,0.85); border:1px solid rgba(255,255,255,0.2); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 140px; z-index: 9999; }
.user-dropdown a { color:#fff; text-decoration:none; font-size: 13px; padding: 6px 8px; border-radius:6px; }
.user-dropdown a:hover { background: rgba(255,255,255,0.12); }
.hidden { display: none !important; }
.letter-avatar { width: 28px; height: 28px; border-radius: 50%; background: #607d8b; color:#fff; display:inline-flex; align-items:center; justify-content:center; font-weight:800; border:2px solid rgba(255,255,255,0.85); margin-right:8px; cursor:pointer; }
/* Fancy gradient avatar placeholder */
.avatar-fancy { display:inline-flex; align-items:center; justify-content:center; border-radius:50%; color:#fff; font-weight:900; letter-spacing:.5px; text-transform:uppercase; border:2px solid rgba(255,255,255,0.85); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.avatar-fancy.avatar-24 { width:24px; height:24px; font-size:12px; }
.avatar-fancy.avatar-28 { width:28px; height:28px; font-size:13px; }
.avatar-fancy.avatar-32 { width:32px; height:32px; font-size:14px; }
.avatar-fancy.avatar-40 { width:40px; height:40px; font-size:16px; }
.avatar-fancy.avatar-64 { width:64px; height:64px; font-size:28px; border:1px solid rgba(255,255,255,0.25); }

/* Bootstrap-like compact buttons for post actions */
.btn { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:8px; border:1px solid rgba(0,0,0,0.15); background: rgba(255,255,255,0.9); color:#111; cursor:pointer; font-size: 13px; line-height: 1; }
.btn:hover { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity:.6; cursor:not-allowed; }
.btn-sm { padding:4px 8px; font-size:12px; border-radius:6px; }
.btn-icon { gap:6px; }
.btn-icon .ico { font-size: 14px; line-height:1; display:inline-block; }
.post-card .post-actions .btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.15); }
.post-card .post-actions .btn:hover { background: rgba(0,0,0,0.06); }

/* Inline SVG icon defaults for outline look */
.ico svg { width: 18px; height: 18px; display:block; }
.ico-heart path,
.ico-bookmark path,
.ico-share path,
.ico-repost path,
.ico-comment path { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon.active .ico-heart path { fill: #f44336; stroke: #f44336; }
.btn-icon.active .ico-bookmark path { fill: currentColor; stroke: currentColor; }
.btn-icon.active .ico-share path { fill: currentColor; stroke: currentColor; }
.btn-icon.active .ico-repost path { fill: currentColor; stroke: currentColor; }
.btn-icon.active { background: rgba(0,0,0,0.08); }
.post-card .post-actions { display:flex; gap:10px; align-items:center; margin-top:6px; flex-wrap: wrap; }

/* Comment preview + enhancements tidy layout */
.comments-preview { margin-top: 6px; }
.comments-preview .comment-row,
.comments .comment-row,
.comment-children .comment-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: rgba(139, 117, 198, 0.12);
  border: 1px solid rgba(139, 117, 198, 0.24);
  box-shadow: 0 12px 28px rgba(8, 12, 32, 0.12);
  backdrop-filter: blur(6px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.comments .comment-row:hover,
.comment-children .comment-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(8, 12, 32, 0.16);
}
.comments .comment-row .avatar-link,
.comments-preview .comment-row .avatar-link,
.comment-children .comment-row .avatar-link {
  flex-shrink: 0;
}
.comments .comment-row .comment-body,
.comments-preview .comment-row .comment-body,
.comment-children .comment-row .comment-body {
  flex: 1;
}
.comments .comment-row .comment-text,
.comments-preview .comment-row .comment-text,
.comment-children .comment-row .comment-text {
  font-size: 14px;
  line-height: 1.5;
  color: #1c1c28;
}
.comment-body .comment-actions { margin-top: 8px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.comment-body .comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.comment-meta-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.comment-replyto {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(139, 117, 198, 0.18);
  color: #3942b9;
}
.comment-body .user-link {
  font-weight: 700;
  color: #1f2a4a;
}
.comment-body .user-link:hover { color: #2f3c8f; }
.comment-time { opacity: 0.7; font-size: 12px; }
.comment-actions a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  background: rgba(139, 117, 198, 0.16);
  color: #2f3c8f;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.18s ease;
}
.comment-actions a:hover { background: rgba(139, 117, 198, 0.24); transform: translateY(-1px); }
.comment-dot {
  color: rgba(31, 42, 74, 0.45);
  margin: 0 2px;
  font-size: 14px;
  pointer-events: none;
}
.comment-enh { margin-top: 4px; display: grid; grid-template-columns: repeat(var(--enh-cols, 2), minmax(0,1fr)); gap: 6px; grid-auto-flow: row dense; }
.comment-enh .enhancement-card {
  border: 1px solid var(--enh-card-border, rgba(148, 163, 184, 0.38));
  border-radius: 8px;
  padding: 6px 8px;
  margin-top: 4px;
  background: rgba(var(--enh-card-bg-rgb, 15, 23, 42), var(--enh-card-bg-alpha, 0.92));
  color: #f8fafc;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.3);
}
.comment-enh .enhancement-title {
  font-size: 12px;
  opacity: .95;
  margin-bottom: 4px;
  font-weight: 800;
  text-transform: uppercase;
  text-align: center;
  position: relative;
  padding-right: 28px;
  color: #dbeafe;
}
.comment-enh .enhancement-title .enh-explain-btn {
  position: absolute;
  left: 4px; /* align left to mirror post cards */
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: inherit;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.9;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.comment-enh .enhancement-title .enh-voice-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border-radius: 6px; padding: 2px 6px; }
.comment-enh .enhancement-content { font-size: 13px; line-height: 1.3; color: #f8fafc; }
.comment-enh .enhancement-content a { color: #bfdbfe; }
.comment-enh .enhancement-content strong,
.comment-enh .enhancement-content em { color: inherit; }
.comment-enh .enhancement-card ruby rt { color: #cbd5f5; }
.comment-children,
.comment-replies {
  display: grid;
  gap: 10px;
}
.comment-replies {
  margin-top: 12px;
  border-left: none;
  padding-left: 0;
}
.comment-replies .comment-row {
  margin-left: 0 !important;
  background: rgba(139, 117, 198, 0.1);
  box-shadow: 0 10px 24px rgba(8, 12, 32, 0.1);
}

/* Admin Features footer row */
.feat-footer-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.feat-footer-row input#featFooter { flex: 1 1 420px; min-width: 240px; max-width: 560px; padding:8px; border-radius:8px; border:1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color:#fff; }
.feat-row .drag-handle { opacity: .8; }

/* Post composer attachment */
#postAttach .dm-voice-button { width: auto; }
#postAttach .attach-row { display:flex; align-items:center; gap:8px; }

/* Posts timeline cards */
.post-card { background: rgba(var(--post-card-bg-rgb), var(--post-card-bg-alpha)); color:#111; border:1px solid rgba(0,0,0,0.08); border-radius:14px; padding:12px; box-shadow: 0 10px 28px rgba(0,0,0,0.12); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease; animation: fadeUp .25s ease both; }
/* During timeline rebuilds, suppress card animations/transitions to avoid overall flash */
body.posts-rendering .post-card { animation: none !important; transition: none !important; }
.post-card:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(0,0,0,0.18); border-color: rgba(0,0,0,0.12); background: rgba(255,255,255,0.98); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.post-header { display:flex; align-items:center; gap:10px; position: relative; padding-right: 48px; }
.post-username { font-weight:900; letter-spacing: .2px; }
.post-time { opacity:.9; font-size:12px; margin-left: auto; font-weight: 700; }
.post-media { margin:10px 0; }
.post-text { margin:8px 0; white-space: pre-wrap; font-size: 15px; line-height: 1.5; text-align: center; color: #111; }
/* Do not center main text in posts; center media only */
.post-text { text-align: left; }
.post-media { text-align: center; }
.post-media-img {
  width: 100%;
  height: auto;
  display: block;
}

.game-share-card {
  margin: 10px 0;
  padding: 12px;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.game-share-card .game-share-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  margin-bottom: 6px;
  color: #1f2937;
}
.game-share-card .game-share-owner {
  font-size: 12px;
  color: rgba(17,24,39,0.6);
}
.game-share-card .game-share-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 6px;
  color: rgba(17,24,39,0.85);
}
.game-share-card .game-share-stats strong {
  font-weight: 800;
  color: #111827;
}
.game-share-card .game-share-langs {
  font-size: 12px;
  color: rgba(17,24,39,0.68);
  margin-bottom: 10px;
}
.game-share-card .game-share-actions {
  display: flex;
  gap: 8px;
}
.game-share-card .control-button.primary {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #fff;
}
.game-share-card .control-button.primary:hover {
  background: #1d4ed8;
}

.post-quote-wrapper { margin-top: 8px; }
.post-quote-preview { margin-top: 8px; }
.post-quote-preview .quote-card { margin: 0; }
#postQuotePreview { display: none; border: 1px dashed rgba(99,102,241,0.3); border-radius: 14px; padding: 6px; background: rgba(99,102,241,0.08); }
[data-theme="dark"] #postQuotePreview { border-color: rgba(129,140,248,0.45); background: rgba(99,102,241,0.18); }
.quote-card { position: relative; border: 1px solid rgba(0,0,0,0.12); border-radius: 12px; padding: 12px 14px; background: rgba(255,255,255,0.6); backdrop-filter: blur(8px); transition: border-color .2s ease, background .2s ease; margin-left: 40px; margin-right: 16px; max-width: calc(100% - 56px); }
.quote-card::before, .quote-card::after { position: absolute; color: rgba(79,70,229,0.28); font-size: 30px; font-weight: 600; pointer-events: none; transition: transform .2s ease, color .2s ease; }
.quote-card::before { content: "\275D"; left: -34px; top: 8px; }
.quote-card::after { content: "\275E"; right: -20px; bottom: -6px; }
.quote-card:hover::before, .quote-card:hover::after { color: rgba(79,70,229,0.4); transform: translateY(-2px); }
.quote-card:hover { border-color: rgba(99,102,241,0.35); background: rgba(255,255,255,0.72); }
.quote-card-link { display: block; color: inherit; text-decoration: none; }
.quote-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.quote-avatar .avatar-fancy { width: 32px; height: 32px; font-size: 14px; }
.quote-avatar img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.quote-meta { display: flex; flex-direction: column; gap: 2px; font-size: 0.82rem; color: rgba(55,65,81,0.85); }
.quote-body { font-size: 0.95rem; line-height: 1.45; color: rgba(17,24,39,0.92); white-space: pre-line; word-break: break-word; }
.quote-media { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: flex-start; }
.quote-media-img { flex: 0 0 auto; max-width: 168px; height: 116px; object-fit: contain; border-radius: 10px; background: rgba(241,245,249,0.8); padding: 4px; box-shadow: inset 0 0 0 1px rgba(148,163,184,0.25); }
.quote-media.audio-only { display: flex; }
.quote-media.audio-only .dm-voice-button { width: 100%; justify-content: flex-start; }
.quote-unavailable { color: rgba(55,65,81,0.7); font-style: italic; padding: 4px 0; }
.quote-empty { color: rgba(55,65,81,0.6); font-style: italic; }
.quote-remove { position: absolute; top: 6px; right: 6px; background: rgba(17,24,39,0.66); color: #fff; border: none; border-radius: 999px; width: 24px; height: 24px; font-size: 14px; line-height: 24px; text-align: center; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .2s ease; }
.quote-remove:hover { background: rgba(99,102,241,0.85); }

@media (max-width: 640px) {
  .quote-card { margin-left: 28px; margin-right: 12px; max-width: calc(100% - 40px); padding: 12px; }
  .quote-card::before { left: -26px; font-size: 26px; }
  .quote-card::after { right: -14px; font-size: 26px; }
  .quote-media-img { max-width: 140px; height: 104px; }
  .voice-selector { padding: 14px; }
  .voice-row { padding: 12px; }
  .voice-row-body { flex-direction: column; align-items: flex-start; }
  .voice-custom-control { width: 100%; }
  .voice-select-wrapper { width: 100%; }
  .voice-select { width: 100%; }
  .voice-custom-panel { padding: 10px; }
  .voice-editor-record { flex-direction: column; align-items: stretch; }
  .voice-editor-visual { width: 100%; }
}

.avatar-56 {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.post-detail-shell {
  max-width: 900px;
  margin: 20px auto;
  padding: 0 16px;
}
.post-detail-shell.mobile {
  margin-bottom: 72px;
  padding: 0 12px;
}
.post-detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 18px;
  background: rgba(var(--post-card-bg-rgb), var(--post-card-bg-alpha));
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 18px 42px rgba(20, 28, 58, 0.14);
  margin: 20px 0;
  flex-wrap: wrap;
}
.post-detail-author {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}
.post-detail-avatar .avatar-56,
.post-detail-avatar img {
  box-shadow: 0 8px 24px rgba(14, 21, 41, 0.18);
}
.post-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.post-detail-handle {
  font-size: 22px;
  font-weight: 800;
  color: inherit;
  text-decoration: none;
  word-break: break-word;
}
.post-detail-handle:hover,
.post-detail-handle:focus {
  text-decoration: underline;
}
.post-detail-counts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  opacity: .85;
}
.post-detail-counts span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.post-detail-counts strong {
  font-weight: 800;
}
.post-detail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.post-detail-actions .control-button {
  white-space: nowrap;
}
.control-button.outline {
  background: transparent;
  border: 1px solid rgba(0,0,0,0.25);
  color: inherit;
}
.control-button.outline:hover {
  background: rgba(0,0,0,0.06);
}
.control-button.following {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #1d4ed8;
}
.control-button.following:hover {
  background: rgba(59, 130, 246, 0.22);
}
.post-detail-card {
  margin-top: 12px;
  padding: 16px;
}

.comments-more,
.comments-less {
  text-align: center;
  margin-top: 0;
}
.comments-more .control-button,
.comments-less .control-button,
.comments-more button,
.comments-less button {
  min-width: 120px;
}

.comments-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.comment-row.comment-reply {
  margin-left: 16px;
  border-left: 3px solid rgba(139, 117, 198, 0.35);
  padding-left: 12px;
}

.enh-lang-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border-radius: 6px;
  transition: background 0.2s ease, transform 0.2s ease;
}
.enh-lang-option:hover {
  background: rgba(139, 117, 198, 0.12);
  transform: translateX(2px);
}
.enh-lang-option.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  position: relative;
}
.enh-lang-option.disabled input[type="checkbox"] {
  cursor: not-allowed;
}
.enh-limit-info {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(31, 42, 74, 0.72);
}
.enh-limit-cta {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(139,117,198,0.18), rgba(93,63,211,0.22));
  border: 1px solid rgba(93, 63, 211, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.enh-limit-cta.hidden {
  display: none;
}
.enh-limit-cta .cta-text {
  font-weight: 600;
  color: #2b2560;
  flex: 1 1 auto;
}
.enh-limit-cta .control-button.primary {
  background: linear-gradient(135deg, #7c5cff, #d32fe2);
  color: #fff;
  border: none;
  box-shadow: 0 8px 18px rgba(124, 92, 255, 0.35);
}
.enh-limit-cta.pulse {
  animation: enhancePulse 1.2s ease 2;
}
@keyframes enhancePulse {
  0% { box-shadow: 0 0 0 rgba(124, 92, 255, 0.35); }
  50% { box-shadow: 0 0 24px rgba(211, 47, 226, 0.6); }
  100% { box-shadow: 0 0 0 rgba(124, 92, 255, 0.35); }
}

/* Modern links inside posts */
#tab-posts .post-card a { text-decoration: none; outline: none; }
#tab-posts .post-card a:focus { outline: none; }
#tab-posts .post-card a.user-link,
#tab-posts .post-card a.post-username { color: #1976d2; font-weight: 800; }
#tab-posts .post-card a.user-link:hover,
#tab-posts .post-card a.post-username:hover { color: #1976d2; }
#tab-posts .post-card a.user-link:visited,
#tab-posts .post-card a.post-username:visited { color: #1976d2; }

#tab-posts .post-card .comment-text { color: #333; opacity: .95; }

#tab-posts .post-card .avatar-link img { border: 2px solid transparent; border-radius: 50%; transition: border-color .15s ease; }
#tab-posts .post-card .avatar-link:hover img { border-color: rgba(25,118,210,0.65); }

/* Compact voice button inside posts */
.post-card .dm-voice-button { display:inline-flex; align-items:center; gap:6px; padding: 4px 10px; font-size: 12px; border-radius: 999px; }
.post-card .voice-icon { font-size: 14px; }
.post-card .voice-label { font-size: 12px; }
.post-card .voice-progress { height: 2px; }
.post-card .post-footer { margin-top: 12px; display:flex; justify-content:flex-start; align-items:center; font-size: 12px; color: rgba(17,17,17,0.65); }
.post-card .post-footer .post-time { opacity: 0.85; }
/* Mobile: keep time/readability dark on light post cards */
.mobile-app-body .post-card .post-footer { color: rgba(17,17,17,0.72); }
[data-theme="dark"] .quote-card { background: rgba(30,41,59,0.65); border-color: rgba(148,163,184,0.25); }
[data-theme="dark"] .quote-card:hover { background: rgba(30,41,59,0.78); border-color: rgba(129,140,248,0.35); }
[data-theme="dark"] .quote-card::before, [data-theme="dark"] .quote-card::after { color: rgba(165,180,252,0.28); }
[data-theme="dark"] .quote-card:hover::before, [data-theme="dark"] .quote-card:hover::after { color: rgba(165,180,252,0.42); }
[data-theme="dark"] .quote-body { color: rgba(226,232,240,0.94); }
[data-theme="dark"] .quote-meta { color: rgba(203,213,225,0.82); }
[data-theme="dark"] .quote-empty { color: rgba(203,213,225,0.6); }
[data-theme="dark"] .quote-remove { background: rgba(99,102,241,0.6); }
[data-theme="dark"] .quote-remove:hover { background: rgba(129,140,248,0.8); }

/* Post enhancements grid */
.post-enh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.post-enh-grid .enhancement-card {
  background: rgba(var(--enh-card-bg-rgb, 15, 23, 42), var(--enh-card-bg-alpha, 0.92));
  border: 1px solid var(--enh-card-border, rgba(148, 163, 184, 0.38));
  border-radius: 10px;
  padding: 8px;
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.35);
}
.post-enh-grid .enhancement-title {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  opacity: .95;
  margin-bottom: 6px;
  text-align:center;
  position: relative;
  padding-right: 28px;
  color: #dbeafe;
}
.post-enh-grid .enhancement-content {
  font-size: 14px;
  line-height: 1.6;
  color: #f8fafc;
}
.post-enh-grid .enhancement-content a { color: #bfdbfe; }
.post-enh-grid .enhancement-content strong,
.post-enh-grid .enhancement-content em { color: inherit; }
.post-enh-grid .enhancement-card ruby rt { color: #cbd5f5; }
.post-enh-grid .enhancement-title .enh-voice-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border-radius: 6px; padding: 2px 6px; }
/* Make ruby (furigana/pinyin) more readable inside post enhancements */
.post-enh-grid ruby rt { font-size: 0.95em; }
.post-enh-grid .chinese-ruby rt, .post-enh-grid .cantonese-ruby rt { font-size: 1.08em; }
/* Composer text alignment (override any inherited centering) */
#postComposer { text-align: left; }

/* Visibility switch */
.visibility-switch { position: relative; display:inline-flex; align-items:center; gap:4px; background: rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.2); border-radius: 999px; padding:2px; overflow: hidden; }
.visibility-switch .vis-slider { position:absolute; top:2px; bottom:2px; left:2px; width:26px; border-radius:999px; background: #2563eb; transition: transform 150ms ease; pointer-events:none; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15); z-index: 0; }
.visibility-switch .vis-option { position: relative; z-index: 1; width:26px; height:26px; display:flex; align-items:center; justify-content:center; border-radius:999px; cursor:pointer; opacity:.45; filter: grayscale(100%); transition: opacity 150ms ease, filter 150ms ease; }
.visibility-switch .vis-option.active { opacity:1; filter: none; color: #fff; font-weight: 600; text-shadow: 0 1px 1px rgba(0,0,0,0.35); }

.avatar-ring { position: relative; width: 28px; height: 28px; border-radius: 50%; padding: 2px; background: linear-gradient(135deg, #42a5f5, #ff6b6b, #ffa726); }
.avatar-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display:block; border: 2px solid rgba(0,0,0,0.35); }

/* Post menu (owner) */
.post-card { position: relative; }
.post-card.menu-open { z-index: 900; }
.post-header { position: relative; }
.post-menu-container { position: absolute; right: 6px; top: 4px; margin-left: 0; z-index: 60; }
.post-menu-container.owner-hidden { display: none !important; }
.post-menu-btn { border:none; background: transparent; color: #111; opacity: .85; cursor:pointer; width: 36px; height: 36px; font-size: 22px; line-height: 1; display:flex; align-items:center; justify-content:center; border-radius: 10px; transition: background .15s ease, opacity .15s ease; }
.post-menu-btn:hover { opacity: 1; background: rgba(0,0,0,0.06); }
.post-menu { position: absolute; right: 0; top: 40px; background: rgba(15,23,42,0.97); color: #eef; border:1px solid rgba(255,255,255,0.18); border-radius: 12px; min-width: 190px; z-index: 1200; box-shadow: 0 16px 40px rgba(0,0,0,0.35); padding: 6px; backdrop-filter: blur(6px); }
.post-menu::before { content: ""; position: absolute; top: -6px; right: 12px; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid rgba(15,23,42,0.97); transition: transform .15s ease; }
.post-menu.hidden { display: none; }
.post-menu.open { display: block; }
.post-menu.drop-up { top: auto; bottom: 44px; }
.post-menu.drop-up::before { top: auto; bottom: -6px; transform: rotate(180deg); }
.post-menu .menu-item { display:flex; align-items:center; gap:12px; width:100%; background: transparent; color:#eef; border:none; padding:10px 12px; border-radius:10px; cursor:pointer; font-weight: 600; transition: background .15s ease, color .15s ease, transform .05s ease; text-align:left; }
.post-menu .menu-item:hover { background: rgba(255,255,255,0.10); }
.post-menu .menu-item:active { transform: scale(0.99); }
.post-menu .menu-item .menu-icon { font-size: 18px; }
.post-menu .menu-item .menu-label { flex: 1; }
.post-menu .menu-item.danger { color: #ff6b6b; }
.post-menu .menu-item.danger:hover { background: rgba(255,107,107,0.12); color: #ff8585; }
.post-menu .menu-sep { height:1px; background: rgba(255,255,255,0.12); margin:4px 0; }

/* Visibility popup for posts */

/* Dark scheme tweak */
@media (prefers-color-scheme: dark) {
  .post-menu-btn { color: #fff; }
}

/* Simple image carousel */
.carousel { position: relative; border-radius:12px; overflow: hidden; border:1px solid rgba(0,0,0,0.08); background: rgba(0,0,0,0.06); aspect-ratio: 16 / 9; max-height: 420px; }
/* Make post feed images smaller */
.post-card .carousel { max-height: 160px; }
.carousel-track { display:flex; width: 100%; height: 100%; transition: transform .28s ease; }
.carousel .slide { flex: 0 0 100%; width: 100%; height: 100%; }

/* Single-image carousels: fit content and center the image */
.carousel.single { aspect-ratio: auto; height: auto; max-height: none; background: transparent; }
.post-card .carousel.single {
  max-height: clamp(200px, 38vw, 320px);
  overflow: hidden;
}
.carousel.single .carousel-track { align-items: center; justify-content: center; }
.carousel.single img {
  display:block;
  height: auto;
  width: auto;
  max-width: 100%;
  max-height: clamp(200px, 38vw, 320px);
  object-fit: contain;
  margin: 0 auto;
}

/* Desktop: keep post images at a reasonable width */
@media (min-width: 900px) {
  /* Center media block and limit carousel width */
  .post-card .post-media { display: flex; justify-content: center; }
  .post-card .carousel { max-width: 720px; width: 100%; }
  .post-card .carousel.single { max-width: 720px; }
  /* Also constrain standalone images (not in carousel) */
  .post-card .post-media img.post-media-img {
    width: auto;            /* override global 100% */
    height: auto;
    max-width: 720px;       /* reasonable desktop width */
    max-height: 420px;      /* reasonable desktop height */
    object-fit: contain;    /* keep aspect ratio within box */
    margin: 0 auto;
    display: block;
  }
}

@media (max-width: 768px) {
  .post-card .carousel.single {
    max-height: min(280px, 75vw);
  }
  .carousel.single img {
    max-height: min(280px, 75vw);
  }
  .comments-preview .comment-row,
  .comments .comment-row,
  .comment-children .comment-row {
    padding: 10px 12px;
    gap: 10px;
    margin-bottom: 8px;
  }
  .comment-actions a {
    padding: 4px 8px;
  }
}
.carousel .slide img { width: 100%; height: 100%; object-fit: cover; display:block; }
.carousel-nav { position:absolute; inset:0; display:flex; align-items:center; justify-content:space-between; pointer-events: none; }
.carousel button { pointer-events: auto; background: rgba(0,0,0,0.35); border:1px solid rgba(255,255,255,0.35); color:#fff; border-radius:50%; width:30px; height:30px; display:flex; align-items:center; justify-content:center; transition: opacity .15s ease; }
.carousel button:hover { opacity: .9; }
.carousel-dots { position:absolute; bottom:6px; left:0; right:0; text-align:center; }
.carousel-dots .dot { display:inline-block; width:7px; height:7px; border-radius:50%; margin:0 4px; background: rgba(255,255,255,0.5); transform: scale(1); transition: transform .15s ease, background .15s ease; }
.carousel-dots .dot.active { background:#fff; transform: scale(1.2); }

.post-action-overlay { position: fixed; inset: 0; background: rgba(8,12,24,0.55); backdrop-filter: blur(6px); display: none; align-items: center; justify-content: center; z-index: 2500; padding: 24px; }
.post-action-overlay.active { display: flex; }
.post-action-overlay.hidden { display: none; }
.post-action-dialog { width: min(420px, 92vw); background: rgba(15,23,42,0.96); border:1px solid rgba(255,255,255,0.12); border-radius: 16px; box-shadow: 0 24px 50px rgba(0,0,0,0.35); color: #eef; padding: 18px 20px; font-family: inherit; transform: translateY(12px); opacity: 0; transition: transform .18s ease, opacity .18s ease; }
.post-action-overlay.active .post-action-dialog { transform: translateY(0); opacity: 1; }
.post-action-dialog.busy { opacity: 0.6; pointer-events: none; }
.post-action-title { font-size: 18px; font-weight: 700; margin-bottom: 14px; text-align: left; }
.post-action-message { font-size: 15px; margin-bottom: 18px; opacity: 0.9; }
.post-action-options { display: flex; flex-direction: column; gap: 10px; }
.post-action-option { display: flex; align-items: center; gap: 12px; width: 100%; border-radius: 12px; background: rgba(255,255,255,0.06); border: 1px solid transparent; color: inherit; padding: 12px 14px; font-size: 15px; text-align: left; cursor: pointer; transition: border .15s ease, background .15s ease, transform .08s ease; }
.post-action-option:hover { background: rgba(255,255,255,0.12); }
.post-action-option.active { border-color: rgba(99, 179, 237, 0.8); background: rgba(99, 179, 237, 0.12); }
.post-action-option.disabled { opacity: 0.6; pointer-events: none; }
.post-action-icon { font-size: 22px; width: 32px; text-align: center; }
.post-action-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.post-action-label { font-weight: 700; font-size: 15px; }
.post-action-desc { font-size: 13px; opacity: 0.8; }
.post-action-check { font-size: 16px; }
.post-action-footer { display: flex; justify-content: flex-end; margin-top: 18px; gap: 10px; }
.post-action-footer.split { justify-content: space-between; }
.post-action-btn { border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.08); color: inherit; padding: 8px 16px; font-size: 14px; cursor: pointer; transition: background .15s ease, border .15s ease, transform .08s ease; }
.post-action-btn:hover { background: rgba(255,255,255,0.16); }
.post-action-btn.secondary { border-color: rgba(148,163,184,0.6); }
.post-action-btn.danger { border-color: rgba(255,107,107,0.6); color: #ff7a7a; }
.post-action-btn.danger:hover { background: rgba(255,107,107,0.16); }
.post-action-btn.disabled { pointer-events: none; opacity: 0.6; }
.post-action-open { overflow: hidden; }

.mobile-app-body .post-action-dialog { background: rgba(15,23,42,0.92); }
.mobile-app-body .post-action-desc { opacity: 0.9; }

/* Admin privileges: multi-select dropdown for languages */
.multi-dropdown { position: relative; display: inline-block; width: 100%; }
.multi-dropdown > button { cursor: pointer; display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; }
.multi-dropdown > button .summary { opacity:.9; font-size:12px; }
.multi-dropdown > button .caret { opacity:.85; }
.multi-dropdown .menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: rgba(0,0,0,0.85); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px; padding: 8px; min-width: 220px; z-index: 9999;
  display: none; max-height: 240px; overflow: auto;
}
.multi-dropdown.open .menu { display: block; }
.multi-dropdown .menu label { display:flex; align-items:center; gap:8px; padding:4px 2px; }
.multi-dropdown .menu input[type="checkbox"] { transform: scale(1.1); }

/* Post composer overlay waveform (same height as textarea) */
.post-input-wrap { position: relative; width: 100%; }
.post-input-wrap textarea { display:block; width: 100%; box-sizing: border-box; }
#postWave {
  /* Overlay container for Posts waveform */
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  padding: 0; /* let inner wrapper control spacing */
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  z-index: 15;
  background: rgba(0, 0, 0, 0.3);
}
/* Inner wrapper pinned to exact edges, bars bottom-aligned */
#postWave .wave-bars {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  bottom: 10px;
  display: flex;
  align-items: flex-end;      /* pin bar bottoms to bottom edge */
  justify-content: space-between;
  gap: 2px;
}

/* Ensure Posts waveform bars don't collapse */
#postWave .wave-bars .waveform-bar {
  flex: 0 0 3px;
  background: linear-gradient(to top, #ff6b6b, #ffa726, #42a5f5);
  border-radius: 2px;
  transition: height 0.1s ease;
}
.control-button.tiny { padding:6px 10px; font-size:12px; border-radius:8px; }

/* Submit buttons: loading state */
.control-button.loading { position: relative; opacity: 0.8; pointer-events: none; }
.control-button.loading::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: vcSpin 0.8s linear infinite;
}
@keyframes vcSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@keyframes floatUp {
            0% { opacity: 0; transform: translateY(12px); }
            10% { opacity: 1; transform: translateY(0); }
            90% { opacity: 1; transform: translateY(-10px); }
            100% { opacity: 0; transform: translateY(-20px); }
        }

        /* Presence bubble (green button with avatar, no text) */
        .presence-bubble {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            animation: bubbleUp 1.6s ease-out forwards;
        }
        .presence-bubble .presence-btn {
            background: linear-gradient(45deg, #2ecc71, #27ae60);
            border: 1px solid rgba(255,255,255,0.25);
            border-radius: 999px;
            padding: 6px;
            box-shadow: 0 8px 18px rgba(39, 174, 96, 0.45);
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        .presence-bubble .presence-avatar {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            object-fit: cover;
            border: 2px solid rgba(255,255,255,0.9);
            background: #fff;
        }
        @keyframes bubbleUp {
            0%   { opacity: 0; transform: translateY(8px) scale(0.95); }
            20%  { opacity: 1; transform: translateY(0)    scale(1.00); }
            80%  { opacity: 1; transform: translateY(-20px) scale(1.02); }
            100% { opacity: 0; transform: translateY(-32px) scale(1.04); }
        }

        /* DM area layout tweaks */
        #dmInput,
        #groupInput { font-size: 18px; }
        #dmSendBtn { align-self: center; }
        .dm-line { display: flex; align-items: center; gap: 8px; }
        .dm-line.left { justify-content: flex-start; }
        .dm-line.right { justify-content: flex-end; }
        /* Prevent auto-margins on bubbles from pushing action buttons away in DM view */
        #dmMessages .dm-line .user-message,
        #dmMessages .dm-line .ai-message { margin-left: 0 !important; margin-right: 0 !important; }
        .dm-refetch-btn {
            background: rgba(255,255,255,0.15);
            border: 1px solid rgba(255,255,255,0.25);
            color: #fff;
            border-radius: 8px;
            font-size: 12px;
            padding: 4px 8px;
            cursor: pointer;
            transition: opacity .2s ease;
            height: 28px;
        }
        .dm-refetch-btn:hover { opacity: .9; }
        /* DM bilingual render */
        .dm-main-text .dm-original { font-weight: 600; line-height: 1.35; }
        .dm-main-text .dm-sep { height: 1px; background: rgba(0,0,0,0.25); opacity: .3; margin: 6px 0; }
        [data-theme="dark"] .dm-main-text .dm-sep { background: rgba(255,255,255,0.7); }
        .dm-main-text .dm-translation { font-size: .92em; opacity: .95; line-height: 1.35; display: flex; align-items: baseline; gap: 8px; }
        .dm-main-text .dm-translation .dm-trans-btn { background: transparent; border: none; color: #1976d2; cursor: pointer; font-size: .85em; padding: 0; }
        .dm-main-text .dm-translation .dm-trans-btn:hover { text-decoration: underline; }
.dm-enh-grid { display: grid; grid-template-columns: repeat(var(--enh-cols, 2), minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.dm-enh-grid { align-items: stretch; }
.dm-enh-grid > .enhancement-card { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; align-items: stretch; }
.dm-enh-grid .enhancement-title { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; min-height: 28px; }
/* Position the three-dots explain button on DM/Group enhancement titles */
.dm-enh-grid .enhancement-title { position: relative; }
.dm-enh-grid .enhancement-title .enh-explain-btn {
  position: absolute;
  left: 4px; /* align to left to avoid audio button on right */
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: inherit;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.9;
  z-index: 2; /* ensure white glyph sits above glow */
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.dm-enh-grid .enhancement-title .enh-explain-btn::after,
.post-enh-grid .enhancement-title .enh-explain-btn::after,
.comment-enh .enhancement-title .enh-explain-btn::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  pointer-events: none;
  /* Vivid but subtle aurora under the white glyph on dark cards */
  background:
    radial-gradient(closest-side, rgba(34,211,238,0.38), rgba(34,211,238,0.00) 70%), /* cyan */
    radial-gradient(closest-side, rgba(167,139,250,0.34), rgba(167,139,250,0.00) 70%), /* violet */
    radial-gradient(closest-side, rgba(244,114,182,0.30), rgba(244,114,182,0.00) 70%); /* pink */
  filter: blur(8px) brightness(1.15);
  opacity: .46;
  z-index: 1; /* behind glyph, above card */
  mix-blend-mode: screen; /* lighten on dark cards, minimal on light */
  animation: enhGlow 2.6s ease-in-out infinite alternate;
}
.dm-enh-grid .enhancement-title .enh-explain-btn:hover::after,
.post-enh-grid .enhancement-title .enh-explain-btn:hover::after,
.comment-enh .enhancement-title .enh-explain-btn:hover::after { opacity: .38; }

@keyframes enhGlow {
  0%   { transform: translate(-50%, -50%) scale(0.96); opacity: .40; }
  100% { transform: translate(-50%, -50%) scale(1.06); opacity: .52; }
}

@media (prefers-reduced-motion: reduce) {
  .dm-enh-grid .enhancement-title .enh-explain-btn::after,
  .post-enh-grid .enhancement-title .enh-explain-btn::after,
  .comment-enh .enhancement-title .enh-explain-btn::after { animation: none; opacity: .40; }
}
.dm-enh-grid .enhancement-title .enh-explain-btn:hover {
  background: rgba(255,255,255,0.08);
}

/* Post enhancements: ensure title can host both voice and explain buttons */
.post-enh-grid .enhancement-title { position: relative; }
.post-enh-grid .enhancement-title .enh-explain-btn {
  position: absolute;
  left: 4px; /* move to left; voice button stays on right */
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: inherit;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.9;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}
.post-enh-grid .enhancement-title .enh-explain-btn:hover {
  background: rgba(255,255,255,0.08);
}
.comment-enh .enhancement-title .enh-explain-btn:hover {
  background: rgba(255,255,255,0.08);
}
.dm-enh-grid .enhancement-content {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: stretch;
  width: 100%;
}
.dm-enh-grid .enhancement-card.placeholder .enhancement-content { min-height: 64px; }
        .enhancement-card.placeholder { background: rgba(0,0,0,0.15); border: 1px dashed rgba(255,255,255,0.35); opacity: .9; }
        .enhancement-card.placeholder .enhancement-title { opacity: .85; }
        .enhancement-card.placeholder .enhancement-content { display:flex; align-items:center; justify-content:center; min-height:48px; }
        
        .recorder-section {
            text-align: center;
            margin-bottom: 40px;
        }
        
        .timer {
            font-size: 2em;
            font-weight: bold;
            color: #ff6b6b;
            margin: 10px 0;
        }

        .recorder-core .timer {
            margin: 0 0 6px 0;
        }

        .recorder-core {
            display: flex;
            align-items: stretch;
            justify-content: center;
            gap: 16px;
            margin: 24px auto;
            flex-wrap: wrap;
            max-width: 960px;
        }

        .recorder-core .main-controls {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin: 0;
            align-items: center;
            justify-content: center;
            flex: 1 1 100%;
            min-width: 0;
            text-align: center;
        }

        .recorder-core .main-controls .main-button {
            min-width: 160px;
        }

        .recorder-core #vadStatus,
        .recorder-core .waveform {
            flex: 1 1 100%;
            min-width: 0;
        }

        .main-controls {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin: 20px 0;
        }
        
        .main-button {
            border: none;
            border-radius: 25px;
            padding: 15px 30px;
            color: white;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 16px;
            font-weight: bold;
            min-width: 120px;
        }
        
        .main-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }
        
        .main-button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }
        
        .start-button {
            background: linear-gradient(45deg, #2ecc71, #27ae60);
        }
        
        .stop-button {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
        }
        
        .monitoring-indicator {
            background: linear-gradient(45deg, #f39c12, #e67e22);
            animation: pulse 1.5s infinite;
        }
        
        .recording-indicator {
            background: linear-gradient(45deg, #ff4757, #c44569);
            animation: pulse 1s infinite;
        }
        
        .controls {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin: 20px 0;
        }
        
.control-button {
    background: linear-gradient(45deg, #3742fa, #2f3542);
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.control-button.danger {
    background: linear-gradient(45deg, #ef5350, #e53935);
    border: none;
    color: #fff;
}

.control-button.danger:hover {
    box-shadow: 0 4px 16px rgba(229, 57, 53, 0.35);
}

.control-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
        
        .control-button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }
        
        .status {
            margin: 20px 0;
            padding: 15px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            text-align: center;
            font-size: 16px;
        }

        .sr-only {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border: 0;
        }

        .status-with-toggle {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 12px;
            margin: 20px 0;
            flex-wrap: wrap;
        }

        .status-with-toggle .status {
            display: none !important;
        }

        .status-with-toggle .control-button {
            flex: 0 0 auto;
            white-space: nowrap;
        }

        @media (max-width: 720px) {
            .status-with-toggle {
                flex-direction: column;
                align-items: stretch;
            }
            .status-with-toggle .control-button {
                width: 100%;
                text-align: center;
            }
        }

        .status.success { border-color: rgba(46, 204, 113, 0.5); background: rgba(46, 204, 113, 0.15); }
        .status.error { border-color: rgba(231, 76, 60, 0.5); background: rgba(231, 76, 60, 0.15); }
        .status.processing { border-color: rgba(52, 152, 219, 0.5); background: rgba(52, 152, 219, 0.15); }
        
        .status.monitoring {
            background: rgba(243, 156, 18, 0.2);
            border-color: rgba(243, 156, 18, 0.5);
        }
        
        .status.recording {
            background: rgba(231, 76, 60, 0.2);
            border-color: rgba(231, 76, 60, 0.5);
        }
        
        .status.processing {
            background: rgba(52, 152, 219, 0.2);
            border-color: rgba(52, 152, 219, 0.5);
        }

        /* Avatars */
        .avatar-24 { width:24px; height:24px; border-radius:50%; object-fit:cover; }
        .avatar-32 { width:32px; height:32px; border-radius:50%; object-fit:cover; }
        .avatar-40 { width:40px; height:40px; border-radius:50%; object-fit:cover; }
        .avatar-64 { width:64px; height:64px; border-radius:50%; object-fit:cover; border:1px solid rgba(255,255,255,0.25); }

        /* Profile row */
        .profile-row { display:flex; gap: 16px; align-items:flex-start; flex-wrap: wrap; }
        .profile-row.two-col { display:grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items:start; }
        .profile-avatar { display:flex; flex-direction:column; gap:10px; align-items:center; }
        .profile-avatar-trigger {
            position: relative;
            width: 120px;
            height: 120px;
            border-radius: 50%;
            border: 2px dashed rgba(255,255,255,0.35);
            background: rgba(66,66,96,0.25);
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            cursor: pointer;
            transition: border-color 0.2s ease, background 0.2s ease;
        }
        .profile-avatar-trigger:hover {
            border-color: rgba(66,165,245,0.85);
            background: rgba(66,165,245,0.18);
        }
        .profile-avatar-trigger img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        .profile-avatar-initial {
            position: absolute;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            font-weight: 700;
            color: #fff;
        }
        .profile-avatar-plus {
            position: absolute;
            bottom: 10px;
            right: 10px;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: #42a5f5;
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 18px;
            box-shadow: 0 3px 10px rgba(0,0,0,0.35);
        }
        .profile-avatar-trigger.profile-avatar-fallback {
            border: none;
        }
        .profile-avatar-trigger.profile-avatar-fallback img {
            display: none;
        }
        .profile-avatar-trigger.profile-avatar-fallback .profile-avatar-initial {
            display: flex;
        }
.profile-fields label { display:block; margin-bottom:8px; }
.profile-fields input { padding:8px; border-radius: 8px; border:1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.1); color:#fff; min-width: 220px; }
.profile-email-block { display:flex; flex-direction:column; gap:6px; }
.email-confirm-status { display:flex; align-items:center; gap:10px; font-size:0.9rem; color:#f59e0b; flex-wrap:wrap; }
.email-confirm-status[data-state="sent"] { color:#3b82f6; }
.email-confirm-status[data-state="confirmed"] { color:#10b981; }
.email-confirm-status[data-state="error"] { color:#ef4444; }
.email-confirm-status[hidden] { display:none !important; }
#profileEmailResendBtn.control-button.tiny { padding:6px 12px; }
#profileEmailResendBtn.is-loading { opacity:0.7; pointer-events:none; }
#profileEmailResendBtn .loading-dots { min-width:1.2em; text-align:left; }
        .profile-col { background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 10px; }

.invite-list { display:flex; flex-direction:column; gap:10px; }
.invite-item { display:flex; flex-direction:column; gap:10px; background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.15); border-radius: 12px; padding:12px 14px; }
.invite-item.invite-summary { padding:10px 12px; }
.invite-item.invite-empty { justify-content:center; align-items:center; font-size:13px; opacity:0.75; min-height:60px; }

.invite-primary-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.invite-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.invite-actions-compact { margin-top:4px; }

.invite-toggle-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-top:8px;
}
.invite-toggle-row label {
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13px;
}

.code-chip,
.invite-code-badge {
  appearance:none;
  border:1px solid rgba(255,255,255,0.2);
  background: rgba(15,23,42,0.4);
  color:#fff;
  border-radius: 8px;
  padding:4px 10px;
  font-size:13px;
  cursor:pointer;
  transition: background 0.2s ease;
  max-width:220px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.invite-code-badge { cursor:default; display:inline-flex; align-items:center; }
.code-chip:hover { background: rgba(59,130,246,0.25); }

.invite-lang-chip,
.invite-usage-count,
.invite-remaining-chip {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  background: rgba(15,23,42,0.45);
  border:1px solid rgba(148,163,184,0.26);
  color:#e2e8f0;
}

.invite-usage-count { font-weight:600; }

.invite-pill {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
  border:1px solid transparent;
}
.invite-pill-unused {
  background: rgba(34,197,94,0.16);
  border-color: rgba(34,197,94,0.35);
  color: #bbf7d0;
}
.invite-pill-used {
  background: rgba(59,130,246,0.18);
  border-color: rgba(59,130,246,0.4);
  color: #dbeafe;
}
.invite-pill-inactive {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.4);
  color: #fecaca;
}
.invite-pill-exhausted {
  background: rgba(249,115,22,0.2);
  border-color: rgba(249,115,22,0.45);
  color: #fed7aa;
}
.invite-pill-group {
  background: rgba(99,102,241,0.22);
  border-color: rgba(99,102,241,0.45);
  color: #e0e7ff;
}
.invite-pill-warning {
  background: rgba(234,179,8,0.24);
  border-color: rgba(234,179,8,0.45);
  color: #fef08a;
}

.invite-actions .control-button { padding:4px 10px; font-size:13px; }
.invite-actions .control-button.danger { padding:4px 12px; }

.invite-inline-field {
    display:flex;
    align-items:center;
    gap:6px;
    margin-top:6px;
    width:100%;
}
.invite-inline-field input {
    flex:1 1 auto;
    min-width:0;
}
.invite-inline-field .control-button {
    flex:0 0 auto;
    white-space:nowrap;
}
.invite-inline-nowrap {
    flex-wrap:nowrap;
}

.invite-more { margin-top:6px; text-align:center; }
.invite-more.hidden { display:none; }
.invite-more .control-button { padding:6px 16px; font-size:13px; }

.invite-links-group { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:6px 0; }
.invite-links-label { font-size:13px; opacity:0.8; }
.invite-links-group .control-button { padding:4px 10px; font-size:13px; }

.invite-options { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:4px; }

.admin-invite-controls { display:flex; flex-direction:column; gap:14px; }
.admin-invite-create,
.admin-invite-filters { display:flex; flex-wrap:wrap; align-items:center; gap:12px; }
.admin-invite-create label,
.admin-invite-filters label { display:flex; flex-direction:column; font-size:13px; color:#cbd5f5; }
.admin-invite-create input,
.admin-invite-create select,
.admin-invite-filters select { margin-top:4px; background:rgba(15,23,42,0.75); border:1px solid rgba(148,163,184,0.25); border-radius:8px; padding:6px 10px; color:#e2e8f0; min-width:120px; }

.admin-invite-list { display:flex; flex-direction:column; gap:12px; }
.admin-invite-row { display:grid; grid-template-columns:1.2fr 1fr 1fr 1fr 1.1fr 1.5fr; gap:14px; align-items:center; background:rgba(148,163,184,0.08); border:1px solid rgba(148,163,184,0.12); border-radius:14px; padding:14px 16px; }
.admin-invite-row .invite-col code { background:rgba(15,23,42,0.65); border-radius:8px; padding:4px 8px; font-size:13px; display:inline-block; }
.admin-invite-row .invite-col.links { display:flex; gap:6px; flex-wrap:wrap; }
.admin-invite-row .invite-col.links .control-button { padding:4px 10px; font-size:13px; }
.invite-remaining { display:inline-block; margin-left:8px; font-size:12px; opacity:0.7; }
.invite-last { margin-top:4px; font-size:12px; opacity:0.65; }

@media (max-width: 1100px) {
  .admin-invite-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
  .admin-invite-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
        .invite-code { font-family: monospace; background: rgba(0,0,0,0.2); padding: 2px 6px; border-radius: 4px; }
        .invite-link { flex:1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
        .status-dot { width:10px; height:10px; border-radius:50%; display:inline-block; }
        .status-dot.gray { background:#9ca3af; }
        .status-dot.green { background:#10b981; }
        .status-dot.red { background:#ef4444; }

        body.modal-open {
            overflow: hidden;
        }

        html.modal-open {
            overflow: hidden;
        }

        /* Modal */
        .modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 24px; overflow-y: auto; min-height: 100vh; }
        .modal.hidden { display: none; }
        .modal-dialog { width: min(720px, 92vw); max-height: calc(100vh - 48px); margin: auto; background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); color: #fff; border-radius: 12px; border: 1px solid rgba(255,255,255,0.25); box-shadow: 0 10px 30px rgba(0,0,0,0.25); overflow: hidden; display: flex; flex-direction: column; }
        .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: rgba(255,255,255,0.08); border-bottom: 1px solid rgba(255,255,255,0.2); }
        .modal-content { padding: 12px; flex: 1 1 auto; overflow: auto; }
        .modal-close { background: transparent; border: none; color: #fff; font-size: 18px; cursor: pointer; }
        .inv-summary { font-size: 13px; opacity: .9; margin-left: auto; margin-right: 10px; }

        /* Friends list avatars */
        #friendsList .conversation-item { display:flex; align-items:center; gap:10px; }
        #friendsList .friend-avatar { width:28px; height:28px; border-radius:50%; object-fit:cover; border:1px solid rgba(255,255,255,0.25); }
        #friendsList .friend-name { flex:1; }

        /* Conversation message row with avatar */
        .msg-line { display:flex; gap:8px; align-items:flex-end; }
        .msg-line.right { justify-content:flex-end; }
        .msg-line.left { justify-content:flex-start; }
        
        .status.playing {
            background: rgba(46, 204, 113, 0.2);
            border-color: rgba(46, 204, 113, 0.5);
        }
        
        .status.stopped {
            background: rgba(149, 165, 166, 0.2);
            border-color: rgba(149, 165, 166, 0.5);
        }
        
        .waveform {
            width: 100%;
            height: 120px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 10px;
            margin: 20px 0;
            display: flex;
            align-items: end;
            justify-content: center;
            padding: 10px;
            overflow: hidden;
        }

        .recorder-core .waveform {
            margin: 0;
            min-height: 140px;
        }

        @media (min-width: 720px) {
            .recorder-core .main-controls,
            .recorder-core #vadStatus,
            .recorder-core .waveform {
                flex: 1 1 calc(33.333% - 16px);
            }
        }

        @media (min-width: 960px) {
            .recorder-core {
                flex-wrap: nowrap;
            }
            .recorder-core .main-controls,
            .recorder-core #vadStatus,
            .recorder-core .waveform {
                flex: 1 1 0;
            }
        }
        
        .waveform-bar {
            width: 3px;
            background: linear-gradient(to top, #ff6b6b, #ffa726, #42a5f5);
            margin: 0 1px;
            border-radius: 2px;
            transition: height 0.1s ease;
        }
        
        .conversation-area {
            margin-top: 40px;
        }
        
        /* Desktop-only dark panel; mobile uses theme.css overrides */
        body:not(.mobile-app-body) .conversation-list {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 15px;
            padding: 30px;
            min-height: 400px;
            max-height: 600px;
            overflow-y: auto;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* Posts-specific overrides */
        #tab-posts #postsWrapper {
            background: rgba(var(--posts-bg-rgb), var(--posts-bg-alpha));
        }
        #postsWrapper.no-scroll {
            max-height: none;
            overflow-y: visible;
        }
        #postsWrapper .post-text {
            font-size: calc(15px * var(--posts-font-scale));
        }
        #postsWrapper .post-enh-grid .enhancement-card[data-type="english"] .enhancement-content { font-size: calc(14px * var(--posts-font-scale) * var(--posts-en-scale)); }
        #postsWrapper .post-enh-grid .enhancement-card[data-type="japanese"] .enhancement-content { font-size: calc(14px * var(--posts-font-scale) * var(--posts-ja-scale)); }
        #postsWrapper .post-enh-grid .enhancement-card[data-type="chinese"] .enhancement-content { font-size: calc(14px * var(--posts-font-scale) * var(--posts-zh-scale)); }
        #postsWrapper .post-enh-grid .enhancement-card[data-type="cantonese"] .enhancement-content { font-size: calc(14px * var(--posts-font-scale) * var(--posts-yue-scale)); }
        /* Ruby (furigana/pinyin/jyutping) scaling inside posts */
        #postsWrapper .post-enh-grid .enhancement-card[data-type="japanese"] .enhancement-content ruby rt { font-size: calc(0.70em * var(--posts-ja-ruby-scale) * var(--posts-font-scale)); }
        #postsWrapper .post-enh-grid .enhancement-card[data-type="chinese"] .enhancement-content ruby rt { font-size: calc(0.90em * var(--posts-zh-ruby-scale) * var(--posts-font-scale)); }
        #postsWrapper .post-enh-grid .enhancement-card[data-type="cantonese"] .enhancement-content ruby rt { font-size: calc(0.90em * var(--posts-yue-ruby-scale) * var(--posts-font-scale)); }
        
        .conversation-item {
            margin: 20px 0;
            animation: fadeIn 0.5s ease-in;
        }

        /* Disable entrance animation for desktop lists to avoid flash/bump when switching tabs */
        #friendsList .conversation-item,
        #friendRequestsIncoming .conversation-item,
        #friendRequestsOutgoing .conversation-item,
        #groupsList .conversation-item,
        .group-list-scroll .conversation-item,
        .groups-view .conversations-list .conversation-item {
            animation: none !important;
            transform: none !important;
            opacity: 1 !important;
        }

        /* Disable fade-up on Posts list cards so the composer/input area doesn’t float on tab switch */
        #tab-posts .post-card,
        #postsList .post-card {
            animation: none !important;
            transform: none !important;
            opacity: 1 !important;
        }
        /* Also disable the generic conversation-item fade for the composer wrapper in Posts (desktop) */
        #tab-posts .conversation-item {
            animation: none !important;
            transform: none !important;
            opacity: 1 !important;
        }
        
        .user-message, .ai-message {
            padding: 15px 20px;
            border-radius: 20px;
            margin: 10px 0;
            max-width: 80%;
            word-wrap: break-word;
        }
        
        .user-message {
            background: linear-gradient(135deg, #667eea, #764ba2);
            margin-left: auto;
            text-align: right;
            border-bottom-right-radius: 5px;
        }
        
        .ai-message {
            background: linear-gradient(135deg, #2ecc71, #27ae60);
            margin-right: auto;
            text-align: left;
            border-bottom-left-radius: 5px;
        }
        
        .ai-message.ayano {
            background: linear-gradient(135deg, #ff6b6b, #ee5a24);
        }
        
        .ai-message.lazyingart {
            background: linear-gradient(135deg, #3742fa, #2f3542);
        }
        
        .message-timestamp {
            font-size: 0.8em;
            opacity: 0.7;
            margin-top: 5px;
        }
        
        .voice-indicator {
            font-size: 0.7em;
            opacity: 0.8;
            margin-top: 3px;
            font-style: italic;
        }
        
        .ai-thinking {
            background: linear-gradient(135deg, #f39c12, #e67e22);
            margin-right: auto;
            text-align: left;
            border-bottom-left-radius: 5px;
            animation: thinking 1.5s infinite;
        }
        
        @keyframes thinking {
            0%, 100% { opacity: 0.7; }
            50% { opacity: 1; }
        }
        
        .audio-controls {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 10px;
        }
        
        .play-button {
            background: linear-gradient(45deg, #2ecc71, #27ae60);
            border: none;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            color: white;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s ease;
        }
        
        .play-button:hover {
            transform: scale(1.1);
        }
        
        .play-button.playing {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            animation: playing 1s infinite;
        }
        
        .stop-audio-button {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            border: none;
            border-radius: 5px;
            padding: 5px 10px;
            color: white;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s ease;
        }
        
        .stop-audio-button:hover {
            transform: scale(1.05);
        }
        
        @keyframes playing {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.1); }
        }
        
        /* DUAL LANGUAGE ENHANCEMENT STYLES */
.dual-language-enhancement {
    margin: 15px 0;
    padding: 15px;
    background: rgba(var(--enh-card-bg-rgb, 15, 23, 42), var(--enh-card-bg-alpha, 0.92));
    border-radius: 10px;
    border: 1px solid var(--enh-card-border, rgba(148, 163, 184, 0.38));
    font-size: 0.9em;
    color: #f8fafc;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.32);
}

.language-sections {
  display: grid;
  grid-template-columns: repeat(var(--enh-cols, 2), 1fr);
  gap: 15px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.language-section {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--enh-card-border, rgba(148, 163, 184, 0.38));
  min-width: 0;
  overflow-wrap: break-word;
  background: rgba(var(--enh-section-bg-rgb, 30, 41, 59), var(--enh-section-bg-alpha, 0.9));
  color: #f8fafc;
  display: flex;
  flex-direction: column;
}

        @media (max-width: 768px) {
            .language-sections {
                grid-template-columns: 1fr;
            }
        }
        
.english-text, .furigana-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-width: 100%;
}

/* Make language content flex to push controls to the bottom for uniform alignment */
.english-content,
.japanese-content,
.chinese-content,
.cantonese-content {
  flex: 1 1 auto;
}

/* Footer container holding audio + per-language controls, kept outside content */
.section-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

        .dual-language-enhancement {
            width: 100%;
            max-width: 100%;
            overflow: hidden;
        }
        
        /* Enhancement sections: neutral subtle backgrounds for better contrast */
        .english-section,
        .japanese-section,
        .korean-section,
        .cantonese-section,
        .chinese-section {
            background: rgba(var(--enh-section-bg-rgb, 30, 41, 59), var(--enh-section-bg-alpha, 0.9));
            border-color: rgba(148, 163, 184, 0.35);
        }
        
        .language-header {
            font-weight: bold;
            margin-bottom: 8px;
            padding: 5px 0;
            border-bottom: 1px solid rgba(148, 163, 184, 0.25);
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: #dbeafe;
        }
        
        .english-header { color: #1e88e5; }
        
        .japanese-header { color: #e53935; }
        .korean-header { color: #2e7d32; }
        
        /* Chinese section header accents */
        .chinese-header { color: #f9a825; }
        .chinese-codes {
            color: #fde68a;
            background: rgba(148, 163, 184, 0.18);
            padding: 2px 6px;
            border-radius: 3px;
            border: 1px solid rgba(148, 163, 184, 0.32);
        }
        .korean-codes {
            color: #bbf7d0;
            background: rgba(148, 163, 184, 0.18);
            padding: 2px 6px;
            border-radius: 3px;
            border: 1px solid rgba(148, 163, 184, 0.32);
        }
        
        .language-codes {
            font-size: 0.8em;
            opacity: 0.9;
        }
        
        .english-codes {
            color: #bfdbfe;
            background: rgba(148, 163, 184, 0.18);
            padding: 2px 6px;
            border-radius: 3px;
            border: 1px solid rgba(148, 163, 184, 0.32);
        }
        
        .japanese-codes {
            color: #fda4af;
            background: rgba(148, 163, 184, 0.18);
            padding: 2px 6px;
            border-radius: 3px;
            border: 1px solid rgba(148, 163, 184, 0.32);
        }
        
        .original-text {
            margin: 8px 0;
            padding: 8px;
            background: rgba(15, 23, 42, 0.72);
            border-radius: 5px;
            border-left: 3px solid rgba(96, 165, 250, 0.75);
            font-size: 0.9em;
            opacity: 0.95;
            color: #e2e8f0;
        }
        
        .english-text {
            font-size: calc(var(--en-main-size, 1.25) * 1rem);
            line-height: 1.8;
            padding: 10px;
            background: rgba(30, 41, 59, 0.65);
            border-radius: 8px;
            border: 1px solid rgba(148, 163, 184, 0.3);
            font-family: 'Georgia', 'Times New Roman', serif;
            color: #f8fafc;
        }
        
        .english-text span {
            cursor: help;
            transition: all 0.2s ease;
            padding: 1px 2px;
            border-radius: 2px;
        }
        
        .english-text span:hover {
            background: rgba(148, 163, 184, 0.25);
            transform: scale(1.05);
        }
        
        .furigana-text {
            font-size: calc(var(--ja-main-size, 1.10) * 1rem);
            line-height: 1.8;
            padding: 10px;
            background: rgba(30, 41, 59, 0.65);
            border-radius: 8px;
            border: 1px solid rgba(148, 163, 184, 0.3);
            font-family: 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
            color: #f8fafc;
        }
        
        .furigana-text ruby {
            ruby-align: center;
        }

        .furigana-text rt {
            font-size: calc(var(--ja-ruby-size, 0.70) * 1em);
            opacity: 0.9;
        }

        /* Cantonese ruby styling */
        .cantonese-ruby { line-height: 1.9; font-size: calc(var(--yue-main-size, 1.10) * 1rem); }
        .cantonese-ruby ruby {
            ruby-align: center;
            margin: 0 0.08em; /* add slight spacing between annotated units */
        }
        .cantonese-ruby rt {
            font-size: calc(var(--yue-ruby-size, 0.90) * 1em);   /* Jyutping size */
            opacity: 0.95;
            padding: 0 0.12em;  /* horizontal breathing room per token */
            letter-spacing: 0.02em;
            white-space: nowrap;
        }

        /* Chinese ruby styling */
        .chinese-ruby { line-height: 2.35; font-size: calc(var(--zh-main-size, 1.10) * 1rem); }
        .chinese-ruby ruby { ruby-align: center; margin: 0 0.22em; }
        .chinese-ruby rt {
            font-size: calc(var(--zh-ruby-size, 1.10) * 1em);  /* Pinyin size */
            opacity: 0.97;
            padding: 0 0.22em; /* more spacing per token */
            letter-spacing: 0.08em; /* more airy look */
            white-space: nowrap;
        }

        /* Korean ruby styling */
        .korean-ruby { line-height: 1.9; font-size: calc(var(--ko-main-size, 1.10) * 1rem); }
        .korean-ruby ruby { ruby-align: center; margin: 0 0.12em; }
        .korean-ruby rt { font-size: calc(var(--ko-ruby-size, 0.95) * 1em); opacity: 0.95; padding: 0 0.12em; white-space: nowrap; }

        /* Fallback when no ruby provided: plain text blocks */
        .chinese-text { font-size: calc(var(--zh-main-size, 1.10) * 1rem); }
        .korean-text { font-size: calc(var(--ko-main-size, 1.10) * 1rem); }
        .cantonese-text { font-size: calc(var(--yue-main-size, 1.10) * 1rem); }
        /* POS-based palette for Chinese (applies to base + pinyin) */
        .chinese-ruby ruby.zhpos-noun, .chinese-ruby ruby.zhpos-noun rt { color: #42a5f5; }
        .chinese-ruby ruby.zhpos-verb, .chinese-ruby ruby.zhpos-verb rt { color: #66bb6a; }
        .chinese-ruby ruby.zhpos-adj, .chinese-ruby ruby.zhpos-adj rt { color: #ef5350; }
        .chinese-ruby ruby.zhpos-adv, .chinese-ruby ruby.zhpos-adv rt { color: #ab47bc; }
        .chinese-ruby ruby.zhpos-num, .chinese-ruby ruby.zhpos-num rt { color: #26c6da; }
        .chinese-ruby ruby.zhpos-measure, .chinese-ruby ruby.zhpos-measure rt { color: #8d6e63; }
        .chinese-ruby ruby.zhpos-pron, .chinese-ruby ruby.zhpos-pron rt { color: #ffa726; }
        .chinese-ruby ruby.zhpos-prep, .chinese-ruby ruby.zhpos-prep rt { color: #9ccc65; }
        .chinese-ruby ruby.zhpos-conj, .chinese-ruby ruby.zhpos-conj rt { color: #26a69a; }
        .chinese-ruby ruby.zhpos-part, .chinese-ruby ruby.zhpos-part rt { color: #5c6bc0; }
        .chinese-ruby ruby.zhpos-interj, .chinese-ruby ruby.zhpos-interj rt { color: #f06292; }
        .chinese-ruby ruby.zhpos-other, .chinese-ruby ruby.zhpos-other rt { color: #bdbdbd; }
        /* Simple rotating palette for Chinese characters */
        .chinese-ruby ruby.zhc0, .chinese-ruby ruby.zhc0 rt { color: #ff8a65; }
        .chinese-ruby ruby.zhc1, .chinese-ruby ruby.zhc1 rt { color: #4dd0e1; }
        .chinese-ruby ruby.zhc2, .chinese-ruby ruby.zhc2 rt { color: #81c784; }
        .chinese-ruby ruby.zhc3, .chinese-ruby ruby.zhc3 rt { color: #ba68c8; }
        .chinese-ruby ruby.zhc4, .chinese-ruby ruby.zhc4 rt { color: #9575cd; }
        .chinese-ruby ruby.zhc5, .chinese-ruby ruby.zhc5 rt { color: #f06292; }

        /* POS-based simple palette for Korean */
        .korean-ruby ruby.kopos-noun, .korean-ruby ruby.kopos-noun rt { color: #42a5f5; }
        .korean-ruby ruby.kopos-verb, .korean-ruby ruby.kopos-verb rt { color: #66bb6a; }
        .korean-ruby ruby.kopos-adj, .korean-ruby ruby.kopos-adj rt { color: #ef5350; }
        .korean-ruby ruby.kopos-adv, .korean-ruby ruby.kopos-adv rt { color: #ab47bc; }
        .korean-ruby ruby.kopos-pron, .korean-ruby ruby.kopos-pron rt { color: #ffa726; }
        .korean-ruby ruby.kopos-prep, .korean-ruby ruby.kopos-prep rt { color: #9ccc65; }
        .korean-ruby ruby.kopos-conj, .korean-ruby ruby.kopos-conj rt { color: #26a69a; }
        .korean-ruby ruby.kopos-part, .korean-ruby ruby.kopos-part rt { color: #5c6bc0; }
        .korean-ruby ruby.kopos-num, .korean-ruby ruby.kopos-num rt { color: #26c6da; }
        .korean-ruby ruby.kopos-measure, .korean-ruby ruby.kopos-measure rt { color: #8d6e63; }
        .korean-ruby ruby.kopos-interj, .korean-ruby ruby.kopos-interj rt { color: #f06292; }
        .korean-ruby ruby.kopos-punc, .korean-ruby ruby.kopos-punc rt { color: #bdbdbd; }
        .korean-ruby ruby.kopos-other, .korean-ruby ruby.kopos-other rt { color: #90a4ae; }

        /* Posts page: apply Korean POS colors without requiring .korean-ruby wrapper */
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-noun,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-noun rt { color: #42a5f5; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-verb,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-verb rt { color: #66bb6a; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-adj,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-adj rt { color: #ef5350; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-adv,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-adv rt { color: #ab47bc; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-pron,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-pron rt { color: #ffa726; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-prep,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-prep rt { color: #9ccc65; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-conj,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-conj rt { color: #26a69a; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-part,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-part rt { color: #5c6bc0; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-num,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-num rt { color: #26c6da; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-measure,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-measure rt { color: #8d6e63; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-interj,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-interj rt { color: #f06292; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-punc,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-punc rt { color: #bdbdbd; }
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-other,
        .post-enh-grid .enhancement-card[data-type="korean"] .enhancement-content ruby.kopos-other rt { color: #90a4ae; }

        /* Posts page: ensure Arabic ruby pronunciation matches token color */
        .post-enh-grid .enhancement-card[data-type="arabic"] .enhancement-content .lang-token {
          color: var(--pos-color);
        }
        .post-enh-grid .enhancement-card[data-type="arabic"] .enhancement-content .lang-token rt {
          color: currentColor; /* inherit from token color */
        }
        
        .non-enhanced-content {
            color: #ffa726;
            font-style: italic;
            opacity: 0.8;
            text-align: center;
            padding: 10px;
            border-radius: 5px;
            font-size: 0.9em;
        }
        
        .english-non-enhanced {
            background: rgba(66, 165, 245, 0.1);
            border: 1px solid rgba(66, 165, 245, 0.3);
        }
        
        .japanese-non-enhanced {
            background: rgba(255, 167, 38, 0.1);
            border: 1px solid rgba(255, 167, 38, 0.3);
        }

        .cantonese-non-enhanced {
            background: rgba(0, 230, 118, 0.1);
            border: 1px solid rgba(0, 230, 118, 0.3);
        }

        .korean-non-enhanced {
            background: rgba(46, 125, 50, 0.1);
            border: 1px solid rgba(46, 125, 50, 0.3);
        }
        
        .language-processing {
            color: #f39c12;
            font-style: italic;
            opacity: 0.8;
            text-align: center;
            padding: 8px;
            font-size: 0.9em;
        }
        
        .language-error {
            color: #e74c3c;
            font-style: italic;
            opacity: 0.8;
            text-align: center;
            padding: 8px;
            font-size: 0.9em;
        }
        
        .processing-time {
            font-size: 0.7em;
            opacity: 0.8;
            margin-top: 5px;
            text-align: right;
            color: #6b7280; /* Muted gray on light background */
        }

        /* Left-align enhancement contents for user-side messages */
        .conversation-item.user-item .english-content,
        .conversation-item.user-item .japanese-content,
        .conversation-item.user-item .cantonese-content,
        .conversation-item.user-item .chinese-content,
        .conversation-item.user-item .language-section,
        .conversation-item.user-item .dual-language-enhancement {
            text-align: left;
        }

        /* Left-align processing time inside user enhancements */
        .conversation-item.user-item .processing-time { 
            text-align: left; 
        }

        /* Change password row (responsive) */
        .change-password-row { display:flex; gap: 8px; align-items: center; flex-wrap: wrap; }
        .change-password-row input { flex: 1 1 220px; min-width: 160px; padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.1); color: #fff; }
        .change-password-row .control-button { flex: 0 0 auto; }
        .password-hint { display:block; opacity: 0.85; margin-top: 6px; }
        
.dual-language-loading {
    color: #f39c12;
    font-style: italic;
    opacity: 0.8;
    text-align: center;
    padding: 15px;
    font-size: 0.9em;
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: 8px;
}

/* Per-language controls (prev | 1/1 | next | refetch | voice | delete) */
.lang-controls {
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin-top: 6px;
}
.lang-controls .lang-prev,
.lang-controls .lang-next,
.lang-controls .lang-refetch,
.lang-controls .lang-voice,
.lang-controls .lang-delete {
    margin: 0;
}
.language-header .lang-voice {
    margin-left: 6px;
    padding: 2px 6px;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 6px;
    background: rgba(0,0,0,0.04);
    cursor: pointer;
    font-size: 12px;
}
.language-header .lang-voice:hover {
    background: rgba(0,0,0,0.08);
}
.lang-controls .lang-version {
    margin: 0;
    padding: 0 2px;
    font-size: 0.85em;
    opacity: 0.8;
    user-select: none;
}
        
        .enhancement-controls {
            text-align: center;
            margin: 10px 0;
            font-size: 0.8em;
            opacity: 0.8;
        }
        
        .no-conversations {
            text-align: center;
            font-size: 1.2em;
            opacity: 0.7;
            padding: 50px 20px;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .scrollbar-custom::-webkit-scrollbar {
            width: 8px;
        }
        
        .scrollbar-custom::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
        }
        
        .scrollbar-custom::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.3);
            border-radius: 10px;
        }
        
        .scrollbar-custom::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.5);
        }

        /* Enhancement Audio Controls */
        .enhancement-audio-controls {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 12px;
            padding: 8px;
            background: rgba(0, 0, 0, 0.05);
            border-radius: 6px;
            border: 1px solid rgba(0, 0, 0, 0.10);
            font-size: 0.8em;
        }

        .enhancement-play {
            background: linear-gradient(45deg, #2ecc71, #27ae60);
            border: none;
            border-radius: 18px;
            width: 36px;
            height: 36px;
            color: white;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .enhancement-play:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
        }

        .enhancement-play.playing {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            animation: enhancementPlaying 1s infinite;
            transform: scale(1.05);
        }

        .enhancement-audio-controls .stop-audio-button {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            border: none;
            border-radius: 4px;
            padding: 4px 8px;
            color: white;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
            min-width: 40px;
        }

        .enhancement-audio-controls .stop-audio-button:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
        }

        .enhancement-audio-controls .audio-status {
            font-size: 0.85em;
            opacity: 0.9;
            color: #e2e8f0;
            flex: 1;
            text-align: left;
        }

        @keyframes enhancementPlaying {
            0%, 100% { 
                transform: scale(1.05); 
                box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            }
            50% { 
                transform: scale(1.1); 
                box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
            }
        }

        /* Japanese Enhancement Audio - specific colors */
        .japanese-section .enhancement-play {
            background: linear-gradient(45deg, #ff6b6b, #ee5a24);
        }

        .japanese-section .enhancement-play:hover {
            box-shadow: 0 4px 8px rgba(255, 107, 107, 0.4);
        }

        .japanese-section .enhancement-play.playing {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            box-shadow: 0 6px 12px rgba(255, 107, 107, 0.5);
        }

        /* English Enhancement Audio - specific colors */
        .english-section .enhancement-play {
            background: linear-gradient(45deg, #42a5f5, #2196f3);
        }

        .english-section .enhancement-play:hover {
            box-shadow: 0 4px 8px rgba(66, 165, 245, 0.4);
        }

        .english-section .enhancement-play.playing {
            background: linear-gradient(45deg, #1976d2, #1565c0);
            box-shadow: 0 6px 12px rgba(66, 165, 245, 0.5);
        }

        /* Cantonese Enhancement Audio - specific colors */
        .cantonese-section .enhancement-play {
            background: linear-gradient(45deg, #00e676, #00c853);
        }

        .cantonese-section .enhancement-play:hover {
            box-shadow: 0 4px 8px rgba(0, 230, 118, 0.4);
        }

        .cantonese-section .enhancement-play.playing {
            background: linear-gradient(45deg, #00c853, #00bfa5);
            box-shadow: 0 6px 12px rgba(0, 230, 118, 0.5);
        }

        /* Korean Enhancement Audio - specific colors */
        .korean-section .enhancement-play { background: linear-gradient(45deg, #2e7d32, #1b5e20); }
        .korean-section .enhancement-play:hover { box-shadow: 0 4px 8px rgba(46, 125, 50, 0.4); }
        .korean-section .enhancement-play.playing { background: linear-gradient(45deg, #1b5e20, #2e7d32); box-shadow: 0 6px 12px rgba(46,125,50,0.5); }

        /* Enhancement audio controls responsive design */
        @media (max-width: 768px) {
            .enhancement-audio-controls {
                flex-direction: column;
                align-items: stretch;
                gap: 6px;
            }
            
            .enhancement-play {
                width: 100%;
                height: 32px;
                border-radius: 8px;
            }
            
            .enhancement-audio-controls .stop-audio-button {
                width: 100%;
                padding: 6px 12px;
                border-radius: 6px;
            }
            
            .enhancement-audio-controls .audio-status {
                text-align: center;
                padding: 4px;
            }
        }

        /* Update existing dual-language-enhancement styles to accommodate audio controls */
        .dual-language-enhancement {
            margin: 15px 0;
            padding: 15px;
            background: rgba(var(--enh-card-bg-rgb, 255,255,255), var(--enh-card-bg-alpha, 1));
            border-radius: 10px;
            border: 1px solid var(--enh-card-border, rgba(148, 163, 184, 0.38));
            font-size: 0.9em;
            overflow: hidden; /* Prevent audio controls from breaking layout */
            color: #f8fafc;
            box-shadow: 0 10px 24px rgba(15, 23, 42, 0.32);
        }

        .language-section {
            padding: 12px;
            border-radius: 8px;
            border: 1px solid rgba(0, 0, 0, 0.12);
            min-width: 0;
            overflow-wrap: break-word;
            min-height: 120px; /* Ensure space for audio controls */
            background: rgba(var(--enh-section-bg-rgb, 30, 41, 59), var(--enh-section-bg-alpha, 0.9));
            color: #f8fafc;
            display: flex;
            flex-direction: column;
        }

        /* Add these CSS styles to your HTML template for user audio controls: */

        /* User Audio Controls - Similar to AI but with different styling */
        .user-audio-controls {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 10px;
            padding: 8px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            font-size: 0.85em;
        }

        .user-play {
            background: linear-gradient(45deg, #667eea, #764ba2);
            border: none;
            border-radius: 50%;
            width: 32px;
            height: 32px;
            color: white;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .user-play:hover {
            transform: scale(1.1);
            box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
        }

        .user-play.playing {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            animation: userPlaying 1s infinite;
        }

        @keyframes userPlaying {
            0%, 100% { 
                transform: scale(1.1); 
                opacity: 1; 
            }
            50% { 
                transform: scale(1.2); 
                opacity: 0.8; 
            }
        }

        .user-audio-controls .stop-audio-button {
            background: linear-gradient(45deg, #e74c3c, #c0392b);
            border: none;
            border-radius: 5px;
            padding: 4px 8px;
            color: white;
            cursor: pointer;
            font-size: 11px;
            transition: all 0.3s ease;
            min-width: 35px;
        }

        .user-audio-controls .stop-audio-button:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
        }

        .user-audio-controls .audio-status {
            font-size: 0.8em;
            opacity: 0.8;
            color: #b4a7d6; /* Lighter purple to match user message theme */
            flex: 1;
        }

        /* User message styling enhancements */
        .user-message {
            position: relative;
        }

        .user-item {
            /* Ensure user items have proper spacing */
            margin: 15px 0;
        }

        /* Different audio status colors for user vs AI */
        .user-audio-controls .audio-status {
            color: #b4a7d6; /* Purple tint for user */
        }

        .audio-controls .audio-status {
            color: #90caf9; /* Blue tint for AI */
            flex: 1; /* Push trailing controls (e.g., refetch) to right */
        }

        /* Blue refetch button (avoid red) */
        .refetch-button {
            background: linear-gradient(45deg, #00b0ff, #1976d2);
            border: none;
            border-radius: 8px;
            padding: 6px 12px;
            color: white;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.2s ease;
            min-width: 38px;
            margin-left: 8px;
        }
        .refetch-button:hover {
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(0, 176, 255, 0.45);
        }

        /* Responsive design for user audio controls */
        @media (max-width: 768px) {
            .user-audio-controls {
                padding: 6px;
                gap: 8px;
            }
            
            .user-play {
                width: 28px;
                height: 28px;
                font-size: 12px;
            }
            
            .user-audio-controls .stop-audio-button {
                padding: 3px 6px;
                font-size: 10px;
            }
            
            .user-audio-controls .audio-status {
                font-size: 0.75em;
            }
        }

        /* Loading state for user audio */
        .user-audio-controls .audio-status.loading {
            color: #f39c12;
            animation: pulse 1.5s infinite;
        }

        .user-audio-controls .audio-status.ready {
            color: #2ecc71;
        }

        .user-audio-controls .audio-status.error {
            color: #e74c3c;
        }

        /* Visual distinction between different audio types */
        .conversation-item .audio-controls {
            border-left: 3px solid #42a5f5; /* Blue for AI */
        }

        .conversation-item .user-audio-controls {
            border-left: 3px solid #667eea; /* Purple for User */
        }

        .conversation-item .enhancement-audio-controls {
            border-left: 3px solid #ffa726; /* Orange for Enhancements */
        }

        /* Hover effects for all audio control containers */
        .audio-controls:hover,
        .user-audio-controls:hover,
        .enhancement-audio-controls:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        /* Settings */
        .settings-controls {
            background: rgba(255, 255, 255, 0.1);
            padding: 15px;
            border-radius: 10px;
            margin: 20px 0;
            text-align: center;
        }

        .settings-controls h4 {
            margin: 0 0 15px 0;
            color: #ffa726;
        }

        .settings-buttons {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
            margin-bottom: 15px;
        }

        .settings-btn {
            background: linear-gradient(45deg, #42a5f5, #2196f3) !important;
            min-width: 140px;
        }

        .settings-btn:hover {
            background: linear-gradient(45deg, #1976d2, #1565c0) !important;
        }

        /* Enhancement Customizer (bottom of chat tab) */
        .enhancement-customizer {
            margin-top: 16px;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 12px;
            padding: 16px;
        }
        .enhancement-customizer h4 { margin: 0 0 12px 0; color: #ffd166; }
        .enh-row { display: flex; gap: 16px; flex-wrap: wrap; }
        .enh-col { flex: 1 1 280px; }
        .enh-group { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 12px; }
        .enh-inline { display: flex; align-items: center; gap: 16px; margin: 8px 0; }
        .enh-opacity { display: flex; align-items: center; gap: 8px; }
        #enhSectionBgColor, #enhCardBgColor { width: 44px; height: 32px; border: none; background: none; padding: 0; }
        #enhSectionBgOpacity, #enhCardBgOpacity { width: 160px; }
        #enhSectionBgOpacityValue, #enhCardBgOpacityValue { min-width: 38px; display: inline-block; text-align: right; }
        .enh-font-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
        .enh-font-item { background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px; padding: 10px; }
        .enh-font-title { font-weight: bold; margin-bottom: 6px; color: #a5d6a7; }
        .enh-font-item label { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin: 6px 0; }
        .enh-font-item input[type="range"] { width: 160px; }

        /* Conversation header actions */
        .conv-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; }
        .conv-header h3 { margin: 0; white-space: nowrap; }
        .conv-actions { display: inline-flex; align-items: center; gap: 8px; justify-self: end; }
        .conv-status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 0.9rem; background: rgba(148, 163, 184, 0.18); border: 1px solid rgba(148, 163, 184, 0.28); color: #e2e8f0; transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease; justify-self: center; }
        @media (max-width: 780px) {
            .conv-header { grid-template-columns: minmax(0,1fr); row-gap: 12px; justify-items: center; text-align: center; }
            .conv-actions { justify-self: center; }
            .conv-status-badge { justify-self: center; }
        }
        .conv-status-badge.monitoring { background: rgba(243, 156, 18, 0.2); border-color: rgba(243, 156, 18, 0.45); color: #fbbf24; }
        .conv-status-badge.recording { background: rgba(220, 38, 38, 0.22); border-color: rgba(248, 113, 113, 0.45); color: #fca5a5; }
        .conv-status-badge.processing { background: rgba(59, 130, 246, 0.18); border-color: rgba(96, 165, 250, 0.4); color: #93c5fd; }
        .conv-status-badge.playing { background: rgba(16, 185, 129, 0.2); border-color: rgba(52, 211, 153, 0.45); color: #6ee7b7; }
        .conv-status-badge.stopped { background: rgba(148, 163, 184, 0.18); border-color: rgba(148, 163, 184, 0.28); color: #e2e8f0; }
        @media (max-width: 680px) {
            .conv-heading { width: 100%; }
            .conv-actions { width: 100%; justify-content: flex-end; }
            .conv-status-badge { margin-top: 2px; }
        }

        .auto-save-control {
            border-top: 1px solid rgba(255, 255, 255, 0.2);
            padding-top: 12px;
            margin-top: 12px;
        }

        .auto-save-control label {
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            margin-bottom: 5px;
        }

        .auto-save-control small {
            opacity: 0.8;
            font-size: 12px;
        }

        /* Overrides for main message visuals */
        .ai-message {
            position: relative;
            margin-left: 40px; /* room for avatar */
        }

        .ai-message .audio-controls {
            justify-content: flex-start; /* left align play/stop like before */
        }

        .ai-message::before {
            content: '🤖';
            position: absolute;
            left: -40px;
            top: 12px;
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: rgba(255,255,255,0.15);
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
            font-size: 16px;
        }

        /* Remove robot icon for friend DMs and swap colors in DM area */
        #dmMessages .ai-message::before { content: none; }
        #dmMessages .user-message { background: linear-gradient(135deg, #2ecc71, #27ae60); }
        #dmMessages .ai-message   { background: linear-gradient(135deg, #667eea, #764ba2); }

        /* Group chat bubbles: mirror DM feel, drop robot badge */
        #groupMessages .ai-message::before { content: none; }
        #groupMessages .user-message { background: linear-gradient(135deg, #2ecc71, #27ae60); color: #fff; }
        #groupMessages .ai-message { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; }
        [data-theme="dark"] #groupMessages .ai-message { background: linear-gradient(135deg, #5761d7, #6a46c1); color: #fff; }
        #groupMessages .dm-line .user-message,
        #groupMessages .dm-line .ai-message { margin-left: 0 !important; margin-right: 0 !important; }
        #groupMessages .dm-meta { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; opacity: 0.85; color: rgba(0,0,0,0.65); }
        #groupMessages .user-message .dm-meta { color: rgba(255,255,255,0.92); opacity: 1; }
        #groupMessages .ai-message .dm-meta { color: rgba(255,255,255,0.92); }
        [data-theme="dark"] #groupMessages .dm-meta { color: rgba(255,255,255,0.82); }

        /* Centered toolbar for DM */
        .dm-toolbar { display:flex; justify-content:center; margin-bottom:8px; }

        /* DM font controls */
        .dm-fonts { margin-top: 12px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); padding: 10px; border-radius: 8px; }
        .dm-font-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
        .dm-font-grid label { display:block; font-size: 12px; }
        .dm-fonts .enh-font-title { font-weight: 600; margin-bottom: 4px; }
        .chat-palette-panel { display: none; margin-top: 18px; padding: 14px; background: rgba(15,23,42,0.12); border: 1px solid rgba(148,163,184,0.25); border-radius: 12px; }
        .chat-palette-panel.is-open { display: block; }
        .chat-palette-panel > .setting-group { margin-top: 0; }

        /* DM-specific font variable overrides */
        #dmMessages {
            /* Avoid self-referential var() cycles for Safari/iOS. 
               Fall back to concrete defaults instead of var(--en-main-size) etc. */
            --en-main-size: var(--dm-en-main-size, 1.25);
            --ja-main-size: var(--dm-ja-main-size, 1.10);
            --ja-ruby-size: var(--dm-ja-ruby-size, 0.70);
            --zh-main-size: var(--dm-zh-main-size, 1.10);
            --zh-ruby-size: var(--dm-zh-ruby-size, 0.90);
            --yue-main-size: var(--dm-yue-main-size, 1.10);
            --yue-ruby-size: var(--dm-yue-ruby-size, 0.90);
        }

        #groupMessages {
            --en-main-size: var(--dm-en-main-size, 1.25);
            --ja-main-size: var(--dm-ja-main-size, 1.10);
            --ja-ruby-size: var(--dm-ja-ruby-size, 0.70);
            --zh-main-size: var(--dm-zh-main-size, 1.10);
            --zh-ruby-size: var(--dm-zh-ruby-size, 0.90);
            --yue-main-size: var(--dm-yue-main-size, 1.10);
            --yue-ruby-size: var(--dm-yue-ruby-size, 0.90);
        }

        /* Groups: make conversation area fill between header and composer (mirror DM layout) */
        #tab-groups .conversation-area {
            margin-top: 0 !important;
            display: flex;
            flex-direction: column;
            min-height: 0;
        }
        #tab-groups #groupMessages.conversation-list {
            flex: 1 1 auto;
            min-height: 0;
            max-height: none;
            overflow-y: auto;
            /* Lighter padding to reduce perceived gap */
            padding: 16px;
            margin: 0;
        }
        /* Friends: match groups height behavior on desktop */
        #tab-friends .conversation-area {
            margin-top: 0 !important;
            display: flex;
            flex-direction: column;
            min-height: 0;
        }
        #tab-friends #dmMessages.conversation-list {
            flex: 1 1 auto;
            min-height: 0;
            max-height: none;
            overflow-y: auto;
        }
        #tab-groups #groupMessages .conversation-item:first-of-type { margin-top: 0; }
        #tab-groups #groupMessages .conversation-item:last-of-type { margin-bottom: 0; }

        /* Desktop: bring back scrollable panel for Group conversation list */
        @media (min-width: 900px) {
          #tab-groups #groupMessages.conversation-list {
            max-height: 65vh; /* re-enable scrolling on desktop */
            overflow-y: auto;
          }
          #tab-friends #dmMessages.conversation-list {
            max-height: 65vh; /* larger height but still scrollable */
            overflow-y: auto;
          }
        }

        /* Responsive: DM Fonts collapse on mobile */
        @media (max-width: 900px) {
          .dm-font-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        }
        @media (max-width: 600px) {
          .dm-font-grid { grid-template-columns: 1fr; }
        }

/* Friends columns wrap on small screens */
.friends-columns { flex-wrap: wrap; }
@media (max-width: 900px) {
  .friends-columns > div { flex: 1 1 100%; }
}

/* Friends panel fold */
.friends-panel-bar { display:flex; justify-content: space-between; align-items:center; gap:8px; }
/* Collapsed state hides body using class (Safari-friendly) */
#friendsPanel.collapsed #friendsPanelBody { display: none !important; }
@media (max-width: 700px) {
  /* Default fold on mobile via class set by JS */
}

/* Groups UI */
.group-avatar-logo {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
}

.group-avatar-grid {
  display: grid;
  gap: 2px;
  width: 36px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.12);
}

.group-avatar-grid.grid-2x2 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  height: 36px;
}

.group-avatar-grid.grid-3x3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  height: 36px;
}

.group-avatar-cell {
  display: block;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.18);
}

.group-avatar-cell.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.groups-columns {
  display:flex;
  flex-wrap:wrap;
  gap:20px;
  align-items:stretch;
}
.group-list-column,
.group-info-column {
  flex:1 1 0;
  min-width:260px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.group-list-header-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.group-height-control {
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  opacity:0.85;
}
.group-height-control select {
  background:rgba(0,0,0,0.35);
  border:1px solid rgba(255,255,255,0.25);
  border-radius:8px;
  color:#fff;
  padding:2px 6px;
  font-size:12px;
}
.group-height-control label {
  font-weight:600;
}
.group-list-scroll {
  flex:1 1 auto;
  min-height:0;
  height:440px;
  overflow-y:auto;
  border:1px solid rgba(255,255,255,0.07);
  border-radius:12px;
  background:rgba(0,0,0,0.18);
}
.group-info-shell {
  flex:1 1 auto;
  min-height:0;
  height:440px;
  overflow-y:auto;
  border:1px solid rgba(255,255,255,0.07);
  border-radius:12px;
  background:rgba(0,0,0,0.18);
  padding:6px;
}
.group-info-shell.collapsed {
  display:none;
}
.group-info { min-height:160px; }

@media (max-width: 1024px) {
  .group-list-scroll,
  .group-info-shell {
    height: auto;
    max-height: 440px;
  }
}

.group-list-item {
  padding:0;
}
.group-item-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border: 1px solid transparent; /* avoid layout shift when selected adds border */
  border-radius: 10px;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.group-item-left {
  display:flex;
  align-items:center;
  gap:10px;
  flex:1 1 auto;
  min-width:0;
}
.group-item-text {
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width:0;
}
.group-item-actions {
  display:flex;
  align-items:center;
  gap:8px;
}
.group-item-actions .badge {
  background: #e53935;
  color: #fff;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(229,57,53,0.4);
}
.group-item-name {
  font-weight:600;
  font-size:14px;
  color:#fff;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.group-item-meta {
  font-size:12px;
  opacity:0.75;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.group-list-options {
  background:transparent;
  border:none;
  color:rgba(255,255,255,0.7);
  font-size:18px;
  cursor:pointer;
  padding:4px 6px;
  border-radius:8px;
}
.group-list-options:hover,
.group-list-options:focus {
  background:rgba(255,255,255,0.08);
  color:#fff;
}
.group-list-options:focus {
  outline:2px solid rgba(255,255,255,0.2);
  outline-offset:2px;
}
.conversation-item.group-list-item.selected .group-item-row {
  background:rgba(255,255,255,0.08);
}
.group-info-close {
  background:transparent;
  border:none;
  color:rgba(255,255,255,0.7);
  font-size:18px;
  cursor:pointer;
  padding:2px 6px;
  border-radius:8px;
  margin-left:auto;
}
.group-info-close:hover,
.group-info-close:focus {
  background:rgba(255,255,255,0.08);
  color:#fff;
}
.group-info-card {
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 12px;
  line-height: 1.35;
}
.group-info-header {
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin-bottom:10px;
}
.group-info-header .group-info-meta {
  display:flex;
  flex-direction:column;
  gap:4px;
}
.group-info-name-row {
  display:flex;
  align-items:center;
  gap:8px;
}
.group-info-name { font-weight:600; font-size:15px; }
.group-info-qr {
  width:30px;
  height:30px;
  border-radius:50%;
  border:1px solid rgba(255,255,255,0.25);
  background:rgba(99,102,241,0.18);
  color:#fff;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform 0.15s ease, background 0.15s ease;
}
.group-info-qr:hover,
.group-info-qr:focus {
  background:rgba(99,102,241,0.35);
  transform:scale(1.05);
  outline:none;
}
.group-info-count { font-size:12px; opacity:0.8; }
.group-info-members {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  align-items:center;
}
.group-info-members .group-info-members-btn {
  margin-left:auto;
}
.group-settings-block {
  margin-top:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.group-setting-row {
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;
  border-radius:10px;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.07);
}
.group-pending-row {
  justify-content:space-between;
}
.group-alias-row {
  flex-wrap:wrap;
  gap:8px;
}
.group-alias-row input#groupAliasInput {
  flex:1 1 200px;
  min-width:170px;
  padding:6px 10px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.15);
  background:rgba(255,255,255,0.05);
  color:#fff;
}
.group-alias-row #groupAliasSave {
  flex:0 0 auto;
}
.group-setting-label {
  font-size:13px;
  opacity:0.9;
}
.group-setting-note {
  font-size:12px;
  opacity:0.8;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.07);
  border-radius:10px;
  padding:8px 10px;
}
.group-header-avatar {
  display:flex;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
}
button.group-header-avatar {
  background:none;
  border:none;
  padding:0;
  cursor:pointer;
}
button.group-header-avatar:focus-visible {
  outline:2px solid rgba(148,163,255,0.85);
  outline-offset:2px;
}
.group-header-avatar img.avatar-32 {
  width:36px;
  height:36px;
  border-radius:50%;
}
.group-header-avatar .group-avatar-grid {
  width:36px;
  height:36px;
  border-radius:12px;
}
.group-header-avatar .group-avatar-logo {
  width:36px;
  height:36px;
  border-radius:12px;
}
.group-info-actions {
  margin-top:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.group-actions-section {
  display:flex;
  flex-direction:column;
  gap:6px;
}
.group-actions-title {
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:0.04em;
  opacity:0.7;
}
.group-actions-row {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap:8px;
}
.group-actions-row .control-button {
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-align:center;
}
/* Danger zone styling: make Delete Group stand out */
#groupsDeleteBtn.control-button {
  background: linear-gradient(45deg, #ef5350, #e53935);
  color: #fff;
  border: none;
}
#groupsDeleteBtn.control-button:hover,
#groupsDeleteBtn.control-button:focus-visible {
  box-shadow: 0 6px 18px rgba(229,57,53,0.35);
  transform: translateY(-1px);
}
.group-request-indicator {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:18px;
  padding:2px 6px;
  border-radius:999px;
  background:#f87171;
  color:#200909;
  font-size:11px;
  font-weight:600;
  margin-left:4px;
}
.group-request-indicator.small { font-size:10px; padding:1px 5px; }
.group-item-actions { display:flex; align-items:center; gap:6px; }
.group-role-pill {
  display:inline-block;
  margin-left:8px;
  padding:2px 6px;
  font-size:11px;
  border-radius:999px;
  background:rgba(125,200,255,0.18);
  border:1px solid rgba(125,200,255,0.35);
  color:#9bd3ff;
}
.group-member-chip {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  font-size:12px;
  border-radius:999px;
  background: rgba(255,255,255,0.10);
  border:1px solid rgba(255,255,255,0.15);
}
.group-member-chip.online {
  background:rgba(34,197,94,0.18);
  border-color:rgba(34,197,94,0.45);
  color:#e7ffef;
}
.group-member-chip.offline {
  opacity:0.78;
}
.group-member-chip .presence-dot {
  width:8px;
  height:8px;
  border-radius:50%;
  display:inline-block;
  background:rgba(255,255,255,0.4);
}
.group-member-chip.online .presence-dot {
  background:#22c55e;
  box-shadow:0 0 6px rgba(34,197,94,0.6);
}
.group-member-chip.offline .presence-dot {
  background:rgba(148,163,184,0.6);
}
.group-members-more-btn {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  font-size:12px;
  background:rgba(255,255,255,0.08);
  border:1px solid rgba(255,255,255,0.18);
  color:inherit;
  cursor:pointer;
  transition:background 0.15s ease, border 0.15s ease;
}
.group-members-more-btn:hover {
  background:rgba(255,255,255,0.16);
  border-color:rgba(255,255,255,0.28);
}
.group-members-inline {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:6px;
  margin:6px 0 0;
}
.group-members-modal {
  max-height:60vh;
  overflow:auto;
  padding:12px;
}
.group-members-modal-list {
  display:flex;
  flex-direction:column;
  gap:10px;
}
.group-members-modal-item {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:10px;
  background:rgba(255,255,255,0.08);
  border:1px solid rgba(255,255,255,0.14);
}
.group-members-modal-item .member-main {
  display:flex;
  align-items:center;
  gap:12px;
  flex:1;
  min-width:0;
}
.member-avatar-wrapper {
  position:relative;
  width:38px;
  height:38px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.member-avatar-wrapper .member-avatar,
.member-avatar-wrapper .avatar-32,
.member-avatar-wrapper img {
  width:36px;
  height:36px;
  border-radius:50%;
  object-fit:cover;
}
.member-avatar-wrapper .presence-dot {
  position:absolute;
  bottom:-2px;
  right:-2px;
  width:10px;
  height:10px;
  border-radius:50%;
  border:2px solid rgba(17,24,39,0.9);
  box-shadow:0 0 6px rgba(0,0,0,0.35);
}
.group-members-modal-item.online .presence-dot {
  background:#22c55e;
  box-shadow:0 0 6px rgba(34,197,94,0.55);
}
.group-members-modal-item.offline .presence-dot {
  background:rgba(148,163,184,0.6);
}
.group-members-modal-item.online {
  border-color:rgba(34,197,94,0.45);
  background:rgba(34,197,94,0.12);
}
.member-info { display:flex; flex-direction:column; gap:2px; min-width:0; }
.member-name-line { display:flex; align-items:center; gap:6px; min-width:0; }
.member-name { font-weight:600; font-size:13px; max-width:200px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.member-handle { font-size:12px; opacity:0.7; }
.member-role { font-size:11px; padding:2px 6px; border-radius:999px; border:1px solid rgba(255,255,255,0.18); opacity:0.8; }
.member-status { font-size:11px; opacity:0.7; }
.member-actions { display:flex; align-items:center; gap:6px; }

.group-requests-modal {
  position:fixed;
  inset:0;
  padding:20px;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(10,12,28,0.88);
  /* Ensure this modal sits above any chat cards, FABs, or sticky headers */
  z-index:10010;
}
.group-requests-modal.hidden { display:none; }
.group-requests-dialog {
  position: relative;
  z-index: 10011; /* keep the card above its backdrop */
  /* Provide a solid surface so underlying cards don’t show through */
  background: rgba(23,24,54,0.96);
  border: 1px solid rgba(255,255,255,0.12);
  color: #eef;
}
.group-requests-card {
  width:420px;
  max-width:100%;
  max-height:80vh;
  display:flex;
  flex-direction:column;
  background:rgba(23,24,54,0.95);
  border:1px solid rgba(255,255,255,0.1);
  border-radius:18px;
  box-shadow:0 20px 45px rgba(0,0,0,0.45);
}
.group-requests-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:18px 20px 10px;
}
.group-requests-header h3 { margin:0; font-size:1.05rem; }

/* Explain modal rich styling */
.explain-wrap { display:flex; flex-direction:column; gap:12px; }
.explain-header { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.ex-title { font-weight:800; font-size:18px; letter-spacing:.2px; }
.ex-pron { margin-left:auto; display:flex; gap:6px; flex-wrap:wrap; }
.ex-chip { display:inline-flex; align-items:center; gap:6px; padding:4px 8px; border-radius:999px; font-weight:700; font-size:12px; background: rgba(99,102,241,0.18); border:1px solid rgba(255,255,255,0.15); }
.ex-section { border-radius:12px; padding:10px 12px; border:1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.04); }
.ex-sec-head { font-weight:800; margin-bottom:6px; opacity:.95; display:flex; align-items:center; gap:6px; }
.ex-list { margin:0; padding-left:18px; }
.ex-list li { margin:4px 0; }
.ex-vocab-list .ex-word { font-weight:800; margin-right:6px; }
.ex-vocab-list .ex-mean { opacity:.95; margin-right:6px; }
.ex-vocab-list .ex-notes { opacity:.8; font-style:italic; }
.ex-gram-item { margin-bottom:8px; }
.ex-gram-point { font-weight:800; }
.ex-gram-expl { opacity:.95; margin:2px 0 4px; }
.ex-examples { margin:4px 0 0 18px; padding:0; }
.ex-examples li { list-style: '• '; margin:2px 0; opacity:.95; }
/* Section color tints */
.ex-summary { background: linear-gradient(0deg, rgba(16,185,129,0.12), rgba(16,185,129,0.10)); border-color: rgba(16,185,129,0.28); }
.ex-vocab { background: linear-gradient(0deg, rgba(59,130,246,0.12), rgba(59,130,246,0.10)); border-color: rgba(59,130,246,0.28); }
.ex-grammar { background: linear-gradient(0deg, rgba(139,92,246,0.12), rgba(139,92,246,0.10)); border-color: rgba(139,92,246,0.28); }
.ex-usage { background: linear-gradient(0deg, rgba(245,158,11,0.12), rgba(245,158,11,0.10)); border-color: rgba(245,158,11,0.28); }
.ex-gloss { background: linear-gradient(0deg, rgba(203,213,225,0.14), rgba(203,213,225,0.10)); border-color: rgba(203,213,225,0.28); }
.group-requests-close {
  background:transparent;
  border:none;
  color:#fff;
  font-size:18px;
  cursor:pointer;
}
.group-requests-body {
  padding:0 20px 20px;
  overflow-y:auto;
}
.group-requests-list .pending-item {
  background:rgba(43,46,92,0.65);
  border:1px solid rgba(255,255,255,0.08);
}
.group-requests-list .pending-item + .pending-item { margin-top:10px; }
.group-requests-list .pending-actions button {
  padding:6px 12px;
  border-radius:8px;
  border:none;
  cursor:pointer;
  font-size:0.9rem;
}
.group-requests-list .pending-actions .approve { background:#22c55e; color:#0b1b0f; }
.group-requests-list .pending-actions .reject { background:#ef4444; color:#290808; }
.member-action { width:30px; height:30px; display:flex; align-items:center; justify-content:center; border-radius:999px; border:1px solid transparent; background:rgba(255,255,255,0.08); color:inherit; font-weight:700; font-size:16px; cursor:pointer; transition:background 0.15s ease, transform 0.15s ease; }
.member-action:hover { transform:translateY(-1px); }
.member-action:disabled { opacity:0.45; cursor:not-allowed; }
.member-action.add-friend { background:rgba(34,197,94,0.18); border-color:rgba(34,197,94,0.45); color:#bdfcc7; width:auto; min-width:40px; padding:0 8px; gap:4px; }
.member-action.add-friend .member-action-icon { display:flex; align-items:center; justify-content:center; }
.member-action.add-friend .member-action-icon svg { width:17px; height:17px; display:block; }
.member-action.add-friend .member-action-plus { font-size:16px; line-height:1; }
.member-action.remove-member { background:rgba(229,57,53,0.18); border-color:rgba(229,57,53,0.45); color:#ffbab6; }
.member-action.action-complete { background:rgba(34,197,94,0.35); border-color:rgba(34,197,94,0.55); color:#ffffff; }
.group-members {
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin:10px 0;
}
.group-header-name { font-weight:600; font-size:15px; }
.group-header-members { display:flex; flex-direction:column; gap:4px; font-size:12px; opacity:0.9; }
.group-members-summary { font-size:11px; line-height:1.3; color: rgba(255,255,255,0.72); }
.group-members-summary .summary-label { display:block; font-size:10px; text-transform:uppercase; letter-spacing:0.05em; opacity:0.65; margin-bottom:2px; }
.group-members-summary .summary-names { display:block; font-size:11px; }
.conv-actions-icons { display:flex; align-items:center; gap:8px; }
.control-button.icon-button { width:38px; height:38px; padding:0; display:flex; align-items:center; justify-content:center; font-size:18px; }
.toggle-icon-wrap { display:flex; align-items:center; gap:6px; }
.toggle-icon { font-size:18px; }
.toggle-icon-wrap .toggle-switch { margin:0; }
.group-friend-row {
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;
  border-radius:10px;
  background: rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.08);
  margin-bottom:6px;
  cursor:pointer;
  transition: background 0.15s ease;
}
.group-friend-row:hover { background: rgba(255,255,255,0.12); }
.group-friend-row input { margin:0; }
#groupColorPreview {
  display:grid;
  grid-template-columns: repeat(4, 18px);
  gap:6px;
  margin:6px 0 10px;
}
#groupColorPreview span {
  display:block;
  width:18px;
  height:18px;
  border-radius:6px;
  background: rgba(255,255,255,0.25);
}
.group-chip-hint {
  margin-left:6px;
  font-size:11px;
  opacity:0.7;
}
#groupsList .conversation-item.selected {
  background:linear-gradient(45deg, rgba(66,165,245,0.3), rgba(33,150,243,0.3));
  border-color:rgba(66,165,245,0.6);
}
.dm-handle {
  margin-left:6px;
  font-size:12px;
  opacity:0.8;
}
.dm-role-badge {
  display:inline-block;
  margin-left:6px;
  padding:2px 6px;
  font-size:11px;
  border-radius:999px;
  background:rgba(255,255,255,0.12);
  border:1px solid rgba(255,255,255,0.2);
}
.group-rename-input {
  width:100%;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.05);
  color:#fff;
}
.groups-view .conversations-list { max-height: 420px; }
.groups-chat-header {
  display:flex;
  align-items:center;
  gap:10px;
}

        /* Memory page responsive */
        @media (max-width: 800px) {
          .memory-lists { grid-template-columns: 1fr; }
        }

/* DM / Group input layout */

.dm-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  position: relative;
}

.dm-input-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.dm-input-main .control-button {
  align-self: stretch;
}

.dm-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.dm-input-wrap textarea {
  width: 100%;
  padding: 10px;
  resize: vertical;
}

.dm-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
  height: 100%;
}

@media (max-width: 900px) {
  .dm-actions {
    flex-basis: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }
  .dm-input-main {
    flex-basis: 100%;
  }
}

.conversation-settings-inline {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversation-settings-inline label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.conversation-settings-inline .range-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.conversation-settings-inline .value-display {
  font-weight: 600;
}

.conversation-settings-inline input[type="checkbox"] {
  width: auto;
}

        /* Foldable headers */
        .fold-header { cursor: pointer; user-select: none; }
        .fold-header::after { content: ' ▾'; opacity: 0.8; }
        .folded + .conversations-list { display: none; }

        /* Emoji picker */
        .emoji-picker {
            position: absolute;
            left: 0;
            bottom: 48px;
            background: rgba(0,0,0,0.85);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 10px;
            padding: 8px;
            z-index: 1000;
            display: none;
            max-width: 320px;
            max-height: 220px;
            overflow-y: auto;
            box-shadow: 0 8px 24px rgba(0,0,0,0.35);
        }
        .emoji-picker.open { display: block; }
        .emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
        .emoji-item { font-size: 22px; line-height: 28px; cursor: pointer; text-align: center; }
        .emoji-item:hover { transform: scale(1.1); }

        /* Input waveform while recording */
.dm-input-wrap { position: relative; width: 100%; }
.dm-input-wrap textarea { display:block; width: 100%; box-sizing: border-box; }
.dm-waveform {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  pointer-events: none;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  z-index: 12;
  display: none;
  background: rgba(0,0,0,0.3);
}
.dm-waveform .wave-bars {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  bottom: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2px;
}
.dm-waveform .wave-bars .waveform-bar {
  flex: 0 0 3px;
  background: linear-gradient(to top, #64b5f6, #81c784, #ffd54f);
  border-radius: 2px;
  transition: height 0.1s ease;
}

        .dm-voice-controls { display:flex; align-items:center; gap:8px; margin-top:6px; }
        .dm-voice-button { position: relative; width: 100%; height: 34px; border: none; cursor: pointer; border-radius: 10px; color: #fff; background: linear-gradient(90deg, #607d8b 0%, #455a64 100%); overflow: hidden; display:flex; align-items:center; gap:8px; padding: 0 10px; }
        .dm-voice-button .voice-icon { z-index:2; }
        .dm-voice-button .voice-label { z-index:2; font-size: 13px; opacity: 0.95; }
        .dm-voice-button .voice-progress { position:absolute; left:0; top:0; bottom:0; width:0%; background: linear-gradient(90deg, rgba(33,150,243,0.5), rgba(3,169,244,0.7)); z-index:1; transition: width 0.15s linear; }
        .dm-voice-button.playing { background: linear-gradient(90deg, #0277bd 0%, #01579b 100%); }
        .dm-voice-confirm { display:flex; gap:8px; margin-top:6px; }
        .btn-cancel { background: linear-gradient(45deg, #e53935, #c62828); border:none; color:#fff; border-radius: 16px; padding:6px 10px; cursor:pointer; }
        .btn-send { background: linear-gradient(45deg, #43a047, #2e7d32); border:none; color:#fff; border-radius: 16px; padding:6px 10px; cursor:pointer; }

        /* Quote preview + quoted block in messages */
        .dm-quote-preview { background: rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.25); border-radius: 8px; padding:6px 10px; font-size: 13px; margin-bottom: 6px; display:none; color:#fff; }
        .dm-quote-preview.visible { display:block; }
        .dm-quote-preview .q-close { float:right; background: transparent; color:#fff; border:1px solid rgba(255,255,255,0.4); border-radius: 12px; padding: 2px 8px; cursor:pointer; }
        .dm-quote-preview .quote-preview {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .dm-quote-preview .quote-label {
            font-weight: 600;
            opacity: 0.85;
            flex: 0 0 auto;
        }
        .dm-quote-preview .quote-body {
            flex: 1 1 auto;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            opacity: 0.9;
        }
        .dm-quote-preview .quote-body .quote-text {
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .dm-quote-preview .quote-body img {
            max-height: 36px;
            max-width: 64px;
            border-radius: 6px;
            display: block;
        }
        .dm-quote-preview .quote-cancel {
            background: transparent;
            color: #fff;
            border: 1px solid rgba(255,255,255,0.35);
            border-radius: 12px;
            padding: 2px 10px;
            cursor: pointer;
            flex: 0 0 auto;
        }
        .quoted-block { font-size: 12px; opacity: 0.9; background: rgba(255,255,255,0.08); border-left:3px solid #64b5f6; padding:6px 8px; border-radius: 6px; margin-bottom:6px; }

/* Enhancement cards center content vertically */
.dm-enh-grid .enhancement-card { display:flex; flex-direction:column; }
.dm-enh-grid .enhancement-content { flex:1; display:flex; align-items:stretch; justify-content:stretch; width:100%; }
.dm-enh-grid .enhancement-content { position: relative; }
.dm-enh-voice-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  transform: none;
  border: none;
  border-radius: 999px;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #607d8b, #37474f);
  color: #fff; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  opacity: 0.9;
}
.dm-enh-voice-btn:hover { opacity: 1; }
.dm-enh-voice-btn[disabled] { filter: grayscale(100%); opacity: 0.6; cursor: default; }

/* DM side action buttons spacing */
.dm-quote-btn { margin-top: 8px !important; }
.dm-refetch-btn { margin-bottom: 8px !important; }

.dm-edit-banner,
.group-edit-banner {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  background:rgba(59,130,246,0.18);
  border:1px solid rgba(59,130,246,0.35);
  border-radius:12px;
  padding:8px 12px;
  margin-bottom:10px;
  font-size:13px;
  color:#dfe6ff;
}

.dm-edit-banner .edit-cancel-btn,
.group-edit-banner .edit-cancel-btn {
  appearance:none;
  border:none;
  border-radius:10px;
  padding:4px 12px;
  background:rgba(59,130,246,0.35);
  color:#fff;
  font-size:13px;
  cursor:pointer;
  transition:background 0.15s ease;
}

.dm-edit-banner .edit-cancel-btn:hover,
.group-edit-banner .edit-cancel-btn:hover {
  background:rgba(59,130,246,0.55);
}

.dm-actions-column .message-more-btn {
  appearance:none;
  border:1px solid rgba(148,163,184,0.3);
  background:rgba(148,163,184,0.12);
  color:#fff;
  border-radius:999px;
  width:28px;
  height:28px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:15px;
  cursor:pointer;
  transition:background 0.15s ease;
}

.dm-actions-column .message-more-btn:hover {
  background:rgba(148,163,184,0.24);
}

.message-action-overlay {
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(8,10,16,0.58);
  backdrop-filter:blur(2px);
  z-index:1200;
}

.message-action-overlay.active { display:flex; }

.message-action-sheet {
  display:none;
  background:rgba(15,21,35,0.96);
  border:1px solid rgba(148,163,184,0.3);
  border-radius:16px;
  min-width:220px;
  max-width:320px;
  padding:10px;
  box-shadow:0 24px 48px rgba(0,0,0,0.45);
}

.message-action-sheet.active {
  display:flex;
  flex-direction:column;
  gap:8px;
}

.message-action-sheet.mobile {
  align-self:flex-end;
  margin:0 16px 24px;
  width:calc(100% - 32px);
}

.message-action-sheet.desktop { position:fixed; }

.message-action-btn {
  appearance:none;
  border:none;
  border-radius:12px;
  padding:10px 14px;
  background:rgba(255,255,255,0.08);
  color:#fff;
  text-align:left;
  font-size:15px;
  cursor:pointer;
  transition:background 0.15s ease;
}

.message-action-btn:hover { background:rgba(255,255,255,0.18); }

.message-action-btn.destructive { color:#f87171; }

.message-action-btn.destructive:hover { background:rgba(248,113,113,0.18); }

/* DM/Groups enhancement cards: rounded + dashed border across the full card (including flag/title area) */
.dm-enh-grid > .enhancement-card,
#dmMessages .enhancement-card,
#groupMessages .enhancement-card {
  border-style: dashed !important;
  border-width: 1px !important;
  border-radius: 12px !important;
}

/* DM enhancements: keep inner text blocks padded, but remove their own borders so only the card shows dashed */
.dm-enh-grid .enhancement-content > .english-text,
.dm-enh-grid .enhancement-content > .furigana-text,
.dm-enh-grid .enhancement-content > .cantonese-ruby,
.dm-enh-grid .enhancement-content > .chinese-ruby,
.dm-enh-grid .enhancement-content > .korean-ruby,
.dm-enh-grid .enhancement-content > .korean-text {
  width: 100% !important;
  box-sizing: border-box !important;
  background: transparent !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 10px 12px !important;
}

/* DM enhancements: ensure annotations are readable on dark cards */
.dm-enh-grid .enhancement-card ruby rt,
#dmMessages .enhancement-card ruby rt,
#groupMessages .enhancement-card ruby rt {
  color: #cbd5f5 !important;
}

/* Defensive: ensure enhancement text inherits light color inside DM cards */
.dm-enh-grid .enhancement-card .enhancement-content,
#dmMessages .enhancement-card .enhancement-content,
#groupMessages .enhancement-card .enhancement-content {
  color: inherit;
}

        /* Settings notification styles */
        .settings-notification {
            animation: slideInRight 0.3s ease-out;
        }

        @keyframes slideInRight {
            from {
                transform: translateX(100%);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }
#postWaveBars.waveform { position:absolute; inset:0; height:100%; box-sizing: border-box; background: rgba(0,0,0,0.25); border:1px solid rgba(255,255,255,0.2); border-radius:8px; }
/* Hide legacy enhancement version controls to simplify UI */
.lang-prev, .lang-next, .lang-version { display: none !important; }

/* Tidy enhancement footer controls */
.section-controls { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.section-controls .lang-controls { display: inline-flex; gap: 8px; }
.section-controls .enhancement-audio-controls { display: inline-flex; gap: 8px; align-items: center; }
.section-controls .enh-voice-select { appearance: none; background: rgba(255,255,255,0.08); color:#fff; border:1px solid rgba(255,255,255,0.25); border-radius:6px; padding:3px 6px; height:26px; font-size:12px; }
.section-controls .enh-voice-select { max-width: 140px; min-width: 110px; }
.section-controls .enhancement-generate { padding: 4px 10px; border-radius: 999px; }
.section-controls button { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); color: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.section-controls button:hover { background: rgba(255,255,255,0.14); }

/* Tiny button variant */
.control-button.tiny { font-size: 12px; padding: 4px 8px; border-radius: 8px; }
.user-message, .ai-message { position: relative; }

.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
  align-items: center;
}

.message-reactions.empty {
  display: none;
}

.message-reactions .reaction-chip,
.message-reactions .reaction-add-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #f1f5f9;
  font-size: 13px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.message-reactions .reaction-chip.mine {
  background: rgba(96, 165, 250, 0.28);
  border-color: rgba(96, 165, 250, 0.55);
  color: #ffffff;
}

.message-reactions .reaction-chip:hover {
  background: rgba(96, 165, 250, 0.24);
  border-color: rgba(96, 165, 250, 0.55);
}

.message-reactions .reaction-chip .reaction-count {
  font-size: 12px;
  opacity: 0.9;
}

.message-reactions .reaction-add-btn {
  font-weight: 600;
  font-size: 14px;
}

.message-reactions .reaction-add-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.message-action-sheet .reaction-quick-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 12px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-wrap: wrap;
  width: 100%;
  row-gap: 8px;
}

.message-action-sheet .reaction-quick-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 18px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  flex: 0 1 auto;
}

.message-action-preview {
  width: 100%;
  padding: 8px 6px 0;
  display: flex;
  justify-content: center;
}

.message-action-preview-bubble {
  max-width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: #e2e8f0;
  max-height: 180px;
  overflow: hidden;
  overflow-y: auto;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.message-action-preview-bubble.mine {
  background: linear-gradient(135deg, rgba(59,130,246,0.28), rgba(99,102,241,0.32));
  border-color: rgba(96,165,250,0.45);
  color: #f8fafc;
}

.message-action-preview-bubble img {
  max-width: 180px;
  max-height: 140px;
  width: auto;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 8px auto 0;
}

.message-preview-quote {
  font-size: 13px;
  font-style: italic;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-preview-text {
  margin-top: 6px;
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-preview-image {
  margin-top: 8px;
  text-align: center;
}

.message-preview-voice {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.9;
}

.message-preview-empty {
  text-align: center;
  font-size: 13px;
  opacity: 0.5;
}

@media (max-width: 480px) {
  .message-action-preview {
    padding: 6px 0 0;
  }
  .message-action-preview-bubble {
    max-height: 160px;
  }
}

.reaction-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
  font-size: 32px;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.35));
}

.reaction-burst.visible {
  animation: reactionBurst 650ms ease-out forwards;
}

@keyframes reactionBurst {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0.6; }
  45% { transform: translate(-50%, -62%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0.8); opacity: 0; }
}

.reaction-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1400;
  padding: 60px 16px 24px;
}

.reaction-picker-overlay.visible {
  display: flex;
}

.reaction-picker-panel {
  background: rgba(20, 20, 24, 0.96);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.55);
  padding: 14px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  max-width: 360px;
  max-height: 60vh;
  overflow-y: auto;
}

.reaction-picker-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 20px;
  padding: 6px 0;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.reaction-picker-btn:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateY(-2px);
}

.message-action-sheet .reaction-quick-btn:hover {
  background: rgba(96, 165, 250, 0.2);
  transform: translateY(-1px);
}
/* Posts tabs (desktop) */
.posts-tabs { display:flex; justify-content:center; align-items:center; gap:10px; margin:8px 0; }
.posts-tabs .posts-tab { cursor:pointer; padding:6px 12px; border-radius:999px; border:1px solid rgba(0,0,0,0.15); background: rgba(0,0,0,0.06); color:#111; }
.theme-dark .posts-tabs .posts-tab { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.08); color:#fff; }
.posts-tabs .posts-tab.active { background:#6366f1; color:#fff; border-color: rgba(99,102,241,0.8); }
/* Sticky variant to float under header during scroll */
.posts-tabs.sticky { position: sticky; top: var(--posts-sticky-top, 56px); z-index: 40; padding: 6px 8px; backdrop-filter: blur(6px); }
.posts-tabs.sticky { background: rgba(15,23,42,0.65); border-bottom: 1px solid rgba(255,255,255,0.08); }
.theme-light .posts-tabs.sticky { background: rgba(255,255,255,0.8); border-bottom-color: rgba(0,0,0,0.06); }

/* Default theme (no data-theme): vivid posts tabs with gradient active pill */
html:not([data-theme]) .posts-tabs .posts-tab {
  background: #f3f6fb !important;
  border: 1px solid #e5e7eb !important;
  color: #0f172a !important;
}
html:not([data-theme]) .posts-tabs .posts-tab.active {
  background: linear-gradient(135deg, #0ea5e9, #4f46e5) !important;
  border-color: rgba(79,70,229,0.9) !important;
  color: #ffffff !important;
}
html:not([data-theme]) .posts-tabs .posts-tab:hover { background: #eaf2fd !important; }
html:not([data-theme]) .posts-tabs.sticky {
  background: linear-gradient(90deg, rgba(14,165,233,0.25), rgba(79,70,229,0.25)) !important;
  border-bottom: 1px solid rgba(255,255,255,0.18) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* Scroll-to-bottom affordances for DM/Groups */
.conversation-area {
  position: relative;
}

.scroll-bottom-btn {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 0) scale(0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, rgba(79,70,229,0.92), rgba(14,165,233,0.9));
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 14px 30px rgba(15,23,42,0.25);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

.scroll-bottom-btn.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.scroll-bottom-btn:focus-visible {
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 3px;
}

.theme-light .scroll-bottom-btn {
  box-shadow: 0 12px 28px rgba(31,41,55,0.24);
}

/* Welcome guide overlay */
.welcome-guide {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(6px);
  z-index: 5000;
  overflow: auto;
}

.welcome-guide.hidden {
  display: none !important;
}

.welcome-guide-container {
  position: relative;
  width: min(100%, 520px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 255, 0.25);
  border-radius: 18px;
  padding: 24px;
  color: #f8fafc;
  box-shadow: 0 28px 68px rgba(15, 23, 42, 0.55);
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 640px);
  overflow: hidden;
}

.welcome-guide-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: rgba(226, 232, 240, 0.7);
  font-size: 20px;
  cursor: pointer;
}

.welcome-guide-close:hover,
.welcome-guide-close:focus-visible {
  color: #ffffff;
  outline: none;
}

.welcome-guide-header {
  text-align: center;
  margin-bottom: 18px;
}

.welcome-guide-steps {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.welcome-guide-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(148, 163, 255, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
}

.welcome-guide-dot.active {
  background: #6366f1;
  transform: scale(1.15);
}

.welcome-guide-subtitle {
  margin: 6px 0 0;
  color: rgba(226, 232, 240, 0.78);
  font-size: 0.98rem;
}

.welcome-guide-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 6px;
}

.guide-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guide-step.hidden {
  display: none;
}

.guide-detected {
  font-size: 0.95rem;
  color: rgba(226, 232, 240, 0.8);
}

.guide-detected strong {
  color: #ffffff;
}

.guide-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
}

.guide-form select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 255, 0.3);
  background: rgba(15, 23, 42, 0.7);
  color: #f8fafc;
}

.guide-form select:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.8);
  outline-offset: 1px;
}

.guide-sync-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.guide-mother-wrap select {
  background: rgba(15, 23, 42, 0.7);
}

.guide-hint {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.75);
}

.guide-enh-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.guide-enh-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(129, 140, 248, 0.35);
  background: rgba(79, 70, 229, 0.12);
  color: #e0e7ff;
  flex: 1 1 calc(50% - 10px);
  min-width: 190px;
}

.guide-enh-option input {
  accent-color: #6366f1;
}

.guide-subscribe {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.guide-subscribe a {
  color: #a5b4fc;
  text-decoration: underline;
}

.guide-link {
  color: #a5b4fc;
  font-weight: 600;
  text-decoration: underline;
}

.enhancement-card[data-type="english"] .enhancement-content span + span,
.enhancement-card[data-type="vietnamese"] .enhancement-content span + span,
.enhancement-card[data-type="arabic"] .enhancement-content span + span {
  margin-left: 0.25em;
}

.welcome-guide-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 12px;
  flex-shrink: 0;
}

.guide-nav-buttons {
  display: flex;
  gap: 10px;
}

.guide-btn {
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.guide-btn:focus-visible {
  outline: 2px solid rgba(148, 163, 255, 0.85);
  outline-offset: 2px;
}

.guide-back {
  background: transparent;
  border: 1px solid rgba(148, 163, 255, 0.4);
  color: #e0e7ff;
}

.guide-next {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  color: #ffffff;
}

.guide-skip {
  background: none;
  border: none;
  color: rgba(226, 232, 240, 0.75);
  padding: 0;
  text-decoration: underline;
  font-size: 0.9rem;
}

.guide-skip.hidden {
  display: none !important;
}

.guide-complete-group {
  margin-top: 12px;
}

.guide-complete-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(226, 232, 240, 0.85);
  font-size: 0.95rem;
}

/* Make the settings "Welcome guide completed" row readable on light surfaces */
[data-theme="light"] .guide-complete-row,
[data-theme="vivid"] .guide-complete-row,
[data-theme="bright"] .guide-complete-row {
  color: #0f172a !important;
}

.guide-complete-row input {
  accent-color: #6366f1;
}

@media (max-width: 640px) {
  .welcome-guide-container {
    width: min(100%, 420px);
    padding: 20px 18px;
    max-height: calc(94vh - 24px);
  }
  .guide-enh-option {
    flex: 1 1 100%;
    min-width: 0;
  }
  .welcome-guide-body {
    padding-right: 4px;
  }
}


/* Mother tongue settings layout */
.mother-settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.mother-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex: 1 1 220px;
  min-width: 200px;
}

.mother-select-wrap span { white-space: nowrap; }
.mother-select-wrap select {
  width: auto;
  flex: 1 1 260px;
  min-width: 200px;
  max-width: 100%;
}

.mother-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 180px;
}

.mother-toggle-wrap span {
  flex: 1 1 auto;
}

.mother-sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .mother-select-wrap {
    flex: 1 1 160px;
    min-width: 160px;
  }
  .mother-toggle-wrap {
    flex: 1 1 160px;
    min-width: 160px;
  }
}

/* Allow the entire row to wrap; keep only the label+select inline via .mother-select-wrap */
/* Admin Invites: tighten filters row alignment */
.admin-invite-filters { align-items: center; }
.admin-invite-filters label { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.admin-invite-filters label select { margin-top: 0; }
/* Make refresh button visually match select height and align center */
#adminInviteRefreshBtn { display: inline-flex; align-items: center; padding: 6px 10px; line-height: 1.2; }

/* Desktop chat: drag-and-drop image overlay + fancy progress ring */
.chat-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9010;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 17, 28, 0.35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.chat-drop-overlay.visible { display: flex; }
.chat-drop-card {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  padding: 16px 18px;
  min-width: 260px;
  color: #e8eef7;
  box-shadow: 0 18px 46px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  gap: 16px;
}
.chat-drop-card .chat-drop-hint { font-weight: 700; letter-spacing: .2px; }
.chat-drop-progress {
  --p: 0; /* 0..100 */
  width: 56px; height: 56px; border-radius: 50%;
  background: conic-gradient(#6ee7b7 calc(var(--p) * 1%), rgba(255,255,255,0.12) 0);
  position: relative;
  animation: chatRingSpin 1.2s linear infinite;
}
.chat-drop-progress.indeterminate { animation-play-state: running; }
.chat-drop-progress:not(.indeterminate) { animation-play-state: paused; }
.chat-drop-progress::after { /* inner cutout */
  content: '';
  position: absolute; inset: 7px; border-radius: 50%;
  background: radial-gradient(150px 150px at 30% 20%, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
@keyframes chatRingSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.chat-drop-overlay.drop-active .chat-drop-card {
  border-color: rgba(56,189,248,0.5);
  box-shadow: 0 20px 60px rgba(14, 165, 233, 0.3), inset 0 0 0 1px rgba(56,189,248,0.35);
}

/* Inline image upload progress ring for DM/Groups bubbles */
.img-upload-wrap { position: relative; display: inline-block; }
.img-upload-ring {
  --p: 0; /* 0..100 */
  position: absolute; right: 6px; bottom: 6px;
  width: 28px; height: 28px; border-radius: 50%;
  background: conic-gradient(#60a5fa calc(var(--p) * 1%), rgba(255,255,255,0.15) 0);
  animation: chatRingSpin 1s linear infinite;
}
.img-upload-ring.indeterminate { animation-play-state: running; }
.img-upload-ring:not(.indeterminate) { animation-play-state: paused; }
.img-upload-ring::after {
  content: '';
  position: absolute; inset: 4px; border-radius: 50%;
  background: rgba(0,0,0,0.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
