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

:root {
  --purple:      #6C48C5;
  --purple-dark: #5534B0;
  --purple-light:#8B6FD4;
  --purple-pale: #E9E3FF;
  --green:       #22C55E;
  --green-dark:  #16A34A;
  --yellow:      #FBBF24;
  --yellow-dark: #D97706;
  --slate:       #94A3B8;
  --slate-light: #E2E8F0;
  --bg:          #F1F5F9;
  --card:        #FFFFFF;
  --text:        #1E293B;
  --text-muted:  #64748B;
  --radius:      16px;
  --shadow:      0 4px 24px rgba(108, 72, 197, 0.10);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.07);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.screen-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

.screen-top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px 0;
  max-width: 480px;
  margin: 0 auto;
}

.screen-content {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 24px 60px;
}

.step-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Logo ─────────────────────────────────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.logo-text {
  font-size: 28px;
  font-weight: 900;
  color: var(--purple);
  letter-spacing: -0.5px;
}

.logo-owl { display: flex; align-items: center; }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1.hero-heading {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 12px;
}

h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  margin-top: 24px;
}

.hero-sub, .screen-sub {
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.5;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--purple);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  border: none;
  border-radius: 50px;
  padding: 14px 28px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(108,72,197,0.30);
  letter-spacing: 0.01em;
}

