/**
 * OsirisBrain Professional Chat — Premium Design System
 * Date: 2026-02-15
 *
 * Three-screen flow: Login → Professional Lobby → Chat
 * Apple-inspired white minimal design with Inter font.
 * Each professional card has its own accent color.
 */

/* ─── Design Tokens ─── */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f0f0f2;
  --bg-input: #f5f5f7;
  --bg-input-hover: #efeff1;

  --border-color: #d2d2d7;
  --border-light: #e5e5ea;
  --border-focus: #0071e3;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #aeaeb2;
  --text-accent: #0071e3;

  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: rgba(0, 113, 227, 0.08);
  --accent-ring: rgba(0, 113, 227, 0.3);

  --success: #34c759;
  --danger: #ff3b30;
  --warning: #ff9500;
  --icon-color: #86868b;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-display:
    "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Menlo", "Monaco", monospace;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-card-hover: 0 4px 20px rgba(0, 0, 0, 0.08), 0 8px 32px rgba(0, 0, 0, 0.04);

  --transition-fast: 120ms ease;
  --transition-normal: 200ms ease;
  --transition-smooth: 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Reset ─── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════
   SCREEN 1: LOGIN
   ═══════════════════════════════════════════════════ */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-container.hidden {
  display: none;
}

.login-card {
  width: 380px;
  padding: 44px 36px 36px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: slideUp 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.login-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--icon-color);
}

.login-logo svg {
  width: 48px;
  height: 48px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

.license-input-group {
  margin-bottom: 10px;
}

.license-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  text-align: center;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.license-input:hover {
  background: var(--bg-input-hover);
}

.license-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.license-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.connect-btn {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  color: #ffffff;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-normal);
  box-shadow: var(--shadow-md);
  margin-top: 6px;
}

.connect-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.01);
  box-shadow: var(--shadow-lg);
}

.connect-btn:active {
  transform: scale(0.99);
}

.connect-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 2026-02-19: Remember Me checkbox */
.remember-me {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  cursor: pointer;
  user-select: none;
}

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

.remember-me span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.login-error {
  margin-top: 16px;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
  min-height: 18px;
  font-weight: 500;
  display: none;
}

.login-error.active {
  display: block;
}

/* ═══════════════════════════════════════════════════
   SCREEN 2: PROFESSIONAL LOBBY
   ═══════════════════════════════════════════════════ */
.lobby-container {
  display: none;
  min-height: 100vh;
  background: var(--bg-secondary);
  overflow-y: auto;
}

.lobby-container.active {
  display: block;
}

.lobby-inner {
  max-width: 840px;
  margin: 0 auto;
  padding: 32px 20px 24px;
  animation: slideUp 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.lobby-header {
  text-align: center;
  margin-bottom: 24px;
}

.lobby-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.lobby-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  max-width: 440px;
  margin: 0 auto;
}

/* ─── Professional Grid ─── */
.lobby-grid {
  display: grid;
  gap: 8px;
}

/* Hero card (Osiris) spans full width */
.professional-card.hero {
  grid-column: 1 / -1;
}

/* Desktop: 3 columns for regular cards */
@media (min-width: 640px) {
  .lobby-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ─── Professional Card ─── */
/* 2026-02-20: Compact cards — smaller padding, tighter spacing */
.professional-card {
  background: var(--bg-surface);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--transition-smooth),
    box-shadow var(--transition-smooth),
    border-color var(--transition-smooth);
  box-shadow: var(--shadow-sm);
  animation: fadeInScale 0.4s cubic-bezier(0.25, 0.1, 0.25, 1) backwards;
}

/* Stagger animation per card */
.professional-card:nth-child(1) {
  animation-delay: 0ms;
}

.professional-card:nth-child(2) {
  animation-delay: 40ms;
}

.professional-card:nth-child(3) {
  animation-delay: 80ms;
}

.professional-card:nth-child(4) {
  animation-delay: 120ms;
}

.professional-card:nth-child(5) {
  animation-delay: 160ms;
}

.professional-card:nth-child(6) {
  animation-delay: 200ms;
}

.professional-card:nth-child(7) {
  animation-delay: 240ms;
}

.professional-card:nth-child(8) {
  animation-delay: 280ms;
}

.professional-card:nth-child(9) {
  animation-delay: 320ms;
}

