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

:root {
  --bg: #0d0f14;
  --bg2: #151820;
  --bg3: #1e2230;
  --border: #262c3e;
  --text: #e8eaf0;
  --text-muted: #7a8299;
  --accent: #4f8ef7;
  --accent-dark: #2d6fd4;
  --user-bubble: #1a3a6e;
  --radius: 18px;
  --radius-sm: 10px;
  --header-h: 62px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ===== HEADER ===== */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(13,15,20,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

.btn-back {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-back:hover { background: var(--border); }
.btn-back.hidden { display: none; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.logo-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #E85D04, #F77F00);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-name { font-weight: 700; font-size: 15px; }
.logo-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.dot {
  width: 7px; height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}


/* ===== CHAT AREA ===== */
#chat {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  padding: 20px 0 40px;
  scroll-behavior: smooth;
}


.chat-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== MESSAGE ROW ===== */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: fadeUp 0.2s ease;
}

.msg-row.bot { justify-content: flex-start; }
.msg-row.user { justify-content: flex-end; }

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

/* ===== AVATARS ===== */
.msg-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #E85D04, #F77F00);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  align-self: flex-end;
}

/* ===== BUBBLES ===== */
.bubble {
  max-width: 75%;
  padding: 11px 16px;
  line-height: 1.55;
  font-size: 14px;
}

.bubble.bot {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  color: var(--text);
}

.bubble.user {
  background: var(--user-bubble);
  border: 1px solid rgba(79,142,247,0.3);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  color: var(--text);
  text-align: right;
}

/* ===== TYPING INDICATOR ===== */
.typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  width: fit-content;
}
.typing span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ===== CHOICES BLOCK ===== */
.choices-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 40px;
  padding-top: 4px;
  animation: fadeUp 0.25s ease;
}

.choice-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
}

.choice-btn:hover {
  background: var(--bg2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.choice-btn:active { transform: translateY(0); }

.choice-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}

.choice-btn.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* ===== ARTICLE CONTENT ===== */
.article-body {
  font-size: 14px;
  line-height: 1.7;
}

.article-body h1 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #fff;
}
.article-body h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 18px 0 8px;
  color: #fff;
}
.article-body h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 14px 0 6px;
}
.article-body p {
  margin-bottom: 10px;
  color: var(--text);
}
.article-body ul, .article-body ol {
  margin: 8px 0 12px 18px;
}
.article-body li {
  margin-bottom: 4px;
  color: var(--text);
}
.article-body strong { color: #fff; font-weight: 600; }
.article-body em { color: var(--text-muted); font-style: italic; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 12px 0;
  background: rgba(79,142,247,0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: #a8b8d8;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.article-body th {
  background: var(--bg3);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.article-body td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.article-body tr:last-child td { border-bottom: none; }

.article-body pre {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 12px;
  color: #a0c4ff;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.article-body code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #a0c4ff;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Category badge in choices */
.cat-emoji { margin-right: 6px; }


/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .bubble { max-width: 88%; font-size: 13px; }
  .choice-btn { font-size: 12px; padding: 8px 13px; }
  .choices-row { padding-left: 34px; gap: 6px; }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  font-size: 48px;
  background: linear-gradient(135deg, #E85D04, #F77F00);
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: -8px;
}

.login-divider {
  width: 40px;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
}

.login-info {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ===== LOGIN FORM ===== */
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.login-input::placeholder { color: var(--text-muted); }
.login-input:focus { border-color: var(--accent); }

.login-submit-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 2px;
}
.login-submit-btn:hover { background: var(--accent-dark); }
.login-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
  color: #f87171;
  font-size: 13px;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 8px;
  padding: 10px 14px;
  width: 100%;
  text-align: center;
}

.login-footer {
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0.6;
}

/* ===== USER BUTTON & MENU ===== */
.btn-user {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg3);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.btn-user:hover { border-color: var(--accent); }

.user-avatar {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.user-menu {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  right: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  z-index: 200;
  min-width: 220px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-menu.hidden { display: none; }

.user-info-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.logout-btn {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2);
  color: #f87171;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.15s;
}
.logout-btn:hover { background: rgba(248,113,113,0.2); }

/* ===== UTILS ===== */
.hidden { display: none !important; }
