﻿:root {
  --bg-start: #05070c;
  --bg-end: #0e1118;
  --panel: rgba(28, 32, 43, 0.74);
  --panel-strong: rgba(24, 28, 38, 0.9);
  --line: rgba(148, 163, 184, 0.16);
  --text: #f3f4f6;
  --muted: #9aa4b2;
  --accent: #0a84ff;
  --accent-dark: #0066d6;
  --bubble-self: #0a84ff;
  --bubble-other: #2a2f3b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: linear-gradient(155deg, var(--bg-start), var(--bg-end));
}

body {
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
}

.bg-glow {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(58px);
  opacity: 0.28;
}

.bg-glow-one {
  width: 340px;
  height: 340px;
  background: #1e293b;
  top: -110px;
  left: -90px;
}

.bg-glow-two {
  width: 360px;
  height: 360px;
  background: #1e3a8a;
  right: -110px;
  bottom: -120px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(880px, 100%);
  height: min(92vh, 760px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 16px;
  border-radius: 30px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: var(--panel);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow:
    0 26px 46px rgba(2, 6, 23, 0.58),
    inset 0 1px 0 rgba(148, 163, 184, 0.16);
  transition: filter 180ms ease, opacity 180ms ease;
}

body.privacy-locked .app-shell {
  filter: blur(10px);
  opacity: 0.78;
  pointer-events: none;
  user-select: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  color: #bfdbfe;
  background: rgba(10, 132, 255, 0.14);
  border: 1px solid rgba(10, 132, 255, 0.3);
}

#online-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #32d74b;
}

#logout-btn {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
}

#logout-btn svg {
  width: 18px;
  height: 18px;
}

.messages {
  overflow-y: auto;
  padding: 14px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 80%;
  width: fit-content;
  display: grid;
  gap: 4px;
  align-self: flex-start;
  animation: pop-in 180ms ease-out;
}

.message.self {
  align-self: flex-end;
}

.message .meta {
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.message .bubble {
  padding: 10px 13px;
  border-radius: 18px;
  line-height: 1.32;
  font-size: 0.96rem;
  word-break: break-word;
}

.message.self .bubble {
  background: linear-gradient(160deg, var(--bubble-self), var(--accent-dark));
  color: #eff6ff;
  border-bottom-right-radius: 7px;
}

.message.other .bubble {
  background: var(--bubble-other);
  color: #f3f4f6;
  border-bottom-left-radius: 7px;
}

.system {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.composer {
  display: flex;
  gap: 10px;
  align-items: center;
}

.composer input,
.modal-card input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: #131722;
}

.composer input::placeholder,
.modal-card input::placeholder {
  color: #748091;
}

.composer input:focus,
.modal-card input:focus {
  outline: 2px solid rgba(10, 132, 255, 0.24);
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 14px;
  padding: 0 16px;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  color: #f8fafc;
  background: linear-gradient(165deg, var(--accent), var(--accent-dark));
  box-shadow: 0 8px 20px rgba(10, 132, 255, 0.28);
  cursor: pointer;
}

.icon-btn {
  position: relative;
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  display: block;
  width: 19px;
  height: 19px;
}

.icon-btn.is-loading svg {
  opacity: 0.4;
}

.icon-btn.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  position: absolute;
  animation: spin 0.8s linear infinite;
}

.ghost-btn {
  color: #dbeafe;
  background: rgba(148, 163, 184, 0.16);
  box-shadow: none;
}

.ghost-btn:hover {
  background: rgba(148, 163, 184, 0.24);
}

button:active {
  transform: translateY(1px);
}

.join-actions {
  display: flex;
  gap: 8px;
}

.join-actions button {
  flex: 1;
}

.secondary-btn {
  background: rgba(148, 163, 184, 0.2);
  box-shadow: none;
  color: #dbeafe;
}

.secondary-btn.active {
  background: rgba(10, 132, 255, 0.24);
  border: 1px solid rgba(10, 132, 255, 0.42);
}

.file-bubble {
  display: grid;
  gap: 8px;
}

.chat-image {
  width: min(280px, 100%);
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  cursor: zoom-in;
}

.file-link {
  color: #bfdbfe;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(2, 6, 23, 0.82);
  display: grid;
  place-items: center;
  padding: 22px;
}

.lightbox-image {
  max-width: min(1100px, 94vw);
  max-height: 88vh;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 24px 56px rgba(2, 6, 23, 0.8);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.72);
  color: #e5e7eb;
  font-size: 1.55rem;
  line-height: 1;
  box-shadow: none;
}

.modal-wrap {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.6);
  z-index: 5;
}

.modal-card {
  width: min(420px, calc(100% - 32px));
  border-radius: 22px;
  padding: 22px;
  display: grid;
  gap: 10px;
  background: rgba(24, 28, 38, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 20px 45px rgba(2, 6, 23, 0.62);
}

.modal-card h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

#join-error {
  color: #fca5a5;
  min-height: 1em;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  body {
    padding: 6px;
  }

  .app-shell {
    width: 100%;
    height: 97vh;
    border-radius: 26px;
    padding: 12px;
  }

  .topbar {
    padding: 2px;
  }

  .message {
    max-width: 90%;
  }

  .composer {
    gap: 8px;
  }

  button {
    min-height: 42px;
    padding: 0 14px;
  }
}