.professional-card:nth-child(10) {
  animation-delay: 360ms;
}

.professional-card:nth-child(11) {
  animation-delay: 400ms;
}

.professional-card:nth-child(12) {
  animation-delay: 440ms;
}

.professional-card:nth-child(13) {
  animation-delay: 480ms;
}

/* No accent stripe — clean Apple white */

.professional-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-color);
}

.professional-card:active {
  transform: translateY(-1px) scale(0.99);
}

/* Hero card (Osiris) — special styling */
/* 2026-02-20: Compact hero card */
.professional-card.hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-light);
}

.professional-card.hero .professional-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.professional-card.hero .professional-icon svg {
  width: 20px;
  height: 20px;
}

.professional-card.hero .professional-content {
  flex: 1;
}

.professional-card.hero .professional-name {
  font-size: 14px;
}

.professional-card.hero .professional-tagline {
  font-size: 12px;
}

.professional-card.hero .hero-badge {
  display: inline-block;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* Card inner layout */
/* 2026-02-20: Compact icon + name */
.professional-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  transition: transform var(--transition-spring);
}

.professional-card:hover .professional-icon {
  transform: scale(1.05);
}

.professional-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
  color: var(--icon-color);
}

.professional-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
  margin-bottom: 2px;
}

/* 2026-02-17: Provider badge on professional cards */
.provider-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.professional-tagline {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ─── Lobby Footer ─── */
.lobby-footer {
  text-align: center;
  margin-top: 32px;
}

.lobby-disconnect-btn {
  height: 32px;
  padding: 0 16px;
  background: none;
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.lobby-disconnect-btn:hover {
  color: var(--danger);
  border-color: rgba(255, 59, 48, 0.3);
  background: rgba(255, 59, 48, 0.05);
}

/* ═══════════════════════════════════════════════════
   TAB BAR — Chrome-Style Browser Tabs
   2026-02-17: Dark strip background, rounded-top active tab
   blending into content below, inactive tabs recessed.
   ═══════════════════════════════════════════════════ */
.tab-bar {
  display: flex;
  align-items: flex-end;
  padding: 0 8px;
  height: 38px;
  background: #dee1e6;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 0;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-bar__tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  flex: 1;
  min-width: 0;
  height: 100%;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  height: 30px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: #5f6368;
  background: transparent;
  border: none;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
  max-width: 200px;
  min-width: 80px;
  position: relative;
  margin-bottom: 0;
}

.tab-item:hover {
  background: rgba(255, 255, 255, 0.5);
  color: #3c4043;
}

.tab-item--active {
  background: #ffffff;
  color: #1a1a1a;
  font-weight: 600;
  box-shadow:
    0 -1px 3px rgba(0, 0, 0, 0.06),
    -1px 0 2px rgba(0, 0, 0, 0.04),
    1px 0 2px rgba(0, 0, 0, 0.04);
  z-index: 1;
}

.tab-item--active:hover {
  background: #ffffff;
}

.tab-item:not(.tab-item--active) + .tab-item:not(.tab-item--active)::before {
  content: "";
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background: rgba(0, 0, 0, 0.12);
}

.tab-item__name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-item__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  color: #5f6368;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  opacity: 0;
  transition:
    opacity 0.15s ease,
    background 0.15s ease;
  flex-shrink: 0;
}

.tab-item:hover .tab-item__close,
.tab-item--active .tab-item__close {
  opacity: 0.6;
}

.tab-item__close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.tab-bar__add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: #5f6368;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
  margin-bottom: 4px;
  transition: all 0.15s ease;
}

.tab-bar__add:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #3c4043;
}

/* ═══════════════════════════════════════════════════
   SCREEN 3: CHAT
   ═══════════════════════════════════════════════════ */
