:root {
  --bg: #0a0710;
  --bg-2: #120a1f;
  --panel: rgba(18, 10, 31, 0.72);
  --text: #d7e7ff;
  --muted: #6f7ba3;
  --danger: #ff4d6d;
  --accent: #00f0ff;
  --accent-rgb: 0, 240, 255;
  --accent2: #ff2bd6;
  --accent2-rgb: 255, 43, 214;
  --accent3: #8a5bff;
  --accent3-rgb: 138, 91, 255;
  --grid-line: rgba(var(--accent3-rgb), 0.12);
  --font-body: "Share Tech Mono", monospace;
  --font-display: "Orbitron", sans-serif;
  --radius: 14px;
}

html[data-theme="cyberpunk"] {
  --bg: #0a0710;
  --bg-2: #120a1f;
  --panel: rgba(18, 10, 31, 0.72);
  --text: #d7e7ff;
  --muted: #6f7ba3;
  --danger: #ff4d6d;
  --accent: #00f0ff;
  --accent-rgb: 0, 240, 255;
  --accent2: #ff2bd6;
  --accent2-rgb: 255, 43, 214;
  --accent3: #8a5bff;
  --accent3-rgb: 138, 91, 255;
  --grid-line: rgba(var(--accent3-rgb), 0.12);
  --font-body: "Share Tech Mono", monospace;
  --font-display: "Orbitron", sans-serif;
  --radius: 14px;
}

html[data-theme="hud"] {
  --bg: #050505;
  --bg-2: #0a0a0a;
  --panel: rgba(10, 10, 10, 0.9);
  --text: #ffb000;
  --muted: #8a7a5a;
  --danger: #ff3333;
  --accent: #ffb000;
  --accent-rgb: 255, 176, 0;
  --accent2: #39ff14;
  --accent2-rgb: 57, 255, 20;
  --accent3: #ff9e00;
  --accent3-rgb: 255, 158, 0;
  --grid-line: rgba(var(--accent-rgb), 0.10);
  --font-body: "Share Tech Mono", monospace;
  --font-display: "Share Tech Mono", monospace;
  --radius: 0px;
}

html[data-theme="blueprint"] {
  --bg: #0a1a2f;
  --bg-2: #0a1a2f;
  --panel: rgba(10, 26, 47, 0.85);
  --text: #e0f0ff;
  --muted: #6c8ab0;
  --danger: #ff4d4d;
  --accent: #bfefff;
  --accent-rgb: 191, 239, 255;
  --accent2: #7dd3fc;
  --accent2-rgb: 125, 211, 252;
  --accent3: #5eb3e8;
  --accent3-rgb: 94, 179, 232;
  --grid-line: rgba(var(--accent-rgb), 0.18);
  --font-body: "Share Tech Mono", monospace;
  --font-display: "Share Tech Mono", monospace;
  --radius: 2px;
}

html[data-theme="orange"] {
  --bg: #000000;
  --bg-2: #0a0400;
  --panel: rgba(20, 10, 0, 0.75);
  --text: #ffd8a8;
  --muted: #8a6a4a;
  --danger: #ff2a2a;
  --accent: #ff6a00;
  --accent-rgb: 255, 106, 0;
  --accent2: #ff9e00;
  --accent2-rgb: 255, 158, 0;
  --accent3: #b33a00;
  --accent3-rgb: 179, 58, 0;
  --grid-line: rgba(var(--accent-rgb), 0.12);
  --font-body: "Share Tech Mono", monospace;
  --font-display: "Orbitron", sans-serif;
  --radius: 8px;
}

html[data-theme="darktech"] {
  --bg: #080a08;
  --bg-2: #0d110d;
  --panel: rgba(16, 18, 16, 0.85);
  --text: #9aa39a;
  --muted: #6a726a;
  --danger: #b85c5c;
  --accent: #7a8a7a;
  --accent-rgb: 122, 138, 122;
  --accent2: #9aa39a;
  --accent2-rgb: 154, 163, 154;
  --accent3: #7a8a7a;
  --accent3-rgb: 122, 138, 122;
  --grid-line: rgba(var(--accent-rgb), 0.08);
  --font-body: "Share Tech Mono", monospace;
  --font-display: "Share Tech Mono", monospace;
  --radius: 2px;
}

html[data-theme="enterprise"] {
  --bg: #0b1220;
  --bg-2: #0f1729;
  --panel: rgba(20, 30, 48, 0.72);
  --text: #e2e8f0;
  --muted: #7a8fb0;
  --danger: #ff5b7a;
  --accent: #5b8cff;
  --accent-rgb: 91, 140, 255;
  --accent2: #7aaaff;
  --accent2-rgb: 122, 170, 255;
  --accent3: #3b6adb;
  --accent3-rgb: 59, 106, 219;
  --grid-line: rgba(var(--accent-rgb), 0.08);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(10, 7, 16, 0.8);
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(var(--accent2-rgb), 0.12), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(var(--accent-rgb), 0.12), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 50;
}

.hidden {
  display: none !important;
}

/* ---- Logo ---- */
.logo {
  font-family: var(--font-display);
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6);
  margin: 0;
}
.logo span {
  color: var(--accent2);
  text-shadow: 0 0 8px rgba(var(--accent2-rgb), 0.6);
}
.logo.small {
  font-size: 1.1rem;
}

