:root {
  --sidebar-w:    280px;
  --page-bg-top:  #0f1720;
  --page-bg-bot:  #1b2838;
  --content-bg:   #16202d;
  --content-bg-alt: #1b2838;
  --panel-glow:   rgba(102, 192, 244, 0.06);

  --border:       #2a3f54;
  --border-light: #3d5773;
  --line:         #24384a;

  --text:         #c6d4df;
  --text-soft:    #8f98a0;
  --text-faint:   #5f6b73;

  --link:         #66c0f4;
  --link-visited: #7fb3d9;
  --link-hover:   #a4d7f5;

  --accent:       #66c0f4;
  --accent-dim:   #417a9b;

  --titlebar-from: #1b2838;
  --titlebar-to:   #223549;
  --titlebar-blue-from: #1a2f42;
  --titlebar-blue-to:   #23425c;
  --titlebar-warm-from: #1e2a1c;
  --titlebar-warm-to:   #2b3d24;

  --red:    #e14b4b;
  --red-dark: #a52c2c;
  --green: #a4d007;
  --green-dark: #5c7e10;
  --gold: #cc9900;
  --gold-dark: #8a6300;

  --stamp-active-bg: rgba(164,208,7,0.12);  --stamp-active-text: #b6e23a;
  --stamp-pending-bg: rgba(204,153,0,0.12); --stamp-pending-text: #e0b83f;
  --stamp-banned-bg: rgba(225,75,75,0.12);  --stamp-banned-text: #ef7a7a;

  --font-body: "Segoe UI", "Motiva Sans", Arial, Helvetica, sans-serif;
  --font-display: "Segoe UI", "Motiva Sans", Arial, Helvetica, sans-serif;
  --font-mono: "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  min-height: 100vh;
  background-color: var(--page-bg-bot);
  background-image:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(102,192,244,0.08), transparent 60%),
    linear-gradient(180deg, var(--page-bg-top) 0%, var(--page-bg-bot) 420px, var(--page-bg-bot) 100%);
  background-attachment: fixed;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.5em 0; color: var(--text); }

a { color: var(--link); text-decoration: none; }
a:visited { color: var(--link-visited); }
a:hover { color: var(--link-hover); text-decoration: underline; }

p { line-height: 1.5; margin: 0 0 0.7em 0; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.2em 0;
}

.blink { /* intentionally inert: kept for markup compatibility */ }

/* `.hidden` is a utility class meant to always win regardless of what
   other rules say — several components (chat panel, lightbox) also set
   their own `display` (flex) at equal specificity, and since those rules
   are declared later in this file, plain CSS cascade order made them win
   over `.hidden`, which is backwards: hidden must always mean hidden.
   !important here is intentional, not sloppiness — this is the one class
   in the file whose entire job is to override everything else. */
.hidden { display: none !important; }

.loading-text { color: var(--text-soft); }

.new-badge {
  display: inline-block;
  background: var(--green);
  color: #16200a;
  font-family: var(--font-body);
  font-weight: bold;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
}