.chat-container {
  display: none;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

.chat-container.active {
  display: flex;
}

/* ─── Chat Header ─── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--border-light);
  flex-shrink: 0;
}

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

.chat-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}

.chat-header-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
  color: var(--icon-color);
}

.chat-header-info h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    background var(--transition-normal),
    box-shadow var(--transition-normal);
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.connecting {
  background: var(--warning);
  animation: spin 1s linear infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.6;
    box-shadow: 0 0 4px rgba(52, 199, 89, 0.2);
  }

  50% {
    opacity: 1;
    box-shadow: 0 0 12px rgba(52, 199, 89, 0.6);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.status-text {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

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

.switch-btn {
  height: 30px;
  padding: 0 12px;
  background: none;
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}

.switch-btn svg {
  width: 14px;
  height: 14px;
}

.switch-btn:hover {
  color: var(--accent);
  border-color: var(--accent-ring);
  background: var(--accent-light);
}

.disconnect-btn {
  height: 30px;
  padding: 0 12px;
  background: none;
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.disconnect-btn:hover {
  color: var(--danger);
  border-color: rgba(255, 59, 48, 0.3);
  background: rgba(255, 59, 48, 0.05);
}

/* ─── No Agent Banner ─── */
.no-agent-banner {
  display: none;
  padding: 10px 20px;
  background: rgba(255, 149, 0, 0.06);
  border-bottom: 0.5px solid rgba(255, 149, 0, 0.12);
  text-align: center;
  font-size: 12px;
  color: var(--warning);
  font-weight: 500;
}

.no-agent-banner.active {
  display: block;
}

/* ─── Messages ─── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: fadeIn 0.2s ease-out;
}

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

.message.agent {
  align-self: flex-start;
  align-items: flex-start;
}

.message.system {
  align-self: center;
  align-items: center;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message.agent .message-bubble {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  /* FIX 2026-02-17: Use normal white-space for agent bubbles.
       HTML block elements (p, h3, ul, ol) handle spacing now. */
  white-space: normal;
}

/* ─── Markdown Styles Inside Agent Bubbles ─── */
/* FIX 2026-02-17: Proper web rendering of AI markdown responses.
   OsirisBrain chat is a web chat, not WhatsApp — render properly. */

.message.agent .message-bubble p {
  margin: 0 0 6px 0;
}

.message.agent .message-bubble p:last-child {
  margin-bottom: 0;
}

.message.agent .message-bubble h3,
.message.agent .message-bubble h4,
.message.agent .message-bubble h5,
.message.agent .message-bubble h6 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  margin: 10px 0 4px 0;
}

.message.agent .message-bubble h3 {
  font-size: 15px;
}

.message.agent .message-bubble h4 {
  font-size: 14px;
}

.message.agent .message-bubble h5,
.message.agent .message-bubble h6 {
  font-size: 13px;
}

.message.agent .message-bubble h3:first-child,
.message.agent .message-bubble h4:first-child,
.message.agent .message-bubble h5:first-child {
  margin-top: 0;
}

.message.agent .message-bubble strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message.agent .message-bubble em {
  font-style: italic;
}

.message.agent .message-bubble code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
  border: 0.5px solid var(--border-light);
}

.message.agent .message-bubble ul,
.message.agent .message-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.message.agent .message-bubble li {
  margin: 2px 0;
  line-height: 1.5;
}

.message.agent .message-bubble hr {
  border: none;
  border-top: 0.5px solid var(--border-light);
  margin: 8px 0;
}

.message.agent .message-bubble a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.message.agent .message-bubble a:hover {
  text-decoration: underline;
}

.message.agent .message-bubble br {
  line-height: 0.6;
}

.message.system .message-bubble {
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 10px;
}

.message-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* 2026-02-19: Double check marks on user messages (delivery confirmation) */
.message-checks {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -1px;
  margin-left: 2px;
}

/* 2026-02-17: Phase 5 — Rating buttons for agent message feedback */
.message-rating {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message:hover .message-rating {
  opacity: 1;
}

.rating-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition:
    opacity 0.15s,
    transform 0.15s;
}

.rating-btn:hover {
  opacity: 1;
  transform: scale(1.2);
}

.rating-btn.selected {
  opacity: 1;
  transform: scale(1.1);
}

/* ─── Typing indicator ─── */
.typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.typing-indicator.active {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-5px);
  }
}

/* ─── Cost Footer (2026-02-17) ─── */
.cost-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  background: var(--bg-primary);
  border-top: 0.5px solid var(--border-light);
  flex-shrink: 0;
  font-family: var(--font);
  transition: background var(--transition-fast);
}

.cost-footer--warning {
  background: rgba(255, 149, 0, 0.04);
}

.cost-footer--danger {
  background: rgba(255, 59, 48, 0.04);
}

.cost-footer--over {
  background: rgba(255, 59, 48, 0.08);
}

