:root {
  --bg: #121212;
  --panel: #181818;
  --panel-2: #1e1e1e;
  --line: rgba(176, 130, 219, 0.25);
  --text: #f4f4f6;
  --muted: #b082db;
  --accent: #b082db;
  --accent-dim: rgba(176, 130, 219, 0.14);
  --user-bubble: #232328;
  --admin-bubble: #b082db;
  --admin-text: #121212;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Vazirmatn", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  object-fit: contain;
  background: #000;
  padding: 3px;
  border: 1px solid var(--line);
}

.brand-title {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.btn-close {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  padding: 7px 11px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.btn-close.hidden {
  display: none;
}

.inbox {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 10px;
}

.inbox.hidden {
  display: none;
}

.inbox-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.inbox-scroll::-webkit-scrollbar {
  display: none;
}

.thread-chip {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  max-width: 160px;
  font-family: inherit;
}

.thread-chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}

.thread-chip .preview {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat {
  display: flex;
  flex-direction: column;
  height: calc(100% - 62px);
  min-height: 0;
}

.inbox:not(.hidden)+.chat {
  height: calc(100% - 62px - 52px);
}

.chat-head {
  padding: 8px 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.chat-head.hidden {
  display: none;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bubble.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border: 1px solid var(--line);
}

.bubble.admin {
  align-self: flex-start;
  background: var(--admin-bubble);
  color: var(--admin-text);
}

.bubble .msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble img.attach {
  display: block;
  max-width: min(240px, 70vw);
  border-radius: 12px;
  margin: 4px 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.bubble audio {
  width: min(240px, 75vw);
  margin: 6px 0 2px;
  height: 36px;
}

.bubble .meta {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  opacity: 0.72;
}

.composer {
  padding: 8px 10px calc(10px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.composer-shell {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.tool-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tool-btn:disabled {
  opacity: 0.45;
}

.composer-shell .voice-tool {
  flex-shrink: 0;
}

.composer-shell textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  padding: 10px 6px;
  resize: none;
  max-height: 120px;
  outline: none;
  font-family: inherit;
}

.composer-shell textarea::placeholder {
  color: rgba(176, 130, 219, 0.55);
}

.send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: var(--admin-text);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.send-btn:disabled {
  opacity: 0.45;
}

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

.empty {
  text-align: center;
  color: var(--muted);
  margin: auto;
  font-size: 14px;
  padding: 24px 16px;
  line-height: 1.7;
}

.system-note {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px dashed var(--line);
}