:root {
  --bg: #0e0f12;
  --panel: #14161b;
  --panel-2: #1a1d24;
  --text: #e9e9ee;
  --muted: #9aa0ac;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #8b5cf6;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* { box-sizing: border-box; }
html {
  height: 100%;
  overflow: hidden;
}
body {
  height: 100%;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(1200px 600px at 30% -10%, rgba(139, 92, 246, 0.15), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(34, 197, 94, 0.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji",
    "Segoe UI Emoji";
}
body.hasWallpaper {
  position: relative;
}
body.hasWallpaper::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 18, 0.65);
  z-index: 0;
  pointer-events: none;
}
body.hasWallpaper #app {
  position: relative;
  z-index: 1;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.appShell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(14, 15, 18, 0.75);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbarInner {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 14px;
}

.iconBtn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.iconBtn:active { transform: translateY(1px); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brandMark {
  height: 34px;
  padding: 0 12px;
  border-radius: 12px;
  background: #ffffff;
  color: #0b0c10;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: 0.2px;
}
.brandText { font-weight: 700; letter-spacing: 0.3px; }
.brandSub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.brandCol { display: flex; flex-direction: column; min-width: 0; }

.page {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 80px 14px 90px;
}

.sectionTitle {
  margin: 18px 4px 10px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.2px;
}

.searchRow {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
}
.searchRow input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.pillBtn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.pillBtn.primary { border-color: rgba(139, 92, 246, 0.5); background: rgba(139, 92, 246, 0.18); }
.pillBtn.danger { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.12); }
.pillBtn:active { transform: translateY(1px); }

.gridRow {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.botRow {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  object-fit: cover;
}
.avatar.round { border-radius: 999px; }

.botMeta { min-width: 0; }
.botName { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.botBy { font-size: 12px; color: var(--muted); margin-top: 2px; }
.botStats { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.botStats { min-width: 0; }
.botStats .tag {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag { border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px; }

.actions { display: flex; gap: 8px; align-items: center; }
.botRow .actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.botRow .actions .pillBtn {
  padding: 5px 9px;
  font-size: 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.hScroll {
  display: flex;
  gap: 12px;
  overflow: auto;
  padding: 4px 2px 10px;
  scrollbar-width: none;
}
.hScroll::-webkit-scrollbar { display: none; }

.miniCard {
  width: 220px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.miniCardTop { position: relative; }
.miniCardImg { width: 100%; height: 130px; object-fit: cover; display: block; background: rgba(255, 255, 255, 0.03); }
.miniCardBody { padding: 10px 12px; }
.miniCardName { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.miniCardBy { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  border-top: 1px solid var(--border);
  background: rgba(14, 15, 18, 0.85);
  backdrop-filter: blur(14px);
}
.bottomNavInner {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 14px;
}
.navItem {
  display: grid;
  gap: 6px;
  place-items: center;
  padding: 8px 6px;
  border-radius: 16px;
  border: 1px solid transparent;
  color: var(--muted);
}
.navItem.active {
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.12);
  color: var(--text);
}
.navLabel { font-size: 11px; }

.panel {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.field { display: grid; gap: 6px; margin: 10px 0; }
.field label { color: var(--muted); font-size: 12px; }
.field input, .field textarea, .field select {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }
.error { color: #ffb4b4; font-size: 13px; }
.ok { color: #b8ffd2; font-size: 13px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.chatShell {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chatHeader {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.chatTitle { font-weight: 800; line-height: 1.1; }
.chatSub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.messages {
  padding: 14px 12px;
  height: min(62vh, 560px);
  overflow: auto;
  display: grid;
  gap: 10px;
  justify-items: start;
  align-content: start;
}

.msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  white-space: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: inline-block;
  width: fit-content;
  justify-self: start;
  align-self: start;
}
.hidden { display: none !important; }

.msgText { white-space: pre-wrap; }

.msgTop { display: none; }
.msgVariantNav { display: none; }
.msg.user {
  justify-self: end;
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.12);
}
.msg.bot {
  border-color: rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
}

.composer {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: rgba(14, 15, 18, 0.3);
}
.composer textarea {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.4;
  field-sizing: content;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal {
  width: min(760px, 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(20, 22, 27, 0.95);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modalHead {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modalBody {
  padding: 14px;
  max-height: 60vh;
  overflow: auto;
  color: rgba(233, 233, 238, 0.92);
}
.modalFoot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.drawerBackdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: stretch;
}

.drawer {
  width: min(420px, 92vw);
  height: 100%;
  border-right: 1px solid var(--border);
  background: rgba(14, 15, 18, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  animation: drawerIn 160ms ease-out;
}

@keyframes drawerIn {
  from { transform: translateX(-12px); opacity: 0.8; }
  to { transform: translateX(0); opacity: 1; }
}

.drawerHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 10px;
}

.drawerBody {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

.drawerList {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.drawerItem {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.drawerAvatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  object-fit: cover;
}

.drawerName {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawerSub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 860px) {
  .gridRow { grid-template-columns: 1fr 1fr; }
  .messages { height: 62vh; }
}

@media (max-width: 520px) {
  .topbarInner { padding: 10px 10px; gap: 8px; }
  .page { padding: 76px 10px 92px; }
  .brandSub { display: none; }
  .brandMark { padding: 0 10px; height: 32px; border-radius: 12px; }
  .brandText { font-size: 14px; }
  .searchRow { padding: 10px 10px; }
  .actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .botRow { grid-template-columns: 56px 1fr; }
  .botRow .actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 720px) {
  .botRow { grid-template-columns: 56px 1fr; }
  .botRow .actions { grid-column: 1 / -1; justify-content: flex-start; }
}

.msg.typing .msgText {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 4px;
}
.typingDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typingDot:nth-child(2) { animation-delay: 0.2s; }
.typingDot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-6px); }
}
