/* =========================================================================
   riveraworks — a portfolio that celebrates in public
   ========================================================================= */

:root {
  --sidebar: #171320;
  --sidebar-2: #1E1930;
  --bg: #0d0c12;
  --surface: #16151e;
  --surface-2: #1d1b26;
  --hover: #201e2a;
  --line: #2a2833;
  --line-soft: #221f2b;

  --text: #eae8f0;
  --muted: #8a8796;
  --faint: #605d6b;

  --brand: #f0498b;      /* the persona / voice */
  --brand-soft: #f0498b26;
  --green: #2fbe7e;      /* online / wins */
  --gold: #f5b544;
  --blue: #5b8def;
  --red: #f0466e;        /* unread badges */

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;

  --r: 10px;
  --sidebar-w: 244px;
  --thread-w: 400px;
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* particle canvas + toasts sit above everything */
#fx {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
#toasts {
  position: fixed;
  right: 18px;
  top: 70px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 20vw);
  max-width: 20vw;
  pointer-events: none;
}

/* =============================== LAYOUT ================================== */
.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}
body.thread-open .workspace { grid-template-columns: var(--sidebar-w) 1fr; }

/* =============================== SIDEBAR ================================= */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 30;
}
.ws-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #00000055;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.ws-name::first-letter { text-transform: uppercase; }
.ws-caret { color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 12px 8px; min-height: 0; }
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 12px 10px 6px;
  font-weight: 700;
}
.channel-list { display: flex; flex-direction: column; }

.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 15px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.channel:hover { background: var(--sidebar-2); color: var(--text); }
.channel.is-active { background: var(--brand); color: #fff; font-weight: 600; }
.channel.is-active .hash { color: #ffffffcc; }
.hash { color: var(--faint); font-weight: 500; }
.cname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chan-unread {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.dm { position: relative; }
.dm-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--sidebar);
}
.dm-badge { display: none; }
.dm-badge.show { display: inline-flex; animation: pop-in 0.3s ease; }
.channel.glow {
  animation: dm-glow 1.6s ease infinite;
}
@keyframes dm-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--brand-soft); }
  50% { box-shadow: 0 0 0 3px var(--brand-soft); background: #241a24; }
}