/* ---- Login gate ---- */
.gate {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  height: 100%;
}
.gate-card {
  position: relative;
  width: min(440px, 92vw);
  padding: 36px 32px;
  background: var(--panel);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  box-shadow:
    0 0 0 1px rgba(var(--accent2-rgb), 0.08),
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(var(--accent3-rgb), 0.18);
}
.ffc-logo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 88px;
  margin: 0 auto 14px;
  padding: 10px 12px;
  border-radius: 4px;
  background: rgba(5, 3, 10, 0.95);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  box-shadow:
    0 0 20px rgba(var(--accent-rgb), 0.28),
    inset 0 0 24px rgba(var(--accent3-rgb), 0.06);
  text-align: center;
  overflow: hidden;
}
.ffc-logo::before,
.ffc-logo::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
}
.ffc-logo::before {
  top: 5px;
  left: 5px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  box-shadow: -2px -2px 8px rgba(var(--accent-rgb), 0.35);
}
.ffc-logo::after {
  right: 5px;
  bottom: 5px;
  border-right: 2px solid var(--accent2);
  border-bottom: 2px solid var(--accent2);
  box-shadow: 2px 2px 8px rgba(var(--accent2-rgb), 0.35);
}
.ffc-logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.ffc-logo-streaks {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  opacity: 0.9;
}
.ffc-logo-streaks span {
  display: block;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.95));
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.45);
}
.ffc-logo-streaks span:nth-child(1) {
  width: 13px;
}
.ffc-logo-streaks span:nth-child(2) {
  width: 9px;
  margin-left: 2px;
  opacity: 0.75;
}
.ffc-logo-streaks span:nth-child(3) {
  width: 5px;
  margin-left: 4px;
  opacity: 0.5;
}
.ffc-logo-word {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.5px;
  line-height: 1;
  transform: skewX(-10deg);
  white-space: nowrap;
}
.ffc-logo-brand {
  color: var(--accent);
  text-shadow:
    -2px 0 0 rgba(var(--accent-rgb), 0.35),
    -4px 0 0 rgba(var(--accent-rgb), 0.15),
    0 0 10px rgba(var(--accent-rgb), 0.6);
}
.ffc-logo-tld {
  color: var(--accent2);
  text-shadow:
    0 0 10px rgba(var(--accent2-rgb), 0.55),
    1px 0 0 rgba(var(--accent2-rgb), 0.25);
}
.subtitle {
  text-align: center;
  font-family: var(--font-body);
  color: var(--accent3);
  font-size: 0.85rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.tagline {
  color: var(--muted);
  text-align: center;
  margin: 6px 0 26px;
}
#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#login-form label {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}
input,
textarea {
  font-family: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(var(--accent3-rgb), 0.4);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.18), 0 0 18px rgba(var(--accent-rgb), 0.25);
}
button {
  font-family: var(--font-display);
  letter-spacing: 2px;
  cursor: pointer;
  color: #060010;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
}
button:hover {
  box-shadow: 0 0 18px rgba(var(--accent2-rgb), 0.5);
  filter: brightness(1.08);
}
button:active {
  transform: translateY(1px);
}
.hint {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  margin: 18px 0 0;
}
code {
  color: var(--accent2);
}

/* ---- App shell ---- */
.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.18);
  background: rgba(10, 7, 16, 0.6);
  backdrop-filter: blur(6px);
  overflow: hidden;
}
.topbar .me {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex-shrink: 1;
}
.topbar .me strong {
  color: var(--accent);
}
.topbar .typing-indicator {
  color: var(--accent3);
  font-size: 0.78rem;
  font-style: italic;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}