/* =========================
   PAGE TITLE — Steam-style section header:
   uppercase, letter-spaced, thin blue accent underline
========================= */
.rainbow-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #eaf3fa;
  display: block;
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--accent-dim);
  background: linear-gradient(90deg, var(--accent) 0%, transparent 55%);
  -webkit-background-clip: text;
  background-clip: text;
}
@supports not (background-clip: text) {
  .rainbow-text { color: #eaf3fa; }
}

.tagline { color: var(--text-soft); font-weight: normal; }

/* =========================
   BUTTONS
   default = Steam blue-grey nav button;
   .pink = the green "primary action" button (repurposed, class name unchanged)
========================= */
button, input[type="submit"] {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: #dbeaf5;
  padding: 0.45em 1.1em;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  cursor: pointer;
  background: linear-gradient(180deg, #2c4053 0%, #1a2a38 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  transition: background 0.15s ease, border-color 0.15s ease;
}
button:hover, input[type="submit"]:hover {
  background: linear-gradient(180deg, #375069 0%, #223649 100%);
  border-color: var(--accent);
}
button:active, input[type="submit"]:active {
  background: linear-gradient(180deg, #1a2a38 0%, #2c4053 100%);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button.danger {
  color: #fff;
  border-color: var(--red-dark);
  background: linear-gradient(180deg, #d15b5b 0%, #a52c2c 100%);
}
button.danger:hover { background: linear-gradient(180deg, #e06f6f 0%, #b93838 100%); }

button.pink {
  color: #16200a;
  border-color: var(--green-dark);
  background: linear-gradient(180deg, #c2e33d 0%, #a4d007 55%, #8bb406 100%);
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
button.pink:hover { background: linear-gradient(180deg, #d0ec5c 0%, #b3dd1c 55%, #a4d007 100%); }

button.ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.ghost:hover { background: rgba(102,192,244,0.06); color: var(--accent); border-color: var(--accent-dim); }

/* =========================
   FORM FIELDS
========================= */
input[type="text"], input[type="password"], textarea, select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.45em 0.6em;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #0e1720;
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-soft);
  margin-bottom: 0.3em;
}

/* =========================
   DROPZONE — drag & drop file upload, replaces the raw
   <input type="file"> button. The actual <input> is kept in the
   DOM (visually hidden) so all existing upload/change logic keeps
   working unchanged; this is just a nicer front end for it.
========================= */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-control { display: contents; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 22px 16px;
  border: 2px dashed var(--border-light);
  border-radius: 3px;
  background: rgba(102, 192, 244, 0.03);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.dropzone:hover { border-color: var(--accent-dim); color: var(--text); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(102, 192, 244, 0.1);
  color: var(--accent);
}

.dropzone-icon { font-size: 1.3rem; line-height: 1; }
.dropzone-text { font-size: 0.78rem; margin: 0; }
.dropzone-filename {
  font-size: 0.72rem;
  color: var(--accent);
  margin: 2px 0 0 0;
  font-family: var(--font-mono);
  word-break: break-all;
}

/* Compact row variant — used for the avatar/banner pills on the profile header */
.upload-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.dropzone-compact {
  flex-direction: row;
  padding: 8px 14px;
  gap: 8px;
}
.dropzone-compact .dropzone-icon { font-size: 1rem; }
.dropzone-compact .dropzone-text { font-size: 0.74rem; }

/* =========================
   LAYOUT
========================= */
.page { position: relative; z-index: 2; max-width: 700px; margin: 0 auto; padding: 16px 16px calc(80px + env(safe-area-inset-bottom)); }

nav.board-nav {
  display: flex;
  align-items: center;
  gap: 10px 20px;
  flex-wrap: wrap;
  padding: 10px max(22px, env(safe-area-inset-right)) 10px max(22px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #1b2838 0%, #16202b 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  position: sticky;
  top: 0;
  z-index: 10;
}
nav.board-nav a {
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
nav.board-nav a:hover { color: var(--accent); text-decoration: none; }
nav.board-nav a.current { color: var(--accent); border-bottom-color: var(--accent); }
nav.board-nav a.admin-link {
  background: rgba(204,153,0,0.12);
  color: var(--gold);
  padding: 3px 9px;
  border: 1px solid var(--gold-dark);
  border-radius: 2px;
  text-decoration: none;
  font-weight: 700;
}
nav.board-nav a.admin-link:hover { color: #f0d585; border-color: var(--gold); }

nav.board-nav .search-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  position: relative;
}
nav.board-nav .search-group input { width: 150px; }

#globalSearchResults {
  position: absolute;
  top: 40px;
  right: 0;
  background: var(--content-bg);
  border: 1px solid var(--border-light);
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  min-width: 190px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 20;
}
#globalSearchResults:empty { display: none; }
#globalSearchResults p { margin: 0; padding: 7px 10px; border-bottom: 1px solid var(--line); }
#globalSearchResults p:last-child { border-bottom: none; }

/* =========================
   MODULE — Steam "panel" box: dark translucent body,
   flat header bar with a colored left accent bar
========================= */
.module {
  background: linear-gradient(180deg, var(--content-bg-alt) 0%, var(--content-bg) 100%);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25), inset 0 0 40px var(--panel-glow);
  overflow: hidden;
}
.module-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #dbeaf5;
  padding: 9px 12px;
  background: linear-gradient(180deg, var(--titlebar-from) 0%, var(--titlebar-to) 100%);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
}
.module-body { padding: 14px 14px 14px; }

.module.pink .module-title { background: linear-gradient(180deg, var(--titlebar-warm-from) 0%, var(--titlebar-warm-to) 100%); border-left-color: var(--green); }
.module.blue .module-title { background: linear-gradient(180deg, var(--titlebar-blue-from) 0%, var(--titlebar-blue-to) 100%); border-left-color: var(--accent); }

/* =========================
   AUTH SCREEN
========================= */
#matrixCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  pointer-events: none;
  background: var(--page-bg-bot);
}

#particleCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  pointer-events: none;
}

.auth-wrap { position: relative; z-index: 2; max-width: 420px; margin: 60px auto; padding: 0 16px; text-align: center; }
.auth-wrap h1 { font-size: 1.3rem; margin-bottom: 6px; }
.auth-wrap .tagline { margin-bottom: 20px; }

/* ---- Glitch burst (title only, triggered periodically by JS) ---- */
.glitch { position: relative; }
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  opacity: 0;
}
.glitch::before { color: var(--accent); clip-path: inset(0 0 65% 0); }
.glitch::after   { color: var(--gold);   clip-path: inset(65% 0 0 0); }
.glitch.glitch-active::before {
  opacity: 0.85;
  animation: glitchShiftTop 0.26s steps(3, end) 2;
}
.glitch.glitch-active::after {
  opacity: 0.85;
  animation: glitchShiftBottom 0.26s steps(3, end) 2;
}
@keyframes glitchShiftTop {
  0%   { clip-path: inset(0 0 65% 0);   transform: translate(-3px, -1px); }
  30%  { clip-path: inset(10% 0 55% 0); transform: translate(3px, 1px); }
  60%  { clip-path: inset(0 0 70% 0);   transform: translate(-2px, 0); }
  100% { clip-path: inset(0 0 65% 0);   transform: translate(0, 0); }
}
@keyframes glitchShiftBottom {
  0%   { clip-path: inset(65% 0 0 0);   transform: translate(3px, 1px); }
  30%  { clip-path: inset(55% 0 15% 0); transform: translate(-3px, -1px); }
  60%  { clip-path: inset(70% 0 0 0);   transform: translate(2px, 0); }
  100% { clip-path: inset(65% 0 0 0);   transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .glitch::before, .glitch::after { display: none; }
}
.auth-card .module-body { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-card button { align-self: flex-start; margin-top: 4px; }

/* =========================
   MARQUEE STRIP — Steam "event"/announcement bar
========================= */
.marquee-strip {
  background: var(--content-bg);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  margin-bottom: 14px;
}
.marquee-strip span {
  display: block;
  white-space: normal;
}

/* =========================
   CREATE POST FORM
========================= */
.new-post-form textarea { width: 100%; resize: vertical; min-height: 60px; margin-top: 6px; }
.new-post-form input[type="text"] { width: 100%; }
.new-post-form .row { margin-bottom: 10px; }
.new-post-form input[type="file"] { font-size: 0.78rem; margin-top: 6px; color: var(--text-soft); }

/* =========================
   FEED POSTS
========================= */
.post-module .module-title {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: normal;
}
.post-module .module-title img.mini-avatar {
  width: 20px;
  height: 20px;
  border-radius: 2px;
  border: 1px solid var(--border-light);
}
.post-module p.post-body { color: var(--text); }
.post-module img.post-media,
.post-module video.post-media {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin: 8px 0;
  display: block;
}
.post-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-bottom: 8px;
  display: block;
}

.action-bar { display: flex; gap: 8px; margin-bottom: 4px; }
.like-btn {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  font-weight: bold;
  box-shadow: none;
}
.like-btn.liked { background: var(--red); color: #fff; }
.like-btn:hover { background: rgba(225,75,75,0.12); }
.like-btn.liked:hover { background: var(--red-dark); }

/* =========================
   COMMENTS
========================= */
.comments-box {
  background: #0e1720;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px;
  margin-top: 10px;
}
.comments-box h4 {
  margin: 0 0 8px 0;
  font-family: var(--font-display);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.comment-row {
  background: var(--content-bg);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 6px 8px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.comment-row .comment-user {
  font-weight: bold;
  color: var(--link);
  margin-right: 6px;
}
.comment-row .comment-time {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-faint);
  display: block;
  margin-top: 2px;
}
.comment-form { display: flex; gap: 6px; margin-top: 8px; }
.comment-form input[type="text"] { flex: 1; }
.no-comments { color: var(--text-faint); font-size: 0.8rem; font-style: italic; }

/* =========================
   STATUS STAMPS (admin) — small bordered badges
========================= */
.stamp {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.63rem;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.stamp.active  { color: var(--stamp-active-text); background: var(--stamp-active-bg); }
.stamp.pending { color: var(--stamp-pending-text); background: var(--stamp-pending-bg); }
.stamp.banned  { color: var(--stamp-banned-text); background: var(--stamp-banned-bg); }

/* =========================
   ADMIN DASHBOARD
========================= */
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.user-row:last-child { border-bottom: none; }
.user-row p { margin: 0; }
.user-row .username { font-weight: bold; min-width: 110px; color: var(--text); }
.user-row .ban-reason { color: var(--red); font-size: 0.78rem; }
.user-row select { margin-left: auto; }

/* =========================
   PROFILE PAGE — Steam profile hero: dark artwork banner
   that fades into the panel background, glowing avatar frame
========================= */
.profile-banner {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: -38px;
}
.profile-banner img { width: 100%; height: 170px; object-fit: cover; display: block; filter: saturate(1.05); }
.profile-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15,23,32,0) 40%, var(--content-bg-alt) 100%);
  pointer-events: none;
}

.profile-header {
  background: linear-gradient(180deg, var(--content-bg-alt) 0%, var(--content-bg) 100%);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 46px 16px 14px;
  position: relative;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.profile-header .avatar-wrap { position: absolute; top: -32px; left: 16px; }
.profile-header img.avatar {
  width: 78px; height: 78px;
  object-fit: cover;
  border-radius: 2px;
  border: 3px solid var(--accent);
  box-shadow: 0 0 12px rgba(102,192,244,0.55), 0 2px 6px rgba(0,0,0,0.4);
}
.profile-header h1 { font-size: 1.05rem; color: #eaf3fa; }

/* Click/drag directly on the avatar or banner photo to change it */
.image-dropzone { position: relative; cursor: pointer; }
.image-dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.image-dropzone-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(15, 23, 32, 0.6);
  color: #eaf3fa;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 6px;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none; /* purely visual — clicks/drags go to the wrapper */
  transition: opacity 0.15s ease, background 0.15s ease;
}
.image-dropzone:hover .image-dropzone-overlay,
.image-dropzone:focus-visible .image-dropzone-overlay,
.image-dropzone.drag-over .image-dropzone-overlay {
  opacity: 1;
}
.image-dropzone.drag-over .image-dropzone-overlay {
  background: rgba(102, 192, 244, 0.45);
  color: #fff;
}
.image-dropzone-overlay .dropzone-icon { font-size: 1.1rem; }

.hit-counter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #0a1017;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 10px;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  letter-spacing: 1px;
  box-shadow: inset 0 0 8px rgba(102,192,244,0.15);
}
.hit-counter .label { color: var(--text-faint); letter-spacing: 0.03em; font-size: 0.63rem; text-transform: uppercase; }

.field-block .module-body textarea { width: 100%; resize: vertical; }
.field-block .module-body input[type="file"] { margin-top: 6px; font-size: 0.78rem; color: var(--text-soft); }

.people-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.people-columns .module-body a { display: block; padding: 4px 0; }

/* =========================
   PROFILE POSTS SECTION — showcase-style tiles
========================= */
.posts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.post-preview-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 9px 11px;
  background: #0e1720;
  transition: border-color 0.15s ease;
}
.post-preview-card:hover { border-color: var(--accent-dim); }
.post-preview-card .post-preview-title {
  font-weight: bold;
  font-size: 0.86rem;
  color: #eaf3fa;
  margin: 0 0 3px 0;
}
.post-preview-card .post-preview-body {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin: 0 0 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-preview-card .post-preview-media {
  max-width: 100%;
  max-height: 200px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: 6px;
  display: block;
}
.post-preview-card .post-preview-meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  display: flex;
  gap: 10px;
}
.profile-posts-footer {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}
.view-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.no-posts { color: var(--text-faint); font-size: 0.8rem; font-style: italic; }

/* =========================================================
   RESPONSIVE — iPad / tablets, large phones, small phones
   Breakpoints target layout widths, not specific devices:
     1024px  → iPad landscape, small laptops
      900px  → iPad portrait
      680px  → large phones (iPhone Pro Max, Samsung Ultra)
      480px  → standard phones (iPhone, most Android)
      380px  → small/compact phones (iPhone SE / mini)
   plus a short-landscape tweak for phones rotated sideways.
========================================================= */

/* ---- Tablets (iPad portrait/landscape, Android tablets) ---- */
@media (max-width: 1024px) {
  .page { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 900px) {
  .people-columns { gap: 10px; }
}

/* ---- Large phones (iPhone Pro Max, Samsung Galaxy/Ultra) ---- */
@media (max-width: 680px) {
  .page { padding-left: 14px; padding-right: 14px; }

  nav.board-nav {
    gap: 8px 14px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  nav.board-nav .search-group {
    order: 3;
    width: 100%;
    margin-left: 0;
  }
  nav.board-nav .search-group input { flex: 1; width: auto; min-width: 0; }
  nav.board-nav button.logout-btn { margin-left: auto; }

  #globalSearchResults {
    left: 0;
    right: 0;
    min-width: 0;
    width: 100%;
  }

  .rainbow-text { font-size: 1.2rem; }

  .people-columns { grid-template-columns: 1fr; }

  .profile-banner img { height: 130px; }
  .profile-header { padding-top: 40px; }
  .profile-header .avatar-wrap { top: -28px; }
  .profile-header img.avatar { width: 64px; height: 64px; }

  .user-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .user-row select { margin-left: 0; width: 100%; }
  .user-row button.danger { width: 100%; }
}

/* ---- Standard phones ---- */
@media (max-width: 480px) {
  body { font-size: 12.5px; }
  .page { padding-left: 12px; padding-right: 12px; }

  /* Comfortable tap targets on touchscreens */
  button, input[type="submit"] { padding: 0.55em 1em; }
  input[type="text"], input[type="password"], select, textarea { padding: 0.6em 0.7em; }

  .module-title { font-size: 0.72rem; padding: 8px 10px; }
  .module-body { padding: 12px; }

  .action-bar { flex-wrap: wrap; }
  .comment-form { flex-wrap: wrap; }
  .comment-form input[type="text"] { min-width: 0; }

  .auth-wrap { margin: 36px auto; }

  .profile-banner img { height: 110px; }
  .hit-counter { font-size: 0.72rem; }
}

/* ---- Small / compact phones (iPhone SE, mini) ---- */
@media (max-width: 380px) {
  .rainbow-text { font-size: 1.05rem; }
  nav.board-nav a { font-size: 0.72rem; }
  nav.board-nav .search-group input { font-size: 0.8rem; }

  .profile-header img.avatar { width: 56px; height: 56px; }
  .profile-header .avatar-wrap { top: -24px; }
  .profile-header { padding-top: 36px; }
}

/* ---- Phones in landscape (short viewport height) ---- */
@media (max-height: 420px) and (orientation: landscape) {
  nav.board-nav { position: static; }
  .profile-banner img { height: 100px; }
}

/* =========================
   MISC HELPERS
========================= */
/* Same reasoning as .hidden above — .view-all-btn (declared later in this
   file) sets its own display:inline-flex at equal specificity, which would
   otherwise silently win over this. */
.js-hidden { display: none !important; }

/* =========================
   MESSAGE BUTTONS (profile header + post title bar + admin row)
========================= */
button.message-profile-btn {
  margin-left: 10px;
  align-self: center;
}
.post-module .module-title { display: flex; align-items: center; gap: 8px; }
.post-module .module-title span:not(.mini-avatar) { flex: 1; }
button.post-message-btn {
  padding: 4px 8px;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

/* =========================
   CHAT TOGGLE (nav icon + unread badge)
========================= */
.chat-toggle-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 3px;
  font-size: 1.05rem;
  line-height: 1;
  padding: 6px 10px;
}
.chat-toggle-btn:hover { background: rgba(102,192,244,0.08); border-color: var(--accent-dim); }
.chat-unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--red);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--content-bg);
}

/* =========================
   CHAT PANEL — floating Messenger-style DM window
========================= */
.chat-panel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 320px;
  max-width: calc(100vw - 24px);
  height: 440px;
  max-height: calc(100vh - 100px);
  background: linear-gradient(180deg, var(--content-bg-alt) 0%, var(--content-bg) 100%);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55), inset 0 0 40px var(--panel-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--titlebar-from) 0%, var(--titlebar-to) 100%);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
}
.chat-panel-title-link {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
.chat-panel-title-link:hover { color: var(--accent); text-decoration: underline; }
.chat-close-btn {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 1rem;
  padding: 2px 6px;
  line-height: 1;
}
.chat-close-btn:hover { color: var(--accent); background: transparent; border: none; }

.chat-panel-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---- thread view ---- */
#chatThreadMessages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-msg-row { display: flex; flex-direction: column; max-width: 78%; }
.chat-msg-row.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg-row.theirs { align-self: flex-start; align-items: flex-start; }
.chat-msg-bubble {
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg-row.mine .chat-msg-bubble {
  background: linear-gradient(180deg, #8ec642 0%, var(--green) 55%, var(--green-dark) 100%);
  color: #0f1720;
  border-bottom-right-radius: 3px;
}
.chat-msg-row.theirs .chat-msg-bubble {
  background: var(--content-bg-alt);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-bottom-left-radius: 3px;
}
.chat-msg-time { font-size: 0.6rem; color: var(--text-faint); margin-top: 2px; padding: 0 3px; }

.chat-typing-indicator {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-style: italic;
  padding: 0 10px 4px;
  margin: 0;
}

.chat-thread-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  background: var(--content-bg-alt);
}
.chat-thread-form input[type="text"] { flex: 1; }
.chat-thread-form button { padding: 0.55em 0.9em; font-size: 0.78rem; }

@media (max-width: 480px) {
  .chat-panel {
    right: 8px;
    /* left:0 (not 8px) so this fully covers the DM sidebar's left edge
       on narrow screens if both happen to be open at once — otherwise a
       thin sliver of the sidebar peeks out from underneath, since the
       sidebar itself starts flush at left:0. */
    left: 0;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    height: min(70vh, 480px);
  }
}

/* =========================
   DM SIDEBAR — persistent, collapsible "who can I message" panel
   (partials/chatSidebar.ejs). Toggled by the 💬 button in nav.ejs.
========================= */

/* Reserve room for the sidebar on wide screens so it pushes content over
   instead of covering it. Narrower screens skip this — see the mobile
   override below, where the sidebar overlays instead, exactly like the
   chat panel already does at 480px. */
@media (min-width: 900px) {
  body.chat-sidebar-open { padding-left: var(--sidebar-w); transition: padding-left 0.15s ease; }
}

.chat-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  width: var(--sidebar-w);
  max-width: 86vw;
  background: linear-gradient(180deg, var(--content-bg-alt) 0%, var(--content-bg) 100%);
  border-right: 1px solid var(--border-light);
  box-shadow: 4px 0 20px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transform: translateX(0);
  transition: transform 0.15s ease;
}
.chat-sidebar.hidden { transform: translateX(-100%); display: flex !important; } /* override the global !important display:none — this one animates instead of vanishing */

.chat-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--titlebar-from) 0%, var(--titlebar-to) 100%);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
}
.chat-sidebar-header span { flex: 1; }
.chat-sidebar-close {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 1rem;
  padding: 2px 6px;
  line-height: 1;
}
.chat-sidebar-close:hover { color: var(--accent); background: transparent; border: none; }

