:root {
  --ink: #000e2f;
  --muted: #4b5563;
  --paper: #ffffff;
  --panel: #ffffff;
  --line: #7c878e66;
  --navy: #000e2f;
  --royal-blue: #013ecd;
  --white: #ffffff;
  --sidebar: 272px;

  --body-font: "Proxima Nova", "Segoe UI", Arial, sans-serif;
  --heading-font: "Gotham Bold", Gotham, "Arial Black", Arial, sans-serif;

  font-family: var(--body-font);
}

/* ==========================================
   GLOBAL RESET
   ========================================== */

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ==========================================
   APPLICATION LAYOUT
   ========================================== */

.app-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  overflow-x: clip;
}

.site-footer {
  width: 100%;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

/* ==========================================
   SIDEBAR
   ========================================== */

.sidebar {
  width: var(--sidebar);
  height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  transform: translateX(0);
  overflow-y: auto;
  background: var(--navy);
  color: #ffffff;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  transition:
    width 0.25s ease,
    transform 0.25s ease;
}

.mobile-close {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 30px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px 12px 12px 4px;
  background: var(--white);
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 19px;
}

.brand strong {
  font-family: var(--heading-font);
  font-size: 23px;
  letter-spacing: -0.5px;
}

.nav-label {
  padding: 0 12px 10px;
  color: #7c878e;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 800;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  padding: 12px 13px;
  border-radius: 10px;
  color: #ffffff;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
}

.nav a:hover,
.nav a.active {
  background: #013ecd;
  color: #ffffff;
}

.nav-icon {
  display: none;
}

.sidebar-foot {
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid #7c878e;
  color: #7c878e;
  font-size: 12px;
  line-height: 1.5;
}

.logout-button {
  display: block;
  margin-top: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.logout-button:hover {
  color: #013ecd;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */

.main {
  width: calc(100% - var(--sidebar));
  min-width: 0;
  margin-left: var(--sidebar);
}

.topbar {
  height: 82px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 42px;
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(12px);
}

.menu-button {
  width: 58px;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  padding: 7px;
  position: relative;
}

.menu-button::after {
  content: "Menu";
  color: var(--navy);
  font: 700 14px var(--body-font);
}

.topbar h1 {
  margin: 0;
  font: 700 25px var(--heading-font);
}

.topbar .crumb {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
}

.user-profile {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: block;
  margin-left: 8px;
  border: 2px solid var(--royal-blue);
  border-radius: 50%;
  overflow: hidden;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease;
}

.user-profile:hover {
  border-color: var(--navy);
  transform: scale(1.05);
}

.user-profile img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.content {
  max-width: 1220px;
  margin: 0 auto;
  padding: 42px;
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

.eyebrow {
  color: var(--royal-blue);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.8px;
  margin-bottom: 8px;
}

h1,
h2,
h3 {
  font-family: var(--heading-font);
}

h2 {
  font-size: 46px;
  margin: 0 0 10px;
  line-height: 1.05;
}

h3 {
  margin: 0 0 8px;
  font-size: 21px;
}

.lede {
  color: var(--muted);
  max-width: 620px;
  line-height: 1.65;
  margin: 0;
}

/* ==========================================
   GRID LAYOUTS
   ========================================== */

.grid {
  display: grid;
  gap: 20px;
}

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

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

/* ==========================================
   PANELS
   ========================================== */

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-title h3 {
  margin: 0;
}

.mini-link {
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

/* ==========================================
   STAT CARDS
   ========================================== */

.stat {
  padding: 21px;
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--white);
  position: absolute;
  right: -22px;
  top: -23px;
  opacity: 0.55;
}

.stat strong {
  display: block;
  font: 700 34px var(--heading-font);
  color: var(--navy);
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
  border: 0;
  background: var(--navy);
  color: white;
  border-radius: 8px;
  padding: 11px 16px;
  font-weight: 800;
}

.btn:hover {
  background: var(--navy);
  color: #fcfdfb;
}

.btn-light {
  background: #7c878e33;
  color: var(--navy);
}

.btn-coral {
  background: var(--royal-blue);
}

/* ==========================================
   TAGS
   ========================================== */

.tag {
  display: inline-block;
  border-radius: 20px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  background: #7c878e33;
  color: var(--navy);
}

/* ==========================================
   LISTS
   ========================================== */

.list {
  display: grid;
  gap: 14px;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #7c878e33;
  color: var(--navy);
  font-weight: 900;
}

.item-copy {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.item-copy strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.item-copy span {
  color: var(--muted);
  font-size: 12px;
}

.event-date {
  width: 47px;
  text-align: center;
  color: var(--royal-blue);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 11px;
}

.event-date strong {
  display: block;
  color: var(--ink);
  font: 700 26px var(--heading-font);
}

/* ==========================================
   HERO SECTION
   ========================================== */

.hero {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: end;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

/* ==========================================
   FORM INPUTS
   ========================================== */

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fcfdfb;
}

textarea {
  min-height: 150px;
  resize: vertical;
}

.form-row {
  display: grid;
  gap: 13px;
  margin-bottom: 14px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: -5px;
}

/* PUBLIC JOURNAL CARDS */

.public-journal-card {
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background:  #ffffff;
}

.public-journal-card h4 {
  margin: 0 0 8px;
}

.public-journal-card small {
  display: block;
  margin-bottom: 12px;
  color: #64748b;
}

.public-journal-card p {
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.public-journal-card .journal-mood {
  font-weight: 600;
}

/* ==========================================
   JOURNAL CARDS
   ========================================== */

.journal-card {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.journal-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

/* ==========================================
   CHAT LAYOUT
   ========================================== */

.chat-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 540px;
}

.chat-list {
  border-right: 1px solid var(--line);
  padding-right: 20px;
}

.chat-window {
  padding-left: 26px;
  display: flex;
  flex-direction: column;
}

.message {
  max-width: 68%;
  padding: 12px 15px;
  border-radius: 14px;
  background: #7c878e22;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.message.mine {
  align-self: flex-end;
  background: var(--navy);
  color: white;
}

.messages {
  display: grid;
  gap: 12px;
  margin: auto 0 20px;
}

.chat-input {
  display: flex;
  gap: 8px;
}

.chat-input input {
  flex: 1;
}

/* ==========================================
   PROFILE HEADER
   ========================================== */

.profile-head {
  display: flex;
  gap: 20px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.profile-avatar {
  width: 82px;
  height: 82px;
  background: var(--white);
  border-radius: 24px;
  display: grid;
  place-items: center;
  font: 700 34px var(--heading-font);
  color: var(--navy);
}

.profile-head h2 {
  font-size: 31px;
  margin-bottom: 4px;
}

/* ==========================================
   NAVIGATION COLLAPSE
   ========================================== */

/* Old decorative map styles removed.
   Leaflet now renders the campus map. */

body.nav-collapsed .sidebar {
  width: 76px;
  padding-left: 12px;
  padding-right: 12px;
}

body.nav-collapsed .main {
  width: calc(100% - 76px);
  margin-left: 76px;
}

body.nav-collapsed .brand strong,
body.nav-collapsed .nav-label,
body.nav-collapsed .nav,
body.nav-collapsed .sidebar-foot {
  display: none;
}

body.nav-collapsed .brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.nav-collapsed .nav a {
  justify-content: flex-start;
}

/* ==========================================
   LOGIN PAGE
   ========================================== */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--navy);
}

.login-art {
  padding: 60px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(145deg, #000e2f, #013ecd);
}

.login-art h1 {
  max-width: 480px;
  font: 700 70px/0.98 var(--heading-font);
  margin: 70px 0 18px;
}

.login-art p {
  max-width: 390px;
  color: #ffffffb3;
  line-height: 1.6;
}

.login-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 23px var(--heading-font);
}

.login-form-side {
  background: var(--paper);
  padding: 60px clamp(28px, 7vw, 105px);
  display: flex;
  align-items: center;
}

.login-form {
  width: 100%;
  max-width: 400px;
}

.login-form h2 {
  font-size: 39px;
  margin-bottom: 9px;
}

.login-form .lede {
  margin-bottom: 30px;
}

.login-form .btn {
  width: 100%;
  margin-top: 9px;
}

.forgot {
  text-align: right;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

/* ==========================================
   TABLET RESPONSIVE STYLES
   ========================================== */

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    transform: translateX(-100%);
    box-shadow: 8px 0 24px #000e2f66;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .main {
    width: 100%;
    margin-left: 0;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 13px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    font-size: 29px;
    line-height: 1;
    transition:
      background 0.2s ease,
      transform 0.2s ease;
  }

  .mobile-close:hover {
    background: #013ecd;
    transform: rotate(90deg);
  }

  body.nav-collapsed .sidebar {
    width: var(--sidebar);
    padding: 26px 18px;
  }

  body.nav-collapsed .main {
    width: 100%;
    margin-left: 0;
  }

  body.nav-collapsed .brand strong,
  body.nav-collapsed .nav-label {
    display: block;
  }

  body.nav-collapsed .nav {
    display: grid;
  }

  body.nav-collapsed .sidebar-foot {
    display: block;
  }

  body.nav-collapsed .brand {
    justify-content: flex-start;
    padding-left: 10px;
    padding-right: 10px;
  }

  body.nav-collapsed .nav a {
    justify-content: flex-start;
  }

  .topbar {
    padding: 0 20px;
    height: 70px;
  }

  .topbar .crumb {
    display: none;
  }

  .content {
    padding: 28px 20px;
  }

  h2 {
    font-size: 39px;
  }

  .hero {
    display: block;
    min-width: 0;
  }

  .hero-actions {
    margin-top: 20px;
  }

  .grid-2,
  .grid-3,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-list {
    padding: 0 0 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-window {
    padding: 22px 0 0;
    min-height: 400px;
  }

  .login-page {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 310px;
    padding: 32px 26px;
  }

  .login-art h1 {
    margin: 35px 0 12px;
    font-size: 47px;
  }

  .login-form-side {
    padding: 42px 26px;
  }
}

/* ==========================================
   MOBILE RESPONSIVE STYLES
   ========================================== */

@media (max-width: 520px) {
  .sidebar {
    width: min(272px, 86vw);
    padding: 22px 15px;
  }

  .brand {
    padding: 4px 8px 26px;
    gap: 10px;
  }

  .brand-mark {
    width: 35px;
    height: 35px;
    font-size: 17px;
  }

  .brand strong {
    font-size: 20px;
  }

  .nav a {
    padding: 11px 10px;
    font-size: 13px;
  }

  .nav-icon {
    display: none;
  }

  .mobile-close {
    width: 32px;
    height: 32px;
    font-size: 27px;
  }

  .sidebar-foot {
    padding: 15px 8px 0;
    font-size: 11px;
  }

  .logout-button {
    font-size: 11px;
  }

  .content {
    padding: 24px 16px;
  }

  .site-footer {
    padding: 14px 16px;
    font-size: 11px;
    background-color: #ffffff;
  }

  .topbar {
    padding: 0 14px;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .user-profile {
    margin-left: auto;
  }

  .hero {
    margin-bottom: 22px;
  }

  h2 {
    font-size: 35px;
  }

  .hero-actions {
    display: grid;
    gap: 8px;
  }

  .hero-actions .btn,
  .hero > .btn {
    width: 100%;
    text-align: center;
  }

  .panel {
    padding: 18px;
    border-radius: 12px;
  }

  .panel-title {
    align-items: flex-start;
  }

  .profile-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
  }

  .profile-head button {
    margin-left: 0 !important;
    width: 100%;
  }

  .profile-head h2 {
    font-size: 27px;
  }

  .message {
    max-width: 88%;
  }

  .map-box {
    min-height: 360px;
  }

  .map-label {
    padding: 8px 9px;
    font-size: 10px;
  }

  .login-art {
    min-height: 285px;
  }

  .login-art h1 {
    font-size: 40px;
  }

  .login-form-side {
    padding: 34px 20px;
  }
}

/* ==========================================
   SMALL MOBILE DEVICES
   ========================================== */

@media (max-width: 380px) {
  .sidebar {
    width: 82vw;
    padding: 20px 13px;
  }

  .brand {
    padding-bottom: 22px;
  }

  .brand strong {
    font-size: 18px;
  }

  .nav a {
    padding: 10px 8px;
    font-size: 12px;
  }

  .mobile-close {
    top: 10px;
    right: 10px;
  }
}

/* ==========================================
   PROFILE INTEREST TAGS
   ========================================== */

.interest-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0;
  margin-top: 10px;
}

.interest-tags .interest-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 2px solid #6b7280;
  border-radius: 999px;
  background: #1f2937;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

/* Profile displayed interests */

#profile-interests {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

#profile-interests .tag {
  margin: 0;
}

/* Hover */

.interest-tags .interest-tag:hover {
  background: #374151;
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.interest-tags .interest-tag.selected {
  background: var(--accent) !important;
  color: var(--ink) !important;
  border-width: 3px !important;
  border-style: solid !important;
  border-color: var(--ink) !important;
  box-shadow: 0 0 0 1px var(--accent) !important;
}

.interest-tags .interest-tag.selected:hover {
  background: var(--accent) !important;
  color: var(--ink) !important;
  border-width: 1px !important;
  border-style: solid !important;
  border-color: var(--ink) !important;
  box-shadow: 0 0 0 1px var(--accent) !important;
}

/* Keyboard focus */

.interest-tags .interest-tag:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ==========================================
   JOINED EVENT BUTTON
   ========================================== */

.event-action-btn.joined {
  background: #16a34a;
  color: #fff;
  transition: all 0.2s ease;
}

/* Keep event action text readable on hover */

.event-action-btn:hover {
  color: #fff;
}

/* Hovering a joined event warns the user */

.event-action-btn.joined:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

/* ==========================================
   CREATE EVENT MODAL
   ========================================== */

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: rgba(6, 6, 6, 0.55);
  overflow-y: auto;
}

.event-modal[hidden] {
  display: none;
}

.event-modal-content {
  width: min(700px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.event-modal-content .panel-title {
  margin-bottom: 24px;
}

.event-modal-content .form-row {
  margin-bottom: 18px;
}

@media (max-width: 700px) {
  .event-modal {
    padding: 15px;
  }

  .event-modal-content {
    padding: 22px;
    max-height: 94vh;
  }
}

/* ==========================================
   FRIEND REQUEST OVERLAY
   ========================================== */

.friend-request-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 20, 42, 0.45);
  backdrop-filter: blur(4px);
}

.friend-request-overlay[hidden] {
  display: none;
}

.friend-request-modal {
  width: min(700px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Friend request header */

.friend-request-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.friend-request-modal-header h2 {
  margin: 4px 0 0;
}

.friend-request-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #f1f3f5;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.friend-request-close:hover {
  background: #e5e7eb;
}

/* Friend request list */

.friend-request-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.friend-request-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fafafa;
}

/* Friend information */

.friend-request-person {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.friend-request-avatar {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}

.friend-request-person strong {
  display: block;
  margin-bottom: 4px;
}

.friend-request-person span {
  display: block;
  color: #6b7280;
  font-size: 14px;
}

/* Friend request buttons */

.friend-request-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.friend-request-decline {
  background: #f1f3f5;
  color: #1f2937;
}

.friend-request-accept {
  background: #2563eb;
  color: #ffffff;
}

.friend-request-decline:hover {
  background: #e5e7eb;
}

.friend-request-accept:hover {
  opacity: 0.9;
}

/* Empty state */

.friend-request-empty {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}

.friend-request-empty .notification-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.friend-request-empty h3 {
  margin: 0 0 8px;
  color: #111827;
}

.friend-request-empty p {
  margin: 0;
  line-height: 1.6;
}

/* Prevent background scrolling */

body.friend-request-modal-open {
  overflow: hidden;
}

/* Friend request mobile layout */

@media (max-width: 700px) {
  .friend-request-modal {
    padding: 22px;
    max-height: 85vh;
  }

  .friend-request-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .friend-request-actions {
    width: 100%;
  }

  .friend-request-actions button {
    flex: 1;
  }
}

/* ==========================================
   FRIEND REQUEST PROFILE LINK
   ========================================== */

.friend-request-profile-link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
  padding: 4px;
  transition: background 0.2s ease;
}

.friend-request-profile-link:hover {
  background: #f1f3f5;
}

.friend-request-profile-link strong {
  color: #111827;
}

.friend-request-profile-link span {
  color: #6b7280;
}

/* ==========================================
   EVENT FILTERS
   ========================================== */

.event-filter {
  margin: 30px 0 24px;
}

.event-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.event-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}

.event-filter {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  color: var(--navy);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.event-filter:hover {
  transform: translateY(-1px);
  background: var(--navy);
  color: #ffffff;
}

.event-filter.active {
  background: var(--navy);
  color: #ffffff;
  border: 1px solid var(--line);
}

/* Message shown when a category has no events */

.no-filtered-events {
  grid-column: 1 / -1;
  padding: 30px;
  text-align: center;
  color: #6b7280;
}

.upcoming-event-creator {
  margin-top: 10px;
  font-size: 0.9rem;
}

.upcoming-event-creator a {
  color: #003da5;
  font-weight: 600;
  text-decoration: none;
}

.upcoming-event-creator a:hover {
  text-decoration: underline;
}

/* ==========================================
   HOME PAGE — UPCOMING EVENTS
   ========================================== */

.upcoming-event-card {
  padding: 22px 24px;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #d7dbe0;
  border-radius: 14px;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

/* Hover */

.upcoming-event-card:hover {
  transform: translateY(-3px);
  border-color: #bfc6cf;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.07);
}

/* Category */

.upcoming-event-card .eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3154c6;
}

/* Event title */

.upcoming-event-card h4 {
  margin: 0 0 14px;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
  color: #0b1736;
}

/* Date and time */

.upcoming-event-card p {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #17213a;
}

/* Location */

.upcoming-event-card p:nth-of-type(2) {
  color: #697386;
}

/* Host */

.upcoming-event-card p:last-of-type {
  margin-top: auto;
  padding-top: 14px;
  margin-bottom: 0;
  font-size: 12px;
  color: #697386;
}

.upcoming-event-card p:last-of-type a {
  color: #003da5;
  font-weight: 600;
  text-decoration: none;
}

.upcoming-event-card p:last-of-type a:hover {
  text-decoration: underline;
}

/* View event */

.upcoming-event-card .mini-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #003da5;
  text-decoration: none;
}

.upcoming-event-card .mini-link:hover {
  text-decoration: underline;
}

/* ==========================================
   FRIENDS PREVIEW
   ========================================== */

.friends-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.friends-subtitle {
  margin: 5px 0 0;
  color: var(--muted, #64748b);
  font-size: 13px;
}

.friends-preview {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.friends-preview-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.friends-preview-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e2e8f0);
}

.friends-count {
  color: var(--muted, #64748b);
  font-size: 13px;
}

/* ==========================================
   FRIEND ROWS
   ========================================== */

.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  transition: background 0.2s ease;
}

.friend-row:hover {
  background: var(--surface-soft, #f1f5f9);
}

.friend-row-compact {
  padding: 8px;
}

.friend-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 50%;
  background: #e0eaff;
  color: #244b86;
  font-size: 17px;
  font-weight: 700;
}

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

.friend-details {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.friend-details strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.friend-details span {
  color: var(--muted, #64748b);
  font-size: 12px;
}

.friend-arrow {
  color: var(--muted, #64748b);
  font-size: 20px;
}

/* ==========================================
   FRIENDS OVERLAY
   ========================================== */

.friends-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
}

.friends-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: min(680px, 85vh);
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 20px;
  background: var(--panel, #ffffff);
  color: var(--text, #172033);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
}

.friends-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.friends-dialog-header h2 {
  margin: 0;
  font-size: 22px;
}

.friends-dialog-header p {
  margin: 6px 0 0;
  color: var(--muted, #64748b);
  font-size: 13px;
}

.friends-close-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft, #f1f5f9);
  color: inherit;
  font-size: 25px;
  cursor: pointer;
}

.friends-close-button:hover {
  background: var(--border, #e2e8f0);
}

.friends-search {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface, #ffffff);
  color: inherit;
  font: inherit;
  outline-offset: 3px;
}

.friends-dialog-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
}

/* ==========================================
   FRIENDS MOBILE RESPONSIVE STYLES
   ========================================== */

@media (max-width: 600px) {
  .friends-overlay {
    align-items: stretch;
    padding: 0;
  }

  .friends-dialog {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    box-sizing: border-box;
    padding: 22px 18px;
    border: 0;
    border-radius: 0;
  }

  .friends-preview-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ==========================================
   ADD FRIEND BUTTON
   ========================================== */

#add-friend-btn.is-friended {
  background-color: #e8eef7;
  color: #244a7c;
  border: 1px solid #cbd8ea;
  cursor: default;
  opacity: 1;
}

/* ==========================================
   CAMPUS MAP DASHBOARD
   ========================================== */

.map-hero {
  margin-bottom: 24px;
}

.map-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(250px, 1fr);
  align-items: stretch;
  gap: 20px;
  margin-bottom: 24px;
}

.map-dashboard .map-panel,
.map-dashboard .map-events-panel {
  min-width: 0;
  margin: 0;
}

.map-dashboard .map-panel {
  align-self: start;
}

.map-dashboard .map-panel .panel-title p,
.map-dashboard .map-events-panel .panel-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.map-status {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ==========================================
   CAMPUS MAP CONTAINER
   ========================================== */

.campus-map {
  width: 100%;
  height: 650px;
  min-height: 400px;
  overflow: hidden;
  border-radius: 12px;
  background: #e8eef4;
}

/* ==========================================
   MAP EVENTS SIDEBAR
   ========================================== */

.map-dashboard .map-events-panel {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  overflow: hidden;
}

.map-dashboard .map-events-panel .panel-title {
  flex-shrink: 0;
  align-items: flex-start;
}

.map-dashboard #map-events-list {
  display: block;
  flex: 1;
  min-height: 0;
  max-height: 650px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ==========================================
   MAP EVENT LINKS
   ========================================== */

.map-event-link {
  display: block;
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.map-event-link:last-child {
  border-bottom: 0;
}

.map-event-link strong,
.map-event-link span {
  display: block;
}

.map-event-link strong {
  font-size: 14px;
  line-height: 1.4;
}

.map-event-link span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.map-dashboard .activity-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ==========================================
   LEAFLET POPUPS
   ========================================== */

.campus-map .leaflet-popup-content p {
  margin: 6px 0;
}

.campus-map .leaflet-popup-content strong {
  font-size: 15px;
}

/* ==========================================
   MAP RESPONSIVE LAYOUT
   ========================================== */

@media (max-width: 900px) {
  .map-dashboard {
    grid-template-columns: minmax(0, 1fr);
  }

  .campus-map {
    height: 500px;
    min-height: 350px;
  }

  .map-dashboard #map-events-list {
    max-height: 350px;
  }
}

@media (max-width: 600px) {
  .campus-map {
    height: 380px;
    min-height: 300px;
  }
}

/* ==========================================
   LEAFLET MAP FIXES
   ========================================== */

#campus-map {
  position: relative;
  width: 100%;
  height: 650px;
  min-height: 400px;
  overflow: hidden;
  border-radius: 12px;
  background: #e8eef4;
}

/* Keep Leaflet filling the map container */

#campus-map .leaflet-container,
#campus-map.leaflet-container {
  width: 100%;
  height: 100%;
  background: #e8eef4;
}

/* ==========================================
   CAMPUS LOCATION DROPDOWN
   ========================================== */

.location-suggestions {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 14, 47, 0.1);
}

.location-suggestions[hidden] {
  display: none;
}

.location-option {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.location-option:hover,
.location-option:focus-visible {
  background: #edf3ff;
  color: var(--royal-blue);
}

.location-option:focus-visible {
  outline: 2px solid var(--royal-blue);
  outline-offset: -2px;
}

/* MAP SIDEBAR HOVER */

.map-event-link {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.map-event-link:hover,
.map-event-link.is-active {
  background-color: #edf3ff;
  border-color: #2563eb;
  transform: translateX(3px);
}

/* Prevent global image rules from resizing map tiles */

#campus-map .leaflet-tile,
#campus-map .leaflet-marker-icon,
#campus-map .leaflet-marker-shadow {
  max-width: none !important;
  max-height: none !important;
}

/* ==========================================
   RESPONSIVE LEAFLET MAP HEIGHT
   ========================================== */

@media (max-width: 900px) {
  #campus-map {
    height: 500px;
    min-height: 350px;
  }
}

@media (max-width: 600px) {
  #campus-map {
    height: 380px;
    min-height: 300px;
  }
}
/* ==========================================
   JOURNAL entry cards
   ========================================== */

#journal-entries {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}
/* each card */
.journal-entry {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: (#f8fafc);
  padding: 20px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

/* hover effect for journal entry cards */
.journal-entry:hover {
  border-color: var(--royal-blue);
  box-shadow: 0 4px 12px rgba(0, 14, 47, 0.1);
}
/* Journal title */
.journal-entry h4 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: #0f172a;
}

/* entry date*/
.journal-entry small {
  display: block;
  font-size: 0.875rem;
  color: var(--ink);
  font-weight: bold;
  margin-bottom: 8px;
}

/* journal description */
.journal-entry p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* moodtext for journal entry */
.journal-entry .journal-mood {
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: bold;
  margin-bottom: 12px;
}

/* public / private indicator for journal entry */
.journal-entry .tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  background-color: var(--line);
  color: var(--ink);
}
/* ==========================================
Journal card footer
   ========================================== */
/* journal footer */
.journal-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
/* delete button */
.journal-delete-btn {
  background: transparent;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
/* hover effect for delete button */
.journal-delete-btn:hover {
  background: #fecaca;
  border-color: #f87171;
  color: #b91c1c;
}
.journal-delete-btn:focus-visible {
  outline: 2px solid #f87171;
  outline-offset: 3px;
}

.journal-delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* ==========================================
   PUBLIC CHAT CATEGORIES
========================================== */

#public-chat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 0.75fr));
  gap: 8px;
  padding: 10px 0;
}

.public-chat-channel {
  width: 100%;
  min-width: 0;
  padding: 9px 6px;

  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;

  color: #1f2937;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;

  cursor: pointer;
  transition: background-color 0.2s ease,
              border-color 0.2s ease,
              color 0.2s ease;
}

/* Hover */
.public-chat-channel:hover {
  background-color: #e0e7ff;
  border-color: #93c5fd;
}

/* Active category */
.public-chat-channel.active {
  background-color: #2563eb;
  border-color: #2563eb;
  color: white;
  font-weight: 600;
}

/* Keyboard accessibility */
.public-chat-channel:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
/* ==========================================
   PRIVATE CHAT CATEGORIES
========================================== */

#private-chat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 0;
}