.topbar .status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}
.topbar-btn {
  background: transparent;
  border: 1px solid rgba(var(--accent3-rgb), 0.4);
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
  flex-shrink: 0;
}
.topbar-btn:hover {
  background: rgba(var(--accent3-rgb), 0.15);
  box-shadow: 0 0 10px rgba(var(--accent3-rgb), 0.3);
}
.mute-btn.muted {
  color: var(--danger);
  border-color: rgba(255, 77, 109, 0.4);
}
.mute-btn.muted:hover {
  background: rgba(255, 77, 109, 0.15);
  box-shadow: 0 0 10px rgba(255, 77, 109, 0.3);
}
.logout-btn {
  border-color: rgba(255, 77, 109, 0.4);
  color: var(--danger);
}
.logout-btn:hover {
  background: rgba(255, 77, 109, 0.15);
  box-shadow: 0 0 10px rgba(255, 77, 109, 0.3);
}
.status.online {
  color: #57ffa8;
  text-shadow: 0 0 8px rgba(87, 255, 168, 0.5);
}
.status.status-clickable {
  cursor: pointer;
  user-select: none;
}
.status.status-clickable:hover {
  filter: brightness(1.15);
}
.status.status-pinging {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.45);
}
.status.offline {
  color: var(--danger);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: min(300px, 28vw) 1fr;
  min-height: 0;
  position: relative;
}
.layout .chat {
  min-width: 0;
  min-height: 0;
}
.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.messages {
  list-style: none;
  margin: 0;
  padding: 12px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg {
  position: relative;
  padding: 4px 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: pop 0.18s ease-out;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(var(--accent3-rgb), 0.06);
}
.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.3;
  overflow: visible;
}
.msg .body {
  display: block;
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg:hover {
  background: rgba(var(--accent3-rgb), 0.05);
}
.msg .time {
  color: var(--muted);
  font-size: 0.78rem;
  opacity: 0.7;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, opacity 0.12s;
}
.msg .time:hover {
  opacity: 1;
  color: var(--accent);
}
.msg .time.show-date {
  color: var(--accent);
  opacity: 1;
}
.msg .who {
  color: var(--accent);
  font-weight: 700;
}
.msg .who::after {
  content: none;
}
.msg.mine .who {
  color: var(--accent2);
}
.msg.mine .msg-attachment {
  text-align: left;
  justify-items: start;
}
.msg.system {
  text-align: center;
  background: transparent;
  border: none;
  color: var(--muted);
  font-style: italic;
  font-size: 0.82rem;
  padding: 2px 0;
}
.msg .body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.4);
  transition: text-decoration-color 0.15s;
}
.msg .body a:hover {
  text-decoration-color: var(--accent);
  text-shadow: 0 0 6px rgba(var(--accent-rgb), 0.4);
}
.msg-attachment {
  margin-top: 6px;
  display: grid;
  justify-items: start;
  gap: 4px;
  width: 100%;
  text-align: left;
}
.msg-attachment-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  max-width: min(320px, 100%);
}
.msg .body:empty {
  display: none;
}
.msg-attachment-name {
  min-width: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-attachment-dl {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(var(--accent3-rgb), 0.35);
  background: rgba(10, 7, 16, 0.85);
  color: var(--accent);
  text-decoration: none;
  font-size: 0.75rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.msg-attachment-dl:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
}
.msg-attachment-expired .msg-attachment-dl,
.msg-attachment-expired .cyber-audio-dl {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.7;
  border-color: rgba(var(--accent2-rgb), 0.28);
  color: rgba(111, 123, 163, 0.85);
  background: rgba(18, 10, 31, 0.75);
  box-shadow: none;
  position: relative;
}
.msg-attachment-dl-disabled::after,
.msg-attachment-expired .msg-attachment-dl::after {
  content: "";
  position: absolute;
  width: 62%;
  height: 1px;
  background: rgba(255, 77, 109, 0.55);
  box-shadow: 0 0 5px rgba(255, 77, 109, 0.35);
  transform: rotate(-42deg);
  pointer-events: none;
}
.msg-attachment-name-expired {
  opacity: 0.72;
}
.msg-attachment-media {
  position: relative;
  display: inline-block;
  max-width: min(320px, 100%);
  border-radius: 8px;
  overflow: hidden;
}
.msg-attachment-media-expired {
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  box-shadow:
    0 0 18px rgba(var(--accent-rgb), 0.08),
    inset 0 0 24px rgba(var(--accent2-rgb), 0.04);
  background: rgba(10, 7, 16, 0.92);
}
.msg-attachment-expired-stub {
  display: grid;
  place-items: center;
  min-height: 88px;
  min-width: min(280px, 100%);
  padding: 16px 20px;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.04) 0%, rgba(var(--accent2-rgb), 0.05) 100%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(var(--accent-rgb), 0.03) 3px,
      rgba(var(--accent-rgb), 0.03) 4px
    );
}
.msg-attachment-expired-stub-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.45);
  text-align: center;
}
.msg-attachment-expired-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid rgba(var(--accent-rgb), 0.38);
  background: rgba(10, 7, 16, 0.88);
  box-shadow:
    0 0 14px rgba(var(--accent-rgb), 0.18),
    inset 0 0 16px rgba(var(--accent2-rgb), 0.06);
  pointer-events: none;
  white-space: nowrap;
}
.msg-attachment-expired-badge-inline {
  margin-top: 2px;
  align-self: flex-start;
}
.msg-attachment-expired-label {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.45);
}
.cyber-audio-expired {
  position: relative;
  opacity: 0.82;
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: inset 0 0 20px rgba(var(--accent2-rgb), 0.05);
}
.cyber-audio-expired .msg-attachment-expired-badge {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.cyber-audio-expired .cyber-audio-seek,
.cyber-audio-expired .cyber-audio-vol,
.cyber-audio-expired .cyber-audio-controls button:not(.msg-attachment-dl-disabled) {
  pointer-events: none;
  opacity: 0.45;
}
.msg-deleted-text {
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
}
.msg-deleted .msg-head .who {
  opacity: 0.65;
}
.msg-img {
  max-width: 320px;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid rgba(var(--accent3-rgb), 0.3);
  cursor: zoom-in;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: block;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(5, 3, 10, 0.92);
  backdrop-filter: blur(4px);
  cursor: default;
}
.lightbox.hidden {
  display: none;
}
.lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  padding: 16px;
  cursor: zoom-out;
  pointer-events: auto;
  overflow: hidden;
  touch-action: none;
}
.lightbox-zoom-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  cursor: default;
}
.lightbox-zoom-wrap.hidden {
  display: none;
}
.lightbox-media {
  max-width: min(96vw, 100%);
  max-height: min(96vh, 100%);
  border-radius: 8px;
  border: 1px solid var(--accent);
  box-shadow: 0 0 32px rgba(var(--accent-rgb), 0.35);
  pointer-events: auto;
}
.lightbox-media.hidden {
  display: none;
}
.lightbox-img {
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  touch-action: none;
  cursor: default;
  -webkit-user-drag: none;
  user-select: none;
}
.lightbox-video {
  background: #000;
  touch-action: none;
  user-select: none;
  cursor: default;
}
.lightbox.lightbox-zoomed .lightbox-img {
  cursor: zoom-out;
}
.lightbox.lightbox-zoomed .lightbox-img:active {
  cursor: grabbing;
}
.lightbox-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: min(34vw, 200px);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  cursor: pointer;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
}
.lightbox-nav.hidden {
  display: none;
  pointer-events: none;
}
.lightbox-prev {
  left: 0;
}
.lightbox-next {
  right: 0;
}

/* ---- Image editor (pre-send) ---- */
.image-editor {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 3, 10, 0.92);
  backdrop-filter: blur(4px);
}
.image-editor.hidden {
  display: none;
}
.image-editor-card {
  width: min(720px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  background: rgba(10, 7, 16, 0.96);
  box-shadow: 0 0 30px rgba(var(--accent3-rgb), 0.2);
}
.image-editor-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--accent);
}
.image-editor-viewport {
  position: relative;
  width: 100%;
  height: min(52vh, 420px);
  min-height: 200px;
  border-radius: 8px;
  border: 1px solid rgba(var(--accent3-rgb), 0.35);
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}
.image-editor-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.image-editor-img.flipped {
  transform: scaleX(-1);
}
.image-editor-crop {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.35);
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}
.image-editor-viewport.has-crop {
  cursor: crosshair;
}
.image-editor-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-body);
}
.image-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.image-editor-btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 1px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(var(--accent3-rgb), 0.4);
  background: rgba(10, 7, 16, 0.85);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.image-editor-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.25);
  filter: none;
  transform: none;
}
.image-editor-apply {
  color: #060010;
  border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  font-weight: 700;
}
.image-editor-apply:hover {
  color: #060010;
  box-shadow: 0 0 18px rgba(var(--accent2-rgb), 0.45);
}
.image-editor-cancel:hover {
  border-color: var(--danger);
  color: #ffb3c0;
}

