@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Quicksand:wght@500;600;700&display=swap');

:root {
  --bg: #14102B;
  --surface: #201A44;
  --surface-2: #2A2258;
  --purple: #7B2FBE;
  --green: #AAFF00;
  --coral: #FF6B6B;
  --gold: #FFD166;
  --text: #F5F3FF;
  --text-dim: #B6ADD9;
  --radius: 24px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Quicksand', sans-serif; height: 100%; overscroll-behavior-y: none; }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, .display { font-family: 'Baloo 2', sans-serif; font-weight: 700; margin: 0; }

.screen { display: none; flex-direction: column; flex: 1; animation: fadeIn .25s ease; }
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.pad { padding: 20px 18px 32px; }

/* Buttons / inputs (shared) */
.btn { font-family: 'Baloo 2'; font-weight: 700; font-size: 1rem; border: none; border-radius: 999px; padding: 15px 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s ease, filter .12s ease; }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--green); color: #14102B; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 2px solid var(--surface-2); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"] {
  width: 100%; padding: 14px 16px; border-radius: var(--radius-sm); border: 2px solid var(--surface-2);
  background: var(--surface); color: var(--text); font-family: 'Quicksand'; font-size: 1rem;
}
label.field-label { font-family: 'Baloo 2'; font-size: 0.9rem; margin-bottom: 4px; display: block; }
.field { display: flex; flex-direction: column; gap: 6px; }
.subtitle { color: var(--text-dim); font-size: 0.95rem; }
.error-text { color: var(--coral); font-size: 0.88rem; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* AUTH */
#screen-auth .pad { justify-content: center; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.auth-logo { text-align: center; }
.auth-logo img { width: 90px; height: 90px; }
.auth-toggle { text-align: center; font-size: 0.9rem; color: var(--text-dim); }
.auth-toggle a { color: var(--green); cursor: pointer; font-weight: 700; }

/* TOPBAR */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--surface); }
.stat { display: flex; align-items: center; gap: 6px; font-family: 'Baloo 2'; font-size: 0.9rem; }
.xp-bar-wrap { flex: 1; height: 8px; background: #0e0c22; border-radius: 20px; overflow: hidden; margin: 0 8px; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--green)); border-radius: 20px; transition: width .5s ease; }
.icon-btn { background: none; border: none; color: var(--text-dim); font-size: 1.3rem; cursor: pointer; }

/* HOME / lists */
.list-item { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px; cursor: pointer; }
.list-item .badge { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Baloo 2'; font-weight: 700; font-size: 0.85rem; background: var(--surface-2); flex-shrink: 0; }
.list-item .info { flex: 1; }
.list-item .info .name { font-family: 'Baloo 2'; font-size: 0.98rem; }
.list-item .info .sub { font-size: 0.82rem; color: var(--text-dim); }
.list { display: flex; flex-direction: column; gap: 10px; }

/* SETUP */
.upload-zone { border: 2px dashed var(--surface-2); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: var(--text-dim); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 2px solid var(--surface-2); }
input[type="file"] { display: none; }

/* CHAT */
#screen-chat { height: 100vh; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); }
.chat-header img { width: 34px; height: 34px; }
.chat-header .title { font-family: 'Baloo 2'; font-size: 1rem; flex: 1; }
.topics-strip { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; background: var(--bg); }
.topic-chip { flex-shrink: 0; background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 0.78rem; font-family: 'Baloo 2'; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.topic-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.messages { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 12px 15px; border-radius: 18px; line-height: 1.45; font-size: 0.95rem; white-space: pre-wrap; }
.msg.assistant { background: var(--surface); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--purple); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.msg-thumbs img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }

.quiz-card { align-self: stretch; background: var(--surface); border: 2px solid var(--surface-2); border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.quiz-card .q-text { font-family: 'Baloo 2'; font-weight: 600; font-size: 1rem; }
.quiz-option { background: var(--surface-2); border: 2px solid transparent; border-radius: var(--radius-sm); padding: 12px 14px; font-family: 'Quicksand'; font-weight: 600; font-size: 0.92rem; color: var(--text); cursor: pointer; text-align: left; }
.quiz-option.correct { background: rgba(170,255,0,.18); border-color: var(--green); }
.quiz-option.wrong { background: rgba(255,107,107,.18); border-color: var(--coral); }
.quiz-option.disabled { pointer-events: none; opacity: .7; }
.quiz-explain { font-size: 0.85rem; color: var(--text-dim); }

.typing-indicator { align-self: flex-start; display: flex; gap: 4px; padding: 12px 15px; background: var(--surface); border-radius: 18px; }
.typing-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: blink 1.2s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.chat-input-bar { display: flex; gap: 8px; padding: 10px 12px; background: var(--surface); align-items: flex-end; }
.chat-input-bar textarea { flex: 1; resize: none; max-height: 90px; border-radius: 18px; border: 2px solid var(--surface-2); background: var(--bg); color: var(--text); padding: 10px 14px; font-family: 'Quicksand'; font-size: 0.95rem; }
.send-btn, .attach-btn { width: 44px; height: 44px; border-radius: 50%; border: none; flex-shrink: 0; font-size: 1.2rem; cursor: pointer; }
.send-btn { background: var(--green); color: #14102B; }
.attach-btn { background: var(--surface-2); color: var(--text); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2); padding: 10px 18px; border-radius: 999px; font-family: 'Baloo 2'; font-size: 0.9rem; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 50; }
.hidden { display: none !important; }
