* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f5f6fa;
  color: #2d3436;
}

.screen { min-height: 100vh; }

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  text-align: center;
  width: 320px;
}
.login-box input {
  width: 100%;
  padding: 0.7rem;
  margin: 1rem 0;
  border-radius: 8px;
  border: 1px solid #dfe4ea;
}
.login-box button {
  width: 100%;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: #6c5ce7;
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.error { color: #d63031; min-height: 1.2em; }

.mascot-img { width: 90px; height: auto; display: block; margin: 0 auto; }
.mascot-login { width: 110px; margin-bottom: 0.5rem; }
.mascot-box { text-align: center; margin-bottom: 1rem; }
.mascot-name { color: #FFD93B; font-weight: 700; margin-top: 0.3rem; font-size: 0.95rem; }

#app-screen {
  display: flex;
}

.sidebar {
  width: 240px;
  background: #2d3436;
  color: white;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
  min-height: 100vh;
}
.sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: #b2bec3;
  margin: 1.5rem 0 0.5rem;
}
.student-list, .subject-list { display: flex; flex-direction: column; gap: 0.4rem; }
.student-btn, .subject-btn, .nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.8rem;
  border: none;
  border-radius: 8px;
  background: #3d4548;
  color: white;
  cursor: pointer;
  margin-bottom: 0.3rem;
}
.student-btn.active, .subject-btn.active, .nav-btn.active { background: #6c5ce7; }
.logout-btn {
  margin-top: 2rem;
  background: transparent;
  border: 1px solid #636e72;
  color: #dfe6e9;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
}

.content { flex: 1; padding: 2rem; max-width: 900px; }
.view { display: none; }
.view.active { display: block; }

.mascot3d-container {
  width: 100%;
  height: 240px;
  margin-bottom: 1rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #eef1ff 0%, #f5f6fa 100%);
  overflow: hidden;
}
.mascot3d-container canvas { display: block; width: 100%; height: 100%; }

.chat-window {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  height: 45vh;
  overflow-y: auto;
  margin-bottom: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.msg-row { display: flex; align-items: flex-end; gap: 0.5rem; margin-bottom: 1rem; }
.msg-row.user { justify-content: flex-end; }
.msg-avatar { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: #FFD93B; padding: 3px; }
.msg { max-width: 78%; padding: 0.6rem 0.9rem; border-radius: 12px; line-height: 1.4; white-space: pre-wrap; margin-bottom: 0; }
.msg.user { background: #6c5ce7; color: white; }
.msg.assistant { background: #f1f2f6; }

.chat-input-row { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.chat-input-row textarea {
  flex: 1;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid #dfe4ea;
  font-family: inherit;
  resize: vertical;
}
#mic-btn, #send-btn {
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: #6c5ce7;
  color: white;
  cursor: pointer;
}
#mic-btn.recording { background: #d63031; }
.voice-toggle { width: 100%; font-size: 0.85rem; color: #636e72; }

.schedule-form, #upload-form { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.schedule-form select, .schedule-form input, #upload-form select, #upload-form input {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid #dfe4ea;
}
.schedule-form button, #upload-form button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: #6c5ce7;
  color: white;
  cursor: pointer;
}

.schedule-item, .progress-item {
  background: white;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.status-mastered { color: #00b894; font-weight: 600; }
.status-in_progress { color: #fdcb6e; font-weight: 600; }
.status-struggling { color: #d63031; font-weight: 600; }

.remove-btn { background: none; border: none; color: #d63031; cursor: pointer; font-size: 1.1rem; }

/* --- Мобильная версия --- */
@media (max-width: 768px) {
  #app-screen { flex-direction: column; }

  .sidebar {
    width: 100%;
    min-height: auto;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }
  .sidebar h2 { margin: 0.6rem 0 0.3rem; }
  .mascot-box .mascot-img { width: 56px; }
  .mascot-box { margin-bottom: 0.3rem; }

  .student-list, .subject-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.2rem;
  }
  .student-btn, .subject-btn {
    width: auto;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .logout-btn { margin-top: 0.8rem; }

  .content { padding: 1rem; max-width: 100%; }

  .mascot3d-container { height: 170px; }
  .chat-window { height: 42vh; }

  .chat-input-row textarea,
  .login-box input,
  .schedule-form select,
  .schedule-form input,
  #upload-form select,
  #upload-form input {
    font-size: 16px; /* чтобы iOS Safari не увеличивал экран при фокусе */
  }

  #mic-btn, #send-btn {
    padding: 0.9rem 1.1rem;
    font-size: 1rem;
  }

  .msg { max-width: 92%; }

  .schedule-form, #upload-form { flex-direction: column; align-items: stretch; }
}
