/* ══════════════════════════════════════════════
   Study Groupio — Main Stylesheet
   Dark & Light Theme with CSS Variables
   Font: Outfit (display) + Nunito (body)
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Nunito:wght@400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  --brand-blue: #4361EE;
  --brand-violet: #7B5EA7;
  --brand-pink: #F72585;
  --brand-gradient: linear-gradient(135deg, #4361EE, #7B5EA7, #F72585);
  --brand-gradient-soft: linear-gradient(135deg, rgba(67,97,238,0.15), rgba(247,37,133,0.1));

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 999px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.18);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.24);
  --shadow-glow: 0 0 32px rgba(67,97,238,0.3);

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

@media (min-width: 769px) {
  .mobile-bottom-nav {
    display: none;
  }
}

@media (max-width: 768px) {
  body {
    padding-left: 0;
  }
  .desktop-sidebar {
    display: none;
  }
  .mobile-bottom-nav {
    display: flex;
  }
}

/* Main Content Adjustments - Enhanced */
.main-content {
  padding-top: 60px;
  margin-left: 0;
  min-height: 100vh;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding-left: clamp(8px, 1.5vw, 16px);
  padding-right: clamp(8px, 1.5vw, 16px);
}

/* ── DARK THEME (default) ── */
[data-theme="dark"], .theme-dark {
  --bg-primary: #000000;
  --bg-secondary: #090909;
  --bg-card: #121212;
  --bg-card-hover: #1A1A1A;
  --bg-input: #101010;
  --bg-input-focus: #161616;
  --bg-overlay: rgba(0,0,0,0.94);
  --bg-nav: rgba(0,0,0,0.9);

  --nav-surface: var(--bg-primary);
  --nav-hover: rgba(255,255,255,0.08);
  --nav-active: rgba(255,255,255,0.13);

  --text-primary: #F5F5F5;
  --text-secondary: #B1B1B1;
  --text-muted: #8A8A8A;
  --text-placeholder: #696969;
  --text-inverse: #000000;

  --border-color: rgba(255,255,255,0.14);
  --border-focus: rgba(67,97,238,0.6);
  --border-input: rgba(255,255,255,0.18);

  --btn-primary-bg: linear-gradient(135deg, #4361EE, #6B48C8);
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: rgba(255,255,255,0.08);
  --btn-secondary-text: #F5F5F5;
  --btn-secondary-border: rgba(255,255,255,0.2);

  --tab-active-bg: #4361EE;
  --tab-inactive: #8C8C8C;

  --success: #10D982;
  --error: #FF6B9D;
  --error-light: #FF8FAB;
  --error-gradient: linear-gradient(135deg, #FF6B9D, #C44569);
  --error-glow: rgba(255, 107, 157, 0.3);
  --warning: #FFB703;
  --info: #4CC9F0;

  --scrollbar-thumb: #4361EE44;
  --scrollbar-track: #111111;
  
  /* Academic objects colors */
  --academic-fill: rgba(67,97,238,0.15);
  --academic-stroke: rgba(67,97,238,0.4);
}

/* ── LIGHT THEME ── */
[data-theme="light"], .theme-light {
  --bg-primary: #F8F9FC;
  --bg-secondary: #EEF1FA;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F5F7FC;
  --bg-input: #F0F3FA;
  --bg-input-focus: #E8ECF6;
  --bg-overlay: rgba(248,249,252,0.98);
  --bg-nav: rgba(255,255,255,0.92);

  --nav-surface: var(--bg-primary);
  --nav-hover: rgba(0,0,0,0.04);
  --nav-active: rgba(0,0,0,0.06);

  --text-primary: #1A1D2E;
  --text-secondary: #4A4F7A;
  --text-muted: #7B81A6;
  --text-placeholder: #A8AECA;
  --text-inverse: #F0F2FF;

  --border-color: rgba(0,0,0,0.08);
  --border-focus: rgba(67,97,238,0.6);
  --border-input: rgba(0,0,0,0.12);

  --btn-primary-bg: linear-gradient(135deg, #4361EE 0%, #5B52D9 50%, #6B48C8 100%);
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: rgba(67,97,238,0.08);
  --btn-secondary-text: #3D52C9;
  --btn-secondary-border: rgba(67,97,238,0.2);

  --tab-active-bg: #4361EE;
  --tab-inactive: #9CA3C9;

  --success: #0DB56A;
  --error: #E74C3C;
  --error-light: #EC7063;
  --error-gradient: linear-gradient(135deg, #E74C3C, #C0392B);
  --error-glow: rgba(231, 76, 60, 0.25);
  --warning: #D4920A;
  --info: #0096C7;

  --scrollbar-thumb: #4361EE66;
  --scrollbar-track: #E8ECF6;

  --shadow-sm: 0 2px 12px rgba(67,97,238,0.08);
  --shadow-md: 0 8px 32px rgba(67,97,238,0.12);
  --shadow-lg: 0 20px 56px rgba(67,97,238,0.16);
  --shadow-glow: 0 0 40px rgba(67,97,238,0.2);
  
  /* Academic objects colors - enhanced for light theme */
  --academic-fill: rgba(67,97,238,0.15);
  --academic-stroke: rgba(67,97,238,0.6);
  
  /* Subtle accent colors */
  --accent-blue: rgba(67,97,238,0.1);
  --accent-violet: rgba(123,94,167,0.1);
  --accent-pink: rgba(247,37,133,0.08);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

@media (min-width: 769px) {
  body {
    padding-left: 72px;
  }
}

/* ── Custom Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }

/* ── Utility Classes ── */
.gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ══════════════════════════════════════════
   ICONS (SVG-based)
   ══════════════════════════════════════════ */

/* Icon base styles */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* Theme toggle icon */
.theme-icon {
  width: 20px;
  height: 20px;
}

/* Sun icon (light theme) */
.icon-sun {
  background: radial-gradient(circle, #FFB703 30%, transparent 70%);
  border-radius: 50%;
  position: relative;
}
.icon-sun::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, #FFB703 20%, transparent 40%);
}

/* Moon icon */
.icon-moon {
  position: relative;
}

/* ── Profile Info Icons ── */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--brand-blue);
  opacity: 0.8;
}

/* ══════════════════════════════════════════
   AUTH PAGES (Login / Register)
   ══════════════════════════════════════════ */

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

/* Decorative background blobs */
.auth-page::before,
.auth-page::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
.auth-page::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #4361EE, transparent);
  top: -150px; left: -150px;
}
.auth-page::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #F72585, transparent);
  bottom: -100px; right: -100px;
}

/* Floating Academic Objects */
.floating-objects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-object {
  position: absolute;
  opacity: 0.6;
  animation: float 6s ease-in-out infinite;
}

.floating-object:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; }
.floating-object:nth-child(2) { top: 20%; right: 8%; animation-delay: 1s; }
.floating-object:nth-child(3) { bottom: 25%; left: 8%; animation-delay: 2s; }
.floating-object:nth-child(4) { bottom: 15%; right: 5%; animation-delay: 0.5s; }
.floating-object:nth-child(5) { top: 40%; left: 2%; animation-delay: 1.5s; }
.floating-object:nth-child(6) { top: 60%; right: 3%; animation-delay: 2.5s; }
.floating-object:nth-child(7) { bottom: 30%; left: 3%; animation-delay: 3s; }
.floating-object:nth-child(8) { bottom: 40%; right: 8%; animation-delay: 0.8s; }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(var(--float-y, -20px)) rotate(var(--float-rot, 5deg)); }
}

.floating-object svg {
  width: 40px;
  height: 40px;
  fill: var(--academic-fill);
  stroke: var(--academic-stroke);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(67,97,238,0.15));
}

/* Vary sizes */
.floating-object:nth-child(odd) svg {
  width: 35px;
  height: 35px;
}

.floating-object:nth-child(3n) svg {
  width: 45px;
  height: 45px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

/* Theme Toggle */
.theme-toggle-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
  z-index: 999;
  box-shadow: var(--shadow-sm);
}
.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  color: var(--brand-blue);
  transform: scale(1.05);
}

/* Back Button */
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 28px;
  transition: var(--transition);
  padding: 6px 0;
}
.auth-back:hover { color: var(--brand-blue); transform: translateX(-3px); }
.auth-back svg { width: 20px; height: 20px; }

/* Auth Logo */
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}
.auth-logo img {
  display: block;
  height: clamp(36px, 6vw, 52px);
  width: auto;
  max-width: min(320px, 85vw);
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  filter: brightness(0.92) drop-shadow(0 10px 30px rgba(67, 97, 238, 0.18));
  animation: logoBrightIn 700ms cubic-bezier(0.22, 1, 0.36, 1) 120ms forwards, logoGlowPulse 3.2s ease-in-out 900ms infinite;
}

@keyframes logoBrightIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1.08) drop-shadow(0 14px 42px rgba(67, 97, 238, 0.28));
  }
}

@keyframes logoGlowPulse {
  0%, 100% {
    filter: brightness(1.02) drop-shadow(0 12px 38px rgba(67, 97, 238, 0.22));
  }
  50% {
    filter: brightness(1.12) drop-shadow(0 18px 54px rgba(247, 37, 133, 0.20));
  }
}

/* Auth Header */
.auth-header { margin-bottom: 32px; }
.auth-header .welcome { font-family: var(--font-display); font-size: 17px; color: var(--text-secondary); font-weight: 400; margin-bottom: 2px; }
.auth-header h1 { font-family: var(--font-display); font-size: 40px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }

/* Alert Messages */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 500;
  border-left: 4px solid;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.alert-error   { background: rgba(255,77,109,0.1); border-color: var(--error); color: var(--error); }