.private-chat-channel {
  width: 100%;
  min-width: 0;
  padding: 9px 6px;

  background-color: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;

  color: #1f2937;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;

  cursor: pointer;
  transition: background-color 0.2s ease,
              border-color 0.2s ease,
              color 0.2s ease;
}

/* Hover */
.private-chat-channel:hover {
  background-color: #e0e7ff;
  border-color: #93c5fd;
}

/* Selected private chat */
.private-chat-channel.active {
  background-color: #2563eb;
  border-color: #2563eb;
  color: white;
  font-weight: 600;
}

/* Keyboard accessibility */
.private-chat-channel:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}
/* ==========================================
   CHAT SIDEBAR SPACING
========================================== */

.chat-layout {
  display: flex;
  gap: 24px;
}

/* ==========================================
   CHAT MESSAGE BUBBLES
========================================== */

/* Message history layout */
#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

/* All messages */
.chat-message {
  display: flex;
  flex-direction: column;
  align-self: flex-start;

  max-width: 75%;
  padding: 12px 16px;

  background-color: #f1f3f5;
  color: #1f2937;

  border-radius: 18px 18px 18px 5px;
  overflow-wrap: anywhere;
}

/* Logged-in user's messages */
.chat-message.own-message {
  align-self: flex-end;

  background-color: #2563eb;
  color: #ffffff;

  border-radius: 18px 18px 5px 18px;
}

