*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --glass-bg:       rgba(255, 255, 255, 0.07);
  --glass-border:   rgba(255, 255, 255, 0.13);
  --glass-shine:    rgba(255, 255, 255, 0.2);
  --bubble-me-bg:   rgba(56, 139, 253, 0.3);
  --bubble-me-bd:   rgba(56, 139, 253, 0.45);
  --bubble-him-bg:  rgba(255, 255, 255, 0.08);
  --bubble-him-bd:  rgba(255, 255, 255, 0.13);
  --text:           rgba(255, 255, 255, 0.95);
  --text-muted:     rgba(255, 255, 255, 0.42);
  --accent:         #3b8bfd;
  --green:          #4ade80;
  --radius:         20px;
  --header-h:       70px;
  font-size: 16px;
}

body {
  background: #07090f;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

/* ── AURORA ──────────────────────────────────────────────── */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.aurora-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
}
.aurora-blob:nth-child(1) {
  width: 65vw; height: 65vw;
  background: radial-gradient(circle, #1a4fd6 0%, transparent 70%);
  top: -20%; left: -15%;
  opacity: 0.55;
  animation: drift-a 22s ease-in-out infinite;
}
.aurora-blob:nth-child(2) {
  width: 55vw; height: 55vw;
  background: radial-gradient(circle, #6d28d9 0%, transparent 70%);
  bottom: 5%; right: -10%;
  opacity: 0.5;
  animation: drift-b 28s ease-in-out infinite;
}
.aurora-blob:nth-child(3) {
  width: 45vw; height: 45vw;
  background: radial-gradient(circle, #0e7490 0%, transparent 70%);
  bottom: -10%; left: 20%;
  opacity: 0.45;
  animation: drift-c 19s ease-in-out infinite;
}
.aurora-blob:nth-child(4) {
  width: 35vw; height: 35vw;
  background: radial-gradient(circle, #9d174d 0%, transparent 70%);
  top: 35%; right: 10%;
  opacity: 0.3;
  animation: drift-a 24s ease-in-out infinite reverse;
}

@keyframes drift-a {
  0%,100% { transform: translate(0,0) scale(1); }
  25%     { transform: translate(4vw,-3vh) scale(1.06); }
  50%     { transform: translate(-2vw,4vh) scale(0.96); }
  75%     { transform: translate(2vw,2vh) scale(1.02); }
}
@keyframes drift-b {
  0%,100% { transform: translate(0,0) scale(1); }
  33%     { transform: translate(-5vw,2vh) scale(1.08); }
  66%     { transform: translate(3vw,-4vh) scale(0.94); }
}
@keyframes drift-c {
  0%,100% { transform: translate(0,0) scale(1); }
  40%     { transform: translate(3vw,-5vh) scale(1.1); }
  80%     { transform: translate(-4vw,1vh) scale(0.92); }
}

/* ── PIN SCREEN ─────────────────────────────────────────── */
.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 320px;
  padding: 48px 32px 40px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(48px) saturate(200%);
  -webkit-backdrop-filter: blur(48px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 36px;
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04),
    inset 1px 0 0 rgba(255, 255, 255, 0.06),
    0 28px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

/* lens flare shimmer */
.pin-box::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 36px;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.1) 0%,
    rgba(255,255,255,0.03) 40%,
    transparent 60%
  );
  pointer-events: none;
}

.pin-avatar {
  position: relative;
  width: 90px;
  height: 90px;
  margin-bottom: 2px;
}
.pin-avatar img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.2),
    0 0 0 4px rgba(56,139,253,0.2),
    0 8px 24px rgba(0,0,0,0.4);
}

.pin-box h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #fff;
}
.pin-subtitle {
  color: var(--text-muted);
  font-size: 0.83rem;
  letter-spacing: 0.01em;
  text-align: center;
}