.msg-img:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.3);
}
.msg-video {
  max-width: 400px;
  max-height: 300px;
  border-radius: 8px;
  border: 1px solid rgba(var(--accent3-rgb), 0.3);
  display: block;
}
.cyber-audio {
  width: min(100%, 340px);
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb), 0.06), rgba(var(--accent3-rgb), 0.08)),
    rgba(6, 0, 16, 0.85);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.12), inset 0 0 24px rgba(var(--accent3-rgb), 0.06);
}
.cyber-audio-el {
  display: none;
}
.cyber-audio-top {
  margin-bottom: 8px;
}
.cyber-audio-title {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.5px;
}
.cyber-audio-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.cyber-audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(var(--accent3-rgb), 0.45);
  background: rgba(10, 7, 16, 0.8);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s, background 0.12s;
}
.cyber-audio-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.25);
  filter: none;
}
.cyber-audio-dl {
  margin-left: auto;
  color: var(--accent2);
  border-color: rgba(var(--accent2-rgb), 0.35);
}
.cyber-audio-dl:hover {
  color: #ffd2ff;
  border-color: var(--accent2);
  box-shadow: 0 0 10px rgba(var(--accent2-rgb), 0.25);
}
.cyber-audio-time {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 72px;
  text-align: center;
}
.cyber-audio-seek,
.cyber-audio-vol {
  width: 100%;
  height: 6px;
  margin: 0;
  appearance: none;
  background: rgba(var(--accent3-rgb), 0.18);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.cyber-audio-seek::-webkit-slider-thumb,
.cyber-audio-vol::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent));
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.45);
}
.cyber-audio-seek::-moz-range-thumb,
.cyber-audio-vol::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.45);
}
.cyber-audio-vol-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.cyber-audio-vol-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  opacity: 0.85;
}
.cyber-audio-vol {
  flex: 1;
}
.msg-file-link {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(var(--accent3-rgb), 0.1);
  border: 1px solid rgba(var(--accent3-rgb), 0.3);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.msg-file-link:hover {
  background: rgba(var(--accent3-rgb), 0.2);
  border-color: var(--accent);
}

.event-log {
  margin-top: auto;
  border-top: 1px solid rgba(var(--accent3-rgb), 0.18);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.event-log-toggle {
  width: 100%;
  box-sizing: border-box;
  background: rgba(18, 10, 31, 0.55);
  border: 1px solid rgba(var(--accent3-rgb), 0.22);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--accent3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  overflow: hidden;
}
.event-log-toggle > span:not(.event-log-chevron) {
  min-width: 0;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-log-chevron {
  flex-shrink: 0;
  color: var(--accent);
  transition: transform 0.15s;
}

.event-log.collapsed .event-log-list {
  display: none;
}

.event-log.collapsed .event-log-chevron {
  transform: rotate(-90deg);
}

.event-log-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 32vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-log-list li {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.3;
  user-select: text;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.event-log-time {
  color: var(--accent);
  opacity: 0.7;
  font-size: 0.68rem;
  white-space: nowrap;
}
/* Owner "delete my message" control (own messages only). */
.msg-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255, 60, 60, 0.4);
  background: rgba(10, 7, 16, 0.85);
  color: #ff3c3c;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.msg-delete::before,
.msg-delete::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 1.6px;
  background: currentColor;
  border-radius: 1px;
}
.msg-delete::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.msg-delete::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}
.msg:hover .msg-delete,
.msg-delete:focus-visible {
  opacity: 0.85;
}
.msg-delete:hover {
  opacity: 1;
  background: rgba(255, 60, 60, 0.2);
  border-color: #ff3c3c;
}
/* ---- Attachments panel ---- */
.attachments-panel {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: rgba(10, 7, 16, 0.95);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  max-height: 200px;
  overflow-y: auto;
}
.attachments-panel.hidden { display: none !important; }

.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(var(--accent3-rgb), 0.08);
  border: 1px solid rgba(var(--accent3-rgb), 0.25);
  border-radius: 8px;
  min-width: 180px;
  max-width: 280px;
  position: relative;
  animation: pop 0.15s ease-out;
}
.attach-item.attach-error {
  border-color: rgba(255, 60, 60, 0.5);
  background: rgba(255, 60, 60, 0.08);
}
.attach-item-audio {
  flex: 1 1 100%;
  max-width: 100%;
  min-width: min(100%, 340px);
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.attach-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.attach-item-audio .attach-bar-wrap {
  width: 100%;
}
.attach-item-audio .cyber-audio {
  width: 100%;
  margin-top: 0;
}
.attach-item-image {
  flex: 1 1 100%;
  max-width: 100%;
  min-width: min(100%, 280px);
}
.attach-preview-clickable {
  cursor: zoom-in;
}
.attach-preview-clickable:hover {
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.25);
}
.attach-edit-btn {
  flex-shrink: 0;
  align-self: center;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}
.attach-edit-btn:hover {
  background: rgba(var(--accent-rgb), 0.15);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
  filter: none;
  transform: none;
}

.attach-preview {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}
.attach-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attach-icon {
  font-size: 1.4rem;
}

.attach-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.attach-name {
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-size {
  font-size: 0.65rem;
  color: var(--muted);
}

.attach-bar-wrap {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.attach-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.5);
}

.attach-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 60, 60, 0.5);
  background: rgba(10, 7, 16, 0.9);
  color: #ff3c3c;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}
.attach-remove::before,
.attach-remove::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
.attach-remove::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.attach-remove::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}
.attach-remove:hover {
  background: rgba(255, 60, 60, 0.2);
  border-color: #ff3c3c;
}