.me {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid #00000055;
  background: #00000022;
}
.me-info { min-width: 0; }
.me-name { font-weight: 700; font-size: 14px; color: #fff; }
.me-status { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* avatar */
.avatar {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #b23a86);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
  letter-spacing: 0.02em;
}
.avatar-me { width: 34px; height: 34px; border-radius: 8px; }
.me-online {
  position: absolute; right: -3px; bottom: -3px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--sidebar);
}

/* =============================== MAIN =================================== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 58px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.chan-heading { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.chan-hash { color: var(--muted); font-weight: 600; font-size: 18px; }
.chan-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.chan-topic {
  color: var(--muted);
  font-size: 13px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; gap: 4px; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 17px; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.burger { display: none; }

.feed-scroll { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.feed { padding: 22px 8px 6px; max-width: 900px; }

/* =============================== MESSAGE ================================ */
.msg {
  display: flex;
  gap: 12px;
  padding: 8px 20px;
  border-radius: 8px;
  position: relative;
}
.msg:hover { background: #ffffff05; }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-name { font-weight: 700; font-size: 15px; }
.msg-time { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }

.msg-line { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0; }
.win-emoji { font-size: 22px; line-height: 1.35; flex-shrink: 0; }
.win-head {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.32;
  letter-spacing: -0.015em;
  color: var(--text);
}
.msg-sub { color: var(--muted); font-size: 14.5px; margin: 2px 0 4px 32px; }

/* reactions */
.reacts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px 32px; position: relative; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 9px 2px 7px;
  font-size: 13px;
  color: var(--text);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.chip:hover { border-color: var(--brand); background: #241a26; }
.chip.mine { border-color: var(--brand); background: var(--brand-soft); }
.chip-e { font-size: 14px; }
.chip-n { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 700; }
.chip.mine .chip-n { color: var(--brand); }
.chip.bump { animation: chip-bump 0.34s cubic-bezier(.34,1.7,.4,1); }
@keyframes chip-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.react-add {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 20px;
  width: 28px; height: 25px;
  font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .12s, color .12s;
}
.react-add:hover { border-color: var(--brand); color: var(--brand); border-style: solid; }

.tray {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 5px 7px;
  box-shadow: var(--shadow);
  z-index: 5;
  animation: tray-up 0.16s ease;
}
@keyframes tray-up { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.tray-btn {
  border: 0; background: transparent; font-size: 20px;
  width: 34px; height: 34px; border-radius: 50%;
  transition: transform .1s, background .1s;
}
.tray-btn:hover { background: var(--hover); transform: scale(1.25); }

/* thread affordance */
.thread-open {
  margin: 8px 0 2px 32px;
  border: 0; background: transparent;
  color: var(--muted);
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 0;
  transition: color .12s;
}
.thread-open:hover { color: var(--brand); }
.thr-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* pinned intro */
.msg-pinned {
  border-left: 3px solid var(--gold);
  background: #ffffff04;
  margin: 0 8px 6px;
}
.pin-tag { font-family: var(--font-mono); font-size: 11px; color: var(--gold); }
.pinned-pitch { font-size: 16px; line-height: 1.55; color: #d9d6e2; margin: 4px 0 12px; max-width: 60ch; }
.pinned-cta { display: flex; gap: 8px; }
.btn-primary {
  background: var(--brand); color: #fff;
  border: 0; border-radius: 8px;
  padding: 9px 16px; font-weight: 700; font-size: 14px;
  text-decoration: none; display: inline-flex; align-items: center;
  transition: transform .1s, filter .12s;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font-weight: 600; font-size: 14px; text-decoration: none;
  transition: border-color .12s;
}
.btn-ghost:hover { border-color: var(--muted); }

/* day divider */
.day-divider {
  display: flex; align-items: center; justify-content: center;
  margin: 14px 20px; position: relative;
}
.day-divider::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--line);
}
.day-divider span {
  position: relative; background: var(--bg);
  padding: 0 12px; font-size: 12px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px; line-height: 22px;
  font-family: var(--font-mono);
}

/* entrance animations */
.pre-in { opacity: 0; transform: translateY(10px); }
.in { animation: msg-in 0.5s cubic-bezier(.2,.8,.25,1) both; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.msg.flash { animation: msg-in .5s cubic-bezier(.2,.8,.25,1) both, flash 1.4s ease .2s; }
@keyframes flash {
  0% { background: var(--brand-soft); }
  100% { background: transparent; }
}
.msg.is-live { border-left: 2px solid var(--green); }

/* composer (interactive) */
.composer { padding: 8px 20px 18px; flex-shrink: 0; background: var(--bg); border-top: 1px solid var(--line-soft); }
.composer-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 6px 6px 15px;
  background: var(--surface);
  display: flex; align-items: center; gap: 8px;
  transition: border-color .14s, box-shadow .14s;
}
.composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer-input {
  flex: 1; border: 0; background: transparent; color: var(--text);
  font-family: inherit; font-size: 15px; padding: 8px 0; outline: none;
}
.composer-input::placeholder { color: var(--faint); }
.send-btn {
  border: 0; border-radius: 9px; width: 38px; height: 34px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: filter .12s, transform .1s, opacity .12s;
}
.send-btn:hover { filter: brightness(1.1); }
.send-btn:active { transform: scale(.94); }
.send-arrow { font-size: 14px; line-height: 1; }
.composer-hint { color: var(--faint); font-size: 12px; font-family: var(--font-mono); margin: 8px 2px 0; }

/* guest (visitor) messages */
.avatar-guest { background: linear-gradient(135deg, #3a3745, #26242f); color: var(--muted); font-size: 11px; }
.is-guest .msg-name { color: var(--text); }
.guest-tag {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 20px; padding: 0 6px; line-height: 15px;
}

/* ===================== DM CHAT (interactive) ===================== */
.dm-composer { display: none; padding: 10px 16px 16px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--surface); }
.thread.is-dm .dm-composer { display: block; }

.dm-log { padding: 6px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.dm-line { display: flex; gap: 10px; align-items: flex-end; max-width: 76%; }
.dm-line.from-leon { align-self: flex-start; }
.dm-line.from-you { align-self: flex-end; flex-direction: row-reverse; }
.dm-line .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.dm-bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 14.5px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--line); color: #e4e1ec;
  border-bottom-left-radius: 4px;
}
.from-you .dm-bubble {
  background: var(--brand); border-color: var(--brand); color: #fff;
  border-bottom-left-radius: 14px; border-bottom-right-radius: 4px;
}
.dm-link { color: var(--brand); font-weight: 700; text-decoration: underline; }
.from-you .dm-link { color: #fff; }
.dm-line.just-in { animation: bubble-in .28s cubic-bezier(.2,1.2,.35,1) both; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(8px) scale(.96); } }

.dm-bubble.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.dm-bubble.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: typing 1.1s infinite ease-in-out;
}
.dm-bubble.typing span:nth-child(2) { animation-delay: .18s; }
.dm-bubble.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* =============================== THREAD ================================= */
.thread {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 66vw;
  max-width: 66vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px -30px rgba(0,0,0,.7);
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(.2,.8,.2,1);
  z-index: 50;
  display: flex; flex-direction: column;
}
/* thread content breathes a little wider now */
.thread-body { --thread-pad: clamp(4px, 4vw, 40px); }
.thread.open { transform: none; }
.thread-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.thread-title { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
.thread-sub { font-size: 12px; color: var(--muted); }
.thread-body { overflow-y: auto; padding: 14px 4px 30px; min-height: 0; flex: 1; }

.thread-count {
  font-size: 12px; color: var(--muted); font-weight: 700;
  padding: 6px 20px; position: relative; margin: 4px 0 6px;
}
.thread-count::after {
  content: ""; position: absolute; left: 76px; right: 20px; top: 50%;
  height: 1px; background: var(--line);
}
.thread-reply .msg-name { font-size: 14px; }
.reply-tag {
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--brand); background: var(--brand-soft);
  padding: 1px 7px; border-radius: 20px;
}
.reply-text { font-size: 14.5px; line-height: 1.6; color: #d9d6e2; margin-top: 3px; }
.thread-reply.honest { }
.thread-reply.honest .reply-tag { color: var(--gold); background: #f5b5441f; }

/* receipts table */
.receipts {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.receipt-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft);
  gap: 12px;
}
.receipt-row:last-child { border-bottom: 0; }
.receipt-row:nth-child(odd) { background: #ffffff04; }
.receipt-k { font-size: 13px; color: var(--muted); }
.receipt-v { font-family: var(--font-mono); font-weight: 700; font-size: 13.5px; color: var(--green); text-align: right; }

/* DM panel specifics */
.thread.is-dm .thread-title { color: var(--brand); }
.dm-intro { text-align: center; padding: 26px 20px 18px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.dm-bigav {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--brand), #b23a86); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
}
.dm-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; }
.dm-role { font-size: 12.5px; color: var(--muted); margin-top: 4px; max-width: 32ch; margin-inline: auto; line-height: 1.5; }
.dm-msg .reply-text { color: #e4e1ec; }
.dm-cta { margin-top: 12px; }

/* =============================== TOASTS ================================= */
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 13px 15px;
  display: flex; gap: 12px; align-items: flex-start;
  transform: translateX(120%) scale(.96);
  opacity: 0;
  transition: transform 0.42s cubic-bezier(.2,1.3,.35,1), opacity .3s;
  cursor: default;
}
.toast.in { transform: none; opacity: 1; }
.toast.out { transform: translateX(120%); opacity: 0; }
.toast-icon {
  font-size: 24px; width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: 10px;
}
.toast-av {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #b23a86); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.toast-main { min-width: 0; }
.toast-head { display: flex; align-items: baseline; gap: 8px; }
.toast-head b { font-size: 14px; }
.toast-tag {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.toast-text { font-size: 14px; line-height: 1.45; margin-top: 2px; color: #d9d6e2; }
.toast-dm { border-color: var(--brand); cursor: pointer; }
.toast-dm:hover { background: #1c1622; }
.toast-cta-row { margin-top: 6px; }
.toast-reply-hint {
  font-family: var(--font-mono); font-size: 11px; color: var(--brand);
  font-weight: 700;
}
.toast-sys { background: var(--surface-2); }
.toast-sys .toast-text { color: var(--muted); font-size: 13px; }

/* screen shake */
.shake { animation: shake 0.55s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%,90% { transform: translate3d(-2px,0,0); }
  20%,80% { transform: translate3d(4px,0,0); }
  30%,50%,70% { transform: translate3d(-8px,0,0); }
  40%,60% { transform: translate3d(8px,0,0); }
}

@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }

/* =============================== SCROLLBARS ============================= */
.nav::-webkit-scrollbar, .feed-scroll::-webkit-scrollbar, .thread-body::-webkit-scrollbar { width: 10px; }
.nav::-webkit-scrollbar-thumb, .feed-scroll::-webkit-scrollbar-thumb, .thread-body::-webkit-scrollbar-thumb {
  background: #ffffff12; border-radius: 10px; border: 3px solid transparent; background-clip: padding-box;
}
.feed-scroll:hover::-webkit-scrollbar-thumb { background: #ffffff20; background-clip: padding-box; }

/* =============================== RESPONSIVE ============================= */
#nav-scrim { display: none; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 270px; z-index: 45;
    transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  }
  body.nav-open .sidebar { transform: none; }
  #nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: #000000aa; opacity: 0; pointer-events: none; transition: opacity .3s;
  }
  body.nav-open #nav-scrim { opacity: 1; pointer-events: auto; }
  .burger { display: flex; }
  .chan-topic { display: none; }
  .win-head { font-size: 18px; }
  .thread { width: 100%; max-width: 100%; }
  .feed { padding: 16px 4px 6px; }
  .msg { padding: 8px 14px; }
  .msg-sub, .reacts, .thread-open { margin-left: 0; }
  .dm-line { max-width: 86%; }
  #toasts { right: 10px; left: 10px; top: 10px; width: auto; max-width: none; }
}

/* =============================== REDUCED MOTION ========================= */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; scroll-behavior: auto; }
  .pre-in { opacity: 1; transform: none; }
  .toast { transition: opacity .2s; transform: none; }
  .toast.in { transform: none; }
  .thread { transition: none; }
}

/* =========================================================================
   ADDITIONS: thread-dim, contact modal, mobile touch fixes
   ========================================================================= */

/* ---- mobile mass-tap defect fixes ----
   Kills the grey tap-flash, text-selection highlight, and double-tap zoom
   jump that showed up when rapidly tapping reactions on touch screens. */
button, a, .chip, .channel, .react-add, .tray-btn, .send-btn, .icon-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.chip, .react-add, .tray-btn, .win-emoji, .chip-e, .chip-n, .reacts, .thread-open {
  -webkit-user-select: none;
  user-select: none;
}
/* stop the reaction row reflowing/jumping as counts grow under rapid taps */
.chip { will-change: transform; }
.chip-n { min-width: 1.1ch; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- thread-open dim: main page eases darker than the panel ---- */
#thread-scrim {
  position: fixed; inset: 0; z-index: 49;
  background: rgba(4, 3, 8, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.34s cubic-bezier(.2,.8,.2,1);
}
body.thread-open #thread-scrim { opacity: 1; pointer-events: auto; }
/* the panel itself sits above the scrim, so it stays bright */
.thread { z-index: 50; }

/* ============================ CONTACT MODAL ============================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(4, 3, 8, 0.62);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.28s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  position: relative;
  width: min(470px, 96vw);
  max-height: 92vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 40px 90px -20px rgba(0,0,0,.7);
  padding: 26px 26px 24px;
  transform: translateY(14px) scale(.975);
  transition: transform 0.32s cubic-bezier(.2,1,.3,1);
}
.modal-overlay.open .modal { transform: none; }
.cm-close { position: absolute; top: 12px; right: 12px; }

.cm-head { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.cm-av {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), #b23a86); color: #fff;
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.cm-title { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.cm-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.cm-field { margin-bottom: 14px; }
.cm-field label {
  display: block; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.cm-field input, .cm-field select, .cm-field textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; font-family: inherit; font-size: 15px;
  outline: none; transition: border-color .14s, box-shadow .14s;
}
.cm-field textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.cm-field input:focus, .cm-field select:focus, .cm-field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.cm-field select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a8796' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
.cm-honey { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.cm-error { color: #ff8098; font-size: 13px; min-height: 18px; margin: 2px 0 8px; }
.cm-submit { width: 100%; justify-content: center; padding: 12px; font-size: 15px; position: relative; }
.cm-submit.loading .cm-submit-label { visibility: hidden; }
.cm-submit.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2px solid #ffffff66; border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* success state */
.cm-success { text-align: center; padding: 12px 6px 6px; }
.cm-check { width: 76px; height: 76px; margin: 0 auto 16px; }
.cm-check svg { width: 100%; height: 100%; }
.cm-check-c { stroke: var(--green); stroke-width: 2.5; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw-c .5s ease forwards; }
.cm-check-p { stroke: var(--green); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw-p .35s ease .45s forwards; }
@keyframes draw-c { to { stroke-dashoffset: 0; } }
@keyframes draw-p { to { stroke-dashoffset: 0; } }
.cm-success-title { font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.cm-success-text { font-size: 14.5px; color: var(--muted); line-height: 1.55; margin: 10px auto 20px; max-width: 34ch; }

@media (max-width: 860px) {
  .modal { padding: 22px 18px 20px; border-radius: 16px; }
  .cm-field input, .cm-field select, .cm-field textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
  .composer-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  #thread-scrim, .modal-overlay, .modal { transition: opacity .2s; }
  .cm-check-c, .cm-check-p { animation: none; stroke-dashoffset: 0; }
}

/* =========================================================================
   ADDITIONS: photo avatars, dismissible/swipeable toasts, hover eggs
   ========================================================================= */

/* photo avatars (used everywhere Leon's avatar appears) */
.avatar-photo { background-size: cover; background-position: center; background-repeat: no-repeat; }
.avatar-photo span { display: none; }
.toast-av.avatar-photo, .dm-bigav.avatar-photo, .cm-av.avatar-photo { background-color: transparent; }

/* ---- dismissible + swipeable toasts ---- */
.toast { position: relative; touch-action: pan-y; padding-right: 30px; }
.toast-x {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--muted);
  font-size: 10px; line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(.85);
  transition: opacity .14s, transform .14s, background .14s, color .14s;
  pointer-events: auto; cursor: pointer;
}
.toast:hover .toast-x { opacity: 1; transform: scale(1); }
.toast-x:hover { background: var(--line); color: var(--text); }
.toast-head { padding-right: 8px; }
/* on touch there's no hover, so always show the X */
@media (pointer: coarse) { .toast-x { opacity: 1; transform: scale(1); } }

/* ---- hover easter eggs on reaction chips (desktop) ---- */
@media (hover: hover) {
  .chip:hover .chip-e { animation: chip-bob 0.9s ease-in-out infinite; display: inline-block; }
  .react-add:hover { transform: rotate(90deg); }
}
@keyframes chip-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-2px) rotate(-9deg); }
  70% { transform: translateY(-2px) rotate(9deg); }
}
.chip.wild-pop .chip-e { animation: chip-spin 0.55s cubic-bezier(.3,1.4,.4,1); display: inline-block; }
@keyframes chip-spin { from { transform: rotate(0) scale(1); } to { transform: rotate(360deg) scale(1); } }
.react-add { transition: border-color .12s, color .12s, transform .18s cubic-bezier(.3,1.4,.4,1); }

