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

:root {
  --bg:          #0a0a0a;
  --bg-surface:  #111111;
  --bg-raised:   #1a1a1a;
  --border:      #2a2a2a;
  --border-mid:  #333333;
  --text:        #f0f0f0;
  --text-muted:  #888888;
  --text-dim:    #555555;
  --accent:      #ffffff;
  --accent-dim:  #cccccc;
  --green:       #4ade80;
  --red:         #f87171;
  --mono:        'JetBrains Mono', monospace;
  --sans:        'Inter', system-ui, sans-serif;
  --radius:      6px;
  --transition:  160ms ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-dim);
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent-dim);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Header ───────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}

.header-inner {
  max-width: 780px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--text);
}

.logo-bracket {
  color: var(--text-muted);
}

.site-nav a {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text-muted);
  transition: color var(--transition);
}

.site-nav a:hover {
  color: var(--text);
}

/* ── Main ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* ── Hero ─────────────────────────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hero-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--accent);
}

.hero-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 300;
  margin-top: 0.25rem;
}

/* ── Bot Container ────────────────────────────────────── */
.bot-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Chat Window ──────────────────────────────────────── */
.chat-window {
  min-height: 340px;
  max-height: 480px;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
  width: 4px;
}

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

.chat-window::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 2px;
}

/* ── Messages ─────────────────────────────────────────── */
.message {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.6;
  animation: fadeSlideIn 200ms ease forwards;
}

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

.message-prefix {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.message-text {
  color: var(--text);
}

.bot-message .message-prefix {
  color: var(--text-muted);
}

.user-message .message-prefix {
  color: var(--text-dim);
}

.user-message .message-text {
  color: var(--text-muted);
}

.message.correct .message-prefix {
  color: var(--green);
}

.message.correct .message-text {
  color: var(--green);
}

.message.incorrect .message-prefix {
  color: var(--red);
}

.message.incorrect .message-text {
  color: var(--red);
}

.message.question .message-text {
  color: var(--accent);
  font-size: 0.9rem;
}

/* ── Score Bar ────────────────────────────────────────── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.score-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
}

.score-value {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 3.5rem;
}

.score-track {
  flex: 1;
  height: 3px;
  background: var(--border-mid);
  border-radius: 2px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 400ms ease;
}

/* ── Input Row ────────────────────────────────────────── */
.input-row {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  gap: 0.5rem;
  background: var(--bg-surface);
}

.input-prefix {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

.user-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.875rem;
  caret-color: var(--accent);
  min-width: 0;
}

.user-input::placeholder {
  color: var(--text-dim);
}

.send-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--accent-dim);
}

.send-btn:active {
  opacity: 0.8;
}

/* ── Footer ───────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}

.footer-status {
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.72rem;
}

/* ── Learn More Popup ─────────────────────────────────── */
.learn-popup {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 250ms ease, transform 250ms ease;
}

.learn-popup.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.learn-popup-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.learn-popup-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.learn-popup-btn {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--bg);
  background: var(--accent);
  text-decoration: none;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
  transition: background var(--transition);
}

.learn-popup-btn:hover {
  background: var(--accent-dim);
  color: var(--bg);
}

.learn-popup-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color var(--transition);
  flex-shrink: 0;
}

.learn-popup-close:hover {
  color: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────── */

/* Prevent iOS Safari from zooming in on input focus */
@media (max-width: 768px) {
  .user-input {
    font-size: 1rem;
  }
}

@media (max-width: 600px) {
  /* Layout */
  .site-header {
    padding: 0 1rem;
  }

  .header-inner {
    padding: 0;
  }

  .main-content {
    padding: 1.5rem 1rem 1rem;
    gap: 1.5rem;
  }

  /* Hero */
  .hero-title {
    font-size: 2rem;
  }

  .hero-sub {
    font-size: 0.875rem;
  }

  /* Chat window — shorter on small screens, still scrollable */
  .chat-window {
    min-height: 240px;
    max-height: 55vh;
    padding: 1rem;
    gap: 0.75rem;
  }

  /* Slightly smaller message text */
  .message {
    font-size: 0.8rem;
  }

  /* Score bar — compress */
  .score-bar {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  /* Input — full width, no Send button (Enter submits) */
  .input-row {
    padding: 0.75rem 1rem;
  }

  .send-btn {
    display: none;
  }

  /* Popup — full width strip along the bottom */
  .learn-popup {
    bottom: 0;
    right: 0;
    left: 0;
  }

  .learn-popup-inner {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    justify-content: space-between;
    padding: 0.75rem 1rem;
  }

  .learn-popup-text {
    white-space: normal;
    flex: 1;
  }

  /* Footer */
  .site-footer {
    padding: 1rem;
    font-size: 0.72rem;
  }
}