/* ---- Drag & drop overlay ---- */
.chat.drag-over {
  position: relative;
}
.chat.drag-over::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(var(--accent-rgb), 0.06);
  border: 2px dashed var(--accent);
  border-radius: 12px;
  z-index: 20;
  pointer-events: none;
  animation: pulse-border 1s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.composer {
  position: relative;
  border-top: 1px solid rgba(var(--accent-rgb), 0.18);
  padding: 18px 14px 10px;
  background: rgba(10, 7, 16, 0.6);
}
/* Top drag strip: grab it to resize the message input vertically. */
.composer-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 14px;
  cursor: ns-resize;
  touch-action: none;
  z-index: 12;
}
.composer-resize-handle::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 4px;
  border-radius: 3px;
  background: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.25);
  transition: background 0.15s, box-shadow 0.15s;
}
.composer-resize-handle:hover::before,
.composer-resize-handle.dragging::before {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 10px rgba(var(--accent3-rgb), 0.5);
}
.composer-input-row {
  display: flex;
}
.composer-input-row textarea {
  flex: 1;
  width: 100%;
  min-height: 38px;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 1.05rem;
  line-height: 1.4;
  box-sizing: border-box;
  resize: none;
}
.composer-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.attach-btn {
  background: transparent;
  border: 1px solid rgba(var(--accent3-rgb), 0.4);
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-sizing: border-box;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  color: var(--text);
}
.attach-btn:hover {
  background: rgba(var(--accent3-rgb), 0.15);
  box-shadow: 0 0 10px rgba(var(--accent3-rgb), 0.3);
}
.attach-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.emoji-btn {
  background: transparent;
  border: 1px solid rgba(var(--accent3-rgb), 0.4);
  font-size: 1.2rem;
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-sizing: border-box;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  color: var(--text);
}
.emoji-btn:hover {
  background: rgba(var(--accent3-rgb), 0.15);
  box-shadow: 0 0 10px rgba(var(--accent3-rgb), 0.3);
}
.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: rgba(10, 7, 16, 0.95);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}
.emoji-picker.hidden {
  display: none !important;
}
.emoji-picker button {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
  min-width: 32px;
  text-align: center;
}
.emoji-picker button:hover {
  background: rgba(var(--accent-rgb), 0.15);
  box-shadow: none;
}
.emoji-category {
  width: 100%;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 0 2px;
  font-family: var(--font-body);
}
.byte-count {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  line-height: 1.2;
}
.byte-count #byte-count-msg {
  font-size: 0.6rem;
  opacity: 0.7;
}
.byte-count #byte-count-label {
  font-size: 0.6rem;
  opacity: 0.7;
}
.byte-count.over {
  color: var(--danger);
}
.send-btn {
  flex-shrink: 0;
}

.toast {
  position: absolute;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 77, 109, 0.16);
  border: 1px solid var(--danger);
  color: #ffd2da;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 0 20px rgba(255, 77, 109, 0.3);
}

/* ---- Send context menu ---- */
.send-ctx-menu {
  position: absolute;
  bottom: 60px;
  right: 14px;
  z-index: 50;
  background: rgba(10, 7, 16, 0.95);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(var(--accent3-rgb), 0.15);
  padding: 6px 0;
  min-width: 200px;
}
.send-ctx-menu.hidden { display: none; }
.ctx-item {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 10px 16px;
  text-align: left;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.12s, color 0.12s;
}
.ctx-item:hover {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
}
.ctx-item:active {
  transform: none;
  box-shadow: none;
}
.ctx-divider {
  height: 1px;
  background: rgba(var(--accent3-rgb), 0.25);
  margin: 4px 10px;
}
.ctx-item .ctx-hint {
  color: var(--muted);
  font-size: 0.68rem;
  margin-left: 8px;
}
.ctx-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Cyberpunk checkbox ---- */
.cyber-checkbox {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  position: relative;
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  border-radius: 3px;
  background: rgba(var(--accent-rgb), 0.05);
  box-shadow: inset 0 0 6px rgba(var(--accent-rgb), 0.15);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  /* clipped corner for that cyberpunk chamfer look */
  clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%);
}
.ctx-item:hover .cyber-checkbox {
  border-color: var(--accent);
  box-shadow: inset 0 0 8px rgba(var(--accent-rgb), 0.3), 0 0 8px rgba(var(--accent-rgb), 0.3);
}
.cyber-checkbox.checked {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6), 0 0 18px rgba(255, 42, 109, 0.35);
}
.cyber-checkbox.checked::after {
  content: "\2713";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0710;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

/* ---- Replies ---- */
.msg-reply {
  display: inline-block;
  max-width: min(480px, 100%);
  margin: 2px 0;
  padding: 2px 8px;
  border-left: 2px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.06);
  border-radius: 0 6px 6px 0;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  text-indent: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  transition: background 0.12s;
}
.msg-reply:hover {
  background: rgba(var(--accent-rgb), 0.12);
}
.msg-reply-login {
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}
.msg-flash {
  animation: msg-flash-anim 1.4s ease-out;
}
@keyframes msg-flash-anim {
  0%, 40% { background: rgba(var(--accent-rgb), 0.16); }
  100% { background: transparent; }
}

/* ---- Message context menu ---- */
.msg-ctx-menu {
  position: fixed;
  z-index: 100;
  background: rgba(10, 7, 16, 0.95);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(var(--accent3-rgb), 0.15);
  padding: 6px 0;
  min-width: 160px;
}
.msg-ctx-menu.hidden { display: none; }

/* ---- Reply bar (composer) ---- */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 2px solid var(--accent);
  background: rgba(var(--accent-rgb), 0.07);
  border-radius: 0 8px 8px 0;
  font-size: 0.82rem;
  overflow: hidden;
}
.reply-bar-icon {
  color: var(--accent);
  flex-shrink: 0;
}
.reply-bar-login {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}
.reply-bar-text {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.reply-cancel {
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.reply-cancel:hover {
  color: var(--danger);
  background: rgba(255, 77, 109, 0.12);
  box-shadow: none;
}

/* ---- Edit bar (composer) ---- */
.edit-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 2px solid var(--accent2);
  background: rgba(var(--accent2-rgb), 0.07);
  border-radius: 0 8px 8px 0;
  font-size: 0.82rem;
  overflow: hidden;
}
.edit-bar-icon {
  color: var(--accent2);
  flex-shrink: 0;
}
.edit-bar-label {
  color: var(--accent2);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.edited-tag {
  color: var(--muted);
  font-size: 0.68rem;
  margin-left: 6px;
  font-family: var(--font-body);
  letter-spacing: 0.5px;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}
.edited-tag::after {
  content: attr(data-edited-at);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  background: rgba(10, 7, 16, 0.96);
  color: var(--accent);
  font-size: 0.68rem;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 40;
}
.msg.mine .edited-tag::after {
  left: auto;
  right: calc(100% + 8px);
}
.edited-tag:hover::after,
.edited-tag:focus-visible::after {
  opacity: 1;
  visibility: visible;
}
.msg-ctx-menu .ctx-danger {
  color: #ffb3c0;
}
.msg-ctx-menu .ctx-danger:hover {
  background: rgba(255, 77, 109, 0.12);
  color: #ffd2da;
}

/* ---- Message reactions ---- */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  text-indent: 0;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(var(--accent3-rgb), 0.12);
  border: 1px solid rgba(var(--accent3-rgb), 0.35);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.82rem;
  font-family: var(--font-body);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.reaction-chip:hover {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
}
.reaction-chip.mine {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
}
.reaction-chip .reaction-count {
  color: var(--muted);
  font-size: 0.72rem;
}
.reaction-chip.mine .reaction-count {
  color: var(--accent);
}
.reaction-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px dashed rgba(var(--accent3-rgb), 0.4);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, border-color 0.12s, color 0.12s;
}
.msg:hover .reaction-add {
  opacity: 1;
}
.reaction-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
}

