/* ============================================================
   StudentsConnect — Global Styles v2.0 (Day 9 Merged)
   Base: attached typography + spacing system
   Premium layer: shadows, animations, frosted glass, bottom nav
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── DARK MODE (default) ──────────────────────────────────── */
:root,
[data-theme="dark"] {

  /* Brand */
  --gold:        #D4AF37;
  --gold-light:  #F0D878;
  --gold-dim:    #8B6914;
  --gold-pale:   rgba(212,175,55,0.08);
  --gold-glow:   rgba(212,175,55,0.15);

  /* Navy scale */
  --navy:        #0D1117;
  --navy-2:      #161B22;
  --navy-3:      #1C2330;
  --navy-4:      #242E3F;
  --navy-5:      #2D3748;

  /* Borders */
  --border:      rgba(212,175,55,0.18);
  --border-dim:  rgba(255,255,255,0.07);
  --border-focus:rgba(212,175,55,0.5);

  /* Text */
  --text-1:      #F0EDE6;
  --text-2:      #A8A29E;
  --text-3:      #6B6560;

  /* Semantic colours */
  --error:       #F87171;
  --error-pale:  rgba(248,113,113,0.08);
  --success:     #4ADE80;
  --success-pale:rgba(74,222,128,0.08);
  --warning:     #FBBF24;
  --info:        #60A5FA;

  /* Surfaces */
  --bg-page:     #0D1117;
  --bg-card:     #161B22;
  --bg-input:    #1C2330;
  --bg-hover:    rgba(255,255,255,0.04);

  /* Shadow system — 3 levels */
  --shadow:      rgba(0,0,0,0.4);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.4);
  --shadow-gold: 0 4px 20px rgba(212,175,55,0.2);

  /* Chrome */
  --sidebar-bg:  #161B22;
  --topbar-bg:   rgba(22,27,34,0.95);

  /* Layout */
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --bottom-nav-h:60px;

  /* Radii */
  --radius-xs:   4px;
  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-full: 9999px;

  /* Typography scale — ATTACHED system */
  --fs-xxs:      11px;
  --fs-xs:       12px;
  --fs-sm:       14px;
  --fs-md:       15px;
  --fs-base:     16px;
  --fs-lg:       18px;
  --fs-xl:       22px;
  --fs-2xl:      26px;
  --fs-3xl:      34px;

  --lh-tight:    1.25;
  --lh-normal:   1.5;
  --lh-relaxed:  1.65;

  /* Spacing — 4px grid (ATTACHED) */
  --space-1:     4px;
  --space-2:     8px;
  --space-3:     12px;
  --space-4:     16px;
  --space-5:     20px;
  --space-6:     24px;
  --space-8:     32px;

  /* Control / touch sizes */
  --control-sm:  34px;
  --control-md:  40px;
  --control-lg:  44px;

  /* Easing curves */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:    120ms;
  --dur-base:    200ms;
  --dur-slow:    350ms;

  /* Fonts */
  --font-display:'Playfair Display', Georgia, serif;
  --font-body:   'DM Sans', sans-serif;
  --font-mono:   'DM Mono', monospace;
}

/* ── LIGHT MODE ───────────────────────────────────────────── */
[data-theme="light"] {
  --gold:        #B8860B;
  --gold-light:  #D4AF37;
  --gold-dim:    #8B6914;
  --gold-pale:   rgba(184,134,11,0.08);
  --gold-glow:   rgba(184,134,11,0.12);

  --navy:        #F8F6F1;
  --navy-2:      #FFFFFF;
  --navy-3:      #F3F0EA;
  --navy-4:      #EBE7DE;
  --navy-5:      #E0DBD0;

  --border:      rgba(184,134,11,0.2);
  --border-dim:  rgba(0,0,0,0.08);
  --border-focus:rgba(184,134,11,0.4);

  --text-1:      #1A1613;
  --text-2:      #5C5650;
  --text-3:      #9A9490;

  --error:       #DC2626;
  --error-pale:  rgba(220,38,38,0.06);
  --success:     #16A34A;
  --success-pale:rgba(22,163,74,0.06);
  --warning:     #D97706;
  --info:        #2563EB;

  --bg-page:     #F8F6F1;
  --bg-card:     #FFFFFF;
  --bg-input:    #F3F0EA;
  --bg-hover:    rgba(0,0,0,0.03);

  --shadow:      rgba(0,0,0,0.08);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-gold: 0 4px 20px rgba(184,134,11,0.15);

  --sidebar-bg:  #FFFFFF;
  --topbar-bg:   rgba(255,255,255,0.95);
}