.alert-success { background: rgba(16,217,130,0.1); border-color: var(--success); color: var(--success); }
.alert-info    { background: rgba(76,201,240,0.1); border-color: var(--info); color: var(--info); }

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
  min-width: 300px;
  max-width: 400px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: all;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(100%);
  opacity: 0;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-content {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toast.error {
  border-color: var(--error);
  background: rgba(255,77,109,0.1);
}

.toast.error .toast-icon {
  color: var(--error);
}

.toast.success {
  border-color: var(--success);
  background: rgba(16,217,130,0.1);
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.info {
  border-color: var(--info);
  background: rgba(76,201,240,0.1);
}

.toast.info .toast-icon {
  color: var(--info);
}

/* Form Groups */
.form-group { margin-bottom: 16px; position: relative; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

/* Input error state - Enhanced */
.input-error { 
  border-color: var(--error) !important;
  background: rgba(255, 107, 157, 0.05) !important;
  position: relative;
}

.input-error:focus { 
  border-color: var(--error-light) !important;
  box-shadow: 0 0 0 4px var(--error-glow), 0 0 20px var(--error-glow) !important;
  animation: errorPulse 0.3s ease-in-out;
}

.input-error::placeholder {
  color: var(--error-light);
  opacity: 0.7;
}

/* Field error message below input - Enhanced Modern Design */
.field-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 0;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  background: var(--error-gradient);
  color: white;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: none;
  box-shadow: 0 4px 12px var(--error-glow);
  animation: errorSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.3s ease, transform 0.3s ease;
  cursor: pointer;
  user-select: none;
  width: 100%;
  box-sizing: border-box;
}

/* Special handling for field errors inside input-wrapper */
.input-wrapper > .field-error {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: 0;
  position: relative;
  margin-bottom: 8px;
}

/* Field errors in form-group (default positioning) */
.form-group > .field-error {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: 4px;
  margin-bottom: 8px;
}

/* Ensure input-wrapper maintains proper positioning */
.input-wrapper {
  position: relative;
}

.input-wrapper.has-icon-right {
  position: relative;
}

.input-wrapper.has-icon-right > .field-error {
  margin-bottom: 8px;
}

.input-wrapper > .field-error::after {
  display: block; /* Show triangle pointer when inside input-wrapper */
}

.form-group > .field-error::after {
  display: block; /* Show triangle pointer when in form-group */
}

.field-error:hover {
  transform: translateY(0) scale(1.02);
  box-shadow: 0 6px 16px var(--error-glow);
}

.field-error.dismissing {
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  pointer-events: none;
}

.field-error::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: errorShimmer 2s infinite;
}

.field-error::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid var(--error);
  position: absolute;
  top: -6px;
  left: 16px;
}

/* Form group with error - Enhanced */
.form-group.has-error .form-input,
.form-group.has-error .form-select {
  border-color: var(--error);
  background: rgba(255, 107, 157, 0.05);
  position: relative;
}

.form-group.has-error .form-input:focus,
.form-group.has-error .form-select:focus {
  border-color: var(--error-light);
  box-shadow: 0 0 0 4px var(--error-glow), 0 0 20px var(--error-glow);
  animation: errorPulse 0.3s ease-in-out;
}

.form-group.has-error .form-label {
  color: var(--error);
  font-weight: 600;
}

/* Error animations */
@keyframes errorSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes errorShimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes errorPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Forgot link container styling */
.forgot-link-container {
  margin-top: 8px;
  text-align: right;
}

.forgot-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.forgot-link:hover {
  color: var(--brand-blue);
}

.input-wrapper { position: relative; }

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 16px 20px;
  transition: var(--transition);
  outline: none;
  appearance: none;
}
.form-input:focus {
  border-color: var(--brand-blue);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 4px rgba(67,97,238,0.12);
}
.form-input::placeholder { color: var(--text-placeholder); }
.form-input.has-icon-right { padding-right: 52px; }

/* Password toggle */
.input-icon-right {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  display: flex;
  transition: var(--transition);
  z-index: 10;
}
.input-icon-right:hover { color: var(--brand-blue); }

/* Password Strength */
.password-strength {
  margin-top: 8px;
  display: flex;
  gap: 4px;
}
.strength-bar {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: var(--border-input);
  transition: background 0.3s ease;
}
.strength-bar.active-weak   { background: var(--error); }
.strength-bar.active-medium { background: var(--warning); }
.strength-bar.active-strong { background: var(--success); }
.strength-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* Role Selector */
.role-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}
.role-option { flex: 1; }
.role-option input[type="radio"] { display: none; }
.role-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.role-option input:checked + .role-label {
  border-color: var(--brand-blue);
  background: rgba(67,97,238,0.12);
  color: var(--brand-blue);
}
.role-label:hover { border-color: var(--brand-blue); color: var(--brand-blue); }

/* Forgot Password */
.forgot-link {
  display: block;
  text-align: right;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  margin-top: 8px;
  margin-bottom: 24px;
  transition: var(--transition);
}
.forgot-link:hover { color: var(--brand-blue); }

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 17px 24px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  border: none;
  transition: var(--transition-bounce);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s ease;
}
.btn:hover::after { background: rgba(255,255,255,0.07); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 8px 24px rgba(67,97,238,0.35);
}
.btn-primary:hover { box-shadow: 0 12px 32px rgba(67,97,238,0.45); transform: translateY(-1px); }

.btn-google {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1.5px solid var(--border-input);
  margin-top: 12px;
}
.btn-google:hover { background: var(--bg-card-hover); }

.btn-google img { width: 20px; height: 20px; }

.btn-loading {
  pointer-events: none;
  opacity: 0.8;
}

/* Divider */
.auth-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 16px 0;
  position: relative;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border-color);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }

/* Auth Footer */
.auth-footer {
  text-align: center;
  margin-top: 28px;
  font-size: 14px;
  color: var(--text-secondary);
}
.auth-footer a {
  color: var(--brand-blue);
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
}
.auth-footer a:hover { color: var(--brand-violet); }