/* ---- Reaction picker ---- */
.reaction-picker {
  position: fixed;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: auto;
  max-width: min(360px, calc(100vw - 16px));
  height: auto;
  padding: 6px 8px;
  background: rgba(10, 7, 16, 0.95);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(var(--accent3-rgb), 0.15);
  overflow: hidden;
}
.reaction-picker.expanded {
  width: min(320px, calc(100vw - 16px));
  height: min(380px, calc(100vh - 16px));
  max-height: min(380px, calc(100vh - 16px));
  padding: 8px;
}
.reaction-picker.hidden {
  display: none;
}
.reaction-quick {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  overflow-x: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 32px;
}
.reaction-picker.expanded .reaction-quick {
  flex-wrap: wrap;
  overflow-x: visible;
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(var(--accent3-rgb), 0.2);
}
.reaction-expanded {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
}
.reaction-search-wrap {
  flex-shrink: 0;
  margin-bottom: 6px;
}
.reaction-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(var(--accent3-rgb), 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.reaction-search::placeholder {
  color: var(--muted);
}
.reaction-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
}
.reaction-full {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 2px;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-right: 2px;
}
.reaction-quick-btn,
.reaction-full button {
  background: transparent;
  border: none;
  font-family: inherit;
  font-weight: normal;
  letter-spacing: 0;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
  filter: none;
  background-image: none;
}
.reaction-quick-btn {
  padding-top: 1px;
}
.reaction-expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 999px;
  background: rgba(var(--accent3-rgb), 0.18);
  background-image: none;
  color: var(--muted);
  font-family: inherit;
  font-weight: normal;
  letter-spacing: 0;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none;
  filter: none;
  transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.reaction-expand-btn svg {
  display: block;
  flex-shrink: 0;
}
.reaction-picker.expanded .reaction-expand-btn {
  display: none;
}
.reaction-expand-btn:hover {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
  transform: none;
  filter: none;
}
.reaction-expand-btn:active {
  transform: none;
}
.reaction-quick-btn:hover,
.reaction-full button:hover {
  background: rgba(var(--accent-rgb), 0.15);
  transform: scale(1.12);
  box-shadow: none;
  filter: none;
}
.reaction-quick-btn:active {
  transform: scale(1.05);
}
.reaction-full .emoji-category {
  width: 100%;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 0 2px;
  font-family: var(--font-body);
}
.emoji-search-empty {
  width: 100%;
  padding: 16px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--font-body);
}

/* ---- Side drawer (rooms / users / log) ---- */
.drawer-overlay {
  display: none;
}
.drawer {
  position: relative;
  top: auto;
  left: auto;
  bottom: auto;
  z-index: 1;
  width: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  overflow: hidden;
  background: rgba(8, 5, 14, 0.55);
  border-right: 1px solid rgba(var(--accent3-rgb), 0.18);
  box-shadow: none;
  backdrop-filter: none;
  animation: none;
}
.drawer.hidden {
  display: none;
}
.drawer-section {
  border: 1px solid rgba(var(--accent3-rgb), 0.25);
  border-radius: 10px;
  background: rgba(18, 10, 31, 0.5);
  overflow: hidden;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.drawer-section.collapsed {
  flex: 0 0 auto;
}
.drawer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
  overflow: hidden;
}
.drawer-header > span:not(.drawer-caret):not(.drawer-count) {
  min-width: 0;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-header:hover {
  background: rgba(var(--accent-rgb), 0.08);
  box-shadow: none;
}
.drawer-caret {
  flex-shrink: 0;
  display: inline-block;
  transition: transform 0.15s;
  font-size: 0.7rem;
}
.drawer-section.collapsed .drawer-caret {
  transform: rotate(-90deg);
}
.drawer-count {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
}
.drawer-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 6px 6px;
}
.drawer-section.collapsed .drawer-body,
.drawer-section.collapsed .drawer-resize {
  display: none;
}
.drawer-resize {
  height: 10px;
  cursor: ns-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(var(--accent3-rgb), 0.15);
}
.drawer-resize::before {
  content: "";
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: rgba(var(--accent3-rgb), 0.45);
  transition: background 0.12s, box-shadow 0.12s;
}
.drawer-resize:hover::before,
.drawer-resize.dragging::before {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
}
.drawer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}
.drawer-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-room {
  cursor: pointer;
  transition: background 0.12s;
}
.drawer-room:hover {
  background: rgba(var(--accent-rgb), 0.08);
}
.drawer-room.active {
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
}
.drawer-room .drawer-room-users {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.72rem;
  flex-shrink: 0;
}
.drawer-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px 8px;
  list-style: none;
}
.drawer-lobby-btn,
.drawer-create-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 1px;
  padding: 4px 2px;
  transition: color 0.12s, text-shadow 0.12s;
}
.drawer-lobby-btn {
  color: var(--accent2);
}
.drawer-lobby-btn:hover {
  text-shadow: 0 0 8px rgba(var(--accent2-rgb), 0.5);
  box-shadow: none;
}
.drawer-create-btn {
  color: var(--accent);
  margin-left: auto;
}
.drawer-create-btn:hover {
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.5);
  box-shadow: none;
}
.drawer-delete-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 77, 109, 0.35);
  border-radius: 8px;
  color: #ffb3c0;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 1px;
  padding: 8px 10px;
  transition: color 0.12s, background 0.12s, box-shadow 0.12s;
}
.drawer-delete-btn:hover {
  background: rgba(255, 77, 109, 0.12);
  color: #ffd2da;
  box-shadow: 0 0 10px rgba(255, 77, 109, 0.25);
}

