:root {
  --bg-color: #080c14;
  --card-bg: rgba(255, 255, 255, 0.035);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-hover-border: rgba(99, 102, 241, 0.3);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent-cyan: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success: #10b981;
}

body, html {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow-x: hidden;
}

.background-blob {
  position: fixed;
  top: -10%;
  left: -10%;
  width: 55vw;
  height: 55vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(0,0,0,0) 70%);
  border-radius: 50%;
  z-index: -1;
  animation: float 14s infinite alternate ease-in-out;
}

.blob-2 {
  top: 50%;
  left: 55%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.09) 0%, rgba(0,0,0,0) 70%);
  animation-delay: -7s;
}

@keyframes float {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(35px) scale(1.08); }
}

/* ── Login Screen ─────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.login-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: cardEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardEntrance {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.logo-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #000;
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.3), inset 0 0 15px rgba(255, 255, 255, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.logo-circle:hover {
  transform: scale(1.03);
  box-shadow: 0 0 45px rgba(56, 189, 248, 0.4);
}

.login-head-icon {
  width: 82px;
  height: 82px;
  object-fit: contain;
}

.login-font-logo {
  height: 26px;
  max-width: 240px;
  object-fit: contain;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
}

.login-tagline {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 20px 0;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 6px 14px;
  border-radius: 20px;
  color: #a5b4fc;
  font-size: 0.76rem;
  font-weight: 500;
  margin-bottom: 28px;
}

.login-form {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  padding-right: 48px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  background: transparent !important;
  border: none !important;
  color: var(--text-dim) !important;
  padding: 6px !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.toggle-password-btn:hover {
  color: var(--text-main) !important;
}

.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  text-transform: none !important;
  letter-spacing: normal !important;
}

.remember-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.login-btn {
  margin-top: 10px;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.login-error {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.4;
  margin-top: 4px;
}

.shake {
  animation: shakeAnim 0.4s ease-in-out;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ── Main App Layout ──────────────────────────────────────────────────────── */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 30px 20px 60px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--card-border);
  flex-wrap: wrap;
  gap: 16px;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-head-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.brand-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-font-logo {
  height: 20px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.session-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--card-border) !important;
  color: var(--text-muted) !important;
  padding: 6px 14px !important;
  font-size: 0.82rem !important;
  border-radius: 8px !important;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #fca5a5 !important;
}

/* ── Content Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px 32px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  transition: border-color 0.3s, transform 0.2s;
}

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

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.4s ease forwards;
}

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

h2 {
  margin-top: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

h3 {
  font-size: 1.05rem;
  margin-top: 22px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-weight: 600;
}

p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-top: 6px;
}

.form-group {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 42px;
}

select option {
  background: #0f172a;
  color: #fff;
  padding: 8px;
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

button:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none !important;
}

button.secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

.context-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.context-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 20px;
  color: #a5b4fc;
  font-size: 0.8rem;
  font-weight: 600;
}

.context-box, .response-box, .explanation-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 18px 20px;
  font-size: 0.95rem;
  line-height: 1.65;
  margin-top: 12px;
  white-space: pre-wrap;
}

.response-box {
  border-left: 4px solid var(--primary);
  background: rgba(99, 102, 241, 0.05);
  font-size: 1.05rem;
  font-weight: 500;
  color: #f1f5f9;
}

.explanation-box {
  border-left: 4px solid #38bdf8;
  background: rgba(56, 189, 248, 0.05);
  color: var(--text-muted);
  font-size: 0.92rem;
}

.loader {
  margin-top: 16px;
  color: #a5b4fc;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.loader::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  box-sizing: border-box;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  animation: cardEntrance 0.3s ease;
}

.modal-card h3 {
  margin-top: 0;
  color: var(--text-main);
  font-size: 1.3rem;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 16px;
}

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

.auth-steps {
  text-align: left;
  margin: 14px 0;
  padding-left: 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.auth-btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}

.auth-btn:hover {
  opacity: 0.9;
}

/* ── Split Layout & Live Chat Transcript ─────────────────────────────────── */
.analysis-split-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  margin-top: 18px;
  align-items: start;
}

.analysis-left-col {
  display: flex;
  flex-direction: column;
}

.analysis-right-col {
  display: flex;
  flex-direction: column;
}

.chat-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.chat-feed-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.feed-live-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  color: #34d399;
  font-size: 0.76rem;
  font-weight: 600;
}

.chat-feed-container {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  height: 520px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}

/* Custom Sleek Scrollbar */
.chat-feed-container::-webkit-scrollbar {
  width: 6px;
}
.chat-feed-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
.chat-feed-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
.chat-feed-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.feed-empty {
  margin: auto;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-style: italic;
  text-align: center;
}

/* ── Chat Speech Bubbles ─────────────────────────────────────────────────── */
.chat-bubble {
  max-width: 84%;
  padding: 11px 15px;
  font-size: 0.88rem;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: fadeIn 0.3s ease;
  word-break: break-word;
}

/* User Bubble (Xavier / "You") - Indigo Accent, Right Aligned */
.bubble-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(79, 70, 229, 0.18) 100%);
  border: 1px solid rgba(99, 102, 241, 0.48);
  border-radius: 16px 16px 3px 16px;
  color: #f8fafc;
}

.bubble-user .bubble-header {
  color: #a5b4fc;
}

.bubble-user .bubble-sender {
  color: #c7d2fe;
  font-weight: 700;
}

/* Interlocutor Bubble (Counterpart / Boss / Peer) - Emerald / Teal Accent, Left Aligned */
.bubble-other {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.16) 0%, rgba(5, 150, 105, 0.12) 100%);
  border: 1px solid rgba(16, 185, 129, 0.38);
  border-radius: 16px 16px 16px 3px;
  color: #f1f5f9;
}

.bubble-other .bubble-header {
  color: #6ee7b7;
}

.bubble-other .bubble-sender {
  color: #a7f3d0;
  font-weight: 700;
}

.bubble-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 5px;
  font-size: 0.76rem;
}

.bubble-time {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.bubble-text {
  white-space: pre-wrap;
  color: var(--text-main);
}

@media (max-width: 960px) {
  .analysis-split-layout {
    grid-template-columns: 1fr;
  }
  .chat-feed-container {
    height: 420px;
  }
}