.auth-copyright {
  text-align: center;
  margin-top: 36px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════
   PROFILE PAGE
   ══════════════════════════════════════════ */

.profile-page {
  min-height: 100vh;
  background: var(--nav-surface);
  padding-bottom: 80px;
}

/* Top Nav */
.top-nav {
  background: var(--bg-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  position: sticky;
  display: flex;
  align-items: center;
  justify-content: space-between;
  top: 0;
  z-index: 100;
}
.nav-logo img {
  display: block;
  height: clamp(28px, 4.5vw, 34px);
  width: auto;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  filter: brightness(1.02) drop-shadow(0 8px 22px rgba(67, 97, 238, 0.14));
  transition: filter 250ms ease, transform 250ms ease;
}

.nav-logo:hover img {
  filter: brightness(1.12) drop-shadow(0 12px 32px rgba(67, 97, 238, 0.22));
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .auth-logo img {
    animation: none !important;
    opacity: 1;
    transform: none;
    filter: brightness(1.05) drop-shadow(0 12px 34px rgba(67, 97, 238, 0.18));
  }

  .nav-logo img {
    transition: none;
  }
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-icon-btn {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
}
.nav-icon-btn:hover { color: var(--brand-blue); border-color: var(--brand-blue); }

/* Profile Header Card */
.profile-header-card {
  background: var(--nav-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 12px 0;
  position: relative;
}

/* Cover photo gradient */
.profile-cover {
  height: 120px;
  background: var(--nav-surface);
  border-radius: 0;
  margin-bottom: -45px;
  position: relative;
  overflow: hidden;
}
.profile-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: none;
}

/* Avatar */
.profile-avatar-wrap {
  margin-top: -48px;
  position: relative;
  display: inline-block;
  margin-bottom: 12px;
}
.profile-avatar {
  width: 90px; height: 90px;
  border-radius: var(--radius-full);
  border: 4px solid var(--nav-surface);
  object-fit: cover;
  background: transparent;
  box-shadow: none;
}
.avatar-edit-btn {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--brand-blue);
  border: 2px solid var(--nav-surface);
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: var(--transition);
}
.avatar-edit-btn:hover { background: var(--brand-violet); transform: scale(1.1); }

.profile-name { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-bottom: 2px; }
.profile-pronoun { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.profile-school { font-size: 18px; color: var(--text-secondary); margin-top: 4px; font-weight: 600; }
.profile-username { font-size: 16px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.profile-level { font-size: 17px; color: var(--text-muted); }

.profile-stats {
  display: flex;
  gap: 24px;
  margin: 14px 0 0;
  padding-bottom: 16px;
}
.stat { font-size: 17px; color: var(--text-muted); }
.stat strong { color: var(--text-primary); font-family: var(--font-display); font-weight: 700; }

/* Profile Actions */
.profile-actions {
  display: flex;
  gap: 10px;
  margin: 16px 0 0;
  padding-bottom: 0;
}
.profile-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: var(--transition-bounce);
  text-align: center;
}
.profile-btn-primary {
  background: rgba(67,97,238,0.15);
  color: var(--brand-blue);
  border: 1.5px solid rgba(67,97,238,0.3);
}
.profile-btn-primary:hover { background: rgba(67,97,238,0.25); }
.profile-btn-icon {
  flex: 0 0 48px;
  width: 48px;
  padding: 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.profile-btn-icon:hover { border-color: var(--brand-blue); color: var(--brand-blue); }

/* Profile Tabs */
.profile-tabs {
  display: flex;
  background: var(--nav-surface);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  scrollbar-width: none;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.tab-item {
  flex: 1;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 8px;
  font-size: 24px;
  color: var(--tab-inactive);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  border-radius: 0;
  background: none;
  border-left: none; border-right: none; border-top: none;
}
.tab-item.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }
.tab-item:hover { color: var(--brand-blue); }

/* Responsive Icon Sizing */
@media (max-width: 768px) {
  .tab-item {
    font-size: 20px;
    padding: 12px 6px;
  }
  
  .profile-btn-icon {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .tab-item {
    font-size: 18px;
    padding: 10px 4px;
    min-width: 56px;
  }
  
  .profile-btn-icon {
    font-size: 14px;
    width: 44px;
    flex: 0 0 44px;
  }
}

/* Profile Content */
.profile-content { padding: 20px; }

/* Grid tab content */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.post-placeholder {
  aspect-ratio: 1;
  background: var(--nav-hover);
  border-radius: 0;
  border: none;
}

/* Profile Content Centering on Desktop Landscape */
@media (min-width: 1024px) and (orientation: landscape) {
  .profile-header-card,
  .profile-tabs,
  .profile-content {
    max-width: 1000px;
    margin: 0 auto;
  }
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-sheet {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  width: fit-content;
  min-width: 400px;
  max-width: min(90vw, 800px);
  /* Let modal size itself to content */
  height: auto;
  min-height: 200px;
  max-height: min(90vh, 800px); /* Cap at 90vh or 800px whichever is smaller */
  padding: 24px 20px 40px;
  transform: scale(0.95);
  transition: transform 0.35s cubic-bezier(0.34, 1.1, 0.64, 1);
  overflow-x: hidden;
  overflow-y: auto; /* Allow scrolling if content exceeds max-height */
}
.modal-overlay.active .modal-sheet { transform: scale(1); }

.modal-handle {
  width: 40px; height: 4px;
  background: var(--border-color);
  border-radius: 99px;
  margin: 0 auto 24px;
}
.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin-bottom: 24px; }

/* Contribute Option Buttons */
.contribute-option {
  width: 100%;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.contribute-option:hover {
  background: var(--bg-card-hover);
  border-color: var(--brand-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* File Preview Styles */
#filePreview {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#filePreview video {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

/* Two-Column Layout for Contribute Details */
.contribute-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.preview-column {
  display: flex;
  flex-direction: column;
}

.form-column {
  display: flex;
  flex-direction: column;
}

/* Responsive: Single Column on Mobile */
@media (max-width: 768px) {
  .contribute-two-column {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .preview-column {
    order: 2; /* Form first on mobile, then preview */
  }

  .form-column {
    order: 1;
  }
}

/* File Input Drag & Drop Styles */
#fileInput {
  transition: all 0.2s ease;
}

#fileInput:hover {
  border-color: var(--brand-blue);
  background: rgba(67, 97, 238, 0.05);
}

#fileInput:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-nav);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 20px 14px;
  z-index: 100;
}
.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  transition: var(--transition);
  background: none;
  border: none;
  font-size: 22px;
  text-decoration: none;
}
.bottom-nav .nav-item:hover, .bottom-nav .nav-item.active { color: var(--brand-blue); }
.nav-item-profile {
  background: var(--bg-card);
  border-radius: var(--radius-full);
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--brand-blue);
  box-shadow: 0 4px 12px rgba(67,97,238,0.3);
}
.nav-item-profile.active { background: var(--brand-blue); color: white !important; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* Loading spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (min-width: 1024px) {
  .auth-page { padding: 60px 32px; }
  
  /* Extra large floating objects on desktop */
  .floating-object svg {
    width: 60px;
    height: 60px;
  }
  .floating-object:nth-child(odd) svg {
    width: 55px;
    height: 55px;
  }
  .floating-object:nth-child(3n) svg {
    width: 65px;
    height: 65px;
  }
}

@media (min-width: 640px) {
  .auth-page { padding: 40px 24px; }
  .profile-header-card { padding: 24px 28px 0; }
  .profile-content { padding: 24px 28px; }
  
  /* Larger floating objects on desktop */
  .floating-object svg {
    width: 50px;
    height: 50px;
  }
  .floating-object:nth-child(odd) svg {
    width: 45px;
    height: 45px;
  }
  .floating-object:nth-child(3n) svg {
    width: 55px;
    height: 55px;
  }
}

@media (max-width: 768px) {
  .auth-page { padding: 20px 16px; }
  
  /* Medium floating objects on tablets */
  .floating-object svg {
    width: 35px;
    height: 35px;
  }
  .floating-object:nth-child(odd) svg {
    width: 30px;
    height: 30px;
  }
  .floating-object:nth-child(3n) svg {
    width: 40px;
    height: 40px;
  }
  
  /* Reduce animation intensity on tablets */
  .floating-object {
    animation-duration: 8s;
  }

  .floating-objects {
    --float-y: -15px;
    --float-rot: 3deg;
  }
}

@media (max-width: 480px) {
  .auth-page { padding: 16px 12px; }
  
  /* Small floating objects on mobile */
  .floating-object svg {
    width: 25px;
    height: 25px;
  }
  .floating-object:nth-child(odd) svg {
    width: 20px;
    height: 20px;
  }
  .floating-object:nth-child(3n) svg {
    width: 30px;
    height: 30px;
  }
  
  /* Further reduce animation on mobile */
  .floating-object {
    animation-duration: 10s;
    opacity: 0.4;
  }

  .floating-objects {
    --float-y: -10px;
    --float-rot: 2deg;
  }
}

@media (max-width: 320px) {
  .auth-page { padding: 12px 8px; }
  
  /* Minimal floating objects on small screens */
  .floating-object svg {
    width: 20px;
    height: 20px;
  }
  .floating-object:nth-child(odd) svg {
    width: 18px;
    height: 18px;
  }
  .floating-object:nth-child(3n) svg {
    width: 22px;
    height: 22px;
  }
  
  /* Minimal animation on very small screens */
  .floating-object {
    animation-duration: 12s;
    opacity: 0.3;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.4s ease forwards; }
.fade-in-delay-1 { animation-delay: 0.1s; opacity: 0; }
.fade-in-delay-2 { animation-delay: 0.2s; opacity: 0; }
.fade-in-delay-3 { animation-delay: 0.3s; opacity: 0; }

/* ── Login Preloader (Instagram-style) ── */
.login-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.login-preloader.show {
  opacity: 1;
  visibility: visible;
}

.login-preloader-content {
  text-align: center;
}

.login-preloader-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  animation: preloaderPulse 1.5s ease-in-out infinite;
}

@keyframes preloaderPulse {
  0%, 100% { 
    opacity: 0.8;
    transform: scale(1);
  }
  50% { 
    opacity: 1;
    transform: scale(1.05);
  }
}

/* ── Instagram-like Navigation ── */

/* Top Navbar */
.top-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--nav-surface);
  border-bottom: none;
  z-index: 1100;
}

.top-navbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.top-navbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-toggle {
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  border-radius: 12px;
  cursor: pointer;
}

.topbar-toggle:hover {
  background: var(--bg-card-hover);
}

.top-navbar-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.top-navbar-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(14px, 1.4vw, 18px);
  color: var(--text-primary);
  line-height: 1;
  white-space: nowrap;
}

.top-navbar-logo img {
  height: 34px;
  width: auto;
  max-width: min(240px, 55vw);
  display: block;
  border-radius: 12px;
}

.top-navbar-right {
  display: flex;
  align-items: center;
}

.top-navbar-action {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-primary);
  border-radius: 12px;
}

.top-navbar-action:hover {
  background: var(--nav-hover);
}

@media (min-width: 769px) {
  .top-navbar-right {
    display: none;
  }
}

/* Desktop Sidebar */
.desktop-sidebar {
  --desktop-sidebar-width: 76px;
  --desktop-sidebar-expanded-width: 230px;
  --desktop-nav-icon-size: 26px;
  --desktop-nav-label-size: 15px;
  --desktop-nav-item-gap: 14px;
  --desktop-nav-item-gap-collapsed: 0px;
  --desktop-nav-item-py: 14px;
  --desktop-nav-item-px: 18px;
  --desktop-nav-item-px-collapsed: 12px;
  --desktop-nav-item-mx: 8px;
  position: fixed;
  top: 60px;
  left: 0;
  width: var(--desktop-sidebar-width);
  height: calc(100vh - 60px);
  background: var(--nav-surface);
  border-right: none;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(0);
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
  box-shadow: none;
  overflow-x: hidden;
}

.desktop-sidebar:hover,
.desktop-sidebar:focus-within {
  width: var(--desktop-sidebar-expanded-width);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.14);
}

@media (min-width: 769px) {
  .desktop-sidebar {
    display: flex;
  }
}

/* Small desktop: preserve icon clarity, compress spacing */
@media (min-width: 769px) and (max-width: 1099px) {
  .desktop-sidebar {
    --desktop-sidebar-width: 72px;
    --desktop-sidebar-expanded-width: 206px;
    --desktop-nav-label-size: 13px;
    --desktop-nav-item-gap: 10px;
    --desktop-nav-item-py: 10px;
    --desktop-nav-item-px: 12px;
    --desktop-nav-item-px-collapsed: 10px;
    --desktop-nav-item-mx: 6px;
  }
}

/* Medium desktop */
@media (min-width: 1100px) and (max-width: 1439px) {
  .desktop-sidebar {
    --desktop-sidebar-width: 76px;
    --desktop-sidebar-expanded-width: 230px;
    --desktop-nav-label-size: 14px;
    --desktop-nav-item-gap: 12px;
    --desktop-nav-item-py: 12px;
    --desktop-nav-item-px: 16px;
    --desktop-nav-item-px-collapsed: 11px;
    --desktop-nav-item-mx: 8px;
  }
}

/* Large desktop */
@media (min-width: 1440px) {
  .desktop-sidebar {
    --desktop-sidebar-width: 82px;
    --desktop-sidebar-expanded-width: 280px;
    --desktop-nav-label-size: 16px;
    --desktop-nav-item-gap: 16px;
    --desktop-nav-item-py: 15px;
    --desktop-nav-item-px: 20px;
    --desktop-nav-item-px-collapsed: 12px;
    --desktop-nav-item-mx: 10px;
  }
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}

.sidebar-nav .nav-item,
.sidebar-bottom .nav-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: var(--desktop-nav-item-gap-collapsed);
  padding: var(--desktop-nav-item-py) var(--desktop-nav-item-px-collapsed);
  margin: 2px var(--desktop-nav-item-mx);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: var(--desktop-nav-label-size);
  transition: background-color 0.15s ease, color 0.15s ease, gap 0.2s ease, padding 0.2s ease;
  position: relative;
  border-radius: var(--radius-md);
}

.desktop-sidebar:hover .sidebar-nav .nav-item,
.desktop-sidebar:focus-within .sidebar-nav .nav-item,
.desktop-sidebar:hover .sidebar-bottom .nav-item,
.desktop-sidebar:focus-within .sidebar-bottom .nav-item {
  gap: var(--desktop-nav-item-gap);
  padding: var(--desktop-nav-item-py) var(--desktop-nav-item-px);
}

.sidebar-nav .nav-item:hover,
.sidebar-bottom .nav-item:hover {
  background: var(--nav-hover);
  color: var(--text-primary);
}

.sidebar-nav .nav-item.active,
.sidebar-bottom .nav-item.active {
  color: var(--text-primary);
  background: var(--nav-active);
}

.sidebar-nav .nav-item.active:hover,
.sidebar-bottom .nav-item.active:hover {
  background: var(--nav-active);
}

.sidebar-nav .nav-item svg {
  flex-shrink: 0;
  width: var(--desktop-nav-icon-size);
  height: var(--desktop-nav-icon-size);
}

.sidebar-nav .nav-item span,
.sidebar-bottom .nav-item span {
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition: max-width 0.2s ease, opacity 0.16s ease, transform 0.2s ease;
  pointer-events: none;
}

.desktop-sidebar:hover .sidebar-nav .nav-item span,
.desktop-sidebar:focus-within .sidebar-nav .nav-item span,
.desktop-sidebar:hover .sidebar-bottom .nav-item span,
.desktop-sidebar:focus-within .sidebar-bottom .nav-item span {
  max-width: 160px;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.sidebar-bottom {
  padding: 10px 0;
  border-top: 1px solid var(--border-color);
}

.nav-avatar {
  width: var(--desktop-nav-icon-size);
  height: var(--desktop-nav-icon-size);
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.nav-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sidebar-actions {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contribute-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--brand-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-bounce);
  box-shadow: var(--shadow-md);
}

.contribute-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.settings-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 0;
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  text-align: left;
}

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

/* Mobile Bottom Navigation - Instagram Style */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--nav-surface);
  border-top: none;
  display: none;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 1100;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  gap: 0;
}

@media (min-width: 769px) and (max-width: 1023px) {
  .topbar-toggle {
    display: inline-flex;
  }
}


/* Enhanced mobile nav for small phones */
@media (max-width: 380px) {
  .mobile-bottom-nav {
    height: 65px;
    padding: 0 4px;
  }
}

@media (max-width: 320px) {
  .mobile-bottom-nav {
    height: 60px;
  }
}

.mobile-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 12px;
  min-width: 52px;
  position: relative;
  flex: 0 0 auto;
}

