:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --accent: #7c9cff;
  --accent-2: #5eead4;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0f1115;
  font-weight: 700; font-size: 22px;
  border-radius: 10px;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 0.2px; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.status { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.live { color: var(--success); border-color: var(--success); }
.badge.mock { color: var(--warning); border-color: var(--warning); }

button {
  font: inherit;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s, transform 0.05s;
}
button:hover:not(:disabled) { background: #2b3140; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  color: #0f1115;
  border-color: transparent;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: #94afff; }

#app { flex: 1; display: flex; overflow: hidden; }

/* ── Landing ───────────────────────────────────────────────────────────────── */
.landing { flex: 1; display: grid; place-items: center; padding: 24px; }
.card {
  width: 100%; max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.card h2 { margin: 0 0 6px; }
.card .muted { margin: 0 0 22px; }
.card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}
.card input[type="text"] {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
}
.card input[type="text"]:focus { outline: 2px solid var(--accent); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ── Tutor pane ────────────────────────────────────────────────────────────── */
.tutor { flex: 1; display: grid; grid-template-columns: 1fr 360px; gap: 0; overflow: hidden; }
.hidden { display: none !important; }

.chat-pane {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}
.transcript {
  flex: 1; overflow-y: auto;
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 12px;
}
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 14.5px;
  white-space: pre-wrap;
}
.bubble.agent { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.bubble.student { background: var(--accent); color: #0f1115; align-self: flex-end; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.bubble.student .meta { color: rgba(15,17,21,0.7); }
.bubble.kind-misconception { border-left: 3px solid var(--warning); }
.bubble.kind-hint { border-left: 3px solid var(--accent-2); }
.bubble.kind-mastered { border-left: 3px solid var(--success); }
.bubble.kind-advance { border-left: 3px solid var(--accent); }
.bubble.kind-escalate { border-left: 3px solid var(--danger); }
.bubble.kind-done { border-left: 3px solid var(--success); background: rgba(74,222,128,0.06); }
.bubble.kind-question { font-weight: 500; }
.bubble.kind-plan { font-size: 13px; color: var(--muted); }
.bubble.kind-system { font-size: 12px; color: var(--muted); font-style: italic; }

.answer-form {
  display: flex; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.answer-form input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
}
.answer-form input:focus { outline: 2px solid var(--accent); }

/* ── Learner-model panel ───────────────────────────────────────────────────── */
.model-pane {
  background: var(--surface);
  padding: 20px;
  overflow-y: auto;
}
.model-pane h3 { margin: 0 0 4px; font-size: 14px; }
.model-pane .small { font-size: 11px; }
.muted { color: var(--muted); }
.skill-list { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; }
.skill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.skill.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.skill.mastered { border-color: var(--success); }
.skill-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 500;
}
.skill-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.bar {
  margin-top: 8px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}
.skill.mastered .bar > span { background: var(--success); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); margin-bottom: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; margin-right: 5px; vertical-align: middle; }
.dot-mastered { background: var(--success); }
.dot-current { background: var(--accent); }
.dot-pending { background: var(--border); }

.misconceptions { margin-top: 16px; }
.misconceptions h4 { font-size: 12px; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.misconception {
  font-size: 12px;
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.misconception .label { font-weight: 600; color: var(--warning); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid; place-items: center;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: min(680px, 90vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
}
.modal-card h2 { margin: 0 0 12px; }
.modal-card pre {
  flex: 1; overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12.5px;
  white-space: pre-wrap;
  margin: 0 0 14px;
}
