:root {
  --bg-deep: #141a39;
  --bg-deep-2: #101733;
  --glow-1: #ff5f83;
  --glow-2: #3f5fff;
  --card: rgba(37, 46, 82, 0.82);
  --panel: #1a2346;
  --panel-2: #2d3554;
  --panel-3: #212b51;
  --text: #edf1ff;
  --muted: #aab6de;
  --accent: #ed4b70;
  --accent-soft: #ff6a8b;
  --border: rgba(205, 218, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% 18%, rgba(255, 95, 131, 0.18), transparent 30%),
    radial-gradient(circle at 88% 24%, rgba(63, 95, 255, 0.2), transparent 30%),
    linear-gradient(135deg, var(--bg-deep), var(--bg-deep-2));
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(5px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hidden {
  display: none !important;
}

.environmentRibbon {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 232, 176, 0.55);
  background: rgba(255, 182, 75, 0.18);
  color: #ffe9a9;
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.authScreen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.authGlow {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 999px;
  filter: blur(84px);
  opacity: 0.46;
  pointer-events: none;
}

.authGlowLeft {
  background: var(--glow-1);
  left: -130px;
  top: 160px;
}

.authGlowRight {
  background: var(--glow-2);
  right: -120px;
  top: 140px;
}

.authCard {
  width: min(440px, 92vw);
  background: linear-gradient(160deg, rgba(44, 55, 99, 0.86), rgba(29, 35, 69, 0.86));
  border: 1px solid rgba(228, 236, 255, 0.13);
  box-shadow: 0 24px 70px rgba(3, 8, 30, 0.52);
  backdrop-filter: blur(10px);
  border-radius: 26px;
  padding: 34px 34px 26px;
  position: relative;
  z-index: 2;
  animation: riseIn 0.35s ease-out;
}

.authTitle {
  text-align: center;
  margin-bottom: 24px;
}

.brandLogo {
  display: block;
  height: auto;
  width: auto;
  max-width: 100%;
}

.brandLogoAuth {
  max-width: min(180px, 54vw);
  max-height: 54px;
  margin: 0 auto;
}

.sidebarBrand {
  display: flex;
  align-items: center;
}

.sidebarTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brandLogoSidebar {
  max-width: 135px;
  max-height: 34px;
}

.iconBtn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.iconBtn:hover {
  transform: rotate(12deg);
  filter: none;
}

.iconBtn.active {
  background: rgba(237, 75, 112, 0.2);
  border-color: rgba(237, 75, 112, 0.55);
}

.authTabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}

.authTab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 6px 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.authTab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.authForm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.authForm label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.authForm input {
  width: 100%;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.authForm input:focus {
  border-color: rgba(237, 75, 112, 0.8);
  box-shadow: 0 0 0 2px rgba(237, 75, 112, 0.2);
}

.authActionBtn {
  margin-top: 12px;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.15s ease;
}

.authActionBtn:hover {
  filter: brightness(1.05);
}

.authActionBtn:active {
  transform: translateY(1px);
}

.authStatus {
  min-height: 24px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.authStatus[data-type="error"] {
  color: #ff9fb4;
}

#appScreen {
  height: 100vh;
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(15, 24, 54, 0.74);
  backdrop-filter: blur(6px);
  min-height: 0;
  overflow-y: auto;
}

h1 {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: 30px;
  letter-spacing: 0.03em;
}

.card {
  background: color-mix(in srgb, var(--panel) 90%, black 10%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: riseIn 0.32s ease-out both;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-1px);
  border-color: rgba(237, 75, 112, 0.33);
}

.profileName {
  font-weight: 800;
}

.profileIdentity {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.profileInfo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profileCard {
  gap: 12px;
}

.avatarBadge {
  position: relative;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--panel-2) 88%, black 12%);
  border: 1px solid var(--border);
  color: var(--text);
  flex: 0 0 auto;
}

.avatarFallback {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.avatarImage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatarLg {
  width: 56px;
  height: 56px;
}

.avatarXl {
  width: 74px;
  height: 74px;
}

.avatarMd {
  width: 34px;
  height: 34px;
}

.avatarSm {
  width: 28px;
  height: 28px;
}

.avatarXs {
  width: 22px;
  height: 22px;
}

.avatarEditable {
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(237, 75, 112, 0.22);
  transition: box-shadow 0.2s ease;
}

.avatarEditable:hover {
  box-shadow: 0 0 0 3px rgba(237, 75, 112, 0.22);
}

.avatarTools {
  position: absolute;
  inset: auto 6px 6px auto;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.avatarEditable:hover .avatarTools,
.avatarEditable:focus-within .avatarTools {
  opacity: 1;
  transform: translateY(0);
}

.avatarToolBtn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(16, 23, 51, 0.92);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.avatarToolBtn.danger {
  width: 24px;
  height: 24px;
  font-size: 12px;
  background: rgba(237, 75, 112, 0.88);
  border-color: rgba(255, 255, 255, 0.24);
}

label {
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

input:focus {
  border-color: rgba(237, 75, 112, 0.75);
  box-shadow: 0 0 0 2px rgba(237, 75, 112, 0.18);
}

button {
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.2s ease;
}

button:hover {
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.58;
  cursor: default;
}

.secondary {
  background: var(--panel-3);
  color: var(--text);
}

.quickActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.inlineActions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.searchRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.userResult,
.memberPill,
.inviteRow {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 8px 10px;
}

.userResult,
.memberPill {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.userResultLeft {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.userText {
  min-width: 0;
}

.userResultName {
  font-weight: 700;
}

#groupCard {
  display: none;
}

.showGroupBuilder #groupCard {
  display: flex;
}

.inviteRow {
  display: grid;
  gap: 8px;
}

.inviteActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

small,
.meta,
#appStatus {
  color: var(--muted);
}

#appStatus[data-type="error"] {
  color: #ff9fb4;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow: auto;
}

.chatItem {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatItem:hover {
  transform: translateY(-1px);
}

.chatItem.active {
  border-color: var(--accent);
}

.chatItem.unread {
  box-shadow: inset 0 0 0 1px rgba(237, 75, 112, 0.5);
}

.chatTitleLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chatTitleWrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatTitleWrap .chatTitleLine {
  flex: 1 1 auto;
}

.chatUnreadBadge {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chatHeader {
  border-bottom: 1px solid var(--border);
  padding: 18px;
  background: rgba(15, 24, 54, 0.36);
}

.chatHeader h2 {
  margin: 0;
  font-size: 20px;
}

.chatTypingHint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.messages {
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 72%;
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  animation: bubbleIn 0.2s ease-out;
}

.bubble.me {
  align-self: flex-end;
  background: rgba(237, 75, 112, 0.2);
  border-color: rgba(237, 75, 112, 0.55);
}

.bubbleHead {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bubbleSender {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.meta {
  margin-top: 4px;
  font-size: 12px;
}

.bubble .meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.messageTime {
  display: inline-block;
}

.messageStatus {
  min-width: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: #b8c2e8;
}

.messageStatus[data-status="pending"] {
  color: #aeb6d6;
}

.messageStatus[data-status="sent"] {
  color: #aeb6d6;
}

.messageStatus[data-status="delivered"] {
  color: #aeb6d6;
}

.messageStatus[data-status="read"] {
  color: #63b3ff;
}

.messageStatus[data-status="failed"] {
  color: #ff5f83;
  font-weight: 800;
}

.messageStatus.clickable {
  cursor: pointer;
}

.chatInput {
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: rgba(15, 24, 54, 0.36);
}

.toastContainer {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(360px, 92vw);
  border: 1px solid rgba(237, 75, 112, 0.45);
  background: rgba(20, 28, 56, 0.94);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 10px 28px rgba(5, 9, 26, 0.42);
  backdrop-filter: blur(6px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hide {
  opacity: 0;
  transform: translateY(6px);
}

.toastTitle {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
}

.toastBody {
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    height: 100vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 48vh;
  }

  .messages {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .authCard {
    padding: 28px 20px 22px;
    border-radius: 20px;
  }

  .authTitle {
    margin-bottom: 18px;
  }

  .brandLogoAuth {
    max-height: 45px;
  }

  .chatInput {
    grid-template-columns: 1fr;
  }

  .searchRow,
  .inlineActions,
  .quickActions,
  .inviteActions {
    grid-template-columns: 1fr;
  }
}
