:root {
  --primary: #4F46E5;
  --primary-light: #EEF2FF;
  --secondary: #F59E0B;
  --success: #10B981;
  --warning: #EF4444;
  --bg-gradient: linear-gradient(135deg, #F0F9FF 0%, #E0E7FF 50%, #F5F3FF 100%);
  --surface: #FFFFFF;
  --text-dark: #1F2937;
  --text-muted: #6B7280;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.07), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-bubble: 0 4px 12px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.app-container {
  width: 100%;
  max-width: 920px;
  height: 94vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 4px solid #E0E7FF;
}

/* Modal logowania */
.auth-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  background: white;
  width: 100%;
  max-width: 440px;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
}

.auth-header {
  text-align: center;
  margin-bottom: 20px;
}

.auth-mascot {
  font-size: 42px;
  margin-bottom: 8px;
}

.auth-header h2 {
  font-family: 'Fredoka', cursive;
  color: #312E81;
  font-size: 24px;
}

.auth-header p {
  color: #64748B;
  font-size: 13px;
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: #F1F5F9;
  padding: 4px;
  border-radius: 12px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  color: #64748B;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 4px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #CBD5E1;
  font-size: 14px;
  font-family: 'Nunito', sans-serif;
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary);
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.auth-submit-btn:hover { background: #4338CA; }
.reg-btn { background: #10B981; }
.reg-btn:hover { background: #059669; }

.reg-info {
  font-size: 11px;
  color: #64748B;
  background: #F8FAFC;
  padding: 8px;
  border-radius: 8px;
  margin: 10px 0;
  line-height: 1.4;
}

.auth-alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
  font-weight: 600;
}
.auth-alert.error { background: #FEE2E2; color: #DC2626; }
.auth-alert.success { background: #D1FAE5; color: #059669; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #F1F5F9;
}

.admin-link {
  color: #64748B;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

/* Górny pasek z logo i profilem ucznia */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #FAF5FF;
  border-bottom: 2px solid #F3E8FF;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mascot-mini {
  font-size: 36px;
  background: #FEF3C7;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid #FDE68A;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  animation: bounce 2.5s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-title {
  font-family: 'Fredoka', cursive;
  font-size: 24px;
  color: #3730A3;
  line-height: 1.1;
}

.logo-subtitle {
  font-size: 12px;
  color: #6B7280;
  font-weight: 600;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.user-name-label {
  font-size: 13px;
  color: #475569;
}

.logout-btn {
  background: #FEE2E2;
  color: #DC2626;
  border: none;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.settings-pill {
  display: flex;
  gap: 10px;
  background: #FFFFFF;
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid #E5E7EB;
}

.pill-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-item label {
  font-size: 12px;
  font-weight: 700;
  color: #4B5563;
}

.pill-item select {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid #D1D5DB;
  border-radius: 12px;
  padding: 4px 8px;
  color: #1F2937;
  outline: none;
  background-color: #F9FAFB;
  cursor: pointer;
}

/* Wstążka pamięci (Ostatnio przerabiany materiał) */
.memory-ribbon {
  background: #EFF6FF;
  border-bottom: 1px solid #DBEAFE;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #1E40AF;
  font-weight: 700;
}

/* Pasek tematu i postępu */
.topic-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  flex-wrap: wrap;
  gap: 12px;
}

.topic-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topic-tag {
  font-size: 13px;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
}

.topic-dropdown {
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #1E293B;
  background: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  border-radius: 10px;
  padding: 5px 12px;
  cursor: pointer;
}

.mastery-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.mastery-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 800;
}

.mastery-label { color: #64748B; }
.mastery-pct { color: #4F46E5; }

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #34D399);
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chat */
.chat-area {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #F8FAFC;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: fadeIn 0.3s ease-out;
}

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

.tutor-msg { align-self: flex-start; }
.user-msg { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 3px 6px rgba(0,0,0,0.08);
}

.tutor-avatar { background: #FEF3C7; border: 2px solid #FCD34D; }
.user-avatar { background: #E0E7FF; border: 2px solid #A5B4FC; }

.bubble-content {
  background: var(--surface);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-bubble);
  border: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-msg .bubble-content {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
}

.speaker-name {
  font-size: 11px;
  font-weight: 800;
  color: #6366F1;
  text-transform: uppercase;
}

.user-msg .speaker-name { display: none; }

.text {
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
  word-break: break-word;
}

.tts-btn {
  align-self: flex-start;
  margin-top: 6px;
  background: #EEF2FF;
  color: #4F46E5;
  border: none;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* Wskaźnik myślenia */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 12px 24px;
  background: #F8FAFC;
}

.mini { width: 32px; height: 32px; font-size: 18px; }

.thinking-bubble {
  background: #FFFFFF;
  padding: 8px 16px;
  border-radius: 16px;
  border: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.thinking-text { font-size: 13px; font-weight: 700; color: #6B7280; }

.dots { display: flex; gap: 4px; }
.dots span {
  width: 6px; height: 6px;
  background: #4F46E5;
  border-radius: 50%;
  animation: dotPulse 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Pytania startowe */
.quick-prompts {
  display: flex;
  gap: 8px;
  padding: 8px 24px;
  background: #FFFFFF;
  border-top: 1px solid #F1F5F9;
  overflow-x: auto;
}

.chip {
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover {
  background: #EEF2FF;
  color: #4338CA;
}

/* Dolny panel wejściowy */
.input-panel {
  background: #FFFFFF;
  padding: 16px 24px;
  border-top: 2px solid #E2E8F0;
}

.input-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input-form input {
  flex: 1;
  padding: 14px 20px;
  border-radius: 30px;
  border: 2px solid #E5E7EB;
  font-size: 15px;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  outline: none;
}

.input-form input:focus { border-color: var(--primary); }

.voice-input-btn {
  background: #F3F4F6;
  border: 2px solid #E5E7EB;
  border-radius: 50%;
  width: 48px; height: 48px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn {
  background: #4F46E5;
  color: #FFFFFF;
  border: none;
  border-radius: 30px;
  padding: 0 24px;
  height: 48px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
