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

:root {
  --surface: #0a0a0f;
  --surface-2: #12121a;
  --surface-3: #1a1a25;
  --border: #2a1a2a;
  --text: #e8d8e8;
  --text-muted: #8a7a8a;
  --accent: #ff2266;
  --accent-glow: #ff0055;
  --accent-dim: #cc0044;
  --sidebar-w: 280px;
  --chat-bg: #0d0d15;
  --chat-bg-image: url('https://images.unsplash.com/photo-1509557965875-b88c97052f0e?w=1920&q=80');
  --radius: 12px;
  --scary-font: 'Nosifer', cursive;
  --creepy-font: 'Creepster', cursive;
}

html, body {
  height: 100%;
  font-family: 'SN Pro', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--surface);
  overflow: hidden;
}

body {
  display: flex;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, #0f0f18 0%, #1a0a1a 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: transform 0.3s ease;
  position: relative;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 0%, rgba(139, 0, 0, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(80, 0, 80, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.sidebar__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.sidebar__logo svg {
  display: block;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar__title {
  flex: 1;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(255, 0, 85, 0.5);
  font-family: var(--creepy-font);
  letter-spacing: 1px;
}

.sidebar__settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: all 0.3s;
  position: relative;
}

.sidebar__settings-btn:hover {
  background: rgba(255, 34, 102, 0.15);
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  animation: spookyPulse 1.5s infinite;
}

@keyframes spookyPulse {
  0%, 100% { filter: drop-shadow(0 0 8px var(--accent-glow)); }
  50% { filter: drop-shadow(0 0 15px var(--accent-glow)) brightness(1.2); }
}

.sidebar__search {
  padding: 12px 16px 8px;
}

.sidebar__search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(20, 10, 20, 0.8);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.3s;
}

.sidebar__search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(255, 34, 102, 0.3), inset 0 0 10px rgba(255, 34, 102, 0.1);
}

.sidebar__search input::placeholder {
  color: var(--text-muted);
}

.sidebar__people {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.sidebar__people::-webkit-scrollbar {
  width: 4px;
}

.sidebar__people::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-dim), #4a0020);
  border-radius: 4px;
}

.person-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  border: 1px solid transparent;
}

.person-card:hover {
  background: rgba(255, 34, 102, 0.08);
  border-color: rgba(255, 34, 102, 0.2);
}

.person-card.active {
  background: rgba(255, 34, 102, 0.12);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(255, 34, 102, 0.2), inset 0 0 20px rgba(255, 34, 102, 0.05);
}

.person-card__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #111;
  flex-shrink: 0;
  border: 2px solid rgba(255, 34, 102, 0.3);
  position: relative;
}

.person-card__avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--accent-glow), transparent);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
}

.person-card:hover .person-card__avatar::after,
.person-card.active .person-card__avatar::after {
  opacity: 0.5;
  animation: spin 3s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.person-card__info {
  flex: 1;
  min-width: 0;
}

.person-card__name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-card__status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.person-card.active .person-card__status {
  color: var(--accent);
}

.person-card__delete {
  opacity: 0;
  background: none;
  border: none;
  color: #ff4444;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}

.person-card:hover .person-card__delete {
  opacity: 1;
}

.person-card__delete:hover {
  background: rgba(255, 68, 68, 0.2);
  filter: drop-shadow(0 0 5px #ff0000);
}

.sidebar__add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 16px;
  padding: 10px 14px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.sidebar__add-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 34, 102, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s;
}

.sidebar__add-btn:hover::before {
  transform: translateX(100%);
}

.sidebar__add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 20px rgba(255, 34, 102, 0.2);
}

/* ===== Chat Area ===== */
.chat {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.chat__bg {
  position: absolute;
  inset: 0;
  background-color: var(--chat-bg);
  background-image: var(--chat-bg-image);
  background-size: cover;
  background-position: center;
  opacity: 0.4;
  pointer-events: none;
  transition: all 0.5s;
  z-index: 0;
  animation: bgPan 30s linear infinite alternate;
}

@keyframes bgPan {
  0% { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.1) translate(-1%, 1%); }
}

.chat__fog {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(100, 0, 0, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(50, 0, 50, 0.15) 0%, transparent 50%);
  pointer-events: none;
  z-index: 1;
  animation: fogDrift 10s ease-in-out infinite alternate;
}

@keyframes fogDrift {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

.chat__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.7) 100%);
  pointer-events: none;
  z-index: 1;
}

.chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 2;
  position: relative;
}

.chat__header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.chat__menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.chat__header-title {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--creepy-font);
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.chat__header-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2;
  scroll-behavior: smooth;
}

.chat__messages::-webkit-scrollbar {
  width: 5px;
}

.chat__messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-dim), #4a0020);
  border-radius: 4px;
}

/* Messages */
.msg {
  display: flex;
  gap: 10px;
  max-width: 75%;
  animation: msgIn 0.4s ease-out;
}

@keyframes msgIn {
  0% { opacity: 0; transform: translateY(20px) scale(0.95); filter: blur(3px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.msg--self {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #111;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid rgba(255, 34, 102, 0.4);
  position: relative;
}

.msg__avatar::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), transparent, var(--accent));
  opacity: 0.4;
  z-index: -1;
  animation: spin 4s linear infinite;
}