/* =========================================================================
   ADDITIONS: DM-as-view, workspace menu, profile overlay, party FX
   ========================================================================= */

/* ws header is now a fun button */
.ws-head {
  width: 100%; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  padding: 16px 18px 14px; border-bottom: 1px solid #00000055;
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  letter-spacing: -0.01em; color: var(--text); text-align: left;
  transition: background .12s;
}
.ws-head:hover { background: #ffffff08; }
.ws-vibe { margin-left: auto; font-size: 15px; transition: transform .2s; }
.ws-head:hover .ws-vibe { transform: rotate(-12deg) scale(1.15); }
.ws-head.open .ws-vibe { transform: rotate(180deg); }

.ws-menu {
  position: absolute; top: 54px; left: 10px; right: 10px; z-index: 35;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; animation: menu-in .16s ease;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
.ws-menu-item {
  width: 100%; border: 0; background: transparent; color: var(--text);
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background .12s;
}
.ws-menu-item:hover { background: var(--hover); }
.wm-ic { font-size: 16px; width: 20px; text-align: center; }

/* DM as a main view: hide the # in the header, style the intro CTA */
.chan-heading.no-hash .chan-hash { display: none; }
.dm-intro-cta { margin-top: 14px; }
.dm-log { padding-bottom: 20px; }

/* ============================ PROFILE OVERLAY ========================== */
.profile-card {
  position: relative;
  width: min(440px, 96vw); max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 40px 90px -20px rgba(0,0,0,.7);
  padding: 0 0 22px; transform: translateY(14px) scale(.975);
  transition: transform .32s cubic-bezier(.2,1,.3,1);
}
.modal-overlay.open .profile-card { transform: none; }
.pf-close { position: absolute; top: 12px; right: 12px; z-index: 2; color: #fff; }

.pf-top {
  display: flex; gap: 16px; align-items: flex-end;
  padding: 26px 24px 18px;
  background:
    radial-gradient(120% 140% at 20% 0%, #2a1830 0%, transparent 60%),
    linear-gradient(135deg, #241626, #17151e);
  border-radius: 20px 20px 0 0;
}
.pf-avatar {
  width: 92px; height: 92px; border-radius: 20px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), #b23a86);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand);
  animation: pf-ring 3s ease-in-out infinite;
}
@keyframes pf-ring {
  0%, 100% { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand); }
  50% { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px #ff6db0; }
}
.pf-id { padding-bottom: 4px; }
.pf-name { font-family: var(--font-display); font-weight: 800; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.pf-live { font-size: 11px; font-weight: 700; color: var(--green); display: inline-flex; align-items: center; gap: 5px; text-transform: uppercase; letter-spacing: .04em; }
.pf-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.pf-role { color: var(--muted); font-size: 14px; margin-top: 3px; }
.pf-meta { color: var(--faint); font-size: 12px; margin-top: 6px; font-family: var(--font-mono); }

.pf-status {
  margin: 14px 24px 0; padding: 10px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); font-size: 14px; color: #d9d6e2;
}
.pf-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 16px 24px 4px; }
.pf-stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center; }
.pf-stat-v { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--brand); }
.pf-stat-k { font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.25; }

.pf-section-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 16px 24px 6px; font-weight: 700; }
.pf-about { padding: 0 24px; font-size: 14.5px; line-height: 1.6; color: #d9d6e2; }
.pf-facts { margin: 0; padding: 0 24px 0 42px; }
.pf-facts li { font-size: 14px; color: #d3d0dd; line-height: 1.5; margin-bottom: 6px; }
.pf-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 18px 24px 8px; }
.pf-danger {
  margin: 6px 24px 0; width: calc(100% - 48px);
  background: repeating-linear-gradient(45deg, #2a1620, #2a1620 10px, #241019 10px, #241019 20px);
  border: 1px dashed #ff6b8f66; color: #ff9fb5; border-radius: 10px;
  padding: 11px; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .1s, border-color .12s, color .12s;
}
.pf-danger:hover { border-color: #ff6b8f; color: #ffc2d0; transform: translateY(-1px); }
.pf-danger:active { transform: scale(.98); }

/* ============================ PARTY FX ================================= */
#edge-glow {
  position: fixed; inset: 0; z-index: 65; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 120px 20px var(--brand);
  transition: opacity .3s;
}
#edge-glow.on { animation: edge-pulse 1.2s ease; }
@keyframes edge-pulse { 0% { opacity: 0; } 25% { opacity: .55; } 100% { opacity: 0; } }

.combo {
  position: fixed; z-index: 66; pointer-events: none;
  transform: translate(-50%, -100%);
  font-family: var(--font-display); font-weight: 800;
  color: hsl(var(--hue, 45), 95%, 60%);
  text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 18px hsla(var(--hue,45), 95%, 60%, .5);
  opacity: 0; letter-spacing: -.02em; white-space: nowrap;
}
.combo.show { opacity: 1; }
.combo.pop { animation: combo-pop .32s cubic-bezier(.3,1.6,.4,1); }
@keyframes combo-pop { 0% { transform: translate(-50%,-100%) scale(.6) rotate(-6deg); } 60% { transform: translate(-50%,-100%) scale(1.15) rotate(3deg); } 100% { transform: translate(-50%,-100%) scale(1) rotate(0); } }

.shockwave {
  position: fixed; z-index: 64; pointer-events: none;
  width: 20px; height: 20px; border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--brand);
  animation: shockwave .65s ease-out forwards;
}
@keyframes shockwave {
  0% { width: 20px; height: 20px; opacity: .8; border-width: 4px; }
  100% { width: 520px; height: 520px; opacity: 0; border-width: 1px; }
}

@media (max-width: 860px) {
  .pf-stats { grid-template-columns: repeat(2, 1fr); }
  .profile-card { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .pf-avatar { animation: none; }
  #edge-glow.on, .shockwave, .combo.pop { animation: none; }
}

/* =========================================================================
   ADDITIONS: brand logo marquee + thread logo grid
   ========================================================================= */
.brand-strip {
  margin: 6px 8px 4px; padding: 14px 0 16px;
  border: 1px solid var(--line); border-radius: 14px;
  background:
    radial-gradient(120% 160% at 0% 0%, #1d1a27 0%, transparent 55%),
    var(--surface);
  overflow: hidden;
}
.brand-strip-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 0 18px 12px;
}
.brand-strip-title {
  font-family: var(--font-display); font-weight: 800; font-size: 15px;
  letter-spacing: -.01em; color: var(--text);
}
.brand-strip-sub { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }

.marquee {
  position: relative; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.marquee-track {
  display: flex; align-items: center; gap: 16px; width: max-content;
  animation: marquee 60s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

.brand-tile {
  flex: 0 0 auto;
  width: 172px; height: 92px; border-radius: 12px;
  background: #ffffff; /* clean white tile so every logo reads clearly */
  display: flex; align-items: center; justify-content: center;
  padding: 14px 20px; box-sizing: border-box;
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 2px 8px -4px rgba(0,0,0,.5);
  opacity: 1; /* full colour, full opacity — logos should be obvious */
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
a.brand-tile { cursor: pointer; }
.marquee .brand-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px -10px rgba(0,0,0,.65);
}
/* fill the tile: contain keeps aspect ratio, the scale claws back the
   built-in white margin that many of these source logos ship with */
.brand-img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transform: scale(1.1);
}

/* logo grid inside the auto-brands thread */
.brand-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px; margin-top: 8px;
}
.brand-grid .brand-tile { width: auto; height: 78px; opacity: 1; }
.brand-grid .brand-tile:hover { transform: translateY(-2px); }

@media (max-width: 860px) {
  .brand-tile { width: 138px; height: 78px; padding: 12px 16px; }
  .brand-grid .brand-tile { height: 66px; }
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; flex-wrap: nowrap; overflow-x: auto; }
}