/* ── RESET ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* NO always-on transition here — kills scroll performance.
     Use body.theme-transitioning for theme changes only. */
}

/* Selective transitions on interactive elements only */
.btn, .card, .nav-item, .post-action, .paction,
.topbar-icon, .theme-toggle, .t-icon, .t-avatar {
  transition:
    background-color var(--dur-base) ease,
    border-color     var(--dur-base) ease,
    color            var(--dur-fast) ease,
    transform        var(--dur-fast) var(--ease-out),
    box-shadow       var(--dur-fast) ease;
}

/* Theme transition — applied only during intentional theme changes */
body.theme-transitioning,
body.theme-transitioning * {
  transition:
    background-color var(--dur-slow) var(--ease-in-out),
    border-color     var(--dur-slow) var(--ease-in-out),
    color            var(--dur-base) var(--ease-in-out) !important;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  background: var(--bg-page);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Subtle grain texture */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}
[data-theme="light"] body::before { opacity: 0.2; }

/* ── GLOBAL NORMALIZATIONS (ATTACHED) ─────────────────────── */
button, input, textarea, select {
  font-family: var(--font-body);
}

button, a, [onclick] {
  -webkit-tap-highlight-color: transparent;
}

img, video {
  max-width: 100%;
}

.post-media img,
.post-media-grid img,
.post-media-single img,
.mi img {
  object-position: center;
}

/* ── TYPOGRAPHY ───────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}
h1 { font-size: clamp(26px, 3vw, 38px); }
h2 { font-size: clamp(20px, 2.5vw, 28px); line-height: 1.3; }
h3 { font-size: var(--fs-lg); line-height: 1.4; }
h4 { font-size: var(--fs-md); }

p  { font-size: var(--fs-md); line-height: var(--lh-relaxed); color: var(--text-2); }
a  { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }

/* Semantic typography mapping — consistent across all pages */
.page-title,
.search-hero-title,
.empty-title,
.state-title,
.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  line-height: var(--lh-tight);
  font-weight: 600;
  color: var(--text-1);
}

.post-body,
.comment-text,
.c-text,
.bio-text,
.empty-sub,
.state-sub,
.search-hero-sub {
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
}

.post-author,
.uc-name,
.c-name,
.rp-uname,
.topbar-logo-name {
  font-size: var(--fs-sm);
  font-weight: 600;
}

.post-detail,
.uc-detail,
.c-time,
.rp-udetail,
.rp-title,
.nav-sect,
.nav-section,
.field-label,
.s-label {
  font-size: var(--fs-xs);
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dim); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ── APP SHELL ────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1;
  height: var(--topbar-h);
  /* Frosted glass — premium on scroll (LinkedIn/Notion standard) */
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.topbar-logo:hover { text-decoration: none; }

.topbar-logo-mark {
  width: var(--control-sm); height: var(--control-sm);
  min-width: var(--control-sm);
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: box-shadow var(--dur-base);
}
.topbar-logo-mark svg {
  width: 18px; height: 10px;
  max-width: 18px; max-height: 10px;
  flex-shrink: 0;
  pointer-events: none;
}
.topbar-logo:hover .topbar-logo-mark {
  box-shadow: 0 0 0 3px var(--gold-pale);
}
.topbar-logo-name {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-1);
  transition: color var(--dur-fast) ease;
}
.topbar-logo:hover .topbar-logo-name {
  color: var(--gold);
}