/* Sender name */
.chat-message strong {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Timestamp */
.chat-message small {
  font-size: 10px;
  opacity: 0.7;
  margin-bottom: 5px;
}

/* Message text */
.chat-message p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Right-align sender details on own messages */
.chat-message.own-message strong,
.chat-message.own-message small {
  text-align: right;
}

/* ==========================================
   CHAT CONVERSATION CONTAINER
========================================== */

/* Main chat panel */
.chat-room {
  flex: 1;
  min-width: 0;
  min-height: 650px;

  display: flex;
  flex-direction: column;

  padding: 20px;
  background-color: #ffffff;

  border: 1px solid #d1d5db;
  border-radius: 12px;
}

/* Chat title */
#chat-room-title {
  margin: 0 0 16px;
  padding-bottom: 16px;

  border-bottom: 1px solid #e5e7eb;

  font-size: 24px;
  font-weight: 700;
}

/* Messages fill the available space */
#chat-messages {
  flex: 1;
  width: 100%;
  min-height: 350px;
  box-sizing: border-box;
}

/* Message input area */
#chat-message-form {
  display: flex;
  align-items: center;
  gap: 12px;

  width: 100%;
  margin-top: 16px;
  padding-top: 16px;

  border-top: 1px solid #e5e7eb;
}