.mobile-bottom-nav .nav-item::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 4px;
  height: 4px;
  background: var(--brand-blue);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.mobile-bottom-nav .nav-item:hover {
  color: var(--text-secondary);
  background: var(--nav-hover);
  transform: translateY(-2px);
}

.mobile-bottom-nav .nav-item.active {
  color: var(--brand-blue);
  transform: translateY(-2px);
}

.mobile-bottom-nav .nav-item.active::after {
  transform: translateX(-50%) scaleX(1);
}

.mobile-bottom-nav .nav-item svg {
  width: 24px;
  height: 24px;
  transition: all 0.2s ease;
}

.mobile-bottom-nav .nav-item:hover svg {
  transform: scale(1.1);
}

.mobile-bottom-nav .nav-item.active svg {
  transform: scale(1.15);
  filter: drop-shadow(0 2px 8px rgba(67, 97, 238, 0.3));
}

.mobile-bottom-nav .nav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--brand-blue);
}

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




/* Keep content width aligned with collapsed desktop sidebar widths */
@media (min-width: 769px) and (max-width: 1099px) {
  .profile-page {
    max-width: calc(100vw - 72px);
    margin: 0 auto;
  }
}

@media (min-width: 1100px) and (max-width: 1439px) {
  .profile-page {
    max-width: calc(100vw - 76px);
    margin: 0 auto;
  }
}

@media (min-width: 1440px) {
  .profile-page {
    max-width: calc(100vw - 82px);
    margin: 0 auto;
  }
}
@media (min-width: 769px) {
  .main-content {
    margin-left: 0;
  }
}

@media (min-width: 1400px) {
  .main-content {
    margin-left: 0;
  }
}

@media (min-width: 1800px) {
  .main-content {
    margin-left: 0;
  }
}
@media (min-width: 1400px) {
  .main-content {
    margin-left: 0;
  }
}

@media (min-width: 1800px) {
  .main-content {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    padding-bottom: 70px; /* Account for mobile bottom nav */
  }
}

@media (max-width: 380px) {
  .main-content {
    padding-bottom: 65px;
  }
}

@media (max-width: 320px) {
  .main-content {
    padding-bottom: 60px;
  }
}


/* Instagram-like loading animations */
@keyframes navItemSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animate nav items on load */
.desktop-sidebar .nav-item {
  opacity: 1;
}

.desktop-sidebar .nav-item:nth-child(1) { animation-delay: 0.1s; }
.desktop-sidebar .nav-item:nth-child(2) { animation-delay: 0.15s; }
.desktop-sidebar .nav-item:nth-child(3) { animation-delay: 0.2s; }
.desktop-sidebar .nav-item:nth-child(4) { animation-delay: 0.25s; }

/* Mobile nav items animation */
.mobile-bottom-nav .nav-item {
  opacity: 1;
}

.mobile-bottom-nav .nav-item:nth-child(1) { animation-delay: 0.05s; }
.mobile-bottom-nav .nav-item:nth-child(2) { animation-delay: 0.1s; }
.mobile-bottom-nav .nav-item:nth-child(3) { animation-delay: 0.15s; }
.mobile-bottom-nav .nav-item:nth-child(4) { animation-delay: 0.2s; }
.mobile-bottom-nav .nav-item:nth-child(5) { animation-delay: 0.25s; }





/* Smooth transitions for theme changes */
.desktop-sidebar,
.mobile-bottom-nav,
.top-navbar {
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Focus states for accessibility */
.nav-item:focus,
.top-navbar-logo:focus {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .desktop-sidebar .nav-item,
  .mobile-bottom-nav .nav-item {
    opacity: 1;
  }
  
  .sidebar-nav .nav-item:hover,
  .mobile-bottom-nav .nav-item:hover {
    transform: none;
  }
}

@media (max-width: 768px) {
  body {
    padding-left: 0 !important;
  }

  .desktop-sidebar {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }
}

@media (min-width: 769px) {
  body {
    padding-left: 76px !important;
  }

  .desktop-sidebar {
    display: flex !important;
  }

  .mobile-bottom-nav {
    display: none !important;
  }
}

@media (min-width: 769px) and (max-width: 1099px) {
  body {
    padding-left: 72px !important;
  }
}

@media (min-width: 1100px) and (max-width: 1439px) {
  body {
    padding-left: 76px !important;
  }
}

@media (min-width: 1440px) {
  body {
    padding-left: 82px !important;
  }
}

/* Profile Contribution List UI */
.contribution-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contribution-list-item {
  display: grid;
  grid-template-columns: 132px 1fr auto;
  gap: 14px;
  align-items: stretch;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.contribution-list-item.compact {
  grid-template-columns: 1fr auto;
}

.contribution-mini-preview {
  width: 132px;
  height: 92px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: var(--bg-input);
}

.contribution-mini-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.contribution-list-title {
  display: block;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 16px;
  text-decoration: none;
  margin-bottom: 6px;
}

.contribution-list-title:hover {
  color: var(--brand-blue);
}

.contribution-list-meta {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 4px;
}

.contribution-list-stats {
  color: var(--text-muted);
  font-size: 12px;
}

.contribution-list-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Upload progress modal */
.upload-progress-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
}

.upload-progress-modal.active {
  display: flex;
}

.upload-progress-card {
  width: min(92vw, 420px);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  text-align: center;
}

.upload-book-anim {
  width: 100px;
  height: 72px;
  margin: 8px auto 14px;
  position: relative;
}

.upload-book {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 2px solid var(--brand-blue);
  background: linear-gradient(140deg, rgba(67,97,238,0.18), rgba(67,97,238,0.06));
  transform-origin: left center;
  animation: bookOpen 1.15s ease-in-out infinite alternate;
}

.upload-book.success {
  animation: none;
  transform: rotateY(0deg);
}

.upload-pen {
  position: absolute;
  width: 52px;
  height: 6px;
  right: -12px;
  bottom: 12px;
  background: var(--brand-pink);
  border-radius: 999px;
  transform: rotate(-18deg);
  opacity: 0;
}

.upload-pen.success {
  opacity: 1;
  transition: opacity 0.25s ease;
}

.upload-progress-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-progress-text {
  font-size: 14px;
  color: var(--text-secondary);
}

@keyframes bookOpen {
  0% { transform: perspective(180px) rotateY(0deg); }
  100% { transform: perspective(180px) rotateY(-36deg); }
}

@media (max-width: 768px) {
  .contribution-list-item {
    grid-template-columns: 1fr;
  }

  .contribution-mini-preview {
    width: 100%;
    height: 180px;
  }

  .contribution-list-actions {
    justify-content: flex-end;
  }
}

/* Profile redesign and contribution preview refinement */
.profile-page-modern {
  max-width: 980px;
  margin: 0 auto;
  padding-bottom: 32px;
}

.profile-header-modern {
  border: 1px solid var(--border-color);
  border-radius: 18px;
  overflow: hidden;
  margin: 20px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-secondary));
}

.profile-header-modern .profile-cover {
  height: 138px;
  background: linear-gradient(120deg, rgba(67,97,238,0.2), rgba(76,201,240,0.16), rgba(45,212,191,0.15));
}

.profile-header-inner {
  padding: 0 18px 0 18px;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-identity {
  padding-bottom: 6px;
}

.profile-stats-modern {
  border-top: 1px solid var(--border-color);
  margin: 12px 0 0;
  padding: 14px 18px;
  gap: 14px;
}

.profile-stats-modern .stat {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.profile-stats-modern .stat span {
  color: var(--text-secondary);
  font-size: 13px;
}

.profile-content-modern {
  padding: 16px 20px 0;
}

.contribution-list-modern {
  gap: 12px;
}

.contribution-card-modern {
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--bg-card), var(--bg-secondary));
}

.contribution-card-modern .contribution-list-title {
  line-height: 1.4;
  word-break: break-word;
}

.contribution-card-modern .contribution-list-meta,
.contribution-card-modern .contribution-list-stats {
  line-height: 1.45;
  word-break: break-word;
}

.profile-about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.profile-about-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  padding: 12px 14px;
}

.profile-about-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-about-value {
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
}

.contribution-preview-page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.contribution-breadcrumb {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 13px;
}

.contribution-breadcrumb a {
  color: var(--brand-blue);
  text-decoration: none;
}

.contribution-preview-shell {
  background: linear-gradient(180deg, var(--bg-card), var(--bg-secondary));
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
}

.contribution-preview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.contribution-preview-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.2;
  margin-bottom: 8px;
  word-break: break-word;
}

.contribution-preview-meta {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.contribution-preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.contribution-preview-frame-wrap {
  margin-top: 18px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-input);
  min-height: 56vh;
}

.contribution-preview-frame {
  width: 100%;
  height: min(72vh, 920px);
  border: 0;
}

.contribution-preview-empty {
  min-height: 56vh;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
  gap: 10px;
  padding: 24px;
}

.contribution-preview-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

.contribution-preview-description {
  margin-top: 16px;
  color: var(--text-secondary);
  line-height: 1.65;
  word-break: break-word;
}

.contribution-preview-foot {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.contribution-preview-foot a {
  color: var(--brand-blue);
  text-decoration: none;
}

.upload-progress-card {
  position: relative;
  overflow: hidden;
}

.upload-progress-card.uploading .upload-book {
  animation: bookOpen 1.15s ease-in-out infinite alternate;
}

.upload-progress-card.uploading .upload-pen {
  opacity: 1;
  animation: penWrite 1.2s ease-in-out infinite;
}

.upload-writing-line {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 10px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--brand-blue), transparent);
  opacity: 0;
}

.upload-progress-card.uploading .upload-writing-line {
  opacity: 0.95;
  animation: writingScan 1.4s linear infinite;
}

.upload-progress-card.success .upload-book {
  animation: none;
  transform: perspective(180px) rotateY(0deg) scale(0.97);
}

.upload-progress-card.success .upload-pen {
  animation: none;
  opacity: 0.9;
  transform: rotate(-22deg) translateX(-8px);
}

.upload-progress-card.success .upload-writing-line {
  animation: none;
  opacity: 0;
}

@keyframes penWrite {
  0% { transform: rotate(-18deg) translateX(0); }
  50% { transform: rotate(-15deg) translateX(-8px); }
  100% { transform: rotate(-20deg) translateX(0); }
}

@keyframes writingScan {
  0% { transform: translateX(-18px); }
  100% { transform: translateX(18px); }
}

@media (max-width: 768px) {
  .profile-header-modern {
    margin: 12px;
  }

  .profile-content-modern {
    padding: 12px;
  }

  .profile-about-grid {
    grid-template-columns: 1fr;
  }

  .contribution-preview-page {
    padding: 12px;
  }

  .contribution-preview-frame-wrap {
    min-height: 48vh;
  }

  .contribution-preview-frame {
    height: 64vh;
  }
}