.chat-sidebar-body { flex: 1; overflow-y: auto; padding: 10px 8px; }
.chat-sidebar-section { margin-bottom: 18px; }
.chat-sidebar-heading {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin: 4px 6px 6px;
}
.chat-sidebar-subtext { font-size: 0.7rem; color: var(--text-faint); margin: 0 6px 8px; line-height: 1.4; }

.sidebar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 6px;
  border-radius: 4px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.sidebar-row:hover, .sidebar-row:focus-visible { background: rgba(102,192,244,0.08); outline: none; }
.sidebar-row.unread .sidebar-row-name { color: var(--link-hover); }

.sidebar-avatar-wrap { position: relative; flex: 0 0 auto; }
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-light);
  display: block;
}
.sidebar-avatar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  min-width: 15px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--content-bg);
}

.sidebar-row-meta { flex: 1; min-width: 0; }
.sidebar-row-name { font-weight: 600; font-size: 0.8rem; color: var(--text); }
.sidebar-row-preview {
  font-size: 0.72rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-row-time { font-size: 0.62rem; color: var(--text-faint); flex: 0 0 auto; align-self: flex-start; }
.sidebar-row-start {
  font-size: 0.65rem;
  color: var(--accent);
  opacity: 0;
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.sidebar-row-person:hover .sidebar-row-start, .sidebar-row-person:focus-visible .sidebar-row-start { opacity: 1; }

@media (max-width: 899px) {
  /* Below the breakpoint the sidebar overlays content (no reserved
     padding), same treatment the floating chat panel already gets. */
  .chat-sidebar { width: min(var(--sidebar-w), 86vw); }
}

/* =========================
   PHOTO GALLERY — every avatar/banner ever uploaded (see media.role
   backfill in database/db.js), not just the current one.
========================= */
.gallery-hint { color: var(--text-soft); font-size: 0.78rem; margin: 0 0 12px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.gallery-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 1 / 1;
  background: var(--content-bg-alt);
}
.gallery-tile img, .gallery-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-tile-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(15,23,32,0.72);
  border: 1px solid var(--border-light);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  pointer-events: none;
}
.gallery-tile-tag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(15,23,32,0.78);
  color: var(--text);
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.gallery-tile-actions {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: rgba(15,23,32,0.72);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.gallery-tile:hover .gallery-tile-actions,
.gallery-tile:focus-within .gallery-tile-actions { opacity: 1; }
.gallery-tile-actions button {
  font-size: 0.66rem;
  padding: 5px 6px;
  background: var(--content-bg);
  border: 1px solid var(--border-light);
  color: var(--text);
}
.gallery-tile-actions button:hover { color: var(--accent); border-color: var(--accent-dim); }

/* =========================
   LIGHTBOX — full-screen image viewer w/ prev/next
   (profile posts, home feed, gallery all share this)
========================= */
body.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6,10,14,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 40px;
}
.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.lightbox-video {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  background: #000;
}
.lightbox-caption {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.8rem;
  margin: 0;
  padding: 0 60px;
}
.lightbox-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text);
  font-size: 1rem;
  padding: 6px 11px;
  border-radius: 3px;
}
.lightbox-close:hover { color: var(--accent); border-color: var(--accent-dim); }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(22,32,45,0.75);
  border: 1px solid var(--border-light);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  padding: 6px 14px;
  border-radius: 4px;
}
.lightbox-nav:hover { color: var(--accent); border-color: var(--accent-dim); }
.lightbox-prev { left: max(10px, env(safe-area-inset-left)); }
.lightbox-next { right: max(10px, env(safe-area-inset-right)); }

@media (max-width: 480px) {
  .lightbox { padding: 16px; }
  .lightbox-caption { padding: 0 46px; font-size: 0.72rem; }
  .lightbox-nav { font-size: 1.3rem; padding: 5px 10px; }
}

/* =========================
   SECURITY AUDIT LOG (admin dashboard)
========================= */
#auditLog {
  max-height: 360px;
  overflow-y: auto;
}
.audit-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  font-size: 0.8rem;
}
.audit-row:last-child { border-bottom: none; }
.audit-event { font-weight: 600; color: var(--text); min-width: 190px; }
.audit-who { color: var(--text-soft); }
.audit-detail { color: var(--red); font-style: italic; }
.audit-ip { color: var(--text-faint); font-size: 0.72rem; }
.audit-time {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 0.72rem;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .audit-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .audit-time { margin-left: 0; }
}
