:root {
  --bg: #0f1720;
  --panel: #17212c;
  --panel-2: #1e2a37;
  --border: #2a3947;
  --text: #e6edf3;
  --text-dim: #93a3b3;
  --accent: #3b9eff;
  --accent-dim: #1f4a6e;
  --user-bubble: #2a5580;
  --bot-bubble: #1e2a37;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
}

.app {
  display: flex;
  height: 100vh;
}

.main-col {
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  min-width: 0;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px;
}

.sidebar-new-btn {
  width: 100%;
  margin-bottom: 12px;
}

.sidebar-install-btn {
  width: 100%;
  margin-bottom: 12px;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item:hover { background: var(--panel-2); color: var(--text); }
.conv-item.active { background: var(--accent-dim); color: var(--text); }

.sidebar-user {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.sidebar-user img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-email { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px;
}
.sidebar-logout:hover { color: var(--text); }

.login-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.login-card {
  text-align: center;
  max-width: 360px;
  padding: 32px;
}
.login-card h1 { font-size: 20px; margin: 14px 0 8px; }
.login-card p { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; }
#googleSignInBtn { display: flex; justify-content: center; margin-bottom: 20px; }
.owner-note { font-size: 11px; color: var(--text-dim); margin-top: 24px; }

.sidebar-toggle-btn { display: none; font-size: 20px; }
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .sidebar-toggle-btn { display: inline-block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 41;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.4);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
  }
  .sidebar-backdrop.open { display: block; }

  .main-col { max-width: 100%; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 24px; }
.brand-title { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--panel-2); }

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.welcome { text-align: center; padding: 40px 10px; }
.welcome h1 { font-size: 22px; margin-bottom: 8px; }
.welcome p { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 640px;
  margin: 0 auto;
}

.chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  max-width: 260px;
}
.chip:hover { border-color: var(--accent); }

.messages { display: flex; flex-direction: column; gap: 18px; }

.msg { display: flex; gap: 10px; max-width: 100%; }
.msg.user { justify-content: flex-end; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  max-width: 78%;
  line-height: 1.55;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user .msg-bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}
.msg.model .msg-bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.msg-bubble code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.msg-bubble pre {
  background: #0b1218;
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.msg-bubble th { background: rgba(255,255,255,0.05); }
.msg-bubble a { color: var(--accent); }

.msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}

.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.composer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 12px 18px 10px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.attachments:empty { display: none; }

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
}
.attachment-chip button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 8px 12px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  color: var(--text-dim);
}
.icon-btn:hover { color: var(--text); }
.icon-btn.active { color: var(--accent); background: var(--accent-dim); border-radius: 8px; }

#promptInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14.5px;
  resize: none;
  max-height: 160px;
  font-family: inherit;
  padding: 6px 0;
}

.btn-primary {
  background: var(--accent);
  color: #06121d;
  border: none;
  padding: 9px 18px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}
