:root {
  --bg: #0b0d12;
  --panel: #11141b;
  --panel-2: #171b24;
  --border: #272c38;
  --text: #f4f6fa;
  --muted: #949baa;
  --accent: #8b7cff;
  --accent-2: #6d5dfc;
  --user: #242938;
  --danger: #ff6b6b;
  --max: 860px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, textarea { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: 270px;
  flex: 0 0 270px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 4px 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; background: var(--accent); color: white; font-size: 20px;
}
.brand strong { display: block; font-size: 14px; }
.brand span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }

.new-chat {
  border: 1px solid var(--border); background: var(--panel-2); border-radius: 10px;
  padding: 11px 13px; cursor: pointer; text-align: left;
}
.new-chat:hover, .suggestions button:hover { border-color: #3a4050; background: #1c202a; }

.sidebar-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-top: 8px; }
.conversation-list { overflow: auto; display: flex; flex-direction: column; gap: 5px; }
.conversation-item {
  border: 0; background: transparent; border-radius: 9px; padding: 10px;
  text-align: left; cursor: pointer; color: #cfd3dc; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conversation-item:hover, .conversation-item.active { background: var(--panel-2); color: white; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar-footer span { display: block; color: var(--muted); font-size: 10px; margin-top: 7px; }
.text-button { border: 0; background: none; color: var(--muted); padding: 0; cursor: pointer; font-size: 11px; }
.text-button:hover { color: var(--danger); }

.main { min-width: 0; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 62px; flex: 0 0 62px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
  background: rgba(11,13,18,.86); backdrop-filter: blur(10px);
}
.topbar-title { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #61d99b; }
.icon-button {
  width: 36px; height: 36px; border: 1px solid var(--border); background: var(--panel);
  border-radius: 9px; cursor: pointer;
}
.icon-button:hover { background: var(--panel-2); }
.mobile-only { display: none; }

.chat {
  flex: 1; overflow-y: auto; padding: 36px 20px 140px;
}
.welcome { max-width: var(--max); margin: 12vh auto 0; text-align: center; }
.welcome-icon {
  margin: auto; width: 54px; height: 54px; display: grid; place-items: center;
  background: #19162d; color: #b8afff; border: 1px solid #322d5a; border-radius: 17px;
  font-size: 26px;
}
.welcome h1 { font-size: 30px; margin: 20px 0 8px; letter-spacing: -.03em; }
.welcome p { max-width: 560px; margin: 0 auto; color: var(--muted); line-height: 1.6; }
.suggestions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.suggestions button {
  border: 1px solid var(--border); background: var(--panel); border-radius: 999px;
  padding: 9px 13px; cursor: pointer; color: #cbd0db; font-size: 12px;
}

.message-row { max-width: var(--max); margin: 0 auto 22px; display: flex; gap: 12px; }
.message-row.user { justify-content: flex-end; }
.avatar {
  flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 9px; background: var(--panel-2); border: 1px solid var(--border);
  color: #bbb4ff; font-size: 13px;
}
.user .avatar { order: 2; background: var(--user); color: white; }
.bubble {
  max-width: min(760px, 82%); line-height: 1.62; font-size: 14px;
  padding: 11px 14px; border-radius: 14px; border: 1px solid var(--border);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.assistant .bubble { background: var(--panel); }
.user .bubble { background: var(--user); }
.meta { color: var(--muted); font-size: 10px; margin: 5px 3px 0; }
.typing { display: inline-flex; gap: 4px; padding: 5px 2px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #9da3b0; animation: pulse 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.composer-wrap {
  position: fixed; bottom: 0; left: 270px; right: 0; padding: 14px 20px 18px;
  background: linear-gradient(transparent, var(--bg) 30%);
}
.composer { max-width: var(--max); margin: 0 auto; display: flex; gap: 9px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; max-height: 170px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); outline: none; border-radius: 14px;
  padding: 12px 48px 12px 14px; min-height: 48px; line-height: 1.45;
}
.composer textarea:focus { border-color: #49416f; box-shadow: 0 0 0 3px rgba(139,124,255,.08); }
.send-button {
  width: 46px; height: 46px; border: 0; border-radius: 13px; background: var(--accent);
  cursor: pointer; color: white; flex: 0 0 auto;
}
.send-button:hover { background: var(--accent-2); }
.send-button:disabled { opacity: .45; cursor: default; }
.composer-note { max-width: var(--max); margin: 7px auto 0; color: #686e7a; font-size: 9px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 15px);
  opacity: 0; pointer-events: none; background: #242936; border: 1px solid #343b49;
  color: white; padding: 9px 13px; border-radius: 9px; font-size: 12px; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .sidebar {
    position: fixed; z-index: 20; inset: 0 auto 0 0; transform: translateX(-100%);
    transition: transform .2s; box-shadow: 12px 0 35px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: block; }
  .composer-wrap { left: 0; }
  .topbar { padding: 0 14px; }
  .chat { padding-left: 12px; padding-right: 12px; }
  .bubble { max-width: 88%; }
  .welcome h1 { font-size: 25px; }
}
