/* ==========================================================================
   M1sch1ef — chatroom styles
   ========================================================================== */
:root {
  --bg-0: #07070b;
  --bg-1: #0d0d14;
  --bg-2: #131321;
  --line: #1f1f30;
  --line-2: #2a2a40;
  --ink: #e6e6f0;
  --ink-dim: #8a8aa3;
  --ink-low: #5a5a72;
  --acid: #b8ff2e;          /* mischief neon */
  --hot:  #ff2e92;          /* accent two */
  --warn: #ffb84a;
  --shadow-acid: 0 0 0 1px rgba(184,255,46,0.45), 0 0 18px rgba(184,255,46,0.35);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Unbounded", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1100px 700px at 12% -10%, #16162a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #1a0e1e 0%, transparent 55%),
              var(--bg-0);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: var(--acid); color: #000; }

/* ===== Background FX ===== */
.bg-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.bg-scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.02) 0px,
    rgba(255,255,255,0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: .35;
}

/* ===== Nickname Gate ===== */
.nick-gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(7,7,11,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px;
}
.nick-card {
  width: 100%; max-width: 460px;
  background: linear-gradient(180deg, #11111c 0%, #0c0c14 100%);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 36px 32px 28px;
  text-align: left;
  position: relative;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.04);
}
.nick-card::before {
  content: ""; position: absolute; inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(135deg, rgba(184,255,46,0.4), transparent 40%, rgba(255,46,146,0.3) 100%);
  z-index: -1;
  filter: blur(1px);
}
.nick-logo { width: 52px; height: 52px; margin-bottom: 16px; display: block; }
.nick-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.nick-title .acc { color: var(--acid); text-shadow: 0 0 18px rgba(184,255,46,0.45); }
.nick-sub { color: var(--ink-dim); margin: 0 0 22px; font-size: 13px; }
.nick-form { display: flex; gap: 8px; }
.nick-form input {
  flex: 1;
  background: #07070b;
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  padding: 13px 14px;
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.nick-form input:focus {
  border-color: var(--acid);
  box-shadow: 0 0 0 3px rgba(184,255,46,0.15);
}
.nick-form button {
  background: var(--acid);
  color: #000;
  border: none;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  padding: 0 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.nick-form button:hover { transform: translateY(-1px); box-shadow: var(--shadow-acid); }
.nick-form button:active { transform: translateY(0); }
.nick-foot { margin: 18px 0 0; font-size: 11px; color: var(--ink-low); letter-spacing: .04em; }

/* ===== App Shell ===== */
.app {
  position: relative; z-index: 2;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh; height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 18px 0;
}
@media (max-width: 640px){
  .app { padding: 10px 10px 0; }
}

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 28px; height: 28px; }
.brand-name {
  font-family: var(--display); font-weight: 800;
  font-size: 20px; letter-spacing: -0.02em;
}
.who { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-dim); }
.who-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--acid); box-shadow: 0 0 10px var(--acid);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.who-nick {
  background: transparent; border: 1px dashed var(--line-2);
  color: var(--acid); padding: 4px 10px; border-radius: 999px;
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.who-nick:hover { border-color: var(--acid); color: #fff; }

/* tabs */
.tabs-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 2px 12px;
  border-bottom: 1px solid var(--line);
}
.tabs {
  flex: 1; min-width: 0;
  display: flex; gap: 6px; align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-sep {
  flex-shrink: 0;
  display: inline-block;
  width: 1px; height: 18px;
  background: var(--line-2);
  margin: 0 4px;
}
.new-dm {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--hot);
  color: var(--hot);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.new-dm:hover { background: var(--hot); color: #000; box-shadow: 0 0 0 1px var(--hot), 0 0 14px rgba(255,46,146,0.4); }
.tab {
  flex-shrink: 0;
  position: relative;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: var(--acid);
  border-color: var(--acid);
  color: #000;
  font-weight: 700;
  box-shadow: var(--shadow-acid);
}
.tab.tab-dm.active {
  background: var(--hot);
  border-color: var(--hot);
  color: #fff;
  box-shadow: 0 0 0 1px var(--hot), 0 0 18px rgba(255,46,146,0.45);
}
.tab .hash { opacity: .55; }
.tab.active .hash { opacity: .85; }
.tab .unread {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--hot);
  color: #fff;
  font-size: 10px; font-weight: 700;
  margin-left: 2px;
}
.tab.active .unread { background: #000; color: var(--hot); }
.tab .tab-close {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 14px; line-height: 1;
  opacity: .55;
  margin-left: 2px;
  transition: opacity .15s, background .15s;
}
.tab .tab-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.tab.active .tab-close:hover { background: rgba(0,0,0,0.2); }

/* stage */
.stage {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  min-height: 0;
  padding: 14px 0 0;
}

/* messages */
.messages {
  overflow-y: auto;
  padding: 6px 6px 14px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }

.msg {
  display: flex; flex-direction: column; gap: 4px;
  max-width: 78%;
  animation: msgIn .25s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg .meta {
  font-size: 11px; color: var(--ink-low);
  display: flex; gap: 8px; align-items: baseline;
  padding: 0 4px;
}
.msg .meta .name { color: var(--ink-dim); font-weight: 600; }
.msg .bubble {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  color: var(--ink);
}
.msg.self { align-self: flex-end; align-items: flex-end; }
.msg.self .meta .name { color: var(--acid); }
.msg.self .bubble {
  background: rgba(184,255,46,0.08);
  border-color: rgba(184,255,46,0.35);
  color: #f3ffd6;
}
.msg.system { align-self: center; max-width: 100%; }
.msg.system .bubble {
  background: transparent; border: 1px dashed var(--line-2);
  color: var(--ink-low); font-style: italic; font-size: 12px;
  padding: 6px 12px;
}

.empty {
  margin: auto; text-align: center; color: var(--ink-low);
  font-size: 13px; padding: 24px;
}
.empty .glyph {
  font-family: var(--display); font-weight: 800; font-size: 42px;
  color: var(--acid); text-shadow: 0 0 24px rgba(184,255,46,0.35);
  display: block; margin-bottom: 8px; letter-spacing: -0.02em;
}

/* composer */
.composer {
  display: flex; gap: 8px;
  padding: 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  margin-bottom: 10px;
}
.composer input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  padding: 8px 10px;
}
.composer input::placeholder { color: var(--ink-low); }
.composer button {
  background: var(--acid);
  color: #000;
  border: none;
  width: 44px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .12s, box-shadow .12s;
}
.composer button:hover { transform: translateY(-1px); box-shadow: var(--shadow-acid); }
.composer button:active { transform: translateY(0); }

/* footbar */
.footbar {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--ink-low);
  padding: 6px 4px 12px;
}
.footbar code {
  color: var(--acid);
  background: rgba(184,255,46,0.06);
  border: 1px solid rgba(184,255,46,0.18);
  padding: 1px 6px; border-radius: 6px;
  font-size: 11px;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-dim);
  padding: 6px 10px;
  border-radius: 8px;
  font-family: var(--mono); font-size: 11px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ghost:hover { color: var(--hot); border-color: var(--hot); }