/* Message input */
#chat-message-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;

  border: 1px solid #d1d5db;
  border-radius: 8px;

  font-size: 14px;
}

/* Send button */
#chat-send-btn {
  padding: 12px 20px;

  background-color: #2563eb;
  color: #ffffff;

  border: none;
  border-radius: 8px;

  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#chat-send-btn:hover {
  background-color: #1d4ed8;
}

/* ==========================================
   CHAT LAYOUT
========================================== */

.chat-layout {
  display: grid;
  grid-template-columns: 35% minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
  width: 100%;
}

/* Right-side conversation panel */
.chat-room {
  display: flex;
  flex-direction: column;

  width: 100%;
  min-width: 0;
  min-height: 650px;
  box-sizing: border-box;

  padding: 20px;
  background-color: #ffffff;

  border: 1px solid #d1d5db;
  border-radius: 12px;
}

/* Conversation title */
#chat-room-title {
  width: 100%;
  margin: 0 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

/* Messages fill the chat panel */
#chat-messages {
  display: flex;
  flex-direction: column;
  flex: 1;

  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 16px 8px;
}

/* Message form stays at bottom */
#chat-message-form {
  display: flex;
  align-items: center;
  gap: 12px;

  width: 100%;
  box-sizing: border-box;
  margin-top: auto;
  padding-top: 16px;

  border-top: 1px solid #e5e7eb;
}