/* Contribution modal polish */
.document-dropdown-modal {
  backdrop-filter: blur(6px);
}

.document-dropdown-content {
  width: min(560px, 95vw) !important;
  max-width: min(560px, 95vw) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 18px !important;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-secondary)) !important;
}

.document-dropdown-content > div {
  padding: 22px !important;
}

.document-type-option-modal {
  border: 1px solid var(--border-color) !important;
  background: var(--bg-secondary) !important;
  border-radius: 14px !important;
  box-shadow: inset 0 0 0 1px transparent;
}

.document-type-option-modal:hover {
  border-color: var(--brand-blue) !important;
  transform: translateY(-2px) !important;
  background: var(--bg-card) !important;
}

.document-type-option-modal.selected {
  border-color: var(--brand-blue) !important;
  box-shadow: 0 0 0 2px rgba(67,97,238,0.22) !important;
}

.upload-book {
  animation: none;
}

/* Final UI customization pass: profile + contribution + loader */
.profile-page.profile-page-modern {
  background: transparent;
}

.profile-page-modern .profile-header-modern {
  margin: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-secondary);
  box-shadow: none;
}

.profile-page-modern .profile-cover {
  position: relative;
  height: 164px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(130deg, rgba(67,97,238,0.26), rgba(76,201,240,0.2), rgba(45,212,191,0.18));
  background-size: cover;
  background-position: center;
}

.profile-page-modern .profile-cover.has-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  filter: blur(0px) saturate(1.05);
}

.profile-page-modern .profile-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.26));
}

.profile-cover-logo {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  display: grid;
  place-items: center;
  z-index: 2;
  backdrop-filter: blur(2px);
}

.profile-cover-logo img {
  width: 18px;
  height: 18px;
  opacity: 0.95;
}

.profile-page-modern .profile-header-inner {
  margin-top: -22px;
  padding: 0 16px;
}

.profile-page-modern .profile-avatar {
  width: 96px;
  height: 96px;
  border: 3px solid var(--bg-secondary);
  background: var(--bg-card);
}

.profile-page-modern .profile-name {
  font-size: 28px;
  line-height: 1.1;
  margin-bottom: 0;
}

.profile-page-modern .profile-username {
  margin-top: 3px;
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 600;
}

.profile-page-modern .profile-stats-modern {
  margin-top: 10px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border-color);
}

.profile-page-modern .profile-stats-modern .stat {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
  padding: 10px 13px;
}

.profile-page-modern .profile-stats-modern .stat strong {
  font-size: 18px;
}

.profile-page-modern .profile-content-modern {
  padding: 12px 16px;
}

.profile-page-modern .profile-tabs {
  margin: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  overflow: hidden;
}

.profile-page-modern .tab-item {
  padding: 12px 10px;
}

.profile-page-modern .contribution-card-modern {
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.profile-action-btn {
  min-width: 92px;
  justify-content: center;
}

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

.contribution-preview-shell {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.contribution-preview-actions .contribution-action-btn {
  min-width: 122px;
  justify-content: center;
  border-radius: 10px;
}

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

.contribution-preview-frame-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.upload-logo-anim {
  position: relative;
  width: 96px;
  height: 96px;
  margin: 6px auto 12px;
  display: grid;
  place-items: center;
}

.upload-logo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(67,97,238,0.24);
  border-top-color: var(--brand-blue);
  animation: logoSpin 1s linear infinite;
}

.upload-logo {
  width: 44px;
  height: 44px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.upload-success-tick {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--success);
  color: #fff;
  opacity: 0;
  transform: scale(0.7);
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.upload-progress-card.uploading .upload-logo-ring {
  animation: logoSpin 1s linear infinite;
}

.upload-progress-card.success .upload-logo-ring {
  animation: none;
  border-color: rgba(34,197,94,0.25);
}

.upload-progress-card.success .upload-logo {
  opacity: 0;
  transform: scale(0.78);
}

.upload-progress-card.success .upload-success-tick {
  opacity: 1;
  transform: scale(1);
}

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

@media (max-width: 768px) {
  .profile-page-modern .profile-header-modern,
  .profile-page-modern .profile-tabs,
  .profile-page-modern .profile-content-modern {
    margin-left: 10px;
    margin-right: 10px;
  }

  .profile-page-modern .profile-content-modern {
    padding-left: 0;
    padding-right: 0;
  }

  .contribution-preview-actions .contribution-action-btn {
    flex: 1;
    min-width: 0;
  }
}

/* Cover edit and no-card profile data layout */
.cover-edit-btn {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.28);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.cover-edit-btn:hover {
  background: rgba(0,0,0,0.4);
}

.profile-page-modern .profile-avatar-wrap {
  margin-top: -48px;
}

.profile-page-modern .profile-stats-modern {
  border-top: 1px solid var(--border-color);
  gap: 26px;
}

.profile-page-modern .profile-stats-modern .stat {
  background: transparent;
  border: 0;
  padding: 0;
}

.profile-page-modern .profile-tabs {
  border: 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
  margin-top: 0;
}

.profile-page-modern .profile-content-modern {
  background: transparent;
}

/* 2026 polish: premium upload loader + true black dark mode feel */
.upload-progress-modal {
  background: radial-gradient(circle at 50% 20%, rgba(67,97,238,0.22), rgba(0,0,0,0.76) 42%, rgba(0,0,0,0.92) 100%);
  backdrop-filter: blur(10px) saturate(1.06);
}

.upload-progress-card {
  width: min(92vw, 420px);
  padding: 24px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg-card), var(--bg-secondary));
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
}

.upload-progress-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.upload-progress-text {
  color: var(--text-secondary);
}

.upload-logo-anim {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 8px auto 14px;
  display: grid;
  place-items: center;
}

.upload-logo-anim::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(67,97,238,0.32), rgba(67,97,238,0.08) 60%, transparent 70%);
  animation: pulseHalo 1.8s ease-in-out infinite;
}

.upload-logo-ring {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.14);
  border-top-color: #89a4ff;
  border-right-color: var(--brand-blue);
  animation: logoSpin 1s linear infinite;
  box-shadow: 0 0 20px rgba(67,97,238,0.2);
}

.upload-logo {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 8px 16px rgba(67,97,238,0.35));
  transition: transform 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.upload-success-tick {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #17d879, #0fa862);
  box-shadow: 0 12px 26px rgba(16,217,130,0.38);
}

.upload-progress-card.success .upload-logo-ring {
  animation: none;
  border-color: rgba(16,216,121,0.42);
  box-shadow: 0 0 24px rgba(16,216,121,0.28);
}

.upload-progress-card.success .upload-logo {
  opacity: 0;
  transform: scale(0.78);
  filter: blur(1px);
}

@keyframes pulseHalo {
  0%, 100% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.08); opacity: 0.95; }
}