.pin-box input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  outline: none;
  margin-top: 6px;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.pin-box input:focus {
  border-color: rgba(56, 139, 253, 0.55);
  background: rgba(56, 139, 253, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 0 3px rgba(56, 139, 253, 0.15);
}
.pin-box input::placeholder { color: rgba(255,255,255,0.18); letter-spacing: 0.1em; font-size: 1rem; }

.pin-box button {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(56, 139, 253, 0.4);
  border-top-color: rgba(255,255,255,0.25);
  background: rgba(56, 139, 253, 0.25);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 4px 20px rgba(56, 139, 253, 0.22);
  letter-spacing: 0.01em;
}
.pin-box button:hover {
  background: rgba(56, 139, 253, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.24),
    0 8px 28px rgba(56, 139, 253, 0.38);
  transform: translateY(-1px);
}
.pin-box button:active { transform: translateY(0) scale(0.98); }

.pin-error {
  color: rgba(255, 100, 100, 0.9);
  font-size: 0.82rem;
  text-align: center;
}

/* ── APP ─────────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  height: 100dvh;
}

/* ── HEADER ─────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  gap: 13px;
  height: var(--header-h);
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,0.09);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 4px 32px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.header-avatar {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}
.header-avatar img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.18);
}


.header-info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.header-name   { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.header-status { font-size: 0.74rem; color: var(--green); letter-spacing: 0.01em; }

.logout-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(12px);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.logout-btn:hover {
  background: rgba(255,80,80,0.15);
  border-color: rgba(255,80,80,0.3);
  color: rgba(255,120,120,0.9);
}

/* ── MESSAGES ─────────────────────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  min-height: 0;
}
.messages::-webkit-scrollbar { width: 0; }

.date-divider {
  align-self: center;
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 10px 0 4px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
}

/* Bubble wrapper */
.bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 84%;
  animation: bubble-in 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bubble-wrap.from-me  { align-self: flex-end;   flex-direction: row-reverse; }
.bubble-wrap.from-him { align-self: flex-start; }

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12);
}
.bubble-avatar-fallback {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(56,139,253,0.35);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bubble {
  padding: 10px 14px;
  border-radius: 20px;
  line-height: 1.58;
  font-size: 0.94rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.from-me .bubble {
  background: var(--bubble-me-bg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--bubble-me-bd);
  border-top-color: rgba(255,255,255,0.2);
  border-bottom-right-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 4px 20px rgba(56,139,253,0.2);
  color: #fff;
}

.from-him .bubble {
  background: var(--bubble-him-bg);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--bubble-him-bd);
  border-top-color: rgba(255,255,255,0.2);
  border-bottom-left-radius: 5px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.13),
    0 4px 20px rgba(0,0,0,0.18);
  color: var(--text);
}

.bubble-time {
  font-size: 0.67rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: block;
  text-align: right;
}
.from-him .bubble-time { text-align: left; }

/* ── TYPING ─────────────────────────────────────────────── */
.typing-wrap { align-self: flex-start; display: flex; align-items: flex-end; gap: 8px; }
.typing-bubble {
  background: var(--bubble-him-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--bubble-him-bd);
  border-top-color: rgba(255,255,255,0.2);
  border-radius: 20px;
  border-bottom-left-radius: 5px;
  padding: 13px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.typing-bubble span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  animation: bounce 1.3s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.45; }
  30%         { transform: translateY(-6px); opacity: 1; }
}

/* ── INPUT BAR ────────────────────────────────────────────── */
.input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-top: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 -4px 28px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.msg-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-top-color: rgba(255,255,255,0.16);
  border-radius: 22px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px);
  color: #fff;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.msg-input:focus {
  border-color: rgba(56,139,253,0.4);
  background: rgba(255,255,255,0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 0 3px rgba(56,139,253,0.1);
}
.msg-input::placeholder { color: rgba(255,255,255,0.28); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(56,139,253,0.4);
  border-top-color: rgba(255,255,255,0.25);
  background: rgba(56,139,253,0.28);
  backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 4px 18px rgba(56,139,253,0.25);
}
.send-btn:hover {
  background: rgba(56,139,253,0.46);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.26),
    0 6px 24px rgba(56,139,253,0.42);
  transform: scale(1.06);
}
.send-btn:active  { transform: scale(0.94); }
.send-btn:disabled {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.07);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.avatar-fallback {
  width: 100%; height: 100%;
  background: rgba(56,139,253,0.35);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

/* ── WELCOME ─────────────────────────────────────────────── */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px;
  gap: 14px;
}
.welcome-greeting {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.15;
}
.welcome-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.9;
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .bubble-wrap { max-width: 90%; }
  .bubble { font-size: 0.9rem; }
  .pin-box { width: calc(100% - 48px); }
}
