:root {
  --bg: #e7ebf0;
  --panel: #ffffff;
  --panel-soft: #f4f6f8;
  --panel-soft-2: #eef2f5;
  --text: #1f2a36;
  --muted: #6b7c8f;
  --line: rgba(15, 23, 42, 0.08);
  --bot: #ffffff;
  --user: #d9fdd3;
  --accent: #3390ec;
  --accent-2: #2481de;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.logo,
.avatar,
.msg-avatar {
  overflow: hidden;
  border-radius: 50%;
  flex: 0 0 auto;
}

.logo,
.avatar {
  width: 42px;
  height: 42px;
  background: #fff;
}

.logo img,
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-title,
.header-title {
  font-weight: 700;
}

.sidebar-subtitle,
.header-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chat {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 82px;
  height: 100vh;
  min-height: 0;
  background:
    radial-gradient(circle at top, rgba(51, 144, 236, 0.06), transparent 28%),
    linear-gradient(180deg, #edf2f7 0%, #e7ebf0 100%);
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  position: relative;
}

.menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.menu-btn:hover {
  background: rgba(15, 23, 42, 0.06);
}

.menu-dropdown {
  position: absolute;
  top: 46px;
  right: 0;
  width: 240px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.hidden {
  display: none;
}

.menu-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 6px 8px 10px;
}

.commands-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.command-btn {
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
}

.command-btn:hover {
  background: rgba(15, 23, 42, 0.05);
}

.messages {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 20px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
}

.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-row.user .msg-avatar {
  display: none;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  background: #fff;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-bubble {
  max-width: min(780px, 82%);
  border-radius: 18px;
  padding: 12px 14px 8px;
  box-shadow: var(--shadow);
  line-height: 1.45;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.msg-row.bot .msg-bubble {
  background: var(--bot);
  border-top-left-radius: 8px;
}

.msg-row.user .msg-bubble {
  background: var(--user);
  border-top-right-radius: 8px;
}

.msg-time {
  margin-top: 6px;
  text-align: right;
  color: rgba(31, 42, 54, 0.52);
  font-size: 11px;
}

.media-card {
  margin-top: 10px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.02);
}

.media-card img {
  width: 100%;
  display: block;
  max-height: 320px;
  object-fit: contain;
  background: #f8fafc;
}

.media-caption {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
}

.file-card {
  margin-top: 10px;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  text-decoration: none;
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(51, 144, 236, 0.12);
}

.file-title {
  font-size: 14px;
  font-weight: 600;
}

.file-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.inline-keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.inline-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.inline-btn {
  width: 100%;
  border: 1px solid rgba(51, 144, 236, 0.22);
  background: rgba(51, 144, 236, 0.08);
  color: #1f5f9b;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  min-height: 42px;
}

.inline-btn:hover {
  background: rgba(51, 144, 236, 0.14);
}

.inline-row .inline-btn:only-child {
  grid-column: 1 / -1;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.composer input {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  background: #ffffff;
  color: var(--text);
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 14px;
}

.composer input::placeholder {
  color: var(--muted);
}

.send-btn {
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
}

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

.send-btn:disabled,
.inline-btn:disabled,
.command-btn:disabled,
.menu-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .msg-bubble {
    max-width: 92%;
  }

  .menu-dropdown {
    width: 220px;
  }
}

.menu-divider {
  height: 1px;
  margin: 8px 0;
  background: rgba(0,0,0,0.08);
}

.menu-install-btn {
  font-weight: 600;
}