[data-theme="dark"] .upload-progress-card {
  background: linear-gradient(180deg, #121212, #090909);
  border-color: rgba(255,255,255,0.16);
}


/* Contribution action buttons: keep inline with icons */
.contribution-preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

.contribution-preview-actions .contribution-action-btn {
  min-width: 122px;
  justify-content: center;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .contribution-preview-actions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .contribution-preview-actions .contribution-action-btn {
    flex: 0 0 auto;
  }
}

/* Mobile hardening: prevent profile overflow on small devices */
@media (max-width: 768px) {
  .main-content {
    padding-left: 0;
    padding-right: 0;
  }

  .profile-page-modern {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: hidden;
  }

  .profile-page-modern,
  .profile-page-modern * {
    box-sizing: border-box;
  }

  .profile-page-modern .profile-header-modern,
  .profile-page-modern .profile-tabs,
  .profile-page-modern .profile-content-modern {
    margin-left: 8px;
    margin-right: 8px;
    max-width: calc(100vw - 16px);
  }

  .profile-page-modern .profile-content-modern {
    padding-top: 10px;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .profile-page-modern .profile-cover {
    height: 168px;
  }

  .profile-page-modern .profile-avatar {
    width: 92px;
    height: 92px;
  }

  .profile-page-modern .profile-name {
    font-size: 24px;
  }

  .profile-page-modern .profile-stats-modern {
    flex-wrap: wrap;
    gap: 14px;
  }

  .profile-page-modern .contribution-list-item,
  .profile-page-modern .contribution-list-item.compact {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .profile-page-modern .contribution-mini-preview {
    width: 100%;
    height: 170px;
  }

  .profile-page-modern .contribution-list-meta,
  .profile-page-modern .contribution-list-stats,
  .profile-page-modern .contribution-list-title {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .profile-page-modern .contribution-list-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .profile-page-modern .profile-header-modern,
  .profile-page-modern .profile-tabs,
  .profile-page-modern .profile-content-modern {
    margin-left: 6px;
    margin-right: 6px;
    max-width: calc(100vw - 12px);
  }

  .profile-page-modern .profile-cover {
    height: 154px;
  }

  .profile-page-modern .profile-avatar {
    width: 84px;
    height: 84px;
  }

  .profile-page-modern .profile-name {
    font-size: 21px;
  }

  .profile-page-modern .profile-stats-modern .stat {
    width: 100%;
  }
}


/* Final fix: contribution action buttons responsive on small screens */
@media (max-width: 768px) {
  .contribution-preview-actions {
    width: 100%;
    gap: 8px;
    overflow: visible !important;
  }

  .contribution-preview-actions .contribution-action-btn {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* User search overlay */
.user-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 74px 14px 14px;
}

.user-search-overlay.active {
  display: flex;
}

.user-search-panel {
  width: min(620px, 96vw);
  max-height: calc(100vh - 92px);
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

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

.user-search-header h3 {
  font-size: 16px;
}

.user-search-close {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.user-search-input-wrap {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.user-search-results {
  overflow-y: auto;
  padding: 8px;
}

.user-search-item {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 10px;
  border-radius: 10px;
}

.user-search-item:hover {
  background: var(--bg-input);
}

.user-search-item img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.user-search-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-search-meta strong,
.user-search-meta span,
.user-search-meta p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-search-meta strong {
  color: var(--text-primary);
  font-size: 14px;
}

.user-search-meta span {
  color: var(--text-secondary);
  font-size: 13px;
}

.user-search-meta p {
  color: var(--text-muted);
  font-size: 12px;
}

.user-search-hint {
  color: var(--text-muted);
  padding: 12px;
  text-align: center;
}

.mobile-search-trigger {
  display: none;
  position: sticky;
  top: 60px;
  z-index: 20;
  margin: 8px 10px 0;
}

.mobile-search-trigger button {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.profile-social-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 16px 16px;
}

.profile-social-actions form {
  display: inline-flex;
}

.messages-shell {
  max-width: 1120px;
  margin: 18px auto 24px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-secondary);
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 130px);
  overflow: hidden;
}

.messages-sidebar {
  border-right: 1px solid var(--border-color);
  padding: 14px;
}

.messages-sidebar h2 {
  margin-bottom: 12px;
  font-size: 22px;
}

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

.thread-item {
  display: flex;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
}

.thread-item.active,
.thread-item:hover {
  border-color: var(--brand-blue);
  background: var(--bg-card);
}

.thread-item img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.thread-item p {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.messages-chat {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.chat-header {
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 14px;
  background: var(--bg-card);
}

.chat-header img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-header p {
  color: var(--text-secondary);
  font-size: 13px;
}

.chat-messages {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.chat-bubble {
  max-width: 72%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
}

.chat-bubble.mine {
  align-self: flex-end;
  background: rgba(67, 97, 238, 0.16);
  border-color: rgba(67, 97, 238, 0.5);
}

.chat-bubble small {
  color: var(--text-muted);
  font-size: 11px;
}

.chat-form {
  border-top: 1px solid var(--border-color);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.messages-placeholder,
.messages-empty {
  color: var(--text-muted);
}

.messages-placeholder {
  margin: auto;
}

@media (max-width: 900px) {
  .messages-shell {
    grid-template-columns: 1fr;
  }

  .messages-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
  }

  .thread-item p {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .mobile-search-trigger {
    display: block;
  }

  .user-search-overlay {
    padding-top: 68px;
  }

  .profile-social-actions {
    padding-bottom: 12px;
  }
}

/* Profile contribution file-type icon preview */
.contribution-file-icon {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--bg-card), var(--bg-secondary));
}

.contribution-file-icon.pdf {
  color: #e63946;
}

.contribution-file-icon.pptx,
.contribution-file-icon.ppt {
  color: #f97316;
}

.contribution-file-icon.doc,
.contribution-file-icon.docx {
  color: #2563eb;
}

.contribution-file-icon span {
  line-height: 1;
}

/* Borderless social profile vibe (Instagram + LinkedIn inspired) */
.profile-page-modern {
  max-width: 980px;
}

.profile-page-modern .profile-header-modern {
  margin: 8px 10px 14px;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible;
}

.profile-page-modern .profile-cover {
  height: 240px !important;
  border-radius: 26px;
  border: 0 !important;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.profile-page-modern .profile-cover::after {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.46));
}

.profile-page-modern .profile-header-inner {
  margin-top: -68px !important;
  padding: 0 8px;
}

.profile-page-modern .profile-avatar-wrap {
  margin-top: 0 !important;
}

.profile-page-modern .profile-avatar {
  width: 136px !important;
  height: 136px !important;
  border-radius: 50%;
  border: 6px solid var(--bg-primary) !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.profile-page-modern .profile-identity {
  padding: 8px 10px 0;
}

.profile-page-modern .profile-name {
  font-size: clamp(28px, 4vw, 38px) !important;
}

.profile-page-modern .profile-username,
.profile-page-modern .profile-school,
.profile-page-modern .profile-level {
  font-size: 15px;
}

.profile-page-modern .profile-stats-modern {
  border-top: 0 !important;
  padding: 8px 10px 6px !important;
  margin: 0;
  gap: 18px;
}

.profile-page-modern .profile-stats-modern .stat,
.profile-page-modern .profile-tabs,
.profile-page-modern .contribution-card-modern,
.profile-page-modern .profile-about-card {
  border: 0 !important;
  box-shadow: none !important;
}

.profile-page-modern .profile-tabs {
  margin: 4px 12px 10px !important;
  background: transparent !important;
  border-top: 0 !important;
  border-bottom: 0 !important;
  display: flex;
  gap: 8px;
}

.profile-page-modern .tab-item {
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 0;
}

.profile-page-modern .tab-item.active {
  background: rgba(67, 97, 238, 0.2);
  color: var(--text-primary);
}

.profile-page-modern .profile-content-modern {
  padding: 0 12px !important;
  background: transparent;
}

.profile-page-modern .contribution-card-modern {
  background: var(--bg-card);
  border-radius: 16px;
}

.profile-page-modern .profile-about-card {
  background: var(--bg-card);
  border-radius: 14px;
}

.profile-social-actions {
  padding: 8px 10px 2px !important;
  gap: 8px;
}

.profile-social-actions .btn {
  border: 0 !important;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 16px;
}

.profile-social-actions .btn.secondary {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 768px) {
  .profile-page-modern .profile-cover {
    height: 188px !important;
    border-radius: 18px;
  }

  .profile-page-modern .profile-header-inner {
    margin-top: -50px !important;
  }

  .profile-page-modern .profile-avatar {
    width: 100px !important;
    height: 100px !important;
    border-width: 4px !important;
  }

  .profile-page-modern .profile-name {
    font-size: 24px !important;
  }
}
/* Profile social actions refinements */
.profile-social-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
}

.profile-social-actions-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.profile-social-actions-main form,
.profile-social-actions-message {
  display: inline-flex;
}

.profile-social-actions-main .profile-action-btn {
  min-width: 108px;
}

.profile-action-icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--btn-secondary-border) !important;
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.profile-action-icon-btn:hover {
  border-color: var(--brand-blue) !important;
  color: var(--brand-blue);
}

@media (max-width: 640px) {
  .profile-social-actions {
    align-items: stretch;
  }

  .profile-social-actions-main .profile-action-btn {
    min-width: 108px;
  }
}


/* Profile social actions refinement */
.relationship-state-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-secondary);
  background: rgba(67, 97, 238, 0.14);
  margin-bottom: 8px;
}

.profile-social-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.profile-social-actions-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.profile-social-actions-main form,
.profile-social-actions-message {
  display: inline-flex;
}

.profile-social-actions-main .profile-action-btn {
  min-width: 128px;
}

@media (max-width: 640px) {
  .profile-social-actions-main .profile-action-btn {
    min-width: 110px;
  }
}

/* Ensure upload loader truly covers viewport across layouts */
.upload-progress-modal {
  left: 0 !important;
  right: 0 !important;
  width: 100vw;
  max-width: 100vw;
  margin: 0 !important;
}

.upload-progress-card {
  margin-left: auto;
  margin-right: auto;
}

/* Fullscreen messaging experience */
.messages-fullscreen-body {
  padding-left: 0 !important;
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

.messages-fullscreen {
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.msg-topbar {
  height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
}

.msg-topbar h1 {
  font-size: 20px;
}

.msg-topbar-spacer {
  flex: 1;
}

.msg-platform-back {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  font-weight: 600;
  font-size: 13px;
}

.msg-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 340px 1fr;
}

.msg-sidebar {
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}

.msg-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.msg-tab {
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 8px;
}

.msg-tab.active {
  color: #fff;
  border-color: #4361EE;
  background: linear-gradient(135deg, #4361EE 0%, #5B52D9 100%);
}

.msg-list {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 12px;
  padding: 10px;
}

.msg-list-item.active,
.msg-list-item:hover {
  border-color: var(--brand-blue);
  background: var(--bg-input);
}

.msg-list-item img,
.msg-room-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-room-avatar {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #4361EE 0%, #7B5EA7 100%);
}

.msg-room-avatar.large {
  width: 40px;
  height: 40px;
}

.msg-list-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-list-content strong,
.msg-list-content p,
.msg-list-content small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-list-content p,
.msg-list-content small {
  color: var(--text-secondary);
  font-size: 12px;
}

.msg-chat {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.msg-chat-header {
  border-bottom: 1px solid var(--border-color);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
}

.msg-chat-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.msg-chat-header p,
.msg-header-empty {
  color: var(--text-secondary);
  font-size: 13px;
}

.msg-mobile-back {
  display: none;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
}

.msg-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-bubble {
  max-width: min(78%, 720px);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 10px 12px;
  align-self: flex-start;
}

.msg-bubble.mine {
  align-self: flex-end;
  background: rgba(67, 97, 238, 0.18);
  border-color: rgba(67, 97, 238, 0.42);
}

.msg-bubble strong {
  font-size: 12px;
  color: var(--text-secondary);
}

.msg-bubble p {
  margin-top: 2px;
  margin-bottom: 3px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bubble small {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.msg-composer {
  border-top: 1px solid var(--border-color);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: var(--bg-secondary);
}

@media (max-width: 980px) {
  .msg-shell {
    display: block;
    position: relative;
  }

  .msg-sidebar,
  .msg-chat {
    position: absolute;
    inset: 0;
  }

  .msg-chat {
    display: none;
  }

  .msg-shell.show-chat .msg-chat {
    display: flex;
  }

  .msg-shell.show-chat .msg-sidebar {
    display: none;
  }

  .msg-mobile-back {
    display: inline-flex;
  }
}

@media (max-width: 640px) {
  .msg-topbar {
    padding: 10px;
  }

  .msg-topbar h1 {
    font-size: 18px;
  }

  .msg-platform-back {
    padding: 0 10px;
    font-size: 12px;
  }

  .msg-bubble {
    max-width: 90%;
  }
}

/* Messaging spec-aligned 3 panel layout */
.messages-fullscreen-body {
  padding-left: 0 !important;
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

.messages-fullscreen {
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.msg-topbar {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--bg-secondary);
}

.msg-topbar h1 {
  font-size: 18px;
  font-weight: 700;
}

.msg-back-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-card);
  font-size: 18px;
  line-height: 1;
}

.msg-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 360px 1fr;
}

.msg-sidebar {
  min-height: 0;
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 10px;
  overflow-y: auto;
}

.msg-sidebar-title {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.msg-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-tree-head {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
}

.msg-tree-head.active {
  border-color: var(--brand-blue);
}

.msg-tree-head .arrow {
  color: var(--text-secondary);
  width: 14px;
  text-align: center;
}

.msg-tree-items {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  gap: 4px;
  padding-left: 24px;
}

.msg-tree-items.collapsed {
  display: none;
}

.msg-tree-items a,
.msg-tree-empty {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: 8px;
  padding: 6px 8px;
}

.msg-tree-items a:hover,
.msg-tree-items a.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

.msg-list-panel {
  min-height: 0;
  border-right: 1px solid var(--border-color);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.msg-list-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
}

.msg-list-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.msg-list {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-list-item {
  display: flex;
  gap: 10px;
  align-items: center;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 8px;
  text-decoration: none;
  color: inherit;
}

.msg-list-item:hover,
.msg-list-item.active {
  border-color: var(--brand-blue);
}

.msg-list-item img,
.msg-room-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
}

.msg-room-avatar {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #4361EE 0%, #7B5EA7 100%);
}

.msg-room-avatar.large {
  width: 42px;
  height: 42px;
}

.msg-list-content {
  min-width: 0;
  flex: 1;
}

.msg-list-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.msg-list-content strong,
.msg-list-content p,
.msg-list-content small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-list-content p,
.msg-list-content small {
  color: var(--text-secondary);
  font-size: 12px;
}

.msg-list-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.msg-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  opacity: 0.85;
}

.msg-row-menu {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
}

.msg-chat {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.msg-chat-header {
  min-height: 56px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.msg-chat-header img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.msg-chat-header p,
.msg-header-empty {
  color: var(--text-secondary);
  font-size: 12px;
}

.msg-chat-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.msg-chat-actions button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
}

.msg-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-bubble {
  max-width: min(76%, 700px);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 8px 10px;
}

.msg-bubble.mine {
  align-self: flex-end;
  background: rgba(67, 97, 238, 0.2);
  border-color: rgba(67, 97, 238, 0.4);
}

.msg-bubble strong {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
}

.msg-bubble p {
  margin: 2px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bubble small {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-composer {
  min-height: 56px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: grid;
  grid-template-columns: 36px 1fr 36px auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
}

.msg-input-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
}

@media (max-width: 1023px) {
  .msg-shell {
    grid-template-columns: 72px 320px 1fr;
  }

  .msg-sidebar {
    padding: 8px 6px;
  }

  .msg-sidebar-title,
  .msg-tree-items {
    display: none;
  }

  .msg-tree-head {
    justify-content: center;
    padding: 8px 0;
  }

  .msg-tree-head span:not(.arrow) {
    display: none;
  }

  .msg-tree-head .arrow {
    width: auto;
    font-size: 16px;
  }
}

@media (max-width: 767px) {
  .msg-shell {
    display: block;
    position: relative;
  }

  .msg-sidebar {
    display: none;
  }

  .msg-list-panel,
  .msg-chat {
    position: absolute;
    inset: 0;
  }

  .msg-chat {
    display: none;
  }

  .msg-shell.show-chat .msg-chat {
    display: flex;
  }

  .msg-shell.show-chat .msg-list-panel {
    display: none;
  }

  .msg-bubble {
    max-width: 90%;
  }
}

/* Mobile-first layered navigation */
.messages-fullscreen-body {
  padding-left: 0 !important;
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

.messages-fullscreen {
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.msg-topbar {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--bg-secondary);
}

.msg-topbar h1 { font-size: 18px; font-weight: 700; }

.msg-back-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-card);
  font-size: 18px;
  line-height: 1;
}

/* Mobile home (category selector) */
.msg-mobile-home {
  display: none;
  padding: 18px 16px;
  background: var(--bg-primary);
}

.msg-mobile-home h2 { margin-bottom: 12px; font-size: 18px; }

.msg-mobile-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.msg-home-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  padding: 14px;
  text-align: center;
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.msg-home-card .icon { font-size: 24px; }

/* 3-panel shell */
.msg-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px 360px 1fr; }

.msg-sidebar { min-height: 0; border-right: 1px solid var(--border-color); background: var(--bg-secondary); padding: 10px; overflow-y: auto; }
.msg-sidebar-title { width: 100%; text-align: left; border: 0; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 8px; }

.msg-tree { display: flex; flex-direction: column; gap: 8px; }
.msg-tree-head { width: 100%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); border-radius: 10px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.msg-tree-head .arrow { color: var(--text-secondary); width: 14px; text-align: center; }
.msg-tree-items { display: flex; flex-direction: column; margin-top: 6px; gap: 4px; padding-left: 24px; }
.msg-tree-items.collapsed { display: none; }
.msg-tree-items a, .msg-tree-empty { color: var(--text-secondary); text-decoration: none; font-size: 13px; border-radius: 8px; padding: 6px 8px; }
.msg-tree-items a:hover, .msg-tree-items a.active { background: var(--bg-card); color: var(--text-primary); }

.msg-list-panel { min-height: 0; border-right: 1px solid var(--border-color); background: var(--bg-primary); display: flex; flex-direction: column; }
.msg-list-header { min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--border-color); }
.msg-list-header h2 { font-size: 18px; font-weight: 700; flex-shrink: 0; }
.msg-list-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.msg-search { border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); border-radius: 8px; padding: 6px 10px; min-width: 120px; }
.msg-new-chat { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); font-size: 18px; cursor: pointer; }

.msg-list { min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.msg-list-item { display: flex; gap: 10px; align-items: center; border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-card); padding: 8px; text-decoration: none; color: inherit; }
.msg-list-item:hover, .msg-list-item.active { border-color: var(--brand-blue); }
.msg-list-item img, .msg-room-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.msg-room-avatar { display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #4361EE 0%, #7B5EA7 100%); }
.msg-room-avatar.large { width: 42px; height: 42px; }
.msg-list-content { min-width: 0; flex: 1; }
.msg-list-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.msg-list-content strong, .msg-list-content p, .msg-list-content small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-list-content p, .msg-list-content small { color: var(--text-secondary); font-size: 12px; }
.msg-list-meta { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.msg-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; opacity: 0.85; }
.msg-row-menu { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 16px; }
.msg-fab { position: absolute; right: 16px; bottom: 16px; width: 48px; height: 48px; border-radius: 50%; border: none; background: linear-gradient(135deg, #4361EE, #5B52D9); color: #fff; font-size: 26px; box-shadow: var(--shadow-md); cursor: pointer; }

.msg-chat { min-height: 0; display: flex; flex-direction: column; background: var(--bg-primary); }
.msg-chat-header { min-height: 56px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.msg-chat-header img { width: 42px; height: 42px; border-radius: 50%; }
.msg-chat-header p, .msg-header-empty { color: var(--text-secondary); font-size: 12px; }
.msg-chat-actions { margin-left: auto; display: flex; gap: 8px; }
.msg-chat-actions button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); cursor: pointer; }

.msg-chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg-bubble { max-width: min(76%, 700px); border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-card); padding: 8px 10px; }
.msg-bubble.mine { align-self: flex-end; background: rgba(67, 97, 238, 0.2); border-color: rgba(67, 97, 238, 0.4); }
.msg-bubble strong { display: block; color: var(--text-secondary); font-size: 12px; }
.msg-bubble p { margin: 2px 0; white-space: pre-wrap; word-break: break-word; }
.msg-bubble small { font-size: 11px; color: var(--text-muted); }

.msg-composer { min-height: 56px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); display: grid; grid-template-columns: 36px 1fr 36px auto; gap: 8px; align-items: center; padding: 8px; }
.msg-input-icon { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); font-size: 18px; cursor: pointer; }

/* Tablet breakpoint */
@media (max-width: 1023px) {
  .msg-shell { grid-template-columns: 72px 320px 1fr; }
  .msg-sidebar { padding: 8px 6px; }
  .msg-sidebar-title, .msg-tree-items { display: none; }
  .msg-tree-head { justify-content: center; padding: 8px 0; }
  .msg-tree-head span:not(.arrow) { display: none; }
  .msg-tree-head .arrow { width: auto; font-size: 16px; }
}

/* Mobile layered flow */
@media (max-width: 767px) {
  .msg-shell { display: block; position: relative; }
  .msg-sidebar { display: none; }
  .msg-list-panel, .msg-chat { position: absolute; inset: 0; }
  .msg-chat { display: none; }
  .msg-fab { right: 12px; bottom: 12px; }
  .msg-bubble { max-width: 90%; }

  /* view states */
  .messages-fullscreen.mobile-view-home #msgMobileHome { display: block; }
  .messages-fullscreen.mobile-view-home #msgShell { display: none; }

  .messages-fullscreen.mobile-view-list #msgMobileHome { display: none; }
  .messages-fullscreen.mobile-view-list #msgShell { display: block; }
  .messages-fullscreen.mobile-view-list #msgChat { display: none; }
  .messages-fullscreen.mobile-view-list #msgListPanel { display: block; }

  .messages-fullscreen.mobile-view-chat #msgMobileHome { display: none; }
  .messages-fullscreen.mobile-view-chat #msgShell { display: block; }
  .messages-fullscreen.mobile-view-chat #msgListPanel { display: none; }
  .messages-fullscreen.mobile-view-chat #msgChat { display: flex; }

  .msg-list-back, .msg-chat-back { display: inline-flex; }
}

/* Desktop defaults for back buttons */
.msg-list-back, .msg-chat-back { display: none; }

/* Mobile-first layered navigation & new dropdown/search/resize features */
.messages-fullscreen-body { padding-left: 0 !important; margin: 0; min-height: 100vh; overflow: hidden; }
.messages-fullscreen { width: 100vw; height: 100vh; background: var(--bg-primary); display: flex; flex-direction: column; position: relative; }

.msg-topbar { height: 56px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--bg-secondary); }
.msg-topbar h1 { font-size: 18px; font-weight: 700; flex: 1; }
.msg-back-icon { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-color); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text-primary); background: var(--bg-card); font-size: 18px; line-height: 1; }
.msg-icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); cursor: pointer; }