.btn-primary:hover { background: var(--purple-dark); box-shadow: 0 6px 20px rgba(108,72,197,0.40); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { background: var(--slate); box-shadow: none; cursor: not-allowed; }

.btn-full { width: 100%; margin-top: 24px; }

.btn-ghost {
  background: none;
  border: 2px solid var(--slate-light);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  border-radius: 50px;
  padding: 10px 22px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  margin-top: 16px;
}

.btn-ghost:hover { border-color: var(--purple-light); color: var(--purple); }

.btn-outline {
  display: inline-block;
  background: none;
  border: 2px solid var(--purple);
  color: var(--purple);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border-radius: 50px;
  padding: 9px 20px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-outline:hover { background: var(--purple); color: #fff; }

.btn-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
  white-space: nowrap;
}

.btn-back:hover { color: var(--purple); }

/* ── Profile Grid ─────────────────────────────────────────────────────────── */
.profile-grid {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 440px;
}

.profile-card {
  flex: 1;
  min-width: 110px;
  max-width: 140px;
  background: var(--card);
  border: 2px solid var(--slate-light);
  border-radius: var(--radius);
  padding: 20px 12px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  text-align: center;
  font-family: inherit;
}

.profile-card:hover {
  border-color: var(--purple);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.profile-badge {
  font-size: 28px;
  margin-bottom: 8px;
  line-height: 1;
}

.profile-card-name {
  font-size: 17px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 2px;
}

.profile-card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 6px;
}

.profile-card-stat {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.profile-session-count {
  display: inline-block;
  margin-top: 8px;
  background: var(--purple-pale);
  color: var(--purple-dark);
  font-size: 10px;
  font-weight: 800;
  border-radius: 20px;
  padding: 3px 8px;
}

/* ── Upload Screen ────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--slate-light);
  border-radius: 50px;
  padding: 4px;
  margin-bottom: 20px;
  margin-top: 16px;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab.active { background: var(--card); color: var(--purple); box-shadow: var(--shadow-sm); }

.drop-zone {
  border: 2px dashed var(--slate-light);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  background: var(--card);
}

.drop-zone.drag-over { border-color: var(--purple); background: var(--purple-pale); }

.drop-zone-icon { display: flex; justify-content: center; margin-bottom: 12px; }

.drop-hint {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

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

.file-selected {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--purple);
  background: var(--purple-pale);
  border-radius: 8px;
  padding: 8px 12px;
}

.text-area {
  width: 100%;
  min-height: 200px;
  border: 2px solid var(--slate-light);
  border-radius: var(--radius);
  padding: 16px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  resize: vertical;
  transition: border-color 0.15s;
  background: var(--card);
  line-height: 1.6;
}

.text-area:focus { outline: none; border-color: var(--purple); }

.error-msg {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #DC2626;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

.hidden { display: none !important; }

/* ── Course Map ───────────────────────────────────────────────────────────── */
.map-container {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 10px 10px;
  box-shadow: var(--shadow-sm);
  margin: 16px 0;
  overflow: hidden;
}

.map-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 12px 0 20px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.strong   { background: var(--green); }
.legend-dot.shaky    { background: var(--yellow); }
.legend-dot.untouched{ background: var(--slate-light); border: 1px solid var(--slate); }

/* ── Tooltip ──────────────────────────────────────────────────────────────── */
.map-tooltip {
  position: absolute;
  z-index: 1000;
  background: var(--card);
  border: 1px solid var(--slate-light);
  border-radius: 12px;
  padding: 14px 16px;
  max-width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  pointer-events: none;
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.tooltip-title { font-size: 14px; font-weight: 800; color: var(--text); }
.tooltip-status { font-size: 12px; font-weight: 700; }
.tooltip-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; margin-bottom: 8px; }

.tooltip-concepts { display: flex; flex-wrap: wrap; gap: 4px; }

.concept-tag {
  background: var(--purple-pale);
  color: var(--purple-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

/* ── Chat Screen ──────────────────────────────────────────────────────────── */
#screen-chat {
  display: none;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#screen-chat.active { display: flex; }

/* Full-width background bands for header and input */
.chat-header-wrap {
  background: var(--card);
  border-bottom: 1px solid var(--slate-light);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.chat-input-outer {
  background: var(--card);
  border-top: 1px solid var(--slate-light);
  flex-shrink: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 14px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.chat-mascot { flex-shrink: 0; display: flex; align-items: flex-end; }

.chat-header-info { flex: 1; min-width: 0; }

.chat-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.progress-bar-wrap {
  height: 8px;
  background: var(--slate-light);
  border-radius: 50px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--purple-light));
  border-radius: 50px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}

.progress-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-messages-inner {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.msg-wrap { display: flex; }
.msg-wrap.msg-model  { justify-content: flex-start; }
.msg-wrap.msg-user   { justify-content: flex-end; }

.msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 600;
  animation: msgIn 0.2s ease;
}

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

.msg-bubble-model {
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.msg-bubble-user {
  background: var(--purple);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 20px;
}

.thinking-dots span {
  width: 7px;
  height: 7px;
  background: var(--slate);
  border-radius: 50%;
  animation: blink 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

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

.chat-input-wrap {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.chat-input {
  flex: 1;
  border: 2px solid var(--slate-light);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  resize: none;
  line-height: 1.4;
  transition: border-color 0.15s;
  background: var(--bg);
}

.chat-input:focus { outline: none; border-color: var(--purple); }
.chat-input:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-mute {
  background: none;
  border: 2px solid var(--slate-light);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  align-self: flex-end;
}
.btn-mute:hover { border-color: var(--purple); background: var(--purple-pale); }
.btn-mute.muted { border-color: #FECACA; background: #FEF2F2; }

.btn-exit-chat {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.btn-exit-chat:hover { background: #FEE2E2; color: #DC2626; }

.chat-demo-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px;
  background: #FFFBEB;
  border-top: 1px solid #FDE68A;
  flex-wrap: wrap;
}
.demo-label {
  font-size: 12px;
  font-weight: 700;
  color: #92400E;
  letter-spacing: 0.04em;
}
.btn-skip-results {
  background: #F59E0B;
  border: none;
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 20px;
  transition: background 0.15s;
}
.btn-skip-results:hover { background: #D97706; }
.btn-come-back {
  background: none;
  border: 1.5px solid #94A3B8;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 20px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-come-back:hover { border-color: var(--text); color: var(--text); }

.btn-send {
  width: 44px;
  height: 44px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background 0.15s, transform 0.1s;
}

.btn-send:hover { background: var(--purple-dark); }
.btn-send:active { transform: scale(0.92); }
.btn-send:disabled { background: var(--slate); cursor: not-allowed; }

/* ── Assessment Banner (end of diagnostic) ───────────────────────────────── */
.assessment-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--purple-pale);
  border: 2px solid var(--purple-light);
  border-radius: 18px;
  padding: 24px 20px 20px;
  margin: 8px 0 16px;
  animation: msgIn 0.3s ease;
}

.assessment-banner-owl { margin-bottom: 10px; }

.assessment-banner-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

.assessment-banner-text strong {
  font-size: 17px;
  font-weight: 800;
  color: var(--purple-dark);
}

.chat-inline-error {
  font-size: 14px;
  font-weight: 600;
  color: #DC2626;
  padding: 10px 14px;
  background: #FEF2F2;
  border-radius: 10px;
  border: 1px solid #FECACA;
  margin: 4px 0;
}

.retry-link {
  background: none;
  border: none;
  color: var(--purple);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ── Results Screen ───────────────────────────────────────────────────────── */
.results-level-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  padding: 6px 18px;
  border-radius: 50px;
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.results-stats {
  display: flex;
  gap: 12px;
  margin: 12px 0 20px;
}

.result-stat {
  flex: 1;
  text-align: center;
  background: var(--card);
  border-radius: 12px;
  padding: 14px 8px;
  box-shadow: var(--shadow-sm);
}

.result-stat .stat-num {
  display: block;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
}

.result-stat .stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-stat.strong .stat-num { color: var(--green-dark); }
.result-stat.shaky  .stat-num { color: var(--yellow-dark); }
.result-stat.untouched .stat-num { color: var(--slate); }

.summary-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
}

.summary-strengths { border-left-color: var(--green); }
.summary-gaps      { border-left-color: var(--yellow); }
.summary-next      { border-left-color: var(--purple); }

.summary-card-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  border-radius: 8px;
  flex-shrink: 0;
}

.summary-strengths .summary-card-icon { background: #DCFCE7; color: var(--green-dark); }
.summary-gaps      .summary-card-icon { background: #FEF9C3; color: #A16207; }
.summary-next      .summary-card-icon { background: var(--purple-pale); color: var(--purple-dark); }

.summary-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.summary-card-body {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
  padding-bottom: 48px;
}

/* ── Progress Chart ───────────────────────────────────────────────────────── */
.history-chart {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
}

.history-chart-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.hist-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 88px;
}

.hist-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.hist-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--purple), var(--purple-light));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.6s cubic-bezier(0.4,0,0.2,1);
}

.hist-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 41, 59, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h3 {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  border: 2px solid var(--slate-light);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  transition: border-color 0.15s;
}

.modal-input:focus { outline: none; border-color: var(--purple); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  h1.hero-heading { font-size: 26px; }
  .profile-grid { gap: 10px; }
  .profile-card { min-width: 90px; padding: 16px 8px 12px; }
  .profile-badge { font-size: 24px; }
}