#chat-message-input {
  flex: 1;
  min-width: 0;
}

#chat-send-btn {
  flex-shrink: 0;
}

/* ==========================================
   CHAT MESSAGE NAME + TIME
========================================== */

.chat-message {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 10px;
  row-gap: 6px;
  align-items: baseline;
  justify-content: start;
}

/* Sender name */
.chat-message strong {
  grid-column: 1;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

/* Timestamp beside name */
.chat-message small {
  grid-column: 2;
  margin: 0;
  font-size: 11px;
  opacity: 0.75;
}

/* Message text underneath */
.chat-message p {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Keep own messages aligned to the right */
.chat-message.own-message {
  align-self: flex-end;
}

/* ==========================================
   CHAT PROFILE PICTURES
========================================== */

.chat-message:not(.own-message) {
  position: relative;
  margin-left: 42px;
}

.chat-message-avatar {
  position: absolute;
  left: -42px;
  top: 8px;

  width: 32px;
  height: 32px;

  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #e5e7eb;
}

/* No avatar for your own messages */
.chat-message.own-message .chat-message-avatar {
  display: none;
}

/* ==========================================
   SCROLLABLE CHAT MESSAGE HISTORY
========================================== */


/* ==========================================
   SCROLLABLE CHAT MESSAGE HISTORY - FIXED
========================================== */

/* Right-side conversation panel */
.chat-room {
  display: flex;
  flex-direction: column;
  height: 650px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* Scroll only the messages */
#chat-messages {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;

  gap: 12px;
  padding: 16px 8px;

  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  overscroll-behavior: contain;
}

/* Prevent messages from shrinking */
.chat-message {
  flex-shrink: 0;
}

/* Keep title and input visible */
#chat-room-title,
#chat-message-form {
  flex-shrink: 0;
}

#chat-message-form {
  margin-top: 0;
}

