/* reset everything first */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

/* color variables so we can reuse them easily */
:root {
  --bg: #0a0c10;
  --surface: #111318;
  --surface2: #181c24;
  --surface3: #1e2230;
  --surface4: #242840;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.12);
  --text: #e2e6f0;
  --muted: #7a8099;
  --faint: #3a3f55;
  --accent: #5b8dee;
  --accent2: #3f6fd6;
  --glow: rgba(91, 141, 238, 0.22);
  --purple: #a78bfa;
  --ai-bg: #12151e;
  --user-bg: #151d30;
  --green: #34d399;
  --red: #f87171;
  --sidebar-width: 250px;
  --topbar-height: 54px;
}

body {
  font-family: 'Sora', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

/* the main app container */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}


/* sidebar */

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.28s ease;
  overflow: hidden;
  z-index: 40;
}

.sidebar-header {
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.logo-gem {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 0 14px var(--glow);
}

.logo-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: var(--text);
}

.new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 9px;
  font-family: 'Sora', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 2px 14px var(--glow);
}

.new-btn:hover {
  background: var(--accent2);
  transform: translateY(-1px);
}

.new-btn:active {
  transform: scale(0.98);
}

.hist-label {
  padding: 13px 15px 5px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--faint);
  flex-shrink: 0;
}

.hist-list {
  flex: 1;
  overflow-y: auto;
  padding: 3px 7px;
}

.hist-list::-webkit-scrollbar {
  width: 2px;
}

.hist-list::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.hist-empty {
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
  padding: 18px 10px;
  line-height: 1.7;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.hist-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.hist-item.active {
  background: var(--surface3);
  color: var(--text);
  border-left: 2px solid var(--accent);
  padding-left: 7px;
}

.hist-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.model-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 3px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

.powered {
  font-size: 10px;
  color: var(--faint);
}


/* main chat area */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.menu-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.topbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.model-badge {
  font-size: 10.5px;
  font-weight: 500;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 999px;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.chat-scroll::-webkit-scrollbar {
  width: 3px;
}

.chat-scroll::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}


/* welcome screen */

.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 24px;
  text-align: center;
  animation: fadeUp 0.45s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.orb-wrap {
  margin-bottom: 26px;
}

.orb {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--purple), #ec4899, var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spinOrb 4s linear infinite;
  position: relative;
}

@keyframes spinOrb {
  to {
    transform: rotate(360deg);
  }
}

.orb-inner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  position: absolute;
}

.welcome-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 34px;
  line-height: 1.75;
  max-width: 380px;
}

.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  max-width: 520px;
  width: 100%;
}

.sug-btn {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 11px;
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
  line-height: 1.45;
}

.sug-btn:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-2px);
}

.sug-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}


/* messages */

.messages {
  padding: 14px 0 18px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.message {
  display: flex;
  gap: 12px;
  padding: 10px 20px;
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.ai .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white;
  font-size: 14px;
}

.message.user .msg-avatar {
  background: var(--surface4);
  border: 1px solid var(--border2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.msg-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.message.user .msg-content {
  align-items: flex-end;
}

.msg-name {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 2px;
}

.msg-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.75;
  word-break: break-word;
}

.message.ai .msg-bubble {
  background: var(--ai-bg);
  border: 1px solid var(--border);
  border-radius: 3px 13px 13px 13px;
  color: var(--text);
}

.message.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid rgba(91, 141, 238, 0.18);
  border-radius: 13px 3px 13px 13px;
  color: var(--text);
}

.msg-bubble pre {
  background: #070a10;
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 9px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.65;
}

.msg-bubble code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(91, 141, 238, 0.13);
  padding: 1px 6px;
  border-radius: 4px;
  color: #7eb8ff;
}

.msg-bubble pre code {
  background: none;
  padding: 0;
  color: #8daecf;
}

.msg-bubble ul,
.msg-bubble ol {
  padding-left: 18px;
  margin: 6px 0;
}

.msg-bubble li {
  margin-bottom: 4px;
}

.msg-bubble strong {
  color: var(--text);
}

.error-bubble {
  background: rgba(248, 113, 113, 0.07) !important;
  border-color: rgba(248, 113, 113, 0.22) !important;
  color: #fca5a5 !important;
}

/* bouncing dots while waiting for the AI reply */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 7px 3px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: typeBounce 1.3s infinite;
  opacity: 0.5;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.18s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typeBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-8px);
    opacity: 1;
  }
}


/* input area at the bottom */

.input-area {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.input-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 13px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: rgba(91, 141, 238, 0.5);
  box-shadow: 0 0 0 3px rgba(91, 141, 238, 0.07);
}

.input-box textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Sora', sans-serif;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.6;
  max-height: 150px;
  overflow-y: auto;
  padding: 2px 0;
}

.input-box textarea::placeholder {
  color: var(--faint);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 2px 10px var(--glow);
  font-size: 15px;
}

.send-btn:hover {
  background: var(--accent2);
  transform: scale(1.06);
}

.send-btn:active {
  transform: scale(0.94);
}

.send-btn:disabled {
  background: var(--surface3);
  color: var(--faint);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-note {
  text-align: center;
  font-size: 10.5px;
  color: var(--faint);
  margin-top: 8px;
}

.input-note a {
  color: var(--muted);
}


/* mobile */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

@media (max-width: 680px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.5);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .suggestions {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .msg-content {
    max-width: 88%;
  }

  .messages {
    padding: 8px 0;
  }

  .message {
    padding: 9px 12px;
    gap: 10px;
  }

  .welcome {
    padding: 26px 16px 16px;
  }

  .welcome-sub {
    display: none;
  }
}