/* ---- Room deleted overlay ---- */
.room-deleted-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 0, 16, 0.82);
  backdrop-filter: blur(4px);
}
.room-deleted-overlay.hidden {
  display: none;
}
.room-deleted-card {
  max-width: 360px;
  width: 100%;
  padding: 20px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 77, 109, 0.35);
  background: rgba(10, 7, 16, 0.96);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 77, 109, 0.15);
  text-align: center;
}
.room-deleted-text {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}
.room-deleted-lobby {
  font-family: var(--font-display);
  letter-spacing: 2px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: #060010;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.room-deleted-lobby:hover {
  box-shadow: 0 0 18px rgba(var(--accent2-rgb), 0.5);
  filter: brightness(1.08);
}

.drawer-user-you {
  color: var(--accent);
}
.drawer-log li {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 3px 8px;
  white-space: normal;
}
.drawer-log-date {
  text-align: center;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 1px;
  padding: 8px 8px 4px;
  opacity: 0.9;
}
.drawer-log-date:first-child {
  padding-top: 4px;
}
.drawer-log .log-time {
  color: rgba(var(--accent3-rgb), 0.8);
  margin-right: 6px;
}

/* ---- Cyberpunk Scrollbars ---- */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(10, 7, 16, 0.8);
  border-left: 1px solid rgba(var(--accent-rgb), 0.15);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.5), 0 0 12px rgba(var(--accent2-rgb), 0.3);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent), var(--accent3));
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.8), 0 0 20px rgba(var(--accent3-rgb), 0.5);
}

::-webkit-scrollbar-corner {
  background: var(--bg);
}

/* The composer textarea is resized via the top drag strip, not the
   native bottom-right corner handle. */
textarea {
  resize: none;
}

/* Selections */
::selection {
  background: rgba(var(--accent-rgb), 0.3);
  color: #fff;
}

/* Focus outlines */
:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.4);
}

/* Input / button cyberpunk states */
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3), inset 0 0 4px rgba(var(--accent-rgb), 0.1);
}

button:active {
  transform: scale(0.97);
  box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.6), 0 0 30px rgba(var(--accent2-rgb), 0.3);
}

/* ---- Lobby (room list) ---- */
.lobby {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow-y: auto;
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.lobby-header h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 3px;
  color: var(--accent3);
  margin: 0;
}
.create-room-btn {
  font-size: 0.7rem;
  padding: 8px 16px;
  letter-spacing: 1px;
}
.room-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.room-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid rgba(var(--accent3-rgb), 0.25);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.room-item:hover {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.2);
  background: rgba(18, 10, 31, 0.9);
}
.room-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.room-name-text {
  flex: 1;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-display);
  letter-spacing: 1px;
}
.room-users {
  color: var(--muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.no-rooms {
  color: var(--muted);
  text-align: center;
  margin-top: 60px;
  font-size: 0.9rem;
}
.room-item.room-permanent {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
}
.room-item.room-permanent:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.25);
}
.room-item.loading-placeholder {
  justify-content: center;
  color: var(--accent);
  font-family: var(--font-body);
  animation: pulse-glow 1s ease-in-out infinite;
  border-color: rgba(var(--accent-rgb), 0.2);
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; text-shadow: 0 0 5px var(--accent); }
  50% { opacity: 1; text-shadow: 0 0 15px var(--accent); }
}
.room-label {
  font-family: var(--font-display);
  color: var(--accent2);
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(var(--accent2-rgb), 0.4);
}
.back-btn {
  font-size: 1rem;
  padding: 4px 8px;
}

