:root {
  --bg: #0b0c10;
  --panel: #12141c;
  --panel-2: #181b26;
  --panel-3: #202433;
  --border: #262b3d;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --primary: #f97316;
  --primary-hover: #ea580c;
  --accent: #6366f1;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue-dot: #3b82f6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Grok Bot Cute Blob Avatar with 2 Eyes */
.grok-blob {
  width: 38px;
  height: 38px;
  border-radius: 42% 58% 55% 45% / 48% 45% 55% 52%;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  position: relative;
  transform: rotate(-8deg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.grok-blob span {
  width: 4px;
  height: 9px;
  background: #0b0c10;
  border-radius: 99px;
  display: block;
  transform: rotate(-10deg);
}

.big-blob {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
}

.big-blob span {
  width: 6px;
  height: 14px;
}

/* AUTH VIEW */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #1e2235 0%, #0b0c10 70%);
}

.auth-card {
  width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.auth-logo {
  text-align: center;
  margin-bottom: 20px;
}

.auth-logo h1 {
  font-size: 20px;
  margin-bottom: 6px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.auth-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.auth-tab.active {
  background: var(--panel-3);
  color: var(--text);
}

.auth-form,
.modal-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

input,
textarea,
select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font: inherit;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 9px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  transition: 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover,
.btn-secondary:hover {
  color: var(--text);
  border-color: #4b5563;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 12px;
}

.error-msg {
  color: var(--red);
  font-size: 12.5px;
  text-align: center;
}

/* APP SHELL */
.app-shell {
  display: grid;
  grid-template-columns: 255px 1fr;
  height: 100vh;
}

/* SIDEBAR (Grok Bot style) */
.bot-sidebar {
  background: #0d0f15;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-title {
  font-weight: 700;
  font-size: 14.5px;
}

.sidebar-sub {
  font-size: 11px;
  color: var(--green);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.profile-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border-radius: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s;
}

.profile-item:hover {
  background: var(--panel);
}

.profile-item.active {
  background: var(--panel-2);
  border-color: var(--border);
}

.profile-item-info {
  flex: 1;
  min-width: 0;
}

.profile-item-name {
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile-item-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-dot);
  display: inline-block;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 6px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
}

/* WORKSPACE & HEADER */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.bot-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.bot-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bot-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.bot-title-row h2 {
  font-size: 16px;
}

.pill {
  background: var(--panel-3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
}

.pill-persona {
  color: #c4b5fd;
  border-color: #4c1d95;
  background: rgba(139, 92, 246, 0.14);
}

.pill-delay {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
}

.life-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.life-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.bot-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.goal-banner {
  font-size: 12px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  padding: 4px 10px;
  border-radius: 8px;
  max-width: 520px;
}

.goal-label {
  color: var(--primary);
  font-weight: 700;
  margin-right: 4px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* 3-COLUMN CRM GRID */
.crm-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 295px 1fr 395px;
  overflow: hidden;
}

.crm-col {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.col-contacts {
  background: var(--panel);
}

.col-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.col-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 12.5px;
}

.stage-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stage-pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 99px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}

.stage-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.contact-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-card {
  padding: 10px 11px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s;
}

.contact-card:hover {
  border-color: var(--border);
}

.contact-card.active {
  border-color: var(--primary);
  background: var(--panel-3);
}

.contact-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.contact-name {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.avatar-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.contact-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

.meter-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.meter {
  width: 48px;
  height: 5px;
  background: #272b3a;
  border-radius: 99px;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: var(--green);
}

/* CHAT COLUMN */
.col-chat {
  background: var(--bg);
}

.chat-header {
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.small-bio {
  font-size: 12px;
  margin-top: 2px;
}

.chat-controls {
  display: flex;
  gap: 6px;
}

.select-sm {
  padding: 5px 8px;
  font-size: 12px;
}

.next-action-bar {
  background: rgba(99, 102, 241, 0.12);
  border-bottom: 1px solid rgba(99, 102, 241, 0.28);
  padding: 7px 16px;
  font-size: 12px;
  color: #c7d2fe;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.msg-row.bot {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.contact {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-thought {
  font-size: 11px;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.12);
  border: 1px dashed rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  padding: 4px 8px;
  margin-bottom: 4px;
}

.msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.msg-row.bot .msg-bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-row.contact .msg-bubble {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 3px;
}

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

.ai-draft-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tiny-label {
  font-size: 11px;
}

.btn-chip {
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: #e0e7ff;
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
}

.btn-chip:hover {
  border-color: var(--accent);
}

.btn-chip-goal {
  background: rgba(249, 115, 22, 0.15);
  border-color: rgba(249, 115, 22, 0.45);
  color: #fed7aa;
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thought-input {
  padding: 6px 10px;
  font-size: 12px;
}

.composer-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* COLUMN 3: INTEL PANEL (Psychology, Evaluation, Memory, Goal, Bot Character) */
.col-intel {
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
  gap: 10px;
  border-right: none;
}

.intel-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.intel-card h4 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #d1d5db;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.psych-archetype {
  font-weight: 700;
  color: #c4b5fd;
  font-size: 13.5px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--panel-3);
  border: 1px solid var(--border);
}

.tag-good {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.tag-bad {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.adaptation-box {
  background: rgba(99, 102, 241, 0.11);
  border-left: 3px solid var(--accent);
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 12.5px;
}

.bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}

.bullet-list li {
  padding-left: 14px;
  position: relative;
}

.bullet-list li::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--primary);
}

.inline-add {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.inline-add input {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
}

/* MODALS & TOAST */
.modal {
  margin: auto;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  width: 480px;
  max-width: 94vw;
}

.modal-wide {
  width: 640px;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--panel-3);
  border: 1px solid var(--primary);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