.topbar-search {
  flex: 1;
  max-width: 340px;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-full);
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-1);
  outline: none;
  transition: border-color var(--dur-fast);
}
.topbar-search:focus { border-color: var(--gold); }
.topbar-search::placeholder { color: var(--text-3); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── ICON BUTTON ──────────────────────────────────────────── */
.t-icon,
.topbar-icon {
  width: var(--control-sm); height: var(--control-sm);
  min-width: var(--control-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.t-icon svg,
.topbar-icon svg {
  width: 16px; height: 16px;
  max-width: 16px; max-height: 16px;
  flex-shrink: 0;
  pointer-events: none;
}
.t-icon:hover,
.topbar-icon:hover {
  border-color: var(--border);
  color: var(--text-1);
  background: var(--bg-hover);
}
.t-icon:active,
.topbar-icon:active { transform: scale(0.95); }

.badge-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--error);
  border: 1.5px solid var(--topbar-bg);
}

/* ── AVATAR ───────────────────────────────────────────────── */
.t-avatar,
.avatar {
  width: var(--control-sm); height: var(--control-sm);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border-dim);
  text-transform: uppercase;
  flex-shrink: 0;
  overflow: hidden;
}
.t-avatar:hover,
.avatar:hover { border-color: var(--gold); }
.t-avatar img,
.avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) 0;
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-sect,
.nav-section {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-3) 18px var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  min-height: var(--control-md);
  cursor: pointer;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
  text-decoration: none;
}
.nav-item.active {
  color: var(--gold);
  font-weight: 500;
  border-left-color: var(--gold);
  background: var(--gold-pale);
}
.nav-item svg {
  width: 16px; height: 16px;
  min-width: 16px; max-width: 16px;
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity var(--dur-fast);
}
.nav-item.active svg,
.nav-item:hover svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* ── LAYOUT HELPERS ───────────────────────────────────────── */
.main-content {
  padding: var(--space-6);
  overflow-y: auto;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}
.right-panel {
  width: 280px;
  flex-shrink: 0;
  padding: var(--space-6) var(--space-4);
  border-left: 1px solid var(--border-dim);
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow-y: auto;
}
.three-col {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr 280px;
  min-height: calc(100vh - var(--topbar-h));
}

.rp-section { margin-bottom: var(--space-6); }
.rp-title {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-dim);
}

/* ── CARD ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.card:hover { border-color: var(--border); }
.card-pad { padding: var(--space-4); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  min-height: var(--control-md);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--navy);
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-gold);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-2);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-dim);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-1);
}

.btn-sm   { min-height: 32px; padding: 0 var(--space-3); font-size: var(--fs-xs); }
.btn-xs   { min-height: 26px; padding: 0 10px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn-icon { width: 36px; min-height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ── FORM ELEMENTS ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
}

.field-input {
  min-height: var(--control-lg);
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-1);
  outline: none;
  appearance: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-pale);
}
.field-input::placeholder { color: var(--text-3); }
.field-input.error { border-color: var(--error); }
.field-input:disabled { opacity: 0.5; cursor: not-allowed; }

.field-hint  { font-size: var(--fs-xxs); color: var(--text-3); }
.field-error { font-size: var(--fs-xxs); color: var(--error); display: none; }
.field-error.show { display: block; }

/* ── DIVIDER ──────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--border-dim);
  margin: var(--space-4) 0;
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge,
.user-type-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  white-space: nowrap;
}
.badge-student { background: #E6F1FB; color: #0C447C; }
.badge-alumni  { background: #E1F5EE; color: #085041; }
.badge-alumna  { background: #F5EAF7; color: #7C3AAD; }
.badge-gold    { background: var(--gold-pale); color: var(--gold); border: 1px solid var(--border); }

/* ── SKELETON SHIMMER ─────────────────────────────────────── */
/* Gradient shimmer — Facebook/LinkedIn standard (not opacity pulse) */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-input) 25%,
    var(--bg-hover) 50%,
    var(--bg-input) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-xs);
  animation: shimmer 1.8s ease infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── SPINNER ──────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
  display: inline-block;
}
[data-theme="dark"] .spinner {
  border-color: rgba(255,255,255,0.15);
  border-top-color: var(--navy);
}

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: var(--fs-sm);
  color: var(--text-1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base), transform var(--dur-base) var(--ease-out);
  z-index: 9999;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { border-color: var(--success); color: var(--success); }
