@font-face {
  font-family: "YekanBakh";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/YekanBakhFaNum-Regular.woff") format("woff");
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C, U+200F;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/SpaceGrotesk-400.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 600;
  src: url("assets/fonts/SpaceGrotesk-600.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 700;
  src: url("assets/fonts/SpaceGrotesk-700.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  src: url("assets/fonts/JetBrainsMono-400.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #000000;
  --panel: #07090d;
  --panel-strong: #0b0f16;
  --accent: #29bfb2;
  --accent-strong: #16e0b2;
  --muted: #6b7280;
  --text: #e2e8f0;
  --danger: #ff6b6b;
  --shadow: rgba(0, 0, 0, 0.8);
  --border: rgba(255, 255, 255, 0.06);
  --glow: rgba(41, 191, 178, 0.28);
}

body[data-theme="light"] {
  --bg: #bfc6d4;
  --panel: #d6dbe6;
  --panel-strong: #c9cfdb;
  --accent: #0ea5a0;
  --accent-strong: #0f766e;
  --muted: #556070;
  --text: #0f172a;
  --danger: #c24141;
  --shadow: rgba(15, 23, 42, 0.12);
  --border: rgba(15, 23, 42, 0.1);
  --glow: rgba(14, 165, 160, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "YekanBakh", sans-serif;
  background: radial-gradient(circle at top, #0b1018 0%, var(--bg) 62%, #000000 100%);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

body[data-theme="light"] {
  background: radial-gradient(circle at top, #e6eaf2 0%, var(--bg) 60%, #bfc6d4 100%);
}

body.lang-fa {
  font-family: "YekanBakh", "Space Grotesk", sans-serif;
  direction: rtl;
}

body.lang-fa input,
body.lang-fa textarea,
body.lang-fa select,
body.lang-fa button {
  font-family: "YekanBakh", "Space Grotesk", sans-serif;
}

input,
textarea,
select,
button {
  font-family: "Space Grotesk", "YekanBakh", sans-serif;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(120deg, rgba(51, 209, 198, 0.04) 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(255, 255, 255, 0.03) 38px 39px),
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(255, 255, 255, 0.03) 38px 39px);
  pointer-events: none;
  z-index: 0;
}

.hidden {
  display: none !important;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 260px;
  background: var(--panel-strong);
  border-right: 1px solid var(--border);
  padding: 20px;
  transform: translateX(-110%);
  transition: transform 0.3s ease;
  z-index: 20;
  overflow-y: auto;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 19;
}

.drawer-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.drawer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  margin-bottom: 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.drawer-footer {
  position: absolute;
  bottom: 0;
  margin-top: auto;
  margin-bottom: 6px;
  padding: 12px 6px 4px;
  font-size: 11px;
  color: var(--muted);
  align-items: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: rgba(12, 16, 24, 0.95);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.name-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.drawer-avatar {
  width: 70px;
  height: 70px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2ff1c8, #2f7cff);
  display: grid;
  place-items: center;
  color: #0b0f14;
  font-weight: 700;
  background-size: cover;
  background-position: center;
  border: 1px solid #16e0b2;
}

.drawer-name {
  font-size: 14px;
  font-weight: 600;
}

.drawer-id {
  font-size: 11px;
  color: var(--muted);
}

.drawer-lang {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  rgb(0 0 0 / 88%)
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.lang-toggle-btn {
  min-width: 42px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  transition: background 0.2s ease, color 0.2s ease;
}

.lang-toggle-btn.active {
  background: rgba(41, 191, 178, 0.22);
  color: var(--text);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title {
  font-weight: 700;
  font-size: 18px;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--muted);
}

.list-title.online {
  color: var(--text);
}

.list-title.connecting {
  color: var(--text);
}

.list-title.connecting::after {
  content: "...";
  display: inline-block;
  margin-left: 6px;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0% {
    width: 0;
  }
  100% {
    width: 18px;
  }
}

.drawer-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  text-align: left;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-item.active {
  background: rgba(12, 16, 24, 0.8);
  border-color: var(--border);
}

.list-panel {
  background: rgba(10, 14, 20, 0.92);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100vh);
  position: relative;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 14, 20, 0.98);
  z-index: 5;
}

.list-title {
  font-weight: 700;
  font-size: 18px;
}

.list-actions {
  display: flex;
  gap: 8px;
}

.search-box {
  padding: 12px 16px;
}

.search-box input {
  width: 100%;
  background: var(--panel-strong);
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.archived-toggle {
  margin: 0 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(12, 16, 24, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
}

.archived-count {
  background: rgba(41, 191, 178, 0.2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}


.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  padding: 6px 16px 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

.chat-item {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(12, 16, 24, 0.7);
  cursor: pointer;
  text-align: left;
  align-items: center;
}

.chat-item.active {
  border-color: var(--border);
  background: rgba(16, 22, 32, 0.9);
}

.chat-item .chat-avatar {
  width: 54px;
  height: 54px;
  border-radius: 16px;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2ff1c8, #2f7cff);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0b0f14;
  background-size: cover;
  background-position: center;
}

.chat-avatar.has-image,
.message-avatar.has-image,
.profile-avatar.has-image,
.drawer-avatar.has-image {
  color: transparent;
}

.saved-avatar {
  background: rgb(41 191 178 / 53%);
  color: var(--accent);
}

.chat-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.chat-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
}

.chat-item:hover .chat-actions,
.chat-item:focus-within .chat-actions {
  opacity: 1;
}

@media (max-width: 900px) {
  .chat-actions {
    opacity: 1;
  }
}

.chat-action-btn {
  border: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.4);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 10px;
  font-size: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.chat-action-btn svg {
  width: 14px;
  height: 14px;
}

.chat-item.pinned {
  border-color: rgba(41, 191, 178, 0.4);
}

.chat-item.archived {
  opacity: 0.6;
}

.chat-title-text {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.chat-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  flex: 1;
}

.chat-time {
  font-size: 11px;
  color: var(--muted);
}

.chat-badge {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #0b0f14;
  display: grid;
  place-items: center;
  font-size: 11px;
  padding: 0 6px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100vh);
  background: rgba(7, 10, 15, 0.85);
  min-height: 0;
  position: relative;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 14, 20, 0.98);
  z-index: 5;
}

.chat-info {
  flex: 1;
}

.chat-title {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.chat-subtitle.typing {
  color: var(--accent);
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.typing-indicator {
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
}

.typing-indicator.hidden {
  display: none;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.message.search-hit {
  border-color: rgba(41, 191, 178, 0.6);
  box-shadow: 0 0 0 1px rgba(41, 191, 178, 0.2);
}

.chat-search {
  position: relative;
}

.chat-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--muted);
}

.chat-search input {
  padding-left: 36px;
  width: 100%;
}

body.lang-fa .chat-search svg {
  left: auto;
  right: 12px;
}

body.lang-fa .chat-search input {
  padding-left: 12px;
  padding-right: 36px;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  padding-bottom: calc(18px + 84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.message {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12, 16, 24, 0.8);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.message.has-media {
  width: fit-content;
  max-width: 100%;
}

.message.has-media .message-body {
  width: fit-content;
  max-width: 100%;
}

.message.has-media .message-media {
  display: block;
  width: auto;
}

.message.no-avatar {
  grid-template-columns: 1fr;
}

.message.outgoing {
  margin-left: auto;
  background: rgba(41, 191, 178, 0.16);
  grid-template-columns: 1fr;
  text-align: right;
  align-self: flex-end;
}

.message.outgoing .message-avatar {
  display: none;
}

.message strong {
  font-size: 12px;
  color: var(--accent);
}

.message span {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  direction: auto;
  unicode-bidi: plaintext;
  text-align: start;
}

.message .mention {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.message .mention:hover {
  text-decoration: underline;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  margin: 4px;
}

.verified-badge svg {
  width: 20px;
  height: 20px;
}

.message-reply {
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  font-size: 12px;
  color: var(--muted);
  direction: auto;
  unicode-bidi: plaintext;
  text-align: start;
}

.message-time {
  align-self: flex-end;
  font-size: 10px;
  color: var(--muted);
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2ff1c8, #2f7cff);
  display: grid;
  place-items: center;
  color: #0b0f14;
  font-weight: 700;
  background-size: cover;
  background-position: center;
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-header {
  display: inline-flex;
  align-items: center;
}

.message-id {
  margin-left: 6px;
  font-size: 10px;
  color: var(--muted);
}

.message-media {
  margin-top: 6px;
  max-width: 100%;
  border-radius: 12px;
  cursor: pointer;
}

.media-inline {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
}

.audio-player {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(12, 16, 24, 0.8);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(320px, 100%);
}

.audio-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.audio-title {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-play {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.8);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.audio-bar {
  flex: 1;
  accent-color: var(--accent);
}

.audio-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.audio-el {
  display: none;
}

.video-player {
  position: relative;
  margin-top: 6px;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  width: min(520px, 100%);
}

.video-el {
  width: 100%;
  display: block;
  background: #000;
}

.video-play {
  position: absolute;
  inset: auto 12px 48px auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.video-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  width: calc(100% - 20px);
  accent-color: var(--accent);
}

.video-meta {
  position: absolute;
  left: 10px;
  bottom: 38px;
  display: flex;
  gap: 8px;
  align-items: center;
  color: #fff;
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.video-title {
  font-weight: 600;
}

.video-time {
  opacity: 0.8;
}
@media (min-width: 900px) {
  .message-media {
    max-width: 60%;
  }
  .message.has-media {
    max-width: 55%;
  }
  .video-player {
    max-width: 560px;
  }
  .audio-player {
    max-width: 340px;
  }
}

.media-card {
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(12, 16, 24, 0.8);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  cursor: pointer;
}

.media-thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 700;
}

.file-link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 12px;
  cursor: pointer;
}

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: rgba(8, 10, 14, 0.95);
}

.file-preview.hidden {
  display: none;
}

.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: rgba(12, 16, 24, 0.9);
}

.reply-preview.hidden {
  display: none;
}

.reply-preview-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.reply-preview-text span:first-child {
  color: var(--text);
  font-weight: 600;
}

.file-preview-name {
  font-size: 13px;
}

.file-preview-size {
  font-size: 11px;
  color: var(--muted);
}

.upload-progress {
  height: 6px;
  background: rgba(12, 16, 24, 0.6);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin: 6px 16px 0;
  overflow: hidden;
}

.upload-progress.hidden {
  display: none;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ff1c8, #2f7cff);
  transition: width 0.2s ease;
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.98);
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

body:not(.chat-active) .composer,
body:not(.chat-active) .file-preview,
body:not(.chat-active) .reply-preview {
  display: none;
}

body.read-only .composer,
body.read-only .file-preview,
body.read-only .reply-preview,
body.read-only .edit-preview {
  display: none;
}

.composer textarea {
  flex: 1;
  background: var(--panel-strong);
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  line-height: 1.6;
  font-family: inherit;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 200, 200, 0.35) transparent;
}

.composer textarea::-webkit-scrollbar {
  width: 6px;
}

.composer textarea::-webkit-scrollbar-thumb {
  background: rgba(120, 200, 200, 0.35);
  border-radius: 999px;
}

.composer textarea::-webkit-scrollbar-track {
  background: transparent;
}

.file-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.file-btn input {
  display: none;
  opacity: 0;
  position: absolute;
  width: 1px;
  height: 1px;
}

.file-btn svg {
  pointer-events: none;
}

.file-btn:hover {
  border-color: var(--border);
  color: var(--text);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn.muted {
  color: var(--muted);
}

.emoji-picker {
  position: absolute;
  bottom: 74px;
  left: 16px;
  width: 252px;
  max-height: 260px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 200, 200, 0.35) transparent;
  z-index: 6;
}

body.lang-fa .emoji-picker {
  left: auto;
  right: 16px;
}

.emoji-picker.hidden {
  display: none;
}

.emoji-item {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-strong);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 18px;
}

.emoji-item:hover {
  border-color: var(--border);
}

.emoji-picker::-webkit-scrollbar {
  width: 6px;
}

.emoji-picker::-webkit-scrollbar-thumb {
  background: rgba(120, 200, 200, 0.35);
  border-radius: 999px;
}

.emoji-picker::-webkit-scrollbar-track {
  background: transparent;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #090d12, #0c2728);
  color: #0b0f14;
  cursor: pointer;
  font-size: 35px;
}

.back-btn {
  display: none;
}

.fab {
  position: absolute;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  margin: 0;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  border: none;
  background: linear-gradient(135deg, #090d12, #0c2728);
  color: #fff;
  font-size: 3px;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.3);
}

#refreshBtn {
  bottom: calc(86px + env(safe-area-inset-bottom));
}


.chat-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.7);
  display: grid;
  place-items: center;
  z-index: 30;
  opacity: 1;
  transition: opacity 0.22s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal {
  width: min(440px, 92vw);
  background: rgba(18, 24, 36, 0.95);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 30px 60px var(--shadow);
  max-height: min(80vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.media-modal {
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.overlay:not(.hidden) .modal,
.overlay:not(.hidden) .media-modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.auth-toggle {
  display: inline-flex;
  gap: 6px;
  background: rgba(12, 16, 24, 0.6);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 14px;
}

.auth-toggle-btn {
  min-width: 86px;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.auth-toggle-btn.active {
  background: rgba(41, 191, 178, 0.22);
  color: var(--text);
}

.auth-panel.hidden {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

input,
select {
  background: var(--panel-strong);
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 209, 198, 0.2);
}

.toggle-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  margin: 8px 0;
}

.toggle-inline input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  margin: 5px;
  width: 100%;
  justify-content: space-around;
}

.primary {
  background: linear-gradient(135deg, #2ff1c8, #2f7cff);
  color: #0b0f14;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}

.error-text {
  font-size: 11px;
  color: var(--danger);
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.settings-modal {
  width: min(520px, 92vw);
}

.settings-section {
  margin-bottom: 16px;
}

.settings-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 16px;
}

.profile-avatar-lg {
  width: 84px;
  height: 84px;
  border-radius: 24px;
}

.profile-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.profile-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 12px;
  text-align: center;
}

.password-fields.hidden {
  display: none;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 10px;
}

.settings-actions {
  display: grid;
  gap: 10px;
}

.admin-section select {
  width: 100%;
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.admin-token {
  display: grid;
  gap: 6px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--muted);
}

.admin-token-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-token-value {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

.admin-requests {
  margin-top: 12px;
}

.request-list {
  display: grid;
  gap: 8px;
}

.danger {
  border-color: rgba(255, 104, 97, 0.6);
  color: var(--danger);
}

.settings-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.profile-avatar {
  width: 100%;
  height: 230px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2ff1c8, #2f7cff);
  display: grid;
  place-items: center;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.profile-id {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.upload-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.upload-pill input {
  display: none;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
}

.toggle.active {
  background: rgba(41, 191, 178, 0.2);
  color: var(--text);
}

.request-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.media-modal {
  width: min(720px, 92vw);
  background: rgba(12, 16, 24, 0.95);
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 40px 80px var(--shadow);
}

.media-content {
  display: grid;
  place-items: center;
}

.media-content img,
.media-content video {
  max-width: 100%;
  border-radius: 16px;
}

.media-content audio {
  width: 100%;
}

.chat-list::-webkit-scrollbar,
.chat-body::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  width: 8px;
}

.chat-list::-webkit-scrollbar-thumb,
.chat-body::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.chat-list::-webkit-scrollbar-track,
.chat-body::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list,
.chat-body,
.modal {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body.lang-fa .chat-body,
body.lang-fa .composer textarea,
body.lang-fa .message span {
  font-family: "YekanBakh", "Space Grotesk", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

body.lang-fa .chat-header,
body.lang-fa .list-panel {
  text-align: right;
}

body.lang-en {
  direction: ltr;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .list-panel {
    height: var(--app-height, 100vh);
  }

  .chat-panel {
    position: fixed;
    inset: 0;
    height: var(--app-height, 100vh);
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  body.chat-active .chat-panel {
    transform: translateX(0);
  }

  body.chat-active .list-panel {
    display: none;
  }

  .fab,
  #refreshBtn {
    position: fixed;
    right: 18px;
  }

  body.chat-active .fab,
  body.chat-active #refreshBtn {
    display: none;
  }

  .back-btn {
    display: grid;
  }
}

@media (max-width: 720px) {
  .list-header {
    padding: 12px 14px;
  }

  .search-box {
    padding: 10px 14px;
  }

  .chat-list {
    padding: 4px 8px 140px;
  }

  .chat-item {
    grid-template-columns: 52px 1fr auto;
    padding: 8px 10px;
  }

  .chat-item .chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .chat-avatar {
    width: 38px;
    height: 38px;
  }

  .chat-header {
    padding: 12px 14px;
  }

  .chat-body {
    padding: 14px;
  }

  .composer {
    padding: 10px 12px;
    gap: 8px;
  }

  .composer textarea {
    min-height: 40px;
    font-size: 14px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .send-btn {
    width: 40px;
    height: 40px;
  }

  .modal {
    width: min(420px, 92vw);
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .drawer {
    width: min(280px, 86vw);
  }

  .drawer-header {
    gap: 10px;
  }

  .drawer-avatar {
    width: 58px;
    height: 58px;
  }

  .chat-item {
    grid-template-columns: 46px 1fr auto;
  }

  .chat-item .chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .chat-title {
    font-size: 15px;
  }

  .chat-subtitle {
    font-size: 11px;
  }

  .chat-body {
    padding: 12px;
  }

  .message {
    padding: 8px 10px;
  }

  .message span {
    font-size: 13px;
  }
}

@media (min-width: 1200px) {
  .app {
    grid-template-columns: minmax(320px, 360px) 1fr;
  }

  .list-panel {
    border-right: 1px solid var(--border);
  }

  .chat-body {
    padding: 22px 28px;
  }
}

body[data-theme="light"] .list-panel {
  background: rgba(240, 243, 248, 0.95);
}

body[data-theme="light"] .chat-action-btn {
  background: rgba(255, 255, 255, 0.95);
}

body[data-theme="light"] .chat-panel {
  background: rgba(240, 243, 248, 0.7);
}

body[data-theme="light"] .chat-item {
  background: rgba(255, 255, 255, 0.9);
}

body[data-theme="light"] .chat-header,
body[data-theme="light"] .composer,
body[data-theme="light"] .list-header {
  background: rgba(255, 255, 255, 0.95);
}

body[data-theme="light"] .file-preview {
  background: rgba(255, 255, 255, 0.95);
}

body[data-theme="light"] .modal {
  background: rgba(255, 255, 255, 0.98);
}

body[data-theme="light"] .archived-toggle {
  background: rgba(255, 255, 255, 0.9);
}

body[data-theme="light"] .message {
  background: rgba(255, 255, 255, 0.95);
}

body[data-theme="light"] .message.outgoing {
  background: rgba(14, 165, 160, 0.12);
}
