/* Member Chat — acewithgrace.space paid-member rooms & friends.
   SEPARATE from the library Study Hall: different button, different endpoints
   (/api/members/* only), different data. Never the twain shall meet.
   Brand palette: dark teal #2A5E51, cream #F7F3EA, terracotta #CD7346. */

#mc-fab {
  position: fixed; right: 18px; bottom: 90px; z-index: 2147483000;
  display: flex; align-items: center; gap: 8px;
  background: #CD7346; color: #fff; border: none; border-radius: 999px;
  padding: 12px 18px; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.25); font-family: inherit;
}
#mc-fab:hover { background: #b8623a; }
#mc-fab .mc-dot { width: 9px; height: 9px; border-radius: 50%; background: #ffe1c2; }

#mc-panel {
  position: fixed; right: 18px; bottom: 148px; z-index: 2147483001;
  width: 400px; max-width: calc(100vw - 36px); height: 560px; max-height: calc(100vh - 110px);
  background: #F7F3EA; border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  display: none; flex-direction: column; font-family: inherit; color: #2A2A28;
}
#mc-panel.mc-open { display: flex; }

#mc-head { background: #2A5E51; color: #F7F3EA; padding: 12px 14px; }
#mc-head .mc-title { font-weight: 700; font-size: 15px; }
#mc-head .mc-sub { font-size: 12px; opacity: .85; }
#mc-tabs { display: flex; gap: 6px; margin-top: 8px; }
#mc-tabs button {
  flex: 1; background: transparent; border: 1px solid rgba(247,243,234,.4);
  color: #F7F3EA; border-radius: 8px; padding: 6px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
#mc-tabs button.mc-active { background: #F7F3EA; color: #2A5E51; font-weight: 700; }
#mc-close {
  position: absolute; top: 10px; right: 10px; background: transparent;
  border: 1px solid rgba(247,243,234,.4); color: #F7F3EA; border-radius: 8px;
  padding: 4px 9px; font-size: 12px; cursor: pointer;
}

.mc-view { flex: 1; overflow-y: auto; padding: 12px 14px; display: none; flex-direction: column; gap: 8px; }
.mc-view.mc-active { display: flex; }