/* Scrollbar styling */
#chat-messages::-webkit-scrollbar {
  width: 7px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================
   CHAT MESSAGE HISTORY SCROLLBAR
========================================== */

/* Actual conversation container */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 650px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* Keep conversation title fixed */
#chat-room-title {
  flex-shrink: 0;
}

/* Scrollable message history */
#chat-messages {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;

  gap: 12px;
  padding: 16px 8px;

  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  overscroll-behavior: contain;
}

/* Prevent individual messages from shrinking */
.chat-message {
  flex-shrink: 0;
}

/* Keep input at bottom */
#chat-message-form {
  flex-shrink: 0;
  margin-top: 0;
}

/* Scrollbar appearance */
#chat-messages::-webkit-scrollbar {
  width: 7px;
}

#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================
   CHAT MESSAGE EDIT / DELETE
========================================== */

.chat-message.editable-message {
  cursor: pointer;
}

.chat-message.editable-message:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}

.chat-message-actions[hidden],
.chat-message [hidden] {
  display: none !important;
}

.chat-message-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

.chat-message-actions button {
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chat-message-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-message.is-editing {
  cursor: default;
}

.chat-edit-input {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
  resize: vertical;
}

.chat-edit-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.chat-edit-actions button {
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chat-edit-actions button:first-child {
  background: #ffffff;
  color: #013ecd;
}

.chat-edit-actions button:last-child {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}
/* Delete message button */
.chat-message-actions button:last-child {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #dc2626;
}

/* Delete button hover */
.chat-message-actions button:last-child:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* ==========================================
   CHATS: MOBILE CONVERSATION LAYOUT
   ========================================== */

/* Hide mobile toggle on desktop */
body[data-page="chats"] .mobile-conversations-toggle {
  display: none;
}

/* Mobile and tablet */
@media (max-width: 800px) {

  body[data-page="chats"] .content {
    padding: 18px 14px 24px;
  }

  body[data-page="chats"] .hero {
    margin-bottom: 18px;
  }

  body[data-page="chats"] .hero h2 {
    font-size: clamp(27px, 7vw, 36px);
  }

  /* Stack conversation list above messages */
  body[data-page="chats"] .chat-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    min-height: 0;
    overflow: hidden;
  }

  /* Conversation selection section */
  body[data-page="chats"] .chat-sidebar {
    width: 100%;
    padding: 0;
    border: 0;
    border-bottom: 1px solid #e2e8f0;
    min-width: 0;
  }

  /* Mobile Show/Hide button */
  body[data-page="chats"] .mobile-conversations-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px;
    border: 0;
    background: #f8fafc;
    color: #000e2f;
    font-weight: 800;
    font-size: 15px;
    text-align: left;
  }

  body[data-page="chats"] .mobile-conversations-toggle .toggle-right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #013ecd;
    font-size: 13px;
  }

  body[data-page="chats"] .mobile-conversations-toggle .toggle-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
  }

  body[data-page="chats"] .chat-sidebar.mobile-expanded .toggle-chevron {
    transform: rotate(180deg);
  }

  /* Hide desktop Conversations heading */
  body[data-page="chats"] .chat-sidebar > h3 {
    display: none;
  }

  /* Collapsible channel lists */
  body[data-page="chats"] .chat-sidebar .chat-groups {
    display: none;
    padding: 10px 14px 14px;
  }

  body[data-page="chats"] .chat-sidebar.mobile-expanded .chat-groups {
    display: block;
  }

  body[data-page="chats"] .chat-group {
    margin-bottom: 10px;
  }

  body[data-page="chats"] .chat-group summary {
    padding: 10px 0;
    cursor: pointer;
  }

  /* Scroll long channel/friend lists */
  body[data-page="chats"] #public-chat-list,
  body[data-page="chats"] #private-chat-list {
    max-height: 210px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Larger touch targets */
  body[data-page="chats"] .public-chat-channel,
  body[data-page="chats"] .private-chat-channel {
    min-height: 42px;
  }

  /* Chat conversation area */
  body[data-page="chats"] .chat-main {
    display: flex;
    flex-direction: column;
    height: min(70dvh, 650px);
    min-height: 350px;
    width: 100%;
    padding: 14px 12px 12px;
    overflow: hidden;
  }

  /* Active chat heading */
  body[data-page="chats"] #chat-room-title {
    font-size: 17px;
    line-height: 1.3;
    margin: 0;
    padding: 0 0 12px;
    overflow-wrap: anywhere;
  }

  /* Scroll messages independently */
  body[data-page="chats"] #chat-messages {
    flex: 1 1 0;
    min-height: 0;
    padding: 12px 6px;
    gap: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Message bubbles */
  body[data-page="chats"] .chat-message {
    max-width: 83%;
    overflow-wrap: anywhere;
  }

  body[data-page="chats"] .chat-message:not(.own-message) {
    margin-left: 36px;
  }

  /* Profile pictures */
  body[data-page="chats"] .chat-message-avatar {
    left: -36px;
    width: 28px;
    height: 28px;
  }

  /* Message input stays below scrollable history */
  body[data-page="chats"] #chat-message-form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 10px;
    min-width: 0;
  }

  body[data-page="chats"] #chat-message-input {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 16px;
    padding: 11px;
  }

  body[data-page="chats"] #chat-send-btn {
    flex: 0 0 auto;
    min-height: 43px;
    padding: 10px 13px;
  }

  /* Touch-friendly edit/delete controls */
  body[data-page="chats"] .chat-message-actions button {
    min-height: 36px;
    padding: 8px 12px;
  }
}

