/* ==========================================================================
   AYChat design language — aurora glass
   Palette: deep space navy base, cyan → violet → magenta aurora accents.
   ========================================================================== */

:root {
  --ay-void: #05060b;
  --ay-abyss: #0b0d17;
  --ay-cyan: #22d3ee;
  --ay-violet: #8b5cf6;
  --ay-magenta: #ec4899;
  --radius-lg: 24px;
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  background: var(--ay-abyss);
  color: #e8eaf2;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  overflow-x: hidden;
}

body.amoled {
  background: #000;
  --ay-abyss: #000;
}

#aurora {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- surfaces */

.glass {
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.028));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 22px 48px -22px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.ay-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: conic-gradient(from 210deg, var(--ay-cyan), var(--ay-violet), var(--ay-magenta), var(--ay-cyan));
  box-shadow: 0 0 22px -4px rgba(139, 92, 246, 0.75);
  position: relative;
  flex-shrink: 0;
}

.ay-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 6px;
  background: var(--ay-abyss);
}

/* ------------------------------------------------------------------ panes */

.pane {
  min-width: 0;
}

@media (max-width: 767px) {
  .pane {
    display: none;
  }
  .pane.pane-active {
    display: flex;
  }
}

/* ---------------------------------------------------------------- controls */

.tab,
.chip,
.filter {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 14px;
  transition: all 0.22s var(--ease-emphasized);
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover,
.chip:hover,
.filter:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.filter {
  padding: 5px 12px;
  font-size: 11px;
}

.tab-active,
.filter-active {
  color: #fff;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(139, 92, 246, 0.28));
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 6px 18px -8px rgba(139, 92, 246, 0.9);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  color: rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: all 0.2s var(--ease-emphasized);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.94);
}

.send-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--ay-cyan), var(--ay-violet));
  box-shadow: 0 10px 26px -10px rgba(139, 92, 246, 0.95);
  transition: transform 0.18s var(--ease-emphasized), filter 0.18s;
  cursor: pointer;
  border: none;
}

.send-btn svg {
  width: 19px;
  height: 19px;
}

.send-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px) scale(1.03);
}

.send-btn:active {
  transform: scale(0.92);
}

/* ---------------------------------------------------------------- avatars */

.avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  background: linear-gradient(140deg, var(--g1, #22d3ee), var(--g2, #8b5cf6));
  flex-shrink: 0;
}

.avatar-xs { width: 26px; height: 26px; font-size: 9px; }
.avatar-sm { width: 40px; height: 40px; font-size: 12px; }
.avatar-md { width: 42px; height: 42px; font-size: 13px; }

/* ------------------------------------------------------------- chat rows */

.chat-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border-radius: 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s var(--ease-emphasized), border-color 0.2s, transform 0.2s;
}

.chat-row:hover {
  background: rgba(255, 255, 255, 0.055);
  transform: translateX(2px);
}

.chat-row.active {
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.14), rgba(139, 92, 246, 0.16));
  border-color: rgba(139, 92, 246, 0.35);
}

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--ay-violet), var(--ay-magenta));
  box-shadow: 0 4px 12px -4px rgba(236, 72, 153, 0.9);
}

.presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--ay-abyss);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* -------------------------------------------------------------- messages */

.msg-row {
  display: flex;
  animation: rise 0.34s var(--ease-emphasized) both;
}

.msg-row.out { justify-content: flex-end; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.bubble {
  max-width: min(78%, 460px);
  padding: 9px 13px;
  border-radius: 20px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.bubble.in {
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 7px;
  color: #eceef6;
}

.bubble.out {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.92), rgba(139, 92, 246, 0.95));
  border-bottom-right-radius: 7px;
  color: #fff;
  box-shadow: 0 10px 26px -14px rgba(139, 92, 246, 1);
}

.meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.62;
  justify-content: flex-end;
}

.tick { width: 13px; height: 13px; }
.tick.read { color: #67e8f9; opacity: 1; }

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 0.16s var(--ease-emphasized);
}

.reaction-pill:hover { transform: scale(1.09); }

.day-sep {
  text-align: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 10px 0 4px;
}

.typing i {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 2px;
  border-radius: 50%;
  background: currentColor;
  animation: bounce 1.3s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }

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

/* ------------------------------------------------------------------ call */

.call-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.call-tile.speaking {
  outline: 2px solid rgba(34, 211, 238, 0.85);
  outline-offset: -2px;
  animation: glow 1.6s ease-in-out infinite;
}

@keyframes glow {
  50% { box-shadow: 0 0 22px -4px rgba(34, 211, 238, 0.85); }
}

.call-tile .tag {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.45);
  border-radius: 7px;
  padding: 2px 5px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s var(--ease-emphasized);
  cursor: pointer;
}

.call-btn svg { width: 18px; height: 18px; }
.call-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.call-btn:active { transform: scale(0.9); }

.call-btn[aria-pressed="true"] {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.5);
  color: #67e8f9;
}

.call-end {
  background: linear-gradient(135deg, #f43f5e, #ef4444);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px -10px rgba(244, 63, 94, 1);
}

.call-end:hover { background: linear-gradient(135deg, #fb7185, #f43f5e); color: #fff; }

/* ----------------------------------------------------------------- music */

.album-art {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: conic-gradient(from 140deg, var(--ay-magenta), var(--ay-violet), var(--ay-cyan), var(--ay-magenta));
  box-shadow: 0 12px 28px -12px rgba(236, 72, 153, 0.9);
  overflow: hidden;
}

.album-art.spinning { animation: spin 9s linear infinite; }

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

.album-glyph {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.progress {
  position: relative;
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 35%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ay-cyan), var(--ay-magenta));
  transition: width 0.25s linear;
}

.music-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.18s var(--ease-emphasized);
}

.music-btn svg { width: 17px; height: 17px; }
.music-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.play-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--ay-violet), var(--ay-magenta));
  box-shadow: 0 10px 26px -10px rgba(236, 72, 153, 1);
  transition: transform 0.18s var(--ease-emphasized), filter 0.18s;
}

.play-btn svg { width: 20px; height: 20px; }
.play-btn:hover { filter: brightness(1.12); transform: scale(1.05); }
.play-btn:active { transform: scale(0.93); }

.lyric-line {
  font-size: 12px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.3);
  transition: color 0.3s, transform 0.3s var(--ease-emphasized);
}

.lyric-line.current {
  color: #fff;
  font-weight: 600;
  transform: translateX(3px);
}

/* --------------------------------------------------------------- stories */

.story {
  flex-shrink: 0;
  width: 60px;
  text-align: center;
  cursor: pointer;
}

.story-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(from 180deg, var(--ay-cyan), var(--ay-violet), var(--ay-magenta), var(--ay-cyan));
  transition: transform 0.24s var(--ease-emphasized);
}

.story:hover .story-ring { transform: scale(1.07); }
.story.seen .story-ring { background: rgba(255, 255, 255, 0.16); }

.story-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--ay-abyss);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--g1, #22d3ee), var(--g2, #8b5cf6));
}

.story-name {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* -------------------------------------------------------------- utilities */

.ay-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.ay-scroll::-webkit-scrollbar-track { background: transparent; }
.ay-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
.ay-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

:focus-visible {
  outline: 2px solid var(--ay-cyan);
  outline-offset: 2px;
  border-radius: 8px;
}

.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;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