.mc-room {
  background: #fff; border: 1px solid #e0d8c2; border-radius: 12px;
  padding: 10px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.mc-room:hover { border-color: #2A5E51; }
.mc-room .mc-rname { font-weight: 700; font-size: 14px; }
.mc-room .mc-rmeta { font-size: 12px; color: #8a8172; }
.mc-badge {
  font-size: 10px; font-weight: 700; border-radius: 4px; padding: 1px 6px;
  background: #2A5E51; color: #F7F3EA; margin-left: 6px;
}
.mc-badge.mc-lock { background: #CD7346; }
.mc-room .mc-del {
  margin-left: auto; background: none; border: none; color: #b0482f;
  font-size: 12px; cursor: pointer;
}

.mc-actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid #e0d8c2; }
.mc-actions button {
  flex: 1; border-radius: 10px; padding: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
#mc-new-room { background: #2A5E51; color: #F7F3EA; border: none; }
#mc-join-code { background: transparent; color: #2A5E51; border: 1px solid #2A5E51; }

/* inside a room */
#mc-roomview { display: none; flex-direction: column; flex: 1; min-height: 0; }
#mc-roomview.mc-active { display: flex; }
#mc-rv-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #e9e2d2; border-bottom: 1px solid #e0d8c2;
}
#mc-rv-head .mc-rname { font-weight: 700; font-size: 14px; flex: 1; }
#mc-rv-head button {
  background: #fff; border: 1px solid #d8cfb8; border-radius: 8px;
  padding: 4px 9px; font-size: 12px; cursor: pointer; font-family: inherit;
}
#mc-whisper-allowance {
  padding: 5px 14px; background: #f1ecdf; color: #6b6252;
  border-bottom: 1px solid #e0d8c2; font-size: 11px; text-align: right;
}
#mc-whisper-allowance[hidden] { display: none; }
#mc-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.mc-msg { max-width: 88%; }
.mc-msg .mc-meta { font-size: 11px; color: #6b6252; margin-bottom: 2px; }
.mc-msg .mc-bubble {
  background: #fff; border: 1px solid #e0d8c2; border-radius: 12px;
  padding: 8px 11px; font-size: 14px; line-height: 1.45; word-wrap: break-word; position: relative;
}
.mc-msg.mc-mine { align-self: flex-end; }
.mc-msg.mc-mine .mc-bubble { background: #2A5E51; color: #F7F3EA; border-color: #2A5E51; }
.mc-msg.mc-mine .mc-meta { text-align: right; }
.mc-report {
  position: absolute; top: 2px; right: 6px; background: none; border: none;
  font-size: 11px; color: #a39a86; cursor: pointer; opacity: 0; padding: 2px 4px;
}
.mc-msg:hover .mc-report { opacity: 1; }
.mc-msg .mc-nudge {
  position: absolute; top: 2px; right: 42px; background: none; border: 0;
  color: #2563eb; font-size: 11px; cursor: pointer; opacity: 0; padding: 2px 4px;
}
.mc-msg:hover .mc-nudge { opacity: 1; }
@media (max-width: 600px) {
  .mc-msg .mc-nudge { opacity: 1; }
}
.mc-msg.mc-private { border-left: 3px solid #8b5cf6; }
.mc-msg.mc-private .mc-bubble { background: rgba(139, 92, 246, 0.1); }
.mc-whisper-nudge {
  align-self: center; display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 9px; max-width: 96%; padding: 9px 12px; border-radius: 12px;
  border: 1px solid #c4b5fd; background: rgba(139, 92, 246, 0.09); color: #3b2d62; font-size: 13px;
}
.mc-whisper-actions { display: inline-flex; gap: 6px; }
.mc-whisper-actions button { border-radius: 7px; padding: 5px 9px; cursor: pointer; font: inherit; }
.mc-whisper-accept { border: 0; background: #2A5E51; color: #F7F3EA; }
.mc-whisper-decline { border: 1px solid #b8aacd; background: transparent; color: inherit; }
.mc-whisper-result {
  align-self: center; max-width: 96%; padding: 7px 11px; border-radius: 10px;
  border: 1px solid #c4b5fd; background: rgba(139, 92, 246, 0.08);
  color: #3b2d62; font-size: 12px; text-align: center;
}
.mc-dir-tappable {
  color: #1d4ed8; font-weight: 700; text-decoration: underline; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform 0.12s ease, filter 0.12s ease;
  animation: mc-dir-pulse 2s ease-in-out infinite;
}
.mc-dir-tappable:active { transform: scale(0.96); filter: brightness(0.9); }
@keyframes mc-dir-pulse {
  0%, 100% { text-shadow: 0 0 6px rgba(37, 99, 235, 0.4); }
  50% { text-shadow: 0 0 18px rgba(37, 99, 235, 0.9); }
}
#mc-compose-field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
#mc-direction { padding: 0 3px; font-size: 12px; color: #4b5563; }
#mc-inputbar { border-top: 1px solid #e0d8c2; padding: 10px 12px; display: flex; gap: 8px; }
#mc-text {
  flex: 1; border: 1px solid #d8cfb8; border-radius: 10px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; resize: none; max-height: 90px;
}
#mc-send {
  background: #CD7346; color: #fff; border: none; border-radius: 10px;
  padding: 0 16px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}

/* friends */
.mc-friend {
  background: #fff; border: 1px solid #e0d8c2; border-radius: 12px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.mc-friend .mc-fname { font-weight: 700; font-size: 14px; }
.mc-friend .mc-fsub { font-size: 12px; color: #8a8172; }
.mc-pres {
  width: 10px; height: 10px; border-radius: 50%; background: #c9c2b2; flex-shrink: 0;
}
.mc-pres.mc-on { background: #4caf7d; box-shadow: 0 0 6px #4caf7d; }
.mc-friend .mc-fbtns { margin-left: auto; display: flex; gap: 6px; }
.mc-friend button {
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.mc-accept { background: #2A5E51; color: #F7F3EA; border: none; }
.mc-decline, .mc-remove { background: transparent; border: 1px solid #d8cfb8; color: #6b6252; }
#mc-friend-search { display: flex; gap: 8px; }
#mc-friend-search input {
  flex: 1; border: 1px solid #d8cfb8; border-radius: 10px; padding: 9px 11px;
  font-size: 14px; font-family: inherit;
}
#mc-friend-search button {
  background: #2A5E51; color: #F7F3EA; border: none; border-radius: 10px;
  padding: 0 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.mc-section { font-size: 12px; font-weight: 700; color: #8a8172; text-transform: uppercase; margin-top: 4px; }

/* modals */
.mc-modal-back {
  position: fixed; inset: 0; z-index: 2147483002; background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.mc-modal-back.mc-open { display: flex; }
.mc-modal {
  background: #F7F3EA; border-radius: 16px; padding: 22px; max-width: 420px; width: 100%;
  max-height: 85vh; overflow-y: auto; color: #2A2A28; font-family: inherit;
}
.mc-modal h3 { margin: 0 0 10px; color: #2A5E51; font-size: 18px; }
.mc-modal p { font-size: 14px; line-height: 1.55; }
.mc-modal input[type=text], .mc-modal select {
  width: 100%; box-sizing: border-box; padding: 10px 12px; font-size: 15px;
  border: 1px solid #d8cfb8; border-radius: 10px; font-family: inherit; margin: 6px 0;
}
.mc-modal .mc-err { color: #b0482f; font-size: 13px; min-height: 18px; }
.mc-modal .mc-primary {
  width: 100%; background: #2A5E51; color: #F7F3EA; border: none; border-radius: 10px;
  padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 10px;
  font-family: inherit;
}
.mc-modal .mc-row { display: flex; gap: 10px; margin: 8px 0; }
.mc-modal .mc-row label {
  flex: 1; border: 1px solid #d8cfb8; border-radius: 10px; padding: 10px;
  font-size: 14px; cursor: pointer; display: flex; gap: 8px; align-items: center;
  background: #fff;
}
.mc-code {
  font-size: 34px; font-weight: 700; letter-spacing: 6px; text-align: center;
  background: #fff; border: 2px dashed #2A5E51; border-radius: 12px; padding: 14px; margin: 10px 0;
}
.mc-member-row {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border: 1px solid #e0d8c2; border-radius: 10px; padding: 8px 12px; margin-bottom: 6px;
}
.mc-member-row .mc-fname { font-size: 14px; font-weight: 700; flex: 1; }
.mc-member-row button {
  border: 1px solid #d8cfb8; background: transparent; border-radius: 8px;
  padding: 4px 10px; font-size: 12px; cursor: pointer; color: #b0482f; font-family: inherit;
}

@media (max-width: 480px) {
  #mc-panel { right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%;
    height: 82vh; max-height: 82vh; border-radius: 16px 16px 0 0; }
  #mc-fab { right: 14px; bottom: 90px; }
}

.mc-mocktest-button {
  flex: 0 0 auto; background: #2A5E51; color: #F7F3EA; border: none;
  border-radius: 10px; padding: 0 11px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.mc-mocktest-button:hover { background: #234e44; }
.mc-mocktest-button[hidden] { display: none; }
.mc-mocktest-back {
  position: fixed; inset: 0; z-index: 2147483003; background: rgba(0,0,0,.58);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.mc-mocktest-back.mc-mocktest-open { display: flex; }
.mc-mocktest-modal {
  width: 100%; max-width: 460px; max-height: 85vh; overflow-y: auto;
  box-sizing: border-box; padding: 20px; border-radius: 16px;
  background: #F7F3EA; color: #2A2A28; font-family: inherit;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.mc-mocktest-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mc-mocktest-title { margin: 0; color: #2A5E51; font-size: 18px; }
.mc-mocktest-close {
  flex: 0 0 auto; border: 1px solid #d8cfb8; background: #fff; color: #2A2A28;
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: 12px;
}
.mc-mocktest-intro { margin: 10px 0 14px; font-size: 14px; line-height: 1.45; }
.mc-mocktest-subjects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mc-mocktest-subject {
  min-height: 44px; padding: 9px 11px; border: 1px solid #d8cfb8; border-radius: 10px;
  background: #fff; color: #2A5E51; text-align: left; font: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.mc-mocktest-subject:hover, .mc-mocktest-subject:focus-visible {
  border-color: #2A5E51; background: #e9f0ec; outline: none;
}
.mc-mocktest-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 8px; padding: 10px 12px; border: 1px solid #2A5E51;
  border-radius: 10px; background: #edf3ef; color: #234e44;
  font-size: 13px; font-weight: 700; text-decoration: none;
}
.mc-mocktest-card:hover { background: #dfeae3; text-decoration: underline; }
.mc-mocktest-card-label { min-width: 0; }
.mc-mocktest-card-arrow { flex: 0 0 auto; font-size: 18px; }
@media (max-width: 480px) {
  .mc-mocktest-button { padding: 0 8px; font-size: 11px; }
  .mc-mocktest-modal { padding: 16px; }
  .mc-mocktest-subjects { grid-template-columns: 1fr; }
}

.dark #mc-panel,
.dark .mc-modal,
.dark .mc-mocktest-modal {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
}

.dark .mc-room,
.dark .mc-friend,
.dark #mc-rv-head button,
.dark #mc-text,
.dark #mc-friend-search input,
.dark .mc-modal input,
.dark .mc-modal select,
.dark .mc-modal .mc-row label,
.dark .mc-code,
.dark .mc-member-row,
.dark .mc-mocktest-close,
.dark .mc-mocktest-subject {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.dark .mc-msg:not(.mc-mine) .mc-bubble {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.dark #mc-rv-head {
  background: hsl(var(--muted));
  border-color: hsl(var(--border));
}

.dark .mc-room .mc-rmeta,
.dark .mc-friend .mc-fsub,
.dark .mc-msg .mc-meta,
.dark .mc-section,
.dark .mc-decline,
.dark .mc-remove,
.dark .mc-report {
  color: hsl(var(--muted-foreground));
}

.dark #mc-join-code,
.dark .mc-modal h3,
.dark .mc-mocktest-title {
  color: hsl(var(--primary));
}

.dark #mc-join-code {
  border-color: hsl(var(--primary));
}

.dark .mc-room .mc-del{color:hsl(var(--destructive));}
/* MOBILE "More" menu fix: while the mobile bottom-tab "More" popup
   (#mobile-more-menu) is open, hide the floating Member Chat pill so it
   cannot overlap or block the popup's menu items. The pill reappears
   automatically when the popup closes. */
body:has(#mobile-more-menu) #mc-fab,
body:has(#mobile-more-menu) #sh-fab{display:none !important;}

.dark .mc-member-row button,
.dark .mc-modal .mc-err {
  color: hsl(var(--destructive));
}

.dark .mc-mocktest-subject:hover,
.dark .mc-mocktest-subject:focus-visible {
  background: hsl(var(--secondary));
  border-color: hsl(var(--primary));
}

.dark .mc-mocktest-card {
  background: hsl(var(--secondary));
  border-color: hsl(var(--primary));
  color: hsl(var(--foreground));
}

.dark .mc-mocktest-card:hover {
  background: hsl(var(--muted));
}
.dark .mc-dir-tappable { color: #60a5fa; animation: mc-dir-pulse-dark 2s ease-in-out infinite; }
@keyframes mc-dir-pulse-dark {
  0%, 100% { text-shadow: 0 0 6px rgba(96, 165, 250, 0.4); }
  50% { text-shadow: 0 0 18px rgba(96, 165, 250, 0.9); }
}
.dark .mc-msg.mc-private { border-left-color: #c4b5fd; }
.dark .mc-msg.mc-private .mc-bubble { background: rgba(139, 92, 246, 0.22); color: hsl(var(--foreground)); }
.dark .mc-whisper-nudge {
  border-color: #6d5b91; background: rgba(139, 92, 246, 0.2); color: hsl(var(--foreground));
}
.dark #mc-whisper-allowance {
  background: hsl(var(--secondary)); border-color: hsl(var(--border)); color: hsl(var(--muted-foreground));
}
.dark .mc-whisper-result {
  border-color: #6d5b91; background: rgba(139, 92, 246, 0.2); color: hsl(var(--foreground));
}
.dark .mc-whisper-decline { border-color: hsl(var(--border)); }
.dark #mc-direction { color: hsl(var(--muted-foreground)); }
@media (prefers-reduced-motion: reduce) {
  .mc-dir-tappable { animation: none; transition: none; }
}

.mc-linkicon { margin-left: 6px; text-decoration: none; font-size: 13px; }
#mc-linkbox input { width: 100%; box-sizing: border-box; margin-bottom: 8px;
  padding: 8px; border: 1px solid #d8cfbd; border-radius: 6px; font-size: 14px; }
#mc-dm-msgs { max-height: 300px; overflow-y: auto; padding: 8px 0; }
.mc-dm { margin-right: 6px; }
.mc-dm-error { color: #b42318; font-size: 13px; padding: 4px 0; }
.dark .mc-dm-error { color: #fca5a5; }

/* Ambient gold finish — shadow-only pulses preserve contrast in light and dark mode. */
#mc-panel {
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3), inset 0 0 0 1px rgba(212, 175, 55, .25);
}

#mc-fab {
  overflow: hidden;
  isolation: isolate;
  --mc-gold-pulse-low: .30;
  --mc-gold-pulse-high: .65;
  animation: mc-gold-pulse 3s ease-in-out infinite;
}

#mc-head {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#mc-fab::after,
#mc-head::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 215, 130, .28) 48%, rgba(255, 255, 255, .35) 52%, transparent 70%);
  background-size: 250% 100%;
  background-position: 120% 0;
  animation: mc-sheen 5.5s linear infinite;
  pointer-events: none;
}

#mc-tabs button.mc-active,
#mc-send,
.mc-msg.mc-mine .mc-bubble {
  --mc-gold-pulse-low: .15;
  --mc-gold-pulse-high: .45;
  animation: mc-gold-pulse 3s ease-in-out infinite;
}

@keyframes mc-gold-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(212, 175, 55, var(--mc-gold-pulse-low, .30)); }
  50% { box-shadow: 0 0 22px rgba(212, 175, 55, var(--mc-gold-pulse-high, .65)); }
}

@keyframes mc-sheen {
  from { background-position: 120% 0; }
  to { background-position: -20% 0; }
}

@media (prefers-reduced-motion: reduce) {
  #mc-fab,
  #mc-fab::after,
  #mc-head::after,
  #mc-tabs button.mc-active,
  #mc-send,
  .mc-msg.mc-mine .mc-bubble {
    animation: none;
  }
}
