/* =========================================================
   Idle Ones · Forum
   Built on the main site theme variables for a seamless look
   ========================================================= */

.forum-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ---- Nav additions (user chip, logout) ---- */
.nav__user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.nav__user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.nav__logout { display: inline; margin: 0; }
.nav__logout-btn {
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.nav__logout-btn:hover { border-color: var(--gold); color: var(--gold-deep); }

/* ---- Permission badges ---- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--muted);
  vertical-align: middle;
}
.badge--p2 { background: #e8f0ff; color: #2b5bbd; border-color: #cfe0ff; }
.badge--p3 { background: var(--gold-soft); color: var(--gold-deep); border-color: #f0d79a; }
.badge--p4 { background: #ffe9e9; color: #c0392b; border-color: #f5c6c0; }
:root[data-theme="dark"] .badge--p2 { background: #16233d; color: #7ea6ff; border-color: #294066; }
:root[data-theme="dark"] .badge--p3 { background: var(--gold-soft); color: var(--gold-deep); border-color: #4a3c1c; }
:root[data-theme="dark"] .badge--p4 { background: #3a1c1a; color: #ff8f80; border-color: #5a2b27; }

/* Discord display role: tinted with the role's own color */
.badge--role {
  --role-color: var(--muted);
  color: var(--role-color);
  border-color: color-mix(in srgb, var(--role-color) 45%, transparent);
  background: color-mix(in srgb, var(--role-color) 12%, transparent);
}
.badge--role::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--role-color);
  margin-right: 5px;
  vertical-align: middle;
}

/* ---- Hero ---- */
.forum-hero {
  text-align: center;
  padding: 16px 0 28px;
}
.forum-hero__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--gold-deep);
  margin: 0 0 8px;
}
.forum-hero__sub {
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto;
}

/* ---- Trending ---- */
.trending { margin-bottom: 28px; }
.trending__head {
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.trending__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.trend-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.trend-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.trend-card__cat {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold-deep);
}
.trend-card__title {
  font-size: 0.98rem;
  line-height: 1.35;
  color: var(--ink);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.trend-card__meta { margin-top: auto; }
.trend-card__author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}
.trend-card__avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.trend-card__stats {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}
@media (max-width: 720px) {
  .trending__grid { grid-template-columns: 1fr; }
}

/* ---- Breadcrumbs ---- */
.crumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.crumbs a { color: var(--gold-deep); font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }

/* ---- Category cards ---- */
.cat-list { display: grid; gap: 14px; }
.cat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.cat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.cat-card__name { margin: 0 0 4px; font-size: 1.15rem; color: var(--ink); }
.cat-card__desc { margin: 0; color: var(--muted); font-size: 0.92rem; }
.cat-card__stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}
.cat-card__stats strong { color: var(--ink); }

/* ---- Category header ---- */
.cat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.cat-head__title { margin: 0 0 4px; font-size: 1.6rem; color: var(--ink); }
.cat-head__desc { margin: 0; color: var(--muted); font-size: 0.92rem; max-width: 620px; }

