:root {
  --bg-sidebar: #171717;
  --bg-main: #212121;
  --bg-card: #2a2a2a;
  --bg-input: #2f2f2f;
  --border: #3a3a3a;
  --text-main: #ececec;
  --text-muted: #9b9b9b;
  --accent: #ffffff;
  --accent-text: #171717;
  --brand: #ff5c5c;
  --bubble-user: #2f2f2f;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

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

button { font-family: inherit; }

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

/* Sidebar */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  padding: 6px 8px 14px;
}
.brand-dot {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--brand), #ff8a5c);
  flex-shrink: 0;
}

.nav-primary {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-card); color: var(--text-main); }
.nav-item.active { background: var(--bg-card); color: var(--text-main); }

.chat-list-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 40px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item:hover { background: var(--bg-card); color: var(--text-main); }
.chat-item.active { background: var(--bg-card); color: var(--text-main); }
.chat-item .label { overflow: hidden; text-overflow: ellipsis; }
.chat-item .del {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.chat-item:hover .del { opacity: 1; }
.chat-item .del:hover { color: var(--danger); }

.sidebar-bottom {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.signin-card {
  margin-top: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.signin-title { font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.signin-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 10px; line-height: 1.4; }
.signin-card-btn {
  width: 100%;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-footer {
  font-size: 11px;
  color: var(--text-muted);
  padding: 12px 8px 2px;
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.model-select select {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.signin-top-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.user-chip .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-main);
  font-size: 12px;
}
.user-chip button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.user-chip button:hover { color: var(--text-main); border-color: var(--text-muted); }

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.hero {
  display: none;
  text-align: center;
  padding: 18px 20px 4px;
}
.hero h1 { font-size: 24px; font-weight: 600; margin: 0; }

.main.is-empty .content { justify-content: center; }
.main.is-empty .hero { display: block; }
.main.is-empty .messages { display: none; }
.main.is-empty .composer-wrap { border-top: none; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 8px;
}

.msg-row {
  max-width: 780px;
  margin: 0 auto 22px;
  padding: 0 20px;
  display: flex;
  gap: 14px;
}
.msg-row.user { justify-content: flex-end; }

.bubble {
  max-width: 70%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-row.user .bubble { background: var(--bubble-user); border-bottom-right-radius: 4px; }
.msg-row.assistant .bubble { background: transparent; padding-left: 0; max-width: 100%; }
.msg-row.assistant.error .bubble { color: var(--danger); }

.cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--text-main);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Composer */
.composer-wrap {
  padding: 12px 20px 10px;
}

.composer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 10px 10px 18px;
}

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

#sendBtn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
#sendBtn:disabled { opacity: 0.35; cursor: not-allowed; }

.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 620px;
  margin: 10px auto 0;
}

/* Placeholder views */
.placeholder-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
}
.placeholder-view h2 { color: var(--text-main); margin: 0; font-size: 20px; }
.ghost-btn {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13.5px;
  cursor: pointer;
}
.ghost-btn:hover { background: var(--bg-card); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  position: relative;
  background: #1b1b1b;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 6px; font-size: 20px; text-align: center; }
.modal-sub { margin: 0 0 20px; font-size: 13.5px; color: var(--text-muted); text-align: center; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }

.social-buttons { display: flex; flex-direction: column; gap: 8px; }
.social-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #232323;
  color: var(--text-main);
  font-size: 14px;
  cursor: not-allowed;
  opacity: 0.55;
}
.social-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  background: #3a3a3a;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

#authForm { display: flex; flex-direction: column; gap: 10px; }
#authForm input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
}
#authForm input:focus { border-color: var(--text-muted); }

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.auth-submit {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 18px 0 0;
}
.auth-toggle button {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 0 0 4px;
  font-size: 13px;
}

/* Pricing modal */
.pricing-modal { max-width: 780px; }
.plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 10px;
}
.plan-card {
  position: relative;
  background: #202020;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
}
.plan-card.highlighted { border-color: var(--brand); }
.plan-badge {
  position: absolute;
  top: -10px;
  right: 16px;
  background: var(--brand);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
}
.plan-card h3 { margin: 4px 0 4px; font-size: 15px; }
.price { font-size: 26px; font-weight: 700; margin: 0 0 14px; }
.price span { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.plan-card ul { list-style: none; margin: 0 0 16px; padding: 0; flex: 1; }
.plan-card li {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 5px 0;
  padding-left: 18px;
  position: relative;
}
.plan-card li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--brand);
}
.plan-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 10px;
  padding: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.plan-btn:disabled { opacity: 0.5; cursor: default; }
.plan-btn.primary { background: var(--accent); color: var(--accent-text); border: none; }

.pricing-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin: 18px 0 0;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a2a;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 100;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