.msg-search-overlay { display: none; position: absolute; top: 56px; left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border-color); padding: 12px; z-index: 5; }
.msg-search-overlay.open { display: block; }
.msg-search-block { display: grid; gap: 8px; }
.msg-search-wide { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-primary); }

.msg-mobile-home { display: none; padding: 18px 16px; background: var(--bg-primary); }
.msg-mobile-home h2 { margin-bottom: 12px; font-size: 18px; }
.msg-mobile-home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.msg-home-card { border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-card); padding: 14px; text-align: center; display: grid; gap: 6px; cursor: pointer; }
.msg-home-card .icon { font-size: 24px; }

.msg-shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 72px 260px 6px 360px 6px 1fr; position: relative; }
.msg-icon-rail { background: var(--bg-secondary); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0; }
.msg-icon-rail a { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; text-decoration: none; color: var(--text-primary); border: 1px solid var(--border-color); font-size: 18px; }
.msg-icon-rail a.active { border-color: var(--brand-blue); }

.msg-sidebar { min-height: 0; border-right: 1px solid var(--border-color); background: var(--bg-secondary); padding: 10px; overflow-y: auto; }
.msg-sidebar-title { width: 100%; text-align: left; border: 0; background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 8px; }
.msg-tree { display: flex; flex-direction: column; gap: 8px; }
.msg-tree-head { width: 100%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); border-radius: 10px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.msg-tree-head .arrow { color: var(--text-secondary); width: 14px; text-align: center; }
.msg-tree-items { display: flex; flex-direction: column; margin-top: 6px; gap: 4px; padding-left: 24px; }
.msg-tree-items.collapsed { display: none; }
.msg-tree-items a, .msg-tree-empty { color: var(--text-secondary); text-decoration: none; font-size: 13px; border-radius: 8px; padding: 6px 8px; }
.msg-tree-items a:hover, .msg-tree-items a.active { background: var(--bg-card); color: var(--text-primary); }

.msg-divider { width: 6px; cursor: col-resize; background: transparent; }

