:root {
  --bg1: #f1f4ff;
  --bg2: #e3e9ff;
  --panel: #ffffff;
  --panel-2: #f5f7ff;
  --text: #1c2230;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-2: #1e40af;
  --shadow: rgba(15, 23, 42, 0.2);
  --border: rgba(15, 23, 42, 0.15);
}

.darkmode {
  --bg1: #05070f;
  --bg2: #0b1024;
  --panel: #141a2f;
  --panel-2: #1b223b;
  --text: #f5f7ff;
  --muted: #9aa3b2;
  --accent: #4c6fff;
  --accent-2: #2f49d1;
  --shadow: rgba(0, 0, 0, 0.4);
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg2), var(--bg1));
  color: var(--text);
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
}

.appShell {
  display: grid;
  grid-template-columns: 64px 220px 1fr;
  height: 100vh;
}

.serverBar {
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  gap: 10px;
}

.serverBrand {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.serverBrand img {
  width: 26px;
  height: 26px;
}

.serverList {
  display: grid;
  gap: 10px;
  width: 100%;
  justify-items: center;
}

.serverItem {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  display: grid;
  place-items: center;
  text-decoration: none;
  border: 1px solid var(--border);
}

.serverItem.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.serverAdd {
  margin-top: auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.channelBar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

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

.serverActions {
  display: flex;
  gap: 6px;
}

.serverTitle {
  font-weight: 700;
}

.serverActions {
  display: flex;
  gap: 10px;
}

/* Header spacing fix */
.serverHeader {
  gap: 10px;
  flex-wrap: wrap;
}

.serverTitle {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.serverActions {
  flex: 0 0 auto;
}

.inviteBtn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  margin-left: 4px;
}

.channelList {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.channelItem {
  text-decoration: none;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
}

.channelItem.active,
.channelItem:hover {
  background: var(--panel-2);
}

.chatMain {
  display: flex;
  flex-direction: column;
  padding: 16px;
  height: 100%;
  gap: 10px;
  min-height: 0;
}

.chatHeader h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.devBadge {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 700;
}

.hidden {
  display: none;
}

.chatHeader h2 {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}

.chatHeader {
  flex: 0 0 auto;
}

.voiceBar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.voiceBtn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.voiceBtn.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.voiceStatus {
  font-size: 12px;
  color: var(--muted);
}

.chatShell {
  width: min(760px, 90%);
  margin: 80px auto 40px;
  text-align: center;
}

h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 700;
}

h2 {
  margin: 0 0 24px;
  font-size: 18px;
  color: var(--muted);
  font-weight: 600;
}

#chatWindow {
  flex: 1 1 auto;
  min-height: 200px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  overflow-y: auto;
  box-shadow: 0 10px 30px var(--shadow);
  text-align: left;
}

.chatBubble {
  background-color: var(--panel-2);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
  max-width: 80%;
  word-wrap: break-word;
}

.darkmode .chatBubble {
  background-color: #2a2f45;
}

.username {
  font-weight: 700;
  margin-bottom: 4px;
}

.username.clickable {
  cursor: pointer;
}

.username.clickable:hover {
  text-decoration: underline;
}

.username.dev {
  color: #ff4d4d;
}

.username.normie {
  color: var(--muted);
}

.messageText {
  font-size: 14px;
  color: var(--text);
}

.messageMedia {
  margin-top: 8px;
  max-width: 100%;
  max-height: 240px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.mediaModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 1400;
}

.mediaModal.hidden {
  display: none;
}

.mediaContent img,
.mediaContent video {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 12px;
  background: #000;
}

.mediaClose {
  position: fixed;
  top: 16px;
  right: 16px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
}

.messageMediaLink {
  margin-top: 8px;
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
}

#inputBar {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin: 0;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 6px 18px var(--shadow);
}

.mediaButton {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.mediaButton:hover {
  background: var(--panel);
}

.mediaName {
  font-size: 12px;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  resize: none;
  padding: 6px;
  max-height: 140px;
}

#sendButton {
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: 0.2s;
}

#sendButton:hover {
  background: var(--accent-2);
}

.topButtons {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 1000;
}

.topButton {
  height: 46px;
  width: 46px;
  border-radius: 50%;
  background-color: var(--panel);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px var(--shadow);
  transition: 0.2s;
}

.topButton:hover {
  background-color: var(--panel-2);
}

.topButton svg,
.topButton .material-symbols-outlined {
  font-size: 22px;
  color: var(--text);
}

.topButton .icon-sun {
  display: none;
}

.darkmode .topButton .icon-moon {
  display: none;
}

.darkmode .topButton .icon-sun {
  display: inline;
}

.darkmode .topButton svg,
.darkmode .topButton .material-symbols-outlined {
  color: #ffffff;
}

.friendsActions {
  margin-bottom: 16px;
}

.friendAdd {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.friendAdd input {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  min-width: 220px;
}

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

.actionButton {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.actionButton:hover {
  background: var(--panel-2);
}

.friendList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.friendItem {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.friendItem:hover {
  transform: translateY(-1px);
  background: var(--panel-2);
}

.friendItem.requestItem {
  cursor: default;
}

.friendName {
  cursor: pointer;
}

.requestActions {
  display: flex;
  gap: 6px;
}

.pendingTag {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
}

.actionButton.small {
  padding: 6px 10px;
  font-size: 12px;
}

.friendEmpty {
  color: var(--muted);
  padding: 12px;
}

.notifStack {
  position: fixed;
  right: 20px;
  bottom: 90px;
  display: grid;
  gap: 10px;
  z-index: 1000;
  max-width: 260px;
}

.notifCard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 8px 20px var(--shadow);
  font-size: 13px;
}

.notifCard strong {
  display: block;
  margin-bottom: 4px;
}

.notifCard.fade {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.profileModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  z-index: 1200;
}

.profileModal.hidden {
  display: none;
}

.profileCard {
  width: min(320px, 86vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 32px var(--shadow);
}

.profileHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.profileHeader h3 {
  margin: 0;
}

.profileClose {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.profileMeta {
  color: var(--muted);
  margin: 0 0 8px;
}

.profileAbout {
  margin: 0;
  font-size: 14px;
}

.devTestBtn {
  position: fixed;
  left: 90px;
  bottom: 20px;
  z-index: 1100;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--shadow);
}

.devPopup {
  position: fixed;
  left: 90px;
  bottom: 70px;
  z-index: 1101;
  width: min(280px, 80vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 24px var(--shadow);
  padding: 10px 12px;
}

.devPopup.hidden {
  display: none;
}

.devPopupHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  margin-bottom: 6px;
}

.devPopupClose {
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

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

.devPopupAction {
  margin-top: 10px;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.devPopupAction:hover {
  background: var(--panel);
}

.devPopupAction.danger {
  border-color: rgba(239, 68, 68, 0.6);
  color: #ef4444;
}

.loginShell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginCard {
  width: min(420px, 92vw);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 14px 40px var(--shadow);
}

.loginBrand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.loginBrand h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: 0.2px;
}

.loginBrand p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.loginForm {
  display: grid;
  gap: 10px;
}

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

.loginInput {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
}

textarea.loginInput {
  resize: vertical;
  min-height: 88px;
}

.loginInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.loginButton {
  margin-top: 6px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.loginButton:hover {
  background: var(--accent-2);
}

.loginActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.loginButton.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.loginButton.ghost:hover {
  background: var(--panel-2);
}
