:root {
  --bg: #05080a;
  --text: #e6fff4;
  --muted: #5f8f78;
  --pink: #00ff9c;
  --violet: #22d3ee;
  --surface: #0b1218;
  --border: rgba(255,255,255,0.08);
  --font-display: ui-monospace, 'Cascadia Code', Consolas, monospace;
  --font-body: ui-monospace, 'Cascadia Code', Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); height: 100%; overflow: hidden;
}

/* ---- Entry ---- */
#chatEntry {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; overflow-y: auto;
}
.ce-box {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid rgba(34,211,238,0.25);
  border-radius: 18px; padding: 2rem 2rem 1.75rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  box-shadow: 0 0 60px rgba(34,211,238,0.07);
  position: relative;
}
.ce-back {
  position: absolute; top: 1.1rem; left: 1.25rem;
  color: var(--muted); text-decoration: none; font-size: 0.82rem;
  transition: color 0.2s;
}
.ce-back:hover { color: var(--text); }
.ce-logo { font-size: 2rem; text-align: center; margin-top: 0.5rem; }
.ce-box h1 {
  font-family: var(--font-display); font-weight: 900; font-size: 1.7rem;
  text-align: center;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.ce-sub {
  font-size: 0.78rem; color: var(--muted); text-align: center; line-height: 1.5;
}

.ce-room-row {
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.6rem 0.9rem;
}
.ce-hash { color: var(--violet); font-weight: 700; font-size: 1rem; }
.ce-room-name { font-weight: 600; font-size: 0.95rem; flex: 1; }
.ce-change {
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 600;
  color: var(--muted); background: none; border: 1px solid var(--border);
  border-radius: 999px; padding: 0.2rem 0.65rem; cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.ce-change:hover { color: var(--pink); border-color: rgba(0,255,156,0.4); }

.ce-field { display: flex; flex-direction: column; gap: 0.35rem; }
.ce-field label {
  font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em;
}
.ce-opt { font-weight: 400; font-size: 0.73rem; color: rgba(198,179,230,0.6); }
.ce-field input {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.65rem 0.9rem;
  color: var(--text); font-family: var(--font-body); font-size: 0.92rem;
  outline: none; transition: border-color 0.2s;
  width: 100%;
}
.ce-field input:focus { border-color: rgba(34,211,238,0.5); }
.ce-field input::placeholder { color: rgba(198,179,230,0.35); }

.ce-join {
  width: 100%; padding: 0.85rem;
  font-family: var(--font-display); font-weight: 900; font-size: 1rem;
  color: #fff; cursor: pointer; border: none; border-radius: 12px;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  transition: opacity 0.2s, transform 0.15s;
  margin-top: 0.2rem;
}
.ce-join:hover { opacity: 0.88; transform: translateY(-1px); }
.ce-join:active { transform: translateY(0); opacity: 1; }
.ce-join:disabled { opacity: 0.45; cursor: default; transform: none; }

.ce-badges {
  display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: center;
}
.ce-badges span {
  font-size: 0.72rem; color: var(--muted);
  background: rgba(34,211,238,0.08); border: 1px solid rgba(34,211,238,0.2);
  border-radius: 999px; padding: 0.2rem 0.65rem;
}
.ce-error {
  font-size: 0.8rem; color: #ff8080; text-align: center;
  background: rgba(255,80,80,0.08); border: 1px solid rgba(255,80,80,0.25);
  border-radius: 8px; padding: 0.6rem 0.8rem; line-height: 1.5;
}
.ce-setup-warn {
  font-size: 0.8rem; color: #ff9966; text-align: center;
  background: rgba(255,100,50,0.08); border: 1px solid rgba(255,100,50,0.2);
  border-radius: 8px; padding: 0.6rem 0.8rem; line-height: 1.5;
}

/* ---- Chat room ---- */
#chatRoom {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
}

.cr-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: rgba(6,3,11,0.9); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cr-back {
  color: var(--muted); text-decoration: none; font-size: 0.85rem;
  padding: 0.3rem 0.5rem; border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.cr-back:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.cr-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; flex: 1; }
.cr-hash { color: var(--violet); }
.cr-status { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: var(--muted); }
.cr-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #666;
  transition: background 0.4s;
}
.cr-dot.live { background: #48ff9b; box-shadow: 0 0 6px #48ff9b88; }
.cr-dot.error { background: #ff4848; }
.cr-fp {
  font-family: monospace; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.12em; color: #48ff9b;
  background: rgba(72,255,155,0.08); border: 1px solid rgba(72,255,155,0.2);
  border-radius: 999px; padding: 0.15rem 0.55rem;
  cursor: default; flex-shrink: 0;
}
.cr-fp:empty { display: none; }
.cr-hide {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 0.95rem; padding: 0.3rem 0.5rem; border-radius: 6px;
  transition: color 0.2s;
}
.cr-hide:hover { color: var(--violet); }
.cr-hide[aria-pressed="true"] { color: var(--pink); }
.cr-invite {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 0.95rem; padding: 0.3rem 0.5rem; border-radius: 6px;
  transition: color 0.2s;
}
.cr-invite:hover { color: var(--violet); }
.cr-leave {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; padding: 0.3rem 0.5rem; border-radius: 6px;
  transition: color 0.2s;
}
.cr-leave:hover { color: var(--pink); }

.cr-messages {
  flex: 1; overflow-y: auto; padding: 1rem 1rem 0.5rem;
  display: flex; flex-direction: column; gap: 0.1rem;
  scroll-behavior: smooth;
  /* Discourage casual copy/exfil of plaintext from the rendered transcript. */
  -webkit-user-select: none; -moz-user-select: none; user-select: none;
}

/* Privacy screen: blur the transcript when the window loses focus, the tab
   is hidden, or the user toggles the eye button. Frustrates background
   screenshot/screen-record/screen-share capture and shoulder-surfing. */
.cr-messages.privacy-blur {
  filter: blur(13px);
  transition: filter 0.12s ease;
  pointer-events: none;
}
.cr-messages.privacy-blur::after {
  content: "🙈 hidden";
  position: sticky; bottom: 40%;
  text-align: center; font-size: 0.8rem; color: var(--muted);
  filter: none; opacity: 0.7;
}
.cr-messages::-webkit-scrollbar { width: 4px; }
.cr-messages::-webkit-scrollbar-track { background: transparent; }
.cr-messages::-webkit-scrollbar-thumb { background: rgba(34,211,238,0.25); border-radius: 2px; }

/* Message rows */
.msg {
  display: flex; flex-direction: column;
  padding: 0.28rem 0.5rem; border-radius: 8px;
  max-width: 100%;
  animation: msgIn 0.18s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.own { align-items: flex-end; }
.msg.other { align-items: flex-start; }

.msg-meta {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.7rem; color: var(--muted); margin-bottom: 0.18rem;
}
.msg-handle { font-weight: 700; }
.msg-identicon { border-radius: 3px; flex-shrink: 0; image-rendering: pixelated; box-shadow: 0 0 0 1px var(--border); }
.msg-time { opacity: 0.55; }

.msg-bubble {
  font-size: 0.9rem; line-height: 1.55;
  padding: 0.5rem 0.85rem; border-radius: 14px;
  max-width: min(72ch, 88vw); word-break: break-word;
}
.msg.own .msg-bubble {
  background: linear-gradient(135deg, rgba(0,255,156,0.22), rgba(34,211,238,0.22));
  border: 1px solid rgba(34,211,238,0.22);
}
.msg.other .msg-bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}

/* System messages */
.msg-system {
  text-align: center; font-size: 0.73rem; color: rgba(198,179,230,0.45);
  padding: 0.5rem 0; font-style: italic;
}

/* ---- Input bar ---- */
.cr-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 0.85rem 0.9rem;
  background: rgba(6,3,11,0.9); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.cr-handle-pill {
  font-size: 0.72rem; font-weight: 700;
  padding: 0.25rem 0.7rem; border-radius: 999px;
  white-space: nowrap; flex-shrink: 0;
  border: 1px solid rgba(34,211,238,0.3);
  background: rgba(34,211,238,0.1);
  color: var(--text);
}
.cr-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 0.4rem;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 0.4rem 0 0.85rem;
  transition: border-color 0.2s;
}
.cr-input-wrap:focus-within { border-color: rgba(34,211,238,0.45); }
.cr-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-body); font-size: 0.92rem;
  padding: 0.65rem 0;
}
.cr-input::placeholder { color: rgba(198,179,230,0.3); }
.cr-send {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  border: none; border-radius: 8px; color: #fff;
  width: 34px; height: 34px; font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity 0.2s, transform 0.15s;
}
.cr-send:hover { opacity: 0.85; transform: scale(1.05); }
.cr-send:disabled { opacity: 0.3; transform: none; cursor: default; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .ce-box { padding: 1.6rem 1.25rem 1.5rem; border-radius: 14px; }
  .cr-bar { padding: 0.55rem 0.6rem 0.75rem; gap: 0.35rem; }
  .cr-handle-pill { display: none; }
}