.msg-list-panel { min-height: 0; border-right: 1px solid var(--border-color); background: var(--bg-primary); display: flex; flex-direction: column; position: relative; }
.msg-list-header { min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid var(--border-color); }
.msg-list-back { display: none; }
.msg-dropdown { position: relative; }
.msg-dropdown-toggle { border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.msg-dropdown-menu { position: absolute; top: 110%; left: 0; min-width: 210px; border: 1px solid var(--border-color); background: var(--bg-card); border-radius: 10px; box-shadow: var(--shadow-sm); display: none; z-index: 10; }
.msg-dropdown-menu .msg-dropdown-title { padding: 10px 12px; font-weight: 700; border-bottom: 1px solid var(--border-color); }
.msg-dropdown-menu button { width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--text-primary); }
.msg-dropdown-menu button:hover { background: var(--bg-input); }
.msg-list-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.msg-quick-filters button { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-card); cursor: pointer; }

.msg-list { min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.msg-list-item { display: flex; gap: 10px; align-items: center; border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-card); padding: 8px; text-decoration: none; color: inherit; }
.msg-list-item:hover, .msg-list-item.active { border-color: var(--brand-blue); }
.msg-list-item img, .msg-room-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.msg-room-avatar { display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #4361EE 0%, #7B5EA7 100%); }
.msg-room-avatar.large { width: 42px; height: 42px; }
.msg-list-content { min-width: 0; flex: 1; }
.msg-list-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.msg-list-content strong, .msg-list-content p, .msg-list-content small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-list-content p, .msg-list-content small { color: var(--text-secondary); font-size: 12px; }
.msg-list-meta { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.msg-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; opacity: 0.85; }
.msg-row-menu { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 16px; }
.msg-fab { position: absolute; right: 16px; bottom: 16px; width: 48px; height: 48px; border-radius: 50%; border: none; background: linear-gradient(135deg, #4361EE, #5B52D9); color: #fff; font-size: 22px; box-shadow: var(--shadow-md); cursor: pointer; }

.msg-chat { min-height: 0; display: flex; flex-direction: column; background: var(--bg-primary); }
.msg-chat-header { min-height: 56px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.msg-chat-back { display: none; }
.msg-chat-header img { width: 42px; height: 42px; border-radius: 50%; }
.msg-chat-header p, .msg-header-empty { color: var(--text-secondary); font-size: 12px; }
.msg-chat-actions { margin-left: auto; display: flex; gap: 8px; }
.msg-chat-actions button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); cursor: pointer; }

.msg-tabs { border-bottom: 1px solid var(--border-color); display: flex; gap: 6px; padding: 6px 10px; }
.msg-tabs button { border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.msg-tabs button.active { border-color: var(--brand-blue); }

.msg-chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg-bubble { max-width: min(76%, 700px); border-radius: 12px; border: 1px solid var(--border-color); background: var(--bg-card); padding: 8px 10px; position: relative; }
.msg-bubble.mine { align-self: flex-end; background: rgba(67, 97, 238, 0.2); border-color: rgba(67, 97, 238, 0.4); }
.msg-bubble strong { display: block; color: var(--text-secondary); font-size: 12px; }
.msg-bubble p { margin: 2px 0; white-space: pre-wrap; word-break: break-word; }
.msg-bubble small { font-size: 11px; color: var(--text-muted); }
.msg-bubble-actions { display: none; gap: 6px; margin-top: 4px; }
.msg-bubble:hover .msg-bubble-actions { display: inline-flex; }
.msg-bubble-actions button { border: 1px solid var(--border-color); background: var(--bg-card); border-radius: 6px; padding: 2px 6px; cursor: pointer; }

.msg-composer { min-height: 56px; border-top: 1px solid var(--border-color); background: var(--bg-secondary); display: grid; grid-template-columns: 36px 1fr 36px auto; gap: 8px; align-items: center; padding: 8px; }
.msg-input-icon { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); font-size: 18px; cursor: pointer; }

/* Tablet */
@media (max-width: 1023px) {
  .msg-shell { grid-template-columns: 0 0 0 320px 6px 1fr; }
  .msg-icon-rail, .msg-sidebar, #dividerLeft { display: none; }
}

/* Mobile layered flow */
@media (max-width: 767px) {
  .msg-shell { display: block; position: relative; }
  .msg-icon-rail, .msg-sidebar, #dividerLeft, #dividerRight { display: none; }
  .msg-list-panel, .msg-chat { position: absolute; inset: 0; }
  .msg-chat { display: none; }
  .msg-fab { right: 12px; bottom: 12px; }
  .msg-bubble { max-width: 90%; }

  .messages-fullscreen.mobile-view-home #msgMobileHome { display: block; }
  .messages-fullscreen.mobile-view-home #msgShell { display: none; }

  .messages-fullscreen.mobile-view-list #msgMobileHome { display: none; }
  .messages-fullscreen.mobile-view-list #msgShell { display: block; }
  .messages-fullscreen.mobile-view-list #msgChat { display: none; }
  .messages-fullscreen.mobile-view-list #msgListPanel { display: block; }

  .messages-fullscreen.mobile-view-chat #msgMobileHome { display: none; }
  .messages-fullscreen.mobile-view-chat #msgShell { display: block; }
  .messages-fullscreen.mobile-view-chat #msgListPanel { display: none; }
  .messages-fullscreen.mobile-view-chat #msgChat { display: flex; }

  .msg-list-back, .msg-chat-back { display: inline-flex; }
}

.resizing { cursor: col-resize; user-select: none; }

.msg-icon-chip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-secondary);
  background: var(--bg-card);
}

.msg-home-card .msg-icon-chip {
  width: 22px;
  height: 22px;
}

/* 2026-03 responsive and preview stability fixes */
#contributeModal .modal-sheet {
  width: min(800px, 92vw) !important;
  min-width: 0 !important;
  max-width: min(800px, 92vw) !important;
  max-height: 92vh !important;
  padding: 18px !important;
}

#contributeModal .contribute-two-column {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 18px !important;
  align-items: start !important;
}

#contributeModal .education-class-container {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
}

#contributeModal #filePreview {
  min-height: 360px !important;
  aspect-ratio: auto !important;
}

@media (max-width: 980px) {
  #contributeModal .modal-sheet {
    width: min(760px, calc(100vw - 18px)) !important;
    max-width: min(760px, calc(100vw - 18px)) !important;
    max-height: 95vh !important;
  }

  #contributeModal .contribute-two-column {
    grid-template-columns: 1fr !important;
  }

  #contributeModal .preview-column,
  #contributeModal .form-column {
    width: 100% !important;
  }

  #contributeModal .education-class-container {
    grid-template-columns: 1fr !important;
  }

  #contributeModal #filePreview {
    min-height: 250px !important;
  }
}

.contribution-preview-title-wrap {
  min-width: 0;
  flex: 1 1 320px;
}

.contribution-preview-actions {
  margin-left: auto;
  max-width: 100%;
  flex-wrap: wrap !important;
  justify-content: flex-end;
}

.contribution-preview-actions .contribution-action-btn {
  max-width: 100%;
}

.profile-page-modern .contribution-list-actions,
.profile-page-modern .contribution-list-actions .profile-action-btn {
  flex-wrap: wrap;
}

@media (min-width: 1024px) {
  .profile-page-modern .contribution-list-item {
    grid-template-columns: 150px 1fr auto;
  }

  .profile-page-modern .contribution-list-actions {
    justify-content: flex-end;
    align-content: center;
  }
}

@media (max-width: 768px) {
  .contribution-preview-actions {
    width: 100%;
    justify-content: stretch;
  }

  .contribution-preview-actions .contribution-action-btn {
    flex: 1 1 0;
  }
}


/* 2026-03 contribution/profile compact controls + modal responsiveness */
#contributeModal .modal-sheet {
  width: min(700px, 92vw) !important;
  max-width: min(700px, 92vw) !important;
  min-width: 0 !important;
  padding: 16px !important;
  position: relative;
  overflow: hidden;
}

#contributeModal .document-dropdown-modal {
  position: absolute !important;
  inset: 0 !important;
  z-index: 20 !important;
  background: rgba(0, 0, 0, 0.55) !important;
  backdrop-filter: blur(3px);
  align-items: center !important;
  justify-content: center !important;
  padding: 12px !important;
}

#contributeModal .document-dropdown-content {
  width: min(520px, calc(100% - 12px)) !important;
  max-width: min(520px, calc(100% - 12px)) !important;
  max-height: calc(100% - 12px) !important;
  overflow-y: auto !important;
}

#contributeModal .contribute-two-column {
  grid-template-columns: 1fr !important;
  gap: 14px !important;
}

#contributeModal #filePreview {
  min-height: 220px !important;
}

@media (min-width: 1024px) {
  #contributeModal .modal-sheet {
    width: min(760px, 88vw) !important;
    max-width: min(760px, 88vw) !important;
  }

  #contributeModal .contribute-two-column {
    grid-template-columns: minmax(250px, 0.95fr) minmax(0, 1.05fr) !important;
  }
}

.contribution-icon-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-icon-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
  border: 1px solid var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.profile-icon-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  transform: translateY(-1px);
}

.profile-icon-btn.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.contribution-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}

.contribution-edit-sheet {
  width: min(520px, 92vw) !important;
  max-width: min(520px, 92vw) !important;
  min-width: 0 !important;
}

.contribution-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.contribution-edit-actions .btn {
  min-height: 36px;
  padding: 8px 12px;
}

@media (max-width: 768px) {
  .contribution-list-actions.contribution-icon-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .profile-icon-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }
}

/* 2026-03 final modal stacking + compact widths */
.modal-overlay {
  z-index: 6000 !important;
}

#contributeModal {
  z-index: 7000 !important;
}

#contributeModal .modal-sheet {
  width: min(620px, 92vw) !important;
  max-width: min(620px, 92vw) !important;
}

@media (min-width: 1024px) {
  #contributeModal .modal-sheet {
    width: min(680px, 86vw) !important;
    max-width: min(680px, 86vw) !important;
  }
}

#documentDropdownModal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 8100 !important;
  display: none;
}

#documentDropdownModal.active {
  display: flex !important;
}

#documentDropdownModal .document-dropdown-content {
  width: min(520px, 92vw) !important;
  max-width: min(520px, 92vw) !important;
}

.contribution-edit-sheet {
  width: min(560px, 94vw) !important;
  max-width: min(560px, 94vw) !important;
  padding: 16px 14px 18px !important;
}

.contribution-edit-preview {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  min-height: 200px;
  max-height: 300px;
  background: var(--bg-card);
  margin-bottom: 12px;
}

.contribution-edit-preview .contribution-preview-frame {
  width: 100%;
  height: 240px;
  border: 0;
}

.two-col-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 768px) {
  .two-col-fields {
    grid-template-columns: 1fr;
  }

  .contribution-edit-preview .contribution-preview-frame {
    height: 200px;
  }
}
