/* ScoutQSI — private alpha chat UI */

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

:root {
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #181c27;
  --surface-3: #1f2433;
  --border: #2a3144;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --accent-strong: #2563eb;
  --text: #e8edf7;
  --text-dim: #9aa6bd;
  --text-muted: #6b7280;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-width: 280px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", monospace;
  --max-chat: 760px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

body.modal-open { overflow: hidden; }

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

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-lockup .product-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.brand-lockup .assistant-name {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 2px;
}

.brand-lockup .tech-line,
.brand-lockup .corp-line {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

#btn-new-chat {
  margin: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

#btn-new-chat:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 16px 6px;
}

#conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.conversation-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 13px;
}

.conversation-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.conversation-item.active {
  background: var(--accent-soft);
  border-color: rgba(79, 140, 255, 0.25);
  color: var(--text);
}

.conversation-item .title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item .meta {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.alpha-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 999px;
  padding: 6px 10px;
}

/* Main */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: radial-gradient(circle at top, rgba(79, 140, 255, 0.08), transparent 36%), var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 21, 29, 0.85);
  backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

#btn-sidebar-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
}

.topbar-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

#chat-area {
  flex: 1;
  overflow-y: auto;
}

#messages {
  max-width: var(--max-chat);
  margin: 0 auto;
  padding: 24px 20px 12px;
}

/* Empty state */
#empty-state {
  max-width: 680px;
  margin: 48px auto 0;
  text-align: center;
  padding: 0 20px 24px;
}

.empty-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  box-shadow: 0 0 40px rgba(79, 140, 255, 0.25);
}

.empty-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.6px;
}

.empty-tagline,
.empty-powered {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}

.empty-description {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}

.empty-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.empty-prompt-btn,
.suggestion-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
}

.empty-prompt-btn:hover,
.suggestion-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Messages */
.msg-group { margin-bottom: 22px; }

.msg-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.msg-label.user { text-align: right; color: #7aa7ff; }

.bubble {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
}

.bubble-user {
  margin-left: auto;
  background: linear-gradient(180deg, #244684, #1b3566);
  border: 1px solid rgba(79, 140, 255, 0.25);
  border-bottom-right-radius: 6px;
}

.bubble-scout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.bubble-scout pre {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  font-family: var(--mono);
  font-size: 12px;
}

.bubble-scout code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

.bubble-scout strong { color: #93c5fd; }
.bubble-scout blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-dim);
  margin: 8px 0;
}

.tool-disclosure { margin: -6px 0 10px; }

.tool-summary-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tool-detail {
  display: none;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.tool-detail.open { display: block; }

.tool-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.tool-row:last-child { border-bottom: none; }

.tool-name {
  font-family: var(--mono);
  color: var(--accent);
  min-width: 160px;
}

.source-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.source-label {
  font-size: 10px;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid var(--border);
}

.game-cards {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.game-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.game-card-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.stat-block {
  background: var(--surface-3);
  border-radius: 10px;
  padding: 8px 10px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.loading-indicator,
.progress-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.dot-flashing {
  display: inline-flex;
  gap: 5px;
}

.dot-flashing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s infinite ease-in-out;
}

.dot-flashing span:nth-child(2) { animation-delay: 0.15s; }
.dot-flashing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.error-bubble {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fecaca;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.retry-btn {
  margin-top: 8px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: transparent;
  color: #fecaca;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

/* Composer */
#input-area {
  border-top: 1px solid var(--border);
  background: rgba(18, 21, 29, 0.92);
  padding: 14px 18px 18px;
}

#input-inner {
  max-width: var(--max-chat);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px 10px 16px;
}

#input-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#user-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  resize: none;
  min-height: 24px;
  max-height: 140px;
  font: inherit;
}

#send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: var(--accent-strong);
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
}

#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  max-width: var(--max-chat);
  margin: 8px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* Access modal */
#access-modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

#access-modal.open { display: flex; }

.access-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.access-card h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.access-card p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
}

#access-code-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}

#access-error {
  color: #fca5a5;
  font-size: 12px;
  min-height: 18px;
  margin-top: 8px;
}

#access-submit {
  width: 100%;
  margin-top: 14px;
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--accent-strong);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
  }

  #sidebar.open { transform: translateX(0); }

  #btn-sidebar-toggle { display: inline-grid; place-items: center; }

  .sidebar-backdrop.visible { display: block; }

  .bubble { max-width: 94%; }
}
