:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf5;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --user-bubble: #1d4ed8;
  --bot-bubble: #243044;
  --drawer-h: 52px;
  --font: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.header {
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: calc(var(--drawer-h) + 1rem);
}

.msg {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-start;
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-end;
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.25rem;
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  margin-bottom: var(--drawer-h);
}

.composer input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font: inherit;
  outline: none;
}

.composer input:focus {
  border-color: var(--accent);
}

.composer button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.composer button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.composer button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  max-width: 720px;
  margin: 0 auto;
}

.drawer-toggle {
  width: 100%;
  height: var(--drawer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1.25rem;
  background: var(--surface-2);
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.drawer-toggle .label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.drawer-toggle .version {
  font-size: 0.9rem;
  font-weight: 600;
}

.drawer-toggle .chevron {
  transition: transform 0.25s ease;
  font-size: 1rem;
  color: var(--text-muted);
}

.drawer.open .chevron {
  transform: rotate(180deg);
}

.drawer-panel {
  max-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-top: 1px solid var(--border);
  transition: max-height 0.28s ease;
}

.drawer.open .drawer-panel {
  max-height: 160px;
}

.drawer-body {
  padding: 0.85rem 1.25rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.drawer-body strong {
  color: var(--text);
  font-weight: 600;
}

.typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.5rem 0;
}

.typing span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}