.msg__body {
  display: flex;
  flex-direction: column;
}

.msg__name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 3px;
  text-shadow: 0 0 8px var(--accent-glow);
}

.msg--self .msg__name {
  text-align: right;
}

.msg__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(26, 10, 26, 0.9);
  border: 1px solid rgba(255, 34, 102, 0.2);
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  overflow: hidden;
}

.msg__bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 34, 102, 0.05), transparent);
  pointer-events: none;
}

.msg--self .msg__bubble {
  background: linear-gradient(135deg, rgba(255, 34, 102, 0.9), rgba(180, 0, 60, 0.9));
  color: #fff;
  border: none;
  box-shadow: 0 0 20px rgba(255, 34, 102, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.msg__time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.msg--self .msg__time {
  text-align: right;
}

/* System message */
.msg-system {
  align-self: center;
  font-size: 0.78rem;
  color: var(--accent);
  padding: 6px 16px;
  background: rgba(255, 34, 102, 0.1);
  border: 1px solid rgba(255, 34, 102, 0.3);
  border-radius: 20px;
  animation: msgIn 0.4s ease-out;
  text-shadow: 0 0 8px var(--accent-glow);
  font-family: var(--creepy-font);
  letter-spacing: 0.5px;
}

/* Chat input */
.chat__input-area {
  padding: 12px 20px 16px;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.chat__input-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.chat__current-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat__current-user .mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.65rem;
  color: #111;
}

.chat__input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(20, 10, 20, 0.9);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 8px 6px 16px;
  transition: all 0.3s;
  position: relative;
}

.chat__input-wrapper::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), transparent, var(--accent));
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s;
}

.chat__input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(255, 34, 102, 0.3);
}

.chat__input-wrapper:focus-within::before {
  opacity: 0.5;
  animation: borderGlow 2s linear infinite;
}

@keyframes borderGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

.chat__input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 6px 0;
}

.chat__input-wrapper textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.chat__send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 0 15px rgba(255, 34, 102, 0.4);
}

.chat__send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 25px rgba(255, 34, 102, 0.6);
}

.chat__send-btn:active {
  transform: scale(0.95);
}

/* Empty state */
.chat__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  z-index: 2;
}

.chat__empty-icon {
  font-size: 4rem;
  opacity: 0.5;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 15px var(--accent-glow));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.chat__empty-text {
  font-size: 1.2rem;
  font-family: var(--creepy-font);
  color: var(--accent);
  text-shadow: 0 0 15px var(--accent-glow);
}

.chat__empty-hint {
  font-size: 0.82rem;
  opacity: 0.6;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: linear-gradient(180deg, #12121a 0%, #1a0a1a 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  animation: modalIn 0.3s ease-out;
  box-shadow: 0 0 50px rgba(255, 34, 102, 0.2);
}

@keyframes modalIn {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); filter: blur(5px); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal__header h3 {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--creepy-font);
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal__close:hover {
  background: rgba(255, 34, 102, 0.2);
  color: var(--accent);
}

.modal__body {
  padding: 16px 20px;
}

.modal__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 12px;
}

.modal__label:first-child {
  margin-top: 0;
}

.modal__input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(20, 10, 20, 0.8);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.3s;
}

.modal__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(255, 34, 102, 0.3);
}

.modal__input::placeholder {
  color: var(--text-muted);
}

.modal__colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal__color-opt {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.modal__color-opt:hover {
  transform: scale(1.15);
}

.modal__color-opt.selected {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
}

.modal__bg-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal__bg-opt {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.modal__bg-opt:hover {
  transform: scale(1.08);
}

.modal__bg-opt.selected {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
}

.modal__bg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.modal__bg-img-opt {
  width: 60px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: all 0.2s;
}

.modal__bg-img-opt:hover {
  transform: scale(1.05);
}

.modal__bg-img-opt.selected {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

.modal__btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.modal__btn:active {
  transform: scale(0.97);
}

.modal__btn--cancel {
  background: rgba(30, 20, 30, 0.8);
  color: var(--text-muted);
}

.modal__btn--cancel:hover {
  background: rgba(50, 30, 50, 0.8);
  color: var(--text);
}

.modal__btn--ok {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 34, 102, 0.4);
}

.modal__btn--ok:hover {
  box-shadow: 0 0 25px rgba(255, 34, 102, 0.6);
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 30px rgba(255, 34, 102, 0.3);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .chat__menu-btn {
    display: flex;
  }
  .msg {
    max-width: 90%;
  }
}

/* ===== Horror Effects ===== */
.horror-flicker {
  animation: horrorFlicker 0.1s linear infinite;
}

@keyframes horrorFlicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.95; }
  75% { opacity: 0.98; }
}

.blood-drip {
  position: absolute;
  top: 0;
  width: 3px;
  height: 0;
  background: linear-gradient(180deg, #880000, transparent);
  animation: drip 3s ease-in infinite;
}

@keyframes drip {
  0% { height: 0; opacity: 1; }
  70% { height: 30px; opacity: 1; }
  100% { height: 30px; opacity: 0; }
}

/* Custom scrollbar for horror theme */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(10, 0, 10, 0.5);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-dim), #4a0020);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent), #6a0030);
}