/* Smaller phones */
@media (max-width: 380px) {

  body[data-page="chats"] .content {
    padding-left: 10px;
    padding-right: 10px;
  }

  body[data-page="chats"] .chat-main {
    padding-left: 8px;
    padding-right: 8px;
  }

  body[data-page="chats"] .chat-message {
    max-width: 88%;
  }
}

/* ==========================================
   GUEST CHAT STYLING
========================================== */

/* Private chats guest message */
.guest-private-message {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 16px 10px;
}

.guest-private-message strong {
  display: block;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
}

.guest-private-message p {
  font-size: 13px;
  line-height: 1.6;
  color: #64748b;
  margin: 0;
  overflow-wrap: break-word;
}

.guest-signup-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 11px 10px;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  line-height: 1.4;
}

.guest-signup-btn:hover {
  background: #1d4ed8;
}

/* Guest prompt in message input area */
.guest-chat-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 16px;
  border-top: 1px solid #e2e8f0;
}

.guest-chat-prompt[hidden] {
  display: none;
}

.guest-chat-prompt span {
  flex: 1 1 200px;
  font-size: 14px;
  color: #64748b;
}

.guest-chat-login-btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}

.guest-chat-login-btn:hover {
  background: #1d4ed8;
}

/* Ensure the guest sidebar content fits */
#private-chat-list {
  min-width: 0;
}