/* ---- Thread list ---- */
.thread-list { display: grid; gap: 10px; }
.thread-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  transition: border-color .15s, box-shadow .15s;
}
.thread-row:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.thread-row__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.thread-row__flags { display: flex; gap: 6px; }
.thread-row__title { font-weight: 700; color: var(--ink); }
.thread-row__meta { font-size: 0.82rem; color: var(--muted); }
.thread-row__stats {
  display: flex;
  flex-direction: column;
  text-align: right;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.thread-row__stats strong { color: var(--ink); }

/* ---- Tags ---- */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tag--pin { background: var(--gold-soft); color: var(--gold-deep); }
.tag--lock { background: var(--bg-sunk); color: var(--muted); }

/* ---- Thread view ---- */
.thread-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.thread-head__title {
  margin: 0;
  font-size: 1.5rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mod-bar { display: flex; gap: 6px; margin: 0; flex-shrink: 0; }

.post-list { display: grid; gap: 14px; }
.post {
  display: grid;
  grid-template-columns: 140px 1fr;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.post__author {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.post__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
}
.post__author-name { font-weight: 700; font-size: 0.92rem; color: var(--ink); word-break: break-word; }
.post__body { padding: 16px 18px; min-width: 0; }
.post__meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.post__meta a { color: var(--muted); }
.post__edited { font-style: italic; }
.post__content { color: var(--ink-soft); line-height: 1.7; word-wrap: break-word; overflow-wrap: anywhere; }
.post__content--deleted { color: var(--faint); }
.post__content a { color: var(--gold-deep); text-decoration: underline; }
.post__content code {
  background: var(--bg-sunk);
  padding: 1px 5px;
  border-radius: 5px;
}
.post__image { display: inline-block; margin-top: 12px; }
.post__image img {
  max-height: 420px;
  width: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}

/* Image gallery shared by posts and chat. One image shows at natural size,
   several tile into a compact square grid */
.gallery { margin-top: 12px; display: grid; gap: 6px; max-width: 520px; }
.gallery__item {
  display: block;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.gallery__item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery--1 { display: inline-block; max-width: 100%; }
.gallery--1 .gallery__item img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}
.gallery--2 { grid-template-columns: repeat(2, 1fr); }
.gallery--3,
.gallery--many { grid-template-columns: repeat(3, 1fr); }
.gallery--2 .gallery__item,
.gallery--3 .gallery__item,
.gallery--many .gallery__item { aspect-ratio: 1 / 1; }
.post__footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.post__actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
.post__actions form { margin: 0; }
.post__action {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.post__action:hover { color: var(--gold-deep); }
.post__action--danger:hover { color: #c0392b; }

/* ---- Reply to a specific post ---- */
.post__reply-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.post__reply-btn:hover { color: var(--gold-deep); border-color: var(--gold); }

.post__replying {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 3px 10px 3px 8px;
  border-left: 2px solid var(--gold);
  background: var(--bg-sunk);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}
.post__replying:hover { color: var(--gold-deep); }
.post__replying span { font-weight: 600; }

.reply-box__context {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-left: 2px solid var(--gold);
  background: var(--bg-sunk);
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.reply-box__context[hidden] { display: none; }
.reply-box__clear {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.reply-box__clear:hover { color: #c0392b; }

/* ---- Like button ---- */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .12s;
}
.like-btn:hover { border-color: #e9899b; color: #e35d7b; }
.like-btn__icon { fill: none; stroke: currentColor; stroke-width: 2; }
.like-btn.is-liked {
  color: #e35d7b;
  border-color: #f0b9c5;
  background: #fdeef1;
}
.like-btn.is-liked .like-btn__icon { fill: currentColor; stroke: currentColor; }
:root[data-theme="dark"] .like-btn.is-liked { background: #2e1a1f; border-color: #5a2e38; }
.like-btn--sm { padding: 3px 9px; font-size: 0.76rem; gap: 5px; }
.like-btn--pop { animation: like-pop .3s ease; }
@keyframes like-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .like-btn--pop { animation: none; }
}

/* ---- Floating reply shortcut (mobile) ---- */
.reply-fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1b1405;
  font: inherit;
  font-weight: 800;
  box-shadow: var(--shadow-gold);
  cursor: pointer;
  transition: opacity .2s, transform .2s;
}
.reply-fab.is-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}
@media (max-width: 720px) {
  .reply-fab { display: inline-flex; }
}

/* ---- Reply / compose ---- */
.reply-box, .compose {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 22px;
  box-shadow: var(--shadow-sm);
}
.reply-box__title, .compose__title { margin: 0 0 12px; color: var(--ink); }
.field { display: block; margin-bottom: 16px; }
.field__label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; color: var(--ink-soft); }

textarea, .field input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 14px;
  resize: vertical;
}
textarea:focus, .field input[type="text"]:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.reply-box__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.file-input {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}
.file-input--block { display: block; margin: 4px 0 18px; }
.file-input__note {
  font-size: 0.78rem;
  color: var(--muted);
}
.file-input__note--error { color: #c0392b; font-weight: 600; }
.compose__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--gold); }
.btn--primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  border-color: transparent;
  color: #1b1405;
  box-shadow: var(--shadow-gold);
}
.btn--sm { padding: 6px 12px; font-size: 0.8rem; }
.btn--danger { color: #c0392b; border-color: #f0c6c0; }
.btn--danger:hover { border-color: #c0392b; }
:root[data-theme="dark"] .btn--danger { color: #ff8f80; border-color: #5a2b27; }

/* ---- Pager ---- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}
.pager__info { color: var(--muted); font-size: 0.88rem; }

/* ---- Flashes ---- */
.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid var(--line);
}
.flash--ok { background: #e9f8ee; color: #1e7d45; border-color: #bfe8cd; }
.flash--error { background: #ffe9e9; color: #c0392b; border-color: #f5c6c0; }
:root[data-theme="dark"] .flash--ok { background: #16271c; color: #6fdc97; border-color: #234a33; }
:root[data-theme="dark"] .flash--error { background: #2e1816; color: #ff8f80; border-color: #5a2b27; }

.empty {
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
}
.empty a { color: var(--gold-deep); font-weight: 700; }

/* ---- Admin ---- */
.admin-table {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-row {
  display: grid;
  grid-template-columns: 1.5fr 1.4fr 0.8fr 0.7fr 1.6fr;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.admin-row:last-child { border-bottom: none; }
.admin-row--head { background: var(--bg-soft); font-weight: 700; color: var(--ink-soft); }
.admin-user { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.admin-avatar { width: 28px; height: 28px; border-radius: 50%; }
.admin-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--muted); }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-actions form { margin: 0; display: inline-flex; gap: 6px; }
.admin-perm select {
  font: inherit;
  font-size: 0.8rem;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
}

.footer--slim { padding: 28px 20px; text-align: center; }

/* =========================================================
   Reddit-style threaded discussion
   ========================================================= */

/* ---- Opening post card ---- */
.op-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.op-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.op-card__avatar-link { flex: none; display: inline-flex; line-height: 0; }
.op-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  transition: border-color .15s;
}
.op-card__avatar-link:hover .op-card__avatar { border-color: var(--gold); }
.op-card__author-link { color: inherit; text-decoration: none; }
.op-card__author-link:hover { color: var(--gold-deep); }
.op-card__author {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  color: var(--ink);
}
.op-card__meta { font-size: 0.8rem; color: var(--muted); }
.op-card__body { line-height: 1.7; }
.op-card__actions { margin-top: 14px; }

/* ---- Comments header ---- */
.comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}
.comments-head__title { margin: 0; font-size: 1.15rem; color: var(--ink); }
.comments-head__toggle {
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.comments-head__toggle:hover { border-color: var(--gold); color: var(--gold-deep); }
.comments-empty { margin-top: 22px; }

/* ---- Comment tree ---- */
.comment {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
/* Nested comments indent and get their own vertical rail */
.comment__children > .comment {
  margin-top: 12px;
}
/* The clickable rail that collapses a subtree */
.comment__rail {
  flex: 0 0 14px;
  width: 14px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  position: relative;
}
.comment__rail::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background .15s;
}
.comment__rail:hover::before { background: var(--gold); }

.comment__main { flex: 1 1 auto; min-width: 0; }

.comment__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.84rem;
}
.comment__toggle {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.comment__toggle:hover { border-color: var(--gold); color: var(--gold-deep); }
.comment__avatar-link { display: inline-flex; line-height: 0; }
.comment__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  transition: border-color .15s;
}
.comment__avatar-link:hover .comment__avatar { border-color: var(--gold); }
.comment__author { font-weight: 700; color: var(--ink); }
.comment__author:hover { color: var(--gold-deep); }
.comment__meta { color: var(--muted); }
.comment__collapsed-note { color: var(--faint); font-style: italic; }

.comment__collapsible { padding-top: 4px; }
.comment.is-collapsed > .comment__main > .comment__collapsible { display: none; }

.comment__body { color: var(--ink-soft); line-height: 1.65; }
.comment__body .post__content { word-wrap: break-word; overflow-wrap: anywhere; }
.comment__removed { color: var(--faint); }

.comment__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.comment__actions form { margin: 0; }
.comment__act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.comment__act:hover { color: var(--gold-deep); }
.comment__act--danger:hover { color: #c0392b; }

.comment__children {
  margin-top: 6px;
}

@media (max-width: 720px) {
  .comment { gap: 7px; }
  .comment__rail { flex-basis: 10px; width: 10px; }
  .comment__rail::before { left: 4px; }
}

@media (max-width: 720px) {
  .post { grid-template-columns: 1fr; }
  .post__author {
    flex-direction: row;
    justify-content: flex-start;
    border-right: none;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }
  .post__avatar { width: 38px; height: 38px; }
  .admin-row { grid-template-columns: 1fr; gap: 6px; }
  .admin-row--head { display: none; }
  .cat-card, .thread-row { flex-direction: column; align-items: flex-start; }
  .cat-card__stats, .thread-row__stats { flex-direction: row; gap: 12px; text-align: left; }
}

/* =========================================================
   Custom flair badge (granted by staff)
   ========================================================= */
.badge--flair {
  --flair-color: var(--gold-deep);
  color: var(--flair-color);
  border-color: color-mix(in srgb, var(--flair-color) 55%, transparent);
  background: color-mix(in srgb, var(--flair-color) 14%, transparent);
}
.badge--flair::before {
  content: "\2726"; /* a small sparkle */
  margin-right: 4px;
  font-size: 0.7em;
  vertical-align: middle;
}

/* =========================================================
   Member profiles
   ========================================================= */
.profile-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-top: 16px;
}
.profile-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.profile-head__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  flex: none;
}
.profile-head__main { flex: 1 1 auto; min-width: 0; }
.profile-head__name {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.profile-head__pronouns {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.profile-head__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-head__ingame {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.profile-head__ingame span {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-right: 6px;
}
.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 18px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}
.profile-stats strong { color: var(--ink); }
.profile-stats__joined { margin-left: auto; }

.profile-bio__head,
.profile-flair h2 {
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 0 10px;
}
.profile-bio__body {
  line-height: 1.7;
  color: var(--ink-soft);
  overflow: hidden;
}
.profile-bio__body.is-clamped {
  max-height: 7.5em;
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent);
          mask-image: linear-gradient(180deg, #000 60%, transparent);
}
.profile-bio__toggle {
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--gold-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.profile-flair { margin-top: 20px; }
.profile-flair__form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}
.profile-flair__form input[type="text"] {
  flex: 1 1 220px;
  font: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
}
.profile-flair__form input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}

/* =========================================================
   Profile settings form
   ========================================================= */
.settings-form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 640px;
}
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field__label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.settings-field input,
.settings-field textarea {
  font: inherit;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  resize: vertical;
}
.settings-field input:focus,
.settings-field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.settings-form__row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* =========================================================
   Live chat
   ========================================================= */
.forum-hero__chat { margin-top: 16px; }

.chat {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  height: min(72vh, 720px);
}
.chat__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
.chat__title { margin: 0; font-size: 1.2rem; color: var(--ink); }
.chat__sub { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); }
.chat__stream {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.chat-msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.chat-msg__avatar-link { flex: none; }
.chat-msg__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
}
.chat-msg__main { min-width: 0; flex: 1 1 auto; }
.chat-msg__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.chat-msg__author { font-weight: 700; color: var(--ink); }
.chat-msg__time { font-size: 0.75rem; color: var(--muted); }
.chat-msg__edited { font-size: 0.72rem; color: var(--muted); font-style: italic; }

/* Quoted reply shown above a message, click to jump to the original */
.chat-msg__quote {
  display: flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  margin-bottom: 3px;
  padding: 3px 10px;
  border: none;
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--bg-soft);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}
.chat-msg__quote:hover { background: var(--gold-soft); }
.chat-msg__quote-author { font-weight: 700; color: var(--gold-deep); flex: none; }
.chat-msg__quote-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Per-message actions reveal on hover, like Discord */
.chat-msg__actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity .12s;
}
.chat-msg:hover .chat-msg__actions,
.chat-msg:focus-within .chat-msg__actions { opacity: 1; }
.chat-msg__act {
  background: none;
  border: none;
  padding: 1px 4px;
  border-radius: 6px;
  color: var(--muted);
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
}
.chat-msg__act:hover { color: var(--ink); background: var(--bg-soft); }
.chat-msg__act--danger:hover { color: #c0392b; }
.chat-msg .gallery { max-width: 380px; margin-top: 6px; }
.chat-msg__text {
  line-height: 1.55;
  color: var(--ink-soft);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg__removed { color: var(--muted); }
.chat-msg--new { animation: chat-pop .25s ease; }
@keyframes chat-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Consecutive messages from one author tuck together: hide the repeated
   avatar and header and pull the row up tight */
.chat-msg--grouped { margin-top: -10px; }
.chat-msg--grouped .chat-msg__avatar-link { visibility: hidden; height: 0; }
.chat-msg--grouped .chat-msg__head { display: none; }

/* The viewer's own messages get a subtle gold edge */
.chat-msg--mine .chat-msg__main {
  border-left: 2px solid var(--gold-soft);
  padding-left: 8px;
  margin-left: -10px;
}

/* Brief highlight when you jump to a quoted message */
.chat-msg--flash { animation: chat-flash 1.4s ease; }
@keyframes chat-flash {
  0%, 30% { background: var(--gold-soft); }
  100% { background: transparent; }
}

/* Inline edit box that replaces a message body */
.chat-edit { margin: 4px 0; }
.chat-edit__input {
  width: 100%;
  font: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  resize: vertical;
}
.chat-edit__input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.chat-edit__row { display: flex; gap: 8px; margin-top: 6px; }
.btn--tiny { padding: 4px 12px; font-size: 0.78rem; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { color: var(--ink); }

.chat__compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  margin: 0;
}
.chat__compose-row { display: flex; gap: 10px; align-items: flex-end; }
.chat__compose textarea {
  flex: 1 1 auto;
  font: inherit;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  resize: none;
  max-height: 140px;
  line-height: 1.4;
}
.chat__compose textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.chat__send { flex: none; }

/* Reply context bar above the input */
.chat__reply-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}
.chat__reply-bar strong { color: var(--ink); }
.chat__reply-bar[hidden] { display: none; }
.chat__reply-cancel {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.chat__reply-cancel:hover { color: #c0392b; }

/* Thumbnails of images queued for the next message */
.chat__previews { display: flex; flex-wrap: wrap; gap: 8px; }
.chat__previews[hidden] { display: none; }
.chat-preview {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
}
.chat-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-preview__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

/* Paperclip attach button that wraps the hidden file input */
.chat__attach {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.chat__attach:hover { background: var(--card); color: var(--gold-deep); }
.chat__hint { font-size: 0.72rem; color: var(--muted); padding-left: 4px; }
.chat__login { margin: 16px; }

/* Floating "N new messages" pill, shown when the reader is scrolled up */
.chat__unread {
  position: absolute;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 999px;
  background: var(--gold-deep);
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 2;
  animation: chat-pop .2s ease;
}
.chat__unread:hover { filter: brightness(1.06); }
.chat__unread[hidden] { display: none; }

@media (max-width: 720px) {
  .profile-stats__joined { margin-left: 0; width: 100%; }
  .chat { height: min(78vh, 640px); }
}
@media (prefers-reduced-motion: reduce) {
  .chat__stream { scroll-behavior: auto; }
  .chat-msg--new { animation: none; }
}