.toast-error   { border-color: var(--error);   color: var(--error);   }
.toast-info    { border-color: var(--info);     color: var(--info);    }

/* ── ANIMATIONS ───────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Animation utility classes */
.anim-fade-up  { animation: fadeInUp    var(--dur-slow) var(--ease-out) both; }
.anim-fade-in  { animation: fadeIn      var(--dur-base) var(--ease-out) both; }
.anim-scale-in { animation: scaleIn     var(--dur-base) var(--ease-out) both; }
.anim-slide-in { animation: slideInRight var(--dur-slow) var(--ease-out) both; }

/* ── POST CARD ────────────────────────────────────────────── */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--space-4);
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
}
.post-card:hover { border-color: var(--border); }

.post-header,
.post-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
}
.post-meta   { flex: 1; min-width: 0; }
.post-author { font-size: var(--fs-sm); font-weight: 600; color: var(--text-1); }
.post-detail { font-size: var(--fs-xs); color: var(--text-3); margin-top: 3px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.post-body   { padding: 0 var(--space-4) var(--space-3); font-size: var(--fs-md); color: var(--text-1); line-height: var(--lh-relaxed); white-space: pre-wrap; word-break: break-word; }
.post-stats  { padding: var(--space-2) var(--space-4) var(--space-3); font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: var(--space-3); border-top: 1px solid var(--border-dim); border-bottom: 1px solid var(--border-dim); flex-wrap: wrap; }
.post-actions { display: flex; }
.post-action {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-2);
  min-height: var(--control-md);
  font-size: var(--fs-sm);
  color: var(--text-2);
  cursor: pointer;
  border: none;
  border-right: 1px solid var(--border-dim);
  background: transparent;
  font-family: var(--font-body);
}
.post-action:last-child { border-right: none; }
.post-action:hover { background: var(--bg-hover); color: var(--text-1); }
.post-action.liked { color: var(--error); }
.post-action svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── THEME TOGGLE ─────────────────────────────────────────── */
.theme-toggle {
  width: var(--control-sm); height: var(--control-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.theme-toggle:hover {
  border-color: var(--border);
  color: var(--text-1);
  background: var(--bg-hover);
}

/* ── MODAL ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal-overlay.open {
  display: flex;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--dur-base) var(--ease-out);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-dim);
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.modal-title { font-size: var(--fs-md); font-weight: 500; color: var(--text-1); }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-2);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-1); }
.modal-body   { padding: var(--space-5); }
.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-dim);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ── EMPTY / ERROR STATES ─────────────────────────────────── */
.empty-state,
.state-box {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
}
.empty-feed {
  text-align: center;
  padding: var(--space-8) var(--space-6);
}
.empty-icon,
.state-icon { font-size: 40px; margin-bottom: var(--space-4); }
.empty-sub,
.state-sub  { max-width: 280px; margin: 0 auto; }

/* ── MOBILE BOTTOM NAV ────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-dim);
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: center;
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) 0;
  cursor: pointer;
  color: var(--text-3);
  text-decoration: none;
  position: relative;
}
.bn-item.active { color: var(--gold); }
.bn-item:hover  { color: var(--text-1); }
.bn-item svg    { width: 22px; height: 22px; }
.bn-label       { font-size: 10px; font-weight: 500; }
.bn-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 14px);
  min-width: 16px; height: 16px;
  background: var(--error);
  color: white;
  font-size: 9px; font-weight: 700;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--bg-page);
}

/* ── PAGE-LEVEL SPACING CONSISTENCY ──────────────────────── */
.search-hero,
.compose-box,
.stories-wrap,
.profile-card,
.post-card,
.state-box,
.empty-feed {
  margin-bottom: var(--space-4);
}

/* ── UTILITY CLASSES ──────────────────────────────────────── */
.truncate     { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only      { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .right-panel { display: none; }
  .three-col   { grid-template-columns: var(--sidebar-w) 1fr; }
}

@media (max-width: 720px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"] { --topbar-h: 56px; }

  .sidebar        { display: none !important; }
  .app-shell      { grid-template-columns: 1fr; }
  .three-col      { grid-template-columns: 1fr; }
  .main-content   { padding: var(--space-4); }
  .bottom-nav     { display: block; }

  /* Content clears bottom nav — scoped to named pages only.
     Bare `main` intentionally excluded to avoid breaking login,
     register, 404, settings and other non-feed pages. */
  .main-content,
  .feed-main,
  .main-feed,
  .main-profile,
  .main-search,
  .main-notif,
  .main-post {
    padding-bottom: calc(var(--bottom-nav-h) + var(--space-4));
  }

  .topbar             { padding: 0 var(--space-3); gap: var(--space-3); }
  .topbar-logo-name   { font-size: var(--fs-sm); }

  .post-body,
  .comment-text,
  .c-text   { font-size: var(--fs-md); }

  .page-title,
  .search-hero-title,
  .empty-title,
  .state-title { font-size: 20px; }
}

@media (max-width: 420px) {
  .main-content { padding: var(--space-3); }
  .modal { border-radius: var(--radius) var(--radius) 0 0; max-height: 95vh; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* ── SVG SAFETY — prevent icon inflation ─────────────────────
   Hard safety net: UI icon SVGs never grow beyond container.  */
.topbar svg,
.sidebar svg,
.nav-item svg,
.t-icon svg,
.topbar-icon svg,
.theme-toggle svg,
.t-avatar svg,
.btn svg,
.post-action svg,
.paction svg,
.bottom-nav svg,
.bn-item svg,
.modal-close svg {
  display: block;
  pointer-events: none;
}

/* ============================================================
   StudentsConnect — Clean Final Stability Layer v3.0
   Purpose: one layout rhythm, safe icon sizing, search/settings fixes.
   Note: this replaces the old duplicated emergency patches.
   ============================================================ */

/* ── 1. App shell layout authority ─────────────────────────── */
.app-shell {
  min-height: 100vh;
  background: var(--bg-page);
}

.body-grid {
  width: 100%;
  min-height: calc(100vh - var(--topbar-h));
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.body-grid:has(.right-panel) {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 300px;
}

.body-grid > main,
.main-feed,
.main-profile,
.main-post,
.main-notif,
.main-search,
.main-settings,
.main-content,
main[class^="main-"] {
  width: 100%;
  min-width: 0;
  margin-inline: auto;
  padding: var(--space-6);
}

.main-feed { max-width: 720px; }
.main-profile,
.main-post,
.main-notif { max-width: 760px; }
.main-search { max-width: 1080px; }
.main-settings { max-width: 1100px; }
.main-content { max-width: 980px; }

.right-panel {
  width: 300px;
  min-width: 280px;
  max-width: 300px;
  min-height: calc(100vh - var(--topbar-h));
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  overflow-y: auto;
  padding: var(--space-6) var(--space-4);
  background: var(--bg-page);
  border-left: 1px solid var(--border-dim);
}

/* ── 2. Search page stability ─────────────────────────────── */
.main-search > *,
.search-hero,
.results-section,
.results-header,
.breadcrumb,
.user-card,
.school-card,
.state-card,
.empty-state,
.state-box {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.search-hero {
  width: 100%;
  overflow: hidden;
}

.search-tabs {
  width: 100%;
  display: flex;
  align-items: stretch;
}

.stab {
  flex: 1 1 0;
  min-width: 0;
}

.search-input-wrap,
.filter-row,
.search-submit,
.results-section {
  width: 100%;
  max-width: 100%;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

/* ── 3. Settings page desktop balance ─────────────────────── */
.settings-layout,
.settings-grid,
.settings-shell {
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.settings-nav,
.settings-tabs,
.settings-sidebar {
  width: 100%;
  min-width: 0;
}

.settings-panel,
.settings-panel.active,
.settings-content,
.settings-card,
.settings-panel .s-card,
.s-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* ── 4. Spacing rhythm ────────────────────────────────────── */
.post-card,
.profile-card,
.section-card,
.search-hero,
.state-box,
.empty-state,
.user-card,
.school-card,
.notif-item,
.settings-card,
.panel-card,
.compose-box,
.stories-wrap,
.s-card {
  box-sizing: border-box;
  margin-bottom: var(--space-4);
}

.section-card,
.settings-card,
.panel-card,
.state-box,
.empty-state,
.search-hero {
  padding: var(--space-4);
}

.s-field,
.field,
.f-field,
.settings-card .field {
  margin-bottom: var(--space-4);
}

.s-label,
.field-label,
.f-label,
.settings-card label {
  margin-bottom: var(--space-2);
}

button,
.btn,
.btn-outline,
.btn-connect,
.btn-edit,
.save-btn,
.cancel-btn,
.load-more-btn,
.load-comments-btn,
.mark-all-btn,
.uc-btn,
.notif-btn,
.paction,
.post-action {
  box-sizing: border-box;
}

.page-title,
.search-hero-title,
.state-title,
.empty-title {
  margin-bottom: var(--space-2);
}

.search-hero-sub,
.state-sub,
.empty-sub,
.page-subtitle,
.page-sub {
  margin-bottom: var(--space-4);
}

.user-card,
.school-card,
.notif-item {
  margin-bottom: var(--space-3);
}

/* ── 5. Safe SVG/icon sizing ────────────────────────────────
   Important: do NOT globally clamp .app-shell svg.
   Only known UI icon containers are locked. Decorative state
   icons and logo are intentionally larger/different. */
.topbar-logo-mark,
.t-icon,
.topbar-icon,
.theme-toggle,
.nav-item,
.bn-item,
.state-icon,
.empty-icon,
.search-icon,
.search-icon-big {
  overflow: hidden;
  flex-shrink: 0;
}

.topbar-logo-mark svg {
  width: 18px;
  height: 10px;
  max-width: 18px;
  max-height: 10px;
  display: block;
  flex-shrink: 0;
}

.topbar-icon svg,
.theme-toggle svg,
.sidebar svg,
.nav-item svg,
.t-icon svg,
.modal-close svg,
.post-action svg,
.paction svg,
.btn svg,
.back-btn svg,
.section-edit svg,
.save-btn svg,
.snav-item svg,
.search-icon svg {
  width: 16px;
  height: 16px;
  max-width: 16px;
  max-height: 16px;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.bottom-nav svg,
.bn-item svg {
  width: 22px;
  height: 22px;
  max-width: 22px;
  max-height: 22px;
  display: block;
  flex-shrink: 0;
}

.state-icon svg,
.empty-icon svg,
.search-icon-big svg,
.empty-state > svg,
.empty-feed > svg,
.state-box > svg,
.error-state > svg {
  width: 40px;
  height: 40px;
  max-width: 40px;
  max-height: 40px;
  display: block;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── 6. Responsive layout ─────────────────────────────────── */
@media (max-width: 1100px) {
  .body-grid,
  .body-grid:has(.right-panel) {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .right-panel {
    display: none;
  }
}

@media (max-width: 900px) {
  .settings-layout,
  .settings-grid,
  .settings-shell {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

@media (max-width: 720px) {
  .body-grid,
  .body-grid:has(.right-panel) {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .body-grid > main,
  .main-feed,
  .main-profile,
  .main-search,
  .main-post,
  .main-notif,
  .main-settings,
  .main-content,
  main[class^="main-"] {
    max-width: none;
    padding-top: var(--space-3);
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    padding-bottom: calc(var(--bottom-nav-h) + var(--space-4));
  }

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

  .settings-nav,
  .settings-tabs,
  .settings-sidebar {
    width: 100%;
    max-width: none;
  }
}

/* =========================================================
   FINAL SPACING RHYTHM — CLEAN INTEGRATION (NO CONFLICT)
   ========================================================= */

/* 1. Standard page padding (overrides inconsistencies safely) */
.body-grid > main,
.main-feed,
.main-profile,
.main-post,
.main-notif,
.main-search,
.main-settings,
.main-content,
main[class^="main-"] {
  padding: var(--space-6);
}

/* 2. Vertical rhythm between direct children */
.main-feed > *,
.main-profile > *,
.main-post > *,
.main-notif > *,
.main-search > *,
.main-settings > *,
.main-content > * {
  margin-bottom: var(--space-4);
}

.main-feed > *:last-child,
.main-profile > *:last-child,
.main-post > *:last-child,
.main-notif > *:last-child,
.main-search > *:last-child,
.main-settings > *:last-child,
.main-content > *:last-child {
  margin-bottom: 0;
}

/* 3. Card-level rhythm tightening */
.post-card,
.profile-card,
.section-card,
.search-hero,
.state-box,
.empty-state,
.user-card,
.school-card,
.notif-item,
.settings-card,
.panel-card,
.compose-box,
.stories-wrap,
.s-card {
  margin-bottom: var(--space-4);
}

/* 4. Internal spacing consistency */
.field,
.s-field {
  margin-bottom: var(--space-4);
}

.field-label,
.s-label {
  margin-bottom: var(--space-2);
}

/* 5. Title + subtitle spacing */
.page-title,
.search-hero-title,
.state-title,
.empty-title {
  margin-bottom: var(--space-2);
}

.page-sub,
.page-subtitle,
.search-hero-sub,
.state-sub,
.empty-sub {
  margin-bottom: var(--space-4);
}

/* 6. Mobile rhythm (critical for bottom nav spacing) */
@media (max-width: 720px) {
  .body-grid > main,
  .main-feed,
  .main-profile,
  .main-post,
  .main-notif,
  .main-search,
  .main-settings,
  .main-content,
  main[class^="main-"] {
    padding: var(--space-3);
    padding-bottom: calc(var(--bottom-nav-h) + var(--space-4));
  }

  .main-feed > *,
  .main-profile > *,
  .main-post > *,
  .main-notif > *,
  .main-search > *,
  .main-settings > *,
  .main-content > * {
    margin-bottom: var(--space-3);
  }

  .post-card,
  .profile-card,
  .section-card,
  .search-hero,
  .state-box,
  .empty-state,
  .user-card,
  .school-card,
  .notif-item,
  .settings-card,
  .panel-card,
  .compose-box,
  .stories-wrap,
  .s-card {
    margin-bottom: var(--space-3);
  }
}

/* =========================================================
   MICRO-INTERACTIONS — PREMIUM APP FEEL
   ========================================================= */

.card,
.post-card,
.s-card,
.profile-card,
.user-card,
.school-card,
.notif-item,
.compose-box,
.stories-wrap,
.search-hero,
.state-box,
.empty-state {
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) ease,
    border-color var(--dur-base) ease,
    background-color var(--dur-base) ease;
}

.card:hover,
.post-card:hover,
.s-card:hover,
.profile-card:hover,
.user-card:hover,
.school-card:hover,
.notif-item:hover,
.compose-box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.btn:hover:not(:disabled),
.save-btn:hover:not(:disabled),
.post-btn:hover:not(:disabled),
.load-more-btn:hover:not(:disabled),
.load-comments-btn:hover:not(:disabled),
.mark-all-btn:hover:not(:disabled),
.notif-btn:hover:not(:disabled),
.uc-btn:hover:not(:disabled),
.connect-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled),
.save-btn:active:not(:disabled),
.post-btn:active:not(:disabled),
.load-more-btn:active:not(:disabled),
.load-comments-btn:active:not(:disabled),
.mark-all-btn:active:not(:disabled),
.notif-btn:active:not(:disabled),
.uc-btn:active:not(:disabled),
.connect-btn:active:not(:disabled),
.post-action:active,
.paction:active,
.nav-item:active,
.bn-item:active {
  transform: scale(0.97);
}

.t-icon:hover,
.theme-toggle:hover,
.topbar-icon:hover {
  box-shadow: 0 0 0 3px var(--gold-pale);
}

.t-avatar:hover,
.avatar:hover {
  box-shadow: 0 0 0 3px var(--gold-pale);
}

.nav-item,
.bn-item,
.snav-item {
  transition:
    background-color var(--dur-base) ease,
    color var(--dur-fast) ease,
    transform var(--dur-fast) var(--ease-out);
}

.nav-item:hover,
.snav-item:hover {
  transform: translateX(2px);
}

.bn-item:hover {
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}