/* ---- Dialogs ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}
.dialog-card {
  width: min(400px, 90vw);
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(var(--accent3-rgb), 0.18);
}
.dialog-card h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: var(--accent);
  margin: 0 0 16px;
  text-align: center;
}
.dialog-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dialog-card label {
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.dialog-actions button {
  flex: 1;
}
.dialog-cancel {
  background: transparent !important;
  border: 1px solid rgba(var(--accent3-rgb), 0.4) !important;
  color: var(--muted) !important;
}
.dialog-cancel:hover {
  background: rgba(var(--accent3-rgb), 0.15) !important;
}

/* ---- Mobile responsive ---- */
@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .layout .drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 70;
    width: min(320px, 85vw);
    background: rgba(10, 7, 16, 0.96);
    border-right: 1px solid rgba(var(--accent-rgb), 0.25);
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(var(--accent3-rgb), 0.15);
    backdrop-filter: blur(10px);
    animation: drawer-in 0.18s ease-out;
  }
  .layout .drawer.hidden {
    display: none;
  }
  .drawer-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 69;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
  }
  .drawer-overlay.hidden {
    display: none;
  }
  @keyframes drawer-in {
    from { transform: translateX(-30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
  }
  .topbar {
    padding: 8px 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .topbar .logo.small {
    font-size: 0.75rem;
  }
  .topbar .me {
    font-size: 0.75rem;
    max-width: 35%;
  }
  .topbar .status {
    font-size: 0.72rem;
  }
  .topbar .typing-indicator {
    display: none;
  }
  .room-label {
    font-size: 0.68rem;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-btn {
    padding: 4px 7px;
    font-size: 0.8rem;
    min-width: 28px;
    text-align: center;
  }
}

@media (min-width: 721px) {
  .back-btn {
    display: none !important;
  }
}

@media (max-width: 720px) {
  .lobby {
    padding: 14px 10px;
  }
  .lobby-header {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 14px;
  }
  .lobby-header h2 {
    text-align: center;
    font-size: 0.85rem;
  }
  .create-room-btn {
    width: 100%;
    text-align: center;
    padding: 10px;
    font-size: 0.7rem;
  }
  .room-item {
    padding: 10px 12px;
    gap: 8px;
  }
  .room-name-text {
    font-size: 0.82rem;
  }
  .room-users {
    font-size: 0.72rem;
  }
  .messages {
    padding: 10px;
    gap: 6px;
  }
  .msg {
    max-width: 100%;
    padding: 6px 10px;
    font-size: 0.88rem;
    background: rgba(18, 10, 31, 0.7);
    border-radius: 10px;
    border-left: 2px solid var(--accent3);
    border-bottom: none;
  }
  .msg:not(.system) {
    text-indent: 0;
  }
  .msg-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
  }
  .msg.mine .msg-head {
    justify-content: flex-end;
  }
  .msg .body {
    display: block;
  }
  .msg:hover {
    background: rgba(18, 10, 31, 0.85);
  }
  .msg .time {
    display: inline;
    font-size: 0.65rem;
    margin-right: 0;
    margin-top: 0;
  }
  .msg .who::after {
    content: "";
  }
  .msg.mine {
    border-left: none;
    border-right: 2px solid var(--accent2);
    background: rgba(45, 14, 40, 0.6);
    text-align: right;
  }
  .msg.mine .msg-attachment {
    text-align: left;
    justify-items: start;
  }
  .msg.mine .msg-attachment-head,
  .msg.mine .msg-img,
  .msg.mine .msg-video {
    justify-self: start;
  }
  .composer {
    padding: 16px 8px 6px;
    position: sticky;
    bottom: 0;
    z-index: 10;
  }
  .composer-bottom-row {
    gap: 4px;
    margin-top: 6px;
  }
  .composer-actions {
    gap: 4px;
  }
  .composer-input-row textarea {
    font-size: 0.85rem;
    padding: 6px 8px;
    min-height: 32px;
    height: 32px;
  }
  .composer-input-row textarea::placeholder {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .byte-count {
    font-size: 0.58rem;
    white-space: nowrap;
  }
  .emoji-btn,
  .attach-btn {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }
  .send-btn {
    padding: 6px 10px;
    font-size: 0.65rem;
    letter-spacing: 1px;
    white-space: nowrap;
  }
  .gate-card {
    padding: 24px 18px;
  }
  .dialog-card {
    padding: 20px 16px;
    width: min(360px, 92vw);
  }
  .dialog-card input[type="text"],
  .dialog-card input[type="password"] {
    font-size: 16px;
    padding: 10px 12px;
  }
}

@media (max-width: 380px) {
  .topbar .me {
    max-width: 70px;
    font-size: 0.68rem;
  }
  .topbar .logo.small {
    font-size: 0.68rem;
  }
  .room-label {
    max-width: 70px;
    font-size: 0.6rem;
  }
  .msg {
    font-size: 0.82rem;
  }
  .byte-count {
    display: none;
  }
  .send-btn {
    padding: 6px 8px;
    font-size: 0.6rem;
  }
}

/* ---- Theme extras ---- */
.theme-switcher {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 4px 6px;
  margin-left: 8px;
}

html[data-theme="hud"] body {
  background:
    radial-gradient(circle at 50% 50%, rgba(var(--accent-rgb), 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(var(--accent2-rgb), 0.04) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

html[data-theme="blueprint"] body {
  background:
    linear-gradient(0deg, var(--bg) 48px, rgba(var(--accent-rgb), 0.03) 49px, transparent 50px),
    linear-gradient(90deg, var(--bg) 48px, rgba(var(--accent-rgb), 0.03) 49px, transparent 50px),
    var(--bg);
}

html[data-theme="orange"] body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(var(--accent2-rgb), 0.14), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(var(--accent-rgb), 0.14), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
}

html[data-theme="darktech"] body {
  background: var(--bg);
}

html[data-theme="enterprise"] body {
  background: var(--bg);
}

html[data-theme="blueprint"] .scanlines,
html[data-theme="darktech"] .scanlines,
html[data-theme="enterprise"] .scanlines {
  display: none;
}

html[data-theme="hud"] .hud-corners,
html[data-theme="hud"] .gate-card,
html[data-theme="hud"] .composer,
html[data-theme="hud"] .drawer-section,
html[data-theme="hud"] .dialog-card {
  position: relative;
}

html[data-theme="hud"] .hud-corners::before,
html[data-theme="hud"] .gate-card::before,
html[data-theme="hud"] .composer::before,
html[data-theme="hud"] .drawer-section::before,
html[data-theme="hud"] .dialog-card::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 12px;
  height: 12px;
  border-top: 2px solid var(--accent);
  border-left: 2px solid var(--accent);
  pointer-events: none;
  z-index: 2;
}

html[data-theme="hud"] .hud-corners::after,
html[data-theme="hud"] .gate-card::after,
html[data-theme="hud"] .composer::after,
html[data-theme="hud"] .drawer-section::after,
html[data-theme="hud"] .dialog-card::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 12px;
  height: 12px;
  border-bottom: 2px solid var(--accent2);
  border-right: 2px solid var(--accent2);
  pointer-events: none;
  z-index: 2;
}

html[data-theme="hud"] .gate-card,
html[data-theme="hud"] .dialog-card,
html[data-theme="hud"] .composer,
html[data-theme="hud"] .drawer-section,
html[data-theme="hud"] .room-list li,
html[data-theme="blueprint"] .gate-card,
html[data-theme="blueprint"] .dialog-card,
html[data-theme="blueprint"] .composer,
html[data-theme="blueprint"] .drawer-section,
html[data-theme="blueprint"] .room-list li,
html[data-theme="enterprise"] .gate-card,
html[data-theme="enterprise"] .dialog-card,
html[data-theme="enterprise"] .composer,
html[data-theme="enterprise"] .drawer-section,
html[data-theme="enterprise"] .room-list li {
  border-radius: var(--radius);
  backdrop-filter: none;
}

html[data-theme="blueprint"] .gate-card,
html[data-theme="blueprint"] .dialog-card,
html[data-theme="blueprint"] .composer,
html[data-theme="blueprint"] .drawer-section,
html[data-theme="blueprint"] .room-list li {
  border-style: dashed;
}

/* ---- @mention autocomplete ---- */
.mention-suggest {
  min-height: 0;
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg-surface, #1a1a2e);
  border: 1px solid var(--border, #3a3a5c);
  border-radius: 8px;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin-bottom: 4px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
}
.mention-item {
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font-mono, monospace);
  font-size: 0.95rem;
  color: var(--fg, #e0e0e0);
  transition: background 0.1s;
}
.mention-item:hover,
.mention-item.selected {
  background: var(--accent, #7c3aed);
  color: #fff;
}