.cost-footer__left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cost-footer__label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cost-footer__amount {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.cost-footer__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cost-footer__bar {
  width: 80px;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.cost-footer__bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition:
    width var(--transition-normal),
    background var(--transition-fast);
}

.cost-footer__bar-fill--warning {
  background: var(--warning);
}

.cost-footer__bar-fill--danger {
  background: var(--danger);
}

.cost-footer__budget {
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ─── Input Area — Apple iMessage Style (2026-02-19) ─── */
.chat-input-area {
  padding: 12px 16px;
  background: var(--bg-primary);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: 22px;
  padding: 4px 4px 4px 6px;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--border-color);
}

/* Action buttons (image attach, mic) — delicate monochrome icons */
.input-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--icon-color);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    color var(--transition-fast),
    background var(--transition-fast),
    opacity var(--transition-fast);
  padding: 0;
}

.input-action-btn:hover:not(:disabled) {
  color: var(--text-secondary);
  background: var(--bg-surface-hover);
}

.input-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Mic recording state — pulsing red */
.input-action-btn.recording {
  color: var(--danger);
  animation: pulse 1.5s ease-in-out infinite;
}

.chat-input {
  flex: 1;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 32px;
  line-height: 1.4;
  box-shadow: none;
}

.chat-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

/* Send button — Apple-style circle */
.send-btn {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
  flex-shrink: 0;
  box-shadow: none;
  padding: 0;
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.08);
}

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

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ─── Image Preview Strip ─── */
.image-preview-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 0;
}

.image-preview-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 0.5px solid var(--border-light);
}

.image-preview-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-remove {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.image-preview-remove:hover {
  color: var(--danger);
  background: rgba(255, 59, 48, 0.08);
}

/* ─── Focus ring ─── */
:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 1px;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 639px) {
  .lobby-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lobby-inner {
    padding: 32px 16px 24px;
  }

  .lobby-title {
    font-size: 24px;
  }

  .lobby-subtitle {
    font-size: 13px;
  }

  .professional-card {
    padding: 18px 16px;
  }

  .professional-card.hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 22px 20px;
  }

  .professional-icon {
    width: 38px;
    height: 38px;
    margin-bottom: 10px;
  }

  .professional-icon svg {
    width: 20px;
    height: 20px;
  }

  .professional-name {
    font-size: 13px;
  }

  .professional-tagline {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .login-card {
    width: 100%;
    padding: 32px 24px;
    border-radius: var(--radius-lg);
  }

  .message {
    max-width: 85%;
  }

  .chat-header {
    padding: 0 16px;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 16px;
  }

  .switch-btn span {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════
   CREATE CARD (dashed border, "+" icon)
   ═══════════════════════════════════════════════════ */
.professional-card.create-card {
  border: 1.5px dashed var(--border-color);
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
}

.professional-card.create-card:hover {
  border-color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.01);
  box-shadow: none;
}

.create-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  font-weight: 300;
}

.create-card-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Custom Section Divider ─── */
.lobby-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.lobby-divider-line {
  flex: 1;
  height: 0.5px;
  background: var(--border-light);
}

.lobby-divider-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* ─── Custom Badge ─── */
.custom-badge {
  display: inline-block;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ─── Delete button on custom cards ─── */
.custom-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition:
    opacity var(--transition-fast),
    color var(--transition-fast);
}

.professional-card:hover .custom-delete-btn {
  opacity: 1;
}

.custom-delete-btn:hover {
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════
   BUILDER MODAL
   ═══════════════════════════════════════════════════ */
.builder-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.builder-overlay.active {
  display: flex;
}

.builder-modal {
  width: 520px;
  max-height: 80vh;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.builder-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.builder-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-secondary);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.builder-close:hover {
  background: var(--bg-input-hover);
}

.builder-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.builder-body::-webkit-scrollbar {
  width: 4px;
}

.builder-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.builder-section {
  margin-bottom: 20px;
}

.builder-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.builder-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.builder-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.builder-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.builder-input::placeholder {
  color: var(--text-muted);
}

/* ─── Skill Input Row ─── */
.builder-skill-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.builder-skill-title {
  height: 36px;
  font-size: 13px;
}

.builder-textarea {
  width: 100%;
  min-height: 72px;
  max-height: 160px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  resize: vertical;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.builder-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.builder-textarea::placeholder {
  color: var(--text-muted);
}

.builder-add-skill-btn {
  align-self: flex-end;
  height: 32px;
  padding: 0 14px;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.builder-add-skill-btn:hover {
  background: var(--bg-input-hover);
  color: var(--text-primary);
}

/* ─── Fragment Cards (added skills) ─── */
.builder-fragments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.fragment-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-md);
  animation: fadeInScale 0.2s ease;
}

.fragment-card-content {
  flex: 1;
  min-width: 0;
}

.fragment-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.fragment-card-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.fragment-remove-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.fragment-remove-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--danger);
}