#chat-message-form[hidden] {
  display: none;
}

/* ==========================================
   FIX GUEST PRIVATE CHAT LAYOUT
========================================== */

/* Make the conversation sidebar wider */
.chat-layout {
  grid-template-columns: minmax(320px, 35%) minmax(0, 1fr);
}

/* Allow private chat content to use full width */
.chat-sidebar,
.chat-groups,
.chat-group,
#private-chat-list {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Improve guest message spacing */
.guest-private-message {
  width: 100%;
  padding: 16px 12px;
  box-sizing: border-box;
  gap: 12px;
}

/* Keep the heading readable */
.guest-private-message strong {
  font-size: 15px;
  line-height: 1.5;
}

/* Improve description readability */
.guest-private-message p {
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: normal;
}

/* Make sign-in button fill available space */
.guest-signup-btn {
  width: 100%;
  display: block;
  box-sizing: border-box;
  padding: 12px;
  font-size: 13px;
  line-height: 1.4;
}

/* Preserve mobile layout */
@media (max-width: 800px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   FIX GUEST PRIVATE CHAT MESSAGE WIDTH
========================================== */

/* Let the guest message span all three columns */
#private-chat-list .guest-private-message {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 16px 12px;
}

/* Keep the heading on fewer lines */
#private-chat-list .guest-private-message strong {
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}

/* Make the description readable */
#private-chat-list .guest-private-message p {
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

/* Center the sign-in button */
#private-chat-list .guest-signup-btn {
  display: block;
  width: 100%;
  padding: 12px;
  text-align: center;
  box-sizing: border-box;
}

/* ==========================================
   CHAT POLICY NOTICE
========================================== */

.chat-policy-notice {
  margin: 14px 0 0;
  max-width: 700px;
  font-size: 14px;
  line-height: 1.6;
  color: #64748b;
}

.chat-policy-notice a {
  color: #013ecd;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-policy-notice a:hover {
  color: #000e2f;
}

.chat-policy-notice a:focus-visible {
  outline: 2px solid #013ecd;
  outline-offset: 3px;
  border-radius: 2px;
}
.guest-journal-message[hidden],
.guest-journal-save-notice[hidden],
#journal-entries[hidden],
#entry-count[hidden] {
  display: none !important;
}