/* ─── Builder Footer ─── */
.builder-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 0.5px solid var(--border-light);
}

.builder-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

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

.builder-cancel-btn {
  height: 36px;
  padding: 0 16px;
  background: none;
  border: 0.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.builder-cancel-btn:hover {
  background: var(--bg-secondary);
}

.builder-save-btn {
  height: 36px;
  padding: 0 20px;
  background: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.builder-save-btn:hover {
  opacity: 0.85;
}

.builder-save-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ─── Builder Responsive ─── */
@media (max-width: 560px) {
  .builder-modal {
    width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }
}

/* ═══════════════════════════════════════════════════
   VOICE INDICATOR (2026-02-23)
   Displays an animated or static waveform pill when the
   AI responds with `MEDIA:/path` audio payload.
   ═══════════════════════════════════════════════════ */

.ai-voice-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 8px; /* Extra space before text */
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 980px; /* Apple pill style */
  width: fit-content;
  color: #1d1d1f;
}

.ai-voice-indicator .bar {
  width: 3px;
  height: 4px;
  background-color: var(--accent-ring);
  border-radius: 2px;
  opacity: 0.8;
}

/* Live Playing Animation */
.ai-voice-indicator.playing .bar {
  animation: voice-pulse 1s ease-in-out infinite;
  /* Stops after ~15 seconds (typical max talking time) */
  animation-iteration-count: 15;
  animation-fill-mode: forwards;
}

.ai-voice-indicator.playing .bar:nth-child(2) {
  animation-delay: 0.2s;
}
.ai-voice-indicator.playing .bar:nth-child(3) {
  animation-delay: 0.4s;
}
.ai-voice-indicator.playing .bar:nth-child(4) {
  animation-delay: 0.6s;
}

/* Historical Static State */
.ai-voice-indicator.static .bar {
  height: 8px; /* Fixed height for past messages */
  opacity: 0.4;
  background-color: #86868b;
}

@keyframes voice-pulse {
  0%,
  100% {
    height: 4px;
  }
  50% {
    height: 14px;
    background-color: #000;
    opacity: 1;
  }
}

/* ─── Evolving State Animation ─── */
.message--evolving {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 149, 0, 0.4); /* Golden border base */
  box-shadow: 0 0 15px rgba(255, 149, 0, 0.15); /* Soft outer glow */
  animation: evolvingPulse 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.message--evolving::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 149, 0, 0.1) 0%,
    rgba(200, 50, 48, 0.05) 50%,
    rgba(255, 215, 0, 0.05) 100%
  );
  z-index: 0;
  pointer-events: none;
  animation: gradientShift 3s infinite linear;
  background-size: 200% 200%;
}

.message--evolving .message-content {
  position: relative;
  z-index: 2; /* Keep text above the animated background */
}

/* Neural Canvas Background specifically inside evolving messages */
.message--evolving canvas.evolution-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.6;
  pointer-events: none;
  mix-blend-mode: overlay;
}

@keyframes evolvingPulse {
  0% {
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.4);
  }
  50% {
    box-shadow: 0 0 25px rgba(255, 59, 48, 0.3); /* Shifts to a ruby/danger glow */
    border-color: rgba(255, 59, 48, 0.6);
  }
  100% {
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.4);
  }
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ─── Markdown Elements (Tables, Code Blocks) ─── */
.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--border-light);
}

.message-bubble th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border-light);
}

.message-bubble td {
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border-light);
  color: var(--text-secondary);
}

.message-bubble tr:last-child td {
  border-bottom: none;
}

.message.user .message-bubble th,
.message.user .message-bubble td {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.message.user .message-bubble th {
  background: rgba(0, 0, 0, 0.1);
}

.message-bubble pre {
  background: var(--bg-secondary);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-primary);
}

.message.user .message-bubble pre {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
